[open-ils-commits] r18942 - in trunk/Open-ILS/xul/staff_client/chrome/content: OpenILS main (phasefx)

svn at svn.open-ils.org svn at svn.open-ils.org
Thu Dec 9 06:09:12 EST 2010


Author: phasefx
Date: 2010-12-09 06:09:06 -0500 (Thu, 09 Dec 2010)
New Revision: 18942

Modified:
   trunk/Open-ILS/xul/staff_client/chrome/content/OpenILS/global_util.js
   trunk/Open-ILS/xul/staff_client/chrome/content/main/menu.js
Log:
fix copy/paste-o with decrement of unsaved_data semaphore and move functions from menu.js to global_util.js.  tie unsaved_data into offline mode to speedbump closure via the login window

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-09 06:41:38 UTC (rev 18941)
+++ trunk/Open-ILS/xul/staff_client/chrome/content/OpenILS/global_util.js	2010-12-09 11:09:06 UTC (rev 18942)
@@ -1,5 +1,22 @@
     function $(id) { return document.getElementById(id); }
 
+    function oils_unsaved_data_V() {
+        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; }
+        data.unsaved_data++;
+        data.stash('unsaved_data');
+    }
+
+    function oils_unsaved_data_P() {
+        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; }
+        data.unsaved_data--;
+        if (data.unsaved_data < 0) { data.unsaved_data = 0; }
+        data.stash('unsaved_data');
+    }
+
     function oils_lock_page(params) {
         dump('oils_lock_page\n');
         if (!params) { params = {}; }
@@ -12,7 +29,11 @@
         if (typeof xulG != 'undefined') {
             if (typeof xulG.unlock_tab == 'function') {
                 xulG.lock_tab();
+            } else {
+                oils_unsaved_data_V();
             }
+        } else {
+            oils_unsaved_data_V();
         }
         return window.oils_lock;
     }
@@ -24,7 +45,11 @@
         if (typeof xulG != 'undefined') {
             if (typeof xulG.unlock_tab == 'function') {
                 xulG.unlock_tab();
+            } else {
+                oils_unsaved_data_P();
             }
+        } else {
+            oils_unsaved_data_P();
         }
         return window.oils_lock;
     }

Modified: trunk/Open-ILS/xul/staff_client/chrome/content/main/menu.js
===================================================================
--- trunk/Open-ILS/xul/staff_client/chrome/content/main/menu.js	2010-12-09 06:41:38 UTC (rev 18941)
+++ trunk/Open-ILS/xul/staff_client/chrome/content/main/menu.js	2010-12-09 11:09:06 UTC (rev 18942)
@@ -140,7 +140,7 @@
 
                 for (var id in obj.tab_semaphores) {
                     if (obj.tab_semaphores[id] > 0) {
-                        obj.global_unsaved_data_P();
+                        oils_unsaved_data_P();
                     }
                 }
 
@@ -1386,7 +1386,7 @@
             if (this.tab_semaphores[id] > 0) {
                 var confirmation = window.confirm(offlineStrings.getString('menu.close_tab.unsaved_data_warning'));
                 if (!confirmation) { return; }
-                obj.global_unsaved_data_P();
+                oils_unsaved_data_P();
             }
             delete this.tab_semaphores[id];
         }
@@ -1646,22 +1646,6 @@
 
     'tab_semaphores' : {},
 
-    'global_unsaved_data_V' : function() {
-        var obj = this;
-        obj.data.stash_retrieve();
-        if (typeof obj.data.unsaved_data == 'undefined') { obj.data.unsaved_data = 0; }
-        obj.data.unsaved_data++;
-        obj.data.stash('unsaved_data');
-    },
-    'global_unsaved_data_P' : function() {
-        var obj = this;
-        obj.data.stash_retrieve();
-        if (typeof obj.data.unsaved_data == 'undefined') { obj.data.unsaved_data = 0; }
-        obj.data.unsaved_data++;
-        if (obj.data.unsaved_data < 0) { obj.data.unsaved_data = 0; }
-        obj.data.stash('unsaved_data');
-    },
-
     'set_tab' : function(url,params,content_params) {
         var obj = this;
         if (!url) url = '/xul/server/';
@@ -1678,7 +1662,7 @@
                 if (obj.tab_semaphores[id] > 0) {
                     var confirmation = window.confirm(offlineStrings.getString('menu.replace_tab.unsaved_data_warning'));
                     if (!confirmation) { return; }
-                    obj.global_unsaved_data_P();
+                    oils_unsaved_data_P();
                 }
                 delete obj.tab_semaphores[id];
             }
@@ -1695,7 +1679,7 @@
                 obj.tab_semaphores[id] = 0;
             }
             obj.tab_semaphores[id]++; 
-            obj.global_unsaved_data_V();
+            oils_unsaved_data_V();
             return obj.tab_semaphores[id]; 
         };
         content_params.unlock_tab = function() { 
@@ -1705,7 +1689,7 @@
             }
             obj.tab_semaphores[id]--;
             if (obj.tab_semaphores[id] < 0) { obj.tab_semaphores[id] = 0; } 
-            obj.global_unsaved_data_P();
+            oils_unsaved_data_P();
             return obj.tab_semaphores[id]; 
         };
         content_params.inspect_tab = function() {



More information about the open-ils-commits mailing list