]> git.evergreen-ils.org Git - Evergreen.git/blob - Open-ILS/xul/staff_client/chrome/content/cat/opac.xul
untested window_open for Bill
[Evergreen.git] / Open-ILS / xul / staff_client / chrome / content / 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 SYSTEM "chrome://open_ils_staff_client/locale/lang.dtd">
13
14 <!-- ///////////////////////////////////////////////////////////////////////////////////////////////////////////// -->
15 <!-- OVERLAYS -->
16 <?xul-overlay href="chrome://open_ils_staff_client/content/OpenILS/util_overlay.xul"?>
17
18 <window id="opac_win"
19         onload="try { my_init(); } catch(E) { alert(E); }"
20         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
21
22         <!-- ///////////////////////////////////////////////////////////////////////////////////////////////////////////// -->
23         <!-- BEHAVIOR -->
24         <script type="text/javascript">
25                 var myPackageDir = 'open_ils_staff_client'; var IAMXUL = true; var g = {};
26                 netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
27         </script>
28         <scripts id="openils_util_scripts"/>
29
30         <script type="text/javascript" src="chrome://open_ils_staff_client/content/main/JSAN.js"/>
31         <script>
32         <![CDATA[
33
34                 var docid; var marc_html; var top_pane; var bottom_pane; var opac_frame;
35
36                 function my_init() {
37                         try {
38                                 netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
39                 if (typeof JSAN == 'undefined') { throw( "The JSAN library object is missing."); }
40                                 JSAN.errorLevel = "die"; // none, warn, or die
41                                 JSAN.addRepository('..');
42                                 JSAN.use('util.error'); g.error = new util.error();
43                                 g.error.sdump('D_TRACE','my_init() for cat/opac.xul');
44
45                                 JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'});
46                                 XML_HTTP_SERVER = data.server_unadorned;
47
48                                 JSAN.use('util.network'); g.network = new util.network();
49
50                                 g.cgi = new CGI();
51                                 try { authtime = g.cgi.param('authtime') || xulG.authtime; } catch(E) { g.error.sdump('D_ERROR',E); }
52                                 try { docid = g.cgi.param('docid') || xulG.docid; } catch(E) { g.error.sdump('D_ERROR',E); }
53                                 try { opac_url = g.cgi.param('opac_url') || xulG.opac_url; } catch(E) { g.error.sdump('D_ERROR',E); }
54
55                                 JSAN.use('util.deck');
56                                 top_pane = new util.deck('top_pane');
57                                 bottom_pane = new util.deck('bottom_pane');
58
59                                 set_opac();
60
61                         } catch(E) {
62                                 var err_msg = "!! This software has encountered an error.  Please tell your friendly " +
63                                         "system administrator or software developer the following:\ncat/opac.xul\n" + E + '\n';
64                                 try { g.error.sdump('D_ERROR',err_msg); } catch(E) { dump(err_msg); }
65                                 alert(err_msg);
66                         }
67                 }
68
69                 function set_brief_view() {
70                         var url = xulG.url_prefix( urls.XUL_BIB_BRIEF ) + '?docid=' + window.escape(docid); 
71                         dump('spawning ' + url + '\n');
72                         top_pane.set_iframe( 
73                                 url,
74                                 {}, 
75                                 { 
76                                         'set_tab_name' : function(n) { 
77                                                 if (typeof window.xulG == 'object' && typeof window.xulG.set_tab_name == 'function') {
78                                                         try { window.xulG.set_tab_name('Bib Record: ' + n); } catch(E) { alert(E); }
79                                                 } else {
80                                                         dump('no set_tab_name\n');
81                                                 }
82                                         }
83                                 }  
84                         );
85                 }
86
87                 function set_marc_view() {
88                         bottom_pane.set_iframe( xulG.url_prefix( urls.XUL_MARC_VIEW ) + '?docid=' + window.escape(docid),{},xulG);
89                 }
90
91                 function set_marc_edit() {
92                         bottom_pane.set_iframe( 
93                                 xulG.url_prefix( urls.XUL_MARC_EDIT ),
94                                 {},
95                                 {
96                                         'record' : { 'url' : '/opac/extras/supercat/retrieve/marcxml/record/' + docid },
97                                         'save' : {
98                                                 'label' : 'Save Record',
99                                                 'func' : function (new_marcxml) {
100                                                         try {
101                                                                 var r = g.network.simple_request('MARC_XML_RECORD_UPDATE', [ ses(), docid, new_marcxml ]);
102                                                                 if (typeof r.ilsevent != 'undefined') {
103                                                                         throw(r);
104                                                                 } else {
105                                                                         alert('Record successfully saved.');
106                                                                 }
107                                                         } catch(E) {
108                                                                         g.error.standard_unexpected_error_alert('Record not likely updated.',E);
109                                                         }
110                                                 }
111                                         }
112                                 }
113                         );
114                 }
115
116                 function set_copy_browser() {
117                         bottom_pane.set_iframe( xulG.url_prefix( urls.XUL_COPY_VOLUME_BROWSE ) + '?docid=' + window.escape(docid),{},xulG);
118                 }
119
120                 function set_copy_browser_old() {
121                         bottom_pane.set_iframe( xulG.url_prefix( urls.XUL_COPY_VOLUME_BROWSE_OLD ) + '?docid=' + window.escape(docid),{},xulG);
122                 }
123
124                 function set_hold_browser() {
125                         bottom_pane.set_iframe( xulG.url_prefix( urls.XUL_HOLDS_BROWSER ) + '?docid=' + window.escape(docid),{},xulG);
126                 }
127
128                 function set_opac() {
129                         try {
130                                 var content_params = { 
131                                         'show_nav_buttons' : true,
132                                         'show_print_button' : true,
133                                         'passthru_content_params' : { 
134                                                 'authtoken' : ses(), 
135                                                 'authtime' : ses('authtime'),
136                                                 'window_open' : function(a,b,c) {
137                                                         try {
138                                                                 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
139                                                                 window.open(a,b,c);
140                                                         } catch(E) {
141                                                                 g.error.standard_unexpected_error_alert('window_open',E);
142                                                         }
143                                                 }
144                                         },
145                                         'on_url_load' : function(f) {
146                                                 netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
147                                                 var win;
148                                                 try {
149                                                         if (typeof f.contentWindow.wrappedJSObject.attachEvt != 'undefined') {
150                                                                 win = f.contentWindow.wrappedJSObject;
151                                                         } else {
152                                                                 win = f.contentWindow;
153                                                         }
154                                                 } catch(E) {
155                                                         win = f.contentWindow;
156                                                 }
157                                                 win.attachEvt("rdetail", "recordRetrieved",
158                                                         function(id){
159                                                                 try {
160                                                                         var url = xulG.url_prefix( urls.XUL_BIB_BRIEF ) + '?docid=' + window.escape(docid) 
161                                                                         dump('removing ' + url + '\n');
162                                                                         try { top_pane.remove_iframe( url ); } catch(E) { dump(E + '\n'); }
163                                                                         docid = id;
164                                                                         set_brief_view();
165                                                                         document.getElementById('nav').setAttribute('hidden','false');
166                                                                 } catch(E) {
167                                                                         g.error.standard_unexpected_error_alert('rdetail -> recordRetrieved',E);
168                                                                 }
169                                                         }
170                                                 );
171                                         },
172                                         'url_prefix' : xulG.url_prefix,
173                                 };
174                                 if (opac_url) content_params.url = opac_url;
175                                 browser_frame = bottom_pane.set_iframe( xulG.url_prefix(urls.XUL_BROWSER) + '?name=Catalog', {}, content_params);
176                         } catch(E) {
177                                 g.error.sdump('D_ERROR','set_opac: ' + E);
178                         }
179                 }
180
181                 function bib_in_new_tab() {
182                         try {
183                                 var url = browser_frame.contentWindow.g.browser.controller.view.browser_browser.contentWindow.wrappedJSObject.location.href;
184                                 var content_params = { 'session' : ses(), 'authtime' : ses('authtime'), 'opac_url' : url };
185                                 xulG.new_tab(xulG.url_prefix(urls.XUL_OPAC_WRAPPER), {}, content_params);
186                         } catch(E) {
187                                 g.error.sdump('D_ERROR',E);
188                         }
189                 }
190
191                 function remove_me() {
192                         var url = xulG.url_prefix( urls.XUL_BIB_BRIEF ) + '?docid=' + window.escape(docid);
193                         dump('removing ' + url + '\n');
194                         try { top_pane.remove_iframe( url ); } catch(E) { dump(E + '\n'); }
195                         document.getElementById('nav').setAttribute('hidden','true');
196                 }
197
198                 function add_to_bucket() {
199                         JSAN.use('util.window'); var win = new util.window();
200                         win.open(
201                                 xulG.url_prefix(urls.XUL_RECORD_BUCKETS)
202                                 + '?record_ids=' + js2JSON( [ docid ] ),
203                                 'sel_bucket_win' + win.window_name_increment(),
204                                 'chrome,resizable,modal,center'
205                         );
206                 }
207         ]]>
208         </script>
209
210         <vbox flex="1">
211                 <deck id="top_pane"/>
212                 <menubar id="nav" hidden="true">
213                         <menu label="Actions for this Record" accesskey="A">
214                         <menupopup>
215                         <menuitem label="OPAC View" accesskey="O" id="opac_view" oncommand="set_opac();"/>
216                         <menuitem label="MARC View" accesskey="V" id="marc_view" oncommand="set_marc_view();"/>
217                         <menuitem label="MARC Edit" accesskey="E" id="marc_edit" oncommand="set_marc_edit();"/>
218                         <menuitem label="Holdings Maintenance" accesskey="H" id="copy_browse" oncommand="set_copy_browser();"/>
219                         <menuitem label="Developers: Old Copy Browser" accesskey="C" id="copy_browse_old" oncommand="set_copy_browser_old();"/>
220                         <menuitem label="View Holds" accesskey="s" id="view_holds" oncommand="set_hold_browser();"/>
221                         <menuseparator/>
222                         <menuitem label="Add to Bucket" accesskey="B" id="add_bucket" oncommand="add_to_bucket();"/>
223                         <menuseparator/>
224                         <menuitem label="Duplicate in New Tab" id="bib_in_new_tab" oncommand="bib_in_new_tab();"/>
225                         <menuitem label="Remove this Frame" id="remove_me" oncommand="remove_me();"/>
226                         </menupopup>
227                         </menu>
228                 </menubar>
229                 <deck id="bottom_pane" flex="1"/>
230         </vbox>
231
232 </window>
233