]> git.evergreen-ils.org Git - working/Evergreen.git/blob - Evergreen/staff_client/chrome/content/evergreen/util/spawn_win.js
new and improved spawn_interface()
[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','trying to spawn_interface('+d+','+placement+','+place+','+chrome+','+label+','+js2JSON(passthru_params)+')\n');
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                 } catch(E) {
91                         alert('Hrmm. ' + pretty_print( js2JSON(E) ) );
92                 }
93         } catch(E) {
94                 dump(js2JSON(E)+'\n');
95                 //incr_progressmeter('auth_meter',-100);
96                 //alert('Login failed on new_window: ' + js2JSON(E)); enable_login_prompts(); return;
97         }
98         //incr_progressmeter('auth_meter',100);
99 }
100
101 function spawn_marc_editor(d,placement,place,passthru_params) {
102         var chrome = 'chrome://evergreen/content/cat/marc.xul';
103         spawn_interface(d,placement,place,chrome,getString('marc_editor_interface_label'),passthru_params);
104 }
105
106 function spawn_opac_navigator(d,placement,place,passthru_params) {
107         var chrome = 'chrome://evergreen/content/opac/opac.xul';
108         //var chrome = 'http://google.com/';
109         spawn_interface(d,placement,place,chrome,getString('opac_navigator_interface_label'),passthru_params);
110 }
111
112 function spawn_oclc_import(d,placement,place,params) {
113         sdump('D_SPAWN','trying to spawn_oclc_import('+js2JSON(passthru_params)+')\n');
114         // sample TCN: 03715963 
115         try {
116                 if (params.tcn.length < 6) {
117                         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. :)");
118                 }
119                 var result = user_request(
120                         'open-ils.search',
121                         'open-ils.search.z3950.import',
122                         [ G.auth_ses[0], params.tcn ]
123                 )[0];
124                 if (typeof result == 'object') {
125                         if (result.records.length > 0) {        
126                                 params['import_tree'] = result.records[0];
127                         } else {
128                                 throw('no records. result = ' + js2JSON(result) + '\n');
129                         }
130                 } else {
131                         throw('result: ' + js2JSON(result) + '\n');
132                 }
133                 spawn_marc_editor(d,placement,place,params);
134         } catch(E) {
135                 handle_error(E);
136         }
137 }
138
139 function spawn_patron_edit(d,placement,place,passthru_params) {
140         var chrome = 'chrome://evergreen/content/patron/patron_edit.xul';
141         spawn_interface(d,placement,place,chrome,getString('patron_editor_interface_label'),passthru_params);
142 }
143
144 function spawn_patron_register(d,placement,place,passthru_params) {
145         var chrome = 'chrome://evergreen/content/patron/patron_new.xul';
146         spawn_interface(d,placement,place,chrome,getString('patron_register_interface_label'),passthru_params);
147 }
148
149
150 function spawn_copy_stat_cat_edit(d,placement,place,passthru_params) {
151         var chrome = 'chrome://evergreen/content/stat_cat/copy_stat_cat_editor.xul';
152         spawn_interface(d,placement,place,chrome,getString('copy_stat_cat_editor_interface'),passthru_params);
153 }
154
155 function spawn_patron_stat_cat_edit(d,placement,place,passthru_params) {
156         var chrome = 'chrome://evergreen/content/stat_cat/patron_stat_cat_editor.xul';
157         spawn_interface(d,placement,place,chrome,getString('patron_stat_cat_editor_interface'),passthru_params);
158 }
159
160 function spawn_survey_admin_wizard(d,placement,place,passthru_params) {
161         var chrome = 'chrome://evergreen/content/survey/survey_wizard.xul';
162         spawn_interface(d,placement,place,chrome,getString('survey_admin_interface_label'),passthru_params);
163 }
164
165
166 function spawn_z3950_import(d,placement,place,passthru_params) {
167         var chrome = 'chrome://evergreen/content/z39_50/z39_50.xul';
168         spawn_interface(d,placement,place,chrome,getString('z39_50_import_interface_label'),passthru_params);
169 }
170
171 function spawn_javascript_console(d,placement,place,passthru_params) {
172         var chrome = 'chrome://global/cotnent/console.xul';
173         spawn_interface(d,placement,place,chrome,getString('javascript_console_label'),passthru_params);
174 }
175
176 function spawn_xuleditor(d,placement,place,passthru_params) {
177         var chrome = 'chrome://evergreen/content/util/xuledit.xul';
178         spawn_interface(d,placement,place,chrome,getString('xuleditor_label'),passthru_params);
179 }
180
181 function spawn_javascript_shell(d,placement,place,passthru_params) {
182         var chrome = 'chrome://evergreen/content/util/shell.html';
183         spawn_interface(d,placement,place,chrome,getString('javascript_shell_label'),passthru_params);
184 }