]> git.openstreetmap.org Git - rails.git/blob - app/assets/javascripts/leaflet.sidebar-pane.js
Create pane button fn
[rails.git] / app / assets / javascripts / leaflet.sidebar-pane.js
1 L.OSM.sidebarPane = function (options) {
2   var control = L.control(options);
3
4   control.makeButton = function (buttonClass, buttonTitle, toggle) {
5     var button =  $("<a>")
6       .attr("class", "control-button")
7       .attr("href", "#")
8       .html("<span class=\"icon " + buttonClass + "\"></span>")
9       .on("click", toggle);
10     
11     if (buttonTitle) {
12       button.attr("title", I18n.t(buttonTitle))
13     }
14
15     return button;
16   };
17
18   control.makeUI = function (uiClass, paneTitle, toggle) {
19     var $ui = $("<div>")
20       .attr("class", uiClass);
21
22     $("<div>")
23       .attr("class", "sidebar_heading")
24       .appendTo($ui)
25       .append(
26         $("<button type='button' class='btn-close float-end mt-1'>")
27           .attr("aria-label", I18n.t("javascripts.close"))
28           .bind("click", toggle))
29       .append(
30         $("<h4>")
31           .text(I18n.t(paneTitle)));
32
33     return $ui;
34   };
35
36   return control;
37 };