confirm window closure if tabs within the window are locked
authorphasefx <phasefx@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Tue, 7 Dec 2010 16:58:10 +0000 (16:58 +0000)
committerphasefx <phasefx@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Tue, 7 Dec 2010 16:58:10 +0000 (16:58 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@18926 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/xul/staff_client/chrome/content/main/menu.js
Open-ILS/xul/staff_client/chrome/locale/en-US/offline.properties

index c120381..233e075 100644 (file)
@@ -119,6 +119,31 @@ 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;
+                    }
+                }
+
+                return true;
+
+            },
+            false
+        );
+
         var cmd_map = {
             'cmd_broken' : [
                 ['oncommand'],
@@ -128,7 +153,10 @@ main.menu.prototype = {
             /* File Menu */
             'cmd_close_window' : [ 
                 ['oncommand'], 
-                function() { window.close(); } 
+                function() {
+                    JSAN.use('util.widgets');
+                    util.widgets.dispatch('close',window);
+                }
             ],
             'cmd_new_window' : [
                 ['oncommand'],
index b94d60a..cee3330 100644 (file)
@@ -282,3 +282,4 @@ menu.tab9.accesskey=9
 menu.tab10.accesskey=0
 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?