From 71e7208a0aceccf47edce739803130096999da5d Mon Sep 17 00:00:00 2001 From: Anton Khorev Date: Sat, 27 Aug 2022 20:54:37 +0300 Subject: [PATCH] Create pane button fn --- app/assets/javascripts/leaflet.key.js | 6 +----- app/assets/javascripts/leaflet.layers.js | 7 +------ app/assets/javascripts/leaflet.share.js | 7 +------ app/assets/javascripts/leaflet.sidebar-pane.js | 14 ++++++++++++++ 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/app/assets/javascripts/leaflet.key.js b/app/assets/javascripts/leaflet.key.js index 46c4661d2..238d70c5f 100644 --- a/app/assets/javascripts/leaflet.key.js +++ b/app/assets/javascripts/leaflet.key.js @@ -5,11 +5,7 @@ L.OSM.key = function (options) { var $container = $("
") .attr("class", "control-key"); - var button = $("") - .attr("class", "control-button") - .attr("href", "#") - .html("") - .on("click", toggle) + var button = this.makeButton("key", null, toggle) .appendTo($container); var $ui = this.makeUI("key-ui", "javascripts.key.title", toggle); diff --git a/app/assets/javascripts/leaflet.layers.js b/app/assets/javascripts/leaflet.layers.js index 518cdc7f1..9ef2d759e 100644 --- a/app/assets/javascripts/leaflet.layers.js +++ b/app/assets/javascripts/leaflet.layers.js @@ -7,12 +7,7 @@ L.OSM.layers = function (options) { var $container = $("
") .attr("class", "control-layers"); - var button = $("") - .attr("class", "control-button") - .attr("href", "#") - .attr("title", I18n.t("javascripts.map.layers.title")) - .html("") - .on("click", toggle) + var button = this.makeButton("layers", "javascripts.map.layers.title", toggle) .appendTo($container); var $ui = this.makeUI("layers-ui", "javascripts.map.layers.header", toggle); diff --git a/app/assets/javascripts/leaflet.share.js b/app/assets/javascripts/leaflet.share.js index 875008cfc..c518eb4e9 100644 --- a/app/assets/javascripts/leaflet.share.js +++ b/app/assets/javascripts/leaflet.share.js @@ -10,12 +10,7 @@ L.OSM.share = function (options) { var $container = $("
") .attr("class", "control-share"); - var button = $("") - .attr("class", "control-button") - .attr("href", "#") - .attr("title", I18n.t("javascripts.share.title")) - .html("") - .on("click", toggle) + var button = this.makeButton("share", "javascripts.share.title", toggle) .appendTo($container); var $ui = this.makeUI("share-ui", "javascripts.share.title", toggle); diff --git a/app/assets/javascripts/leaflet.sidebar-pane.js b/app/assets/javascripts/leaflet.sidebar-pane.js index f087cbb4a..fff0b4063 100644 --- a/app/assets/javascripts/leaflet.sidebar-pane.js +++ b/app/assets/javascripts/leaflet.sidebar-pane.js @@ -1,6 +1,20 @@ L.OSM.sidebarPane = function (options) { var control = L.control(options); + control.makeButton = function (buttonClass, buttonTitle, toggle) { + var button = $("") + .attr("class", "control-button") + .attr("href", "#") + .html("") + .on("click", toggle); + + if (buttonTitle) { + button.attr("title", I18n.t(buttonTitle)) + } + + return button; + }; + control.makeUI = function (uiClass, paneTitle, toggle) { var $ui = $("
") .attr("class", uiClass); -- 2.39.5