X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/078059b76b8304368fd7ddac2dd563470e83472e..250bb47cc2723c7af6fac0a6e9e900c1a50f9292:/app/assets/javascripts/leaflet.query.js diff --git a/app/assets/javascripts/leaflet.query.js b/app/assets/javascripts/leaflet.query.js index 3eab9054d..906487274 100644 --- a/app/assets/javascripts/leaflet.query.js +++ b/app/assets/javascripts/leaflet.query.js @@ -8,10 +8,29 @@ L.OSM.query = function (options) { var link = $('') .attr('class', 'control-button') .attr('href', '#') - .attr('data-original-title', I18n.t('javascripts.site.queryfeature_tooltip')) .html('') .appendTo($container); + map.on('zoomend', update); + + update(); + + function update() { + var wasDisabled = link.hasClass('disabled'), + isDisabled = map.getZoom() < 14; + link + .toggleClass('disabled', isDisabled) + .attr('data-original-title', I18n.t(isDisabled ? + 'javascripts.site.queryfeature_disabled_tooltip' : + 'javascripts.site.queryfeature_tooltip')); + + if (isDisabled && !wasDisabled) { + link.trigger('disabled'); + } else if (wasDisabled && !isDisabled) { + link.trigger('enabled'); + } + } + return $container[0]; };