2 <!-- Application: Evergreen Staff Client -->
3 <!-- Screen: Workstation level search preferences -->
8 <?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
9 <?xml-stylesheet href="chrome://open_ils_staff_client/skin/global.css" type="text/css"?>
11 <!DOCTYPE window SYSTEM "chrome://open_ils_staff_client/locale/lang.dtd">
13 <?xul-overlay href="chrome://open_ils_staff_client/content/OpenILS/util_overlay_chrome.xul"?>
15 <window id="search_prefs_diag"
16 onload="try { my_init(); } catch(E) { alert(E); }"
17 xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
18 <script type="text/javascript">
19 var myPackageDir = 'open_ils_staff_client'; var IAMXUL = true;
21 <scripts id="openils_util_scripts"/>
22 <script type="text/javascript" src="JSAN.js"/>
35 JSAN.use('OpenILS.data');
36 data = new OpenILS.data();
37 data.init({'via':'stash'});
38 search_lib_box = document.getElementById('search_lib');
39 pref_lib_box = document.getElementById('pref_lib');
40 adv_pane_box = document.getElementById('adv_pane');
41 // NOTE: If this ever deals with custom trees, this is where you likely want to mess with things.
42 add_aou(data.tree.aou, '');
43 prefSvc = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefBranch).QueryInterface(Components.interfaces.nsIPrefBranch2);
44 saved_message = document.getElementById('saved_message').textContent;
45 cleared_message = document.getElementById('cleared_message').textContent;
46 if (data.search_lib) {
47 search_lib_box.value = data.search_lib;
49 search_lib_box.selectedIndex = 0;
52 pref_lib_box.value = data.pref_lib;
54 pref_lib_box.selectedIndex = 0;;
57 adv_pane_box.value = data.adv_pane;
59 adv_pane_box.selectedIndex = 0;
62 function add_aou(aou, depth) {
63 if (aou.children().length > 0) {
64 aou.children().sort(function(a, b) {
65 if (a.name() < b.name()) return -1;
66 if (a.name() > b.name()) return 1;
70 search_lib_box.appendItem(depth + aou.name(), aou.id(), '');
71 pref_lib_box.appendItem(depth + aou.name(), aou.id(), '');
72 for(var i = 0; i < aou.children().length; i++)
73 add_aou(aou.children()[i], depth + ' ');
75 function update_prefs() {
76 prefSvc.setIntPref('open-ils.' + data.server_unadorned + '.search_lib', search_lib_box.value);
77 prefSvc.setIntPref('open-ils.' + data.server_unadorned + '.pref_lib', pref_lib_box.value);
78 prefSvc.setCharPref('open-ils.' + data.server_unadorned + '.adv_pane', adv_pane_box.value);
79 data.search_lib = search_lib_box.value;
80 data.pref_lib = pref_lib_box.value;
81 data.adv_pane = adv_pane_box.value;
82 data.stash('search_lib');
83 data.stash('pref_lib');
84 data.stash('adv_pane');
87 function clear_prefs() {
88 prefSvc.clearUserPref('open-ils.' + data.server_unadorned + '.search_lib');
89 prefSvc.clearUserPref('open-ils.' + data.server_unadorned + '.pref_lib');
90 prefSvc.clearUserPref('open-ils.' + data.server_unadorned + '.adv_pane');
91 data.search_lib = null;
94 data.stash('search_lib');
95 data.stash('pref_lib');
96 data.stash('adv_pane');
97 alert(cleared_message);
101 <commandset id="search_prefs_cmds">
102 <command id="save_search_prefs" oncommand="update_prefs()" />
103 <command id="clear_search_prefs" oncommand="clear_prefs()" />
105 <vbox id="search_prefs_main">
107 <caption label="&staff.search_prefs.search_lib.caption;"/>
108 <description>&staff.search_prefs.search_lib.description;</description>
109 <menulist id="search_lib">
115 <caption label="&staff.search_prefs.pref_lib.caption;"/>
116 <description>&staff.search_prefs.pref_lib.description;</description>
117 <menulist id="pref_lib">
123 <caption label="&staff.search_prefs.adv_pane.caption;"/>
124 <description>&staff.search_prefs.adv_pane.description;</description>
125 <menulist id="adv_pane">
127 <menuitem label="&staff.search_prefs.adv_pane.advanced;" value="advanced" />
128 <menuitem label="&staff.search_prefs.adv_pane.numeric;" value="numeric" />
129 <menuitem label="&staff.search_prefs.adv_pane.expert;" value="expert" />
133 <button id="save_button" command="save_search_prefs" label="&staff.search_prefs.save.label;" accesskey="&staff.search_prefs.save.accesskey;"/>
134 <button id="clear_button" command="clear_search_prefs" label="&staff.search_prefs.clear.label;" accesskey="&staff.search_prefs.clear.accesskey;"/>
136 <description id="saved_message" style="display:none">&staff.search_prefs.saved_message;</description>
137 <description id="cleared_message" style="display:none">&staff.search_prefs.cleared_message;</description>