]> git.openstreetmap.org Git - rails.git/blobdiff - app/assets/javascripts/leaflet.sidebar.js
Start to make turn-by-turn instructions clickable
[rails.git] / app / assets / javascripts / leaflet.sidebar.js
index 961842668f25432a3c4905e8df6f8b9a3163fc58..db9e7aef2505228010751b145e38771e48cc7564 100644 (file)
@@ -2,6 +2,7 @@ L.OSM.sidebar = function(selector) {
   var control = {},
     sidebar = $(selector),
     current = $(),
+    currentButton  = $(),
     map;
 
   control.addTo = function (_) {
@@ -15,24 +16,31 @@ L.OSM.sidebar = function(selector) {
       .appendTo(sidebar);
   };
 
-  control.togglePane = function(pane) {
+  control.togglePane = function(pane, button) {
     current
       .hide()
       .trigger('hide');
 
+    currentButton
+      .removeClass('active');
+
     if (current === pane) {
       $(sidebar).hide();
-      current = $();
+      current = currentButton = $();
     } else {
       $(sidebar).show();
       current = pane;
+      currentButton = button || $();
     }
 
+    map.invalidateSize({pan: false, animate: false});
+
     current
       .show()
       .trigger('show');
 
-    map.invalidateSize({pan: false, animate: false});
+    currentButton
+      .addClass('active');
   };
 
   return control;