X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/c8fb5ad24c5751bd2d43b86e4359381d200af066..bf9dd8f350ca1b54afb79dda79506d980ccb5738:/app/assets/javascripts/leaflet.note.js diff --git a/app/assets/javascripts/leaflet.note.js b/app/assets/javascripts/leaflet.note.js index a38e012de..86c455499 100644 --- a/app/assets/javascripts/leaflet.note.js +++ b/app/assets/javascripts/leaflet.note.js @@ -2,17 +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('id', 'createnoteanchor') - .attr('class', 'control-button geolink') - .attr('data-minzoom', 12) - .attr('href', '#') - .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-original-title", I18n.t(disabled ? + "javascripts.site.createnote_disabled_tooltip" : + "javascripts.site.createnote_tooltip")); + } + + update(); + return $container[0]; };