X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/c8fb5ad24c5751bd2d43b86e4359381d200af066..d48b25124eaf561428176c60b79cc90e0a8e8125:/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..5223b1420 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);
@@ -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,20 @@ 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);
+ }
+ $('.leaflet-control .control-button').tooltip('hide');
+ }
+
+ function updateButton() {
+ var disabled = ['mapnik', 'cyclemap'].indexOf(map.getMapBaseLayerId()) === -1;
+ button
+ .toggleClass('disabled', disabled)
+ .attr('data-original-title',
+ I18n.t(disabled ?
+ 'javascripts.key.tooltip_disabled' :
+ 'javascripts.key.tooltip'));
}
function update() {
@@ -60,7 +75,7 @@ L.OSM.key = function (options) {
$('.mapkey-table-entry').each(function () {
var data = $(this).data();
- if (layer == data.layer && zoom >= data.zoomMin && zoom <= data.zoomMax) {
+ if (layer === data.layer && zoom >= data.zoomMin && zoom <= data.zoomMax) {
$(this).show();
} else {
$(this).hide();