]> git.openstreetmap.org Git - rails.git/blobdiff - app/assets/javascripts/leaflet.note.js
Merge pull request #5449 from AntonKhorev/edit-preferences
[rails.git] / app / assets / javascripts / leaflet.note.js
index 8451e9b72eb3742c3d4a08cfcfa708641d45a23b..19fc9392c0af65497bf686f8e0c24020cdba3050 100644 (file)
@@ -2,24 +2,31 @@ 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");
 
-    var link = $('<a>')
-      .attr('class', 'control-button')
-      .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);
+    map.on("zoomend", update);
 
     function update() {
-      var disabled = OSM.STATUS === "database_offline" || map.getZoom() < 12;
+      var wasDisabled = link.hasClass("disabled"),
+          isDisabled = 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'));
+        .toggleClass("disabled", isDisabled)
+        .attr("data-bs-original-title", I18n.t(isDisabled ?
+          "javascripts.site.createnote_disabled_tooltip" :
+          "javascripts.site.createnote_tooltip"));
+
+      if (isDisabled && !wasDisabled) {
+        link.trigger("disabled");
+      } else if (wasDisabled && !isDisabled) {
+        link.trigger("enabled");
+      }
     }
 
     update();