summaryrefslogtreecommitdiff
path: root/ext/fg/js/frontend.js
diff options
context:
space:
mode:
authorAlex Yatskov <alex@foosoft.net>2020-04-18 11:05:35 -0700
committerAlex Yatskov <alex@foosoft.net>2020-04-18 11:05:35 -0700
commitf2186c51e4ef219d158735d30a32bbf3e49c4e1a (patch)
tree61de35513b6182e83b626c1571bc2aa97234e3b0 /ext/fg/js/frontend.js
parentb3e79d0e396353de2cbefb945412bfda4bd6ca99 (diff)
parent9e7750125c40d1c4121e8d015957606721bede7c (diff)
Merge branch 'master' into testing
Diffstat (limited to 'ext/fg/js/frontend.js')
-rw-r--r--ext/fg/js/frontend.js33
1 files changed, 26 insertions, 7 deletions
diff --git a/ext/fg/js/frontend.js b/ext/fg/js/frontend.js
index 6fbbd0fb..eecfe2e1 100644
--- a/ext/fg/js/frontend.js
+++ b/ext/fg/js/frontend.js
@@ -17,7 +17,7 @@
/* global
* TextScanner
- * apiForward
+ * apiBroadcastTab
* apiGetZoom
* apiKanjiFind
* apiOptionsGet
@@ -29,11 +29,14 @@ class Frontend extends TextScanner {
constructor(popup) {
super(
window,
- popup.isProxy() ? [] : [popup.getContainer()],
+ () => this.popup.isProxy() ? [] : [this.popup.getContainer()],
[(x, y) => this.popup.containsPoint(x, y)]
);
this.popup = popup;
+
+ this._disabledOverride = false;
+
this.options = null;
this.optionsContext = {
@@ -43,7 +46,7 @@ class Frontend extends TextScanner {
this._pageZoomFactor = 1.0;
this._contentScale = 1.0;
- this._orphaned = true;
+ this._orphaned = false;
this._lastShowPromise = Promise.resolve();
this._windowMessageHandlers = new Map([
@@ -132,8 +135,20 @@ class Frontend extends TextScanner {
];
}
+ setDisabledOverride(disabled) {
+ this._disabledOverride = disabled;
+ this.setEnabled(this.options.general.enable, this._canEnable());
+ }
+
+ async setPopup(popup) {
+ this.onSearchClear(false);
+ this.popup = popup;
+ await popup.setOptions(this.options);
+ }
+
async updateOptions() {
- this.setOptions(await apiOptionsGet(this.getOptionsContext()));
+ this.options = await apiOptionsGet(this.getOptionsContext());
+ this.setOptions(this.options, this._canEnable());
const ignoreNodes = ['.scan-disable', '.scan-disable *'];
if (!this.options.scanning.enableOnPopupExpressions) {
@@ -259,19 +274,23 @@ class Frontend extends TextScanner {
}
_broadcastRootPopupInformation() {
- if (!this.popup.isProxy() && this.popup.depth === 0) {
- apiForward('rootPopupInformation', {popupId: this.popup.id, frameId: this.popup.frameId});
+ if (!this.popup.isProxy() && this.popup.depth === 0 && this.popup.frameId === 0) {
+ apiBroadcastTab('rootPopupInformation', {popupId: this.popup.id, frameId: this.popup.frameId});
}
}
_broadcastDocumentInformation(uniqueId) {
- apiForward('documentInformationBroadcast', {
+ apiBroadcastTab('documentInformationBroadcast', {
uniqueId,
frameId: this.popup.frameId,
title: document.title
});
}
+ _canEnable() {
+ return this.popup.depth <= this.options.scanning.popupNestingMaxDepth && !this._disabledOverride;
+ }
+
async _updatePopupPosition() {
const textSource = this.getCurrentTextSource();
if (textSource !== null && await this.popup.isVisible()) {