]> 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 8c4dee308ada2bb36068aaf2f7fe430a9501279c..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");
+
+    currentButton
+      .addClass("active");
   };
 
   return control;