From 68776e378c01f3b09b07ec7c402fbf6517740c5f Mon Sep 17 00:00:00 2001 From: Andy Allan Date: Wed, 3 Aug 2022 15:20:17 +0100 Subject: [PATCH] Fix remaining tooltips, and add tests These were broken during the upgrade to bootstrap 5 Fixes #3632 --- app/assets/javascripts/application.js | 2 +- app/assets/javascripts/leaflet.layers.js | 2 +- app/assets/javascripts/leaflet.note.js | 2 +- app/assets/javascripts/leaflet.query.js | 2 +- test/system/site_test.rb | 31 ++++++++++++++++++++++++ 5 files changed, 35 insertions(+), 4 deletions(-) diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index d5b16bbfb..740990fb3 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -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 diff --git a/app/assets/javascripts/leaflet.layers.js b/app/assets/javascripts/leaflet.layers.js index 5c5e43c5c..0f8e6c4d2 100644 --- a/app/assets/javascripts/leaflet.layers.js +++ b/app/assets/javascripts/leaflet.layers.js @@ -171,7 +171,7 @@ L.OSM.layers = function (options) { } $(item).attr("class", disabled ? "disabled" : ""); - item.attr("data-original-title", disabled ? + item.attr("data-bs-original-title", disabled ? I18n.t("javascripts.site.map_" + name + "_zoom_in_tooltip") : ""); }); }; diff --git a/app/assets/javascripts/leaflet.note.js b/app/assets/javascripts/leaflet.note.js index 86c455499..5f8010967 100644 --- a/app/assets/javascripts/leaflet.note.js +++ b/app/assets/javascripts/leaflet.note.js @@ -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")); } diff --git a/app/assets/javascripts/leaflet.query.js b/app/assets/javascripts/leaflet.query.js index 5f449c214..00292b74d 100644 --- a/app/assets/javascripts/leaflet.query.js +++ b/app/assets/javascripts/leaflet.query.js @@ -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")); diff --git a/test/system/site_test.rb b/test/system/site_test.rb index b9d7bcd57..a08f7f344 100644 --- a/test/system/site_test.rb +++ b/test/system/site_test.rb @@ -37,4 +37,35 @@ class SiteTest < ApplicationSystemTestCase tooltip.assert_text "Map Key" tooltip.assert_text "not available" end + + test "tooltip shows for query button when zoomed in" do + visit "/#map=14/0/0" + + assert_no_selector ".tooltip" + button = find ".control-query .control-button" + button.hover + tooltip = find ".tooltip" + tooltip.assert_text "Query features" + tooltip.assert_no_text "Zoom in" + end + + test "tooltip shows for query button when zoomed out" do + visit "/#map=10/0/0" + + assert_no_selector ".tooltip" + button = find ".control-query .control-button" + button.hover + tooltip = find ".tooltip" + tooltip.assert_text "Zoom in to query features" + end + + test "tooltip shows for edit button when zoomed out" do + visit "/#map=11/0/0" + + assert_no_selector ".tooltip" + button = find "#edit_tab" + button.hover + tooltip = find ".tooltip" + tooltip.assert_text "Zoom in to edit the map" + end end -- 2.39.5