]> git.evergreen-ils.org Git - working/Evergreen.git/blob - Evergreen/staff_client/chrome/content/evergreen/util/spawn_win.js
circ_tree
[working/Evergreen.git] / Evergreen / staff_client / chrome / content / evergreen / util / spawn_win.js
1 function spawn_interface(d,placement,place,chrome,label,passthru_params) {
2         sdump('D_SPAWN',arg_dump(arguments,{0:true,1:true,2:true,3:true,4:true,5:true}));
3         var w;
4         switch(placement) {
5                 case 'new_tab' : 
6                         new_tab(d,place); 
7                         w = spawn_interface(d,'replace_tab',place,chrome,label,passthru_params); break;
8
9                 case 'replace_tab' : 
10                         w = replace_tab(d,place,label,chrome); break;
11
12                 case 'new_window' : 
13                         w = new_window( chrome, { 'window_name' : label } ); break;
14
15
16                 case 'replace_iframe' :
17                 case 'replace_browser' :
18                 case 'replace_editor' :
19                         var el = placement.slice(8);
20                         var container = get_widget( d, place );
21                         empty_widget( d, container );
22                         w = spawn_interface(d,'new_' + el,place,chrome,label,passthru_params); 
23                         break;
24
25                 case 'new_iframe' :
26                 case 'new_browser' :
27                 case 'new_editor' :
28                         var el = placement.slice(4);
29                         var frame = d.createElement( el );
30                         frame.setAttribute('flex','1');
31                         get_widget( d, place ).appendChild( frame );
32                         w = spawn_interface(d,'set_frame',frame,chrome,label,passthru_params); 
33                         break;
34
35                 case 'set_frame' :
36                         var frame = get_widget( d, place );
37                         frame.setAttribute('src',chrome); 
38                         w = frame.contentWindow;
39                         break;
40         }
41         w.params = passthru_params;
42         w.mw = mw;
43         if (placement == 'new_tab' || placement == 'replace_tab') w.app_shell = d;
44         return w;
45 }
46
47 function spawn_batch_copy_editor(d,placement,place,passthru_params) {
48         var chrome = 'chrome://evergreen/content/cat/copy_edit.xul';
49         return spawn_interface(d,placement,place,chrome,getString('copies_editor_interface_label'),passthru_params);
50 }
51
52 function spawn_bill_pay(d,placement,place,passthru_params) {
53         var chrome = 'chrome://evergreen/content/bill/bill.xul';
54         return spawn_interface(d,placement,place,chrome,getString('bills_interface_label'),passthru_params);
55 }
56
57 function spawn_check_in(d,placement,place,passthru_params) {
58         var chrome = 'chrome://evergreen/content/circ/checkin.xul';
59         return spawn_interface(d,placement,place,chrome,getString('checkin_interface_label'),passthru_params);
60 }
61
62 function spawn_check_out(d,placement,place,passthru_params) {
63         var chrome = 'chrome://evergreen/content/circ/checkout.xul';
64         return spawn_interface(d,placement,place,chrome,getString('checkout_interface_label'),passthru_params);
65 }
66
67 function spawn_circ_display(d,placement,place,passthru_params) {
68         var chrome = 'chrome://evergreen/content/circ/circ_deck_patron.xul';
69         return spawn_interface(d,placement,place,chrome,getString('display_patron_interface_label'),passthru_params);
70 }
71
72 function spawn_circ_tree(d,placement,place,passthru_params) {
73         var chrome = 'chrome://evergreen/content/circ/circ_tree.xul';
74         return spawn_interface(d,placement,place,chrome,'circ_tree',passthru_params);
75 }
76
77 function spawn_circ_list(d,placement,place,passthru_params) {
78         var chrome = 'chrome://evergreen/content/circ/circ_list.xul';
79         return spawn_interface(d,placement,place,chrome,getString('items_out_interface_label'),passthru_params);
80 }
81
82 function spawn_circ_search(d,placement,place,passthru_params) {
83         var chrome = 'chrome://evergreen/content/circ/circ_deck_search.xul';
84         return spawn_interface(d,placement,place,chrome,getString('patron_search_interface_label'),passthru_params);
85 }
86
87 function spawn_clamshell(d,placement,place,passthru_params) {
88         var chrome = 'chrome://evergreen/content/main/clam_shell.xul';
89         return spawn_interface(d,placement,place,chrome,'clamshell',passthru_params);
90 }
91
92 function spawn_clamshell_vertical(d,placement,place,passthru_params) {
93         var chrome = 'chrome://evergreen/content/main/clam_shell_vertical.xul';
94         return spawn_interface(d,placement,place,chrome,'clamshell',passthru_params);
95 }
96
97 function spawn_copy_browser(d,placement,place,passthru_params) {
98         var chrome = 'chrome://evergreen/content/cat/browse_list.xul';
99         return spawn_interface(d,placement,place,chrome,getString('copy_browser_interface_label'),passthru_params);
100 }
101
102 function spawn_main() {
103         sdump('D_SPAWN','trying to spawn app_shell\n');
104         try {
105                 var w = new_window('chrome://evergreen/content/main/app_shell.xul');
106                 if (!w) { throw('window ref == null'); }
107                 try {
108                         w.document.title = G.user.usrname() + '@' + G.user_ou.name();
109                         w.params = {};
110                 } catch(E) {
111                         alert('Hrmm. ' + pretty_print( js2JSON(E) ) );
112                 }
113         } catch(E) {
114                 dump(js2JSON(E)+'\n');
115                 //incr_progressmeter('auth_meter',-100);
116                 //alert('Login failed on new_window: ' + js2JSON(E)); enable_login_prompts(); return;
117         }
118         //incr_progressmeter('auth_meter',100);
119 }
120
121 function spawn_marc_editor(d,placement,place,passthru_params) {
122         var chrome = 'chrome://evergreen/content/cat/marc.xul';
123         return spawn_interface(d,placement,place,chrome,getString('marc_editor_interface_label'),passthru_params);
124 }
125
126 function spawn_opac_navigator(d,placement,place,passthru_params) {
127         var chrome = 'chrome://evergreen/content/opac/opac.xul';
128         //var chrome = 'http://google.com/';
129         return spawn_interface(d,placement,place,chrome,getString('opac_navigator_interface_label'),passthru_params);
130 }
131
132 function spawn_oclc_import(d,placement,place,params) {
133         sdump('D_SPAWN','trying to spawn_oclc_import('+js2JSON(passthru_params)+')\n');
134         // sample TCN: 03715963 
135         try {
136                 if (params.tcn.length < 6) {
137                         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. :)");
138                 }
139                 var result = user_request(
140                         'open-ils.search',
141                         'open-ils.search.z3950.import',
142                         [ G.auth_ses[0], params.tcn ]
143                 )[0];
144                 if (typeof result == 'object') {
145                         if (result.records.length > 0) {        
146                                 params['import_tree'] = result.records[0];
147                         } else {
148                                 throw('no records. result = ' + js2JSON(result) + '\n');
149                         }
150                 } else {
151                         throw('result: ' + js2JSON(result) + '\n');
152                 }
153                 spawn_marc_editor(d,placement,place,params);
154         } catch(E) {
155                 handle_error(E);
156         }
157 }
158
159 function spawn_paged_tree(d,placement,place,passthru_params) {
160         var chrome = 'chrome://evergreen/content/main/paged_tree.xul';
161         return spawn_interface(d,placement,place,chrome,'paged_tree',passthru_params);
162 }
163
164 function spawn_patron_display(d,placement,place,passthru_params) {
165         var chrome = 'chrome://evergreen/content/patron/patron_display.xul';
166         return spawn_interface(d,placement,place,chrome,getString('patron_display_interface_label'),passthru_params);
167 }
168
169 function spawn_patron_display_status(d,placement,place,passthru_params) {
170         var chrome = 'chrome://evergreen/content/patron/patron_display_status.xul';
171         return spawn_interface(d,placement,place,chrome,getString('patron_display_interface_label'),passthru_params);
172 }
173
174 function spawn_patron_display_contact(d,placement,place,passthru_params) {
175         var chrome = 'chrome://evergreen/content/patron/patron_display_contact.xul';
176         return spawn_interface(d,placement,place,chrome,getString('patron_display_interface_label'),passthru_params);
177 }
178
179 function spawn_patron_edit(d,placement,place,passthru_params) {
180         var chrome = 'chrome://evergreen/content/patron/patron_edit.xul';
181         return spawn_interface(d,placement,place,chrome,getString('patron_editor_interface_label'),passthru_params);
182 }
183
184 function spawn_patron_register(d,placement,place,passthru_params) {
185         var chrome = 'chrome://evergreen/content/patron/patron_new.xul';
186         return spawn_interface(d,placement,place,chrome,getString('patron_register_interface_label'),passthru_params);
187 }
188
189 function spawn_patron_search(d,placement,place,passthru_params) {
190         var chrome = 'chrome://evergreen/content/patron/patron_search.xul';
191         return spawn_interface(d,placement,place,chrome,getString('patron_search_interface_label'),passthru_params);
192 }
193
194 function spawn_patron_search_form(d,placement,place,passthru_params) {
195         var chrome = 'chrome://evergreen/content/patron/patron_search_form.xul';
196         return spawn_interface(d,placement,place,chrome,getString('patron_search_interface_label'),passthru_params);
197 }
198
199 function spawn_patron_search_results(d,placement,place,passthru_params) {
200         var chrome = 'chrome://evergreen/content/patron/patron_search_results.xul';
201         return spawn_interface(d,placement,place,chrome,getString('patron_search_interface_label'),passthru_params);
202 }
203
204 function spawn_copy_stat_cat_edit(d,placement,place,passthru_params) {
205         var chrome = 'chrome://evergreen/content/stat_cat/copy_stat_cat_editor.xul';
206         return spawn_interface(d,placement,place,chrome,getString('copy_stat_cat_editor_interface'),passthru_params);
207 }
208
209 function spawn_patron_stat_cat_edit(d,placement,place,passthru_params) {
210         var chrome = 'chrome://evergreen/content/stat_cat/patron_stat_cat_editor.xul';
211         return spawn_interface(d,placement,place,chrome,getString('patron_stat_cat_editor_interface'),passthru_params);
212 }
213
214 function spawn_survey_admin_wizard(d,placement,place,passthru_params) {
215         var chrome = 'chrome://evergreen/content/survey/survey_wizard.xul';
216         return spawn_interface(d,placement,place,chrome,getString('survey_admin_interface_label'),passthru_params);
217 }
218
219
220 function spawn_z3950_import(d,placement,place,passthru_params) {
221         var chrome = 'chrome://evergreen/content/z39_50/z39_50.xul';
222         return spawn_interface(d,placement,place,chrome,getString('z39_50_import_interface_label'),passthru_params);
223 }
224
225 function spawn_javascript_console(d,placement,place,passthru_params) {
226         var chrome = 'chrome://global/content/console.xul';
227         return spawn_interface(d,placement,place,chrome,getString('javascript_console_label'),passthru_params);
228 }
229
230 function spawn_xuleditor(d,placement,place,passthru_params) {
231         var chrome = 'chrome://evergreen/content/util/xuledit.xul';
232         return spawn_interface(d,placement,place,chrome,getString('xuleditor_label'),passthru_params);
233 }
234
235 function spawn_javascript_shell(d,placement,place,passthru_params) {
236         var chrome = 'chrome://evergreen/content/util/shell.html';
237         return spawn_interface(d,placement,place,chrome,getString('javascript_shell_label'),passthru_params);
238 }