X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/c8fb5ad24c5751bd2d43b86e4359381d200af066..04fbc71a40ba73f9d9ba7253fc076b54c3d7ec84:/app/assets/javascripts/leaflet.key.js?ds=sidebyside
diff --git a/app/assets/javascripts/leaflet.key.js b/app/assets/javascripts/leaflet.key.js
index c5124e39d..d88ce5d6e 100644
--- a/app/assets/javascripts/leaflet.key.js
+++ b/app/assets/javascripts/leaflet.key.js
@@ -5,7 +5,7 @@ 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'))
@@ -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);
+ if (!button.hasClass('disabled')) {
+ options.sidebar.togglePane($ui, button);
+ }
+ }
+
+ function updateButton() {
+ var layer = map.getMapBaseLayerId();
+ button.toggleClass('disabled', layer !== 'mapnik');
}
function update() {