1 L.OSM.key = function (options) {
2 var control = L.OSM.sidebarPane(options);
4 control.onAdd = function (map) {
5 var $container = $("<div>")
6 .attr("class", "control-key");
8 var button = this.makeButton("key", null, toggle)
11 var $ui = this.makeUI("key-ui", "javascripts.key.title", toggle);
13 var $section = $("<div>")
14 .attr("class", "section")
17 options.sidebar.addPane($ui);
23 map.on("baselayerchange", updateButton);
28 map.on("zoomend baselayerchange", update);
29 $section.load("/key", update);
33 map.off("zoomend baselayerchange", update);
39 if (!button.hasClass("disabled")) {
40 options.sidebar.togglePane($ui, button);
42 $(".leaflet-control .control-button").tooltip("hide");
45 function updateButton() {
46 var disabled = ["mapnik", "cyclemap"].indexOf(map.getMapBaseLayerId()) === -1;
48 .toggleClass("disabled", disabled)
49 .attr("data-bs-original-title",
51 "javascripts.key.tooltip_disabled" :
52 "javascripts.key.tooltip"));
56 var layer = map.getMapBaseLayerId(),
59 $(".mapkey-table-entry").each(function () {
60 var data = $(this).data();
61 if (layer === data.layer && zoom >= data.zoomMin && zoom <= data.zoomMax) {