Skip to content

Commit

Permalink
update strings
Browse files Browse the repository at this point in the history
  • Loading branch information
LukePulverenti committed Feb 10, 2020
1 parent 3d322ae commit 3604ebd
Show file tree
Hide file tree
Showing 20 changed files with 394 additions and 4,309 deletions.
25 changes: 16 additions & 9 deletions alphanumericshortcuts/alphanumericshortcuts.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

if (chr.length === 1) {
currentDisplayTextContainer = this.options.itemsContainer;
onAlphanumericKeyPress(e, chr);
onAlphanumericKeyPress(this, e, chr);
}
}
}
Expand All @@ -53,23 +53,26 @@
alpanumericShortcutTimeout = null;
}
}
function resetAlphaNumericShortcutTimeout() {
function resetAlphaNumericShortcutTimeout(instance) {
clearAlphaNumericShortcutTimeout();
alpanumericShortcutTimeout = setTimeout(onAlphanumericShortcutTimeout, 2000);
alpanumericShortcutTimeout = setTimeout(onAlphanumericShortcutTimeout.bind(instance), 2000);
}

function onAlphanumericKeyPress(e, chr) {
function onAlphanumericKeyPress(instance, e, chr) {
if (currentDisplayText.length >= 3) {
return;
}
ensureInputDisplayElement();
currentDisplayText += chr;
inputDisplayElement.innerHTML = currentDisplayText;
inputDisplayElement.classList.remove('hide');
resetAlphaNumericShortcutTimeout();
resetAlphaNumericShortcutTimeout(instance);
}

function onAlphanumericShortcutTimeout() {

var instance = this;

var value = currentDisplayText;
var container = currentDisplayTextContainer;

Expand All @@ -78,12 +81,16 @@
inputDisplayElement.innerHTML = '';
inputDisplayElement.classList.add('hide');
clearAlphaNumericShortcutTimeout();
selectByShortcutValue(container, value);
selectByShortcutValue(instance, container, value);
}

function selectByShortcutValue(container, value) {
function selectByShortcutValue(instance, container, value) {

value = value.toUpperCase();
if (instance.onAlphaNumericValueEntered) {
if (instance.onAlphaNumericValueEntered(value)) {
return;
}
}

var focusElem;
if (value === '#') {
Expand All @@ -92,7 +99,7 @@
}

if (!focusElem) {
focusElem = container.querySelector('*[data-prefix^=\'' + value + '\']');
focusElem = container.querySelector('*[data-prefix^=\'' + value.toUpperCase() + '\']');
}

if (focusElem) {
Expand Down
Loading

0 comments on commit 3604ebd

Please sign in to comment.