]> git.openstreetmap.org Git - rails.git/commitdiff
Create pane button fn
authorAnton Khorev <tony29@yandex.ru>
Sat, 27 Aug 2022 17:54:37 +0000 (20:54 +0300)
committerAnton Khorev <tony29@yandex.ru>
Sat, 27 Aug 2022 17:54:37 +0000 (20:54 +0300)
app/assets/javascripts/leaflet.key.js
app/assets/javascripts/leaflet.layers.js
app/assets/javascripts/leaflet.share.js
app/assets/javascripts/leaflet.sidebar-pane.js

index 46c4661d2b0bd31e027a30a70348e2e798f195e4..238d70c5f25c08c71688a9e9c851ba338268d9be 100644 (file)
@@ -5,11 +5,7 @@ L.OSM.key = function (options) {
     var $container = $("<div>")
       .attr("class", "control-key");
 
-    var button = $("<a>")
-      .attr("class", "control-button")
-      .attr("href", "#")
-      .html("<span class=\"icon key\"></span>")
-      .on("click", toggle)
+    var button = this.makeButton("key", null, toggle)
       .appendTo($container);
 
     var $ui = this.makeUI("key-ui", "javascripts.key.title", toggle);
index 518cdc7f173a96bb1d36bb2e8c993d925ffaf683..9ef2d759eea4af789f5c0d9a6882fa5d9b187528 100644 (file)
@@ -7,12 +7,7 @@ L.OSM.layers = function (options) {
     var $container = $("<div>")
       .attr("class", "control-layers");
 
-    var button = $("<a>")
-      .attr("class", "control-button")
-      .attr("href", "#")
-      .attr("title", I18n.t("javascripts.map.layers.title"))
-      .html("<span class=\"icon layers\"></span>")
-      .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);
index 875008cfc7450bab96deb64b0c3d8c20f52de8b2..c518eb4e9de2e96a6cbdc81f79b5b7204012db91 100644 (file)
@@ -10,12 +10,7 @@ L.OSM.share = function (options) {
     var $container = $("<div>")
       .attr("class", "control-share");
 
-    var button = $("<a>")
-      .attr("class", "control-button")
-      .attr("href", "#")
-      .attr("title", I18n.t("javascripts.share.title"))
-      .html("<span class=\"icon share\"></span>")
-      .on("click", toggle)
+    var button = this.makeButton("share", "javascripts.share.title", toggle)
       .appendTo($container);
 
     var $ui = this.makeUI("share-ui", "javascripts.share.title", toggle);
index f087cbb4a5845b30123f9fb8706cfa522a63d9f1..fff0b40631931b93f023f162a04e4b2548c2c17e 100644 (file)
@@ -1,6 +1,20 @@
 L.OSM.sidebarPane = function (options) {
   var control = L.control(options);
 
+  control.makeButton = function (buttonClass, buttonTitle, toggle) {
+    var button =  $("<a>")
+      .attr("class", "control-button")
+      .attr("href", "#")
+      .html("<span class=\"icon " + buttonClass + "\"></span>")
+      .on("click", toggle);
+    
+    if (buttonTitle) {
+      button.attr("title", I18n.t(buttonTitle))
+    }
+
+    return button;
+  };
+
   control.makeUI = function (uiClass, paneTitle, toggle) {
     var $ui = $("<div>")
       .attr("class", uiClass);