X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/9d5b81094c69a02782faead1528ef32ffcc48aea..a7ba87340d91a6eeef096783b04a9b0a963bfa99:/app/assets/javascripts/leaflet.note.js?ds=inline diff --git a/app/assets/javascripts/leaflet.note.js b/app/assets/javascripts/leaflet.note.js index 77fb9baff..5f8010967 100644 --- a/app/assets/javascripts/leaflet.note.js +++ b/app/assets/javascripts/leaflet.note.js @@ -2,16 +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', I18n.t('javascripts.notes.new.add')) - .html('') + var link = $("") + .attr("class", "control-button") + .attr("href", "#") + .html("") .appendTo($container); + map.on("zoomend", update); + + 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]; };