From cf3fa3bb2d0beb67ac4944941fc33080b56f0d66 Mon Sep 17 00:00:00 2001 From: Anton Khorev Date: Fri, 23 Sep 2022 13:34:40 +0300 Subject: [PATCH] Use jquery interface for enabling/disabling tooltips --- app/assets/javascripts/application.js | 15 +++++---------- app/assets/javascripts/leaflet.layers.js | 18 ++++++------------ config/eslint.json | 1 - test/system/site_test.rb | 2 +- 4 files changed, 12 insertions(+), 24 deletions(-) diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index 8b8beb5b4..24d50dcce 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -56,20 +56,15 @@ window.updateLinks = function (loc, zoom, layers, object) { link.href = href; }); + // Disable the button group and also the buttons to avoid + // inconsistent behaviour when zooming var editDisabled = zoom < 13; - var editTab = $("#edit_tab"); - editTab - // Disable the button group and also the buttons to avoid - // inconsistent behaviour when zooming + $("#edit_tab") + .tooltip({ placement: "bottom" }) + .tooltip(editDisabled ? "enable" : "disable") .toggleClass("disabled", editDisabled) .find("a") .toggleClass("disabled", editDisabled); - var editTooltip = bootstrap.Tooltip.getOrCreateInstance(editTab[0], { placement: "bottom" }); - if (editDisabled) { - editTooltip.enable(); - } else { - editTooltip.disable(); - } }; window.maximiseMap = function () { diff --git a/app/assets/javascripts/leaflet.layers.js b/app/assets/javascripts/leaflet.layers.js index f372b86cf..020876c47 100644 --- a/app/assets/javascripts/leaflet.layers.js +++ b/app/assets/javascripts/leaflet.layers.js @@ -100,11 +100,10 @@ L.OSM.layers = function (options) { var item = $("
  • ") .appendTo(overlays); - var tooltip; if (name === "notes" || name === "data") { - item.attr("title", I18n.t("javascripts.site.map_" + name + "_zoom_in_tooltip")); - tooltip = new bootstrap.Tooltip(item[0]); - tooltip.disable(); + item + .attr("title", I18n.t("javascripts.site.map_" + name + "_zoom_in_tooltip")) + .tooltip("disable"); } var label = $("