]> git.openstreetmap.org Git - rails.git/blob - app/assets/javascripts/leaflet.sidebar.js
a6529ad0087d35ded17371569444fb6cfa3c2dac
[rails.git] / app / assets / javascripts / leaflet.sidebar.js
1 L.OSM.sidebar = function(selector) {
2   var control = {},
3     sidebar = $(selector),
4     current = $();
5
6   control.addPane = function(pane) {
7     pane
8       .hide()
9       .appendTo(sidebar);
10   };
11
12   control.togglePane = function(pane) {
13     var controlContainer = $('.leaflet-control-container .leaflet-top.leaflet-right');
14
15     current
16       .hide()
17       .trigger('hide');
18
19     if (current === pane) {
20       $(sidebar).hide();
21       controlContainer.css({paddingRight: '0'});
22       current = $();
23     } else {
24       $(sidebar).show();
25       controlContainer.css({paddingRight: '200px'});
26       current = pane;
27     }
28
29     current
30       .show()
31       .trigger('show');
32   };
33
34   return control;
35 };