},
'logoff' : function() {
+
+ this.data.stash_retrieve();
+ if (typeof this.data.unsaved_data != 'undefined') {
+ if (this.data.unsaved_data > 0) {
+ var confirmation = window.confirm( document.getElementById('offlineStrings').getString('menu.logoff.unsaved_data_warning') );
+ if (!confirmation) { return; }
+ this.data.unsaved_data = 0;
+ this.data.stash('unsaved_data');
+ }
+ }
this.error.sdump('D_AUTH','logoff' + this.w + '\n');
this.controller.view.progress_bar.value = 0;
this.error.sdump('D_AUTH','close' + this.w + '\n');
- if (window.confirm(document.getElementById('authStrings').getString('staff.auth.controller.confirm_close'))) {
+ var confirm_string = document.getElementById('authStrings').getString('staff.auth.controller.confirm_close');
+
+ this.data.stash_retrieve();
+ if (typeof this.data.unsaved_data != 'undefined') {
+ if (this.data.unsaved_data > 0) {
+ confirm_string = document.getElementById('offlineStrings').getString('menu.shutdown.unsaved_data_warning');
+ }
+ }
+
+ if (window.confirm(confirm_string)) {
+ this.data.unsaved_data = 0;
+ this.data.stash('unsaved_data');
this.logoff();
this.w.close(); /* Probably won't go any further */
}
}
+ for (var id in obj.tab_semaphores) {
+ if (obj.tab_semaphores[id] > 0) {
+ obj.global_unsaved_data_P();
+ }
+ }
+
return true;
},
'cmd_shutdown' : [
['oncommand'],
function() {
- if (window.confirm(offlineStrings.getString('menu.cmd_shutdown.prompt'))) {
+ var confirm_string = offlineStrings.getString('menu.cmd_shutdown.prompt');
+ obj.data.stash_retrieve();
+ if (typeof obj.data.unsaved_data != 'undefined') {
+ if (obj.data.unsaved_data > 0) {
+ confirm_string = offlineStrings.getString('menu.shutdown.unsaved_data_warning');
+ }
+ }
+ if (window.confirm(confirm_string)) {
+ obj.data.unsaved_data = 0; // just in case the program doesn't close somehow
+ obj.data.stash('unsaved_data');
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
var windowManager = Components.classes["@mozilla.org/appshell/window-mediator;1"].getService();
var windowManagerInterface = windowManager.QueryInterface(Components.interfaces.nsIWindowMediator);
if (this.tab_semaphores[id] > 0) {
var confirmation = window.confirm(offlineStrings.getString('menu.close_tab.unsaved_data_warning'));
if (!confirmation) { return; }
- delete this.tab_semaphores[id];
+ obj.global_unsaved_data_P();
}
+ delete this.tab_semaphores[id];
}
this.controller.view.tabs.removeItemAt(idx);
'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/';
if (obj.tab_semaphores[id] > 0) {
var confirmation = window.confirm(offlineStrings.getString('menu.replace_tab.unsaved_data_warning'));
if (!confirmation) { return; }
- delete obj.tab_semaphores[id];
+ obj.global_unsaved_data_P();
}
+ delete obj.tab_semaphores[id];
}
}
var unique_id = idx + ':' + new Date();
obj.tab_semaphores[id] = 0;
}
obj.tab_semaphores[id]++;
+ obj.global_unsaved_data_V();
return obj.tab_semaphores[id];
};
content_params.unlock_tab = function() {
}
obj.tab_semaphores[id]--;
if (obj.tab_semaphores[id] < 0) { obj.tab_semaphores[id] = 0; }
+ obj.global_unsaved_data_P();
return obj.tab_semaphores[id];
};
content_params.inspect_tab = function() {