[open-ils-commits] r18928 - trunk/Open-ILS/xul/staff_client/chrome/content/OpenILS (phasefx)

svn at svn.open-ils.org svn at svn.open-ils.org
Tue Dec 7 11:58:20 EST 2010


Author: phasefx
Date: 2010-12-07 11:58:17 -0500 (Tue, 07 Dec 2010)
New Revision: 18928

Modified:
   trunk/Open-ILS/xul/staff_client/chrome/content/OpenILS/global_util.js
Log:
oils_lock_page() and oils_unlock_page() for xul interfaces that wraps xulG.lock_tab/unlock_tab and works for both windowed and tabbed interfaces

Modified: trunk/Open-ILS/xul/staff_client/chrome/content/OpenILS/global_util.js
===================================================================
--- trunk/Open-ILS/xul/staff_client/chrome/content/OpenILS/global_util.js	2010-12-07 16:58:14 UTC (rev 18927)
+++ trunk/Open-ILS/xul/staff_client/chrome/content/OpenILS/global_util.js	2010-12-07 16:58:17 UTC (rev 18928)
@@ -1,5 +1,55 @@
     function $(id) { return document.getElementById(id); }
 
+    function oils_lock_page(params) {
+        if (!params) { params = {}; }
+        if (window.oils_lock) {
+            if (!params.allow_multiple_locks) {
+                return 'already locked';
+            }
+        }
+        window.oils_lock = true;
+        if (typeof xulG != 'undefined') {
+            if (typeof xulG.unlock_tab == 'function') {
+                xulG.lock_tab();
+            }
+        }
+        return 'locked';
+    }
+
+    function oils_unlock_page(params) {
+        window.oils_lock = false;
+        if (typeof xulG != 'undefined') {
+            if (typeof xulG.unlock_tab == 'function') {
+                xulG.unlock_tab();
+            }
+        }
+        return 'unlocked';
+    }
+
+    window.addEventListener(
+        'close',
+        function(ev) {
+
+                if (window.oils_lock) {
+                    var confirmation = window.confirm($('offlineStrings').getString('menu.close_window.unsaved_data_warning'));
+                    if (!confirmation) {
+                        ev.preventDefault();
+                        return false;
+                    }
+                }
+
+                window.oils_lock = false;
+                if (typeof xulG != 'undefined') {
+                    if (typeof xulG.unlock_tab == 'function') {
+                        xulG.unlock_tab();
+                    }
+                }
+
+                return true;
+        },
+        false
+    );
+
     function ses(a,params) {
         try {
             if (!params) params = {};



More information about the open-ils-commits mailing list