From e36bc8771fd0b79a43cd809041002879f862487d Mon Sep 17 00:00:00 2001 From: toasted-nutbread Date: Fri, 3 Jul 2020 12:02:21 -0400 Subject: 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 --- ext/fg/js/float.js | 20 +++----------------- 1 file changed, 3 insertions(+), 17 deletions(-) (limited to 'ext/fg/js') 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; } -- cgit v1.2.3