X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/fa9b4a5f6a00fd862ce3230a64d6c6c89c7fbb6c..1f0884a34c078ae955c0466fbcdddadfab9dca33:/app/assets/javascripts/leaflet.key.js
diff --git a/app/assets/javascripts/leaflet.key.js b/app/assets/javascripts/leaflet.key.js
index 1c219d953..58bfbf6d2 100644
--- a/app/assets/javascripts/leaflet.key.js
+++ b/app/assets/javascripts/leaflet.key.js
@@ -8,7 +8,6 @@ L.OSM.key = function (options) {
var button = $('')
.attr('class', 'control-button')
.attr('href', '#')
- .attr('title', I18n.t('javascripts.key.tooltip'))
.html('')
.on('click', toggle)
.appendTo($container);
@@ -20,10 +19,9 @@ L.OSM.key = function (options) {
.attr('class', 'sidebar_heading')
.appendTo($ui)
.append(
- $('')
+ $('')
.text(I18n.t('javascripts.close'))
- .attr('class', 'sidebar_close')
- .attr('href', '#')
+ .attr('class', 'icon close')
.bind('click', toggle))
.append(
$('')
@@ -39,6 +37,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 +53,19 @@ 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);
+ }
+ $('.leaflet-control .control-button').tooltip('hide');
+ }
+
+ 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() {