1 var docid; var marc_html; var top_pane; var bottom_pane; var opac_browser; var opac_url;
3 var marc_view_reset = true;
4 var marc_edit_reset = true;
5 var copy_browser_reset = true;
6 var manage_parts_reset = true;
7 var manage_multi_home_reset = true;
8 var hold_browser_reset = true;
9 var serctrl_view_reset = true;
11 function $(id) { return document.getElementById(id); }
15 netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
16 if (typeof JSAN == 'undefined') { throw(document.getElementById('offlineStrings').getString('common.jsan.missing')); }
17 JSAN.errorLevel = "die"; // none, warn, or die
18 JSAN.addRepository('..');
19 JSAN.use('util.error'); g.error = new util.error();
20 g.error.sdump('D_TRACE','my_init() for cat/opac.xul');
22 JSAN.use('OpenILS.data'); g.data = new OpenILS.data(); g.data.init({'via':'stash'});
23 XML_HTTP_SERVER = g.data.server_unadorned;
25 // Pull in local customizations
26 var r = new XMLHttpRequest();
27 r.open("GET", xulG.url_prefix('/xul/server/skin/custom.js'), false);
29 if (r.status == 200) {
30 dump('Evaluating /xul/server/skin/custom.js\n');
31 eval( r.responseText );
34 window.help_context_set_locally = true;
36 JSAN.use('util.network'); g.network = new util.network();
39 try { authtime = g.cgi.param('authtime') || xulG.authtime; } catch(E) { g.error.sdump('D_ERROR',E); }
40 try { docid = g.cgi.param('docid') || xulG.docid; } catch(E) { g.error.sdump('D_ERROR',E); }
41 try { opac_url = g.cgi.param('opac_url') || xulG.opac_url; } catch(E) { g.error.sdump('D_ERROR',E); }
42 try { g.view_override = g.cgi.param('default_view') || xulG.default_view; } catch(E) { g.error.sdump('D_ERROR',E); }
44 JSAN.use('util.deck');
45 top_pane = new util.deck('top_pane');
46 bottom_pane = new util.deck('bottom_pane');
51 var err_msg = document.getElementById("offlineStrings").getFormattedString("common.exception", ["cat/opac.xul", E]);
52 try { g.error.sdump('D_ERROR',err_msg); } catch(E) { dump(err_msg); }
57 function default_focus() {
58 opac_wrapper_set_help_context();
61 function opac_wrapper_set_help_context() {
63 dump('Entering opac.js, opac_wrapper_set_help_context\n');
64 var cw = bottom_pane.get_contentWindow();
65 if (cw && typeof cw['location'] != 'undefined') {
66 if (typeof cw.help_context_set_locally == 'undefined') {
68 'protocol' : cw.location.protocol,
69 'hostname' : cw.location.hostname,
70 'port' : cw.location.port,
71 'pathname' : cw.location.pathname,
74 xulG.set_help_context(help_params);
76 dump('\tcw.help_context_set_locally = ' + cw.help_context_set_locally + '\n');
77 if (typeof cw.default_focus == 'function') {
82 dump('opac.js: problem in opac_wrapper_set_help_context(): bottom_pane = ' + bottom_pane + ' cw = ' + cw + '\n');
83 dump('\tcw.location = ' + cw.location + '\n');
86 // We can expect some errors here if this called before the DOM is ready. Easiest to just trap and ignore
87 dump('Error in opac.js, opac_wrapper_set_help_context(): ' + E + '\n');
91 function set_brief_view() {
92 var url = xulG.url_prefix( urls.XUL_BIB_BRIEF ) + '?docid=' + window.escape(docid);
93 dump('spawning ' + url + '\n');
95 var content_params = {
96 'set_tab_name' : function(n) {
97 if (typeof window.xulG == 'object' && typeof window.xulG.set_tab_name == 'function') {
98 try { window.xulG.set_tab_name(document.getElementById('offlineStrings').getFormattedString("cat.bib_record", [n])); } catch(E) { alert(E); }
100 dump('no set_tab_name\n');
105 ["url_prefix", "new_tab", "set_tab", "close_tab", "new_patron_tab",
106 "set_patron_tab", "volume_item_creator", "get_new_session",
107 "holdings_maintenance_tab", "open_chrome_window", "url_prefix",
108 "network_meter", "page_meter", "set_statusbar", "set_help_context",
109 "get_barcode", "reload_opac", "get_barcode_and_settings"
110 ].forEach(function(k) { content_params[k] = xulG[k]; });
119 function set_marc_view() {
120 g.view = 'marc_view';
121 if (marc_view_reset) {
122 bottom_pane.reset_iframe( xulG.url_prefix( urls.XUL_MARC_VIEW ) + '?docid=' + window.escape(docid),{},xulG);
123 marc_view_reset = false;
125 bottom_pane.set_iframe( xulG.url_prefix( urls.XUL_MARC_VIEW ) + '?docid=' + window.escape(docid),{},xulG);
127 opac_wrapper_set_help_context();
128 bottom_pane.get_contentWindow().addEventListener('load',opac_wrapper_set_help_context,false);
131 function set_marc_edit() {
132 g.view = 'marc_edit';
133 var a = xulG.url_prefix( urls.XUL_MARC_EDIT );
136 'marc_control_number_identifier' : g.data.hash.aous['cat.marc_control_number_identifier'] || 'Set cat.marc_control_number_identifier in Library Settings',
137 'record' : { 'url' : '/opac/extras/supercat/retrieve/marcxml/record/' + docid, "id": docid, "rtype": "bre" },
138 'fast_add_item' : function(doc_id,cn_label,cp_barcode) {
140 var cat = { util: {} }; /* FIXME: kludge since we can't load remote JSAN libraries into chrome */
141 cat.util.spawn_copy_editor = function(params) {
143 if (!params.copy_ids && !params.copies) return;
144 if (params.copy_ids && params.copy_ids.length == 0) return;
145 if (params.copies && params.copies.length == 0) return;
146 if (params.copy_ids) params.copy_ids = js2JSON(params.copy_ids); // legacy
147 if (!params.caller_handles_update) params.handle_update = 1; // legacy
150 JSAN.use('util.network'); obj.network = new util.network();
151 JSAN.use('util.error'); obj.error = new util.error();
154 if (params.copy_ids && params.copy_ids.length > 1 && params.edit == 1)
155 title = $("offlineStrings").getString('staff.cat.util.copy_editor.batch_edit');
156 else if(params.copies && params.copies.length > 1 && params.edit == 1)
157 title = $("offlineStrings").getString('staff.cat.util.copy_editor.batch_view');
158 else if(params.copy_ids && params.copy_ids.length == 1)
159 title = $("offlineStrings").getString('staff.cat.util.copy_editor.edit');
161 title = $("offlineStrings").getString('staff.cat.util.copy_editor.view');
163 JSAN.use('util.window'); var win = new util.window();
164 var my_xulG = win.open(
165 (urls.XUL_COPY_EDITOR),
167 'chrome,modal,resizable',
170 if (!my_xulG.copies && params.edit) {
172 return my_xulG.copies;
176 JSAN.use('util.error'); var error = new util.error();
177 error.standard_unexpected_error_alert('Error in chrome/content/cat/opac.js, cat.util.spawn_copy_editor',E);
180 cat.util.fast_item_add = function(doc_id,cn_label,cp_barcode) {
184 JSAN.use('util.error'); error = new util.error();
185 JSAN.use('util.network'); var network = new util.network();
187 var acn_blob = network.simple_request(
188 'FM_ACN_FIND_OR_CREATE',
189 [ ses(), cn_label, doc_id, ses('ws_ou') ]
192 if (typeof acn_blob.ilsevent != 'undefined') {
193 error.standard_unexpected_error_alert('Error in chrome/content/cat/opac.js, cat.util.fast_item_add', acn_blob);
197 // Get the default copy status; default to available if unset, per 1.6
198 var fast_ccs = g.data.hash.aous['cat.default_copy_status_fast'] || 0;
200 var copy_obj = new acp();
203 copy_obj.barcode( cp_barcode );
204 copy_obj.call_number( acn_blob.acn_id );
205 copy_obj.circ_lib( ses('ws_ou') );
206 /* FIXME -- use constants */
209 copy_obj.deposit_amount(0);
210 copy_obj.fine_level(2); // Normal
211 copy_obj.loan_duration(2); // Normal
212 copy_obj.location(1); // Stacks
213 copy_obj.status(fast_ccs);
214 copy_obj.circulate(get_db_true());
215 copy_obj.holdable(get_db_true());
216 copy_obj.opac_visible(get_db_true());
217 copy_obj.ref(get_db_false());
218 copy_obj.mint_condition(get_db_true());
220 JSAN.use('util.window'); var win = new util.window();
222 var unified_interface = String( data.hash.aous['ui.unified_volume_copy_editor'] ) == 'true';
223 if (unified_interface) {
224 var horizontal_interface = String( data.hash.aous['ui.cat.volume_copy_editor.horizontal'] ) == 'true';
225 var url = window.xulG.url_prefix( horizontal_interface ? urls.XUL_VOLUME_COPY_CREATOR_HORIZONTAL : urls.XUL_VOLUME_COPY_CREATOR );
226 var w = xulG.set_tab(
229 'tab_name' : document.getElementById('offlineStrings').getFormattedString(
236 'existing_copies' : [ copy_obj ],
237 'load_opac_when_done' : true,
238 'labels_in_new_tab' : true
243 var x = cat.util.spawn_copy_editor( { 'handle_update' : 1, 'edit' : 1, 'docid' : doc_id, 'copies' : [ copy_obj ] });
249 if (error) error.standard_unexpected_error_alert('Error in chrome/content/cat/opac.js, cat.util.fast_item_add #2',E); else alert('FIXME: ' + E);
252 return cat.util.fast_item_add(doc_id,cn_label,cp_barcode);
254 alert('Error in chrome/content/cat/opac.js, set_marc_edit, fast_item_add: ' + E);
258 'label' : document.getElementById('offlineStrings').getString('cat.save_record'),
259 'func' : function (new_marcxml) {
261 var r = g.network.simple_request('MARC_XML_RECORD_UPDATE', [ ses(), docid, new_marcxml ]);
262 marc_view_reset = true;
263 copy_browser_reset = true;
264 hold_browser_reset = true;
266 if (typeof r.ilsevent != 'undefined') {
271 'oncomplete' : function() {}
275 g.error.standard_unexpected_error_alert(document.getElementById('offlineStrings').getString("cat.save.failure"), E);
279 'lock_tab' : xulG.lock_tab,
280 'unlock_tab' : xulG.unlock_tab
282 if (marc_edit_reset) {
283 bottom_pane.reset_iframe( a,b,c );
284 marc_edit_reset = false;
286 bottom_pane.set_iframe( a,b,c );
288 opac_wrapper_set_help_context();
289 bottom_pane.get_contentWindow().addEventListener('load',opac_wrapper_set_help_context,false);
292 function set_copy_browser() {
293 g.view = 'copy_browser';
294 if (copy_browser_reset) {
295 bottom_pane.reset_iframe( xulG.url_prefix( urls.XUL_COPY_VOLUME_BROWSE ) + '?docid=' + window.escape(docid),{},xulG);
296 copy_browser_reset =false;
298 bottom_pane.set_iframe( xulG.url_prefix( urls.XUL_COPY_VOLUME_BROWSE ) + '?docid=' + window.escape(docid),{},xulG);
300 opac_wrapper_set_help_context();
301 bottom_pane.get_contentWindow().addEventListener('load',opac_wrapper_set_help_context,false);
304 function set_hold_browser() {
305 g.view = 'hold_browser';
306 if (hold_browser_reset) {
307 bottom_pane.reset_iframe( xulG.url_prefix( urls.XUL_HOLDS_BROWSER ) + '?docid=' + window.escape(docid),{},xulG);
308 hold_browser_reset = false;
310 bottom_pane.set_iframe( xulG.url_prefix( urls.XUL_HOLDS_BROWSER ) + '?docid=' + window.escape(docid),{},xulG);
312 opac_wrapper_set_help_context();
313 bottom_pane.get_contentWindow().addEventListener('load',opac_wrapper_set_help_context,false);
317 function open_acq_orders() {
319 var content_params = {
321 "authtime": ses("authtime"),
323 "show_nav_buttons": true,
324 "show_print_button": false
327 ["url_prefix", "new_tab", "set_tab", "close_tab", "new_patron_tab",
328 "set_patron_tab", "volume_item_creator", "get_new_session",
329 "holdings_maintenance_tab", "set_tab_name", "open_chrome_window",
330 "url_prefix", "network_meter", "page_meter", "set_statusbar",
331 "set_help_context", "get_barcode", "reload_opac",
332 "get_barcode_and_settings"
333 ].forEach(function(k) { content_params[k] = xulG[k]; });
335 var loc = urls.XUL_BROWSER + "?url=" + window.escape(
336 xulG.url_prefix("/eg/acq/lineitem/related/") +
337 docid + "?target=bib"
341 "tab_name": $("offlineStrings").getString(
342 "staff.cat.opac.related_items"
348 g.error.sdump("D_ERROR", E);
352 function open_alt_serial_mgmt() {
354 var content_params = {
356 "authtime": ses("authtime"),
357 "show_nav_buttons": true,
359 "show_print_button": false,
360 "passthru_content_params": {
361 "reload_opac": xulG.reload_opac
365 ["url_prefix", "new_tab", "set_tab", "close_tab", "new_patron_tab",
366 "set_patron_tab", "volume_item_creator", "get_new_session",
367 "holdings_maintenance_tab", "set_tab_name", "open_chrome_window",
368 "url_prefix", "network_meter", "page_meter", "set_statusbar",
369 "set_help_context", "get_barcode", "reload_opac",
370 "get_barcode_and_settings"
371 ].forEach(function(k) { content_params[k] = xulG[k]; });
373 var loc = urls.XUL_BROWSER + "?url=" + window.escape(
374 xulG.url_prefix("/eg/serial/list_subscription?record_entry=") +
379 "tab_name": $("offlineStrings").getString(
380 "staff.cat.opac.serial_alt_mgmt"
386 g.error.sdump("D_ERROR", E);
390 function set_opac() {
393 var content_params = {
394 'show_nav_buttons' : true,
395 'show_print_button' : true,
396 'passthru_content_params' : {
398 'authtime' : ses('authtime'),
399 'window_open' : function(a,b,c) {
401 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect UniversalBrowserWrite');
402 return window.open(a,b,c);
404 g.error.standard_unexpected_error_alert('window_open',E);
407 'get_barcode' : xulG.get_barcode,
408 'get_barcode_and_settings' : xulG.get_barcode_and_settings
410 'on_url_load' : function(f) {
411 netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
414 if (typeof f.contentWindow.wrappedJSObject.attachEvt != 'undefined') {
415 win = f.contentWindow.wrappedJSObject;
417 win = f.contentWindow;
420 win = f.contentWindow;
422 win.attachEvt("rdetail", "recordRetrieved",
425 if (docid == id) return;
429 g.error.standard_unexpected_error_alert('rdetail -> recordRetrieved',E);
434 g.f_record_start = null; g.f_record_prev = null;
435 g.f_record_next = null; g.f_record_end = null;
436 g.f_record_back_to_results = null;
437 $('record_start').disabled = true; $('record_next').disabled = true;
438 $('record_prev').disabled = true; $('record_end').disabled = true;
439 $('record_back_to_results').disabled = true;
440 $('record_pos').setAttribute('value','');
442 win.attachEvt("rdetail", "nextPrevDrawn",
443 function(rIndex,rCount){
444 $('record_pos').setAttribute('value', document.getElementById('offlineStrings').getFormattedString('cat.record.counter', [(1+rIndex), rCount ? rCount : 1]));
445 if (win.rdetailNext) {
446 g.f_record_next = function() {
447 g.view_override = g.view;
450 $('record_next').disabled = false;
452 if (win.rdetailPrev) {
453 g.f_record_prev = function() {
454 g.view_override = g.view;
457 $('record_prev').disabled = false;
459 if (win.rdetailStart) {
460 g.f_record_start = function() {
461 g.view_override = g.view;
464 $('record_start').disabled = false;
466 if (win.rdetailEnd) {
467 g.f_record_end = function() {
468 g.view_override = g.view;
471 $('record_end').disabled = false;
473 if (win.rdetailBackToResults) {
474 g.f_record_back_to_results = function() {
475 g.view_override = g.view;
476 win.rdetailBackToResults();
477 if (g.view != "opac") {
479 opac_wrapper_set_help_context();
482 $('record_back_to_results').disabled = false;
487 $('mfhd_add').setAttribute('oncommand','create_mfhd()');
488 var mfhd_edit_menu = $('mfhd_edit');
489 var mfhd_delete_menu = $('mfhd_delete');
491 // clear menus on subsequent loads
492 if (mfhd_edit_menu.firstChild) {
493 mfhd_edit_menu.removeChild(mfhd_edit_menu.firstChild);
494 mfhd_delete_menu.removeChild(mfhd_delete_menu.firstChild);
497 mfhd_edit_menu.disabled = true;
498 mfhd_delete_menu.disabled = true;
500 win.attachEvt("rdetail", "MFHDDrawn",
502 if (win.mfhdDetails && win.mfhdDetails.length > 0) {
504 g.mfhd.details = win.mfhdDetails;
505 mfhd_edit_menu.disabled = false;
506 mfhd_delete_menu.disabled = false;
507 for (var i = 0; i < win.mfhdDetails.length; i++) {
508 var mfhd_details = win.mfhdDetails[i];
509 var num = mfhd_details.entryNum;
511 var label = mfhd_details.label + ' (' + num + ')';
512 var item = mfhd_edit_menu.appendItem(label);
513 item.setAttribute('oncommand','open_mfhd_editor('+mfhd_details.id+')');
514 item = mfhd_delete_menu.appendItem(label);
515 item.setAttribute('oncommand','delete_mfhd('+mfhd_details.id+')');
517 } else if (g.mfhd) { // clear from previous runs if deleting last MFHD
520 var change_event = document.createEvent("Event");
521 change_event.initEvent("MFHDChange",false,false);
522 window.dispatchEvent(change_event);
526 'url_prefix' : xulG.url_prefix,
528 content_params.new_tab = xulG.new_tab;
529 content_params.set_tab = xulG.set_tab;
530 content_params.close_tab = xulG.close_tab;
531 content_params.lock_tab = xulG.lock_tab;
532 content_params.unlock_tab = xulG.unlock_tab;
533 content_params.inspect_tab = xulG.inspect_tab;
534 content_params.new_patron_tab = xulG.new_patron_tab;
535 content_params.set_patron_tab = xulG.set_patron_tab;
536 content_params.volume_item_creator = xulG.volume_item_creator;
537 content_params.get_new_session = xulG.get_new_session;
538 content_params.holdings_maintenance_tab = xulG.holdings_maintenance_tab;
539 content_params.set_tab_name = xulG.set_tab_name;
540 content_params.open_chrome_window = xulG.open_chrome_window;
541 content_params.url_prefix = xulG.url_prefix;
542 content_params.network_meter = xulG.network_meter;
543 content_params.page_meter = xulG.page_meter;
544 content_params.set_statusbar = xulG.set_statusbar;
545 content_params.set_help_context = xulG.set_help_context;
546 content_params.get_barcode = xulG.get_barcode;
547 content_params.get_barcode_and_settings = xulG.get_barcode_and_settings;
549 var secure_opac = true; // default to secure
550 netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
551 var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components.interfaces['nsIPrefBranch']);
552 if (prefs.prefHasUserValue('oils.secure_opac')) {
553 secure_opac = prefs.getBoolPref('oils.secure_opac');
555 dump('secure_opac = ' + secure_opac + '\n');
558 content_params.url = xulG.url_prefix( opac_url, secure_opac );
560 content_params.url = xulG.url_prefix( urls.browser, secure_opac );
562 browser_frame = bottom_pane.set_iframe( xulG.url_prefix(urls.XUL_BROWSER) + '?name=Catalog', {}, content_params);
563 /* // Remember to use the REMOTE_BROWSER if we ever try to move this to remote xul again
564 browser_frame = bottom_pane.set_iframe( xulG.url_prefix(urls.XUL_REMOTE_BROWSER) + '?name=Catalog', {}, content_params);
567 g.error.sdump('D_ERROR','set_opac: ' + E);
569 opac_wrapper_set_help_context();
570 opac_browser = bottom_pane.get_contentWindow();
571 opac_browser.addEventListener('load',opac_wrapper_set_help_context,false);
574 xulG.reload_opac = function() {
576 JSAN.use('util.widgets');
577 opac_browser.g.browser.reload();
579 g.error.sdump("D_ERROR", 'error reloading opac: ' + E + '\n');
583 function set_serctrl_view() {
584 g.view = 'serctrl_view';
585 if (serctrl_view_reset) {
586 bottom_pane.reset_iframe( xulG.url_prefix( urls.XUL_SERIAL_SERCTRL_MAIN ) + '?docid=' + window.escape(docid), {}, xulG);
587 serctrl_view_reset =false;
589 bottom_pane.set_iframe( xulG.url_prefix( urls.XUL_SERIAL_SERCTRL_MAIN ) + '?docid=' + window.escape(docid), {}, xulG);
593 function create_mfhd() {
594 // Check if the source is allowed to have copies, first.
596 var bibObj = g.network.request(
597 api.FM_BRE_RETRIEVE_VIA_ID.app,
598 api.FM_BRE_RETRIEVE_VIA_ID.method,
604 var cbsObj = g.network.request(
605 api.FM_CBS_RETRIEVE_VIA_PCRUD.app,
606 api.FM_CBS_RETRIEVE_VIA_PCRUD.method,
607 [ ses(), bibObj.source() ]
610 if (cbsObj && cbsObj.can_have_copies() != get_db_true()) {
611 alert(document.getElementById('offlineStrings').getFormattedString('staff.cat.bib_source.can_have_copies.false', [cbsObj.source()]));
615 g.error.sdump('D_ERROR','can have copies check: ' + E);
616 alert('Error in chrome/content/cat/opac.js, create_mfhd(): ' + E);
621 JSAN.use('util.window'); var win = new util.window();
622 var select_aou_window = win.open(
623 xulG.url_prefix(urls.XUL_SERIAL_SELECT_AOU),
625 'chrome,resizable,modal,centerscreen',
626 {'server_unadorned' : g.data.server_unadorned}
628 if (!select_aou_window.create_mfhd_aou) {
631 var r = g.network.simple_request(
632 'MFHD_XML_RECORD_CREATE',
633 [ ses(), 1, select_aou_window.create_mfhd_aou, docid ]
635 if (typeof r.ilsevent != 'undefined') {
638 alert("MFHD record created."); //TODO: better success message
639 xulG.reload_opac(); // browser_frame.contentWindow.g.browser.controller.view.cmd_reload.doCommand();
641 g.error.standard_unexpected_error_alert("Create MFHD failed", E); //TODO: better error handling
645 function delete_mfhd(sre_id) {
646 if (g.error.yns_alert(
647 document.getElementById('offlineStrings').getFormattedString('serial.delete_record.confirm', [sre_id]),
648 document.getElementById('offlineStrings').getString('cat.opac.delete_record'),
649 document.getElementById('offlineStrings').getString('cat.opac.delete'),
650 document.getElementById('offlineStrings').getString('cat.opac.cancel'),
652 document.getElementById('offlineStrings').getString('cat.opac.record_deleted.confirm')) == 0) {
653 var robj = g.network.request(
654 'open-ils.permacrud',
655 'open-ils.permacrud.delete.sre',
657 if (typeof robj.ilsevent != 'undefined') {
658 alert(document.getElementById('offlineStrings').getFormattedString('cat.opac.record_deleted.error', [docid, robj.textcode, robj.desc]) + '\n');
660 alert(document.getElementById('offlineStrings').getString('cat.opac.record_deleted'));
661 xulG.reload_opac(); // browser_frame.contentWindow.g.browser.controller.view.cmd_reload.doCommand();
666 function open_mfhd_editor(sre_id) {
668 var r = g.network.simple_request(
672 if (typeof r.ilsevent != 'undefined') {
675 open_marc_editor(r, 'MFHD');
677 g.error.standard_unexpected_error_alert("Create MFHD failed", E); //TODO: better error handling
681 function open_marc_editor(rec, label) {
682 win = window.open( xulG.url_prefix('/xul/server/cat/marcedit.xul') );
685 record : {marc : rec.marc()},
687 label: 'Save ' + label,
688 func: function(xmlString) { // TODO: switch to pcrud, or define an sre update method in Serial.pm?
689 var method = 'open-ils.permacrud.update.' + rec.classname;
692 'open-ils.permacrud', method,
701 function bib_in_new_tab() {
703 var url = browser_frame.contentWindow.g.browser.controller.view.browser_browser.contentWindow.wrappedJSObject.location.href;
704 var content_params = { 'session' : ses(), 'authtime' : ses('authtime'), 'opac_url' : url };
705 content_params.url_prefix = xulG.url_prefix;
706 content_params.new_tab = xulG.new_tab;
707 content_params.set_tab = xulG.set_tab;
708 content_params.close_tab = xulG.close_tab;
709 content_params.lock_tab = xulG.lock_tab;
710 content_params.unlock_tab = xulG.unlock_tab;
711 content_params.inspect_tab = xulG.inspect_tab;
712 content_params.new_patron_tab = xulG.new_patron_tab;
713 content_params.set_patron_tab = xulG.set_patron_tab;
714 content_params.volume_item_creator = xulG.volume_item_creator;
715 content_params.get_new_session = xulG.get_new_session;
716 content_params.holdings_maintenance_tab = xulG.holdings_maintenance_tab;
717 content_params.set_tab_name = xulG.set_tab_name;
718 content_params.open_chrome_window = xulG.open_chrome_window;
719 content_params.url_prefix = xulG.url_prefix;
720 content_params.network_meter = xulG.network_meter;
721 content_params.page_meter = xulG.page_meter;
722 content_params.set_statusbar = xulG.set_statusbar;
723 content_params.set_help_context = xulG.set_help_context;
724 content_params.get_barcode = xulG.get_barcode;
725 content_params.get_barcode_and_settings = xulG.get_barcode_and_settings;
727 xulG.new_tab(xulG.url_prefix(urls.XUL_OPAC_WRAPPER), {}, content_params);
729 g.error.sdump('D_ERROR',E);
733 function batch_receive_in_new_tab() {
735 var content_params = {"session": ses(), "authtime": ses("authtime")};
737 ["url_prefix", "new_tab", "set_tab", "close_tab", "new_patron_tab",
738 "set_patron_tab", "volume_item_creator", "get_new_session",
739 "holdings_maintenance_tab", "set_tab_name", "open_chrome_window",
740 "url_prefix", "network_meter", "page_meter", "set_statusbar",
741 "set_help_context", "get_barcode", "reload_opac",
742 "get_barcode_and_settings"
743 ].forEach(function(k) { content_params[k] = xulG[k]; });
746 xulG.url_prefix(urls.XUL_SERIAL_BATCH_RECEIVE) +
747 "?docid=" + window.escape(docid), {
748 "tab_name": $("offlineStrings").getString(
749 "menu.cmd_serial_batch_receive.tab"
754 g.error.sdump("D_ERROR", E);
758 function remove_me() {
759 var url = xulG.url_prefix( urls.XUL_BIB_BRIEF ) + '?docid=' + window.escape(docid);
760 dump('removing ' + url + '\n');
761 try { top_pane.remove_iframe( url ); } catch(E) { dump(E + '\n'); }
762 $('nav').setAttribute('hidden','true');
765 function add_to_bucket() {
766 JSAN.use('util.window'); var win = new util.window();
768 xulG.url_prefix(urls.XUL_RECORD_BUCKETS_QUICK),
770 'chrome,resizable,modal,centerscreen',
772 record_ids: [ docid ]
777 // FIXME: now duplicated in cat.util, which we can't import here, though maybe
778 // we can do something at build time
779 function mark_for_overlay() {
780 g.data.marked_record = docid;
781 g.data.stash('marked_record');
782 var robj = g.network.simple_request('MODS_SLIM_RECORD_RETRIEVE.authoritative',[docid]);
783 if (typeof robj.ilsevent == 'undefined') {
784 g.data.marked_record_mvr = robj;
786 g.data.marked_record_mvr = null;
787 g.error.standard_unexpected_error_alert('in mark_for_overlay',robj);
789 g.data.stash('marked_record_mvr');
790 if (g.data.marked_record_mvr) {
791 alert(document.getElementById('offlineStrings').getFormattedString('cat.opac.record_marked_for_overlay.tcn.alert',[ g.data.marked_record_mvr.tcn() ]));
794 $("offlineStrings").getFormattedString('staff.cat.z3950.marked_record_for_overlay_indicator.tcn.label',[g.data.marked_record_mvr.tcn()]),
795 $("offlineStrings").getFormattedString('staff.cat.z3950.marked_record_for_overlay_indicator.record_id.label',[g.data.marked_record]),
796 gen_statusbar_click_handler('marked_record')
799 alert(document.getElementById('offlineStrings').getFormattedString('cat.opac.record_marked_for_overlay.record_id.alert',[ g.data.marked_record ]));
802 $("offlineStrings").getFormattedString('staff.cat.z3950.marked_record_for_overlay_indicator.record_id.label',[g.data.marked_record]),
804 gen_statusbar_click_handler('marked_record')
809 function mark_for_hold_transfer() {
810 g.data.marked_record_for_hold_transfer = docid;
811 g.data.stash('marked_record_for_hold_transfer');
812 var robj = g.network.simple_request('MODS_SLIM_RECORD_RETRIEVE.authoritative',[docid]);
813 if (typeof robj.ilsevent == 'undefined') {
814 g.data.marked_record_for_hold_transfer_mvr = robj;
816 g.data.marked_record_for_hold_transfer_mvr = null;
817 g.error.standard_unexpected_error_alert('in mark_for_hold_transfer',robj);
819 g.data.stash('marked_record_for_hold_transfer_mvr');
820 if (g.data.marked_record_mvr) {
821 var m = $("offlineStrings").getFormattedString('staff.cat.opac.marked_record_for_hold_transfer_indicator.tcn.label',[g.data.marked_record_for_hold_transfer_mvr.tcn()]);
827 gen_statusbar_click_handler('marked_record_for_hold_transfer')
830 var m = $("offlineStrings").getFormattedString('staff.cat.opac.marked_record_for_hold_transfer_indicator.record_id.label',[g.data.marked_record_for_hold_transfer]);
836 gen_statusbar_click_handler('marked_record_for_hold_transfer')
841 function transfer_title_holds() {
842 g.data.stash_retrieve();
843 var target = g.data.marked_record_for_hold_transfer;
845 var m = $("offlineStrings").getString('staff.cat.opac.title_for_hold_transfer.destination_needed.label');
849 var robj = g.network.simple_request('TRANSFER_TITLE_HOLDS',[ ses(), target, [ docid ] ]);
851 var m = $("offlineStrings").getString('staff.cat.opac.title_for_hold_transfer.success.label');
854 var m = $("offlineStrings").getString('staff.cat.opac.title_for_hold_transfer.failure.label');
857 hold_browser_reset = true;
858 if (g.view == 'hold_browser') { set_hold_browser(); };
861 function delete_record() {
862 if (g.error.yns_alert(
863 document.getElementById('offlineStrings').getFormattedString('cat.opac.delete_record.confirm', [docid]),
864 document.getElementById('offlineStrings').getString('cat.opac.delete_record'),
865 document.getElementById('offlineStrings').getString('cat.opac.delete'),
866 document.getElementById('offlineStrings').getString('cat.opac.cancel'),
868 document.getElementById('offlineStrings').getString('cat.opac.record_deleted.confirm')) == 0) {
869 var robj = g.network.simple_request('FM_BRE_DELETE',[ses(),docid]);
870 if (typeof robj.ilsevent != 'undefined') {
871 alert(document.getElementById('offlineStrings').getFormattedString('cat.opac.record_deleted.error', [docid, robj.textcode, robj.desc]) + '\n');
873 alert(document.getElementById('offlineStrings').getString('cat.opac.record_deleted'));
874 refresh_display(docid);
879 function undelete_record() {
880 if (g.error.yns_alert(
881 document.getElementById('offlineStrings').getFormattedString('cat.opac.undelete_record.confirm', [docid]),
882 document.getElementById('offlineStrings').getString('cat.opac.undelete_record'),
883 document.getElementById('offlineStrings').getString('cat.opac.undelete'),
884 document.getElementById('offlineStrings').getString('cat.opac.cancel'),
886 document.getElementById('offlineStrings').getString('cat.opac.record_undeleted.confirm')) == 0) {
888 var robj = g.network.simple_request('FM_BRE_UNDELETE',[ses(),docid]);
889 if (typeof robj.ilsevent != 'undefined') {
890 alert(document.getElementById('offlineStrings').getFormattedString('cat.opac.record_undeleted.error', [docid, robj.textcode, robj.desc]) + '\n');
892 alert(document.getElementById('offlineStrings').getString('cat.opac.record_undeleted'));
893 refresh_display(docid);
898 function refresh_display(id) {
900 marc_view_reset = true;
901 marc_edit_reset = true;
902 copy_browser_reset = true;
903 hold_browser_reset = true;
904 manage_parts_reset = true;
905 manage_multi_home_reset = true;
906 serctrl_view_reset = true;
907 while(top_pane.node.lastChild) top_pane.node.removeChild( top_pane.node.lastChild );
908 var children = bottom_pane.node.childNodes;
909 for (var i = 0; i < children.length; i++) {
910 if (children[i] != browser_frame) bottom_pane.node.removeChild(children[i]);
914 $('nav').setAttribute('hidden','false');
915 var settings = g.network.simple_request(
917 [ ses(), g.data.list.au[0].id() ]
919 var view = settings['staff_client.catalog.record_view.default'];
920 if (g.view_override) {
921 view = g.view_override;
922 g.view_override = null;
925 case 'marc_view' : set_marc_view(); break;
926 case 'marc_edit' : set_marc_edit(); break;
927 case 'copy_browser' : set_copy_browser(); break;
928 case 'hold_browser' : set_hold_browser(); break;
929 case 'serctrl_view' : set_serctrl_view(); break;
931 default: set_opac(); break;
933 opac_wrapper_set_help_context();
935 g.error.standard_unexpected_error_alert('in refresh_display',E);
939 function set_default() {
940 var robj = g.network.simple_request(
942 [ ses(), g.data.list.au[0].id(), { 'staff_client.catalog.record_view.default' : g.view } ]
944 if (typeof robj.ilsevent != 'undefined') {
945 if (robj.ilsevent != 0) g.error.standard_unexpected_error_alert(document.getElementById('offlineStrings').getString('cat.preference.error'), robj);
949 function add_volumes() {
953 edit = g.network.request(
954 api.PERM_MULTI_ORG_CHECK.app,
955 api.PERM_MULTI_ORG_CHECK.method,
960 [ 'CREATE_VOLUME', 'CREATE_COPY' ]
962 ).length == 0 ? 1 : 0;
964 g.error.sdump('D_ERROR','batch permission check: ' + E);
968 alert(document.getElementById('offlineStrings').getString('staff.circ.copy_status.add_volumes.perm_failure'));
969 return; // no read-only view for this interface
972 // Check if the source is allowed to have copies.
974 var bibObj = g.network.request(
975 api.FM_BRE_RETRIEVE_VIA_ID.app,
976 api.FM_BRE_RETRIEVE_VIA_ID.method,
982 var cbsObj = g.network.request(
983 api.FM_CBS_RETRIEVE_VIA_PCRUD.app,
984 api.FM_CBS_RETRIEVE_VIA_PCRUD.method,
985 [ ses(), bibObj.source() ]
988 if (cbsObj && cbsObj.can_have_copies() != get_db_true()) {
989 alert(document.getElementById('offlineStrings').getFormattedString('staff.cat.bib_source.can_have_copies.false', [cbsObj.source()]));
993 g.error.sdump('D_ERROR','can have copies check: ' + E);
994 alert('Error in chrome/content/cat/opac.js, add_volumes(): ' + E);
998 var title = document.getElementById('offlineStrings').getFormattedString('staff.circ.copy_status.add_volumes.title', [docid]);
1001 var unified_interface = String( g.data.hash.aous['ui.unified_volume_copy_editor'] ) == 'true';
1002 if (unified_interface) {
1003 var horizontal_interface = String( g.data.hash.aous['ui.cat.volume_copy_editor.horizontal'] ) == 'true';
1004 url = window.xulG.url_prefix( horizontal_interface ? urls.XUL_VOLUME_COPY_CREATOR_HORIZONTAL : urls.XUL_VOLUME_COPY_CREATOR );
1006 url = window.xulG.url_prefix( urls.XUL_VOLUME_COPY_CREATOR_ORIGINAL );
1009 var w = xulG.new_tab(
1011 { 'tab_name' : title },
1012 { 'doc_id' : docid, 'ou_ids' : [ ses('ws_ou') ], 'reload_opac' : xulG.reload_opac }
1015 alert('Error in chrome/content/cat/opac.js, add_volumes(): ' + E);
1019 function manage_parts() {
1021 g.view = 'manage_parts';
1022 var loc = urls.XUL_BROWSER + "?url=" + window.escape(
1023 window.xulG.url_prefix(urls.CONIFY_MANAGE_PARTS) + '?r=' + docid
1025 if (manage_parts_reset) {
1026 bottom_pane.reset_iframe( loc,{},xulG);
1027 manage_parts_reset =false;
1029 bottom_pane.set_iframe( loc,{},xulG);
1031 opac_wrapper_set_help_context();
1032 bottom_pane.get_contentWindow().addEventListener('load',opac_wrapper_set_help_context,false);
1034 alert('Error in chrome/content/cat/opac.js, manage_parts(): ' + E);
1038 function manage_multi_home_items() {
1040 g.view = 'manage_multi_home';
1041 var loc = window.xulG.url_prefix(urls.MANAGE_MULTI_HOME_ITEMS);
1042 if (manage_multi_home_reset) {
1043 bottom_pane.reset_iframe( loc,{},{'docid':docid,'no_bib_summary':true,'url_prefix':xulG.url_prefix,'new_tab':xulG.new_tab});
1044 manage_multi_home_reset =false;
1046 bottom_pane.set_iframe( loc,{},{'docid':docid,'no_bib_summary':true,'url_prefix':xulG.url_prefix,'new_tab':xulG.new_tab});
1048 opac_wrapper_set_help_context();
1049 bottom_pane.get_contentWindow().addEventListener('load',opac_wrapper_set_help_context,false);
1051 alert('Error in chrome/content/cat/opac.js, manage_multi_home_items(): ' + E);
1055 function mark_for_multi_home() {
1056 g.data.marked_multi_home_record = docid;
1057 g.data.stash('marked_multi_home_record');
1058 var robj = g.network.simple_request('MODS_SLIM_RECORD_RETRIEVE.authoritative',[docid]);
1059 if (typeof robj.ilsevent == 'undefined') {
1060 g.data.marked_multi_home_record_mvr = robj;
1062 g.data.marked_multi_home_record_mvr = null;
1063 g.error.standard_unexpected_error_alert('in mark_for_multi_home',robj);
1065 g.data.stash('marked_multi_home_record_mvr');
1067 if (g.data.marked_multi_home_record_mvr) {
1068 alert(document.getElementById('offlineStrings').getFormattedString('cat.opac.record_marked_for_multi_home.tcn.alert',[ g.data.marked_multi_home_record_mvr.tcn() ]));
1071 $("offlineStrings").getFormattedString('staff.cat.copy_browser.marked_record_for_multi_home_indicator.tcn.label',[g.data.marked_multi_home_record_mvr.tcn()]),
1072 $("offlineStrings").getFormattedString('staff.cat.copy_browser.marked_record_for_multi_home_indicator.record_id.label',[g.data.marked_multi_home_record]),
1073 gen_statusbar_click_handler('marked_multi_home_record')
1076 alert(document.getElementById('offlineStrings').getFormattedString('cat.opac.record_marked_for_multi_home.record_id.alert',[ g.data.marked_multi_home_record ]));
1079 $("offlineStrings").getFormattedString('staff.cat.copy_browser.marked_record_for_multi_home_indicator.record_id.label',[g.data.marked_multi_home_record]),
1081 gen_statusbar_click_handler('marked_multi_home_record')
1086 function gen_statusbar_click_handler(data_key) {
1087 return function (ev) {
1089 if (! g.data[data_key]) {
1093 if (ev.button == 0 /* left click, spawn opac */) {
1094 var opac_url = xulG.url_prefix( urls.opac_rdetail ) + g.data[data_key];
1095 var content_params = {
1097 'authtime' : ses('authtime'),
1098 'opac_url' : opac_url,
1101 xulG.url_prefix(urls.XUL_OPAC_WRAPPER),
1102 {'tab_name':'Retrieving title...'},
1107 if (ev.button == 2 /* right click, remove mark */) {
1108 if ( window.confirm( document.getElementById('offlineStrings').getString('cat.opac.clear_statusbar') ) ) {
1109 g.data[data_key] = null;
1110 g.data.stash(data_key);
1111 ev.target.setAttribute('label','');
1112 if (ev.target.hasAttribute('tooltiptext')) {
1113 ev.target.removeAttribute('tooltiptext');