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
This commit is contained in:
parent
3d9853acaa
commit
c73a0753d7
2 changed files with 35 additions and 7 deletions
|
@ -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; i<textboxes.length; i++) {
|
||||
let textbox = textboxes[i];
|
||||
textbox.value = textbox.value.toUpperCase();
|
||||
// .value takes care of the initial value, and this takes care of direct pref changes
|
||||
// while the window is open
|
||||
textbox.setAttribute('onsyncfrompreference', 'return Zotero_Preferences.Keys.capitalizePref(this.id)');
|
||||
textbox.setAttribute('oninput', 'this.value = this.value.toUpperCase()');
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
capitalizePref: function (id) {
|
||||
var elem = document.getElementById(id);
|
||||
var pref = document.getElementById(elem.getAttribute('preference'));
|
||||
if (pref.value) {
|
||||
return pref.value.toUpperCase();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
@ -2420,17 +2420,17 @@ Zotero.Keys = new function() {
|
|||
* Called by Zotero.init()
|
||||
*/
|
||||
function init() {
|
||||
var actions = Zotero.Prefs.prefBranch.getChildList('keys', {}, {});
|
||||
var cmds = Zotero.Prefs.prefBranch.getChildList('keys', {}, {});
|
||||
|
||||
// Get the key=>command 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 <key> 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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue