From 5c98419930d26a029a0b335229c4417e1ae0ff06 Mon Sep 17 00:00:00 2001 From: phasefx Date: Fri, 17 Dec 2010 16:41:45 +0000 Subject: [PATCH] use just one close handler for menu.js; small tweak to support that, and some debug output git-svn-id: svn://svn.open-ils.org/ILS/trunk@19011 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- .../chrome/content/OpenILS/global_util.js | 16 +++++++++-- .../xul/staff_client/chrome/content/main/menu.js | 32 +--------------------- 2 files changed, 14 insertions(+), 34 deletions(-) diff --git a/Open-ILS/xul/staff_client/chrome/content/OpenILS/global_util.js b/Open-ILS/xul/staff_client/chrome/content/OpenILS/global_util.js index e68c9da29e..a21f6eafb7 100644 --- a/Open-ILS/xul/staff_client/chrome/content/OpenILS/global_util.js +++ b/Open-ILS/xul/staff_client/chrome/content/OpenILS/global_util.js @@ -5,17 +5,28 @@ data.stash_retrieve(); if (typeof data.unsaved_data == 'undefined') { data.unsaved_data = 0; } data.unsaved_data++; + window.oils_lock++; data.stash('unsaved_data'); + dump('incrementing window.oils_lock\n'); + dump(location.href + ' window.oils_lock == ' + window.oils_lock + '\n'); + dump('incrementing data.unsaved_data\n'); + dump('data.unsaved_data == ' + data.unsaved_data + '\n'); } function oils_unsaved_data_P(count) { if (!count) { count = 1; } + dump('decrementing window.oils_lock by ' + count + '\n'); + window.oils_lock -= count; + if (window.oils_lock < 0) { window.oils_lock = 0; } + dump(location.href + ' window.oils_lock == ' + window.oils_lock + '\n'); JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.stash_retrieve(); data.stash_retrieve(); if (typeof data.unsaved_data == 'undefined') { data.unsaved_data = 0; } + dump('decrementing data.unsaved_data by ' + count + '\n'); data.unsaved_data -= count; if (data.unsaved_data < 0) { data.unsaved_data = 0; } data.stash('unsaved_data'); + dump('data.unsaved_data == ' + data.unsaved_data + '\n'); } function oils_lock_page(params) { @@ -26,7 +37,6 @@ return window.oils_lock; } } - window.oils_lock++; if (typeof xulG != 'undefined') { if (typeof xulG.unlock_tab == 'function') { dump('\twith xulG.lock_tab\n'); @@ -44,8 +54,6 @@ function oils_unlock_page(params) { dump('oils_unlock_page\n'); - window.oils_lock--; - if (window.oils_lock < 0) { window.oils_lock = 0; } if (typeof xulG != 'undefined') { if (typeof xulG.unlock_tab == 'function') { dump('\twith xulG.unlock_tab\n'); @@ -62,6 +70,7 @@ } window.oils_lock = 0; + dump(location.href + ' init window.oils_lock == ' + window.oils_lock + '\n'); window.addEventListener( 'close', function(ev) { @@ -85,6 +94,7 @@ oils_unsaved_data_P( window.oils_lock ); } window.oils_lock = 0; + dump(location.href + ' forcing window.oils_lock == ' + window.oils_lock + '\n'); // Dispatching the window close event doesn't always close the window, even though the event does happen setTimeout( diff --git a/Open-ILS/xul/staff_client/chrome/content/main/menu.js b/Open-ILS/xul/staff_client/chrome/content/main/menu.js index 7185650d42..077955a90f 100644 --- a/Open-ILS/xul/staff_client/chrome/content/main/menu.js +++ b/Open-ILS/xul/staff_client/chrome/content/main/menu.js @@ -119,37 +119,6 @@ main.menu.prototype = { ); } - window.addEventListener( - 'close', - function(ev) { - - var unsaved_data = false; - for (var id in obj.tab_semaphores) { - if (obj.tab_semaphores[id] > 0) { - unsaved_data = true; - } - } - - if (unsaved_data) { - var confirmation = window.confirm(offlineStrings.getString('menu.close_window.unsaved_data_warning')); - if (!confirmation) { - ev.preventDefault(); - return false; - } - } - - for (var id in obj.tab_semaphores) { - if (obj.tab_semaphores[id] > 0) { - oils_unsaved_data_P( obj.tab_semaphores[id] ); - } - } - - return true; - - }, - false - ); - var cmd_map = { 'cmd_broken' : [ ['oncommand'], @@ -1321,6 +1290,7 @@ main.menu.prototype = { if (window.confirm(confirm_string)) { obj.data.unsaved_data = 0; // just in case the program doesn't close somehow obj.data.stash('unsaved_data'); + dump('forcing data.unsaved_data == ' + obj.data.unsaved_data + '\n'); netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); var windowManager = Components.classes["@mozilla.org/appshell/window-mediator;1"].getService(); var windowManagerInterface = windowManager.QueryInterface(Components.interfaces.nsIWindowMediator); -- 2.11.0