From ef7342df2832fec43fc7d890aa4bc8e61bb94ef2 Mon Sep 17 00:00:00 2001 From: phasefx Date: Mon, 12 Oct 2009 14:51:14 +0000 Subject: [PATCH] backport changesets 13953, 14017: persist mechanism replacement for 1.9 xulrunners git-svn-id: svn://svn.open-ils.org/ILS/branches/rel_1_6_0@14356 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- .../chrome/content/OpenILS/global_util.js | 44 +++++++++++++ .../chrome/content/circ/offline_checkin.xul | 6 +- .../chrome/content/circ/offline_checkout.xul | 8 +-- .../chrome/content/circ/offline_in_house_use.xul | 6 +- .../chrome/content/circ/offline_renew.xul | 8 +-- .../chrome/content/main/menu_frame.xul | 4 +- .../chrome/content/util/list_clipboard.xul | 4 +- .../xul/staff_client/server/cat/copy_buckets.xul | 2 +- .../staff_client/server/cat/copy_buckets_quick.xul | 2 +- .../xul/staff_client/server/cat/copy_editor.xul | 4 +- .../xul/staff_client/server/cat/copy_summary.xul | 4 +- Open-ILS/xul/staff_client/server/cat/marcedit.xul | 10 +-- .../xul/staff_client/server/cat/record_buckets.xul | 2 +- .../server/cat/record_buckets_overlay.xul | 2 +- .../server/cat/record_buckets_quick.xul | 2 +- .../xul/staff_client/server/cat/spine_labels.xul | 76 +++++++++++----------- .../xul/staff_client/server/cat/volume_editor.xul | 4 +- Open-ILS/xul/staff_client/server/cat/z3950.xul | 14 ++-- Open-ILS/xul/staff_client/server/circ/checkin.xul | 2 +- .../staff_client/server/circ/checkin_overlay.xul | 8 +-- Open-ILS/xul/staff_client/server/circ/checkout.xul | 2 +- .../staff_client/server/circ/checkout_overlay.xul | 4 +- .../xul/staff_client/server/circ/copy_details.xul | 4 +- .../xul/staff_client/server/circ/copy_status.xul | 2 +- .../server/circ/copy_status_overlay.xul | 4 +- .../xul/staff_client/server/circ/in_house_use.xul | 6 +- .../staff_client/server/patron/bill_history.xul | 10 +-- Open-ILS/xul/staff_client/server/patron/bills.xul | 2 +- .../staff_client/server/patron/bills_overlay.xul | 4 +- .../xul/staff_client/server/patron/display.xul | 2 +- .../staff_client/server/patron/display_horiz.xul | 2 +- .../server/patron/display_horiz_overlay.xul | 10 +-- .../staff_client/server/patron/display_overlay.xul | 10 +-- .../staff_client/server/patron/hold_notices.xul | 10 +-- Open-ILS/xul/staff_client/server/patron/holds.xul | 2 +- .../staff_client/server/patron/holds_overlay.xul | 4 +- .../xul/staff_client/server/patron/summary.xul | 2 +- .../server/patron/summary_overlay_horiz.xul | 2 +- 38 files changed, 169 insertions(+), 125 deletions(-) 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 f3cbb4ded8..042e8d2a6b 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 @@ -35,6 +35,50 @@ } } + function persist_helper() { + try { + netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); + var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components.interfaces['nsIPrefBranch']); + var nodes = document.getElementsByAttribute('oils_persist','*'); + for (var i = 0; i < nodes.length; i++) { + var base_key = 'oils_persist_' + String(location.hostname + location.pathname + '_' + nodes[i].getAttribute('id')).replace('/','_','g') + '_'; + var attribute_list = nodes[i].getAttribute('oils_persist').split(' '); + for (var j = 0; j < attribute_list.length; j++) { + var key = base_key + attribute_list[j]; + var value = prefs.prefHasUserValue(key) ? prefs.getCharPref(key) : null; + dump('persist_helper: retrieving key = ' + key + ' value = ' + value + ' for ' + nodes[i].nodeName + '\n'); + if (value) nodes[i].setAttribute( attribute_list[j], value ); + } + if (nodes[i].nodeName == 'checkbox' && attribute_list.indexOf('checked') > -1) { + var evt = document.createEvent("Events"); + evt.initEvent( 'command', true, true ); + nodes[i].dispatchEvent(evt); + nodes[i].addEventListener( + 'command', + function(bk) { + return function(ev) { + try { + netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); + var key = bk + 'checked'; + var value = ev.target.checked; + ev.target.setAttribute( 'checked', value ); + prefs.setCharPref( key, value ); + dump('persist_helper: setting key = ' + key + ' value = ' + value + ' for checkbox\n'); + } catch(E) { + alert('Error in persist_helper(), checkbox command event listener: ' + E); + } + }; + }(base_key), + false + ); + } + // TODO: Need to add event listeners for window resizing, splitter repositioning, grippy state, etc. + } + } catch(E) { + alert('Error in persist_helper(): ' + E); + } + } + function getKeys(o) { var keys = []; for (var k in o) keys.push(k); diff --git a/Open-ILS/xul/staff_client/chrome/content/circ/offline_checkin.xul b/Open-ILS/xul/staff_client/chrome/content/circ/offline_checkin.xul index d19616d0b4..8fa3bc47bb 100644 --- a/Open-ILS/xul/staff_client/chrome/content/circ/offline_checkin.xul +++ b/Open-ILS/xul/staff_client/chrome/content/circ/offline_checkin.xul @@ -16,7 +16,7 @@ @@ -50,7 +50,7 @@ &common.check_barcode.description; - +