X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/eebe1f1d3ed885e94725c07d24e0483f603f03da..0b7435ab32b3271ae000894f6798cc087b3c058c:/app/assets/javascripts/leaflet.note.js
diff --git a/app/assets/javascripts/leaflet.note.js b/app/assets/javascripts/leaflet.note.js
index 68e09c88d..5f8010967 100644
--- a/app/assets/javascripts/leaflet.note.js
+++ b/app/assets/javascripts/leaflet.note.js
@@ -2,28 +2,28 @@ L.OSM.note = function (options) {
var control = L.control(options);
control.onAdd = function (map) {
- var $container = $('
')
- .attr('class', 'control-note');
+ var $container = $("
")
+ .attr("class", "control-note");
- $('
')
- .attr('class', 'control-button')
- .attr('href', '#')
- .attr('title', 'Notes')
- .html('')
- .on('click', toggle)
+ var link = $("")
+ .attr("class", "control-button")
+ .attr("href", "#")
+ .html("")
.appendTo($container);
- function toggle(e) {
- e.stopPropagation();
- e.preventDefault();
+ map.on("zoomend", update);
- if (map.hasLayer(map.noteLayer)) {
- map.removeLayer(map.noteLayer);
- } else {
- map.addLayer(map.noteLayer);
- }
+ function update() {
+ var disabled = OSM.STATUS === "database_offline" || map.getZoom() < 12;
+ link
+ .toggleClass("disabled", disabled)
+ .attr("data-bs-original-title", I18n.t(disabled ?
+ "javascripts.site.createnote_disabled_tooltip" :
+ "javascripts.site.createnote_tooltip"));
}
+ update();
+
return $container[0];
};