]> git.evergreen-ils.org Git - working/Evergreen.git/blob - Evergreen/staff_client/chrome/content/evergreen/util/spawn_win.js
using arg_dump
[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); break;
23
24                 case 'new_iframe' :
25                 case 'new_browser' :
26                 case 'new_editor' :
27                         var el = placement.slice(4);
28                         var frame = d.createElement( el );
29                         get_widget( d, place ).appendChild( frame );
30                         w = spawn_interface(d,'set_frame',frame,chrome,label,passthru_params); break;
31
32                 case 'set_frame' :
33                         var frame = get_widget( d, place );
34                         frame.setAttribute('src',chrome); 
35                         w = frame.contentWindow;
36                         break;
37         }
38         w.params = passthru_params;
39         w.mw = mw;
40         return w;
41 }
42
43 function spawn_batch_copy_editor(d,placement,place,passthru_params) {
44         var chrome = 'chrome://evergreen/content/cat/copy_edit.xul';
45         spawn_interface(d,placement,place,chrome,getString('copies_editor_interface_label'),passthru_params);
46 }
47
48 function spawn_bill_pay(d,placement,place,passthru_params) {
49         var chrome = 'chrome://evergreen/content/bill/bill.xul';
50         spawn_interface(d,placement,place,chrome,getString('bills_interface_label'),passthru_params);
51 }
52
53 function spawn_check_in(d,placement,place,passthru_params) {
54         var chrome = 'chrome://evergreen/content/circ/checkin.xul';
55         spawn_interface(d,placement,place,chrome,getString('checkin_interface_label'),passthru_params);
56 }
57
58 function spawn_check_out(d,placement,place,passthru_params) {
59         var chrome = 'chrome://evergreen/content/circ/checkout.xul';
60         spawn_interface(d,placement,place,chrome,getString('checkout_interface_label'),passthru_params);
61 }
62
63 function spawn_circ_display(d,placement,place,passthru_params) {
64         var chrome = 'chrome://evergreen/content/circ/circ_deck_patron.xul';
65         spawn_interface(d,placement,place,chrome,getString('display_patron_interface_label'),passthru_params);
66 }
67
68 function spawn_circ_list(d,placement,place,passthru_params) {
69         var chrome = 'chrome://evergreen/content/circ/circ_list.xul';
70         spawn_interface(d,placement,place,chrome,getString('items_out_interface_label'),passthru_params);
71 }
72
73 function spawn_circ_search(d,placement,place,passthru_params) {
74         var chrome = 'chrome://evergreen/content/circ/circ_deck_search.xul';
75         spawn_interface(d,placement,place,chrome,getString('patron_search_interface_label'),passthru_params);
76 }
77
78 function spawn_copy_browser(d,placement,place,passthru_params) {
79         var chrome = 'chrome://evergreen/content/cat/browse_list.xul';
80         spawn_interface(d,placement,place,chrome,getString('copy_browser_interface_label'),passthru_params);
81 }
82
83 function spawn_main() {
84         sdump('D_SPAWN','trying to spawn app_shell\n');
85         try {
86                 var w = new_window('chrome://evergreen/content/main/app_shell.xul');
87                 if (!w) { throw('window ref == null'); }
88                 try {
89                         w.document.title = G.user.usrname() + '@' + G.user_ou.name();
90                         w.params = {};
91                 } catch(E) {
92                         alert('Hrmm. ' + pretty_print( js2JSON(E) ) );
93                 }
94         } catch(E) {
95                 dump(js2JSON(E)+'\n');
96                 //incr_progressmeter('auth_meter',-100);
97                 //alert('Login failed on new_window: ' + js2JSON(E)); enable_login_prompts(); return;
98         }
99         //incr_progressmeter('auth_meter',100);
100 }
101
102 function spawn_marc_editor(d,placement,place,passthru_params) {
103         var chrome = 'chrome://evergreen/content/cat/marc.xul';
104         spawn_interface(d,placement,place,chrome,getString('marc_editor_interface_label'),passthru_params);
105 }
106
107 function spawn_opac_navigator(d,placement,place,passthru_params) {
108         var chrome = 'chrome://evergreen/content/opac/opac.xul';
109         //var chrome = 'http://google.com/';
110         spawn_interface(d,placement,place,chrome,getString('opac_navigator_interface_label'),passthru_params);
111 }
112
113 function spawn_oclc_import(d,placement,place,params) {
114         sdump('D_SPAWN','trying to spawn_oclc_import('+js2JSON(passthru_params)+')\n');
115         // sample TCN: 03715963 
116         try {
117                 if (params.tcn.length < 6) {
118                         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. :)");
119                 }
120                 var result = user_request(
121                         'open-ils.search',
122                         'open-ils.search.z3950.import',
123                         [ G.auth_ses[0], params.tcn ]
124                 )[0];
125                 if (typeof result == 'object') {
126                         if (result.records.length > 0) {        
127                                 params['import_tree'] = result.records[0];
128                         } else {
129                                 throw('no records. result = ' + js2JSON(result) + '\n');
130                         }
131                 } else {
132                         throw('result: ' + js2JSON(result) + '\n');
133                 }
134                 spawn_marc_editor(d,placement,place,params);
135         } catch(E) {
136                 handle_error(E);
137         }
138 }
139
140 function spawn_patron_edit(d,placement,place,passthru_params) {
141         var chrome = 'chrome://evergreen/content/patron/patron_edit.xul';
142         spawn_interface(d,placement,place,chrome,getString('patron_editor_interface_label'),passthru_params);
143 }
144
145 function spawn_patron_register(d,placement,place,passthru_params) {
146         var chrome = 'chrome://evergreen/content/patron/patron_new.xul';
147         spawn_interface(d,placement,place,chrome,getString('patron_register_interface_label'),passthru_params);
148 }
149
150
151 function spawn_copy_stat_cat_edit(d,placement,place,passthru_params) {
152         var chrome = 'chrome://evergreen/content/stat_cat/copy_stat_cat_editor.xul';
153         spawn_interface(d,placement,place,chrome,getString('copy_stat_cat_editor_interface'),passthru_params);
154 }
155
156 function spawn_patron_stat_cat_edit(d,placement,place,passthru_params) {
157         var chrome = 'chrome://evergreen/content/stat_cat/patron_stat_cat_editor.xul';
158         spawn_interface(d,placement,place,chrome,getString('patron_stat_cat_editor_interface'),passthru_params);
159 }
160
161 function spawn_survey_admin_wizard(d,placement,place,passthru_params) {
162         var chrome = 'chrome://evergreen/content/survey/survey_wizard.xul';
163         spawn_interface(d,placement,place,chrome,getString('survey_admin_interface_label'),passthru_params);
164 }
165
166
167 function spawn_z3950_import(d,placement,place,passthru_params) {
168         var chrome = 'chrome://evergreen/content/z39_50/z39_50.xul';
169         spawn_interface(d,placement,place,chrome,getString('z39_50_import_interface_label'),passthru_params);
170 }
171
172 function spawn_javascript_console(d,placement,place,passthru_params) {
173         var chrome = 'chrome://global/cotnent/console.xul';
174         spawn_interface(d,placement,place,chrome,getString('javascript_console_label'),passthru_params);
175 }
176
177 function spawn_xuleditor(d,placement,place,passthru_params) {
178         var chrome = 'chrome://evergreen/content/util/xuledit.xul';
179         spawn_interface(d,placement,place,chrome,getString('xuleditor_label'),passthru_params);
180 }
181
182 function spawn_javascript_shell(d,placement,place,passthru_params) {
183         var chrome = 'chrome://evergreen/content/util/shell.html';
184         spawn_interface(d,placement,place,chrome,getString('javascript_shell_label'),passthru_params);
185 }