Require index-only JS in index.js

This commit is contained in:
John Firebaugh 2012-09-29 14:19:48 -07:00 committed by Tom Hughes
parent 0ec2843b0f
commit 87e8cf3b58
5 changed files with 4 additions and 3 deletions

View file

@ -0,0 +1,36 @@
$(document).ready(function () {
$("#open_map_key").click(function (e) {
var url = $(this).attr('href'),
title = $(this).text();
function updateMapKey() {
var mapLayer = map.baseLayer.keyid,
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.events.unregister("zoomend", map, updateMapKey);
map.events.unregister("changelayer", map, updateMapKey);
});
map.events.register("zoomend", map, updateMapKey);
map.events.register("changelayer", map, updateMapKey);
e.preventDefault();
});
});