make the browser Reload button aware of tab locking for unsaved data
authorphasefx <phasefx@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Thu, 3 Feb 2011 23:40:50 +0000 (23:40 +0000)
committerphasefx <phasefx@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Thu, 3 Feb 2011 23:40:50 +0000 (23:40 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@19377 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/xul/staff_client/chrome/content/util/browser.js
Open-ILS/xul/staff_client/chrome/locale/en-US/offline.properties

index a2d2a35..41ff0d2 100644 (file)
@@ -12,6 +12,8 @@ util.browser = function (params) {
 
 util.browser.prototype = {
 
+    'lock_reload' : false, // as opposed to lock 'n load :)
+
     'init' : function( params ) {
 
         try {
@@ -124,6 +126,14 @@ util.browser.prototype = {
                             ['command'],
                             function() {
                                 try {
+                                    if (obj.lock_reload) {
+                                        if (window.confirm( $('offlineStrings').getString('browser.reload.unsaved_data_warning') )) {
+                                            obj.lock_reload = false;
+                                            window.xulG.unlock_tab();
+                                        } else {
+                                            return;
+                                        }
+                                    }
                                     netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
                                     var n = obj.getWebNavigation();
                                     n.reload( Components.interfaces.nsIWebNavigation.LOAD_FLAGS_NONE );
@@ -258,8 +268,18 @@ util.browser.prototype = {
             if (!cw.xulG.set_tab) { cw.xulG.set_tab = function(a,b,c) { return window.xulG.set_tab(a,b,c); }; }
             if (!cw.xulG.new_tab) { cw.xulG.new_tab = function(a,b,c) { return window.xulG.new_tab(a,b,c); }; }
             if (!cw.xulG.close_tab) { cw.xulG.close_tab = function(a) { return window.xulG.close_tab(a); }; }
-            if (!cw.xulG.lock_tab) { cw.xulG.lock_tab = function() { return window.xulG.lock_tab(); }; }
-            if (!cw.xulG.unlock_tab) { cw.xulG.unlock_tab = function() { return window.xulG.unlock_tab(); }; }
+            if (!cw.xulG.lock_tab) {
+                cw.xulG.lock_tab = function() {
+                    obj.lock_reload = true;
+                    return window.xulG.lock_tab();
+                };
+            }
+            if (!cw.xulG.unlock_tab) {
+                cw.xulG.unlock_tab = function() {
+                    obj.lock_reload = false;
+                    return window.xulG.unlock_tab();
+                };
+            }
             if (!cw.xulG.inspect_tab) { cw.xulG.inspect_tab = function() { return window.xulG.inspect_tab(); }; }
             if (!cw.xulG.new_patron_tab) { cw.xulG.new_patron_tab = function(a,b) { return window.xulG.new_patron_tab(a,b); }; }
             if (!cw.xulG.set_patron_tab) { cw.xulG.set_patron_tab = function(a,b) { return window.xulG.set_patron_tab(a,b); }; }
index 2ccd17d..6a125de 100644 (file)
@@ -280,6 +280,7 @@ menu.tab7.accesskey=7
 menu.tab8.accesskey=8
 menu.tab9.accesskey=9
 menu.tab10.accesskey=0
+browser.reload.unsaved_data_warning=This page may have unsaved data. Reload it anyway?
 menu.close_tab.unsaved_data_warning=This tab may have unsaved data. Close it anyway?
 menu.replace_tab.unsaved_data_warning=This tab may have unsaved data. Replace it anyway?
 menu.close_window.unsaved_data_warning=This window may have unsaved data. Close it anyway?