diff options
author | siikamiika <siikamiika@users.noreply.github.com> | 2020-04-10 03:55:25 +0300 |
---|---|---|
committer | siikamiika <siikamiika@users.noreply.github.com> | 2020-04-11 21:01:27 +0300 |
commit | 92109bb5d25db99033b0bb9f7f3806883f79218d (patch) | |
tree | 999207ff066194323781d9d7c8d6e5d8364fb4e0 /ext/fg/js/frontend.js | |
parent | 1df59d57b5dcbf9d3efedcb21a4d5e16524a67c1 (diff) |
allow disabling scan on search page live
Diffstat (limited to 'ext/fg/js/frontend.js')
-rw-r--r-- | ext/fg/js/frontend.js | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/ext/fg/js/frontend.js b/ext/fg/js/frontend.js index a6b24c76..a6df4b4c 100644 --- a/ext/fg/js/frontend.js +++ b/ext/fg/js/frontend.js @@ -26,15 +26,19 @@ */ class Frontend extends TextScanner { - constructor(popup) { + constructor(popup, initEventDispatcher) { super( window, popup.isProxy() ? [] : [popup.getContainer()], [(x, y) => this.popup.containsPoint(x, y)], - () => this.popup.depth <= this.options.scanning.popupNestingMaxDepth + () => this.popup.depth <= this.options.scanning.popupNestingMaxDepth && !this._disabledOverride ); this.popup = popup; + this.initEventDispatcher = initEventDispatcher; + + this._disabledOverride = false; + this.options = null; this.optionsContext = { @@ -73,6 +77,8 @@ class Frontend extends TextScanner { window.visualViewport.addEventListener('resize', this.onVisualViewportResize.bind(this)); } + this.initEventDispatcher.on('setDisabledOverride', this.onSetDisabledOverride.bind(this)); + yomichan.on('orphaned', this.onOrphaned.bind(this)); yomichan.on('optionsUpdated', this.updateOptions.bind(this)); yomichan.on('zoomChanged', this.onZoomChanged.bind(this)); @@ -228,6 +234,14 @@ class Frontend extends TextScanner { super.onSearchClear(changeFocus); } + onSetDisabledOverride({disabled}) { + this._disabledOverride = disabled; + // other cases handed by regular options update + if (disabled && this.enabled) { + this.setEnabled(false); + } + } + getOptionsContext() { this.optionsContext.url = this.popup.url; return this.optionsContext; |