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.encodeURIComponent( 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.encodeURIComponent( obj.url_prefix('XUL_LOCAL_ADMIN_BASE/') + path);
173 if(addSes) loc += window.encodeURIComponent('?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.encodeURIComponent(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 //obj is defined at the beginning of this block
412 var idx = obj.controller.view.tabs.selectedIndex;
413 var tab = obj.controller.view.tabs.childNodes[ idx ];
414 var id = tab.getAttribute('id');
415 var lose_saved_data_confirmed = 0;
419 if (tab.in_marc_edit) {
420 confirmation = safe_to_proceed();
421 if (!confirmation) { return; }
424 if (typeof obj.tab_semaphores[id] != 'undefined') {
425 if (obj.tab_semaphores[id] > 0) {
426 //If confirmation has not been defined yet
427 //make sure we prompt for possible loss of data
428 if (typeof confirmation == undefined) {
429 confirmation = window.confirm(offlineStrings.getString('menu.replace_tab.unsaved_data_warning'));
432 if (!confirmation) { return; }
433 oils_unsaved_data_P( obj.tab_semaphores[id] );
434 lose_saved_data_confirmed = 1;
437 delete obj.tab_semaphores[id];
441 var tcn = prompt(offlineStrings.getString('menu.cmd_search_tcn.tab'),'',offlineStrings.getString('menu.cmd_search_tcn.prompt'));
443 function spawn_tcn(r,event) {
444 for (var i = 0; i < r.count; i++) {
446 var opac_url = obj.url_prefix('opac_rdetail') + id;
447 obj.data.stash_retrieve();
448 var content_params = {
450 'authtime' : ses('authtime'),
451 'opac_url' : opac_url,
456 obj.url_prefix('XUL_OPAC_WRAPPER'),
462 obj.url_prefix('XUL_OPAC_WRAPPER'),
471 JSAN.use('util.network');
472 var network = new util.network();
473 var robj = network.simple_request('FM_BRE_ID_SEARCH_VIA_TCN',[tcn]);
474 if (robj.count != robj.ids.length) throw('FIXME -- FM_BRE_ID_SEARCH_VIA_TCN = ' + js2JSON(robj));
475 if (robj.count == 0) {
476 var robj2 = network.simple_request('FM_BRE_ID_SEARCH_VIA_TCN',[tcn,1]);
477 if (robj2.count == 0) {
478 alert(offlineStrings.getFormattedString('menu.cmd_search_tcn.not_found.error', [tcn]));
480 if ( window.confirm(offlineStrings.getFormattedString('menu.cmd_search_tcn.deleted.error', [tcn])) ) {
481 spawn_tcn(robj2,event);
485 spawn_tcn(robj,event);
488 if (lose_saved_data_confirmed) {
489 //Reinstate the unsaved data count on this tab.
490 //This is necessary if the user clicks that it is ok
491 //to lose data, then cancels the TCN search.
492 //This code ensures that they are prompted that they might lose
493 //data if they replace the tab again.
494 obj.tab_semaphores[id] = 1;
495 oils_unsaved_data_V();
500 'cmd_search_bib_id' : [
503 var bib_id = prompt(offlineStrings.getString('menu.cmd_search_bib_id.tab'),'',offlineStrings.getString('menu.cmd_search_bib_id.prompt'));
506 var opac_url = obj.url_prefix('opac_rdetail') + bib_id;
507 var content_params = {
509 'authtime' : ses('authtime'),
510 'opac_url' : opac_url,
514 obj.url_prefix('XUL_OPAC_WRAPPER'),
515 {'tab_name':'#' + bib_id},
520 'cmd_copy_status' : [
523 obj.data.stash_retrieve();
524 obj.command_tab(event,obj.url_prefix('XUL_COPY_STATUS'),{},{});
528 /* Circulation Menu */
529 'cmd_patron_register' : [
533 function log_registration(p) {
536 document.getElementById('offlineStrings').getFormattedString(
537 'staff.circ.work_log_patron_registration.message',
539 ses('staff_usrname'),
545 'au_family_name' : p.family_name(),
546 'au_barcode' : p.card().barcode()
550 obj.error.sdump('D_ERROR','Error with work_logging in menu.js, cmd_patron_register:' + E);
554 function spawn_editor(p) {
555 var url = 'XUL_PATRON_EDIT';
558 if (param_count++ == 0) url += '?'; else url += '&';
559 url += i + '=' + window.encodeURIComponent(p[i]);
561 var loc = obj.url_prefix('XUL_BROWSER?url=') + window.encodeURIComponent( obj.url_prefix(url) );
566 'show_print_button' : true ,
567 'tab_name' : offlineStrings.getString('menu.cmd_patron_register.related.tab'),
568 'passthru_content_params' : {
569 'spawn_search' : function(s) { obj.spawn_search(s); },
570 'spawn_editor' : spawn_editor,
571 'on_save' : function(p) { log_registration(p); }
577 obj.data.stash_retrieve();
578 var loc = obj.url_prefix('XUL_BROWSER?url=')
579 + window.encodeURIComponent( obj.url_prefix('XUL_PATRON_EDIT') );
585 'show_print_button' : true ,
586 'tab_name' : offlineStrings.getString('menu.cmd_patron_register.tab'),
587 'passthru_content_params' : {
589 'spawn_search' : function(s) { obj.spawn_search(s); },
590 'spawn_editor' : spawn_editor,
591 'on_save' : function(p) { log_registration(p); }
597 'cmd_staged_patrons' : [
600 obj.data.stash_retrieve();
601 obj.command_tab(event,obj.url_prefix('XUL_STAGED_PATRONS'),{'tab_name':offlineStrings.getString('menu.circulation.staged_patrons.tab')},{});
604 'cmd_circ_checkin' : [
607 obj.data.stash_retrieve();
608 obj.command_tab(event,obj.url_prefix('XUL_CHECKIN'),{},{});
614 obj.data.stash_retrieve();
615 obj.command_tab(event,obj.url_prefix('XUL_RENEW'),{},{});
618 'cmd_circ_checkout' : [
621 obj.data.stash_retrieve();
622 obj.command_tab(event,obj.url_prefix('XUL_PATRON_BARCODE_ENTRY'),{},{});
625 'cmd_circ_hold_capture' : [
628 obj.data.stash_retrieve();
629 obj.command_tab(event,obj.url_prefix('XUL_CHECKIN?hold_capture=1'),{},{});
632 'cmd_browse_holds_shelf' : [
635 obj.data.stash_retrieve();
636 obj.command_tab(event,obj.url_prefix('XUL_HOLDS_BROWSER?shelf=1'),{ 'tab_name' : offlineStrings.getString('menu.cmd_browse_holds_shelf.tab') },{});
639 'cmd_clear_holds_shelf' : [
642 obj.data.stash_retrieve();
645 obj.url_prefix(urls.XUL_HOLDS_BROWSER),
647 'tab_name' : offlineStrings.getString('menu.cmd_browse_holds_shelf.tab')
656 'cmd_circ_hold_pull_list' : [
659 obj.data.stash_retrieve();
660 var loc = urls.XUL_BROWSER + '?url=' + window.encodeURIComponent(
661 obj.url_prefix('XUL_HOLD_PULL_LIST')
663 obj.command_tab(event, loc, {'tab_name' : offlineStrings.getString('menu.cmd_browse_hold_pull_list.tab')} );
667 'cmd_in_house_use' : [
670 obj.data.stash_retrieve();
671 obj.command_tab(event,obj.url_prefix('XUL_IN_HOUSE_USE'),{},{});
675 'cmd_scan_item_as_missing_pieces' : [
678 xulG.window.open(obj.url_prefix('XUL_SCAN_ITEM_AS_MISSING_PIECES'),'scan_missing_pieces','chrome');
685 //obj.set_tab(obj.url_prefix('XUL_STANDALONE'),{},{});
686 window.open(urls.XUL_STANDALONE,'Offline','chrome,resizable');
690 'cmd_local_admin' : [
693 var loc = urls.XUL_BROWSER + '?url=' + window.encodeURIComponent(
694 obj.url_prefix( 'XUL_LOCAL_ADMIN?ses='+window.encodeURIComponent(ses())+'&session='+window.encodeURIComponent(ses()) )
699 {'tab_name' : offlineStrings.getString('menu.cmd_local_admin.tab'), 'browser' : false },
700 { 'no_xulG' : false, 'show_nav_buttons' : true, 'show_print_button' : true }
706 'cmd_toggle_meters' : [
709 var x = document.getElementById('network_progress');
710 if (x) x.hidden = ! x.hidden;
711 var y = document.getElementById('page_progress');
712 if (y) y.hidden = ! y.hidden;
716 'cmd_local_admin_reports' : [
719 var loc = urls.XUL_BROWSER + '?url=' + window.encodeURIComponent( obj.url_prefix('XUL_REPORTS?ses=') + ses());
723 {'tab_name' : offlineStrings.getString('menu.cmd_local_admin_reports.tab'), 'browser' : false },
724 {'no_xulG' : false, 'show_print_button' : false, show_nav_buttons : true }
728 'cmd_open_vandelay' : [
730 function(event) { open_eg_web_page('vandelay/vandelay', null, event); }
732 'cmd_local_admin_transit_list' : [
734 function(event) { open_admin_page('transit_list.xul', 'menu.cmd_local_admin_transit_list.tab', false, event); }
736 'cmd_local_admin_age_overdue_circulations_to_lost' : [
738 function(event) { open_admin_page('circ_age_to_lost.xul', 'menu.cmd_local_admin_age_overdue_circulations_to_lost.tab', true, event); }
740 'cmd_local_admin_cash_reports' : [
742 function(event) { open_admin_page('cash_reports.xhtml', 'menu.cmd_local_admin_cash_reports.tab', true, event); }
744 'cmd_local_admin_fonts_and_sounds' : [
746 function(event) { open_admin_page('font_settings.xul', 'menu.cmd_local_admin_fonts_and_sounds.tab', false, event); }
748 'cmd_local_admin_printer' : [
750 function(event) { open_admin_page('printer_settings.xul', 'menu.cmd_local_admin_printer.tab', false, event); }
752 'cmd_local_admin_do_not_auto_attempt_print_setting' : [
755 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')},{});
758 'cmd_local_admin_closed_dates' : [
760 function(event) { open_admin_page('closed_dates.xhtml', 'menu.cmd_local_admin_closed_dates.tab', true, event); }
762 'cmd_local_admin_copy_locations' : [
764 function(event) { open_admin_page('copy_locations.xhtml', 'menu.cmd_local_admin_copy_locations.tab', true, event); }
766 'cmd_local_admin_lib_settings' : [
768 function(event) { open_admin_page('org_unit_settings.xhtml', 'menu.cmd_local_admin_lib_settings.tab', true, event); }
770 'cmd_local_admin_non_cat_types' : [
772 function(event) { open_admin_page('non_cat_types.xhtml', 'menu.cmd_local_admin_non_cat_types.tab', true, event); }
774 'cmd_local_admin_stat_cats' : [
776 function(event) { open_admin_page('stat_cat_editor.xhtml', 'menu.cmd_local_admin_stat_cats.tab', true, event); }
778 'cmd_local_admin_standing_penalty' : [
780 function(event) { open_eg_web_page('conify/global/config/standing_penalty', null, event); }
782 'cmd_local_admin_grp_penalty_threshold' : [
784 function(event) { open_eg_web_page('conify/global/permission/grp_penalty_threshold', null, event); }
786 'cmd_local_admin_circ_limit_set' : [
788 function(event) { open_eg_web_page('conify/global/config/circ_limit_set', null, event); }
790 'cmd_server_admin_config_rule_circ_duration' : [
792 function(event) { open_eg_web_page('conify/global/config/rule_circ_duration', null, event); }
794 'cmd_server_admin_config_hard_due_date' : [
796 function(event) { open_eg_web_page('conify/global/config/hard_due_date', null, event); }
798 'cmd_server_admin_config_rule_recurring_fine' : [
800 function(event) { open_eg_web_page('conify/global/config/rule_recurring_fine', null, event); }
802 'cmd_server_admin_config_rule_max_fine' : [
804 function(event) { open_eg_web_page('conify/global/config/rule_max_fine', null, event); }
806 'cmd_server_admin_config_rule_age_hold_protect' : [
808 function(event) { open_eg_web_page('conify/global/config/rule_age_hold_protect', null, event); }
810 'cmd_server_admin_config_circ_weights' : [
812 function(event) { open_eg_web_page('conify/global/config/circ_matrix_weights', null, event); }
814 'cmd_server_admin_config_hold_weights' : [
816 function(event) { open_eg_web_page('conify/global/config/hold_matrix_weights', null, event); }
818 'cmd_server_admin_config_weight_assoc' : [
820 function(event) { open_eg_web_page('conify/global/config/weight_assoc', null, event); }
822 'cmd_server_admin_config_actor_sip_fields' : [
824 function(event) { open_eg_web_page('conify/global/config/actor_sip_fields', null, event); }
826 'cmd_server_admin_config_asset_sip_fields' : [
828 function(event) { open_eg_web_page('conify/global/config/asset_sip_fields', null, event); }
830 'cmd_server_admin_circ_limit_group' : [
832 function(event) { open_eg_web_page('conify/global/config/circ_limit_group', null, event); }
834 'cmd_server_admin_config_best_hold_order' : [
836 function(event) { open_eg_web_page('conify/global/config/best_hold_order', null, event); }
838 'cmd_server_admin_vandelay_import_bib_trash_group' : [
840 function(event) { open_eg_web_page('conify/global/vandelay/import_bib_trash_group', null, event); }
842 'cmd_server_admin_config_usr_activity_type' : [
844 function(event) { open_eg_web_page('conify/global/config/usr_activity_type', null, event); }
846 'cmd_server_admin_actor_org_unit_custom_tree' : [
848 function(event) { open_eg_web_page('conify/global/actor/org_unit_custom_tree', null, event); }
850 'cmd_server_admin_floating_groups' : [
852 function(event) { open_eg_web_page('conify/global/config/floating_groups', 'menu.cmd_server_admin_floating_groups.tab', event); }
854 'cmd_local_admin_external_text_editor' : [
857 var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components.interfaces['nsIPrefBranch']);
858 var key = 'oils.text_editor.external.cmd';
859 var has_key = prefs.prefHasUserValue(key);
860 var value = has_key ? prefs.getCharPref(key) : 'C:\\Windows\\notepad.exe %letter.txt%';
861 var cmd = window.prompt(
862 document.getElementById('offlineStrings').getString('text_editor.prompt_for_external_cmd'),
865 if (!cmd) { return; }
866 prefs.setCharPref(key,cmd);
869 'cmd_local_admin_idl_field_doc' : [
871 function(event) { open_eg_web_page('conify/global/config/idl_field_doc', null, event); }
873 'cmd_local_admin_action_trigger' : [
875 function(event) { open_eg_web_page('conify/global/action_trigger/event_definition', null, event); }
877 'cmd_local_admin_survey' : [
879 function(event) { open_eg_web_page('conify/global/action/survey', null, event); }
881 'cmd_local_admin_barcode_completion' : [
883 function() { open_eg_web_page('conify/global/config/barcode_completion',
884 'menu.local_admin.barcode_completion.tab'); }
886 'cmd_local_admin_circ_matrix_matchpoint' : [
888 function() { open_eg_web_page('conify/global/config/circ_matrix_matchpoint',
889 'menu.local_admin.circ_matrix_matchpoint.tab'); }
891 'cmd_local_admin_hold_matrix_matchpoint' : [
893 function() { open_eg_web_page('conify/global/config/hold_matrix_matchpoint',
894 'menu.local_admin.hold_matrix_matchpoint.tab'); }
896 'cmd_local_admin_copy_location_order' : [
898 function(event) { open_eg_web_page('conify/global/asset/copy_location_order', null, event); }
900 'cmd_local_admin_work_log' : [
906 { 'tab_name' : offlineStrings.getString('menu.local_admin.work_log.tab') },
911 "cmd_local_admin_copy_template": [
914 open_eg_web_page("conify/global/asset/copy_template");
917 "cmd_local_admin_item_attribute_editor": [
922 urls.XUL_COPY_EDITOR,
923 { 'tab_name' : offlineStrings.getString('menu.local_admin.item_attribute_editor.tab') },
924 { 'admin' : true, 'not_modal' : true }
928 'cmd_local_admin_patrons_due_refunds' : [
933 obj.url_prefix('XUL_PATRONS_DUE_REFUNDS'),
934 { 'tab_name' : offlineStrings.getString('menu.local_admin.patrons_due_refunds.tab') },
939 'cmd_server_admin_org_type' : [
941 function(event) { open_conify_page('actor/org_unit_type', null, event); }
943 'cmd_server_admin_org_unit' : [
945 function(event) { open_conify_page('actor/org_unit', null, event); }
947 'cmd_server_admin_grp_tree' : [
949 function(event) { open_conify_page('permission/grp_tree', null, event); }
951 'cmd_server_admin_perm_list' : [
953 function(event) { open_conify_page('permission/perm_list', null, event); }
955 'cmd_server_admin_copy_status' : [
957 function(event) { open_conify_page('config/copy_status', null, event); }
959 'cmd_server_admin_marc_code' : [
961 function(event) { open_eg_web_page('conify/global/config/record_attr_definition', null, event); }
963 'cmd_server_admin_coded_value_map' : [
965 function(event) { open_eg_web_page('conify/global/config/coded_value_map', null, event); }
967 'cmd_server_admin_metabib_class' : [
969 function(event) { open_eg_web_page('conify/global/config/metabib_class', null, event); }
971 'cmd_server_admin_metabib_class_ts_map' : [
973 function(event) { open_eg_web_page('conify/global/config/metabib_class_ts_map', null, event); }
975 'cmd_server_admin_metabib_field' : [
977 function(event) { open_eg_web_page('conify/global/config/metabib_field', null, event); }
979 'cmd_server_admin_metabib_field_ts_map' : [
981 function(event) { open_eg_web_page('conify/global/config/metabib_field_ts_map', null, event); }
983 'cmd_server_admin_acn_prefix' : [
985 function(event) { open_eg_web_page('conify/global/config/acn_prefix', null, event); }
987 'cmd_server_admin_acn_suffix' : [
989 function(event) { open_eg_web_page('conify/global/config/acn_suffix', null, event); }
991 'cmd_server_admin_billing_type' : [
993 function(event) { open_eg_web_page('conify/global/config/billing_type', null, event); }
995 'cmd_server_admin_acq_invoice_item_type' : [
997 function(event) { open_eg_web_page('conify/global/acq/invoice_item_type', null, event); }
999 'cmd_server_admin_acq_invoice_payment_method' : [
1001 function(event) { open_eg_web_page('conify/global/acq/invoice_payment_method', null, event); }
1003 'cmd_server_admin_acq_lineitem_alert' : [
1005 function(event) { open_eg_web_page('conify/global/acq/lineitem_alert', null, event); }
1007 'cmd_server_admin_acq_lineitem_marc_attr_def' : [
1009 function(event) { open_eg_web_page('conify/global/acq/lineitem_marc_attr_def', null, event); }
1011 'cmd_server_admin_acq_fund_tag' : [
1013 function(event) { open_eg_web_page('conify/global/acq/fund_tag', null, event); }
1015 'cmd_server_admin_acq_cancel_reason' : [
1017 function(event) { open_eg_web_page('conify/global/acq/cancel_reason', null, event); }
1019 'cmd_server_admin_acq_claim_type' : [
1021 function(event) { open_eg_web_page('conify/global/acq/claim_type', null, event); }
1023 'cmd_server_admin_acq_claim_event_type' : [
1025 function(event) { open_eg_web_page('conify/global/acq/claim_event_type', null, event); }
1027 'cmd_server_admin_acq_claim_policy' : [
1029 function(event) { open_eg_web_page('conify/global/acq/claim_policy', null, event); }
1031 'cmd_server_admin_acq_claim_policy_action' : [
1033 function(event) { open_eg_web_page('conify/global/acq/claim_policy_action', null, event); }
1035 'cmd_server_admin_acq_fund' : [
1037 function(event) { open_eg_web_page('acq/fund/list', null, event); }
1039 'cmd_server_admin_acq_funding_source' : [
1041 function(event) { open_eg_web_page('acq/funding_source/list', null, event); }
1043 'cmd_server_admin_acq_provider' : [
1045 function(event) { open_eg_web_page('conify/global/acq/provider', null, event); }
1047 'cmd_server_admin_acq_edi_account' : [
1049 function(event) { open_eg_web_page('conify/global/acq/edi_account', null, event); }
1051 'cmd_server_admin_acq_edi_message' : [
1053 function(event) { open_eg_web_page('acq/po/edi_messages', null, event); }
1055 'cmd_server_admin_acq_currency_type' : [
1057 function(event) { open_eg_web_page('acq/currency_type/list', null, event); }
1059 'cmd_server_admin_acq_exchange_rate' : [
1061 function(event) { open_eg_web_page('conify/global/acq/exchange_rate', null, event); }
1063 'cmd_server_admin_acq_distrib_formula' : [
1065 function(event) { open_eg_web_page('conify/global/acq/distribution_formula', null, event); }
1067 'cmd_server_admin_sms_carrier' : [
1069 function(event) { open_eg_web_page('conify/global/config/sms_carrier', null, event); }
1071 'cmd_server_admin_z39_source' : [
1073 function(event) { open_eg_web_page('conify/global/config/z3950_source', null, event); }
1075 'cmd_server_admin_org_unit_proximity_adjustment' : [
1077 function(event) { open_eg_web_page('conify/global/config/org_unit_proximity_adjustment', null, event); }
1079 'cmd_server_admin_z39_index_field_map' : [
1081 function(event) { open_eg_web_page('conify/global/config/z3950_index_field_map', null, event); }
1083 'cmd_server_admin_circ_mod' : [
1085 function(event) { open_eg_web_page('conify/global/config/circ_modifier', null, event); }
1087 'cmd_server_admin_global_flag' : [
1089 function(event) { open_eg_web_page('conify/global/config/global_flag', null, event); }
1091 'cmd_server_admin_org_unit_setting_type' : [
1093 function(event) { open_eg_web_page('conify/global/config/org_unit_setting_type', null, event); }
1095 'cmd_server_admin_import_match_set' : [
1097 function(event) { open_eg_web_page('conify/global/vandelay/match_set', null, event); }
1099 'cmd_server_admin_usr_setting_type' : [
1101 function(event) { open_eg_web_page('conify/global/config/usr_setting_type', null, event); }
1103 'cmd_server_admin_authority_control_set': [
1105 function(event) { open_eg_web_page('conify/global/cat/authority/control_set', null, event); }
1107 'cmd_server_admin_authority_browse_axis': [
1109 function(event) { open_eg_web_page('conify/global/cat/authority/browse_axis', null, event); }
1111 'cmd_server_admin_authority_thesaurus': [
1113 function(event) { open_eg_web_page('conify/global/cat/authority/thesaurus', null, event); }
1115 'cmd_server_admin_booking_resource': [
1117 function(event) { open_eg_web_page('conify/global/booking/resource', null, event); }
1119 'cmd_server_admin_booking_resource_type': [
1121 function(event) { open_eg_web_page('conify/global/booking/resource_type', null, event); }
1123 'cmd_server_admin_booking_resource_attr': [
1125 function(event) { open_eg_web_page('conify/global/booking/resource_attr', null, event); }
1127 'cmd_server_admin_booking_resource_attr_value': [
1129 function(event) { open_eg_web_page('conify/global/booking/resource_attr_value', null, event); }
1131 'cmd_server_admin_booking_resource_attr_map': [
1133 function(event) { open_eg_web_page('conify/global/booking/resource_attr_map', null, event); }
1135 'cmd_local_admin_address_alert' : [
1137 function(event) { open_eg_web_page('conify/global/actor/address_alert', null, event); }
1139 'cmd_local_admin_copy_location_group' : [
1141 function(event) { open_eg_web_page('conify/global/asset/copy_location_group', null, event); }
1143 'cmd_local_admin_search_filter_group' : [
1145 function(event) { open_eg_web_page('conify/global/actor/search_filter_group', null, event); }
1147 'cmd_acq_create_invoice' : [
1149 function(event) { open_eg_web_page('acq/invoice/view?create=1', 'menu.cmd_acq_create_invoice.tab', event); }
1151 'cmd_acq_view_my_pl' : [
1153 function(event) { open_eg_web_page('acq/search/unified?ca=pl', 'menu.cmd_acq_unified_search.tab', event); }
1155 'cmd_acq_view_local_po' : [
1157 function(event) { open_eg_web_page('acq/search/unified?ca=po', 'menu.cmd_acq_unified_search.tab', event); }
1159 'cmd_acq_create_po' : [
1161 function(event) { open_eg_web_page('acq/po/create', 'menu.cmd_acq_po.tab', event); }
1163 'cmd_acq_view_local_inv' : [
1165 function(event) { open_eg_web_page('acq/search/unified?ca=inv', 'menu.cmd_acq_unified_search.tab', event); }
1167 'cmd_acq_user_requests' : [
1169 function(event) { open_eg_web_page('acq/picklist/user_request', 'menu.cmd_acq_user_requests.tab', event); }
1171 'cmd_acq_upload' : [
1173 function(event) { open_eg_web_page('acq/picklist/upload', 'menu.cmd_acq_upload.tab', event); }
1175 'cmd_acq_bib_search' : [
1177 function(event) { open_eg_web_page('acq/picklist/bib_search', 'menu.cmd_acq_bib_search.tab', event); }
1179 'cmd_acq_unified_search' : [
1181 function(event) { open_eg_web_page('acq/search/unified', 'menu.cmd_acq_unified_search.tab', event); }
1183 'cmd_acq_from_bib' : [
1185 function(event) { open_eg_web_page('acq/picklist/from_bib', 'menu.cmd_acq_from_bib.tab', event); }
1187 'cmd_acq_new_brief_record' : [
1189 function(event) { open_eg_web_page('acq/picklist/brief_record', 'menu.cmd_acq_new_brief_record.tab', event); }
1191 'cmd_acq_claim_eligible' : [
1193 function(event) { open_eg_web_page('acq/financial/claim_eligible', 'menu.cmd_acq_claim_eligible.tab', event); }
1195 'cmd_booking_reservation' : [
1199 "/eg/booking/reservation",
1200 "menu.cmd_booking_reservation.tab",
1205 'cmd_booking_pull_list' : [
1209 "/eg/booking/pull_list",
1210 "menu.cmd_booking_pull_list.tab",
1215 'cmd_booking_capture' : [
1219 "/eg/booking/capture",
1220 "menu.cmd_booking_capture.tab",
1225 'cmd_booking_reservation_pickup' : [
1229 "/eg/booking/pickup",
1230 "menu.cmd_booking_reservation_pickup.tab",
1235 'cmd_booking_reservation_return' : [
1239 "/eg/booking/return",
1240 "menu.cmd_booking_reservation_return.tab",
1245 'cmd_server_admin_conify_remote_account' : [
1249 "/eg/conify/global/config/remote_account",
1250 "menu.cmd_server_admin_conify_remote_account.tab",
1259 JSAN.use('util.print'); var print = new util.print();
1260 print.reprint_last();
1267 'cmd_retrieve_last_patron' : [
1270 obj.data.stash_retrieve();
1271 if (!obj.data.last_patron) {
1272 alert(offlineStrings.getString('menu.cmd_retrieve_last_patron.session.error'));
1275 var horizontal_interface = String( obj.data.hash.aous['ui.circ.patron_summary.horizontal'] ) == 'true';
1276 var url = obj.url_prefix( horizontal_interface ? 'XUL_PATRON_HORIZ_DISPLAY' : 'XUL_PATRON_DISPLAY' );
1277 obj.command_tab( event, url, {}, { 'id' : obj.data.last_patron } );
1281 'cmd_url_verify' : [
1285 "/eg/url_verify/sessions",
1286 "menu.cmd_url_verify.tab",
1289 'show_print_button': false,
1290 'show_nav_buttons': true
1296 'cmd_retrieve_last_record' : [
1299 obj.data.stash_retrieve();
1300 if (!obj.data.last_record) {
1301 alert(offlineStrings.getString('menu.cmd_retrieve_last_record.session.error'));
1304 var opac_url = obj.url_prefix('opac_rdetail') + obj.data.last_record;
1305 var content_params = {
1307 'authtime' : ses('authtime'),
1308 'opac_url' : opac_url,
1312 obj.url_prefix('XUL_OPAC_WRAPPER'),
1313 {'tab_name' : offlineStrings.getString('menu.cmd_retrieve_last_record.status')},
1319 'cmd_verify_credentials' : [
1324 obj.url_prefix('XUL_VERIFY_CREDENTIALS'),
1325 { 'tab_name' : offlineStrings.getString('menu.cmd_verify_credentials.tabname') },
1331 /* Cataloging Menu */
1332 'cmd_z39_50_import' : [
1335 obj.data.stash_retrieve();
1336 obj.command_tab(event,obj.url_prefix('XUL_Z3950_IMPORT'),{},{});
1339 'cmd_create_marc' : [
1342 obj.data.stash_retrieve();
1343 obj.command_tab(event,obj.url_prefix('XUL_MARC_NEW'),{},{});
1347 'cmd_authority_manage' : [
1351 urls.AUTHORITY_MANAGE,
1352 "menu.cmd_authority_manage.tab",
1358 'cmd_marc_batch_edit' : [
1363 obj.url_prefix('MARC_BATCH_EDIT'),{
1364 'tab_name' : offlineStrings.getString('menu.cmd_marc_batch_edit.tab')
1372 'cmd_change_session' : [
1376 obj.data.stash_retrieve();
1377 JSAN.use('util.network'); var network = new util.network();
1378 var temp_au = js2JSON( obj.data.list.au[0] );
1379 var temp_ses = js2JSON( obj.data.session );
1380 if (obj.data.list.au.length > 1) {
1381 obj.data.list.au = [ obj.data.list.au[1] ];
1382 obj.data.stash('list');
1383 network.reset_titlebars( obj.data );
1384 network.simple_request('AUTH_DELETE', [ obj.data.session.key ] );
1385 obj.data.session = obj.data.previous_session;
1386 obj.data.menu_perms = obj.data.previous_menu_perms;
1387 obj.data.stash('session');
1388 obj.data.stash('menu_perms');
1390 var ios = Components.classes["@mozilla.org/network/io-service;1"].getService(Components.interfaces.nsIIOService);
1391 var cookieUriSSL = ios.newURI("https://" + obj.data.server_unadorned, null, null);
1392 var cookieSvc = Components.classes["@mozilla.org/cookieService;1"].getService(Components.interfaces.nsICookieService);
1394 cookieSvc.setCookieString(cookieUriSSL, null, "ses="+obj.data.session.key + "; secure;", null);
1396 alert(offlineStrings.getFormattedString(main.session_cookie.error, [E]));
1399 if (network.get_new_session(offlineStrings.getString('menu.cmd_chg_session.label'),{'url_prefix':obj.url_prefix})) {
1400 obj.data.stash_retrieve();
1401 if (obj.data.session.is_perm === false) {
1402 obj.data.list.au[1] = JSON2js( temp_au );
1403 obj.data.stash('list');
1404 obj.data.previous_session = JSON2js( temp_ses );
1405 obj.data.previous_menu_perms = obj.data.menu_perms;
1406 obj.data.stash('previous_session');
1407 obj.data.stash('previous_menu_perms');
1409 var temp_session_object = JSON2js( temp_ses );
1410 network.simple_request('AUTH_DELETE', [ temp_session_object.key ] );
1412 obj.data.menu_perms = false;
1413 obj.data.stash('menu_perms');
1416 network.set_user_status();
1418 obj.error.standard_unexpected_error_alert('cmd_change_session',E);
1422 'cmd_manage_offline_xacts' : [
1425 obj.command_tab(event,obj.url_prefix('XUL_OFFLINE_MANAGE_XACTS'), {'tab_name' : offlineStrings.getString('menu.cmd_manage_offline_xacts.tab')}, {});
1428 'cmd_download_patrons' : [
1432 var x = new XMLHttpRequest();
1433 var url = 'https://' + XML_HTTP_SERVER + '/standalone/list.txt';
1434 x.open("GET",url,false);
1436 if (x.status == 200) {
1437 JSAN.use('util.file'); var file = new util.file('offline_patron_list');
1438 file.write_content('truncate',x.responseText);
1440 file = new util.file('offline_patron_list.date');
1441 file.write_content('truncate',new Date());
1443 alert(offlineStrings.getString('menu.cmd_download_patrons.complete.status'));
1445 alert(offlineStrings.getFormattedString('menu.cmd_download_patrons.error', [x.status, x.statusText]));
1448 obj.error.standard_unexpected_error_alert('cmd_download_patrons',E);
1452 'cmd_adv_user_edit' : [
1455 obj.data.stash_retrieve();
1456 obj.command_tab(event,obj.url_prefix('XUL_PATRON_BARCODE_ENTRY'), {}, { 'perm_editor' : true });
1459 'cmd_print_list_template_edit' : [
1462 obj.data.stash_retrieve();
1463 obj.command_tab(event,obj.url_prefix('XUL_PRINT_LIST_TEMPLATE_EDITOR'), {}, {});
1466 'cmd_stat_cat_edit' : [
1469 obj.data.stash_retrieve();
1470 obj.command_tab(event,obj.url_prefix('XUL_STAT_CAT_EDIT?ses=') + window.encodeURIComponent(ses()), {'tab_name' : offlineStrings.getString('menu.cmd_stat_cat_edit.tab')},{});
1473 'cmd_non_cat_type_edit' : [
1476 obj.data.stash_retrieve();
1477 obj.command_tab(event,obj.url_prefix('XUL_NON_CAT_LABEL_EDIT?ses=') + window.encodeURIComponent(ses()), {'tab_name' : offlineStrings.getString('menu.cmd_non_cat_type_edit.tab')},{});
1480 'cmd_copy_location_edit' : [
1483 obj.data.stash_retrieve();
1484 obj.command_tab(event,obj.url_prefix('XUL_COPY_LOCATION_EDIT?ses=') + window.encodeURIComponent(ses()),{'tab_name' : offlineStrings.getString('menu.cmd_copy_location_edit.tab')},{});
1490 obj.data.stash_retrieve();
1491 var content_params = { 'session' : ses(), 'authtime' : ses('authtime') };
1492 obj.command_tab(event,obj.url_prefix('XUL_OPAC_WRAPPER'), {}, content_params);
1498 obj.data.stash_retrieve();
1499 obj.command_tab(event,obj.url_prefix('TEST_HTML?ses=') + window.encodeURIComponent(ses()),{ 'browser' : true },{});
1505 obj.data.stash_retrieve();
1506 obj.command_tab(event,obj.url_prefix('TEST_XUL?ses=') + window.encodeURIComponent(ses()),{ 'browser' : false },{});
1512 obj.command_tab(event,obj.url_prefix('XUL_DEBUG_CONSOLE'),{'tab_name' : offlineStrings.getString('menu.cmd_console.tab')},{});
1518 obj.command_tab(event,obj.url_prefix('XUL_DEBUG_SHELL'),{'tab_name' : offlineStrings.getString('menu.cmd_shell.tab')},{});
1524 obj.command_tab(event,obj.url_prefix('XUL_DEBUG_XULEDITOR'),{'tab_name' : offlineStrings.getString('menu.cmd_xuleditor.tab')},{});
1527 'cmd_fieldmapper' : [
1530 obj.command_tab(event,obj.url_prefix('XUL_DEBUG_FIELDMAPPER'),{'tab_name' : offlineStrings.getString('menu.cmd_fieldmapper.tab')},{});
1533 'cmd_survey_wizard' : [
1536 obj.data.stash_retrieve();
1537 xulG.window.open(obj.url_prefix('XUL_SURVEY_WIZARD'),'survey_wizard','chrome');
1540 'cmd_public_opac' : [
1543 var loc = urls.XUL_BROWSER + '?url=' + window.encodeURIComponent(
1544 obj.url_prefix('remote')
1549 {'tab_name' : offlineStrings.getString('menu.cmd_public_opac.tab'), 'browser' : false},
1550 { 'no_xulG' : true, 'show_nav_buttons' : true, 'show_print_button' : true }
1554 'cmd_clear_cache' : [
1556 function clear_the_cache() {
1558 var cacheClass = Components.classes["@mozilla.org/network/cache-service;1"];
1559 var cacheService = cacheClass.getService(Components.interfaces.nsICacheService);
1560 cacheService.evictEntries(Components.interfaces.nsICache.STORE_ON_DISK);
1561 cacheService.evictEntries(Components.interfaces.nsICache.STORE_IN_MEMORY);
1563 dump(E+'\n');alert(E);
1567 'cmd_restore_all_tabs' : [
1570 var tabs = obj.controller.view.tabs;
1571 for (var i = 0; i < tabs.childNodes.length; i++) {
1572 tabs.childNodes[i].hidden = false;
1576 'cmd_extension_manager' : [
1579 obj.command_tab(event,'chrome://mozapps/content/extensions/extensions.xul?type=extensions',{'tab_name' : offlineStrings.getString('menu.cmd_extension_manager.tab')},{});
1582 'cmd_theme_manager' : [
1585 obj.command_tab(event,'chrome://mozapps/content/extensions/extensions.xul?type=themes',{'tab_name' : offlineStrings.getString('menu.cmd_theme_manager.tab')},{});
1588 'cmd_about_config' : [
1591 obj.command_tab(event,'chrome://global/content/config.xul',{'tab_name' : 'about:config'},{});
1594 'cmd_about_about' : [
1597 obj.command_tab(event,'chrome://global/content/aboutAbout.xhtml',{'tab_name' : 'about:about'},{});
1603 var confirm_string = offlineStrings.getString('menu.cmd_shutdown.prompt');
1604 obj.data.stash_retrieve();
1605 if (typeof obj.data.unsaved_data != 'undefined') {
1606 if (obj.data.unsaved_data > 0) {
1607 confirm_string = offlineStrings.getString('menu.shutdown.unsaved_data_warning');
1610 if (window.confirm(confirm_string)) {
1611 obj.data.unsaved_data = 0; // just in case the program doesn't close somehow
1612 obj.data.stash('unsaved_data');
1613 dump('forcing data.unsaved_data == ' + obj.data.unsaved_data + '\n');
1614 var windowManager = Components.classes["@mozilla.org/appshell/window-mediator;1"].getService();
1615 var windowManagerInterface = windowManager.QueryInterface(Components.interfaces.nsIWindowMediator);
1616 var enumerator = windowManagerInterface.getEnumerator(null);
1617 var w; // close all other windows
1618 while ( w = enumerator.getNext() ) {
1620 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
1627 'cmd_hotkeys_toggle' : [
1630 // Easy enough, toggle disabled on the keyset
1631 var keyset = document.getElementById("menu_frame_keys");
1632 var disabled = (keyset.getAttribute("disabled") == "true") ? "false" : "true";
1633 if(disabled == "true")
1634 keyset.setAttribute("disabled", "true");
1636 keyset.removeAttribute("disabled");
1637 // Then find every menuitem/toolbarbutton for this command for a graphical hint
1638 var controls = document.getElementsByAttribute("command","cmd_hotkeys_toggle");
1639 for(var i = 0; i < controls.length; i++)
1640 controls[i].setAttribute("checked",disabled);
1643 'cmd_hotkeys_set' : [
1646 obj.set_menu_hotkeys(event.explicitOriginalTarget.getAttribute('value'));
1649 'cmd_hotkeys_setworkstation' : [
1652 xulG.pref.setCharPref('open-ils.menu.hotkeyset', obj.data.current_hotkeyset);
1655 'cmd_hotkeys_clearworkstation' : [
1658 if(xulG.pref.prefHasUserValue('open-ils.menu.hotkeyset'))
1659 xulG.pref.clearUserPref('open-ils.menu.hotkeyset');
1662 'cmd_toolbar_set' : [
1665 var newToolbar = event.explicitOriginalTarget.getAttribute('value');
1666 obj.render_toolbar(newToolbar);
1667 obj.toolbar = newToolbar;
1670 'cmd_toolbar_mode_set' : [
1673 var newMode = event.explicitOriginalTarget.getAttribute('value');
1674 var toolbox = document.getElementById('main_toolbox');
1675 var toolbars = toolbox.getElementsByTagName('toolbar');
1676 for(var i = 0; i < toolbars.length; i++)
1677 toolbars[i].setAttribute("mode",newMode);
1678 obj.toolbar_mode = newMode;
1681 'cmd_toolbar_size_set' : [
1684 var newSize = event.explicitOriginalTarget.getAttribute('value');
1685 var toolbox = document.getElementById('main_toolbox');
1686 var toolbars = toolbox.getElementsByTagName('toolbar');
1687 for(var i = 0; i < toolbars.length; i++)
1688 toolbars[i].setAttribute("iconsize",newSize);
1689 obj.toolbar_size = newSize;
1692 'cmd_toolbar_label_position_set' : [
1695 var altPosition = (event.explicitOriginalTarget.getAttribute('value') == "under");
1696 var toolbox = document.getElementById('main_toolbox');
1697 var toolbars = toolbox.getElementsByTagName('toolbar');
1698 for(var i = 0; i < toolbars.length; i++) {
1700 addCSSClass(toolbars[i], 'labelbelow');
1702 removeCSSClass(toolbars[i], 'labelbelow');
1704 obj.toolbar_labelpos = (altPosition ? "under" : "side");
1707 'cmd_toolbar_configure' : [
1710 var url = obj.url_prefix( 'XUL_TOOLBAR_CONFIG' );
1711 obj.command_tab(event,url,{},{});
1714 'cmd_toolbar_setworkstation' : [
1717 xulG.pref.setCharPref('open-ils.menu.toolbar', obj.toolbar);
1718 xulG.pref.setCharPref('open-ils.menu.toolbar.iconsize', obj.toolbar_size);
1719 xulG.pref.setCharPref('open-ils.menu.toolbar.mode', obj.toolbar_mode);
1720 xulG.pref.setBoolPref('open-ils.menu.toolbar.labelbelow', (obj.toolbar_labelpos == "under"));
1723 'cmd_toolbar_clearworkstation' : [
1726 if(xulG.pref.prefHasUserValue('open-ils.menu.toolbar'))
1727 xulG.pref.clearUserPref('open-ils.menu.toolbar');
1728 if(xulG.pref.prefHasUserValue('open-ils.menu.toolbar.iconsize'))
1729 xulG.pref.clearUserPref('open-ils.menu.toolbar.iconsize');
1730 if(xulG.pref.prefHasUserValue('open-ils.menu.toolbar.mode'))
1731 xulG.pref.clearUserPref('open-ils.menu.toolbar.mode');
1732 if(xulG.pref.prefHasUserValue('open-ils.menu.toolbar.labelbelow'))
1733 xulG.pref.clearUserPref('open-ils.menu.toolbar.labelbelow');
1736 'cmd_debug_venkman' : [
1740 xulG.window.win.start_debugger();
1746 'cmd_debug_inspector' : [
1750 xulG.window.win.start_inspector();
1756 'cmd_debug_chrome_list' : [
1760 xulG.window.win.start_chrome_list();
1766 'cmd_debug_chrome_shell' : [
1770 xulG.window.win.start_js_shell();
1776 'cmd_copy_editor_copy_location_first_toggle' : [
1779 var curvalue = xulG.pref.getBoolPref('oils.copy_editor.copy_location_name_first');
1780 xulG.pref.setBoolPref('oils.copy_editor.copy_location_name_first', !curvalue);
1783 'cmd_search_prefs' : [
1787 obj.set_tab(obj.url_prefix('XUL_SEARCH_PREFS'),{'tab_name' : offlineStrings.getString('menu.cmd_search_prefs.tab'), 'browser' : false});
1793 'cmd_server_addon_ws_configure' : [
1797 obj.set_tab(obj.url_prefix('XUL_SERVER_ADDONS'),{'browser' : false});
1805 JSAN.use('util.controller');
1807 obj.controller = new util.controller();
1808 obj.controller.init( { 'window_knows_me_by' : 'g.menu.controller', 'control_map' : cmd_map } );
1810 obj.controller.view.tabbox = window.document.getElementById('main_tabbox');
1811 // Despite what the docs say:
1812 // The "tabs" element need not be the first child
1813 // The "panels" element need not be the second/last
1814 // Nor need they be the only ones there.
1815 // Thus, use the IDs for robustness.
1816 obj.controller.view.tabs = window.document.getElementById('main_tabs');
1817 obj.controller.view.panels = window.document.getElementById('main_panels');
1818 obj.controller.view.tabscroller = window.document.getElementById('main_tabs_scrollbox');
1820 obj.sort_menu(document.getElementById('main.menu.admin'), true);
1822 document.addEventListener(
1826 obj.set_tab(obj.url_prefix('XUL_PATRON_BARCODE_ENTRY'));
1828 obj.error.sdump('D_ERROR','tab_refresh_checkout_handler: ' + js2JSON(E));
1836 if(params['firstURL']) {
1837 obj.new_tab(params['firstURL'],{'focus':true},null);
1840 obj.new_tab(null,{'focus':true},null);
1844 'button_bar_init' : function() {
1849 JSAN.use('util.widgets');
1851 // populate the menu of available toolbars
1852 var x = document.getElementById('main.menu.admin.client.toolbars.current.popup');
1854 util.widgets.remove_children(x);
1856 function create_menuitem(label,value,checked) {
1857 var menuitem = document.createElement('menuitem');
1858 menuitem.setAttribute('name','current_toolbar');
1859 menuitem.setAttribute('type','radio');
1860 menuitem.setAttribute('label',label);
1861 menuitem.setAttribute('value',value);
1862 menuitem.setAttribute('command','cmd_toolbar_set');
1863 if (checked) menuitem.setAttribute('checked','true');
1869 offlineStrings.getString('staff.main.button_bar.none'),
1877 offlineStrings.getString('staff.main.button_bar.default'),
1883 for (var i = 0; i < this.data.list.atb.length; i++) {
1884 var def = this.data.list.atb[i];
1894 // Try workstation pref for button bar
1895 var button_bar = xulG.pref.getCharPref('open-ils.menu.toolbar');
1897 if (!button_bar) { // No workstation pref? Try org unit pref.
1898 if (obj.data.hash.aous['ui.general.button_bar']) {
1899 button_bar = String( obj.data.hash.aous['ui.general.button_bar'] );
1904 this.render_toolbar(button_bar);
1905 this.toolbar = button_bar;
1908 // Check for alternate Size pref
1909 var toolbar_size = xulG.pref.getCharPref('open-ils.menu.toolbar.iconsize');
1910 if(toolbar_size) this.toolbar_size = toolbar_size;
1911 // Check for alternate Mode pref
1912 var toolbar_mode = xulG.pref.getCharPref('open-ils.menu.toolbar.mode');
1913 if(toolbar_mode) this.toolbar_mode = toolbar_mode;
1914 // Check for alternate Label Position pref
1915 var toolbar_labelpos = xulG.pref.getBoolPref('open-ils.menu.toolbar.labelbelow');
1916 if(toolbar_labelpos) this.toolbar_labelpos = toolbar_labelpos;
1918 if(button_bar || toolbar_size || toolbar_mode || toolbar_labelpos) {
1919 var toolbar = document.getElementById('toolbar_main');
1920 if(toolbar_mode) toolbar.setAttribute('mode', toolbar_mode);
1921 if(toolbar_size) toolbar.setAttribute('iconsize', toolbar_size);
1922 if(toolbar_labelpos) addCSSClass(toolbar, 'labelbelow');
1926 var x = document.getElementById('main.menu.admin.client.toolbars.current.popup');
1928 var selectitems = x.getElementsByAttribute('value',button_bar);
1929 if(selectitems.length < 1) selecteditems = x.getElementsByAttribute('value','default');
1930 if(selectitems.length > 0) selectitems[0].setAttribute('checked','true');
1935 var x = document.getElementById('main.menu.admin.client.toolbars.size.popup');
1937 var selectitems = x.getElementsByAttribute('value',toolbar_size);
1938 if(selectitems.length > 0) selectitems[0].setAttribute('checked','true');
1943 var x = document.getElementById('main.menu.admin.client.toolbars.mode.popup');
1945 var selectitems = x.getElementsByAttribute('value',toolbar_mode);
1946 if(selectitems.length > 0) selectitems[0].setAttribute('checked','true');
1950 if(toolbar_labelpos) {
1951 var x = document.getElementById('main.menu.admin.client.toolbars.label_position.popup');
1953 var selectitems = x.getElementsByAttribute('value',"under");
1954 if(selectitems.length > 0) selectitems[0].setAttribute('checked','true');
1958 // stash the available toolbar buttons for later use in the toolbar editing interface
1959 if (typeof this.data.toolbar_buttons == 'undefined') {
1960 this.data.toolbar_buttons = {};
1961 var nl = $('palette').childNodes;
1962 for (var i = 0; i < nl.length; i++) {
1963 var id = nl[i].getAttribute('templateid');
1964 var label = nl[i].getAttribute('label');
1966 this.data.toolbar_buttons[ id ] = label;
1969 this.data.stash('toolbar_buttons');
1973 alert('Error in menu.js, button_bar_init(): ' + E);
1977 'spawn_search' : function(s) {
1979 obj.error.sdump('D_TRACE', offlineStrings.getFormattedString('menu.spawn_search.msg', [js2JSON(s)]) );
1980 obj.new_patron_tab( {}, { 'doit' : 1, 'query' : js2JSON(s) } );
1983 'close_all_tabs' : function() {
1986 var count = obj.controller.view.tabs.childNodes.length;
1987 for (var i = 1; i < count; i++) obj.close_tab();
1988 setTimeout( function(){ obj.controller.view.tabs.firstChild.focus(); }, 0);
1990 obj.error.standard_unexpected_error_alert(offlineStrings.getString('menu.close_all_tabs.error'),E);
1994 'close_tab' : function (specific_idx) {
1995 var idx = specific_idx || this.controller.view.tabs.selectedIndex;
1996 var panel = this.controller.view.panels.childNodes[ idx ];
1998 var tab = this.controller.view.tabs.getItemAtIndex( idx );
1999 var id = tab.getAttribute('id');
2000 if (typeof this.tab_semaphores[id] != 'undefined') {
2001 if (this.tab_semaphores[id] > 0) {
2002 var confirmation = window.confirm(offlineStrings.getString('menu.close_tab.unsaved_data_warning'));
2003 if (!confirmation) { return; }
2004 oils_unsaved_data_P( this.tab_semaphores[id] );
2006 delete this.tab_semaphores[id];
2009 this.controller.view.tabs.removeItemAt(idx);
2010 this.controller.view.panels.removeChild(panel);
2011 if(this.controller.view.tabs.childNodes.length > idx) {
2012 this.controller.view.tabbox.selectedIndex = idx;
2015 this.controller.view.tabbox.selectedIndex = idx - 1;
2017 this.controller.view.tabscroller.ensureElementIsVisible(this.controller.view.tabs.selectedItem);
2018 this.update_all_tab_names();
2019 // Make sure we keep at least one tab open.
2020 if(this.controller.view.tabs.childNodes.length == 1) {
2025 'update_all_tab_names' : function() {
2026 var doAccessKeys = !xulG.pref.getBoolPref('open-ils.disable_accesskeys_on_tabs');
2027 for(var i = 1; i < this.controller.view.tabs.childNodes.length; ++i) {
2028 var tab = this.controller.view.tabs.childNodes[i];
2030 tab.label = i + ' ' + tab.origlabel;
2031 if(doAccessKeys && offlineStrings.testString('menu.tab' + i + '.accesskey')) {
2032 tab.accessKey = offlineStrings.getString('menu.tab' + i + '.accesskey');
2037 'command_tab' : function(event,url,params,content_params) {
2039 var myEvent = event;
2040 if(event && event.sourceEvent) myEvent = event.sourceEvent;
2041 // Note: The last event is not supposed to be myEvent in this if.
2042 if(myEvent && myEvent.explicitOriginalTarget.nodeName.match(/toolbarbutton/) && myEvent.explicitOriginalTarget.command == event.originalTarget.id) {
2043 var value = xulG.pref.getIntPref('ui.key.accelKey');
2046 newTab = myEvent.ctrlKey;
2049 newTab = myEvent.altKey;
2052 newTab = myEvent.metaKey;
2056 if(xulG.pref.getBoolPref('open-ils.toolbar.defaultnewtab')) {
2064 this.new_tab(url,params,content_params);
2067 this.set_tab(url,params,content_params);
2071 'new_tab' : function(url,params,content_params) {
2075 var max_tabs = xulG.pref.getIntPref('open-ils.window_max_tabs') || max_tabs;
2078 if(max_tabs > 0 && this.controller.view.tabs.childNodes.length > max_tabs) return false;
2079 var tab = this.w.document.createElement('tab');
2080 var panel = this.w.document.createElement('tabpanel');
2081 var tabscroller = this.controller.view.tabscroller;
2082 this.controller.view.tabs.appendChild(tab);
2083 this.controller.view.panels.appendChild(panel);
2084 tab.curindex = this.controller.view.tabs.childNodes.length - 1;
2085 if(!xulG.pref.getBoolPref('open-ils.disable_accesskeys_on_tabs')) {
2086 if(offlineStrings.testString('menu.tab' + tab.curindex + '.accesskey')) {
2087 tab.accessKey = offlineStrings.getString('menu.tab' + tab.curindex + '.accesskey');
2090 var tabs = this.controller.view.tabs;
2091 tab.addEventListener(
2095 tabscroller.ensureElementIsVisible(tab);
2098 && ( panel.firstChild.nodeName == 'iframe' || panel.firstChild.nodeName == 'browser' )
2099 && panel.firstChild.contentWindow
2101 var cw = panel.firstChild.contentWindow;
2103 'protocol' : cw.location.protocol,
2104 'hostname' : cw.location.hostname,
2105 'port' : cw.location.port,
2106 'pathname' : cw.location.pathname,
2109 obj.set_help_context(help_params);
2110 if (typeof cw.default_focus == 'function') {
2113 // an alternative to the practice above
2114 var evt = cw.document.createEvent("Events");
2115 evt.initEvent( 'tab_focus', true, true );
2116 cw.window.dispatchEvent(evt);
2119 obj.error.sdump('D_ERROR','init_tab_focus_handler: ' + js2JSON(E));
2125 if (!content_params) content_params = {};
2126 if (!params) params = {};
2127 if (!params.tab_name) params.tab_name = offlineStrings.getString('menu.new_tab.tab');
2128 if (!params.nofocus) params.focus = true; /* make focus the default */
2131 this.controller.view.tabs.selectedItem = tab;
2132 tabscroller.ensureElementIsVisible(tab);
2134 params.index = tab.curindex;
2135 this.set_tab(url,params,content_params);
2138 this.error.sdump('D_ERROR',E);
2143 'set_menu_access' : function(perms) {
2144 if(perms === false) return;
2145 var commands = document.getElementById('universal_cmds').getElementsByTagName('command');
2148 for (var i = 0; i < commands.length; i++) {
2149 if (commands[i].hasAttribute('perm')) {
2150 commandperms = commands[i].getAttribute('perm').split(' ');
2151 for (var j = 0; j < commandperms.length; j++) {
2152 if (perms[commandperms[j]]) {
2153 commands[i].setAttribute('disabled','false');
2157 commands[i].setAttribute('disabled','true');
2163 'set_menu_hotkeys' : function(hotkeyset) {
2164 this.data.stash_retrieve();
2166 var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"].
2167 getService(Components.interfaces.nsIWindowMediator);
2168 var mainwin = wm.getMostRecentWindow('eg_main');
2169 JSAN.use('util.network');
2170 var network = new util.network();
2172 if(hotkeyset) { // Explicit request
2174 this.data.current_hotkeyset = hotkeyset;
2175 this.data.stash('current_hotkeyset');
2176 // Then iterate over windows
2177 var windowManager = Components.classes["@mozilla.org/appshell/window-mediator;1"].getService();
2178 var windowManagerInterface = windowManager.QueryInterface(Components.interfaces.nsIWindowMediator);
2179 var enumerator = windowManagerInterface.getEnumerator('eg_menu');
2182 while ( w = enumerator.getNext() ) {
2184 w.g.menu.set_menu_hotkeys();
2187 else { // Non-explicit request?
2188 if(this.data.current_hotkeyset) // Previous hotkeyset?
2189 hotkeyset = this.data.current_hotkeyset; // Use it
2190 else { // No previous? We need to decide on one!
2191 // Load the list so we know if what we are being asked to load is valid.
2192 var hotkeysets = mainwin.load_hotkey_sets();
2193 if(!hotkeysets) return; // No sets = nothing to load. Which is probably an error, but meh.
2194 hotkeysets.has = function(test) {
2195 for(i = 0; i < this.length; i++) {
2196 if(this[i] == test) return true;
2200 // Try workstation (pref)
2201 hotkeyset = xulG.pref.getCharPref('open-ils.menu.hotkeyset');
2203 // Nothing or nothing valid?
2204 if(!hotkeyset || !hotkeysets.has(hotkeyset)) {
2205 hotkeyset = this.data.hash.aous['ui.general.hotkeyset'];
2207 // STILL nothing? Try Default.
2208 if(!hotkeyset || !hotkeysets.has(hotkeyset)) {
2209 if(hotkeysets.has('Default'))
2210 hotkeyset = 'Default';
2214 // And save whatever we are using.
2215 this.data.current_hotkeyset = hotkeyset;
2216 this.data.stash('current_hotkeyset');
2219 // Clear out all the old hotkeys
2220 var keyset = document.getElementById('menu_frame_keys');
2221 var main_menu = document.getElementById('main_menubar');
2222 if(keyset.hasChildNodes()) {
2223 var menuitems = main_menu.getElementsByAttribute('key','*');
2224 while(menuitems.length > 0) {
2225 var menuitem = menuitems[0];
2226 menuitem.removeAttribute('key');
2227 // Trick/force mozilla to re-evaluate the menuitem
2228 // If you want to take this trick for use *anywhere* in *any* project, regardless of licensing, please do
2229 // Because it was a PITA to figure out
2230 menuitem.style.display = 'none'; // Hide the item to force menu to clear spot
2231 menuitem.setAttribute('acceltext', ''); // Set acceltext to blank string outright
2232 menuitem.removeAttribute('acceltext'); // Remove acceltext to clear out hotkey hint text
2233 menuitem.parentNode.openPopupAtScreen(0,0,false); // Tell menupopup to redraw itself
2234 menuitem.parentNode.hidePopup(); // And then make it go away right away.
2235 menuitem.style.removeProperty('display'); // Restore normal css display
2237 while(keyset.hasChildNodes()) keyset.removeChild(keyset.childNodes[0]);
2239 keyset_lines = mainwin.get_hotkey_array(hotkeyset);
2240 // Next, fill the keyset
2241 for(var line = 0; line < keyset_lines.length; line++) {
2242 // Create and populate our <key>
2243 var key_node = document.createElement('key');
2244 key_node.setAttribute('id',keyset_lines[line][0] + "_key");
2245 key_node.setAttribute('command',keyset_lines[line][0]);
2246 key_node.setAttribute('modifiers',keyset_lines[line][1]);
2247 // If keycode starts with VK_ we assume it is a key code.
2248 // Key codes go in the keycode attribute
2249 // Regular keys (like "i") go in the key attribute
2250 if(keyset_lines[line][2].match(/^VK_/))
2251 key_node.setAttribute('keycode',keyset_lines[line][2]);
2253 key_node.setAttribute('key',keyset_lines[line][2]);
2254 // If a fourth option was specified, set keytext to it.
2255 if(keyset_lines[line][3])
2256 key_node.setAttribute('keytext',keyset_lines[line][3]);
2257 // Add the new node to the DOM
2258 keyset.appendChild(key_node);
2259 // And populate all the menu items that should now display it
2260 var menuitems = main_menu.getElementsByAttribute('command',keyset_lines[line][0]);
2261 for(var i = 0; i < menuitems.length; i++) {
2262 menuitems[i].setAttribute('key', keyset_lines[line][0] + "_key");
2263 // Trick/force mozilla to re-evaluate the menuitem
2264 menuitems[i].style.display = 'none'; // Hide the item to force menu to clear spot
2265 menuitems[i].parentNode.openPopupAtScreen(0,0,false); // Tell menupopup to redraw itself
2266 menuitems[i].parentNode.hidePopup(); // And then make it go away right away
2267 menuitems[i].style.removeProperty('display'); // Restore normal css display
2270 // Force reload of keyset cache?
2271 keyset.parentNode.insertBefore(keyset, keyset.nextSibling);
2272 // If no keys, disable ability to toggle hotkeys (because why bother?)
2273 var x = document.getElementById('cmd_hotkeys_toggle');
2275 if(keyset.hasChildNodes())
2276 x.removeAttribute('disabled');
2278 x.setAttribute('disabled', 'true');
2280 // Select the hotkey set in the menu
2281 // This ensures that first window load OR remote window update shows properly
2282 var hotkeylist = document.getElementById('main.menu.admin.client.hotkeys.current.popup');
2283 var selectitems = hotkeylist.getElementsByAttribute('value',hotkeyset);
2284 if(selectitems.length > 0) selectitems[0].setAttribute('checked','true');
2288 'node' : document.getElementById('page_progress'),
2290 document.getElementById('page_progress').setAttribute('mode','undetermined');
2292 'off' : function() {
2293 document.getElementById('page_progress').setAttribute('mode','determined');
2295 'tooltip' : function(text) {
2296 if (text || text == '') {
2297 document.getElementById('page_progress').setAttribute('tooltiptext',text);
2299 return document.getElementById('page_progress').getAttribute('tooltiptext');
2304 'inc' : function(app,method) {
2306 var m = document.getElementById('network_progress');
2307 var count = 1 + Number( m.getAttribute('count') );
2308 m.setAttribute('mode','undetermined');
2309 m.setAttribute('count', count);
2310 var rows = document.getElementById('network_progress_rows');
2311 var row = document.getElementById('network_progress_tip_'+app+'_'+method);
2313 row = document.createElement('row'); row.setAttribute('id','network_progress_tip_'+app+'_'+method);
2314 var a = document.createElement('label'); a.setAttribute('value','App:');
2315 var b = document.createElement('label'); b.setAttribute('value',app);
2316 var c = document.createElement('label'); c.setAttribute('value','Method:');
2317 var d = document.createElement('label'); d.setAttribute('value',method);
2318 var e = document.createElement('label'); e.setAttribute('value','Total:');
2319 var f = document.createElement('label'); f.setAttribute('value','0');
2320 f.setAttribute('id','network_progress_tip_total_'+app+'_'+method);
2321 var g = document.createElement('label'); g.setAttribute('value','Outstanding:');
2322 var h = document.createElement('label'); h.setAttribute('value','0');
2323 h.setAttribute('id','network_progress_tip_out_'+app+'_'+method);
2324 row.appendChild(a); row.appendChild(b); row.appendChild(c);
2325 row.appendChild(d); row.appendChild(e); row.appendChild(f);
2326 row.appendChild(g); row.appendChild(h); rows.appendChild(row);
2328 var total = document.getElementById('network_progress_tip_total_'+app+'_'+method);
2330 total.setAttribute('value', 1 + Number( total.getAttribute('value') ));
2332 var out = document.getElementById('network_progress_tip_out_'+app+'_'+method);
2334 out.setAttribute('value', 1 + Number( out.getAttribute('value') ));
2337 dump('network_meter.inc(): ' + E + '\n');
2340 'dec' : function(app,method) {
2342 var m = document.getElementById('network_progress');
2343 var count = -1 + Number( m.getAttribute('count') );
2344 if (count < 0) count = 0;
2345 if (count == 0) m.setAttribute('mode','determined');
2346 m.setAttribute('count', count);
2347 var out = document.getElementById('network_progress_tip_out_'+app+'_'+method);
2349 out.setAttribute('value', -1 + Number( out.getAttribute('value') ));
2352 dump('network_meter.dec(): ' + E + '\n');
2356 'set_patron_tab' : function(params,content_params,event) {
2358 var horizontal_interface = String( obj.data.hash.aous['ui.circ.patron_summary.horizontal'] ) == 'true';
2359 var url = obj.url_prefix( horizontal_interface ? 'XUL_PATRON_HORIZ_DISPLAY' : 'XUL_PATRON_DISPLAY' );
2360 obj.command_tab(event,url,params ? params : {},content_params ? content_params : {});
2362 'new_patron_tab' : function(params,content_params) {
2364 var horizontal_interface = String( obj.data.hash.aous['ui.circ.patron_summary.horizontal'] ) == 'true';
2365 var url = obj.url_prefix( horizontal_interface ? 'XUL_PATRON_HORIZ_DISPLAY' : 'XUL_PATRON_DISPLAY' );
2366 obj.new_tab(url,params ? params : {},content_params ? content_params : {});
2368 'volume_item_creator' : function(params) {
2371 var unified_interface = String( obj.data.hash.aous['ui.unified_volume_copy_editor'] ) == 'true';
2372 if (unified_interface) {
2373 var horizontal_interface = String( obj.data.hash.aous['ui.cat.volume_copy_editor.horizontal'] ) == 'true';
2374 url = obj.url_prefix( horizontal_interface ? 'XUL_VOLUME_COPY_CREATOR_HORIZONTAL' : 'XUL_VOLUME_COPY_CREATOR' );
2376 url = obj.url_prefix('XUL_VOLUME_COPY_CREATOR_ORIGINAL');
2380 if (params && params.copy_id) {
2381 // if accessing directly from the embedded catalog,
2382 // load the copy/volume data here so the catalog
2385 JSAN.use('util.network');
2386 var net = new util.network();
2387 var copies = net.simple_request(
2388 'FM_ACP_FLESHED_BATCH_RETRIEVE', [[params.copy_id]]);
2389 var copy = copies[0];
2390 var volume = net.simple_request(
2391 'FM_ACN_RETRIEVE.authoritative', [copy.call_number()]);
2392 copy.call_number(volume);
2393 params.existing_copies = [copy];
2395 alert('cannot fetch copy ' + E);
2399 var w = obj.new_tab(
2401 { 'tab_name' : document.getElementById('offlineStrings').getString('staff.cat.create_or_rebarcode_items') },
2405 'holdings_maintenance_tab' : function(docid,params,content_params) {
2407 if (!content_params) {
2408 content_params = {};
2411 content_params['docid'] = docid;
2413 var url = obj.url_prefix('XUL_COPY_VOLUME_BROWSE');
2414 obj.new_tab(url,params || {}, content_params);
2416 'get_new_session' : function(params) {
2418 if (!params) { params = {}; }
2419 JSAN.use('util.network'); var net = new util.network();
2420 var result = net.get_new_session(null,{'url_prefix':obj.url_prefix},!params.operator_change);
2421 if (typeof params.callback == 'function') {
2422 return params.callback( result, ses(), ses('authtime') );
2426 'set_help_context' : function(params) {
2428 if (!params) { params = {}; }
2429 if (params.protocol == 'chrome:') { return; } /* not supported */
2430 var help_btn = document.getElementById('help_btn');
2432 dump('set_help_context: ' + js2JSON(params) + '\n');
2433 if (params.protocol) { help_btn.setAttribute('protocol', params.protocol); }
2434 if (params.hostname) { help_btn.setAttribute('hostname', params.hostname); }
2435 if (params.port) { help_btn.setAttribute('port', params.port); }
2436 if (params.pathname) { help_btn.setAttribute('pathname', params.pathname); }
2437 if (params.src) { help_btn.setAttribute('src', params.src); }
2441 'tab_semaphores' : {},
2443 'set_tab' : function(url,params,content_params) {
2445 if (!url) url = 'oils://remote/xul/server/';
2446 if (!url.match(/:\/\//) && !url.match(/^data:/)) url = urls.remote + url;
2447 if (!params) params = {};
2448 if (!content_params) content_params = {};
2449 var idx = this.controller.view.tabs.selectedIndex;
2450 if (params && typeof params.index != 'undefined') idx = params.index;
2451 var tab = this.controller.view.tabs.childNodes[ idx ];
2453 var id = tab.getAttribute('id');
2455 if (typeof obj.tab_semaphores[id] != 'undefined') {
2456 if (obj.tab_semaphores[id] > 0) {
2457 var confirmation = window.confirm(offlineStrings.getString('menu.replace_tab.unsaved_data_warning'));
2458 if (!confirmation) { return; }
2459 oils_unsaved_data_P( obj.tab_semaphores[id] );
2461 delete obj.tab_semaphores[id];
2464 var unique_id = idx + ':' + new Date();
2465 tab.setAttribute('id',unique_id);
2466 if (params.focus) tab.focus();
2467 var panel = this.controller.view.panels.childNodes[ idx ];
2468 while ( panel.lastChild ) panel.removeChild( panel.lastChild );
2469 //We need to set tab.marc_edit_changed to false here, so if the user goes
2470 //back to the MARC edit tab from a newly retrieved record when they had
2471 //previously edited the record that used to be in the tab then
2472 //the tab will not be relocked
2473 tab.marc_edit_changed = false;
2475 content_params.is_tab_locked = function() {
2476 dump('is_tab_locked\n');
2477 var id = tab.getAttribute('id');
2478 if (typeof obj.tab_semaphores[id] == 'undefined') {
2481 return obj.tab_semaphores[id] > 0;
2483 content_params.lock_tab = function() {
2485 var id = tab.getAttribute('id');
2486 if (typeof obj.tab_semaphores[id] == 'undefined') {
2487 obj.tab_semaphores[id] = 0;
2489 obj.tab_semaphores[id]++;
2490 oils_unsaved_data_V();
2491 return obj.tab_semaphores[id];
2493 content_params.unlock_tab = function() {
2494 dump('unlock_tab\n');
2495 var id = tab.getAttribute('id');
2496 if (typeof obj.tab_semaphores[id] == 'undefined') {
2497 obj.tab_semaphores[id] = 0;
2500 //If we are in marc edit, then unlock is only calld when saving
2501 //the edits. So, drop all locks in this case.
2502 //Otherwise leave the code as is because I am not sure how other parts
2503 //of the staff client interact with the tab locking
2504 if (tab.in_marc_edit) {
2505 obj.tab_semaphores[id] = 0;
2506 //allow multiple locks again, so if we
2507 //return to marc edit we can put a lock on it again
2508 tab.marc_edit_allow_multiple_locks = true;
2510 obj.tab_semaphores[id]--;
2512 if (obj.tab_semaphores[id] < 0) { obj.tab_semaphores[id] = 0; }
2513 oils_unsaved_data_P();
2514 return obj.tab_semaphores[id];
2516 content_params.inspect_tab = function() {
2517 var id = tab.getAttribute('id');
2518 return 'id = ' + id + ' semaphore = ' + obj.tab_semaphores[id];
2520 content_params.new_tab = function(a,b,c) { return obj.new_tab(a,b,c); };
2521 content_params.set_tab = function(a,b,c) { return obj.set_tab(a,b,c); };
2522 content_params.open_external = function(a) { return obj.open_external(a); };
2523 content_params.close_tab = function() { return obj.close_tab(); };
2524 content_params.new_patron_tab = function(a,b) { return obj.new_patron_tab(a,b); };
2525 content_params.set_patron_tab = function(a,b) { return obj.set_patron_tab(a,b); };
2526 content_params.volume_item_creator = function(a) { return obj.volume_item_creator(a); };
2527 content_params.get_new_session = function(a) { return obj.get_new_session(a); };
2528 content_params.holdings_maintenance_tab = function(a,b,c) { return obj.holdings_maintenance_tab(a,b,c); };
2529 content_params.set_tab_name = function(name) { tab.label = tab.curindex + ' ' + name; tab.origlabel = name; };
2530 content_params.set_help_context = function(params) { return obj.set_help_context(params); };
2531 content_params.open_chrome_window = function(a,b,c) { return xulG.window.open(a,b,c); };
2532 content_params.url_prefix = function(url,secure) { return obj.url_prefix(url,secure); };
2533 content_params.network_meter = obj.network_meter;
2534 content_params.page_meter = obj.page_meter;
2535 content_params.get_barcode = obj.get_barcode;
2536 content_params.get_barcode_and_settings = obj.get_barcode_and_settings;
2537 content_params.render_toolbar_layout = function(layout) { return obj.render_toolbar_layout(layout); };
2538 content_params.set_statusbar = function(slot,text,tooltiptext,click_handler) {
2539 var e = document.getElementById('statusbarpanel'+slot);
2541 var p = e.parentNode;
2542 var sbp = document.createElement('statusbarpanel');
2543 sbp.setAttribute('id','statusbarpanel'+slot);
2544 p.replaceChild(sbp,e); // destroy and replace the statusbarpanel as a poor man's way of clearing event handlers
2546 sbp.setAttribute('label',text);
2548 sbp.setAttribute('tooltiptext',tooltiptext);
2550 if (click_handler) {
2551 sbp.addEventListener(
2559 content_params.chrome_xulG = xulG;
2560 content_params._data = xulG._data;
2561 if (params && params.tab_name) content_params.set_tab_name( params.tab_name );
2565 if (typeof params.browser == 'undefined') params.browser = false;
2566 if (params.browser) {
2568 frame = this.w.document.createElement('browser');
2569 frame.setAttribute('flex','1');
2570 frame.setAttribute('type','content');
2571 frame.setAttribute('autoscroll','false');
2572 frame.setAttribute('id','frame_'+obj.id_incr);
2573 panel.appendChild(frame);
2575 dump('creating browser with src = ' + url + '\n');
2576 JSAN.use('util.browser');
2577 var b = new util.browser();
2582 'alt_print' : false,
2583 'browser_id' : 'frame_'+obj.id_incr,
2584 'passthru_content_params' : content_params,
2591 frame = this.w.document.createElement('iframe');
2592 frame.setAttribute('flex','1');
2593 panel.appendChild(frame);
2594 dump('creating iframe with src = ' + url + '\n');
2595 frame.setAttribute('src',url);
2597 var cw = frame.contentWindow;
2598 if (typeof cw.wrappedJSObject != 'undefined') cw = cw.wrappedJSObject;
2600 cw.xulG = content_params;
2601 cw.addEventListener(
2605 if (typeof cw.help_context_set_locally == 'undefined') {
2607 'protocol' : cw.location.protocol,
2608 'hostname' : cw.location.hostname,
2609 'port' : cw.location.port,
2610 'pathname' : cw.location.pathname,
2613 obj.set_help_context(help_params);
2615 if (typeof cw.default_focus == 'function') {
2618 // an alternative to the practice above
2619 var evt = cw.document.createEvent("Events");
2620 evt.initEvent( 'tab_focus', true, true );
2621 cw.window.dispatchEvent(evt);
2623 obj.error.sdump('D_ERROR', 'main.menu, set_tab, onload: ' + E);
2626 if (typeof params.on_tab_load == 'function') {
2627 params.on_tab_load(cw);
2630 obj.error.sdump('D_ERROR', 'main.menu, set_tab, onload #2: ' + E);
2636 this.error.sdump('D_ERROR', 'main.menu: ' + E);
2640 this.error.sdump('D_ERROR', 'main.menu:2: ' + E);
2641 alert(offlineStrings.getString('menu.set_tab.error'));
2647 'open_external' : function(url) {
2648 // first construct an nsIURI object using the ioservice
2649 var ioservice = Components.classes["@mozilla.org/network/io-service;1"]
2650 .getService(Components.interfaces.nsIIOService);
2652 var uriToOpen = ioservice.newURI(url, null, null);
2654 var extps = Components.classes["@mozilla.org/uriloader/external-protocol-service;1"]
2655 .getService(Components.interfaces.nsIExternalProtocolService);
2658 extps.loadURI(uriToOpen, null);
2661 'get_barcode' : function(window, context, barcode) {
2662 JSAN.use('util.network');
2663 JSAN.use('util.sound');
2665 // Depending on where we were called from data can be found in multiple ways
2667 if(this.data) data = this.data;
2668 else if(xulG.data) data = xulG.data;
2670 JSAN.use('util.data');
2671 data = new util.data();
2673 data.stash_retrieve();
2675 var network = new util.network();
2676 var sound = new util.sound();
2678 // Should return an array. Or an error.
2679 var r = network.simple_request('GET_BARCODES', [ ses(), data.list.au[0].ws_ou(), context, barcode ]);
2684 // Top-level error, likely means bad session or no STAFF_LOGIN permission.
2685 if(typeof r.ilsevent != 'undefined') {
2686 // Hand it off to the caller.
2690 // No results? Return false
2691 if(r.length == 0) return false;
2695 // Return it. If it is an error the caller should deal with it.
2699 // At this point we have more than one result.
2700 // Check to see what we got.
2701 var result_filter = {};
2703 var unique_count = 0;
2704 var found_errors = false;
2708 // Check each result.
2709 for(var i = 0; i < len; ++i) {
2710 // If it is an error
2711 if(typeof r[i].ilsevent != 'undefined') {
2712 // Make note that we found errors
2713 found_errors = true;
2714 // Grab the error into a string
2715 errors += js2JSON(r[i]);
2718 // Otherwise, record the type/id combo for later
2719 var type = r[i].type;
2721 var barcode = r[i].barcode;
2722 if(!result_filter[type]) result_filter[type] = {};
2723 if(!result_filter[type][id]) {
2725 result_filter[type][id] = [];
2727 result_filter[type][id].push(barcode);
2732 // Only errors? Return the first one.
2733 if(unique_count == 0 && found_errors == true) {
2737 // No errors, one (unique) result? Return it.
2738 if(unique_count == 1 && found_errors == false) return valid_r[0];
2740 // For possible debugging, dump the errors.
2741 if(found_errors) dump(errors);
2743 // Still here? Must need to have the user pick.
2744 if(!xulG.url_prefix) xulG.url_prefix = url_prefix; // Make util.window happy
2745 JSAN.use('util.window');
2746 var win = new util.window();
2747 var url = url_prefix('XUL_FANCY_PROMPT');
2748 var title = offlineStrings.getString('barcode_choice.title');
2749 var xml = '<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" xmlns:html="http://www.w3.org/1999/xhtml" flex="1">';
2750 xml += '<groupbox flex="1" style="overflow: auto; border: solid thin;"><caption label="' + title + '"/>';
2751 xml += '<description style="-moz-user-select: text; -moz-user-focus: normal; font-size: large">' + offlineStrings.getString('barcode_choice.prompt') + '</description>';
2752 if(found_errors) // Let the user know that one or more possible answers errored out.
2753 xml += '<description style="-moz-user=select: text; -moz-user-focus: normal; font-size: large">' + offlineStrings.getString('barcode_choice.errors_found') + '</description>';
2754 xml += '</groupbox><groupbox><caption label="' + offlineStrings.getString('barcode_choice.choice_label') + '"/><vbox>';
2756 len = valid_r.length;
2757 // Look at all the non-error answers we got
2758 for(var i = 0; i < len; ++i) {
2759 // If we still have a filtered answer, display a button.
2760 if(result_filter[valid_r[i].type][valid_r[i].id]) {
2761 var result_data = false;
2762 var barcodes = result_filter[valid_r[i].type][valid_r[i].id];
2763 var barcodes_assembled = barcodes.shift();
2764 var button_label = '';
2765 while(barcodes.length > 0) // Join any secondary barcodes found together
2766 barcodes_assembled = offlineStrings.getFormattedString('barcode_choice.join_barcodes', [barcodes_assembled, barcodes.shift()]);
2769 result_data = network.simple_request('BLOB_AU_PARTS_RETRIEVE',
2770 [ ses() , valid_r[i].id, ['family_name', 'first_given_name', 'second_given_name', 'home_ou' ] ]);
2771 button_label = offlineStrings.getFormattedString('barcode_choice.actor',
2772 [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()]);
2775 result_data = network.simple_request('FM_ACP_DETAILS_VIA_BARCODE', [ ses(), valid_r[i].barcode ]);
2776 // Note: This falls through intentionally.
2779 if(!result_data) // If we fell through this should be set already.
2780 result_data = network.simple_request('FM_ACP_DETAILS', [ ses(), valid_r[i].id ]);
2781 button_label = offlineStrings.getFormattedString('barcode_choice.asset',
2782 [barcodes_assembled, result_data.mvr.title(), data.hash.aou[ result_data.copy.circ_lib() ].name(), data.hash.aou[ result_data.copy.circ_lib() ].shortname()]);
2785 r[i].data = result_data;
2787 // This ensures we only show each unique id once
2788 delete result_filter[valid_r[i].type][valid_r[i].id];
2790 // If we have more than one context this should label each entry with where it came from
2791 // Likely most useful for distinguishing assets from bookings
2792 if(context != valid_r[i].type && offlineStrings.testString('barcode_choice.' + valid_r[i].type + '_label'))
2793 button_label = offlineStrings.getFormattedString('barcode_choice.' + valid_r[i].type + '_label', [button_label]);
2795 xml += '<button label="' + button_label.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"') + '" name="fancy_submit" value="' + i + '"/>';
2798 xml += '<button label="' + offlineStrings.getString('barcode_choice.none') + '" name="fancy_cancel"/>';
2799 xml += '</vbox></groupbox></vbox>';
2800 var fancy_prompt_data = win.open( url, 'fancy_prompt', 'chrome,resizable,modal,width=500,height=500', { 'xml' : xml, 'title' : title, 'sound' : 'bad' } );
2801 if(fancy_prompt_data.fancy_status == 'complete')
2802 return valid_r[fancy_prompt_data.fancy_submit];
2804 // user_false is used to indicate the user said "None of the above" to avoid fall-through erroring later.
2805 return "user_false";
2808 'get_barcode_and_settings' : function(window, barcode, settings_only) {
2809 JSAN.use('util.network');
2810 if(!settings_only) {
2811 // We need to double-check the barcode for completion and such.
2812 var new_barcode = xulG.get_barcode(window, 'actor', barcode);
2813 if(new_barcode == "user_false") return;
2814 // No error means we have a (hopefully valid) completed barcode to use.
2815 // Otherwise, fall through to other methods of checking
2816 if(typeof new_barcode.ilsevent == 'undefined')
2817 barcode = new_barcode.barcode;
2821 var network = new util.network();
2822 // We have a barcode! Time to load settings.
2823 // First, we need the user ID
2824 var user = network.simple_request('FM_AU_RETRIEVE_VIA_BARCODE', [ ses(), barcode ]);
2825 if(user.ilsevent != undefined || user.textcode != undefined)
2828 for(var i = 0; i < user.settings().length; i++) {
2829 settings[user.settings()[i].name()] = JSON2js(user.settings()[i].value());
2831 if(!settings['opac.default_phone'] && user.day_phone()) settings['opac.default_phone'] = user.day_phone();
2832 if(!settings['opac.hold_notify'] && settings['opac.hold_notify'] !== '') settings['opac.hold_notify'] = 'email:phone';
2833 // Taken from patron/util.js format_name
2834 var patron_name = ( user.prefix() ? user.prefix() + ' ' : '') +
2835 user.family_name() + ', ' +
2836 user.first_given_name() + ' ' +
2837 ( user.second_given_name() ? user.second_given_name() + ' ' : '' ) +
2838 ( user.suffix() ? user.suffix() : '');
2839 return {"barcode": barcode, "pickup_lib" : user.home_ou(), "settings" : settings, "user_email" : user.email(), "patron_name" : patron_name};
2842 'sort_menu' : function(menu, recurse) {
2843 var curgroup = new Array();
2846 for (var itemid = 0; itemid < menu.firstChild.children.length; itemid++) {
2847 var item = menu.firstChild.children[itemid];
2849 if (item.getAttribute('forceFirst')) {
2850 item.setAttribute('ordinal', curstart);
2854 if (item.nodeName == 'menuseparator') {
2855 this.sort_menu_items(curgroup, curstart);
2856 item.setAttribute('ordinal', curordinal);
2857 curstart = curordinal + 1;
2858 curgroup = new Array();
2861 if (item.nodeName == 'menu' && recurse) {
2862 this.sort_menu(item, recurse);
2864 curgroup.push(item);
2866 this.sort_menu_items(curgroup, curstart);
2869 'sort_menu_items' : function(itemgroup, start) {
2871 var sorted = itemgroup.sort(function(a,b) {
2872 var labelA = a.getAttribute('label').toUpperCase();
2873 var labelB = b.getAttribute('label').toUpperCase();
2874 return labelA.localeCompare(labelB);
2876 for(var item = 0; item < sorted.length; item++) {
2877 sorted[item].setAttribute('ordinal', curpos++);
2881 'observe' : function(subject, topic, data) {
2882 if (topic != "nsPref:changed") {
2887 case 'oils.copy_editor.copy_location_name_first':
2888 var cl_first = xulG.pref.getBoolPref('oils.copy_editor.copy_location_name_first');
2889 var menuitems = document.getElementsByAttribute('command','cmd_copy_editor_copy_location_first_toggle');
2890 for(var i = 0; i < menuitems.length; i++)
2891 menuitems[i].setAttribute('checked', cl_first ? 'true' : 'false');
2896 'stop_observing' : function() {
2897 xulG.pref.removeObserver('oils.copy_editor.*', this);
2900 'render_toolbar' : function(button_bar) {
2903 this.last_sanctioned_toolbar = button_bar;
2905 var toolbar = document.getElementById('toolbar_main');
2907 if (button_bar == 'none' || typeof button_bar == 'undefined') {
2908 toolbar.setAttribute('hidden','true');
2914 JSAN.use('util.widgets'); JSAN.use('util.functional');
2915 var def = this.data.hash.atb[ button_bar ];
2916 if (!def) def = util.functional.find_list( this.data.list.atb, function(e) { return e.label == button_bar; } );
2918 dump('Could not find layout for specified toolbar. Defaulting to a stock toolbar.\n');
2919 layout = ["circ_checkout","circ_checkin","toolbarseparator","search_opac","copy_status","toolbarseparator","patron_search","patron_register","toolbarspacer","hotkeys_toggle"];
2921 layout = JSON2js(def.layout());
2924 this.render_toolbar_layout(layout);
2927 alert('Error in menu.js, render_toolbar('+button_bar+'): ' + E);
2931 'render_toolbar_layout' : function(layout) {
2935 this.data.stash_retrieve();
2936 this.render_toolbar( this.last_sanctioned_toolbar );
2940 var toolbar = document.getElementById('toolbar_main');
2942 // destroy existing toolbar
2943 util.widgets.remove_children(toolbar);
2946 for (var i = 0; i < layout.length; i++) {
2948 if (e.match('toolbarseparator')) {
2949 toolbar.appendChild( document.createElement('toolbarseparator') );
2950 } else if (e.match('toolbarspacer')) {
2951 var spacer = document.createElement('toolbarspacer');
2952 spacer.setAttribute('flex','1');
2953 toolbar.appendChild( spacer );
2955 var templates = $('palette').getElementsByAttribute('templateid',e);
2956 var template = templates.length > 0 ? templates[0] : null;
2958 var clone = template.cloneNode(true);
2959 toolbar.appendChild( clone );
2961 var label = document.createElement('label');
2962 label.setAttribute('value',e);
2963 toolbar.appendChild( label );
2967 toolbar.setAttribute('hidden','false');
2970 alert('Error in menu.js, render_toolbar_layout('+layout+'): ' + E);
2975 dump('exiting main/menu.js\n');