Add/remove active class on map UI buttons

This commit is contained in:
John Firebaugh 2013-07-31 13:56:51 -07:00
parent a125ee829a
commit fa9b4a5f6a
5 changed files with 20 additions and 12 deletions

View file

@ -2,6 +2,7 @@ L.OSM.sidebar = function(selector) {
var control = {},
sidebar = $(selector),
current = $(),
currentButton = $(),
map;
control.addTo = function (_) {
@ -15,17 +16,21 @@ 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});
@ -33,6 +38,9 @@ L.OSM.sidebar = function(selector) {
current
.show()
.trigger('show');
currentButton
.addClass('active');
};
return control;