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}`); window.alert(`Error: ${error}`);
} }
clearSearch() {
$('#query').focus().select();
}
onSearch(e) { onSearch(e) {
e.preventDefault(); e.preventDefault();
$('#intro').slideUp(); $('#intro').slideUp();

View File

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

View File

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

View File

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