diff options
author | toasted-nutbread <toasted-nutbread@users.noreply.github.com> | 2020-07-03 12:02:21 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-07-03 12:02:21 -0400 |
commit | e36bc8771fd0b79a43cd809041002879f862487d (patch) | |
tree | f817984be2b95c71975892cc1c58a5c9c3b9d0fd /ext/fg | |
parent | 6ede83f2934195cb1dc5f261834b7c1bca8bfa90 (diff) |
Display refactor (#643)
* Remove statics
* Move orphan detection and error handling to Display
* Add clearContent function
* Add/use public get/set functions for optionsContext
* Add public getOptions
* Move interactive assignment
* Mark fields as private
* Mark functions as private
* Change stray getter into a function
Diffstat (limited to 'ext/fg')
-rw-r--r-- | ext/fg/js/float.js | 20 |
1 files changed, 3 insertions, 17 deletions
diff --git a/ext/fg/js/float.js b/ext/fg/js/float.js index d7beb675..d86f16c3 100644 --- a/ext/fg/js/float.js +++ b/ext/fg/js/float.js @@ -31,7 +31,6 @@ class DisplayFloat extends Display { this._secret = yomichan.generateId(16); this._token = null; - this._orphaned = false; this._nestedPopupsPrepared = false; this._onKeyDownHandlers = new Map([ @@ -59,24 +58,11 @@ class DisplayFloat extends Display { async prepare() { await super.prepare(); - yomichan.on('orphaned', this.onOrphaned.bind(this)); window.addEventListener('message', this.onMessage.bind(this), false); api.broadcastTab('popupPrepared', {secret: this._secret}); } - onError(error) { - if (this._orphaned) { - this.setContent('orphaned'); - } else { - yomichan.logError(error); - } - } - - onOrphaned() { - this._orphaned = true; - } - onEscape() { window.parent.postMessage('popupClose', '*'); } @@ -126,7 +112,7 @@ class DisplayFloat extends Display { } async setOptionsContext(optionsContext) { - this.optionsContext = optionsContext; + super.setOptionsContext(optionsContext); await this.updateOptions(); } @@ -181,7 +167,7 @@ class DisplayFloat extends Display { } async _configure({messageId, frameId, popupId, optionsContext, childrenSupported, scale}) { - this.optionsContext = optionsContext; + this.setOptionsContext(optionsContext); await this.updateOptions(); @@ -208,7 +194,7 @@ class DisplayFloat extends Display { let complete = false; const onOptionsUpdated = async () => { - const optionsContext = this.optionsContext; + const optionsContext = this.getOptionsContext(); const options = await api.optionsGet(optionsContext); const maxPopupDepthExceeded = !(typeof depth === 'number' && depth < options.scanning.popupNestingMaxDepth); if (maxPopupDepthExceeded || complete) { return; } |