This commit is contained in:
Alex Yatskov 2017-03-25 15:59:33 -07:00
parent 90eaae1725
commit b8d0788144
4 changed files with 30 additions and 38 deletions

View File

@ -49,6 +49,10 @@ window.displayWindow = new class extends Display {
window.alert(`Error: ${error}`);
}
clearSearch() {
$('#query').focus().select();
}
onSearch(e) {
e.preventDefault();
$('#intro').slideUp();

View File

@ -47,6 +47,10 @@ window.displayFrame = new class extends Display {
}
}
clearSearch() {
window.parent.postMessage('popupClose', '*');
}
showOrphaned() {
$('#content').hide();
$('#orphan').show();

View File

@ -46,14 +46,14 @@ window.driver = new class {
}
popupTimerClear() {
if (this.popupTimer !== null) {
if (this.popupTimer) {
window.clearTimeout(this.popupTimer);
this.popupTimer = null;
}
}
onMouseOver(e) {
if (e.target === this.popup.container && this.popuptimer !== null) {
if (e.target === this.popup.container && this.popupTimer) {
this.popupTimerClear();
}
}
@ -106,14 +106,6 @@ window.driver = new class {
const handlers = {
popupClose: () => {
this.searchClear();
},
scanLeft: () => {
},
scanRight: () => {
}
};
@ -147,11 +139,11 @@ window.driver = new class {
}
const textSource = docRangeFromPoint(point, this.options.scanning.imposter);
if (textSource === null || !textSource.containsPoint(point)) {
if (!textSource || !textSource.containsPoint(point)) {
return;
}
if (this.lastTextSource !== null && this.lastTextSource.equals(textSource)) {
if (this.lastTextSource && this.lastTextSource.equals(textSource)) {
return;
}
@ -225,7 +217,7 @@ window.driver = new class {
docImposterDestroy();
this.popup.hide();
if (this.options.scanning.selectText && this.lastTextSource !== null) {
if (this.options.scanning.selectText && this.lastTextSource) {
this.lastTextSource.deselect();
}

View File

@ -50,6 +50,10 @@ class Display {
throw 'override me';
}
clearSearch() {
throw 'override me';
}
showTermDefs(definitions, options, context) {
window.focus();
@ -207,17 +211,13 @@ class Display {
}
onKeyDown(e) {
const notifyParent = action => {
window.parent.postMessage(action, '*');
};
const handlers = {
36: /* home */ () => {
this.entryScroll(0, true);
8: /* backspace */ () => {
},
35: /* end */ () => {
this.entryScroll(this.definitions.length - 1, true);
27: /* escape */ () => {
this.clearSearch();
},
33: /* page up */ () => {
@ -228,6 +228,14 @@ class Display {
this.entryScroll(this.index + 3, true);
},
35: /* end */ () => {
this.entryScroll(this.definitions.length - 1, true);
},
36: /* home */ () => {
this.entryScroll(0, true);
},
38: /* up */ () => {
this.entryScroll(this.index - 1, true);
},
@ -240,28 +248,12 @@ class Display {
},
221: /* ] */ () => {
},
220: /* \ */ () => {
this.audioPlay(this.definitions[this.index]);
},
8: /* backspace */ () => {
221: /* ] */ () => {
},
27: /* escape */ () => {
notifyParent('popupClose');
},
37: /* left */ () => {
notifyParent('scanLeft');
},
39: /* right */ () => {
notifyParent('scanRight');
}
};