]> git.openstreetmap.org Git - rails.git/blobdiff - app/assets/javascripts/leaflet.sidebar.js
Use double quotes consistently in javascript code
[rails.git] / app / assets / javascripts / leaflet.sidebar.js
index 961842668f25432a3c4905e8df6f8b9a3163fc58..240e79a5095f16e957bc640df041622c382b5ec9 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');
+      .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');
+      .trigger("show");
 
-    map.invalidateSize({pan: false, animate: false});
+    currentButton
+      .addClass("active");
   };
 
   return control;