]> git.openstreetmap.org Git - rails.git/commitdiff
Fix zoom level related tooltips except for layer checkboxes
authorAnton Khorev <tony29@yandex.ru>
Fri, 29 Jul 2022 15:07:32 +0000 (18:07 +0300)
committerAnton Khorev <tony29@yandex.ru>
Fri, 29 Jul 2022 15:07:32 +0000 (18:07 +0300)
app/assets/javascripts/application.js
app/assets/javascripts/leaflet.layers.js
app/assets/javascripts/leaflet.note.js
app/assets/javascripts/leaflet.query.js
test/system/site_test.rb

index d5b16bbfb293c3019bee839066dfe803b4e87941..740990fb300521794789bbde90e089406e544ad7 100644 (file)
@@ -59,7 +59,7 @@ window.updateLinks = function (loc, zoom, layers, object) {
   var editDisabled = zoom < 13;
   $("#edit_tab")
     .tooltip({ placement: "bottom" })
-    .attr("data-original-title", editDisabled ?
+    .attr("data-bs-original-title", editDisabled ?
       I18n.t("javascripts.site.edit_disabled_tooltip") : "")
     // Disable the button group and also the buttons to avoid
     // inconsistent behaviour when zooming
index 5c5e43c5c20351b3abf537a9bd55d13f5078dff2..faca07e3c18d0297b686160e2fd139a5a64c6605 100644 (file)
@@ -171,6 +171,7 @@ L.OSM.layers = function (options) {
           }
 
           $(item).attr("class", disabled ? "disabled" : "");
+          // item.attr("data-bs-original-title", disabled ? // has additional bug when zooming out from enabled state
           item.attr("data-original-title", disabled ?
             I18n.t("javascripts.site.map_" + name + "_zoom_in_tooltip") : "");
         });
index 86c4554996007bae71f9b3ac37bc7105c5b1e662..5f801096731793a376ca0c3cdf0f729c2c2312a5 100644 (file)
@@ -17,7 +17,7 @@ L.OSM.note = function (options) {
       var disabled = OSM.STATUS === "database_offline" || map.getZoom() < 12;
       link
         .toggleClass("disabled", disabled)
-        .attr("data-original-title", I18n.t(disabled ?
+        .attr("data-bs-original-title", I18n.t(disabled ?
           "javascripts.site.createnote_disabled_tooltip" :
           "javascripts.site.createnote_tooltip"));
     }
index 5f449c214a31c782f67655e319a497073d0a71c4..00292b74dbfbb3ef6262dd50e949ad50bbc63d32 100644 (file)
@@ -20,7 +20,7 @@ L.OSM.query = function (options) {
           isDisabled = map.getZoom() < 14;
       link
         .toggleClass("disabled", isDisabled)
-        .attr("data-original-title", I18n.t(isDisabled ?
+        .attr("data-bs-original-title", I18n.t(isDisabled ?
           "javascripts.site.queryfeature_disabled_tooltip" :
           "javascripts.site.queryfeature_tooltip"));
 
index b9d7bcd571781b29bbeab6bc198c0e33607d86fd..6dd8550d1795ba1132bc70d9198ae4277b9f86e6 100644 (file)
@@ -37,4 +37,18 @@ class SiteTest < ApplicationSystemTestCase
     tooltip.assert_text "Map Key"
     tooltip.assert_text "not available"
   end
+
+  [
+    "#edit_tab",
+    ".control-note .control-button",
+    ".control-query .control-button"
+  ].each do |selector|
+    test "tooltips on low zoom levels for disabled control '#{selector}'" do
+      visit "/#map=1/1/1"
+
+      assert_no_selector ".tooltip"
+      find(selector).hover
+      assert_selector ".tooltip", :text => "Zoom in"
+    end
+  end
 end