aboutsummaryrefslogtreecommitdiff
path: root/ext/fg/js
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2019-08-09 22:29:14 -0400
committertoasted-nutbread <toasted-nutbread@users.noreply.github.com>2019-08-09 22:29:14 -0400
commit345b9c6f9dc336265f4ef8cd67cc2beb57abe354 (patch)
tree92500ba9920fa00d269ec0ac83a416ca7be48119 /ext/fg/js
parent710ffb88fc75d57f92a8b33b39f62645fc26fedd (diff)
Disable focus of popup when using touch
Context menu on Firefox will not target the text properly if the focus is on the popup window.
Diffstat (limited to 'ext/fg/js')
-rw-r--r--ext/fg/js/frontend.js11
1 files changed, 6 insertions, 5 deletions
diff --git a/ext/fg/js/frontend.js b/ext/fg/js/frontend.js
index fa0d2086..83fd9aff 100644
--- a/ext/fg/js/frontend.js
+++ b/ext/fg/js/frontend.js
@@ -290,7 +290,8 @@ class Frontend {
if (!hideResults && (!this.textSourceLast || !this.textSourceLast.equals(textSource))) {
searched = true;
this.pendingLookup = true;
- hideResults = !await this.searchTerms(textSource) && !await this.searchKanji(textSource);
+ const focus = (type === 'mouse');
+ hideResults = !await this.searchTerms(textSource, focus) && !await this.searchKanji(textSource, focus);
success = true;
}
} catch (e) {
@@ -313,7 +314,7 @@ class Frontend {
}
}
- async searchTerms(textSource) {
+ async searchTerms(textSource, focus) {
textSource.setEndOffset(this.options.scanning.length);
const {definitions, length} = await apiTermsFind(textSource.text());
@@ -329,7 +330,7 @@ class Frontend {
textSource.getRect(),
definitions,
this.options,
- {sentence, url}
+ {sentence, url, focus}
);
this.textSourceLast = textSource;
@@ -340,7 +341,7 @@ class Frontend {
return true;
}
- async searchKanji(textSource) {
+ async searchKanji(textSource, focus) {
textSource.setEndOffset(1);
const definitions = await apiKanjiFind(textSource.text());
@@ -354,7 +355,7 @@ class Frontend {
textSource.getRect(),
definitions,
this.options,
- {sentence, url}
+ {sentence, url, focus}
);
this.textSourceLast = textSource;