Get rid of the sidebar's onclose global state

This commit is contained in:
Tom Hughes 2012-08-30 23:02:54 +01:00
parent 93c392cf5f
commit d7da1562c3
4 changed files with 26 additions and 45 deletions

View file

@ -17,7 +17,7 @@ function startBrowse(sidebarHtml) {
$("#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();
@ -53,7 +53,7 @@ function startBrowse(sidebarHtml) {
}
}
function stopBrowse() {
$("#sidebar").one("closed", function () {
if (map.dataLayer.active) {
map.dataLayer.active = false;
@ -80,7 +80,7 @@ function startBrowse(sidebarHtml) {
map.dataLayer.setVisibility(false);
map.events.unregister("moveend", map, updateData);
}
}
});
function startDrag() {
$("#browse_select_box").html(I18n.t('browse.start_rjs.drag_a_box'));

View file

@ -46,7 +46,7 @@ function startExport(sidebarHtml) {
$("#mapnik_scale").change(mapnikSizeChanged);
openSidebar({ onclose: stopExport });
openSidebar();
if (map.baseLayer.name == "Mapnik") {
$("#format_mapnik").prop("checked", true);
@ -58,7 +58,7 @@ function startExport(sidebarHtml) {
$("#viewanchor").removeClass("active");
$("#exportanchor").addClass("active");
function stopExport() {
$("#sidebar").one("closed", function () {
$("#viewanchor").addClass("active");
$("#exportanchor").removeClass("active");
@ -67,7 +67,7 @@ function startExport(sidebarHtml) {
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(),

View file

@ -1,40 +1,24 @@
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();
});
})();
});