]> git.evergreen-ils.org Git - Evergreen.git/blob - Evergreen/staff_client/chrome/content/evergreen/util/spawn_win.js
some refactor and localization
[Evergreen.git] / Evergreen / staff_client / chrome / content / evergreen / util / spawn_win.js
1 function spawn_interface(d,tab_flag,tabbox,chrome,label,passthru_params) {
2         sdump('D_SPAWN','trying to spawn_window('+d+','+tab_flag+','+tabbox+','+chrome+','+label+','+js2JSON(passthru_params)+')\n');
3         var w;
4         if (tab_flag) {
5                 if (tab != 'replace') { new_tab(d,tabbox); }
6                 w = replace_tab(d,tabbox,label,chrome);
7         } else {
8                 w = new_window( chrome );
9         }
10         w.params = params;
11 }
12
13 function spawn_batch_copy_editor(d,tab_flag,passthru_params) {
14         var chrome = 'chrome://evergreen/content/cat/copy_edit.xul';
15         spawn_interface(d,tab_flag,'main_tabbox',chrome,getString('copies_editor_interface_label'),passthru_params);
16 }
17
18 function spawn_bill_pay(d,tab_flag,passthru_params) {
19         var chrome = 'chrome://evergreen/content/bill/bill.xul';
20         spawn_interface(d,tab_flag,'main_tabbox',chrome,getString('bills_interface_label'),passthru_params);
21 }
22
23 function spawn_check_in(d,tab_flag,passthru_params) {
24         var chrome = 'chrome://evergreen/content/circ/checkin.xul';
25         spawn_interface(d,tab_flag,'main_tabbox',chrome,getString('checkin_interface_label'),passthru_params);
26 }
27
28 function spawn_check_out(d,tab_flag,passthru_params) {
29         var chrome = 'chrome://evergreen/content/circ/checkout.xul';
30         spawn_interface(d,tab_flag,'main_tabbox',chrome,getString('checkout_interface_label'),passthru_params);
31 }
32
33 function spawn_circ_display(d,tab_flag,passthru_params) {
34         var chrome = 'chrome://evergreen/content/circ/circ_deck_patron.xul';
35         spawn_interface(d,tab_flag,'main_tabbox',chrome,getString('display_patron_interface_label'),passthru_params);
36 }
37
38 function spawn_circ_list(d,tab_flag,passthru_params) {
39         var chrome = 'chrome://evergreen/content/circ/circ_list.xul';
40         spawn_interface(d,tab_flag,'main_tabbox',chrome,getString('items_out_interface_label'),passthru_params);
41 }
42
43 function spawn_circ_search(d,tab_flag,passthru_params) {
44         var chrome = 'chrome://evergreen/content/circ/circ_deck_search.xul';
45         spawn_interface(d,tab_flag,'main_tabbox',chrome,getString('patron_search_interface_label'),passthru_params);
46 }
47
48 function spawn_copy_browser(d,tab_flag,passthru_params) {
49         var chrome = 'chrome://evergreen/content/cat/browse_list.xul';
50         spawn_interface(d,tab_flag,'main_tabbox',chrome,getString('copy_browser_interface_label'),passthru_params);
51 }
52
53 function spawn_main() {
54         try {
55                 var w = new_window('chrome://evergreen/content/evergreen/main/app_shell.xul');
56                 if (!w) { throw('window ref == null'); }
57                 try {
58                         w.document.title = G.user.usrname() + '@' + G.user_ou.name();
59                 } catch(E) {
60                         alert('Hrmm. ' + pretty_print( js2JSON(E) ) );
61                 }
62         } catch(E) {
63                 //incr_progressmeter('auth_meter',-100);
64                 //alert('Login failed on new_window: ' + js2JSON(E)); enable_login_prompts(); return;
65         }
66         //incr_progressmeter('auth_meter',100);
67 }
68
69 function spawn_marc_editor(d,tab_flag,passthru_params) {
70         var chrome = 'chrome://evergreen/content/cat/marc.xul';
71         spawn_interface(d,tab_flag,'main_tabbox',chrome,getString('marc_editor_interface_label'),passthru_params);
72 }
73
74 function spawn_opac_navigator(d,tab_flag,passthru_params) {
75         var chrome = 'chrome://evergreen/content/opac/opac.xul';
76         spawn_interface(d,tab_flag,'main_tabbox',chrome,getString('opac_navigator_interface_label'),passthru_params);
77 }
78
79 function spawn_oclc_import(d,tab_flag,params) {
80         sdump('D_SPAWN','trying to spawn_oclc_import('+js2JSON(passthru_params)+')\n');
81         // sample TCN: 03715963 
82         try {
83                 if (params.tcn.length < 6) {
84                         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. :)");
85                 }
86                 var result = user_request(
87                         'open-ils.search',
88                         'open-ils.search.z3950.import',
89                         [ G.auth_ses[0], params.tcn ]
90                 )[0];
91                 if (typeof result == 'object') {
92                         if (result.records.length > 0) {        
93                                 params['import_tree'] = result.records[0];
94                         } else {
95                                 throw('no records. result = ' + js2JSON(result) + '\n');
96                         }
97                 } else {
98                         throw('result: ' + js2JSON(result) + '\n');
99                 }
100                 spawn_marc_editor(d,tab_flag,params);
101         } catch(E) {
102                 handle_error(E);
103         }
104 }
105
106 function spawn_patron_edit(d,tab_flag,passthru_params) {
107         var chrome = 'chrome://evergreen/content/patron/patron_edit.xul';
108         spawn_interface(d,tab_flag,'main_tabbox',chrome,getString('patron_editor_interface_label'),passthru_params);
109 }
110
111 function spawn_patron_register(d,tab_flag,passthru_params) {
112         var chrome = 'chrome://evergreen/content/patron/patron_new.xul';
113         spawn_interface(d,tab_flag,'main_tabbox',chrome,getString('patron_register_interface_label'),passthru_params);
114 }
115
116
117 function spawn_copy_stat_cat_edit(d,tab_flag,passthru_params) {
118         var chrome = 'chrome://evergreen/content/stat_cat/copy_stat_cat_editor.xul';
119         spawn_interface(d,tab_flag,'main_tabbox',chrome,getString('copy_stat_cat_editor_interface'),passthru_params);
120 }
121
122 function spawn_patron_stat_cat_edit(d,tab_flag,passthru_params) {
123         var chrome = 'chrome://evergreen/content/stat_cat/patron_stat_cat_editor.xul';
124         spawn_interface(d,tab_flag,'main_tabbox',chrome,getString('patron_stat_cat_editor_interface'),passthru_params);
125 }
126
127 function spawn_survey_admin_wizard(d,tab_flag,passthru_params) {
128         var chrome = 'chrome://evergreen/content/survey/survey_wizard.xul';
129         spawn_interface(d,tab_flag,'main_tabbox',chrome,getString('survey_admin_interface_label'),passthru_params);
130 }
131
132
133 function spawn_z3950_import(d,tab_flag,passthru_params) {
134         var chrome = 'chrome://evergreen/content/z39_50/z39_50.xul';
135         spawn_interface(d,tab_flag,'main_tabbox',chrome,getString('z39_50_import_interface_label'),passthru_params);
136 }
137