X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/fa9b4a5f6a00fd862ce3230a64d6c6c89c7fbb6c..04fbc71a40ba73f9d9ba7253fc076b54c3d7ec84:/app/assets/javascripts/leaflet.key.js diff --git a/app/assets/javascripts/leaflet.key.js b/app/assets/javascripts/leaflet.key.js index 1c219d953..d88ce5d6e 100644 --- a/app/assets/javascripts/leaflet.key.js +++ b/app/assets/javascripts/leaflet.key.js @@ -39,6 +39,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); @@ -51,7 +55,14 @@ L.OSM.key = function (options) { function toggle(e) { e.stopPropagation(); e.preventDefault(); - options.sidebar.togglePane($ui, button); + if (!button.hasClass('disabled')) { + options.sidebar.togglePane($ui, button); + } + } + + function updateButton() { + var layer = map.getMapBaseLayerId(); + button.toggleClass('disabled', layer !== 'mapnik'); } function update() {