]> git.openstreetmap.org Git - rails.git/blobdiff - app/assets/javascripts/leaflet.note.js
Replace some legacy routes with redirects
[rails.git] / app / assets / javascripts / leaflet.note.js
index 68e09c88deb90a4403479d5b30660f53f04c522a..c0f72af208eee184b3e0de58e0f2bcd3bb9216de 100644 (file)
@@ -5,23 +5,23 @@ L.OSM.note = function (options) {
     var $container = $('<div>')
       .attr('class', 'control-note');
 
-    $('<a>')
+    var link = $('<a>')
       .attr('class', 'control-button')
       .attr('href', '#')
-      .attr('title', 'Notes')
       .html('<span class="icon note"></span>')
-      .on('click', toggle)
       .appendTo($container);
 
-    function toggle(e) {
-      e.stopPropagation();
-      e.preventDefault();
+    map.on('zoomend', update);
 
-      if (map.hasLayer(map.noteLayer)) {
-        map.removeLayer(map.noteLayer);
-      } else {
-        map.addLayer(map.noteLayer);
-      }
+    update();
+
+    function update() {
+      var disabled = map.getZoom() < 12;
+      link
+        .toggleClass('disabled', disabled)
+        .attr('data-original-title', I18n.t(disabled ?
+          'javascripts.site.createnote_disabled_tooltip' :
+          'javascripts.site.createnote_tooltip'));
     }
 
     return $container[0];