X-Git-Url: https://git.openstreetmap.org/rails.git/blobdiff_plain/71e7208a0aceccf47edce739803130096999da5d..9acde429bf8e92c67233461e8a6f5074eb2ff637:/app/assets/javascripts/leaflet.sidebar-pane.js diff --git a/app/assets/javascripts/leaflet.sidebar-pane.js b/app/assets/javascripts/leaflet.sidebar-pane.js index fff0b4063..2dc3479f2 100644 --- a/app/assets/javascripts/leaflet.sidebar-pane.js +++ b/app/assets/javascripts/leaflet.sidebar-pane.js @@ -1,23 +1,24 @@ -L.OSM.sidebarPane = function (options) { +L.OSM.sidebarPane = function (options, uiClass, buttonTitle, paneTitle) { var control = L.control(options); + + control.onAdd = function (map) { + var $container = $("
") + .attr("class", "control-" + uiClass); - control.makeButton = function (buttonClass, buttonTitle, toggle) { var button = $("") .attr("class", "control-button") .attr("href", "#") - .html("") + .html("") .on("click", toggle); if (buttonTitle) { - button.attr("title", I18n.t(buttonTitle)) + button.attr("title", I18n.t(buttonTitle)); } - return button; - }; + button.appendTo($container); - control.makeUI = function (uiClass, paneTitle, toggle) { var $ui = $("
") - .attr("class", uiClass); + .attr("class", uiClass + "-ui"); $("
") .attr("class", "sidebar_heading") @@ -30,8 +31,24 @@ L.OSM.sidebarPane = function (options) { $("

") .text(I18n.t(paneTitle))); - return $ui; - }; + options.sidebar.addPane($ui); + + this.onAddPane(map, button, $ui, toggle); + + function toggle(e) { + e.stopPropagation(); + e.preventDefault(); + if (!button.hasClass("disabled")) { + options.sidebar.togglePane($ui, button); + } + $(".leaflet-control .control-button").tooltip("hide"); + } + + return $container[0]; + } + + // control.onAddPane = function (map, button, $ui, toggle) { + // } return control; };