From e14c6e1a64058b45960a0a3a81d82468dafcdef9 Mon Sep 17 00:00:00 2001 From: phasefx Date: Tue, 19 Apr 2011 15:53:41 +0000 Subject: [PATCH] Menu Hotkeys and Toolbars Dynamic Hotkey sets New cataloging toolbar New updates to circ toolbar New menu items and updates to menus in admin menu area Toolbar/hotkey settings can be saved to workstation prefs from admin -> workstation administration Update org unit setting for button_bar to be a string, circ or cat by default to pick those two toolbars Author: Thomas Berezansky Signed-off-by: Thomas Berezansky Signed-off-by: Jason Etheridge git-svn-id: svn://svn.open-ils.org/ILS/branches/rel_2_1@20209 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- Open-ILS/src/sql/Pg/950.data.seed-values.sql | 7 +- Open-ILS/src/sql/Pg/upgrade/XXXX.client_menus.sql | 14 + Open-ILS/web/opac/locale/en-US/lang.dtd | 35 ++- .../staff_client/chrome/content/auth/controller.js | 2 + .../xul/staff_client/chrome/content/main/main.js | 64 ++++ .../xul/staff_client/chrome/content/main/menu.js | 333 ++++++++++++++++++++- .../chrome/content/main/menu_frame_menus.xul | 156 ++++++---- .../chrome/content/main/menu_frame_overlay.xul | 139 +++++++-- .../xul/staff_client/chrome/content/util/file.js | 4 + .../staff_client/chrome/content/util/network.js | 1 + .../chrome/locale/en-US/offline.properties | 2 + Open-ILS/xul/staff_client/chrome/skin/global.css | 62 ++++ .../chrome/skin/hotkeys/Default.keyset | 20 ++ .../chrome/skin/hotkeys/Minimal.keyset | 7 + .../staff_client/chrome/skin/hotkeys/None.keyset | 1 + .../xul/staff_client/chrome/skin/hotkeys/README | 33 ++ .../media/images/Arrow-rightup-small_toolbar.png | Bin 0 -> 7475 bytes .../skin/media/images/HILLBLU_famiglia_toolbar.png | Bin 0 -> 6888 bytes .../skin/media/images/HILLBLU_indici_toolbar.png | Bin 0 -> 6813 bytes .../skin/media/images/HILLBLU_lente_toolbar.png | Bin 0 -> 6876 bytes .../skin/media/images/HILLBLU_libro_toolbar.png | Bin 0 -> 6581 bytes .../skin/media/images/Search_Items_toolbar.png | Bin 0 -> 7646 bytes .../chrome/skin/media/images/center_toolbar.png | Bin 0 -> 7998 bytes .../skin/media/images/hotkeys_disable_toolbar.png | Bin 0 -> 9011 bytes .../chrome/skin/media/images/licenses.txt | 25 +- .../xul/staff_client/defaults/preferences/prefs.js | 8 + 26 files changed, 807 insertions(+), 106 deletions(-) create mode 100644 Open-ILS/src/sql/Pg/upgrade/XXXX.client_menus.sql create mode 100644 Open-ILS/xul/staff_client/chrome/skin/hotkeys/Default.keyset create mode 100644 Open-ILS/xul/staff_client/chrome/skin/hotkeys/Minimal.keyset create mode 100644 Open-ILS/xul/staff_client/chrome/skin/hotkeys/None.keyset create mode 100644 Open-ILS/xul/staff_client/chrome/skin/hotkeys/README create mode 100644 Open-ILS/xul/staff_client/chrome/skin/media/images/Arrow-rightup-small_toolbar.png create mode 100644 Open-ILS/xul/staff_client/chrome/skin/media/images/HILLBLU_famiglia_toolbar.png create mode 100644 Open-ILS/xul/staff_client/chrome/skin/media/images/HILLBLU_indici_toolbar.png create mode 100644 Open-ILS/xul/staff_client/chrome/skin/media/images/HILLBLU_lente_toolbar.png create mode 100644 Open-ILS/xul/staff_client/chrome/skin/media/images/HILLBLU_libro_toolbar.png create mode 100644 Open-ILS/xul/staff_client/chrome/skin/media/images/Search_Items_toolbar.png create mode 100644 Open-ILS/xul/staff_client/chrome/skin/media/images/center_toolbar.png create mode 100644 Open-ILS/xul/staff_client/chrome/skin/media/images/hotkeys_disable_toolbar.png diff --git a/Open-ILS/src/sql/Pg/950.data.seed-values.sql b/Open-ILS/src/sql/Pg/950.data.seed-values.sql index 4aeecccf3d..c60998f00f 100644 --- a/Open-ILS/src/sql/Pg/950.data.seed-values.sql +++ b/Open-ILS/src/sql/Pg/950.data.seed-values.sql @@ -1885,7 +1885,12 @@ INSERT into config.org_unit_setting_type ( 'ui.general.button_bar', oils_i18n_gettext('ui.general.button_bar', 'Button bar', 'coust', 'label'), oils_i18n_gettext('ui.general.button_bar', 'Button bar', 'coust', 'description'), - 'bool'), + 'string'), + +( 'ui.general.hotkeyset', + oils_i18n_gettext('ui.general.hotkeyset', 'Default Hotkeyset', 'coust', 'label'), + oils_i18n_gettext('ui.general.hotkeyset', 'Default Hotkeyset for clients (filename without the .keyset)', 'coust', 'description'), + 'string'), ( 'circ.hold_shelf_status_delay', oils_i18n_gettext('circ.hold_shelf_status_delay', 'Hold Shelf Status Delay', 'coust', 'label'), diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.client_menus.sql b/Open-ILS/src/sql/Pg/upgrade/XXXX.client_menus.sql new file mode 100644 index 0000000000..fd642c15bf --- /dev/null +++ b/Open-ILS/src/sql/Pg/upgrade/XXXX.client_menus.sql @@ -0,0 +1,14 @@ +BEGIN; + +INSERT INTO config.upgrade_log (version) VALUES ('XXXX'); + +UPDATE config.org_unit_setting_type SET datatype = 'string' WHERE name = 'ui.general.button_bar'; + +INSERT INTO config.org_unit_setting_type ( name, label, description, datatype) VALUES ('ui.general.hotkeyset', 'Default Hotkeyset', 'Default Hotkeyset for clients (filename without the .keyset)', 'string'); + +UPDATE actor.org_unit_setting SET value='"circ"' WHERE name = 'ui.general.button_bar' AND value='true'; + +UPDATE actor.org_unit_setting SET value='"none"' WHERE name = 'ui.general.button_bar' AND value='false'; + +COMMIT; + diff --git a/Open-ILS/web/opac/locale/en-US/lang.dtd b/Open-ILS/web/opac/locale/en-US/lang.dtd index ef4c6cc567..fb7e927321 100644 --- a/Open-ILS/web/opac/locale/en-US/lang.dtd +++ b/Open-ILS/web/opac/locale/en-US/lang.dtd @@ -660,6 +660,9 @@ + + + @@ -672,6 +675,10 @@ + + + + @@ -805,6 +812,32 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -827,8 +860,6 @@ - - diff --git a/Open-ILS/xul/staff_client/chrome/content/auth/controller.js b/Open-ILS/xul/staff_client/chrome/content/auth/controller.js index 51a0ad2720..2b3a14a458 100644 --- a/Open-ILS/xul/staff_client/chrome/content/auth/controller.js +++ b/Open-ILS/xul/staff_client/chrome/content/auth/controller.js @@ -549,7 +549,9 @@ auth.controller.prototype = { this.session.close(); this.data.menu_perms = false; + this.data.current_hotkeyset = undefined; this.data.stash('menu_perms'); + this.data.stash('current_hotkeyset'); /* FIXME - need some locking or object destruction for the async tests */ /* this.test_server( this.controller.view.server_prompt.value ); */ diff --git a/Open-ILS/xul/staff_client/chrome/content/main/main.js b/Open-ILS/xul/staff_client/chrome/content/main/main.js index 9aec40a9e4..f13cbfe633 100644 --- a/Open-ILS/xul/staff_client/chrome/content/main/main.js +++ b/Open-ILS/xul/staff_client/chrome/content/main/main.js @@ -220,6 +220,70 @@ function get_menu_perms(indocument) { return false; } +// Returns a list (cached or from filesystem) of hotkey sets +function load_hotkey_sets() { + if(typeof(load_hotkey_sets.set_list) == 'undefined') { + load_hotkey_sets.set_list = []; + JSAN.use('util.file'); + var file = new util.file(); + var dirEntries = file.get('hotkeys','skin').directoryEntries; + while(dirEntries.hasMoreElements()) { + var entry = dirEntries.getNext(); + entry.QueryInterface(Components.interfaces.nsIFile); + if(!entry.isFile()) continue; + if(!entry.leafName.match(/.+\.keyset$/)) continue; + var keysetname = entry.leafName.replace(/\.keyset$/,''); + load_hotkey_sets.set_list.push(keysetname); + } + file.close(); + } + return load_hotkey_sets.set_list; +} + +// Returns an array (cached or from filesystem) for a given hotkey set +function get_hotkey_array(keyset_name) { + if(typeof(get_hotkey_array.keyset_cache) == 'undefined') { + get_hotkey_array.keyset_cache = {}; + } + if(get_hotkey_array.keyset_cache[keyset_name]) + return get_hotkey_array.keyset_cache[keyset_name]; + JSAN.use('util.file'); + var file = new util.file(); + var keyset_raw; + try { + var keyset_file = file.get('hotkeys','skin'); + keyset_file.append(keyset_name + ".keyset"); + keyset_raw = file.get_content(); + file.close(); + var tempArray = []; + + var keyset_lines = keyset_raw.trim().split("\n"); + for(var line = 0; line < keyset_lines.length; line++) { + // Grab line, strip comments, strip leading/trailing whitespace + var curline = keyset_lines[line].replace(/\s*#.*$/,'').trim(); + if(curline == "") continue; // Skip empty lines + // Split into pieces + var split_line = curline.split(','); + // We need at least 3 elements. Command, modifiers, keycode. + if(split_line.length < 3) continue; + // Trim each segment + split_line[0] = split_line[0].trim(); + split_line[1] = split_line[1].trim(); + split_line[2] = split_line[2].trim(); + if(split_line.length > 3) + split_line[3] = split_line[3].trim(); + // Skip empty commands + if(split_line[0] == "") continue; + // Push to array + tempArray.push(split_line); + } + get_hotkey_array.keyset_cache[keyset_name] = tempArray; + return tempArray; + } catch(E) { // Something went wrong. + return false; + } +} + function main_init() { dump('entering main_init()\n'); try { diff --git a/Open-ILS/xul/staff_client/chrome/content/main/menu.js b/Open-ILS/xul/staff_client/chrome/content/main/menu.js index b8b9f8a940..ba8a97d3be 100644 --- a/Open-ILS/xul/staff_client/chrome/content/main/menu.js +++ b/Open-ILS/xul/staff_client/chrome/content/main/menu.js @@ -33,6 +33,11 @@ main.menu.prototype = { 'id_incr' : 0, + 'toolbar' : 'none', + 'toolbar_size' : 'large', + 'toolbar_mode' : 'both', + 'toolbar_labelpos' : 'side', + 'url_prefix' : function(url) { if (url.match(/^\//)) url = urls.remote + url; if (! url.match(/^(http|chrome):\/\//) && ! url.match(/^data:/) ) url = 'http://' + url; @@ -55,10 +60,72 @@ main.menu.prototype = { eval( r.responseText ); } - var button_bar = String( obj.data.hash.aous['ui.general.button_bar'] ) == 'true'; + // Try workstation pref for button bar + var button_bar = xulG.pref.getCharPref('open-ils.menu.toolbar'); + + if (!button_bar) // No workstation pref? Try org unit pref. + button_bar = String( obj.data.hash.aous['ui.general.button_bar'] ); + if (button_bar) { - var x = document.getElementById('main_toolbar'); + var x = document.getElementById('toolbar_' + button_bar); if (x) x.setAttribute('hidden','false'); + this.toolbar = button_bar; + } + + // Check for alternate Size pref + var toolbar_size = xulG.pref.getCharPref('open-ils.menu.toolbar.iconsize'); + if(toolbar_size) this.toolbar_size = toolbar_size; + // Check for alternate Mode pref + var toolbar_mode = xulG.pref.getCharPref('open-ils.menu.toolbar.mode'); + if(toolbar_mode) this.toolbar_mode = toolbar_mode; + // Check for alternate Label Position pref + var toolbar_labelpos = xulG.pref.getBoolPref('open-ils.menu.toolbar.labelbelow'); + if(toolbar_labelpos) this.toolbar_labelpos = toolbar_labelpos; + + if(button_bar || toolbar_size || toolbar_mode || toolbar_labelpos) { + var toolbox = document.getElementById('main_toolbox'); + var toolbars = toolbox.getElementsByTagName('toolbar'); + for(var i = 0; i < toolbars.length; i++) { + if(toolbars[i].id == 'toolbar_' + button_bar) + toolbars[i].setAttribute('hidden', 'false'); + else + toolbars[i].setAttribute('hidden', 'true'); + if(toolbar_mode) toolbars[i].setAttribute('mode', toolbar_mode); + if(toolbar_size) toolbars[i].setAttribute('iconsize', toolbar_size); + if(toolbar_labelpos) addCSSClass(toolbars[i], 'labelbelow'); + } + } + + if(button_bar) { + var x = document.getElementById('main.menu.admin.client.toolbars.current.popup'); + if (x) { + var selectitems = x.getElementsByAttribute('value',button_bar); + if(selectitems.length > 0) selectitems[0].setAttribute('checked','true'); + } + } + + if(toolbar_size) { + var x = document.getElementById('main.menu.admin.client.toolbars.size.popup'); + if (x) { + var selectitems = x.getElementsByAttribute('value',toolbar_size); + if(selectitems.length > 0) selectitems[0].setAttribute('checked','true'); + } + } + + if(toolbar_mode) { + var x = document.getElementById('main.menu.admin.client.toolbars.mode.popup'); + if (x) { + var selectitems = x.getElementsByAttribute('value',toolbar_mode); + if(selectitems.length > 0) selectitems[0].setAttribute('checked','true'); + } + } + + if(toolbar_labelpos) { + var x = document.getElementById('main.menu.admin.client.toolbars.label_position.popup'); + if (x) { + var selectitems = x.getElementsByAttribute('value',"under"); + if(selectitems.length > 0) selectitems[0].setAttribute('checked','true'); + } } var network_meter = String( obj.data.hash.aous['ui.network.progress_meter'] ) == 'true'; @@ -71,7 +138,26 @@ main.menu.prototype = { var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"]. getService(Components.interfaces.nsIWindowMediator); - wm.getMostRecentWindow('eg_main').get_menu_perms(document); + var mainwin = wm.getMostRecentWindow('eg_main'); + mainwin.get_menu_perms(document); + var hotkeysets = mainwin.load_hotkey_sets(); + + var popupmenu = document.getElementById('main.menu.admin.client.hotkeys.current.popup'); + + for(var i = 0; i < hotkeysets.length; i++) { + var keysetname = hotkeysets[i]; + var menuitem = document.createElement('menuitem'); + if(offlineStrings.testString('hotkey.' + keysetname)) + menuitem.setAttribute('label',offlineStrings.getString('hotkey.' + keysetname)); + else + menuitem.setAttribute('label',keysetname); + menuitem.setAttribute('value',keysetname); + menuitem.setAttribute('type','radio'); + menuitem.setAttribute('name','menu_hotkey_current'); + menuitem.setAttribute('command','cmd_hotkeys_set'); + popupmenu.appendChild(menuitem); + } + JSAN.use('util.network'); var network = new util.network(); network.set_user_status(); @@ -535,14 +621,6 @@ main.menu.prototype = { } ], - 'cmd_toggle_buttonbar' : [ - ['oncommand'], - function() { - var x = document.getElementById('main_toolbar'); - if (x) x.hidden = ! x.hidden; - } - ], - 'cmd_toggle_meters' : [ ['oncommand'], function() { @@ -1325,6 +1403,112 @@ main.menu.prototype = { } } ], + 'cmd_hotkeys_toggle' : [ + ['oncommand'], + function() { + // Easy enough, toggle disabled on the keyset + var keyset = document.getElementById("menu_frame_keys"); + var disabled = (keyset.getAttribute("disabled") == "true") ? "false" : "true"; + keyset.setAttribute("disabled", disabled); + // Then find every menuitem/toolbarbutton for this command for a graphical hint + var controls = document.getElementsByAttribute("command","cmd_hotkeys_toggle"); + for(var i = 0; i < controls.length; i++) + controls[i].setAttribute("checked",disabled); + } + ], + 'cmd_hotkeys_set' : [ + ['oncommand'], + function(event) { + obj.set_menu_hotkeys(event.explicitOriginalTarget.getAttribute('value')); + } + ], + 'cmd_hotkeys_setworkstation' : [ + ['oncommand'], + function() { + xulG.pref.setCharPref('open-ils.menu.hotkeyset', obj.data.current_hotkeyset); + } + ], + 'cmd_hotkeys_clearworkstation' : [ + ['oncommand'], + function() { + if(xulG.pref.prefHasUserValue('open-ils.menu.hotkeyset')) + xulG.pref.clearUserPref('open-ils.menu.hotkeyset'); + } + ], + 'cmd_toolbar_set' : [ + ['oncommand'], + function(event) { + var newToolbar = event.explicitOriginalTarget.getAttribute('value'); + var toolbox = document.getElementById('main_toolbox'); + var toolbars = toolbox.getElementsByTagName('toolbar'); + for(var i = 0; i < toolbars.length; i++) { + if(toolbars[i].id == 'toolbar_' + newToolbar) + toolbars[i].setAttribute('hidden', 'false'); + else + toolbars[i].setAttribute('hidden', 'true'); + } + obj.toolbar = newToolbar; + } + ], + 'cmd_toolbar_mode_set' : [ + ['oncommand'], + function(event) { + var newMode = event.explicitOriginalTarget.getAttribute('value'); + var toolbox = document.getElementById('main_toolbox'); + var toolbars = toolbox.getElementsByTagName('toolbar'); + for(var i = 0; i < toolbars.length; i++) + toolbars[i].setAttribute("mode",newMode); + obj.toolbar_mode = newMode; + } + ], + 'cmd_toolbar_size_set' : [ + ['oncommand'], + function(event) { + var newSize = event.explicitOriginalTarget.getAttribute('value'); + var toolbox = document.getElementById('main_toolbox'); + var toolbars = toolbox.getElementsByTagName('toolbar'); + for(var i = 0; i < toolbars.length; i++) + toolbars[i].setAttribute("iconsize",newSize); + obj.toolbar_size = newSize; + } + ], + 'cmd_toolbar_label_position_set' : [ + ['oncommand'], + function(event) { + var altPosition = (event.explicitOriginalTarget.getAttribute('value') == "under"); + var toolbox = document.getElementById('main_toolbox'); + var toolbars = toolbox.getElementsByTagName('toolbar'); + for(var i = 0; i < toolbars.length; i++) { + if(altPosition) + addCSSClass(toolbars[i], 'labelbelow'); + else + removeCSSClass(toolbars[i], 'labelbelow'); + } + obj.toolbar_labelpos = (altPosition ? "under" : "side"); + } + ], + 'cmd_toolbar_setworkstation' : [ + ['oncommand'], + function() { + xulG.pref.setCharPref('open-ils.menu.toolbar', obj.toolbar); + xulG.pref.setCharPref('open-ils.menu.toolbar.iconsize', obj.toolbar_size); + xulG.pref.setCharPref('open-ils.menu.toolbar.mode', obj.toolbar_mode); + xulG.pref.setBoolPref('open-ils.menu.toolbar.labelbelow', (obj.toolbar_labelpos == "under")); + } + ], + 'cmd_toolbar_clearworkstation' : [ + ['oncommand'], + function() { + if(xulG.pref.prefHasUserValue('open-ils.menu.toolbar')) + xulG.pref.clearUserPref('open-ils.menu.toolbar'); + if(xulG.pref.prefHasUserValue('open-ils.menu.toolbar.iconsize')) + xulG.pref.clearUserPref('open-ils.menu.toolbar.iconsize'); + if(xulG.pref.prefHasUserValue('open-ils.menu.toolbar.mode')) + xulG.pref.clearUserPref('open-ils.menu.toolbar.mode'); + if(xulG.pref.prefHasUserValue('open-ils.menu.toolbar.labelbelow')) + xulG.pref.clearUserPref('open-ils.menu.toolbar.labelbelow'); + } + ], }; JSAN.use('util.controller'); @@ -1411,17 +1595,20 @@ main.menu.prototype = { 'command_tab' : function(event,url,params,content_params) { var newTab = false; - if(event && event.explicitOriginalTarget.nodeName == 'toolbarbutton' && event.explicitOriginalTarget.command == event.originalTarget.id) { + var myEvent = event; + if(event && event.sourceEvent) myEvent = event.sourceEvent; + // Note: The last event is not supposed to be myEvent in this if. + if(myEvent && myEvent.explicitOriginalTarget.nodeName.match(/toolbarbutton/) && myEvent.explicitOriginalTarget.command == event.originalTarget.id) { var value = xulG.pref.getIntPref('ui.key.accelKey'); switch(value) { case 17: - newTab = event.ctrlKey; + newTab = myEvent.ctrlKey; break; case 18: - newTab = event.altKey; + newTab = myEvent.altKey; break; case 224: - newTab = event.metaKey; + newTab = myEvent.metaKey; break; } try { @@ -1529,6 +1716,122 @@ commands: }, + 'set_menu_hotkeys' : function(hotkeyset) { + this.data.stash_retrieve(); + + var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"]. + getService(Components.interfaces.nsIWindowMediator); + var mainwin = wm.getMostRecentWindow('eg_main'); + var explicit = false; + JSAN.use('util.network'); + var network = new util.network(); + + if(hotkeyset) { // Explicit request + this.data.current_hotkeyset = hotkeyset; + this.data.stash('current_hotkeyset'); + explicit = true; + } + else { // Non-explicit request? + if(this.data.current_hotkeyset) // Previous hotkeyset? + hotkeyset = this.data.current_hotkeyset; // Use it + else { // No previous? We need to decide on one! + // Load the list so we know if what we are being asked to load is valid. + var hotkeysets = mainwin.load_hotkey_sets(); + if(!hotkeysets) return; // No sets = nothing to load. Which is probably an error, but meh. + hotkeysets.has = function(test) { + for(i = 0; i < this.length; i++) { + if(this[i] == test) return true; + } + return false; + }; + // Try workstation (pref) + hotkeyset = xulG.pref.getCharPref('open-ils.menu.hotkeyset'); + + // Nothing or nothing valid? + if(!hotkeyset || !hotkeysets.has(hotkeyset)) { + hotkeyset = this.data.hash.aous['ui.general.hotkeyset']; + } + // STILL nothing? Try Default. + if(!hotkeyset || !hotkeysets.has(hotkeyset)) { + if(hotkeysets.has('Default')) + hotkeyset = 'Default'; + else + return false; + } + // And save whatever we are using. + this.data.current_hotkeyset = hotkeyset; + this.data.stash('current_hotkeyset'); + } + } + // Clear out all the old hotkeys + var keyset = document.getElementById('menu_frame_keys'); + var main_menu = document.getElementById('main_menubar'); + if(keyset.hasChildNodes()) { + var menuitems = main_menu.getElementsByAttribute('key','*'); + while(menuitems.length > 0) { + var menuitem = menuitems[0]; + menuitem.removeAttribute('key'); + // Trick/force mozilla to re-evaluate the menuitem + // If you want to take this trick for use *anywhere* in *any* project, regardless of licensing, please do + // Because it was a PITA to figure out + menuitem.style.display = 'none'; // Hide the item to force menu to clear spot + menuitem.removeAttribute('acceltext'); // Remove acceltext to clear out hotkey hint text + menuitem.parentNode.openPopupAtScreen(0,0,false); // Tell menupopup to redraw itself + menuitem.parentNode.hidePopup(); // And then make it go away right away. + menuitem.style.removeProperty('display'); // Restore normal css display + } + while(keyset.hasChildNodes()) keyset.removeChild(keyset.childNodes[0]); + } + keyset_lines = mainwin.get_hotkey_array(hotkeyset); + // Next, fill the keyset + for(var line = 0; line < keyset_lines.length; line++) { + // Create and populate our + var key_node = document.createElement('key'); + key_node.setAttribute('id',keyset_lines[line][0] + "_key"); + key_node.setAttribute('command',keyset_lines[line][0]); + key_node.setAttribute('modifiers',keyset_lines[line][1]); + // If keycode starts with VK_ we assume it is a key code. + // Key codes go in the keycode attribute + // Regular keys (like "i") go in the key attribute + if(keyset_lines[line][2].match(/^VK_/)) + key_node.setAttribute('keycode',keyset_lines[line][2]); + else + key_node.setAttribute('key',keyset_lines[line][2]); + // If a fourth option was specified, set keytext to it. + if(keyset_lines[line][3]) + key_node.setAttribute('keytext',keyset_lines[line][3]); + // Add the new node to the DOM + keyset.appendChild(key_node); + // And populate all the menu items that should now display it + var menuitems = main_menu.getElementsByAttribute('command',keyset_lines[line][0]); + for(var i = 0; i < menuitems.length; i++) { + menuitems[i].setAttribute('key', keyset_lines[line][0] + "_key"); + // Trick/force mozilla to re-evaluate the menuitem + menuitems[i].style.display = 'none'; // Hide the item to force menu to clear spot + menuitems[i].parentNode.openPopupAtScreen(0,0,false); // Tell menupopup to redraw itself + menuitems[i].parentNode.hidePopup(); // And then make it go away right away + menuitems[i].style.removeProperty('display'); // Restore normal css display + } + } + // If no keys, disable ability to toggle hotkeys (because why bother?) + var x = document.getElementById('cmd_hotkeys_toggle'); + if(x) { + if(keyset.hasChildNodes()) + x.removeAttribute('disabled'); + else + x.setAttribute('disabled', 'true'); + } + // Select the hotkey set in the menu + // This ensures that first window load OR remote window update shows properly + var hotkeylist = document.getElementById('main.menu.admin.client.hotkeys.current.popup'); + var selectitems = hotkeylist.getElementsByAttribute('value',hotkeyset); + if(selectitems.length > 0) selectitems[0].setAttribute('checked','true'); + // Tell other windows to update + if(explicit) { + network.set_user_status(); + } + }, + 'page_meter' : { 'node' : document.getElementById('page_progress'), 'on' : function() { diff --git a/Open-ILS/xul/staff_client/chrome/content/main/menu_frame_menus.xul b/Open-ILS/xul/staff_client/chrome/content/main/menu_frame_menus.xul index f7c5c26d95..2dc7cb5ff1 100644 --- a/Open-ILS/xul/staff_client/chrome/content/main/menu_frame_menus.xul +++ b/Open-ILS/xul/staff_client/chrome/content/main/menu_frame_menus.xul @@ -62,7 +62,6 @@ - @@ -210,42 +209,28 @@ - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + - - + + - - - + + + @@ -270,26 +255,26 @@ - - - - + + + + - + - + - + - - + + - + - + @@ -297,10 +282,10 @@ - - - - + + + + - - - - - - + + + + + + @@ -380,8 +365,8 @@ - - + + @@ -389,6 +374,60 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -398,17 +437,13 @@ - - - - @@ -482,7 +517,6 @@ - @@ -495,7 +529,7 @@ - + diff --git a/Open-ILS/xul/staff_client/chrome/content/main/menu_frame_overlay.xul b/Open-ILS/xul/staff_client/chrome/content/main/menu_frame_overlay.xul index fdbed1da78..48f8b5ea32 100644 --- a/Open-ILS/xul/staff_client/chrome/content/main/menu_frame_overlay.xul +++ b/Open-ILS/xul/staff_client/chrome/content/main/menu_frame_overlay.xul @@ -22,7 +22,7 @@