1 L.OSM.key = function (options) {
2 var control = L.control(options);
4 control.onAdd = function (map) {
5 var $container = $('<div>')
6 .attr('class', 'control-key');
9 .attr('class', 'control-button')
11 .html('<span class="icon key"></span>')
13 .appendTo($container);
16 .attr('class', 'key-ui');
19 .attr('class', 'sidebar_heading')
23 .text(I18n.t('javascripts.close'))
24 .attr('class', 'icon close')
25 .bind('click', toggle))
28 .text(I18n.t('javascripts.key.title')));
30 var $section = $('<div>')
31 .attr('class', 'section')
34 options.sidebar.addPane($ui);
40 map.on('baselayerchange', updateButton);
45 map.on('zoomend baselayerchange', update);
46 $section.load('/key', update);
50 map.off('zoomend baselayerchange', update);
56 if (!button.hasClass('disabled')) {
57 options.sidebar.togglePane($ui, button);
59 $('.leaflet-control .control-button').tooltip('hide');
62 function updateButton() {
63 var disabled = map.getMapBaseLayerId() !== 'mapnik';
65 .toggleClass('disabled', disabled)
66 .attr('data-original-title',
68 'javascripts.key.tooltip_disabled' :
69 'javascripts.key.tooltip'));
73 var layer = map.getMapBaseLayerId(),
76 $('.mapkey-table-entry').each(function () {
77 var data = $(this).data();
78 if (layer === data.layer && zoom >= data.zoomMin && zoom <= data.zoomMax) {