Port map key to new UI
This commit is contained in:
parent
eebe1f1d3e
commit
c8f8dbca19
5 changed files with 50 additions and 43 deletions
|
@ -7,7 +7,6 @@
|
|||
//= require leaflet.share
|
||||
//= require index/browse
|
||||
//= require index/export
|
||||
//= require index/key
|
||||
//= require index/notes
|
||||
|
||||
$(document).ready(function () {
|
||||
|
|
|
@ -1,34 +0,0 @@
|
|||
$(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);
|
||||
});
|
||||
});
|
|
@ -1,4 +1,4 @@
|
|||
L.OSM.key = function(options) {
|
||||
L.OSM.key = function (options) {
|
||||
var control = L.control(options);
|
||||
|
||||
control.onAdd = function (map) {
|
||||
|
@ -8,10 +8,55 @@ L.OSM.key = function(options) {
|
|||
$('<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];
|
||||
};
|
||||
|
||||
|
|
|
@ -2,10 +2,6 @@
|
|||
<%= 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' %>
|
||||
|
|
|
@ -1338,8 +1338,6 @@ en:
|
|||
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"
|
||||
|
@ -2042,6 +2040,9 @@ en:
|
|||
share:
|
||||
title: "Share"
|
||||
cancel: "Cancel"
|
||||
key:
|
||||
title: "Map Key"
|
||||
tooltip: "Key for the map"
|
||||
map:
|
||||
base:
|
||||
standard: Standard
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue