aboutsummaryrefslogtreecommitdiff
path: root/ext/fg/js/frontend.js
diff options
context:
space:
mode:
authorsiikamiika <siikamiika@users.noreply.github.com>2020-04-17 01:31:25 +0300
committerGitHub <noreply@github.com>2020-04-17 01:31:25 +0300
commite6053eefa594524c7adcec4986a5a2c499adf192 (patch)
tree5a42ad3163455eda4306fbb5964f8b7fec20bf82 /ext/fg/js/frontend.js
parentbf971be15bf8787f992f03bb5943e3ee32c1583a (diff)
parentb6f7f8c02637cef9cadd4ab2b9f253c42903aee6 (diff)
Merge pull request #439 from siikamiika/popup-live-toggle
Popup live toggle
Diffstat (limited to 'ext/fg/js/frontend.js')
-rw-r--r--ext/fg/js/frontend.js25
1 files changed, 22 insertions, 3 deletions
diff --git a/ext/fg/js/frontend.js b/ext/fg/js/frontend.js
index 95427c4c..eecfe2e1 100644
--- a/ext/fg/js/frontend.js
+++ b/ext/fg/js/frontend.js
@@ -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 = {
@@ -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,7 +274,7 @@ class Frontend extends TextScanner {
}
_broadcastRootPopupInformation() {
- if (!this.popup.isProxy() && this.popup.depth === 0) {
+ if (!this.popup.isProxy() && this.popup.depth === 0 && this.popup.frameId === 0) {
apiBroadcastTab('rootPopupInformation', {popupId: this.popup.id, frameId: this.popup.frameId});
}
}
@@ -272,6 +287,10 @@ class Frontend extends TextScanner {
});
}
+ _canEnable() {
+ return this.popup.depth <= this.options.scanning.popupNestingMaxDepth && !this._disabledOverride;
+ }
+
async _updatePopupPosition() {
const textSource = this.getCurrentTextSource();
if (textSource !== null && await this.popup.isVisible()) {