From be2b0649e99b749d85a4968151dfb4e3288962b7 Mon Sep 17 00:00:00 2001 From: phasefx Date: Fri, 21 Jan 2011 22:22:53 +0000 Subject: [PATCH] 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 --- Open-ILS/web/js/ui/default/actor/user/register.js | 13 +- .../chrome/content/circ/offline_checkin.js | 9 +- .../chrome/content/circ/offline_checkout.js | 9 +- .../chrome/content/circ/offline_in_house_use.js | 9 +- .../chrome/content/circ/offline_register.js | 9 +- .../chrome/content/circ/offline_renew.js | 9 +- Open-ILS/xul/staff_client/server/cat/marcedit.js | 2 +- Open-ILS/xul/staff_client/server/cat/marcedit.xul | 136 ++++++++++----------- 8 files changed, 107 insertions(+), 89 deletions(-) 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 ceb0e70d0..8aa87c824 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 5e98761c0..e764878c7 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 d35f352a8..99da750bf 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 ef9cfd9bd..f849b4eda 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 b633e9346..f3e31c1e6 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 3824fe475..d04cc5ac2 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 389db5098..2dfd22636 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 ab88a1f31..be1b979db 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 @@