Use jquery interface for enabling/disabling tooltips
This commit is contained in:
parent
9657b92fad
commit
cf3fa3bb2d
4 changed files with 12 additions and 24 deletions
|
@ -56,20 +56,15 @@ window.updateLinks = function (loc, zoom, layers, object) {
|
||||||
link.href = href;
|
link.href = href;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Disable the button group and also the buttons to avoid
|
||||||
|
// inconsistent behaviour when zooming
|
||||||
var editDisabled = zoom < 13;
|
var editDisabled = zoom < 13;
|
||||||
var editTab = $("#edit_tab");
|
$("#edit_tab")
|
||||||
editTab
|
.tooltip({ placement: "bottom" })
|
||||||
// Disable the button group and also the buttons to avoid
|
.tooltip(editDisabled ? "enable" : "disable")
|
||||||
// inconsistent behaviour when zooming
|
|
||||||
.toggleClass("disabled", editDisabled)
|
.toggleClass("disabled", editDisabled)
|
||||||
.find("a")
|
.find("a")
|
||||||
.toggleClass("disabled", editDisabled);
|
.toggleClass("disabled", editDisabled);
|
||||||
var editTooltip = bootstrap.Tooltip.getOrCreateInstance(editTab[0], { placement: "bottom" });
|
|
||||||
if (editDisabled) {
|
|
||||||
editTooltip.enable();
|
|
||||||
} else {
|
|
||||||
editTooltip.disable();
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
window.maximiseMap = function () {
|
window.maximiseMap = function () {
|
||||||
|
|
|
@ -100,11 +100,10 @@ L.OSM.layers = function (options) {
|
||||||
var item = $("<li>")
|
var item = $("<li>")
|
||||||
.appendTo(overlays);
|
.appendTo(overlays);
|
||||||
|
|
||||||
var tooltip;
|
|
||||||
if (name === "notes" || name === "data") {
|
if (name === "notes" || name === "data") {
|
||||||
item.attr("title", I18n.t("javascripts.site.map_" + name + "_zoom_in_tooltip"));
|
item
|
||||||
tooltip = new bootstrap.Tooltip(item[0]);
|
.attr("title", I18n.t("javascripts.site.map_" + name + "_zoom_in_tooltip"))
|
||||||
tooltip.disable();
|
.tooltip("disable");
|
||||||
}
|
}
|
||||||
|
|
||||||
var label = $("<label>")
|
var label = $("<label>")
|
||||||
|
@ -148,14 +147,9 @@ L.OSM.layers = function (options) {
|
||||||
.trigger("change");
|
.trigger("change");
|
||||||
}
|
}
|
||||||
|
|
||||||
$(item).attr("class", disabled ? "disabled" : "");
|
$(item)
|
||||||
if (tooltip) {
|
.attr("class", disabled ? "disabled" : "")
|
||||||
if (disabled) {
|
.tooltip(disabled ? "enable" : "disable");
|
||||||
tooltip.enable();
|
|
||||||
} else {
|
|
||||||
tooltip.disable();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,6 @@
|
||||||
"eslint:recommended"
|
"eslint:recommended"
|
||||||
],
|
],
|
||||||
"globals": {
|
"globals": {
|
||||||
"bootstrap": "readonly",
|
|
||||||
"Cookies": "readonly",
|
"Cookies": "readonly",
|
||||||
"I18n": "readonly",
|
"I18n": "readonly",
|
||||||
"L": "readonly",
|
"L": "readonly",
|
||||||
|
|
|
@ -70,7 +70,7 @@ class SiteTest < ApplicationSystemTestCase
|
||||||
assert_no_selector ".tooltip", :text => "Zoom in"
|
assert_no_selector ".tooltip", :text => "Zoom in"
|
||||||
find("h1").hover # un-hover original element
|
find("h1").hover # un-hover original element
|
||||||
|
|
||||||
visit "/#map=10/0/0"
|
visit "#map=10/0/0"
|
||||||
find(selector).hover
|
find(selector).hover
|
||||||
assert_selector ".tooltip", :text => "Zoom in"
|
assert_selector ".tooltip", :text => "Zoom in"
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue