mirror of
https://github.com/discourse/discourse.git
synced 2025-03-09 14:34:35 +00:00
Simplify characterCode lookup
Reduce String.fromCharCode that can’t be optimized by the minifier.
This commit is contained in:
parent
0d84ec4d58
commit
8961a2ee28
@ -31,19 +31,16 @@ shiftMap[32] = " ";
|
|||||||
function mapKeyPressToActualCharacter(isShiftKey, characterCode) {
|
function mapKeyPressToActualCharacter(isShiftKey, characterCode) {
|
||||||
if ( characterCode === 27 || characterCode === 8 || characterCode === 9 || characterCode === 20 || characterCode === 16 || characterCode === 17 || characterCode === 91 || characterCode === 13 || characterCode === 92 || characterCode === 18 ) { return false; }
|
if ( characterCode === 27 || characterCode === 8 || characterCode === 9 || characterCode === 20 || characterCode === 16 || characterCode === 17 || characterCode === 91 || characterCode === 13 || characterCode === 92 || characterCode === 18 ) { return false; }
|
||||||
|
|
||||||
if (isShiftKey) {
|
// Lookup non-letter keypress while holding shift
|
||||||
if ( characterCode >= 65 && characterCode <= 90 ) {
|
if (isShiftKey && ( characterCode < 65 || characterCode > 90 )) {
|
||||||
return String.fromCharCode(characterCode);
|
return shiftMap[characterCode];
|
||||||
} else {
|
|
||||||
return shiftMap[characterCode];
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if ( characterCode >= 65 && characterCode <= 90 ) {
|
|
||||||
return String.fromCharCode(characterCode).toLowerCase();
|
|
||||||
} else {
|
|
||||||
return String.fromCharCode(characterCode);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var stringValue = String.fromCharCode(characterCode);
|
||||||
|
if ( !isShiftKey ) {
|
||||||
|
stringValue = stringValue.toLowerCase();
|
||||||
|
}
|
||||||
|
return stringValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
$.fn.autocomplete = function(options) {
|
$.fn.autocomplete = function(options) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user