X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/5c0aeb1558a778cd5790be5e062c2df7d9b51da6..aaeca5b5346b01d7ef26a301492804d36049eff8:/app/assets/javascripts/leaflet.key.js?ds=inline diff --git a/app/assets/javascripts/leaflet.key.js b/app/assets/javascripts/leaflet.key.js index d12187bc2..cc86736ef 100644 --- a/app/assets/javascripts/leaflet.key.js +++ b/app/assets/javascripts/leaflet.key.js @@ -5,10 +5,9 @@ L.OSM.key = function (options) { var $container = $('
') .attr('class', 'control-key'); - $('') + var button = $('') .attr('class', 'control-button') .attr('href', '#') - .attr('title', I18n.t('javascripts.key.tooltip')) .html('') .on('click', toggle) .appendTo($container); @@ -16,7 +15,7 @@ L.OSM.key = function (options) { var $ui = $('
') .attr('class', 'key-ui'); - $('
') + $('
') .attr('class', 'sidebar_heading') .appendTo($ui) .append( @@ -29,7 +28,8 @@ L.OSM.key = function (options) { $('

') .text(I18n.t('javascripts.key.title'))); - var $section = $('
') + var $section = $('
') + .attr('class', 'section') .appendTo($ui); options.sidebar.addPane($ui); @@ -38,6 +38,10 @@ L.OSM.key = function (options) { .on('show', shown) .on('hide', hidden); + map.on('baselayerchange', updateButton); + + updateButton(); + function shown() { map.on('zoomend baselayerchange', update); $section.load('/key', update); @@ -50,7 +54,18 @@ L.OSM.key = function (options) { function toggle(e) { e.stopPropagation(); e.preventDefault(); - options.sidebar.togglePane($ui); + if (!button.hasClass('disabled')) { + options.sidebar.togglePane($ui, button); + } + } + + function updateButton() { + var disabled = map.getMapBaseLayerId() !== 'mapnik' + button + .toggleClass('disabled', disabled) + .attr('data-original-title', I18n.t(disabled ? + 'javascripts.key.tooltip_disabled' : + 'javascripts.key.tooltip')) } function update() {