$("#sidebar_title").html(I18n.t('browse.start_rjs.data_frame_title'));
$("#sidebar_content").html(sidebarHtml);
- openSidebar({ onclose: stopBrowse });
+ openSidebar();
var vectors = new OpenLayers.Layer.Vector();
}
}
- function stopBrowse() {
+ $("#sidebar").one("closed", function () {
if (map.dataLayer.active) {
map.dataLayer.active = false;
map.dataLayer.setVisibility(false);
map.events.unregister("moveend", map, updateData);
}
- }
+ });
function startDrag() {
$("#browse_select_box").html(I18n.t('browse.start_rjs.drag_a_box'));
$("#mapnik_scale").change(mapnikSizeChanged);
- openSidebar({ onclose: stopExport });
+ openSidebar();
if (map.baseLayer.name == "Mapnik") {
$("#format_mapnik").prop("checked", true);
$("#viewanchor").removeClass("active");
$("#exportanchor").addClass("active");
- function stopExport() {
+ $("#sidebar").one("closed", function () {
$("#viewanchor").addClass("active");
$("#exportanchor").removeClass("active");
map.events.unregister("moveend", map, mapMoved);
map.events.unregister("changebaselayer", map, htmlUrlChanged);
map.removeLayer(vectors);
- }
+ });
function getMercatorBounds() {
var bounds = new OpenLayers.Bounds($("#minlon").val(), $("#minlat").val(),
-var openSidebar;
+function openSidebar(options) {
+ options = options || {};
-(function () {
- var onclose;
+ $("#sidebar").trigger("closed");
- openSidebar = function(options) {
- options = options || {};
+ if (options.title) { $("#sidebar_title").html(options.title); }
- if (onclose) {
- onclose();
- onclose = null;
- }
+ if (options.width) { $("#sidebar").width(options.width); }
+ else { $("#sidebar").width("30%"); }
- if (options.title) { $("#sidebar_title").html(options.title); }
+ $("#sidebar").css("display", "block");
- if (options.width) { $("#sidebar").width(options.width); }
- else { $("#sidebar").width("30%"); }
+ $("#sidebar").trigger("opened");
+};
- $("#sidebar").css("display", "block");
+$(document).ready(function () {
+ $(".sidebar_close").click(function (e) {
+ $("#sidebar").css("display", "none");
- $("#sidebar").trigger("opened");
+ $("#sidebar").trigger("closed");
- onclose = options.onclose;
- };
-
- $(document).ready(function () {
- $(".sidebar_close").click(function (e) {
- $("#sidebar").css("display", "none");
-
- $("#sidebar").trigger("closed");
-
- if (onclose) {
- onclose();
- onclose = null;
- }
-
- e.preventDefault();
- });
+ e.preventDefault();
});
-})();
+});
});
}
- var closeMapKey = function () {
- map.events.unregister("zoomend", map, updateMapKey);
- map.events.unregister("changelayer", map, updateMapKey);
- }
-
$("#open_map_key").click(function () {
updateMapKey();
- openSidebar({
- title: "<%= t('site.key.map_key') %>",
- onclose: closeMapKey
+ openSidebar({ title: "<%= t('site.key.map_key') %>" });
+
+ $("#sidebar").one("closed", function () {
+ map.events.unregister("zoomend", map, updateMapKey);
+ map.events.unregister("changelayer", map, updateMapKey);
});
map.events.register("zoomend", map, updateMapKey);