Use jquery interface for enabling/disabling tooltips

This commit is contained in:
Anton Khorev 2022-09-23 13:34:40 +03:00
parent 9657b92fad
commit cf3fa3bb2d
4 changed files with 12 additions and 24 deletions

View file

@ -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 () {

View file

@ -100,11 +100,10 @@ L.OSM.layers = function (options) {
var item = $("<li>")
.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 = $("<label>")
@ -148,14 +147,9 @@ L.OSM.layers = function (options) {
.trigger("change");
}
$(item).attr("class", disabled ? "disabled" : "");
if (tooltip) {
if (disabled) {
tooltip.enable();
} else {
tooltip.disable();
}
}
$(item)
.attr("class", disabled ? "disabled" : "")
.tooltip(disabled ? "enable" : "disable");
});
};

View file

@ -7,7 +7,6 @@
"eslint:recommended"
],
"globals": {
"bootstrap": "readonly",
"Cookies": "readonly",
"I18n": "readonly",
"L": "readonly",

View file

@ -70,7 +70,7 @@ class SiteTest < ApplicationSystemTestCase
assert_no_selector ".tooltip", :text => "Zoom in"
find("h1").hover # un-hover original element
visit "/#map=10/0/0"
visit "#map=10/0/0"
find(selector).hover
assert_selector ".tooltip", :text => "Zoom in"
end