From e41bb34cbc7cc869124ebaccf0965ec46c28a14c Mon Sep 17 00:00:00 2001 From: phasefx Date: Tue, 7 Dec 2010 16:58:17 +0000 Subject: [PATCH] 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 git-svn-id: svn://svn.open-ils.org/ILS/trunk@18928 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- .../chrome/content/OpenILS/global_util.js | 50 ++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/Open-ILS/xul/staff_client/chrome/content/OpenILS/global_util.js b/Open-ILS/xul/staff_client/chrome/content/OpenILS/global_util.js index 459a6288e..54d8665b5 100644 --- a/Open-ILS/xul/staff_client/chrome/content/OpenILS/global_util.js +++ b/Open-ILS/xul/staff_client/chrome/content/OpenILS/global_util.js @@ -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 = {}; -- 2.11.0