From c73a0753d7eb9936978fdc2a054569172fb43f79 Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Wed, 30 Apr 2014 15:06:35 -0400 Subject: [PATCH] Handle lowercase shortcut key pref values Honor lowercase pref values for shortcut keys, and also always display and set shortcut keys as uppercase in the preferences --- .../zotero/preferences/preferences_keys.js | 19 +++++++++++++++ chrome/content/zotero/xpcom/zotero.js | 23 +++++++++++++------ 2 files changed, 35 insertions(+), 7 deletions(-) diff --git a/chrome/content/zotero/preferences/preferences_keys.js b/chrome/content/zotero/preferences/preferences_keys.js index 20f7ecd19a..8adb8935e5 100644 --- a/chrome/content/zotero/preferences/preferences_keys.js +++ b/chrome/content/zotero/preferences/preferences_keys.js @@ -32,5 +32,24 @@ Zotero_Preferences.Keys = { // Display the appropriate modifier keys for the platform rows[i].firstChild.nextSibling.value = Zotero.isMac ? Zotero.getString('general.keys.cmdShift') : Zotero.getString('general.keys.ctrlShift'); } + + var textboxes = document.getElementById('zotero-keys-rows').getElementsByTagName('textbox'); + for (let i=0; icommand mappings from the prefs - for each(var action in actions) { - var action = action.substr(5); // strips 'keys.' + for each(var cmd in cmds) { + cmd = cmd.substr(5); // strips 'keys.' // Remove old pref - if (action == 'overrideGlobal') { + if (cmd == 'overrideGlobal') { Zotero.Prefs.clear('keys.overrideGlobal'); continue; } - _keys[Zotero.Prefs.get('keys.' + action)] = action; + _keys[this.getKeyForCommand(cmd)] = cmd; } } @@ -2453,7 +2453,7 @@ Zotero.Keys = new function() { globalKeys.forEach(function (x) { let keyElem = document.getElementById('key_' + x.name); if (keyElem) { - let prefKey = Zotero.Prefs.get('keys.' + x.name); + let prefKey = this.getKeyForCommand(x.name); // Only override the default with the pref if the hasn't // been manually changed and the pref has been if (keyElem.getAttribute('key') == x.defaultKey @@ -2462,7 +2462,7 @@ Zotero.Keys = new function() { keyElem.setAttribute('key', prefKey); } } - }); + }.bind(this)); } @@ -2470,6 +2470,15 @@ Zotero.Keys = new function() { key = key.toUpperCase(); return _keys[key] ? _keys[key] : false; } + + + this.getKeyForCommand = function (cmd) { + try { + var key = Zotero.Prefs.get('keys.' + cmd); + } + catch (e) {} + return key !== undefined ? key.toUpperCase() : false; + } }