X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/eb7678145a87c1b9e3cd7ff2d3b5dc08132e4b51..9c3ab20fbafeb6f69da9b38a5d41c0173038668e:/app/assets/javascripts/leaflet.layers.js?ds=inline diff --git a/app/assets/javascripts/leaflet.layers.js b/app/assets/javascripts/leaflet.layers.js index 974962ffd..27311f7c1 100644 --- a/app/assets/javascripts/leaflet.layers.js +++ b/app/assets/javascripts/leaflet.layers.js @@ -1,44 +1,19 @@ -L.OSM.layers = function(options) { - var control = L.control(options); +L.OSM.layers = function (options) { + var control = L.OSM.sidebarPane(options, "layers", "javascripts.map.layers.title", "javascripts.map.layers.header"); - control.onAdd = function (map) { + control.onAddPane = function (map, button, $ui, toggle) { var layers = options.layers; - var $container = $("
") - .attr("class", "control-layers"); - - var button = $("") - .attr("class", "control-button") - .attr("href", "#") - .attr("title", I18n.t("javascripts.map.layers.title")) - .html("") - .on("click", toggle) - .appendTo($container); - - var $ui = $("
") - .attr("class", "layers-ui"); - - $("
") - .attr("class", "sidebar_heading") - .appendTo($ui) - .append( - $("") - .text(I18n.t("javascripts.close")) - .attr("class", "icon close") - .bind("click", toggle)) - .append( - $("

") - .text(I18n.t("javascripts.map.layers.header"))); - var baseSection = $("
") .attr("class", "section base-layers") .appendTo($ui); - var baseLayers = $("
    ") + var baseLayers = $("
      ") .appendTo(baseSection); - layers.forEach(function(layer) { + layers.forEach(function (layer) { var item = $("
    • ") + .attr("class", "rounded-3") .appendTo(baseLayers); if (map.hasLayer(layer)) { @@ -48,8 +23,8 @@ L.OSM.layers = function(options) { var div = $("
      ") .appendTo(item); - map.whenReady(function() { - var miniMap = L.map(div[0], {attributionControl: false, zoomControl: false, keyboard: false}) + map.whenReady(function () { + var miniMap = L.map(div[0], { attributionControl: false, zoomControl: false, keyboard: false }) .addLayer(new layer.constructor({ apikey: layer.options.apikey })); miniMap.dragging.disable(); @@ -63,7 +38,7 @@ L.OSM.layers = function(options) { function shown() { miniMap.invalidateSize(); - setView({animate: false}); + setView({ animate: false }); map.on("moveend", moved); } @@ -84,26 +59,26 @@ L.OSM.layers = function(options) { .appendTo(item); var input = $("") - .attr("type", "radio") - .prop("checked", map.hasLayer(layer)) - .appendTo(label); + .attr("type", "radio") + .prop("checked", map.hasLayer(layer)) + .appendTo(label); label.append(layer.options.name); - item.on("click", function() { - layers.forEach(function(other) { + item.on("click", function () { + layers.forEach(function (other) { if (other === layer) { map.addLayer(other); } else { map.removeLayer(other); } }); - map.fire("baselayerchange", {layer: layer}); + map.fire("baselayerchange", { layer: layer }); }); item.on("dblclick", toggle); - map.on("layeradd layerremove", function() { + map.on("layeradd layerremove", function () { item.toggleClass("active", map.hasLayer(layer)); input.prop("checked", map.hasLayer(layer)); }); @@ -116,46 +91,51 @@ L.OSM.layers = function(options) { $("

      ") .text(I18n.t("javascripts.map.layers.overlays")) - .attr("class", "deemphasize") + .attr("class", "text-muted") .appendTo(overlaySection); - var overlays = $("

        ") + var overlays = $("
          ") .appendTo(overlaySection); var addOverlay = function (layer, name, maxArea) { var item = $("
        • ") - .tooltip({ - placement: "top" - }) .appendTo(overlays); + if (name === "notes" || name === "data") { + item + .attr("title", I18n.t("javascripts.site.map_" + name + "_zoom_in_tooltip")) + .tooltip("disable"); + } + var label = $("