]> git.openstreetmap.org Git - rails.git/blobdiff - app/assets/javascripts/leaflet.note.js
Move routing engines into their own files
[rails.git] / app / assets / javascripts / leaflet.note.js
index a38e012de63cff6f3640ef8b962b127275bd793f..c0f72af208eee184b3e0de58e0f2bcd3bb9216de 100644 (file)
@@ -5,14 +5,25 @@ L.OSM.note = function (options) {
     var $container = $('<div>')
       .attr('class', 'control-note');
 
-    $('<a>')
-      .attr('id', 'createnoteanchor')
-      .attr('class', 'control-button geolink')
-      .attr('data-minzoom', 12)
+    var link = $('<a>')
+      .attr('class', 'control-button')
       .attr('href', '#')
       .html('<span class="icon note"></span>')
       .appendTo($container);
 
+    map.on('zoomend', update);
+
+    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];
   };