//= require leaflet.share
//= require index/browse
//= require index/export
-//= require index/key
//= require index/notes
$(document).ready(function () {
+++ /dev/null
-$(document).ready(function () {
- $("#open_map_key").click(function (e) {
- e.preventDefault();
-
- var url = $(this).attr('href'),
- title = $(this).text();
-
- function updateMapKey() {
- var mapLayer = getMapBaseLayerId(),
- mapZoom = map.getZoom();
-
- $(".mapkey-table-entry").each(function () {
- var data = $(this).data();
-
- if (mapLayer == data.layer &&
- mapZoom >= data.zoomMin && mapZoom <= data.zoomMax) {
- $(this).show();
- } else {
- $(this).hide();
- }
- });
- }
-
- $("#sidebar_content").load(url, updateMapKey);
-
- openSidebar({ title: title });
-
- $("#sidebar").one("closed", function () {
- map.off("zoomend baselayerchange", updateMapKey);
- });
-
- map.on("zoomend baselayerchange", updateMapKey);
- });
-});
-L.OSM.key = function(options) {
+L.OSM.key = function (options) {
var control = L.control(options);
control.onAdd = function (map) {
$('<a>')
.attr('class', 'control-button')
.attr('href', '#')
- .attr('title', 'Map Key')
+ .attr('title', I18n.t("javascripts.key.tooltip"))
.html('<span class="icon key"></span>')
+ .on('click', toggle)
.appendTo($container);
+ var $ui = $('<div>')
+ .attr('class', 'layers-ui')
+ .appendTo(options.uiPane);
+
+ $('<h2>')
+ .text(I18n.t('javascripts.key.title'))
+ .appendTo($ui);
+
+ var $section = $('<section>')
+ .appendTo($ui);
+
+ function toggle(e) {
+ e.stopPropagation();
+ e.preventDefault();
+
+ var controlContainer = $('.leaflet-control-container .leaflet-top.leaflet-right');
+
+ if ($ui.is(':visible')) {
+ $(options.uiPane).hide();
+ controlContainer.css({paddingRight: '0'});
+ map.off("zoomend baselayerchange", update);
+ } else {
+ $(options.uiPane).show();
+ controlContainer.css({paddingRight: '200px'});
+ map.on("zoomend baselayerchange", update);
+ $section.load('/key', update);
+ }
+ }
+
+ function update() {
+ var mapLayer = getMapBaseLayerId(map),
+ mapZoom = map.getZoom();
+
+ $(".mapkey-table-entry").each(function () {
+ var data = $(this).data();
+
+ if (mapLayer == data.layer && mapZoom >= data.zoomMin && mapZoom <= data.zoomMax) {
+ $(this).show();
+ } else {
+ $(this).hide();
+ }
+ });
+ }
+
return $container[0];
};
<%= javascript_include_tag "index" %>
<% end %>
-<% content_for :left_menu do %>
- <li><h4><%= link_to t("site.key.map_key"), {:action => :key}, :id => "open_map_key", :title => t("site.key.map_key_tooltip") %></h4></li>
-<% end %>
-
<%= render :partial => 'home_link' %>
<%= render :partial => 'sidebar' %>
<%= render :partial => 'search' %>
submit_text: "Go"
search_help: "examples: 'Alkmaar', 'Regent Street, Cambridge', 'CB2 5AQ', or 'post offices near Lünen' <a href='http://wiki.openstreetmap.org/wiki/Search'>more examples...</a>"
key:
- map_key: "Map Key"
- map_key_tooltip: "Key for the map"
table:
entry:
motorway: "Motorway"
share:
title: "Share"
cancel: "Cancel"
+ key:
+ title: "Map Key"
+ tooltip: "Key for the map"
map:
base:
standard: Standard