summaryrefslogtreecommitdiff
path: root/ext/fg
diff options
context:
space:
mode:
authorsiikamiika <siikamiika@users.noreply.github.com>2019-12-05 22:12:43 +0200
committersiikamiika <siikamiika@users.noreply.github.com>2019-12-05 22:12:43 +0200
commite5be42d3de14be48c6ef4ef47d06ba130d16fcaf (patch)
treeb274e8eb391ade63c49400b26d674bc795cb8e2b /ext/fg
parent02a34bb4bc81471934e54b5440a20585527d76f5 (diff)
scan decoupling
Diffstat (limited to 'ext/fg')
-rw-r--r--ext/fg/js/frontend.js13
1 files changed, 8 insertions, 5 deletions
diff --git a/ext/fg/js/frontend.js b/ext/fg/js/frontend.js
index 43a4830f..2adbde36 100644
--- a/ext/fg/js/frontend.js
+++ b/ext/fg/js/frontend.js
@@ -20,7 +20,14 @@
class Frontend {
constructor(popup, ignoreNodes) {
this.popup = popup;
- this.textScanner = new TextScanner(window, ignoreNodes, this.popup, this.searchSource.bind(this));
+ this.textScanner = new TextScanner(
+ window,
+ ignoreNodes,
+ [this.popup.container],
+ [(x, y) => this.popup.containsPoint(x, y)]
+ );
+ this.textScanner.subscribe('textSearch', ({textSource, cause}) => this.searchSource(textSource, cause));
+ this.textScanner.subscribe('searchClear', () => this.searchClear(true));
this.options = null;
this.optionsContext = {
@@ -138,7 +145,6 @@ class Frontend {
let results = null;
try {
- this.textScanner.pendingLookup = true;
if (textSource !== null) {
results = (
await this.findTerms(textSource) ||
@@ -165,8 +171,6 @@ class Frontend {
if (results === null && this.options.scanning.autoHideResults) {
this.searchClear(true);
}
-
- this.textScanner.pendingLookup = false;
}
return results;
@@ -182,7 +186,6 @@ class Frontend {
{definitions, context: {sentence, url, focus, disableHistory: true}}
);
- this.textScanner.setCurrentTextSource(textSource);
if (this.options.scanning.selectText) {
textSource.select();
}