From: phasefx Date: Fri, 21 Jan 2011 22:22:53 +0000 (+0000) Subject: more overzealous unsaved data prompts X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=be2b0649e99b749d85a4968151dfb4e3288962b7;p=evergreen%2Ftadl.git more overzealous unsaved data prompts onKeypress catches all sorts of stuff, like the control+w for closing tabs. Not good. Ideally we'd test event.isChar, but that's broken in Mozilla: https://bugzilla.mozilla.org/show_bug.cgi?id=312552 Instead we look to see if control, alt, or meta are being held down. Not perfect, but good enough for now. For example, won't ignore tabs for jumping from field to field, and won't realize the hotkey for clipboard pasting should trigger the unsaved data state. git-svn-id: svn://svn.open-ils.org/ILS/trunk@19257 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- diff --git a/Open-ILS/web/js/ui/default/actor/user/register.js b/Open-ILS/web/js/ui/default/actor/user/register.js index ceb0e70d07..8aa87c8244 100644 --- a/Open-ILS/web/js/ui/default/actor/user/register.js +++ b/Open-ILS/web/js/ui/default/actor/user/register.js @@ -764,11 +764,14 @@ function attachWidgetEvents(fmcls, fmfield, widget) { dojo.connect( widget.widget, 'onKeyPress', - function(){ - if (lock_ready && xulG && typeof xulG.lock_tab == 'function') { - if (! already_locked) { - xulG.lock_tab(); - already_locked = true; + function(ev){ + netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect'); + if (!(ev.altKey || ev.ctrlKey || ev.metaKey)) { + if (lock_ready && xulG && typeof xulG.lock_tab == 'function') { + if (! already_locked) { + xulG.lock_tab(); + already_locked = true; + } } } } diff --git a/Open-ILS/xul/staff_client/chrome/content/circ/offline_checkin.js b/Open-ILS/xul/staff_client/chrome/content/circ/offline_checkin.js index 5e98761c0c..e764878c73 100644 --- a/Open-ILS/xul/staff_client/chrome/content/circ/offline_checkin.js +++ b/Open-ILS/xul/staff_client/chrome/content/circ/offline_checkin.js @@ -28,9 +28,12 @@ function my_init() { JSAN.use('util.date'); function handle_lock(ev) { - if (!local_lock) { - local_lock = true; - xulG.lock(); + netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); + if (!(ev.altKey || ev.ctrlKey || ev.metakey)) { + if (!local_lock) { + local_lock = true; + xulG.lock(); + } } } $('i_barcode').addEventListener('keypress',handle_lock,false); diff --git a/Open-ILS/xul/staff_client/chrome/content/circ/offline_checkout.js b/Open-ILS/xul/staff_client/chrome/content/circ/offline_checkout.js index d35f352a8b..99da750bff 100644 --- a/Open-ILS/xul/staff_client/chrome/content/circ/offline_checkout.js +++ b/Open-ILS/xul/staff_client/chrome/content/circ/offline_checkout.js @@ -33,9 +33,12 @@ function my_init() { todayPlus = util.date.formatted_date(todayPlus,"%F"); function handle_lock(ev) { - if (!local_lock) { - local_lock = true; - xulG.lock(); + netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); + if (!(ev.altKey || ev.ctrlKey || ev.metakey)) { + if (!local_lock) { + local_lock = true; + xulG.lock(); + } } } diff --git a/Open-ILS/xul/staff_client/chrome/content/circ/offline_in_house_use.js b/Open-ILS/xul/staff_client/chrome/content/circ/offline_in_house_use.js index ef9cfd9bdb..f849b4eda2 100644 --- a/Open-ILS/xul/staff_client/chrome/content/circ/offline_in_house_use.js +++ b/Open-ILS/xul/staff_client/chrome/content/circ/offline_in_house_use.js @@ -26,9 +26,12 @@ function my_init() { } ); function handle_lock(ev) { - if (!local_lock) { - local_lock = true; - xulG.lock(); + netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); + if (!(ev.altKey || ev.ctrlKey || ev.metakey)) { + if (!local_lock) { + local_lock = true; + xulG.lock(); + } } } $('i_barcode').addEventListener('keypress',handle_lock,false); diff --git a/Open-ILS/xul/staff_client/chrome/content/circ/offline_register.js b/Open-ILS/xul/staff_client/chrome/content/circ/offline_register.js index b633e93468..f3e31c1e6a 100644 --- a/Open-ILS/xul/staff_client/chrome/content/circ/offline_register.js +++ b/Open-ILS/xul/staff_client/chrome/content/circ/offline_register.js @@ -23,9 +23,12 @@ function my_init() { $('submit').addEventListener('command',next_patron,false); function handle_lock(ev) { - if (!local_lock) { - local_lock = true; - xulG.lock(); + netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); + if (!(ev.altKey || ev.ctrlKey || ev.metakey)) { + if (!local_lock) { + local_lock = true; + xulG.lock(); + } } } $('barcode').addEventListener('keypress',handle_lock,false); diff --git a/Open-ILS/xul/staff_client/chrome/content/circ/offline_renew.js b/Open-ILS/xul/staff_client/chrome/content/circ/offline_renew.js index 3824fe4757..d04cc5ac2a 100644 --- a/Open-ILS/xul/staff_client/chrome/content/circ/offline_renew.js +++ b/Open-ILS/xul/staff_client/chrome/content/circ/offline_renew.js @@ -30,9 +30,12 @@ function my_init() { todayPlus = util.date.formatted_date(todayPlus,"%F"); function handle_lock(ev) { - if (!local_lock) { - local_lock = true; - xulG.lock(); + netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); + if (!(ev.altKey || ev.ctrlKey || ev.metakey)) { + if (!local_lock) { + local_lock = true; + xulG.lock(); + } } } diff --git a/Open-ILS/xul/staff_client/server/cat/marcedit.js b/Open-ILS/xul/staff_client/server/cat/marcedit.js index 389db50985..2dfd226367 100644 --- a/Open-ILS/xul/staff_client/server/cat/marcedit.js +++ b/Open-ILS/xul/staff_client/server/cat/marcedit.js @@ -487,7 +487,7 @@ function setFocusToNextTag (row, direction) { function createMARCTextbox (element,attrs) { var box = createComplexXULElement('textbox', attrs, Array.prototype.slice.apply(arguments, [2]) ); - box.addEventListener('keypress',function(ev) { oils_lock_page(); },false); + box.addEventListener('keypress',function(ev) { netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); if (!(ev.altKey || ev.ctrlKey || ev.metaKey)) { oils_lock_page(); } },false); box.onkeypress = function (event) { var root_node; var node = element; diff --git a/Open-ILS/xul/staff_client/server/cat/marcedit.xul b/Open-ILS/xul/staff_client/server/cat/marcedit.xul index ab88a1f31d..be1b979db6 100644 --- a/Open-ILS/xul/staff_client/server/cat/marcedit.xul +++ b/Open-ILS/xul/staff_client/server/cat/marcedit.xul @@ -28,9 +28,9 @@