1 dump('entering main/menu.js\n');
6 if (typeof main == 'undefined') main = {};
7 main.menu = function () {
9 offlineStrings = document.getElementById('offlineStrings');
10 JSAN.use('util.error'); this.error = new util.error();
11 JSAN.use('util.window'); this.window = new util.window();
12 JSAN.use('OpenILS.data'); this.data = new OpenILS.data(); this.data.init({'via':'stash'});
15 var x = document.getElementById('network_progress');
16 x.setAttribute('count','0');
20 if ( window.confirm(offlineStrings.getString('menu.reset_network_stats')) ) {
21 var y = document.getElementById('network_progress_rows');
22 while(y.firstChild) { y.removeChild( y.lastChild ); }
23 x.setAttribute('mode','determined');
24 x.setAttribute('count','0');
31 main.menu.prototype = {
36 'toolbar_size' : 'large',
37 'toolbar_mode' : 'both',
38 'toolbar_labelpos' : 'side',
40 'url_prefix' : function(url,secure) {
41 // This allows urls to start with a urls key (or be only a urls key)
42 // We stop at the first / or ? to allow extra paths and query strings.
43 var base_url = url.match(/^[^?/|]+/);
45 base_url = base_url[0];
47 url = url.replace(/^[^?/|]+\|?/, urls[base_url]);
49 // if host unspecified URL with leading /, prefix the remote hostname
50 if (url.match(/^\//)) url = urls.remote + url;
51 // if it starts with http:// and we want secure, convert to https://
52 if (secure && url.match(/^http:\/\//)) {
53 url = url.replace(/^http:\/\//, 'https://');
55 // if it doesn't start with a known protocol, add http(s)://
56 if (! url.match(/^(http|https|chrome|oils):\/\//) && ! url.match(/^data:/) ) {
61 dump('url_prefix = ' + url + '\n');
65 'init' : function( params ) {
69 urls.remote = params['server'];
71 xulG.get_barcode = this.get_barcode;
72 xulG.get_barcode_and_settings = this.get_barcode_and_settings;
74 // Disable commands that we can't do anything with right now
75 if(typeof xulG.window.win.start_venkman != 'function') {
76 var element = document.getElementById('cmd_debug_venkman');
77 element.setAttribute('disabled','true');
78 element.removeAttribute('perm');
80 if(typeof xulG.window.win.inspectDOMDocument != 'function') {
81 var element = document.getElementById('cmd_debug_inspector');
82 element.setAttribute('disabled','true');
83 element.removeAttribute('perm');
85 if(typeof xulG.window.win.startChromeList != 'function') {
86 var element = document.getElementById('cmd_debug_chrome_list');
87 element.setAttribute('disabled','true');
88 element.removeAttribute('perm');
92 // Pull in local customizations
93 var r = new XMLHttpRequest();
94 var custom_js = obj.url_prefix('CUSTOM_JS');
95 r.open("GET", custom_js, false);
97 if (r.status == 200) {
98 dump('Evaluating ' + custom_js + '\n');
99 eval( r.responseText );
102 this.button_bar_init();
104 var cl_first = xulG.pref.getBoolPref('oils.copy_editor.copy_location_name_first');
105 var menuitems = document.getElementsByAttribute('command','cmd_copy_editor_copy_location_first_toggle');
106 for(var i = 0; i < menuitems.length; i++)
107 menuitems[i].setAttribute('checked', cl_first ? 'true' : 'false');
109 xulG.pref.addObserver('', this, false);
110 window.addEventListener("unload", function(e) { this.stop_observing(); }, false);
112 var network_meter = String( obj.data.hash.aous['ui.network.progress_meter'] ) == 'true';
113 if (! network_meter) {
114 var x = document.getElementById('network_progress');
115 if (x) x.setAttribute('hidden','true');
116 var y = document.getElementById('page_progress');
117 if (y) y.setAttribute('hidden','true');
120 var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"].
121 getService(Components.interfaces.nsIWindowMediator);
122 var mainwin = wm.getMostRecentWindow('eg_main');
123 mainwin.get_menu_perms(document);
124 var hotkeysets = mainwin.load_hotkey_sets();
126 var popupmenu = document.getElementById('main.menu.admin.client.hotkeys.current.popup');
128 for(var i = 0; i < hotkeysets.length; i++) {
129 var keysetname = hotkeysets[i];
130 var menuitem = document.createElement('menuitem');
131 if(offlineStrings.testString('hotkey.' + keysetname))
132 menuitem.setAttribute('label',offlineStrings.getString('hotkey.' + keysetname));
134 menuitem.setAttribute('label',keysetname);
135 menuitem.setAttribute('value',keysetname);
136 menuitem.setAttribute('type','radio');
137 menuitem.setAttribute('name','menu_hotkey_current');
138 menuitem.setAttribute('command','cmd_hotkeys_set');
139 popupmenu.appendChild(menuitem);
142 JSAN.use('util.network');
143 var network = new util.network();
144 network.set_user_status();
146 this.set_menu_hotkeys();
148 function open_conify_page(path, labelKey, event) {
151 labelKey = labelKey || 'menu.cmd_open_conify.tab';
152 label = offlineStrings.getString(labelKey);
155 var loc = urls.XUL_BROWSER + '?url=' + window.escape( obj.url_prefix('CONIFY/') + path + '.html');
160 {'tab_name' : label, 'browser' : false },
161 {'no_xulG' : false, 'show_print_button' : false, show_nav_buttons:true}
165 function open_admin_page(path, labelKey, addSes, event) {
168 labelKey = labelKey || 'menu.cmd_open_conify.tab';
169 label = offlineStrings.getString(labelKey);
172 var loc = urls.XUL_BROWSER + '?url=' + window.escape( obj.url_prefix('XUL_LOCAL_ADMIN_BASE/') + path);
173 if(addSes) loc += window.escape('?ses=' + ses());
178 {'tab_name' : label, 'browser' : false },
179 {'no_xulG' : false, 'show_print_button' : true, 'show_nav_buttons' : true }
184 function open_eg_web_page(path, labelKey, event, content_params) {
187 labelKey = labelKey || 'menu.cmd_open_conify.tab';
188 var label = offlineStrings.getString(labelKey);
191 var loc = urls.XUL_BROWSER + '?url=' + window.escape(obj.url_prefix('EG_WEB_BASE/') + path);
193 content_params = content_params || {
195 'show_print_button': true,
196 'show_nav_buttons': true
200 event, loc, {tab_name: label, browser: false}, content_params
207 function() { alert(offlineStrings.getString('common.unimplemented')); }
211 'cmd_close_window' : [
214 JSAN.use('util.widgets');
215 util.widgets.dispatch('close',window);
221 var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"].
222 getService(Components.interfaces.nsIWindowMediator);
223 wm.getMostRecentWindow('eg_main').new_tabs(Array('new'));
229 if (obj.new_tab(null,{'focus':true},null) == false)
231 if(window.confirm(offlineStrings.getString('menu.new_tab.max_tab_dialog')))
233 var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"].
234 getService(Components.interfaces.nsIWindowMediator);
235 wm.getMostRecentWindow('eg_main').new_tabs(Array('tab'));
250 var closeAll = false;
251 if(event && event.sourceEvent) myEvent = event.sourceEvent;
252 // Note: The last event is not supposed to be myEvent in this if.
253 if(myEvent && myEvent.explicitOriginalTarget.nodeName.match(/toolbarbutton/) && myEvent.explicitOriginalTarget.command == event.originalTarget.id) {
254 var value = xulG.pref.getIntPref('ui.key.accelKey');
257 closeAll = myEvent.ctrlKey;
260 closeAll = myEvent.altKey;
263 closeAll = myEvent.metaKey;
268 obj.close_all_tabs();
274 'cmd_close_all_tabs' : [
276 function() { obj.close_all_tabs(); }
280 'cmd_edit_copy_buckets' : [
283 obj.data.stash_retrieve();
284 obj.command_tab(event,obj.url_prefix('XUL_COPY_BUCKETS'),{'tab_name':offlineStrings.getString('menu.cmd_edit_copy_buckets.tab')},{});
287 'cmd_edit_volume_buckets' : [
290 obj.data.stash_retrieve();
291 obj.command_tab(event,obj.url_prefix('XUL_VOLUME_BUCKETS'),{'tab_name':offlineStrings.getString('menu.cmd_edit_volume_buckets.tab')},{});
294 'cmd_edit_record_buckets' : [
297 obj.data.stash_retrieve();
298 obj.command_tab(event,obj.url_prefix('XUL_RECORD_BUCKETS'),{'tab_name':offlineStrings.getString('menu.cmd_edit_record_buckets.tab')},{});
301 'cmd_edit_user_buckets' : [
304 obj.data.stash_retrieve();
305 obj.command_tab(event,obj.url_prefix('XUL_USER_BUCKETS'),{'tab_name':offlineStrings.getString('menu.cmd_edit_user_buckets.tab')},{});
310 'cmd_replace_barcode' : [
314 JSAN.use('util.network');
315 var network = new util.network();
317 var old_bc = window.prompt(offlineStrings.getString('menu.cmd_replace_barcode.prompt'),'',offlineStrings.getString('menu.cmd_replace_barcode.label'));
322 copy = network.simple_request('FM_ACP_RETRIEVE_VIA_BARCODE',[ old_bc ]);
323 if (typeof copy.ilsevent != 'undefined') throw(copy);
324 if (!copy) throw(copy);
326 alert(offlineStrings.getFormattedString('menu.cmd_replace_barcode.retrieval.error', [old_bc]) + '\n');
330 // Why did I want to do this twice? Because this copy is more fleshed?
332 copy = network.simple_request('FM_ACP_RETRIEVE',[ copy.id() ]);
333 if (typeof copy.ilsevent != 'undefined') throw(copy);
334 if (!copy) throw(copy);
336 try { alert(offlineStrings.getFormattedString('menu.cmd_replace_barcode.retrieval.error', [old_bc]) + '\n' + (typeof E.ilsevent == 'undefined' ? '' : E.textcode + ' : ' + E.desc)); } catch(F) { alert(E + '\n' + F); }
340 var new_bc = window.prompt(offlineStrings.getString('menu.cmd_replace_barcode.replacement.prompt'),'',offlineStrings.getString('menu.cmd_replace_barcode.replacement.label'));
341 new_bc = String( new_bc ).replace(/\s/g,'');
342 /* Casting a possibly null input value to a String turns it into "null" */
343 if (!new_bc || new_bc == 'null') {
344 alert(offlineStrings.getString('menu.cmd_replace_barcode.blank.error'));
348 var test = network.simple_request('FM_ACP_RETRIEVE_VIA_BARCODE',[ new_bc ]);
349 if (typeof test.ilsevent == 'undefined') {
350 alert(offlineStrings.getFormattedString('menu.cmd_replace_barcode.duplicate.error', [new_bc]));
353 if (test.ilsevent != 1502 /* ASSET_COPY_NOT_FOUND */) {
354 obj.error.standard_unexpected_error_alert(offlineStrings.getFormattedString('menu.cmd_replace_barcode.testing.error', [new_bc]),test);
359 copy.barcode(new_bc); copy.ischanged('1');
360 var r = network.simple_request('FM_ACP_FLESHED_BATCH_UPDATE', [ ses(), [ copy ] ]);
361 if (typeof r.ilsevent != 'undefined') {
362 if (r.ilsevent != 0) {
363 if (r.ilsevent == 5000 /* PERM_FAILURE */) {
364 alert(offlineStrings.getString('menu.cmd_replace_barcode.permission.error'));
366 obj.error.standard_unexpected_error_alert(offlineStrings.getString('menu.cmd_replace_barcode.renaming.error'),r);
371 obj.error.standard_unexpected_error_alert(offlineStrings.getString('menu.cmd_replace_barcode.renaming.failure'),copy);
377 'cmd_patron_search' : [
380 obj.set_patron_tab({},{},event);
383 'cmd_search_usr_id' : [
387 offlineStrings.getString('menu.cmd_search_usr_id.tab'),
389 offlineStrings.getString('menu.cmd_search_usr_id.prompt')
391 if (usr_id != '' && ! isNaN(usr_id)) {
400 'cmd_search_opac' : [
403 obj.data.stash_retrieve();
404 var content_params = { 'session' : ses(), 'authtime' : ses('authtime') };
405 obj.command_tab(event,obj.url_prefix('XUL_OPAC_WRAPPER'), {'tab_name':offlineStrings.getString('menu.cmd_search_opac.tab')}, content_params);
411 var tcn = prompt(offlineStrings.getString('menu.cmd_search_tcn.tab'),'',offlineStrings.getString('menu.cmd_search_tcn.prompt'));
413 function spawn_tcn(r,event) {
414 for (var i = 0; i < r.count; i++) {
416 var opac_url = obj.url_prefix('opac_rdetail') + id;
417 obj.data.stash_retrieve();
418 var content_params = {
420 'authtime' : ses('authtime'),
421 'opac_url' : opac_url,
426 obj.url_prefix('XUL_OPAC_WRAPPER'),
432 obj.url_prefix('XUL_OPAC_WRAPPER'),
441 JSAN.use('util.network');
442 var network = new util.network();
443 var robj = network.simple_request('FM_BRE_ID_SEARCH_VIA_TCN',[tcn]);
444 if (robj.count != robj.ids.length) throw('FIXME -- FM_BRE_ID_SEARCH_VIA_TCN = ' + js2JSON(robj));
445 if (robj.count == 0) {
446 var robj2 = network.simple_request('FM_BRE_ID_SEARCH_VIA_TCN',[tcn,1]);
447 if (robj2.count == 0) {
448 alert(offlineStrings.getFormattedString('menu.cmd_search_tcn.not_found.error', [tcn]));
450 if ( window.confirm(offlineStrings.getFormattedString('menu.cmd_search_tcn.deleted.error', [tcn])) ) {
451 spawn_tcn(robj2,event);
455 spawn_tcn(robj,event);
460 'cmd_search_bib_id' : [
463 var bib_id = prompt(offlineStrings.getString('menu.cmd_search_bib_id.tab'),'',offlineStrings.getString('menu.cmd_search_bib_id.prompt'));
466 var opac_url = obj.url_prefix('opac_rdetail') + bib_id;
467 var content_params = {
469 'authtime' : ses('authtime'),
470 'opac_url' : opac_url,
474 obj.url_prefix('XUL_OPAC_WRAPPER'),
475 {'tab_name':'#' + bib_id},
480 'cmd_copy_status' : [
483 obj.data.stash_retrieve();
484 obj.command_tab(event,obj.url_prefix('XUL_COPY_STATUS'),{},{});
488 /* Circulation Menu */
489 'cmd_patron_register' : [
493 function log_registration(p) {
496 document.getElementById('offlineStrings').getFormattedString(
497 'staff.circ.work_log_patron_registration.message',
499 ses('staff_usrname'),
505 'au_family_name' : p.family_name(),
506 'au_barcode' : p.card().barcode()
510 obj.error.sdump('D_ERROR','Error with work_logging in menu.js, cmd_patron_register:' + E);
514 function spawn_editor(p) {
515 var url = 'XUL_PATRON_EDIT';
518 if (param_count++ == 0) url += '?'; else url += '&';
519 url += i + '=' + window.escape(p[i]);
521 var loc = obj.url_prefix('XUL_BROWSER?url=') + window.escape( obj.url_prefix(url) );
526 'show_print_button' : true ,
527 'tab_name' : offline.getString('menu.cmd_patron_register.related.tab'),
528 'passthru_content_params' : {
529 'spawn_search' : function(s) { obj.spawn_search(s); },
530 'spawn_editor' : spawn_editor,
531 'on_save' : function(p) { log_registration(p); }
537 obj.data.stash_retrieve();
538 var loc = obj.url_prefix('XUL_BROWSER?url=')
539 + window.escape( obj.url_prefix('XUL_PATRON_EDIT') );
545 'show_print_button' : true ,
546 'tab_name' : offlineStrings.getString('menu.cmd_patron_register.tab'),
547 'passthru_content_params' : {
549 'spawn_search' : function(s) { obj.spawn_search(s); },
550 'spawn_editor' : spawn_editor,
551 'on_save' : function(p) { log_registration(p); }
557 'cmd_staged_patrons' : [
560 obj.data.stash_retrieve();
561 obj.command_tab(event,obj.url_prefix('XUL_STAGED_PATRONS'),{'tab_name':offlineStrings.getString('menu.circulation.staged_patrons.tab')},{});
564 'cmd_circ_checkin' : [
567 obj.data.stash_retrieve();
568 obj.command_tab(event,obj.url_prefix('XUL_CHECKIN'),{},{});
574 obj.data.stash_retrieve();
575 obj.command_tab(event,obj.url_prefix('XUL_RENEW'),{},{});
578 'cmd_circ_checkout' : [
581 obj.data.stash_retrieve();
582 obj.command_tab(event,obj.url_prefix('XUL_PATRON_BARCODE_ENTRY'),{},{});
585 'cmd_circ_hold_capture' : [
588 obj.data.stash_retrieve();
589 obj.command_tab(event,obj.url_prefix('XUL_CHECKIN?hold_capture=1'),{},{});
592 'cmd_browse_holds_shelf' : [
595 obj.data.stash_retrieve();
596 obj.command_tab(event,obj.url_prefix('XUL_HOLDS_BROWSER?shelf=1'),{ 'tab_name' : offlineStrings.getString('menu.cmd_browse_holds_shelf.tab') },{});
599 'cmd_clear_holds_shelf' : [
602 obj.data.stash_retrieve();
605 obj.url_prefix(urls.XUL_HOLDS_BROWSER),
607 'tab_name' : offlineStrings.getString('menu.cmd_browse_holds_shelf.tab')
616 'cmd_circ_hold_pull_list' : [
619 obj.data.stash_retrieve();
620 var loc = urls.XUL_BROWSER + '?url=' + window.escape(
621 obj.url_prefix('XUL_HOLD_PULL_LIST')
623 obj.command_tab(event, loc, {'tab_name' : offlineStrings.getString('menu.cmd_browse_hold_pull_list.tab')} );
627 'cmd_in_house_use' : [
630 obj.data.stash_retrieve();
631 obj.command_tab(event,obj.url_prefix('XUL_IN_HOUSE_USE'),{},{});
635 'cmd_scan_item_as_missing_pieces' : [
638 xulG.window.open(obj.url_prefix('XUL_SCAN_ITEM_AS_MISSING_PIECES'),'scan_missing_pieces','chrome');
645 //obj.set_tab(obj.url_prefix('XUL_STANDALONE'),{},{});
646 window.open(urls.XUL_STANDALONE,'Offline','chrome,resizable');
650 'cmd_local_admin' : [
653 //obj.set_tab(obj.url_prefix('XUL_LOCAL_ADMIN')+'?ses='+window.escape(ses())+'&session='+window.escape(ses()),{},{});
654 var loc = urls.XUL_BROWSER + '?url=' + window.escape(
655 obj.url_prefix( 'XUL_LOCAL_ADMIN?ses='+window.escape(ses())+'&session='+window.escape(ses()) )
660 {'tab_name' : offlineStrings.getString('menu.cmd_local_admin.tab'), 'browser' : false },
661 { 'no_xulG' : false, 'show_nav_buttons' : true, 'show_print_button' : true }
667 'cmd_toggle_meters' : [
670 var x = document.getElementById('network_progress');
671 if (x) x.hidden = ! x.hidden;
672 var y = document.getElementById('page_progress');
673 if (y) y.hidden = ! y.hidden;
677 'cmd_local_admin_reports' : [
680 var loc = urls.XUL_BROWSER + '?url=' + window.escape( obj.url_prefix('XUL_REPORTS?ses=') + ses());
684 {'tab_name' : offlineStrings.getString('menu.cmd_local_admin_reports.tab'), 'browser' : false },
685 {'no_xulG' : false, 'show_print_button' : false, show_nav_buttons : true }
689 'cmd_open_vandelay' : [
691 function(event) { open_eg_web_page('vandelay/vandelay', null, event); }
693 'cmd_local_admin_transit_list' : [
695 function(event) { open_admin_page('transit_list.xul', 'menu.cmd_local_admin_transit_list.tab', false, event); }
697 'cmd_local_admin_age_overdue_circulations_to_lost' : [
699 function(event) { open_admin_page('circ_age_to_lost.xul', 'menu.cmd_local_admin_age_overdue_circulations_to_lost.tab', true, event); }
701 'cmd_local_admin_cash_reports' : [
703 function(event) { open_admin_page('cash_reports.xhtml', 'menu.cmd_local_admin_cash_reports.tab', true, event); }
705 'cmd_local_admin_fonts_and_sounds' : [
707 function(event) { open_admin_page('font_settings.xul', 'menu.cmd_local_admin_fonts_and_sounds.tab', false, event); }
709 'cmd_local_admin_printer' : [
711 function(event) { open_admin_page('printer_settings.xul', 'menu.cmd_local_admin_printer.tab', false, event); }
713 'cmd_local_admin_do_not_auto_attempt_print_setting' : [
716 obj.command_tab(event,obj.url_prefix('XUL_DO_NOT_AUTO_ATTEMPT_PRINT_SETTING'),{'tab_name':offlineStrings.getString('menu.cmd_local_admin_do_not_auto_attempt_print_setting.tab')},{});
719 'cmd_local_admin_closed_dates' : [
721 function(event) { open_admin_page('closed_dates.xhtml', 'menu.cmd_local_admin_closed_dates.tab', true, event); }
723 'cmd_local_admin_copy_locations' : [
725 function(event) { open_admin_page('copy_locations.xhtml', 'menu.cmd_local_admin_copy_locations.tab', true, event); }
727 'cmd_local_admin_lib_settings' : [
729 function(event) { open_admin_page('org_unit_settings.xhtml', 'menu.cmd_local_admin_lib_settings.tab', true, event); }
731 'cmd_local_admin_non_cat_types' : [
733 function(event) { open_admin_page('non_cat_types.xhtml', 'menu.cmd_local_admin_non_cat_types.tab', true, event); }
735 'cmd_local_admin_stat_cats' : [
737 function(event) { open_admin_page('stat_cat_editor.xhtml', 'menu.cmd_local_admin_stat_cats.tab', true, event); }
739 'cmd_local_admin_standing_penalty' : [
741 function(event) { open_eg_web_page('conify/global/config/standing_penalty', null, event); }
743 'cmd_local_admin_grp_penalty_threshold' : [
745 function(event) { open_eg_web_page('conify/global/permission/grp_penalty_threshold', null, event); }
747 'cmd_local_admin_circ_limit_set' : [
749 function(event) { open_eg_web_page('conify/global/config/circ_limit_set', null, event); }
751 'cmd_server_admin_config_rule_circ_duration' : [
753 function(event) { open_eg_web_page('conify/global/config/rule_circ_duration', null, event); }
755 'cmd_server_admin_config_hard_due_date' : [
757 function(event) { open_eg_web_page('conify/global/config/hard_due_date', null, event); }
759 'cmd_server_admin_config_rule_recurring_fine' : [
761 function(event) { open_eg_web_page('conify/global/config/rule_recurring_fine', null, event); }
763 'cmd_server_admin_config_rule_max_fine' : [
765 function(event) { open_eg_web_page('conify/global/config/rule_max_fine', null, event); }
767 'cmd_server_admin_config_rule_age_hold_protect' : [
769 function(event) { open_eg_web_page('conify/global/config/rule_age_hold_protect', null, event); }
771 'cmd_server_admin_config_circ_weights' : [
773 function(event) { open_eg_web_page('conify/global/config/circ_matrix_weights', null, event); }
775 'cmd_server_admin_config_hold_weights' : [
777 function(event) { open_eg_web_page('conify/global/config/hold_matrix_weights', null, event); }
779 'cmd_server_admin_config_weight_assoc' : [
781 function(event) { open_eg_web_page('conify/global/config/weight_assoc', null, event); }
783 'cmd_server_admin_config_actor_sip_fields' : [
785 function(event) { open_eg_web_page('conify/global/config/actor_sip_fields', null, event); }
787 'cmd_server_admin_config_asset_sip_fields' : [
789 function(event) { open_eg_web_page('conify/global/config/asset_sip_fields', null, event); }
791 'cmd_server_admin_circ_limit_group' : [
793 function(event) { open_eg_web_page('conify/global/config/circ_limit_group', null, event); }
795 'cmd_server_admin_config_best_hold_order' : [
797 function(event) { open_eg_web_page('conify/global/config/best_hold_order', null, event); }
799 'cmd_server_admin_vandelay_import_bib_trash_group' : [
801 function(event) { open_eg_web_page('conify/global/vandelay/import_bib_trash_group', null, event); }
803 'cmd_server_admin_config_usr_activity_type' : [
805 function(event) { open_eg_web_page('conify/global/config/usr_activity_type', null, event); }
807 'cmd_server_admin_actor_org_unit_custom_tree' : [
809 function(event) { open_eg_web_page('conify/global/actor/org_unit_custom_tree', null, event); }
811 'cmd_local_admin_external_text_editor' : [
814 var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components.interfaces['nsIPrefBranch']);
815 var key = 'oils.text_editor.external.cmd';
816 var has_key = prefs.prefHasUserValue(key);
817 var value = has_key ? prefs.getCharPref(key) : 'C:\\Windows\\notepad.exe %letter.txt%';
818 var cmd = window.prompt(
819 document.getElementById('offlineStrings').getString('text_editor.prompt_for_external_cmd'),
822 if (!cmd) { return; }
823 prefs.setCharPref(key,cmd);
826 'cmd_local_admin_idl_field_doc' : [
828 function(event) { open_eg_web_page('conify/global/config/idl_field_doc', null, event); }
830 'cmd_local_admin_action_trigger' : [
832 function(event) { open_eg_web_page('conify/global/action_trigger/event_definition', null, event); }
834 'cmd_local_admin_survey' : [
836 function(event) { open_eg_web_page('conify/global/action/survey', null, event); }
838 'cmd_local_admin_barcode_completion' : [
840 function() { open_eg_web_page('conify/global/config/barcode_completion',
841 'menu.local_admin.barcode_completion.tab'); }
843 'cmd_local_admin_circ_matrix_matchpoint' : [
845 function() { open_eg_web_page('conify/global/config/circ_matrix_matchpoint',
846 'menu.local_admin.circ_matrix_matchpoint.tab'); }
848 'cmd_local_admin_hold_matrix_matchpoint' : [
850 function() { open_eg_web_page('conify/global/config/hold_matrix_matchpoint',
851 'menu.local_admin.hold_matrix_matchpoint.tab'); }
853 'cmd_local_admin_copy_location_order' : [
855 function(event) { open_eg_web_page('conify/global/asset/copy_location_order', null, event); }
857 'cmd_local_admin_work_log' : [
863 { 'tab_name' : offlineStrings.getString('menu.local_admin.work_log.tab') },
868 "cmd_local_admin_copy_template": [
871 open_eg_web_page("conify/global/asset/copy_template");
874 "cmd_local_admin_item_attribute_editor": [
879 urls.XUL_COPY_EDITOR,
880 { 'tab_name' : offlineStrings.getString('menu.local_admin.item_attribute_editor.tab') },
881 { 'admin' : true, 'not_modal' : true }
885 'cmd_local_admin_patrons_due_refunds' : [
890 obj.url_prefix('XUL_PATRONS_DUE_REFUNDS'),
891 { 'tab_name' : offlineStrings.getString('menu.local_admin.patrons_due_refunds.tab') },
896 'cmd_server_admin_org_type' : [
898 function(event) { open_conify_page('actor/org_unit_type', null, event); }
900 'cmd_server_admin_org_unit' : [
902 function(event) { open_conify_page('actor/org_unit', null, event); }
904 'cmd_server_admin_grp_tree' : [
906 function(event) { open_conify_page('permission/grp_tree', null, event); }
908 'cmd_server_admin_perm_list' : [
910 function(event) { open_conify_page('permission/perm_list', null, event); }
912 'cmd_server_admin_copy_status' : [
914 function(event) { open_conify_page('config/copy_status', null, event); }
916 'cmd_server_admin_marc_code' : [
918 function(event) { open_eg_web_page('conify/global/config/record_attr_definition', null, event); }
920 'cmd_server_admin_coded_value_map' : [
922 function(event) { open_eg_web_page('conify/global/config/coded_value_map', null, event); }
924 'cmd_server_admin_metabib_class' : [
926 function(event) { open_eg_web_page('conify/global/config/metabib_class', null, event); }
928 'cmd_server_admin_metabib_class_ts_map' : [
930 function(event) { open_eg_web_page('conify/global/config/metabib_class_ts_map', null, event); }
932 'cmd_server_admin_metabib_field' : [
934 function(event) { open_eg_web_page('conify/global/config/metabib_field', null, event); }
936 'cmd_server_admin_metabib_field_ts_map' : [
938 function(event) { open_eg_web_page('conify/global/config/metabib_field_ts_map', null, event); }
940 'cmd_server_admin_acn_prefix' : [
942 function(event) { open_eg_web_page('conify/global/config/acn_prefix', null, event); }
944 'cmd_server_admin_acn_suffix' : [
946 function(event) { open_eg_web_page('conify/global/config/acn_suffix', null, event); }
948 'cmd_server_admin_billing_type' : [
950 function(event) { open_eg_web_page('conify/global/config/billing_type', null, event); }
952 'cmd_server_admin_acq_invoice_item_type' : [
954 function(event) { open_eg_web_page('conify/global/acq/invoice_item_type', null, event); }
956 'cmd_server_admin_acq_invoice_payment_method' : [
958 function(event) { open_eg_web_page('conify/global/acq/invoice_payment_method', null, event); }
960 'cmd_server_admin_acq_lineitem_alert' : [
962 function(event) { open_eg_web_page('conify/global/acq/lineitem_alert', null, event); }
964 'cmd_server_admin_acq_lineitem_marc_attr_def' : [
966 function(event) { open_eg_web_page('conify/global/acq/lineitem_marc_attr_def', null, event); }
968 'cmd_server_admin_acq_fund_tag' : [
970 function(event) { open_eg_web_page('conify/global/acq/fund_tag', null, event); }
972 'cmd_server_admin_acq_cancel_reason' : [
974 function(event) { open_eg_web_page('conify/global/acq/cancel_reason', null, event); }
976 'cmd_server_admin_acq_claim_type' : [
978 function(event) { open_eg_web_page('conify/global/acq/claim_type', null, event); }
980 'cmd_server_admin_acq_claim_event_type' : [
982 function(event) { open_eg_web_page('conify/global/acq/claim_event_type', null, event); }
984 'cmd_server_admin_acq_claim_policy' : [
986 function(event) { open_eg_web_page('conify/global/acq/claim_policy', null, event); }
988 'cmd_server_admin_acq_claim_policy_action' : [
990 function(event) { open_eg_web_page('conify/global/acq/claim_policy_action', null, event); }
992 'cmd_server_admin_acq_fund' : [
994 function(event) { open_eg_web_page('acq/fund/list', null, event); }
996 'cmd_server_admin_acq_funding_source' : [
998 function(event) { open_eg_web_page('acq/funding_source/list', null, event); }
1000 'cmd_server_admin_acq_provider' : [
1002 function(event) { open_eg_web_page('conify/global/acq/provider', null, event); }
1004 'cmd_server_admin_acq_edi_account' : [
1006 function(event) { open_eg_web_page('conify/global/acq/edi_account', null, event); }
1008 'cmd_server_admin_acq_edi_message' : [
1010 function(event) { open_eg_web_page('acq/po/edi_messages', null, event); }
1012 'cmd_server_admin_acq_currency_type' : [
1014 function(event) { open_eg_web_page('acq/currency_type/list', null, event); }
1016 'cmd_server_admin_acq_exchange_rate' : [
1018 function(event) { open_eg_web_page('conify/global/acq/exchange_rate', null, event); }
1020 'cmd_server_admin_acq_distrib_formula' : [
1022 function(event) { open_eg_web_page('conify/global/acq/distribution_formula', null, event); }
1024 'cmd_server_admin_sms_carrier' : [
1026 function(event) { open_eg_web_page('conify/global/config/sms_carrier', null, event); }
1028 'cmd_server_admin_z39_source' : [
1030 function(event) { open_eg_web_page('conify/global/config/z3950_source', null, event); }
1032 'cmd_server_admin_org_unit_proximity_adjustment' : [
1034 function(event) { open_eg_web_page('conify/global/config/org_unit_proximity_adjustment', null, event); }
1036 'cmd_server_admin_z39_index_field_map' : [
1038 function(event) { open_eg_web_page('conify/global/config/z3950_index_field_map', null, event); }
1040 'cmd_server_admin_circ_mod' : [
1042 function(event) { open_eg_web_page('conify/global/config/circ_modifier', null, event); }
1044 'cmd_server_admin_global_flag' : [
1046 function(event) { open_eg_web_page('conify/global/config/global_flag', null, event); }
1048 'cmd_server_admin_org_unit_setting_type' : [
1050 function(event) { open_eg_web_page('conify/global/config/org_unit_setting_type', null, event); }
1052 'cmd_server_admin_import_match_set' : [
1054 function(event) { open_eg_web_page('conify/global/vandelay/match_set', null, event); }
1056 'cmd_server_admin_usr_setting_type' : [
1058 function(event) { open_eg_web_page('conify/global/config/usr_setting_type', null, event); }
1060 'cmd_server_admin_authority_control_set': [
1062 function(event) { open_eg_web_page('conify/global/cat/authority/control_set', null, event); }
1064 'cmd_server_admin_authority_browse_axis': [
1066 function(event) { open_eg_web_page('conify/global/cat/authority/browse_axis', null, event); }
1068 'cmd_server_admin_authority_thesaurus': [
1070 function(event) { open_eg_web_page('conify/global/cat/authority/thesaurus', null, event); }
1072 'cmd_server_admin_booking_resource': [
1074 function(event) { open_eg_web_page('conify/global/booking/resource', null, event); }
1076 'cmd_server_admin_booking_resource_type': [
1078 function(event) { open_eg_web_page('conify/global/booking/resource_type', null, event); }
1080 'cmd_server_admin_booking_resource_attr': [
1082 function(event) { open_eg_web_page('conify/global/booking/resource_attr', null, event); }
1084 'cmd_server_admin_booking_resource_attr_value': [
1086 function(event) { open_eg_web_page('conify/global/booking/resource_attr_value', null, event); }
1088 'cmd_server_admin_booking_resource_attr_map': [
1090 function(event) { open_eg_web_page('conify/global/booking/resource_attr_map', null, event); }
1092 'cmd_local_admin_address_alert' : [
1094 function(event) { open_eg_web_page('conify/global/actor/address_alert', null, event); }
1096 'cmd_local_admin_copy_location_group' : [
1098 function(event) { open_eg_web_page('conify/global/asset/copy_location_group', null, event); }
1100 'cmd_local_admin_search_filter_group' : [
1102 function(event) { open_eg_web_page('conify/global/actor/search_filter_group', null, event); }
1104 'cmd_acq_create_invoice' : [
1106 function(event) { open_eg_web_page('acq/invoice/view?create=1', 'menu.cmd_acq_create_invoice.tab', event); }
1108 'cmd_acq_view_my_pl' : [
1110 function(event) { open_eg_web_page('acq/search/unified?ca=pl', 'menu.cmd_acq_unified_search.tab', event); }
1112 'cmd_acq_view_local_po' : [
1114 function(event) { open_eg_web_page('acq/search/unified?ca=po', 'menu.cmd_acq_unified_search.tab', event); }
1116 'cmd_acq_create_po' : [
1118 function(event) { open_eg_web_page('acq/po/create', 'menu.cmd_acq_po.tab', event); }
1120 'cmd_acq_view_local_inv' : [
1122 function(event) { open_eg_web_page('acq/search/unified?ca=inv', 'menu.cmd_acq_unified_search.tab', event); }
1124 'cmd_acq_user_requests' : [
1126 function(event) { open_eg_web_page('acq/picklist/user_request', 'menu.cmd_acq_user_requests.tab', event); }
1128 'cmd_acq_upload' : [
1130 function(event) { open_eg_web_page('acq/picklist/upload', 'menu.cmd_acq_upload.tab', event); }
1132 'cmd_acq_bib_search' : [
1134 function(event) { open_eg_web_page('acq/picklist/bib_search', 'menu.cmd_acq_bib_search.tab', event); }
1136 'cmd_acq_unified_search' : [
1138 function(event) { open_eg_web_page('acq/search/unified', 'menu.cmd_acq_unified_search.tab', event); }
1140 'cmd_acq_from_bib' : [
1142 function(event) { open_eg_web_page('acq/picklist/from_bib', 'menu.cmd_acq_from_bib.tab', event); }
1144 'cmd_acq_new_brief_record' : [
1146 function(event) { open_eg_web_page('acq/picklist/brief_record', 'menu.cmd_acq_new_brief_record.tab', event); }
1148 'cmd_acq_claim_eligible' : [
1150 function(event) { open_eg_web_page('acq/financial/claim_eligible', 'menu.cmd_acq_claim_eligible.tab', event); }
1152 'cmd_booking_reservation' : [
1156 "/eg/booking/reservation",
1157 "menu.cmd_booking_reservation.tab",
1162 'cmd_booking_pull_list' : [
1166 "/eg/booking/pull_list",
1167 "menu.cmd_booking_pull_list.tab",
1172 'cmd_booking_capture' : [
1176 "/eg/booking/capture",
1177 "menu.cmd_booking_capture.tab",
1182 'cmd_booking_reservation_pickup' : [
1186 "/eg/booking/pickup",
1187 "menu.cmd_booking_reservation_pickup.tab",
1192 'cmd_booking_reservation_return' : [
1196 "/eg/booking/return",
1197 "menu.cmd_booking_reservation_return.tab",
1202 'cmd_server_admin_conify_remote_account' : [
1206 "/eg/conify/global/config/remote_account",
1207 "menu.cmd_server_admin_conify_remote_account.tab",
1216 JSAN.use('util.print'); var print = new util.print();
1217 print.reprint_last();
1224 'cmd_retrieve_last_patron' : [
1227 obj.data.stash_retrieve();
1228 if (!obj.data.last_patron) {
1229 alert(offlineStrings.getString('menu.cmd_retrieve_last_patron.session.error'));
1232 var horizontal_interface = String( obj.data.hash.aous['ui.circ.patron_summary.horizontal'] ) == 'true';
1233 var url = obj.url_prefix( horizontal_interface ? 'XUL_PATRON_HORIZ_DISPLAY' : 'XUL_PATRON_DISPLAY' );
1234 obj.command_tab( event, url, {}, { 'id' : obj.data.last_patron } );
1238 'cmd_url_verify' : [
1242 "/eg/url_verify/sessions",
1243 "menu.cmd_url_verify.tab",
1246 'show_print_button': false,
1247 'show_nav_buttons': true
1253 'cmd_retrieve_last_record' : [
1256 obj.data.stash_retrieve();
1257 if (!obj.data.last_record) {
1258 alert(offlineStrings.getString('menu.cmd_retrieve_last_record.session.error'));
1261 var opac_url = obj.url_prefix('opac_rdetail') + obj.data.last_record;
1262 var content_params = {
1264 'authtime' : ses('authtime'),
1265 'opac_url' : opac_url,
1269 obj.url_prefix('XUL_OPAC_WRAPPER'),
1270 {'tab_name' : offlineStrings.getString('menu.cmd_retrieve_last_record.status')},
1276 'cmd_verify_credentials' : [
1281 obj.url_prefix('XUL_VERIFY_CREDENTIALS'),
1282 { 'tab_name' : offlineStrings.getString('menu.cmd_verify_credentials.tabname') },
1288 /* Cataloging Menu */
1289 'cmd_z39_50_import' : [
1292 obj.data.stash_retrieve();
1293 obj.command_tab(event,obj.url_prefix('XUL_Z3950_IMPORT'),{},{});
1296 'cmd_create_marc' : [
1299 obj.data.stash_retrieve();
1300 obj.command_tab(event,obj.url_prefix('XUL_MARC_NEW'),{},{});
1304 'cmd_authority_manage' : [
1308 urls.AUTHORITY_MANAGE,
1309 "menu.cmd_authority_manage.tab",
1315 'cmd_marc_batch_edit' : [
1320 obj.url_prefix('MARC_BATCH_EDIT'),{
1321 'tab_name' : offlineStrings.getString('menu.cmd_marc_batch_edit.tab')
1329 'cmd_change_session' : [
1333 obj.data.stash_retrieve();
1334 JSAN.use('util.network'); var network = new util.network();
1335 var temp_au = js2JSON( obj.data.list.au[0] );
1336 var temp_ses = js2JSON( obj.data.session );
1337 if (obj.data.list.au.length > 1) {
1338 obj.data.list.au = [ obj.data.list.au[1] ];
1339 obj.data.stash('list');
1340 network.reset_titlebars( obj.data );
1341 network.simple_request('AUTH_DELETE', [ obj.data.session.key ] );
1342 obj.data.session = obj.data.previous_session;
1343 obj.data.menu_perms = obj.data.previous_menu_perms;
1344 obj.data.stash('session');
1345 obj.data.stash('menu_perms');
1347 var ios = Components.classes["@mozilla.org/network/io-service;1"].getService(Components.interfaces.nsIIOService);
1348 var cookieUriSSL = ios.newURI("https://" + obj.data.server_unadorned, null, null);
1349 var cookieSvc = Components.classes["@mozilla.org/cookieService;1"].getService(Components.interfaces.nsICookieService);
1351 cookieSvc.setCookieString(cookieUriSSL, null, "ses="+obj.data.session.key + "; secure;", null);
1353 alert(offlineStrings.getFormattedString(main.session_cookie.error, [E]));
1356 if (network.get_new_session(offlineStrings.getString('menu.cmd_chg_session.label'),{'url_prefix':obj.url_prefix})) {
1357 obj.data.stash_retrieve();
1358 if (obj.data.session.is_perm === false) {
1359 obj.data.list.au[1] = JSON2js( temp_au );
1360 obj.data.stash('list');
1361 obj.data.previous_session = JSON2js( temp_ses );
1362 obj.data.previous_menu_perms = obj.data.menu_perms;
1363 obj.data.stash('previous_session');
1364 obj.data.stash('previous_menu_perms');
1366 var temp_session_object = JSON2js( temp_ses );
1367 network.simple_request('AUTH_DELETE', [ temp_session_object.key ] );
1369 obj.data.menu_perms = false;
1370 obj.data.stash('menu_perms');
1373 network.set_user_status();
1375 obj.error.standard_unexpected_error_alert('cmd_change_session',E);
1379 'cmd_manage_offline_xacts' : [
1382 obj.command_tab(event,obj.url_prefix('XUL_OFFLINE_MANAGE_XACTS'), {'tab_name' : offlineStrings.getString('menu.cmd_manage_offline_xacts.tab')}, {});
1385 'cmd_download_patrons' : [
1389 var x = new XMLHttpRequest();
1390 var url = 'http://' + XML_HTTP_SERVER + '/standalone/list.txt';
1391 x.open("GET",url,false);
1393 if (x.status == 200) {
1394 JSAN.use('util.file'); var file = new util.file('offline_patron_list');
1395 file.write_content('truncate',x.responseText);
1397 file = new util.file('offline_patron_list.date');
1398 file.write_content('truncate',new Date());
1400 alert(offlineStrings.getString('menu.cmd_download_patrons.complete.status'));
1402 alert(offlineStrings.getFormattedString('menu.cmd_download_patrons.error', [x.status, x.statusText]));
1405 obj.error.standard_unexpected_error_alert('cmd_download_patrons',E);
1409 'cmd_adv_user_edit' : [
1412 obj.data.stash_retrieve();
1413 obj.command_tab(event,obj.url_prefix('XUL_PATRON_BARCODE_ENTRY'), {}, { 'perm_editor' : true });
1416 'cmd_print_list_template_edit' : [
1419 obj.data.stash_retrieve();
1420 obj.command_tab(event,obj.url_prefix('XUL_PRINT_LIST_TEMPLATE_EDITOR'), {}, {});
1423 'cmd_stat_cat_edit' : [
1426 obj.data.stash_retrieve();
1427 obj.command_tab(event,obj.url_prefix('XUL_STAT_CAT_EDIT?ses=') + window.escape(ses()), {'tab_name' : offlineStrings.getString('menu.cmd_stat_cat_edit.tab')},{});
1430 'cmd_non_cat_type_edit' : [
1433 obj.data.stash_retrieve();
1434 obj.command_tab(event,obj.url_prefix('XUL_NON_CAT_LABEL_EDIT?ses=') + window.escape(ses()), {'tab_name' : offlineStrings.getString('menu.cmd_non_cat_type_edit.tab')},{});
1437 'cmd_copy_location_edit' : [
1440 obj.data.stash_retrieve();
1441 obj.command_tab(event,obj.url_prefix('XUL_COPY_LOCATION_EDIT?ses=') + window.escape(ses()),{'tab_name' : offlineStrings.getString('menu.cmd_copy_location_edit.tab')},{});
1447 obj.data.stash_retrieve();
1448 var content_params = { 'session' : ses(), 'authtime' : ses('authtime') };
1449 obj.command_tab(event,obj.url_prefix('XUL_OPAC_WRAPPER'), {}, content_params);
1455 obj.data.stash_retrieve();
1456 obj.command_tab(event,obj.url_prefix('TEST_HTML?ses=') + window.escape(ses()),{ 'browser' : true },{});
1462 obj.data.stash_retrieve();
1463 obj.command_tab(event,obj.url_prefix('TEST_XUL?ses=') + window.escape(ses()),{ 'browser' : false },{});
1469 obj.command_tab(event,obj.url_prefix('XUL_DEBUG_CONSOLE'),{'tab_name' : offlineStrings.getString('menu.cmd_console.tab')},{});
1475 obj.command_tab(event,obj.url_prefix('XUL_DEBUG_SHELL'),{'tab_name' : offlineStrings.getString('menu.cmd_shell.tab')},{});
1481 obj.command_tab(event,obj.url_prefix('XUL_DEBUG_XULEDITOR'),{'tab_name' : offlineStrings.getString('menu.cmd_xuleditor.tab')},{});
1484 'cmd_fieldmapper' : [
1487 obj.command_tab(event,obj.url_prefix('XUL_DEBUG_FIELDMAPPER'),{'tab_name' : offlineStrings.getString('menu.cmd_fieldmapper.tab')},{});
1490 'cmd_survey_wizard' : [
1493 obj.data.stash_retrieve();
1494 xulG.window.open(obj.url_prefix('XUL_SURVEY_WIZARD'),'survey_wizard','chrome');
1497 'cmd_public_opac' : [
1500 var loc = urls.XUL_BROWSER + '?url=' + window.escape(
1501 obj.url_prefix('remote')
1506 {'tab_name' : offlineStrings.getString('menu.cmd_public_opac.tab'), 'browser' : false},
1507 { 'no_xulG' : true, 'show_nav_buttons' : true, 'show_print_button' : true }
1511 'cmd_clear_cache' : [
1513 function clear_the_cache() {
1515 var cacheClass = Components.classes["@mozilla.org/network/cache-service;1"];
1516 var cacheService = cacheClass.getService(Components.interfaces.nsICacheService);
1517 cacheService.evictEntries(Components.interfaces.nsICache.STORE_ON_DISK);
1518 cacheService.evictEntries(Components.interfaces.nsICache.STORE_IN_MEMORY);
1520 dump(E+'\n');alert(E);
1524 'cmd_restore_all_tabs' : [
1527 var tabs = obj.controller.view.tabs;
1528 for (var i = 0; i < tabs.childNodes.length; i++) {
1529 tabs.childNodes[i].hidden = false;
1533 'cmd_extension_manager' : [
1536 obj.command_tab(event,'chrome://mozapps/content/extensions/extensions.xul?type=extensions',{'tab_name' : offlineStrings.getString('menu.cmd_extension_manager.tab')},{});
1539 'cmd_theme_manager' : [
1542 obj.command_tab(event,'chrome://mozapps/content/extensions/extensions.xul?type=themes',{'tab_name' : offlineStrings.getString('menu.cmd_theme_manager.tab')},{});
1545 'cmd_about_config' : [
1548 obj.command_tab(event,'chrome://global/content/config.xul',{'tab_name' : 'about:config'},{});
1551 'cmd_about_about' : [
1554 obj.command_tab(event,'chrome://global/content/aboutAbout.xhtml',{'tab_name' : 'about:about'},{});
1560 var confirm_string = offlineStrings.getString('menu.cmd_shutdown.prompt');
1561 obj.data.stash_retrieve();
1562 if (typeof obj.data.unsaved_data != 'undefined') {
1563 if (obj.data.unsaved_data > 0) {
1564 confirm_string = offlineStrings.getString('menu.shutdown.unsaved_data_warning');
1567 if (window.confirm(confirm_string)) {
1568 obj.data.unsaved_data = 0; // just in case the program doesn't close somehow
1569 obj.data.stash('unsaved_data');
1570 dump('forcing data.unsaved_data == ' + obj.data.unsaved_data + '\n');
1571 var windowManager = Components.classes["@mozilla.org/appshell/window-mediator;1"].getService();
1572 var windowManagerInterface = windowManager.QueryInterface(Components.interfaces.nsIWindowMediator);
1573 var enumerator = windowManagerInterface.getEnumerator(null);
1574 var w; // close all other windows
1575 while ( w = enumerator.getNext() ) {
1577 if (w.xulG) { w.close(); } // FIXME: kludge so we don't close Firefox windows as an extension. We should define a @windowtype for all the staff client windows and have the enumerator just pull those
1584 'cmd_hotkeys_toggle' : [
1587 // Easy enough, toggle disabled on the keyset
1588 var keyset = document.getElementById("menu_frame_keys");
1589 var disabled = (keyset.getAttribute("disabled") == "true") ? "false" : "true";
1590 if(disabled == "true")
1591 keyset.setAttribute("disabled", "true");
1593 keyset.removeAttribute("disabled");
1594 // Then find every menuitem/toolbarbutton for this command for a graphical hint
1595 var controls = document.getElementsByAttribute("command","cmd_hotkeys_toggle");
1596 for(var i = 0; i < controls.length; i++)
1597 controls[i].setAttribute("checked",disabled);
1600 'cmd_hotkeys_set' : [
1603 obj.set_menu_hotkeys(event.explicitOriginalTarget.getAttribute('value'));
1606 'cmd_hotkeys_setworkstation' : [
1609 xulG.pref.setCharPref('open-ils.menu.hotkeyset', obj.data.current_hotkeyset);
1612 'cmd_hotkeys_clearworkstation' : [
1615 if(xulG.pref.prefHasUserValue('open-ils.menu.hotkeyset'))
1616 xulG.pref.clearUserPref('open-ils.menu.hotkeyset');
1619 'cmd_toolbar_set' : [
1622 var newToolbar = event.explicitOriginalTarget.getAttribute('value');
1623 obj.render_toolbar(newToolbar);
1624 obj.toolbar = newToolbar;
1627 'cmd_toolbar_mode_set' : [
1630 var newMode = event.explicitOriginalTarget.getAttribute('value');
1631 var toolbox = document.getElementById('main_toolbox');
1632 var toolbars = toolbox.getElementsByTagName('toolbar');
1633 for(var i = 0; i < toolbars.length; i++)
1634 toolbars[i].setAttribute("mode",newMode);
1635 obj.toolbar_mode = newMode;
1638 'cmd_toolbar_size_set' : [
1641 var newSize = event.explicitOriginalTarget.getAttribute('value');
1642 var toolbox = document.getElementById('main_toolbox');
1643 var toolbars = toolbox.getElementsByTagName('toolbar');
1644 for(var i = 0; i < toolbars.length; i++)
1645 toolbars[i].setAttribute("iconsize",newSize);
1646 obj.toolbar_size = newSize;
1649 'cmd_toolbar_label_position_set' : [
1652 var altPosition = (event.explicitOriginalTarget.getAttribute('value') == "under");
1653 var toolbox = document.getElementById('main_toolbox');
1654 var toolbars = toolbox.getElementsByTagName('toolbar');
1655 for(var i = 0; i < toolbars.length; i++) {
1657 addCSSClass(toolbars[i], 'labelbelow');
1659 removeCSSClass(toolbars[i], 'labelbelow');
1661 obj.toolbar_labelpos = (altPosition ? "under" : "side");
1664 'cmd_toolbar_configure' : [
1667 var url = obj.url_prefix( 'XUL_TOOLBAR_CONFIG' );
1668 obj.command_tab(event,url,{},{});
1671 'cmd_toolbar_setworkstation' : [
1674 xulG.pref.setCharPref('open-ils.menu.toolbar', obj.toolbar);
1675 xulG.pref.setCharPref('open-ils.menu.toolbar.iconsize', obj.toolbar_size);
1676 xulG.pref.setCharPref('open-ils.menu.toolbar.mode', obj.toolbar_mode);
1677 xulG.pref.setBoolPref('open-ils.menu.toolbar.labelbelow', (obj.toolbar_labelpos == "under"));
1680 'cmd_toolbar_clearworkstation' : [
1683 if(xulG.pref.prefHasUserValue('open-ils.menu.toolbar'))
1684 xulG.pref.clearUserPref('open-ils.menu.toolbar');
1685 if(xulG.pref.prefHasUserValue('open-ils.menu.toolbar.iconsize'))
1686 xulG.pref.clearUserPref('open-ils.menu.toolbar.iconsize');
1687 if(xulG.pref.prefHasUserValue('open-ils.menu.toolbar.mode'))
1688 xulG.pref.clearUserPref('open-ils.menu.toolbar.mode');
1689 if(xulG.pref.prefHasUserValue('open-ils.menu.toolbar.labelbelow'))
1690 xulG.pref.clearUserPref('open-ils.menu.toolbar.labelbelow');
1693 'cmd_debug_venkman' : [
1697 xulG.window.win.start_debugger();
1703 'cmd_debug_inspector' : [
1707 xulG.window.win.start_inspector();
1713 'cmd_debug_chrome_list' : [
1717 xulG.window.win.start_chrome_list();
1723 'cmd_debug_chrome_shell' : [
1727 xulG.window.win.start_js_shell();
1733 'cmd_copy_editor_copy_location_first_toggle' : [
1736 var curvalue = xulG.pref.getBoolPref('oils.copy_editor.copy_location_name_first');
1737 xulG.pref.setBoolPref('oils.copy_editor.copy_location_name_first', !curvalue);
1740 'cmd_search_prefs' : [
1744 obj.set_tab(obj.url_prefix('XUL_SEARCH_PREFS'),{'tab_name' : offlineStrings.getString('menu.cmd_search_prefs.tab'), 'browser' : false});
1752 JSAN.use('util.controller');
1754 obj.controller = new util.controller();
1755 obj.controller.init( { 'window_knows_me_by' : 'g.menu.controller', 'control_map' : cmd_map } );
1757 obj.controller.view.tabbox = window.document.getElementById('main_tabbox');
1758 // Despite what the docs say:
1759 // The "tabs" element need not be the first child
1760 // The "panels" element need not be the second/last
1761 // Nor need they be the only ones there.
1762 // Thus, use the IDs for robustness.
1763 obj.controller.view.tabs = window.document.getElementById('main_tabs');
1764 obj.controller.view.panels = window.document.getElementById('main_panels');
1765 obj.controller.view.tabscroller = window.document.getElementById('main_tabs_scrollbox');
1767 obj.sort_menu(document.getElementById('main.menu.admin'), true);
1769 if(params['firstURL']) {
1770 obj.new_tab(params['firstURL'],{'focus':true},null);
1773 obj.new_tab(null,{'focus':true},null);
1777 'button_bar_init' : function() {
1782 JSAN.use('util.widgets');
1784 // populate the menu of available toolbars
1785 var x = document.getElementById('main.menu.admin.client.toolbars.current.popup');
1787 util.widgets.remove_children(x);
1789 function create_menuitem(label,value,checked) {
1790 var menuitem = document.createElement('menuitem');
1791 menuitem.setAttribute('name','current_toolbar');
1792 menuitem.setAttribute('type','radio');
1793 menuitem.setAttribute('label',label);
1794 menuitem.setAttribute('value',value);
1795 menuitem.setAttribute('command','cmd_toolbar_set');
1796 if (checked) menuitem.setAttribute('checked','true');
1802 offlineStrings.getString('staff.main.button_bar.none'),
1810 offlineStrings.getString('staff.main.button_bar.default'),
1816 for (var i = 0; i < this.data.list.atb.length; i++) {
1817 var def = this.data.list.atb[i];
1827 // Try workstation pref for button bar
1828 var button_bar = xulG.pref.getCharPref('open-ils.menu.toolbar');
1830 if (!button_bar) { // No workstation pref? Try org unit pref.
1831 if (obj.data.hash.aous['ui.general.button_bar']) {
1832 button_bar = String( obj.data.hash.aous['ui.general.button_bar'] );
1837 this.render_toolbar(button_bar);
1838 this.toolbar = button_bar;
1841 // Check for alternate Size pref
1842 var toolbar_size = xulG.pref.getCharPref('open-ils.menu.toolbar.iconsize');
1843 if(toolbar_size) this.toolbar_size = toolbar_size;
1844 // Check for alternate Mode pref
1845 var toolbar_mode = xulG.pref.getCharPref('open-ils.menu.toolbar.mode');
1846 if(toolbar_mode) this.toolbar_mode = toolbar_mode;
1847 // Check for alternate Label Position pref
1848 var toolbar_labelpos = xulG.pref.getBoolPref('open-ils.menu.toolbar.labelbelow');
1849 if(toolbar_labelpos) this.toolbar_labelpos = toolbar_labelpos;
1851 if(button_bar || toolbar_size || toolbar_mode || toolbar_labelpos) {
1852 var toolbar = document.getElementById('toolbar_main');
1853 if(toolbar_mode) toolbar.setAttribute('mode', toolbar_mode);
1854 if(toolbar_size) toolbar.setAttribute('iconsize', toolbar_size);
1855 if(toolbar_labelpos) addCSSClass(toolbar, 'labelbelow');
1859 var x = document.getElementById('main.menu.admin.client.toolbars.current.popup');
1861 var selectitems = x.getElementsByAttribute('value',button_bar);
1862 if(selectitems.length < 1) selecteditems = x.getElementsByAttribute('value','default');
1863 if(selectitems.length > 0) selectitems[0].setAttribute('checked','true');
1868 var x = document.getElementById('main.menu.admin.client.toolbars.size.popup');
1870 var selectitems = x.getElementsByAttribute('value',toolbar_size);
1871 if(selectitems.length > 0) selectitems[0].setAttribute('checked','true');
1876 var x = document.getElementById('main.menu.admin.client.toolbars.mode.popup');
1878 var selectitems = x.getElementsByAttribute('value',toolbar_mode);
1879 if(selectitems.length > 0) selectitems[0].setAttribute('checked','true');
1883 if(toolbar_labelpos) {
1884 var x = document.getElementById('main.menu.admin.client.toolbars.label_position.popup');
1886 var selectitems = x.getElementsByAttribute('value',"under");
1887 if(selectitems.length > 0) selectitems[0].setAttribute('checked','true');
1891 // stash the available toolbar buttons for later use in the toolbar editing interface
1892 if (typeof this.data.toolbar_buttons == 'undefined') {
1893 this.data.toolbar_buttons = {};
1894 var nl = $('palette').childNodes;
1895 for (var i = 0; i < nl.length; i++) {
1896 var id = nl[i].getAttribute('templateid');
1897 var label = nl[i].getAttribute('label');
1899 this.data.toolbar_buttons[ id ] = label;
1902 this.data.stash('toolbar_buttons');
1906 alert('Error in menu.js, button_bar_init(): ' + E);
1910 'spawn_search' : function(s) {
1912 obj.error.sdump('D_TRACE', offlineStrings.getFormattedString('menu.spawn_search.msg', [js2JSON(s)]) );
1913 obj.new_patron_tab( {}, { 'doit' : 1, 'query' : js2JSON(s) } );
1916 'close_all_tabs' : function() {
1919 var count = obj.controller.view.tabs.childNodes.length;
1920 for (var i = 1; i < count; i++) obj.close_tab();
1921 setTimeout( function(){ obj.controller.view.tabs.firstChild.focus(); }, 0);
1923 obj.error.standard_unexpected_error_alert(offlineStrings.getString('menu.close_all_tabs.error'),E);
1927 'close_tab' : function (specific_idx) {
1928 var idx = specific_idx || this.controller.view.tabs.selectedIndex;
1929 var panel = this.controller.view.panels.childNodes[ idx ];
1931 var tab = this.controller.view.tabs.getItemAtIndex( idx );
1932 var id = tab.getAttribute('id');
1933 if (typeof this.tab_semaphores[id] != 'undefined') {
1934 if (this.tab_semaphores[id] > 0) {
1935 var confirmation = window.confirm(offlineStrings.getString('menu.close_tab.unsaved_data_warning'));
1936 if (!confirmation) { return; }
1937 oils_unsaved_data_P( this.tab_semaphores[id] );
1939 delete this.tab_semaphores[id];
1942 this.controller.view.tabs.removeItemAt(idx);
1943 this.controller.view.panels.removeChild(panel);
1944 if(this.controller.view.tabs.childNodes.length > idx) {
1945 this.controller.view.tabbox.selectedIndex = idx;
1948 this.controller.view.tabbox.selectedIndex = idx - 1;
1950 this.controller.view.tabscroller.ensureElementIsVisible(this.controller.view.tabs.selectedItem);
1951 this.update_all_tab_names();
1952 // Make sure we keep at least one tab open.
1953 if(this.controller.view.tabs.childNodes.length == 1) {
1958 'update_all_tab_names' : function() {
1959 var doAccessKeys = !xulG.pref.getBoolPref('open-ils.disable_accesskeys_on_tabs');
1960 for(var i = 1; i < this.controller.view.tabs.childNodes.length; ++i) {
1961 var tab = this.controller.view.tabs.childNodes[i];
1963 tab.label = i + ' ' + tab.origlabel;
1964 if(doAccessKeys && offlineStrings.testString('menu.tab' + i + '.accesskey')) {
1965 tab.accessKey = offlineStrings.getString('menu.tab' + i + '.accesskey');
1970 'command_tab' : function(event,url,params,content_params) {
1972 var myEvent = event;
1973 if(event && event.sourceEvent) myEvent = event.sourceEvent;
1974 // Note: The last event is not supposed to be myEvent in this if.
1975 if(myEvent && myEvent.explicitOriginalTarget.nodeName.match(/toolbarbutton/) && myEvent.explicitOriginalTarget.command == event.originalTarget.id) {
1976 var value = xulG.pref.getIntPref('ui.key.accelKey');
1979 newTab = myEvent.ctrlKey;
1982 newTab = myEvent.altKey;
1985 newTab = myEvent.metaKey;
1989 if(xulG.pref.getBoolPref('open-ils.toolbar.defaultnewtab')) {
1997 this.new_tab(url,params,content_params);
2000 this.set_tab(url,params,content_params);
2004 'new_tab' : function(url,params,content_params) {
2008 var max_tabs = xulG.pref.getIntPref('open-ils.window_max_tabs') || max_tabs;
2011 if(max_tabs > 0 && this.controller.view.tabs.childNodes.length > max_tabs) return false;
2012 var tab = this.w.document.createElement('tab');
2013 var panel = this.w.document.createElement('tabpanel');
2014 var tabscroller = this.controller.view.tabscroller;
2015 this.controller.view.tabs.appendChild(tab);
2016 this.controller.view.panels.appendChild(panel);
2017 tab.curindex = this.controller.view.tabs.childNodes.length - 1;
2018 if(!xulG.pref.getBoolPref('open-ils.disable_accesskeys_on_tabs')) {
2019 if(offlineStrings.testString('menu.tab' + tab.curindex + '.accesskey')) {
2020 tab.accessKey = offlineStrings.getString('menu.tab' + tab.curindex + '.accesskey');
2023 var tabs = this.controller.view.tabs;
2024 tab.addEventListener(
2028 tabscroller.ensureElementIsVisible(tab);
2031 && ( panel.firstChild.nodeName == 'iframe' || panel.firstChild.nodeName == 'browser' )
2032 && panel.firstChild.contentWindow
2034 var cw = panel.firstChild.contentWindow;
2036 'protocol' : cw.location.protocol,
2037 'hostname' : cw.location.hostname,
2038 'port' : cw.location.port,
2039 'pathname' : cw.location.pathname,
2042 obj.set_help_context(help_params);
2043 if (typeof cw.default_focus == 'function') {
2048 obj.error.sdump('D_ERROR','init_tab_focus_handler: ' + js2JSON(E));
2054 if (!content_params) content_params = {};
2055 if (!params) params = {};
2056 if (!params.tab_name) params.tab_name = offlineStrings.getString('menu.new_tab.tab');
2057 if (!params.nofocus) params.focus = true; /* make focus the default */
2060 this.controller.view.tabs.selectedItem = tab;
2061 tabscroller.ensureElementIsVisible(tab);
2063 params.index = tab.curindex;
2064 this.set_tab(url,params,content_params);
2067 this.error.sdump('D_ERROR',E);
2072 'set_menu_access' : function(perms) {
2073 if(perms === false) return;
2074 var commands = document.getElementById('universal_cmds').getElementsByTagName('command');
2077 for (var i = 0; i < commands.length; i++) {
2078 if (commands[i].hasAttribute('perm')) {
2079 commandperms = commands[i].getAttribute('perm').split(' ');
2080 for (var j = 0; j < commandperms.length; j++) {
2081 if (perms[commandperms[j]]) {
2082 commands[i].setAttribute('disabled','false');
2086 commands[i].setAttribute('disabled','true');
2092 'set_menu_hotkeys' : function(hotkeyset) {
2093 this.data.stash_retrieve();
2095 var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"].
2096 getService(Components.interfaces.nsIWindowMediator);
2097 var mainwin = wm.getMostRecentWindow('eg_main');
2098 JSAN.use('util.network');
2099 var network = new util.network();
2101 if(hotkeyset) { // Explicit request
2103 this.data.current_hotkeyset = hotkeyset;
2104 this.data.stash('current_hotkeyset');
2105 // Then iterate over windows
2106 var windowManager = Components.classes["@mozilla.org/appshell/window-mediator;1"].getService();
2107 var windowManagerInterface = windowManager.QueryInterface(Components.interfaces.nsIWindowMediator);
2108 var enumerator = windowManagerInterface.getEnumerator('eg_menu');
2111 while ( w = enumerator.getNext() ) {
2113 w.g.menu.set_menu_hotkeys();
2116 else { // Non-explicit request?
2117 if(this.data.current_hotkeyset) // Previous hotkeyset?
2118 hotkeyset = this.data.current_hotkeyset; // Use it
2119 else { // No previous? We need to decide on one!
2120 // Load the list so we know if what we are being asked to load is valid.
2121 var hotkeysets = mainwin.load_hotkey_sets();
2122 if(!hotkeysets) return; // No sets = nothing to load. Which is probably an error, but meh.
2123 hotkeysets.has = function(test) {
2124 for(i = 0; i < this.length; i++) {
2125 if(this[i] == test) return true;
2129 // Try workstation (pref)
2130 hotkeyset = xulG.pref.getCharPref('open-ils.menu.hotkeyset');
2132 // Nothing or nothing valid?
2133 if(!hotkeyset || !hotkeysets.has(hotkeyset)) {
2134 hotkeyset = this.data.hash.aous['ui.general.hotkeyset'];
2136 // STILL nothing? Try Default.
2137 if(!hotkeyset || !hotkeysets.has(hotkeyset)) {
2138 if(hotkeysets.has('Default'))
2139 hotkeyset = 'Default';
2143 // And save whatever we are using.
2144 this.data.current_hotkeyset = hotkeyset;
2145 this.data.stash('current_hotkeyset');
2148 // Clear out all the old hotkeys
2149 var keyset = document.getElementById('menu_frame_keys');
2150 var main_menu = document.getElementById('main_menubar');
2151 if(keyset.hasChildNodes()) {
2152 var menuitems = main_menu.getElementsByAttribute('key','*');
2153 while(menuitems.length > 0) {
2154 var menuitem = menuitems[0];
2155 menuitem.removeAttribute('key');
2156 // Trick/force mozilla to re-evaluate the menuitem
2157 // If you want to take this trick for use *anywhere* in *any* project, regardless of licensing, please do
2158 // Because it was a PITA to figure out
2159 menuitem.style.display = 'none'; // Hide the item to force menu to clear spot
2160 menuitem.setAttribute('acceltext', ''); // Set acceltext to blank string outright
2161 menuitem.removeAttribute('acceltext'); // Remove acceltext to clear out hotkey hint text
2162 menuitem.parentNode.openPopupAtScreen(0,0,false); // Tell menupopup to redraw itself
2163 menuitem.parentNode.hidePopup(); // And then make it go away right away.
2164 menuitem.style.removeProperty('display'); // Restore normal css display
2166 while(keyset.hasChildNodes()) keyset.removeChild(keyset.childNodes[0]);
2168 keyset_lines = mainwin.get_hotkey_array(hotkeyset);
2169 // Next, fill the keyset
2170 for(var line = 0; line < keyset_lines.length; line++) {
2171 // Create and populate our <key>
2172 var key_node = document.createElement('key');
2173 key_node.setAttribute('id',keyset_lines[line][0] + "_key");
2174 key_node.setAttribute('command',keyset_lines[line][0]);
2175 key_node.setAttribute('modifiers',keyset_lines[line][1]);
2176 // If keycode starts with VK_ we assume it is a key code.
2177 // Key codes go in the keycode attribute
2178 // Regular keys (like "i") go in the key attribute
2179 if(keyset_lines[line][2].match(/^VK_/))
2180 key_node.setAttribute('keycode',keyset_lines[line][2]);
2182 key_node.setAttribute('key',keyset_lines[line][2]);
2183 // If a fourth option was specified, set keytext to it.
2184 if(keyset_lines[line][3])
2185 key_node.setAttribute('keytext',keyset_lines[line][3]);
2186 // Add the new node to the DOM
2187 keyset.appendChild(key_node);
2188 // And populate all the menu items that should now display it
2189 var menuitems = main_menu.getElementsByAttribute('command',keyset_lines[line][0]);
2190 for(var i = 0; i < menuitems.length; i++) {
2191 menuitems[i].setAttribute('key', keyset_lines[line][0] + "_key");
2192 // Trick/force mozilla to re-evaluate the menuitem
2193 menuitems[i].style.display = 'none'; // Hide the item to force menu to clear spot
2194 menuitems[i].parentNode.openPopupAtScreen(0,0,false); // Tell menupopup to redraw itself
2195 menuitems[i].parentNode.hidePopup(); // And then make it go away right away
2196 menuitems[i].style.removeProperty('display'); // Restore normal css display
2199 // Force reload of keyset cache?
2200 keyset.parentNode.insertBefore(keyset, keyset.nextSibling);
2201 // If no keys, disable ability to toggle hotkeys (because why bother?)
2202 var x = document.getElementById('cmd_hotkeys_toggle');
2204 if(keyset.hasChildNodes())
2205 x.removeAttribute('disabled');
2207 x.setAttribute('disabled', 'true');
2209 // Select the hotkey set in the menu
2210 // This ensures that first window load OR remote window update shows properly
2211 var hotkeylist = document.getElementById('main.menu.admin.client.hotkeys.current.popup');
2212 var selectitems = hotkeylist.getElementsByAttribute('value',hotkeyset);
2213 if(selectitems.length > 0) selectitems[0].setAttribute('checked','true');
2217 'node' : document.getElementById('page_progress'),
2219 document.getElementById('page_progress').setAttribute('mode','undetermined');
2221 'off' : function() {
2222 document.getElementById('page_progress').setAttribute('mode','determined');
2224 'tooltip' : function(text) {
2225 if (text || text == '') {
2226 document.getElementById('page_progress').setAttribute('tooltiptext',text);
2228 return document.getElementById('page_progress').getAttribute('tooltiptext');
2233 'inc' : function(app,method) {
2235 var m = document.getElementById('network_progress');
2236 var count = 1 + Number( m.getAttribute('count') );
2237 m.setAttribute('mode','undetermined');
2238 m.setAttribute('count', count);
2239 var rows = document.getElementById('network_progress_rows');
2240 var row = document.getElementById('network_progress_tip_'+app+'_'+method);
2242 row = document.createElement('row'); row.setAttribute('id','network_progress_tip_'+app+'_'+method);
2243 var a = document.createElement('label'); a.setAttribute('value','App:');
2244 var b = document.createElement('label'); b.setAttribute('value',app);
2245 var c = document.createElement('label'); c.setAttribute('value','Method:');
2246 var d = document.createElement('label'); d.setAttribute('value',method);
2247 var e = document.createElement('label'); e.setAttribute('value','Total:');
2248 var f = document.createElement('label'); f.setAttribute('value','0');
2249 f.setAttribute('id','network_progress_tip_total_'+app+'_'+method);
2250 var g = document.createElement('label'); g.setAttribute('value','Outstanding:');
2251 var h = document.createElement('label'); h.setAttribute('value','0');
2252 h.setAttribute('id','network_progress_tip_out_'+app+'_'+method);
2253 row.appendChild(a); row.appendChild(b); row.appendChild(c);
2254 row.appendChild(d); row.appendChild(e); row.appendChild(f);
2255 row.appendChild(g); row.appendChild(h); rows.appendChild(row);
2257 var total = document.getElementById('network_progress_tip_total_'+app+'_'+method);
2259 total.setAttribute('value', 1 + Number( total.getAttribute('value') ));
2261 var out = document.getElementById('network_progress_tip_out_'+app+'_'+method);
2263 out.setAttribute('value', 1 + Number( out.getAttribute('value') ));
2266 dump('network_meter.inc(): ' + E + '\n');
2269 'dec' : function(app,method) {
2271 var m = document.getElementById('network_progress');
2272 var count = -1 + Number( m.getAttribute('count') );
2273 if (count < 0) count = 0;
2274 if (count == 0) m.setAttribute('mode','determined');
2275 m.setAttribute('count', count);
2276 var out = document.getElementById('network_progress_tip_out_'+app+'_'+method);
2278 out.setAttribute('value', -1 + Number( out.getAttribute('value') ));
2281 dump('network_meter.dec(): ' + E + '\n');
2285 'set_patron_tab' : function(params,content_params,event) {
2287 var horizontal_interface = String( obj.data.hash.aous['ui.circ.patron_summary.horizontal'] ) == 'true';
2288 var url = obj.url_prefix( horizontal_interface ? 'XUL_PATRON_HORIZ_DISPLAY' : 'XUL_PATRON_DISPLAY' );
2289 obj.command_tab(event,url,params ? params : {},content_params ? content_params : {});
2291 'new_patron_tab' : function(params,content_params) {
2293 var horizontal_interface = String( obj.data.hash.aous['ui.circ.patron_summary.horizontal'] ) == 'true';
2294 var url = obj.url_prefix( horizontal_interface ? 'XUL_PATRON_HORIZ_DISPLAY' : 'XUL_PATRON_DISPLAY' );
2295 obj.new_tab(url,params ? params : {},content_params ? content_params : {});
2297 'volume_item_creator' : function(params) {
2300 var unified_interface = String( obj.data.hash.aous['ui.unified_volume_copy_editor'] ) == 'true';
2301 if (unified_interface) {
2302 var horizontal_interface = String( obj.data.hash.aous['ui.cat.volume_copy_editor.horizontal'] ) == 'true';
2303 url = obj.url_prefix( horizontal_interface ? 'XUL_VOLUME_COPY_CREATOR_HORIZONTAL' : 'XUL_VOLUME_COPY_CREATOR' );
2305 url = obj.url_prefix('XUL_VOLUME_COPY_CREATOR_ORIGINAL');
2307 var w = obj.new_tab(
2309 { 'tab_name' : document.getElementById('offlineStrings').getString('staff.cat.create_or_rebarcode_items') },
2313 'holdings_maintenance_tab' : function(docid,params,content_params) {
2315 if (!content_params) {
2316 content_params = {};
2319 content_params['docid'] = docid;
2321 var url = obj.url_prefix('XUL_COPY_VOLUME_BROWSE');
2322 obj.new_tab(url,params || {}, content_params);
2324 'get_new_session' : function(params) {
2326 if (!params) { params = {}; }
2327 JSAN.use('util.network'); var net = new util.network();
2328 var result = net.get_new_session(null,{'url_prefix':obj.url_prefix},!params.operator_change);
2329 if (typeof params.callback == 'function') {
2330 return params.callback( result, ses(), ses('authtime') );
2334 'set_help_context' : function(params) {
2336 if (!params) { params = {}; }
2337 if (params.protocol == 'chrome:') { return; } /* not supported */
2338 var help_btn = document.getElementById('help_btn');
2340 dump('set_help_context: ' + js2JSON(params) + '\n');
2341 if (params.protocol) { help_btn.setAttribute('protocol', params.protocol); }
2342 if (params.hostname) { help_btn.setAttribute('hostname', params.hostname); }
2343 if (params.port) { help_btn.setAttribute('port', params.port); }
2344 if (params.pathname) { help_btn.setAttribute('pathname', params.pathname); }
2345 if (params.src) { help_btn.setAttribute('src', params.src); }
2349 'tab_semaphores' : {},
2351 'set_tab' : function(url,params,content_params) {
2353 if (!url) url = 'oils://remote/xul/server/';
2354 if (!url.match(/:\/\//) && !url.match(/^data:/)) url = urls.remote + url;
2355 if (!params) params = {};
2356 if (!content_params) content_params = {};
2357 var idx = this.controller.view.tabs.selectedIndex;
2358 if (params && typeof params.index != 'undefined') idx = params.index;
2359 var tab = this.controller.view.tabs.childNodes[ idx ];
2361 var id = tab.getAttribute('id');
2363 if (typeof obj.tab_semaphores[id] != 'undefined') {
2364 if (obj.tab_semaphores[id] > 0) {
2365 var confirmation = window.confirm(offlineStrings.getString('menu.replace_tab.unsaved_data_warning'));
2366 if (!confirmation) { return; }
2367 oils_unsaved_data_P( obj.tab_semaphores[id] );
2369 delete obj.tab_semaphores[id];
2372 var unique_id = idx + ':' + new Date();
2373 tab.setAttribute('id',unique_id);
2374 if (params.focus) tab.focus();
2375 var panel = this.controller.view.panels.childNodes[ idx ];
2376 while ( panel.lastChild ) panel.removeChild( panel.lastChild );
2378 content_params.is_tab_locked = function() {
2379 dump('is_tab_locked\n');
2380 var id = tab.getAttribute('id');
2381 if (typeof obj.tab_semaphores[id] == 'undefined') {
2384 return obj.tab_semaphores[id] > 0;
2386 content_params.lock_tab = function() {
2388 var id = tab.getAttribute('id');
2389 if (typeof obj.tab_semaphores[id] == 'undefined') {
2390 obj.tab_semaphores[id] = 0;
2392 obj.tab_semaphores[id]++;
2393 oils_unsaved_data_V();
2394 return obj.tab_semaphores[id];
2396 content_params.unlock_tab = function() {
2397 dump('unlock_tab\n');
2398 var id = tab.getAttribute('id');
2399 if (typeof obj.tab_semaphores[id] == 'undefined') {
2400 obj.tab_semaphores[id] = 0;
2402 obj.tab_semaphores[id]--;
2403 if (obj.tab_semaphores[id] < 0) { obj.tab_semaphores[id] = 0; }
2404 oils_unsaved_data_P();
2405 return obj.tab_semaphores[id];
2407 content_params.inspect_tab = function() {
2408 var id = tab.getAttribute('id');
2409 return 'id = ' + id + ' semaphore = ' + obj.tab_semaphores[id];
2411 content_params.new_tab = function(a,b,c) { return obj.new_tab(a,b,c); };
2412 content_params.set_tab = function(a,b,c) { return obj.set_tab(a,b,c); };
2413 content_params.open_external = function(a) { return obj.open_external(a); };
2414 content_params.close_tab = function() { return obj.close_tab(); };
2415 content_params.new_patron_tab = function(a,b) { return obj.new_patron_tab(a,b); };
2416 content_params.set_patron_tab = function(a,b) { return obj.set_patron_tab(a,b); };
2417 content_params.volume_item_creator = function(a) { return obj.volume_item_creator(a); };
2418 content_params.get_new_session = function(a) { return obj.get_new_session(a); };
2419 content_params.holdings_maintenance_tab = function(a,b,c) { return obj.holdings_maintenance_tab(a,b,c); };
2420 content_params.set_tab_name = function(name) { tab.label = tab.curindex + ' ' + name; tab.origlabel = name; };
2421 content_params.set_help_context = function(params) { return obj.set_help_context(params); };
2422 content_params.open_chrome_window = function(a,b,c) { return xulG.window.open(a,b,c); };
2423 content_params.url_prefix = function(url,secure) { return obj.url_prefix(url,secure); };
2424 content_params.network_meter = obj.network_meter;
2425 content_params.page_meter = obj.page_meter;
2426 content_params.get_barcode = obj.get_barcode;
2427 content_params.get_barcode_and_settings = obj.get_barcode_and_settings;
2428 content_params.render_toolbar_layout = function(layout) { return obj.render_toolbar_layout(layout); };
2429 content_params.set_statusbar = function(slot,text,tooltiptext,click_handler) {
2430 var e = document.getElementById('statusbarpanel'+slot);
2432 var p = e.parentNode;
2433 var sbp = document.createElement('statusbarpanel');
2434 sbp.setAttribute('id','statusbarpanel'+slot);
2435 p.replaceChild(sbp,e); // destroy and replace the statusbarpanel as a poor man's way of clearing event handlers
2437 sbp.setAttribute('label',text);
2439 sbp.setAttribute('tooltiptext',tooltiptext);
2441 if (click_handler) {
2442 sbp.addEventListener(
2450 content_params.chrome_xulG = xulG;
2451 content_params._data = xulG._data;
2452 if (params && params.tab_name) content_params.set_tab_name( params.tab_name );
2456 if (typeof params.browser == 'undefined') params.browser = false;
2457 if (params.browser) {
2459 frame = this.w.document.createElement('browser');
2460 frame.setAttribute('flex','1');
2461 frame.setAttribute('type','content');
2462 frame.setAttribute('autoscroll','false');
2463 frame.setAttribute('id','frame_'+obj.id_incr);
2464 panel.appendChild(frame);
2466 dump('creating browser with src = ' + url + '\n');
2467 JSAN.use('util.browser');
2468 var b = new util.browser();
2473 'alt_print' : false,
2474 'browser_id' : 'frame_'+obj.id_incr,
2475 'passthru_content_params' : content_params,
2482 frame = this.w.document.createElement('iframe');
2483 frame.setAttribute('flex','1');
2484 panel.appendChild(frame);
2485 dump('creating iframe with src = ' + url + '\n');
2486 frame.setAttribute('src',url);
2488 var cw = frame.contentWindow;
2489 if (typeof cw.wrappedJSObject != 'undefined') cw = cw.wrappedJSObject;
2491 cw.xulG = content_params;
2492 cw.addEventListener(
2496 if (typeof cw.help_context_set_locally == 'undefined') {
2498 'protocol' : cw.location.protocol,
2499 'hostname' : cw.location.hostname,
2500 'port' : cw.location.port,
2501 'pathname' : cw.location.pathname,
2504 obj.set_help_context(help_params);
2505 } else if (typeof cw.default_focus == 'function') {
2509 obj.error.sdump('D_ERROR', 'main.menu, set_tab, onload: ' + E);
2512 if (typeof params.on_tab_load == 'function') {
2513 params.on_tab_load(cw);
2516 obj.error.sdump('D_ERROR', 'main.menu, set_tab, onload #2: ' + E);
2522 this.error.sdump('D_ERROR', 'main.menu: ' + E);
2526 this.error.sdump('D_ERROR', 'main.menu:2: ' + E);
2527 alert(offlineStrings.getString('menu.set_tab.error'));
2533 'open_external' : function(url) {
2534 // first construct an nsIURI object using the ioservice
2535 var ioservice = Components.classes["@mozilla.org/network/io-service;1"]
2536 .getService(Components.interfaces.nsIIOService);
2538 var uriToOpen = ioservice.newURI(url, null, null);
2540 var extps = Components.classes["@mozilla.org/uriloader/external-protocol-service;1"]
2541 .getService(Components.interfaces.nsIExternalProtocolService);
2544 extps.loadURI(uriToOpen, null);
2547 'get_barcode' : function(window, context, barcode) {
2548 JSAN.use('util.network');
2549 JSAN.use('util.sound');
2551 // Depending on where we were called from data can be found in multiple ways
2553 if(this.data) data = this.data;
2554 else if(xulG.data) data = xulG.data;
2556 JSAN.use('util.data');
2557 data = new util.data();
2559 data.stash_retrieve();
2561 var network = new util.network();
2562 var sound = new util.sound();
2564 // Should return an array. Or an error.
2565 var r = network.simple_request('GET_BARCODES', [ ses(), data.list.au[0].ws_ou(), context, barcode ]);
2570 // Top-level error, likely means bad session or no STAFF_LOGIN permission.
2571 if(typeof r.ilsevent != 'undefined') {
2572 // Hand it off to the caller.
2576 // No results? Return false
2577 if(r.length == 0) return false;
2581 // Return it. If it is an error the caller should deal with it.
2585 // At this point we have more than one result.
2586 // Check to see what we got.
2587 var result_filter = {};
2589 var unique_count = 0;
2590 var found_errors = false;
2594 // Check each result.
2595 for(var i = 0; i < len; ++i) {
2596 // If it is an error
2597 if(typeof r[i].ilsevent != 'undefined') {
2598 // Make note that we found errors
2599 found_errors = true;
2600 // Grab the error into a string
2601 errors += js2JSON(r[i]);
2604 // Otherwise, record the type/id combo for later
2605 var type = r[i].type;
2607 var barcode = r[i].barcode;
2608 if(!result_filter[type]) result_filter[type] = {};
2609 if(!result_filter[type][id]) {
2611 result_filter[type][id] = [];
2613 result_filter[type][id].push(barcode);
2618 // Only errors? Return the first one.
2619 if(unique_count == 0 && found_errors == true) {
2623 // No errors, one (unique) result? Return it.
2624 if(unique_count == 1 && found_errors == false) return valid_r[0];
2626 // For possible debugging, dump the errors.
2627 if(found_errors) dump(errors);
2629 // Still here? Must need to have the user pick.
2630 if(!xulG.url_prefix) xulG.url_prefix = url_prefix; // Make util.window happy
2631 JSAN.use('util.window');
2632 var win = new util.window();
2633 var url = url_prefix('XUL_FANCY_PROMPT');
2634 var title = offlineStrings.getString('barcode_choice.title');
2635 var xml = '<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" xmlns:html="http://www.w3.org/1999/xhtml" flex="1">';
2636 xml += '<groupbox flex="1" style="overflow: auto; border: solid thin;"><caption label="' + title + '"/>';
2637 xml += '<description style="-moz-user-select: text; -moz-user-focus: normal; font-size: large">' + offlineStrings.getString('barcode_choice.prompt') + '</description>';
2638 if(found_errors) // Let the user know that one or more possible answers errored out.
2639 xml += '<description style="-moz-user=select: text; -moz-user-focus: normal; font-size: large">' + offlineStrings.getString('barcode_choice.errors_found') + '</description>';
2640 xml += '</groupbox><groupbox><caption label="' + offlineStrings.getString('barcode_choice.choice_label') + '"/><vbox>';
2642 len = valid_r.length;
2643 // Look at all the non-error answers we got
2644 for(var i = 0; i < len; ++i) {
2645 // If we still have a filtered answer, display a button.
2646 if(result_filter[valid_r[i].type][valid_r[i].id]) {
2647 var result_data = false;
2648 var barcodes = result_filter[valid_r[i].type][valid_r[i].id];
2649 var barcodes_assembled = barcodes.shift();
2650 var button_label = '';
2651 while(barcodes.length > 0) // Join any secondary barcodes found together
2652 barcodes_assembled = offlineStrings.getFormattedString('barcode_choice.join_barcodes', [barcodes_assembled, barcodes.shift()]);
2655 result_data = network.simple_request('BLOB_AU_PARTS_RETRIEVE',
2656 [ ses() , valid_r[i].id, ['family_name', 'first_given_name', 'second_given_name', 'home_ou' ] ]);
2657 button_label = offlineStrings.getFormattedString('barcode_choice.actor',
2658 [barcodes_assembled, result_data[0], result_data[1] + (result_data[2] ? ' ' + result_data[2] : ''), data.hash.aou[ result_data[3] ].name(), data.hash.aou[ result_data[3] ].shortname()]);
2661 result_data = network.simple_request('FM_ACP_DETAILS_VIA_BARCODE', [ ses(), valid_r[i].barcode ]);
2662 // Note: This falls through intentionally.
2665 if(!result_data) // If we fell through this should be set already.
2666 result_data = network.simple_request('FM_ACP_DETAILS', [ ses(), valid_r[i].id ]);
2667 button_label = offlineStrings.getFormattedString('barcode_choice.asset',
2668 [barcodes_assembled, result_data.mvr.title(), data.hash.aou[ result_data.copy.circ_lib() ].name(), data.hash.aou[ result_data.copy.circ_lib() ].shortname()]);
2671 r[i].data = result_data;
2673 // This ensures we only show each unique id once
2674 delete result_filter[valid_r[i].type][valid_r[i].id];
2676 // If we have more than one context this should label each entry with where it came from
2677 // Likely most useful for distinguishing assets from bookings
2678 if(context != valid_r[i].type && offlineStrings.testString('barcode_choice.' + valid_r[i].type + '_label'))
2679 button_label = offlineStrings.getFormattedString('barcode_choice.' + valid_r[i].type + '_label', [button_label]);
2681 xml += '<button label="' + button_label.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"') + '" name="fancy_submit" value="' + i + '"/>';
2684 xml += '<button label="' + offlineStrings.getString('barcode_choice.none') + '" name="fancy_cancel"/>';
2685 xml += '</vbox></groupbox></vbox>';
2686 var fancy_prompt_data = win.open( url, 'fancy_prompt', 'chrome,resizable,modal,width=500,height=500', { 'xml' : xml, 'title' : title, 'sound' : 'bad' } );
2687 if(fancy_prompt_data.fancy_status == 'complete')
2688 return valid_r[fancy_prompt_data.fancy_submit];
2690 // user_false is used to indicate the user said "None of the above" to avoid fall-through erroring later.
2691 return "user_false";
2694 'get_barcode_and_settings' : function(window, barcode, settings_only) {
2695 JSAN.use('util.network');
2696 if(!settings_only) {
2697 // We need to double-check the barcode for completion and such.
2698 var new_barcode = xulG.get_barcode(window, 'actor', barcode);
2699 if(new_barcode == "user_false") return;
2700 // No error means we have a (hopefully valid) completed barcode to use.
2701 // Otherwise, fall through to other methods of checking
2702 if(typeof new_barcode.ilsevent == 'undefined')
2703 barcode = new_barcode.barcode;
2707 var network = new util.network();
2708 // We have a barcode! Time to load settings.
2709 // First, we need the user ID
2710 var user = network.simple_request('FM_AU_RETRIEVE_VIA_BARCODE', [ ses(), barcode ]);
2711 if(user.ilsevent != undefined || user.textcode != undefined)
2714 for(var i = 0; i < user.settings().length; i++) {
2715 settings[user.settings()[i].name()] = JSON2js(user.settings()[i].value());
2717 if(!settings['opac.default_phone'] && user.day_phone()) settings['opac.default_phone'] = user.day_phone();
2718 if(!settings['opac.hold_notify'] && settings['opac.hold_notify'] !== '') settings['opac.hold_notify'] = 'email:phone';
2719 // Taken from patron/util.js format_name
2720 var patron_name = ( user.prefix() ? user.prefix() + ' ' : '') +
2721 user.family_name() + ', ' +
2722 user.first_given_name() + ' ' +
2723 ( user.second_given_name() ? user.second_given_name() + ' ' : '' ) +
2724 ( user.suffix() ? user.suffix() : '');
2725 return {"barcode": barcode, "settings" : settings, "user_email" : user.email(), "patron_name" : patron_name};
2728 'sort_menu' : function(menu, recurse) {
2729 var curgroup = new Array();
2732 for (var itemid = 0; itemid < menu.firstChild.children.length; itemid++) {
2733 var item = menu.firstChild.children[itemid];
2735 if (item.getAttribute('forceFirst')) {
2736 item.setAttribute('ordinal', curstart);
2740 if (item.nodeName == 'menuseparator') {
2741 this.sort_menu_items(curgroup, curstart);
2742 item.setAttribute('ordinal', curordinal);
2743 curstart = curordinal + 1;
2744 curgroup = new Array();
2747 if (item.nodeName == 'menu' && recurse) {
2748 this.sort_menu(item, recurse);
2750 curgroup.push(item);
2752 this.sort_menu_items(curgroup, curstart);
2755 'sort_menu_items' : function(itemgroup, start) {
2757 var sorted = itemgroup.sort(function(a,b) {
2758 var labelA = a.getAttribute('label').toUpperCase();
2759 var labelB = b.getAttribute('label').toUpperCase();
2760 return labelA.localeCompare(labelB);
2762 for(var item = 0; item < sorted.length; item++) {
2763 sorted[item].setAttribute('ordinal', curpos++);
2767 'observe' : function(subject, topic, data) {
2768 if (topic != "nsPref:changed") {
2773 case 'oils.copy_editor.copy_location_name_first':
2774 var cl_first = xulG.pref.getBoolPref('oils.copy_editor.copy_location_name_first');
2775 var menuitems = document.getElementsByAttribute('command','cmd_copy_editor_copy_location_first_toggle');
2776 for(var i = 0; i < menuitems.length; i++)
2777 menuitems[i].setAttribute('checked', cl_first ? 'true' : 'false');
2782 'stop_observing' : function() {
2783 xulG.pref.removeObserver('oils.copy_editor.*', this);
2786 'render_toolbar' : function(button_bar) {
2789 this.last_sanctioned_toolbar = button_bar;
2791 var toolbar = document.getElementById('toolbar_main');
2793 if (button_bar == 'none' || typeof button_bar == 'undefined') {
2794 toolbar.setAttribute('hidden','true');
2800 JSAN.use('util.widgets'); JSAN.use('util.functional');
2801 var def = this.data.hash.atb[ button_bar ];
2802 if (!def) def = util.functional.find_list( this.data.list.atb, function(e) { return e.label == button_bar; } );
2804 dump('Could not find layout for specified toolbar. Defaulting to a stock toolbar.\n');
2805 layout = ["circ_checkout","circ_checkin","toolbarseparator","search_opac","copy_status","toolbarseparator","patron_search","patron_register","toolbarspacer","hotkeys_toggle"];
2807 layout = JSON2js(def.layout());
2810 this.render_toolbar_layout(layout);
2813 alert('Error in menu.js, render_toolbar('+button_bar+'): ' + E);
2817 'render_toolbar_layout' : function(layout) {
2821 this.data.stash_retrieve();
2822 this.render_toolbar( this.last_sanctioned_toolbar );
2826 var toolbar = document.getElementById('toolbar_main');
2828 // destroy existing toolbar
2829 util.widgets.remove_children(toolbar);
2832 for (var i = 0; i < layout.length; i++) {
2834 if (e.match('toolbarseparator')) {
2835 toolbar.appendChild( document.createElement('toolbarseparator') );
2836 } else if (e.match('toolbarspacer')) {
2837 var spacer = document.createElement('toolbarspacer');
2838 spacer.setAttribute('flex','1');
2839 toolbar.appendChild( spacer );
2841 var templates = $('palette').getElementsByAttribute('templateid',e);
2842 var template = templates.length > 0 ? templates[0] : null;
2844 var clone = template.cloneNode(true);
2845 toolbar.appendChild( clone );
2847 var label = document.createElement('label');
2848 label.setAttribute('value',e);
2849 toolbar.appendChild( label );
2853 toolbar.setAttribute('hidden','false');
2856 alert('Error in menu.js, render_toolbar_layout('+layout+'): ' + E);
2861 dump('exiting main/menu.js\n');