1 sdump('D_WIN','Loading win.js\n');
4 // alert() replacement, intended to stop barcode scanners from "scanning through" the dialog
6 // get a reference to the prompt service component.
7 var promptService = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
8 .getService(Components.interfaces.nsIPromptService);
10 // set the buttons that will appear on the dialog. It should be
11 // a set of constants multiplied by button position constants. In this case,
12 // three buttons appear, Save, Cancel and a custom button.
13 //var flags=promptService.BUTTON_TITLE_OK * promptService.BUTTON_POS_0 +
14 // promptService.BUTTON_TITLE_CANCEL * promptService.BUTTON_POS_1 +
15 // promptService.BUTTON_TITLE_IS_STRING * promptService.BUTTON_POS_2;
16 var flags = promptService.BUTTON_TITLE_IS_STRING * promptService.BUTTON_POS_0;
18 // display the dialog box. The flags set above are passed
19 // as the fourth argument. The next three arguments are custom labels used for
20 // the buttons, which are used if BUTTON_TITLE_IS_STRING is assigned to a
21 // particular button. The last two arguments are for an optional check box.
23 sdump('D_WIN','s_alert: ' + s);
24 promptService.confirmEx(window,"ALERT",
28 "Check this box to confirm this message",
37 function new_window(chrome,params) {
38 var name = self.name + '_' + ++mw.G['window_name_increment'];
39 var options = 'chrome,resizable=yes,scrollbars=yes,width=800,height=600,fullscreen=yes';
42 if (params['window_name']) { name = params.window_name; }
43 if (params['window_options']) { options = params.window_options; }
47 //var w = window.open(
48 var w = SafeWindowOpen(
55 w.parentWindow = self;
59 w.am_i_a_top_level_tab = false;
68 // From: Bryan White on netscape.public.mozilla.xpfe, Oct 13, 2004
69 // Message-ID: <ckjh7a$18q1@ripley.netscape.com>
70 // Modified to return window handler, and do errors differently
71 function SafeWindowOpen(url,title,features)
75 netscape.security.PrivilegeManager
76 .enablePrivilege("UniversalXPConnect");
77 const CI = Components.interfaces;
79 Components.classes["@mozilla.org/preferences-service;1"]
80 .getService(CI.nsIPrefBranch);
85 // pref 'dom.disable_open_during_load' is the main popup
87 blocked = PB.getBoolPref("dom.disable_open_during_load");
89 PB.setBoolPref("dom.disable_open_during_load",false);
90 w = window.open(url,title,features);
94 //alert("SafeWindowOpen error:\n\n" + e);
98 PB.setBoolPref("dom.disable_open_during_load",true);
103 function register_window(w) {
104 mw.G['win_list'].push(w);
107 function register_patron_window(w) { }
108 function unregister_patron_window(w) { }
110 function close_all_windows() {
112 while (w = mw.G['win_list'].pop()) {
117 function spawn_copy_browser(tab,params) {
118 sdump('D_WIN','trying to spawn_copy_browser('+js2JSON(params)+')\n');
120 var chrome = 'chrome://evergreen/content/cat/browse_list.xul';
122 if (tab != 'replace') { tabWindow.new_tab('main_tabbox'); }
123 w = tabWindow.replace_tab('main_tabbox','COPIES',chrome);
125 w = mw.new_window( chrome );
127 w.find_this_id = params[0];
128 w.record_columns = params;
131 function spawn_batch_copy_editor(tab,params) {
132 sdump('D_WIN','trying to spawn_copy_editor(' + params + ')');
134 var chrome = 'chrome://evergreen/content/cat/copy_edit.xul';
136 if (tab != 'replace') { tabWindow.new_tab('main_tabbox'); }
137 w = tabWindow.replace_tab('main_tabbox','COPIES EDITOR',chrome);
139 w = mw.new_window( chrome );
144 function spawn_marc_editor(tab,params) {
145 sdump('D_WIN','trying to spawn_marc_editor('+js2JSON(params)+')\n');
147 var chrome = 'chrome://evergreen/content/cat/marc.xul';
149 if (tab != 'replace') { tabWindow.new_tab('main_tabbox'); }
150 w = tabWindow.replace_tab('main_tabbox','MARC',chrome);
152 w = mw.new_window( chrome );
154 w.find_this_id = params[0];
155 w.record_columns = params;
159 function spawn_oclc_import(tab,params) {
160 sdump('D_WIN','trying to spawn_marc_editor('+js2JSON(params)+')\n');
161 // sample TCN: 03715963
163 if (params.tcn.length < 6) {
164 throw("Too short. At the moment, we're really doing a search rather than a retrieve, and it's a substring search at that. We grab the result that matches exactly. But sending a short query would just be mean. :)");
166 var result = user_request(
168 'open-ils.search.z3950.import',
169 [ mw.G.auth_ses[0], params.tcn ]
171 if (typeof result == 'object') {
172 if (result.records.length > 0) {
173 params['import_tree'] = result.records[0];
175 throw('no records. result = ' + js2JSON(result) + '\n');
178 throw('result: ' + js2JSON(result) + '\n');
181 var chrome = 'chrome://evergreen/content/cat/marc.xul';
183 if (tab != 'replace') { tabWindow.new_tab('main_tabbox'); }
184 w = tabWindow.replace_tab('main_tabbox','MARC',chrome);
186 w = mw.new_window( chrome );
190 //w.record_columns = params;
198 function spawn_bill_pay(tab,patron,params) {
199 sdump('D_WIN','trying to spawn_bill_pay('+js2JSON(patron)+')\n');
200 sdump('D_WIN','barcode: ' + patron.barcode() + '\n');
202 var chrome = 'chrome://evergreen/content/bill/bill.xul';
203 var params = { 'barcode' : patron.barcode() };
205 if (tab != 'replace') { tabWindow.new_tab('main_tabbox'); }
206 w = tabWindow.replace_tab('main_tabbox','BILLS',chrome,params);
208 w = mw.new_window( chrome,params );
212 function spawn_check_out(tab,patron,params) {
213 sdump('D_WIN','trying to spawn_check_out('+js2JSON(patron)+')\n');
214 sdump('D_WIN','barcode: ' + patron.barcode() + '\n');
216 var chrome = 'chrome://evergreen/content/circ/checkout.xul';
217 var params = { 'barcode' : patron.barcode() };
219 if (tab != 'replace') { tabWindow.new_tab('main_tabbox'); }
220 w = tabWindow.replace_tab('main_tabbox','CHECK OUT',chrome,params);
222 w = mw.new_window( chrome,params );
226 function spawn_circ_list(tab,patron,params) {
227 sdump('D_WIN','trying to spawn_circ_list('+js2JSON(patron)+')\n');
228 sdump('D_WIN','barcode: ' + patron.barcode() + '\n');
230 var chrome = 'chrome://evergreen/content/circ/circ_list.xul';
231 var params = { 'barcode' : patron.barcode() };
233 if (tab != 'replace') { tabWindow.new_tab('main_tabbox'); }
234 w = tabWindow.replace_tab('main_tabbox','ITEMS OUT',chrome,params);
236 w = mw.new_window( chrome,params );
240 function spawn_patron_edit(tab,patron,params) {
241 sdump('D_WIN','trying to spawn_patron_edit('+js2JSON(patron)+')\n');
242 sdump('D_WIN','barcode: ' + patron.barcode() + '\n');
244 var chrome = 'chrome://evergreen/content/patron/patron_edit.xul';
245 var params = { 'barcode' : patron.barcode() };
247 if (tab != 'replace') { tabWindow.new_tab('main_tabbox'); }
248 w = tabWindow.replace_tab('main_tabbox','PATRON EDIT',chrome,params);
250 w = mw.new_window( chrome, params );
254 function spawn_test() {
255 var chrome = 'chrome://evergreen/content/patron/patron_edit.xul';
256 var params = { 'barcode':'101010101010101' };
257 var w = tabWindow.replace_tab('main_tabbox','TEST',chrome,params);