From 88fe341b7cb67b6202f69dcf7f7e681e6b2cee30 Mon Sep 17 00:00:00 2001 From: phasefx Date: Tue, 7 Dec 2010 16:58:10 +0000 Subject: [PATCH] confirm window closure if tabs within the window are locked git-svn-id: svn://svn.open-ils.org/ILS/trunk@18926 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- .../xul/staff_client/chrome/content/main/menu.js | 30 +++++++++++++++++++++- .../chrome/locale/en-US/offline.properties | 1 + 2 files changed, 30 insertions(+), 1 deletion(-) 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 c120381364..233e07544e 100644 --- a/Open-ILS/xul/staff_client/chrome/content/main/menu.js +++ b/Open-ILS/xul/staff_client/chrome/content/main/menu.js @@ -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'], diff --git a/Open-ILS/xul/staff_client/chrome/locale/en-US/offline.properties b/Open-ILS/xul/staff_client/chrome/locale/en-US/offline.properties index b94d60a9f9..cee3330f56 100644 --- a/Open-ILS/xul/staff_client/chrome/locale/en-US/offline.properties +++ b/Open-ILS/xul/staff_client/chrome/locale/en-US/offline.properties @@ -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? -- 2.11.0