]> git.openstreetmap.org Git - rails.git/blobdiff - app/assets/javascripts/leaflet.note.js
Fix #2402
[rails.git] / app / assets / javascripts / leaflet.note.js
index a38e012de63cff6f3640ef8b962b127275bd793f..86c4554996007bae71f9b3ac37bc7105c5b1e662 100644 (file)
@@ -2,17 +2,28 @@ L.OSM.note = function (options) {
   var control = L.control(options);
 
   control.onAdd = function (map) {
-    var $container = $('<div>')
-      .attr('class', 'control-note');
+    var $container = $("<div>")
+      .attr("class", "control-note");
 
-    $('<a>')
-      .attr('id', 'createnoteanchor')
-      .attr('class', 'control-button geolink')
-      .attr('data-minzoom', 12)
-      .attr('href', '#')
-      .html('<span class="icon note"></span>')
+    var link = $("<a>")
+      .attr("class", "control-button")
+      .attr("href", "#")
+      .html("<span class=\"icon note\"></span>")
       .appendTo($container);
 
+    map.on("zoomend", update);
+
+    function update() {
+      var disabled = OSM.STATUS === "database_offline" || map.getZoom() < 12;
+      link
+        .toggleClass("disabled", disabled)
+        .attr("data-original-title", I18n.t(disabled ?
+          "javascripts.site.createnote_disabled_tooltip" :
+          "javascripts.site.createnote_tooltip"));
+    }
+
+    update();
+
     return $container[0];
   };