Patch from Craig Ricciuto:
[Evergreen.git] / Open-ILS / xul / staff_client / server / cat / opac.xul
1 <?xml version="1.0"?>
2 <!-- Application: Evergreen Staff Client -->
3 <!-- Screen: Cataloger's Search Result Screen -->
4
5 <!-- ///////////////////////////////////////////////////////////////////////////////////////////////////////////// -->
6 <!-- STYLESHEETS -->
7 <?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
8 <?xml-stylesheet href="chrome://open_ils_staff_client/skin/global.css" type="text/css"?>
9
10 <!-- ///////////////////////////////////////////////////////////////////////////////////////////////////////////// -->
11 <!-- LOCALIZATION -->
12 <!DOCTYPE window PUBLIC "" ""[
13         <!--#include virtual="/opac/locale/${locale}/lang.dtd"-->
14 ]>
15
16 <!-- ///////////////////////////////////////////////////////////////////////////////////////////////////////////// -->
17 <!-- OVERLAYS -->
18 <?xul-overlay href="/xul/server/OpenILS/util_overlay.xul"?>
19
20 <window id="opac_win"
21         onload="try { my_init(); font_helper(); } catch(E) { alert(E); }"
22         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
23
24         <!-- ///////////////////////////////////////////////////////////////////////////////////////////////////////////// -->
25         <!-- BEHAVIOR -->
26         <script type="text/javascript">
27                 var myPackageDir = 'open_ils_staff_client'; var IAMXUL = true; var g = {};
28                 netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
29         </script>
30         <scripts id="openils_util_scripts"/>
31
32         <script type="text/javascript" src="/xul/server/main/JSAN.js"/>
33         <script>
34         <![CDATA[
35                 function $(id) { return document.getElementById(id); }
36                 function $w(id,text) { if ($(id)) util.widgets.set_text($(id),text); }
37
38                 var docid; var marc_html; var top_pane; var bottom_pane; var opac_frame; 
39                 var browser_frame; var browser_obj; var browser_win;
40                 var editor_obj;
41                 var holdings_obj;
42                 var holds_obj;
43
44                 var iframe_method = 'reset_iframe'; // set_iframe
45
46                 function my_init() {
47                         try {
48                                 netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
49                                         if (typeof JSAN == 'undefined') { throw( $("commonStrings").getString('common.jsan.missing') ); }
50                                 JSAN.errorLevel = "die"; // none, warn, or die
51                                 JSAN.addRepository('/xul/server/');
52                                 JSAN.use('util.error'); g.error = new util.error();
53                                 g.error.sdump('D_TRACE','my_init() for cat/opac.xul');
54
55                                 JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'});
56                                 XML_HTTP_SERVER = data.server_unadorned;
57
58                                 JSAN.use('util.network'); g.network = new util.network();
59
60                                 try { authtime = xul_param('authtime'); } catch(E) { g.error.sdump('D_ERROR',E); }
61                                 try { docid = xul_param('docid'); } catch(E) { g.error.sdump('D_ERROR',E); }
62                                 try { opac_url = xul_param('opac_url'); } catch(E) { g.error.sdump('D_ERROR',E); }
63
64                                 JSAN.use('util.deck');
65                                 top_pane = new util.deck('top_pane');
66                                 bottom_pane = new util.deck('bottom_pane');
67
68                                 set_opac();
69
70                         } catch(E) {
71                                 var err_msg = document.getElementById("commonStrings").getFormattedString('common.exception', ['cat/opac.xul', E]);
72                                 try { g.error.sdump('D_ERROR',err_msg); } catch(E) { dump(err_msg); }
73                                 alert(err_msg);
74                         }
75                 }
76
77                 function set_brief_view() {
78                         try {
79                                 var url = xulG.url_prefix( urls.XUL_BIB_BRIEF ); // + '?docid=' + window.escape(docid); 
80                                 dump('spawning ' + url + '\n');
81                                 top_pane[iframe_method]( 
82                                         url,
83                                         {}, 
84                                         { 
85                                                 'docid' : docid,
86                                                 'set_tab_name' : function(n) { 
87                                                         if (typeof window.xulG == 'object' && typeof window.xulG.set_tab_name == 'function') {
88                                                                 try { window.xulG.set_tab_name('Bib Record: ' + n); } catch(E) { alert(E); }
89                                                         } else {
90                                                                 dump('no set_tab_name\n');
91                                                         }
92                                                 }
93                                         }  
94                                 );
95                         } catch(E) {
96                                 alert(E);
97                         }
98                 }
99
100                 function set_marc_view() {
101                         try {
102                                 bottom_pane[iframe_method]( 
103                                         xulG.url_prefix( urls.XUL_MARC_VIEW ), // + '?docid=' + window.escape(docid),
104                                         {},
105                                         {
106                                                 'docid' : docid,
107                                         }
108                                 );
109                         } catch(E) {
110                                 alert(E);
111                         }
112                 }
113
114                 function set_marc_edit() {
115                         try {
116                                 bottom_pane.node.selectedIndex = 1;
117                                 var content_params = { 
118                                         'show_nav_buttons' : false,
119                                         'show_print_button' : false,
120                                         'passthru_content_params' : { 
121                                                 'record' : { 'url' : '/opac/extras/supercat/retrieve/marcxml/record/' + docid },
122                                                 'save' : {
123                                                         'label' : 'Save Record',
124                                                         'func' : function (new_marcxml) {
125                                                                 try {
126                                                                         var r = g.network.simple_request('MARC_XML_RECORD_UPDATE', [ ses(), docid, new_marcxml ]);
127                                                                         if (typeof r.ilsevent != 'undefined') {
128                                                                                 throw(r);
129                                                                         } else {
130                                                                                 alert( $("catStrings").getString('staff.cat.opac.set_marc_edit.alert') );
131                                                                         }
132                                                                 } catch(E) {
133                                                                                 g.error.standard_unexpected_error_alert( $("catStrings").getString('staff.cat.opac.set_marc_edit.std_unexpected_error'), E );
134                                                                 }
135                                                         }
136                                                 },
137                                         },
138                                         'url' : xulG.url_prefix( urls.XUL_MARC_EDIT ),
139                                         'name' : 'MarcEditor',
140                                 };
141                                 if (editor_obj) return;
142                                 JSAN.use('util.browser');
143                                 editor_obj = new util.browser();
144                                 editor_obj.init(
145                                         {
146                                                 'url' : xulG.url_prefix(urls.XUL_REMOTE_BROWSER), // + '?name=MarcEditor',
147                                                 'push_xulG' : true,
148                                                 'alt_print' : false,
149                                                 'browser_id' : 'editor',
150                                                 'passthru_content_params' : content_params,
151                                         }
152                                 );
153                         } catch(E) {
154                                 g.error.sdump('D_ERROR','set_marc_edit: ' + E);
155                                 alert('set_marc_edit: ' + E);
156                         }
157                 }
158
159                 function set_copy_browser() {
160                         try {
161                                 bottom_pane.node.selectedIndex = 2;
162                                 xulG.docid = docid;
163                                 var content_params = { 
164                                         'show_nav_buttons' : false,
165                                         'show_print_button' : false,
166                                         'passthru_content_params' : xulG,
167                                         'url' : xulG.url_prefix( urls.XUL_COPY_VOLUME_BROWSE ), // + '?docid=' + window.escape(docid),
168                                         'name' : 'HoldingsMaintenance',
169                                 };
170                                 if (holdings_obj) return;
171                                 JSAN.use('util.browser');
172                                 holdings_obj = new util.browser();
173                                 holdings_obj.init(
174                                         {
175                                                 'url' : xulG.url_prefix(urls.XUL_REMOTE_BROWSER), // + '?name=HoldingsMaintenance',
176                                                 'push_xulG' : true,
177                                                 'alt_print' : false,
178                                                 'browser_id' : 'holdings',
179                                                 'passthru_content_params' : content_params,
180                                         }
181                                 );
182
183                                 //bottom_pane.set_iframe( xulG.url_prefix( urls.XUL_COPY_VOLUME_BROWSE ) + '?docid=' + window.escape(docid),{},xulG);
184                         } catch(E) {
185                                 alert(E);
186                         }
187                 }
188
189                 function set_hold_browser() {
190                         try {
191                                 bottom_pane.node.selectedIndex = 3;
192                                 xulG.docid = docid;
193                                 var content_params = { 
194                                         'show_nav_buttons' : false,
195                                         'show_print_button' : false,
196                                         'passthru_content_params' : xulG,
197                                         'url' : xulG.url_prefix( urls.XUL_HOLDS_BROWSER ), // + '?docid=' + window.escape(docid),
198                                         'name' : 'Holds',
199                                 };
200                                 if (holds_obj) return;
201                                 JSAN.use('util.browser');
202                                 holds_obj = new util.browser();
203                                 holds_obj.init(
204                                         {
205                                                 'url' : xulG.url_prefix(urls.XUL_REMOTE_BROWSER), // + '?name=Holds',
206                                                 'push_xulG' : true,
207                                                 'alt_print' : false,
208                                                 'browser_id' : 'holds',
209                                                 'passthru_content_params' : content_params,
210                                         }
211                                 );
212                                 //bottom_pane.set_iframe( xulG.url_prefix( urls.XUL_HOLDS_BROWSER ) + '?docid=' + window.escape(docid),{},xulG);
213                         } catch(E) {
214                                 alert(E);
215                         }
216                 }
217
218                 function set_opac() {
219                         try {
220                                 bottom_pane.node.selectedIndex = 0;
221                                 var content_params = { 
222                                         'show_nav_buttons' : true,
223                                         'show_print_button' : true,
224                                         'passthru_content_params' : { 
225                                                 'authtoken' : ses(), 
226                                                 'authtime' : ses('authtime'),
227                                                 'window_open' : function(a,b,c) {
228                                                         try {
229                                                                 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect UniversalBrowserWrite');
230                                                                 return window.open(a,b,c);
231                                                         } catch(E) {
232                                                                 g.error.standard_unexpected_error_alert('window_open',E);
233                                                         }
234                                                 }
235                                         },
236                                         'on_url_load' : function(f) {
237                                                 netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
238                                                 var win;
239                                                 try {
240                                                         if (typeof f.contentWindow.wrappedJSObject.attachEvt != 'undefined') {
241                                                                 win = f.contentWindow.wrappedJSObject;
242                                                         } else {
243                                                                 win = f.contentWindow;
244                                                         }
245                                                 } catch(E) {
246                                                         win = f.contentWindow;
247                                                 }
248                                                 browser_win = win;
249                                                 win.attachEvt("rdetail", "recordRetrieved",
250                                                         function(id){
251                                                                 try {
252                                                                         docid = id;
253                                                                         browser_obj = null; editor_obj = null; holdings_obj = null; holds_obj = null;
254                                                                         top_pane.clear(); bottom_pane.clear();
255                                                                         set_brief_view();
256                                                                         document.getElementById('nav').setAttribute('hidden','false');
257                                                                 } catch(E) {
258                                                                         g.error.standard_unexpected_error_alert('rdetail -> recordRetrieved',E);
259                                                                 }
260                                                         }
261                                                 );
262                                         },
263                                         'url_prefix' : xulG.url_prefix,
264                                         'name' : 'Catalog',
265                                 };
266                                 if (opac_url) content_params.url = opac_url;
267                                 if (browser_obj) return;
268                                 JSAN.use('util.browser');
269                                 browser_obj = new util.browser();
270                                 browser_obj.init(
271                                         {
272                                                 'url' : xulG.url_prefix(urls.XUL_REMOTE_BROWSER), // + '?name=Catalog',
273                                                 'push_xulG' : true,
274                                                 'alt_print' : false,
275                                                 'browser_id' : 'browser',
276                                                 'passthru_content_params' : content_params,
277                                         }
278                                 );
279                                 //browser_frame = bottom_pane.set_browser( xulG.url_prefix(urls.XUL_REMOTE_BROWSER) + '?name=Catalog', {}, content_params);
280                         } catch(E) {
281                                 g.error.sdump('D_ERROR','set_opac: ' + E);
282                                 alert('set_opac: ' + E);
283                         }
284                 }
285
286                 function bib_in_new_tab() {
287                         try {
288                                 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
289                                 var url = browser_win.location.href;
290                                 var content_params = { 'session' : ses(), 'authtime' : ses('authtime'), 'opac_url' : url };
291                                 xulG.new_tab(xulG.url_prefix(urls.XUL_OPAC_WRAPPER), {}, content_params);
292                         } catch(E) {
293                                 g.error.sdump('D_ERROR',E);
294                                 alert(E);
295                         }
296                 }
297
298                 function remove_me() {
299                         try {
300                                 browser_obj = null; editor_obj = null; holdings_obj = null; holds_obj = null;
301                                 top_pane.clear(); bottom_pane.clear();
302                                 document.getElementById('nav').setAttribute('hidden','true');
303                         } catch(E) {
304                                 alert(E);
305                         }
306                 }
307
308                 function add_to_bucket() {
309                         try {
310                                 JSAN.use('util.window'); var win = new util.window();
311                                 win.open(
312                                         xulG.url_prefix(urls.XUL_RECORD_BUCKETS),
313                                         //+ '?record_ids=' + js2JSON( [ docid ] ),
314                                         'sel_bucket_win' + win.window_name_increment(),
315                                         'chrome,resizable,modal,center',
316                                         { 'record_ids' : [ docid ] }
317                                 );
318                         } catch(E) {
319                                 alert(E);
320                         }
321                 }
322
323                 function refresh() {
324                         alert( $("catStrings").getString('staff.cat.opac.refresh.function_not_implemented.alert') );
325                 }
326         ]]>
327         </script>
328         
329         <messagecatalog id="catStrings" src="/xul/server/locale/<!--#echo var='locale'-->/cat.properties" />
330         <messagecatalog id="circStrings" src="/xul/server/locale/<!--#echo var='locale'-->/circ.properties" />
331         <messagecatalog id="commonStrings" src="/xul/server/locale/<!--#echo var='locale'-->/common.properties" />
332
333         <commandset><command id="cmd_forward"/><command id="cmd_back"/></commandset>
334
335         <vbox flex="1">
336                 <deck id="top_pane"/>
337                 <splitter><grippy/></splitter>
338                 <menubar id="nav" hidden="true">
339                         <menu label="&staff.cat.opac.menu.label;" accesskey="&staff.cat.opac.menu.accesskey;">
340                         <menupopup>
341                         <menuitem label="&staff.cat.opac.menuitem.opacview.label;" accesskey="&staff.cat.opac.menuitem.opacview.accesskey;" id="opac_view" oncommand="set_opac();"/>
342                         <menuitem label="&staff.cat.opac.menuitem.marcview.label;" accesskey="&staff.cat.opac.menuitem.marcview.accesskey;" id="marc_view" oncommand="set_marc_view();"/>
343                         <menuitem label="&staff.cat.opac.menuitem.marcedit.label;" accesskey="&staff.cat.opac.menuitem.marcedit.accesskey;" id="marc_edit" oncommand="set_marc_edit();"/>
344                         <menuitem label="&staff.cat.opac.menuitem.holding.label;" accesskey="&staff.cat.opac.menuitem.holding.accesskey;" id="copy_browse" oncommand="set_copy_browser();"/>
345                         <menuitem label="&staff.cat.opac.menuitem.viewholds.label;" accesskey="&staff.cat.opac.menuitem.viewholds.accesskey;" id="view_holds" oncommand="set_hold_browser();"/>
346                         <menuseparator/>
347                         <menuitem label="&staff.cat.opac.menuitem.addtobucket.label;" accesskey="&staff.cat.opac.menuitem.addtobucket.accesskey;" id="add_bucket" oncommand="add_to_bucket();"/>
348                         <menuseparator/>
349                         <menuitem label="&staff.cat.opac.menuitem.refreshinterfaces.label;" id="refresh" oncommand="refresh();"/>
350                         <menuitem label="&staff.cat.opac.menuitem.dupnewtab.label;" id="bib_in_new_tab" oncommand="bib_in_new_tab();"/>
351                         <menuitem label="&staff.cat.opac.menuitem.removeframe.label;" id="remove_me" oncommand="remove_me();"/>
352                         </menupopup>
353                         </menu>
354                 </menubar>
355                 <deck id="bottom_pane" flex="1">
356                         <browser id="browser"/>
357                         <browser id="editor"/>
358                         <browser id="holdings"/>
359                         <browser id="holds"/>
360                 </deck>
361         </vbox>
362
363 </window>
364