aboutsummaryrefslogtreecommitdiff
path: root/ext/fg/js/frontend.js
diff options
context:
space:
mode:
authorAlex Yatskov <alex@foosoft.net>2017-09-16 23:08:43 -0700
committerAlex Yatskov <alex@foosoft.net>2017-09-16 23:08:43 -0700
commit9280985306f5a9c79b9bd2c4daea596a5ec78ae5 (patch)
tree3feed98555c924983bbea83187ea35f8657bbc68 /ext/fg/js/frontend.js
parent5a531541238b52ba56475ae3f91873bd1b8a9d10 (diff)
add option to automatically hide search results (fixes #71)
Diffstat (limited to 'ext/fg/js/frontend.js')
-rw-r--r--ext/fg/js/frontend.js21
1 files changed, 10 insertions, 11 deletions
diff --git a/ext/fg/js/frontend.js b/ext/fg/js/frontend.js
index 41c93f00..e4035289 100644
--- a/ext/fg/js/frontend.js
+++ b/ext/fg/js/frontend.js
@@ -169,27 +169,21 @@ class Frontend {
}
async searchAt(point) {
- let textSource = null;
+ const textSource = docRangeFromPoint(point);
+ let hideResults = false;
try {
if (this.pendingLookup) {
return;
}
- textSource = docRangeFromPoint(point);
- if (!textSource || !textSource.containsPoint(point)) {
- docImposterDestroy();
- return;
- }
-
if (this.textSourceLast && this.textSourceLast.equals(textSource)) {
return;
}
- this.pendingLookup = true;
-
- if (!await this.searchTerms(textSource)) {
- await this.searchKanji(textSource);
+ if (textSource && textSource.containsPoint(point)) {
+ this.pendingLookup = true;
+ hideResults = !await this.searchTerms(textSource) && !await this.searchKanji(textSource);
}
} catch (e) {
if (window.yomichan_orphaned) {
@@ -201,6 +195,11 @@ class Frontend {
}
} finally {
docImposterDestroy();
+
+ if (hideResults && this.options.scanning.autoHideResults) {
+ this.popup.hide();
+ }
+
this.pendingLookup = false;
}
}