diff options
author | siikamiika <siikamiika@users.noreply.github.com> | 2020-02-14 11:00:36 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-02-14 11:00:36 +0200 |
commit | c09a3ded1d694887e4e9ff48cc3c387abdbb2065 (patch) | |
tree | af4a70e78ecc76a9e93ffcd23323f48c9da89d35 /ext/fg/js/popup.js | |
parent | e645296b1b5e993355844f2cb2b026b87d05759e (diff) | |
parent | 810a7e7d92d15412974810702d954de60453dd31 (diff) |
Merge pull request #357 from siikamiika/simplify-display-prepare
Simplify display prepare
Diffstat (limited to 'ext/fg/js/popup.js')
-rw-r--r-- | ext/fg/js/popup.js | 25 |
1 files changed, 10 insertions, 15 deletions
diff --git a/ext/fg/js/popup.js b/ext/fg/js/popup.js index 0b142dda..d077b1f8 100644 --- a/ext/fg/js/popup.js +++ b/ext/fg/js/popup.js @@ -28,8 +28,6 @@ class Popup { this._child = null; this._childrenSupported = true; this._injectPromise = null; - this._isInjected = false; - this._isInjectedAndLoaded = false; this._visible = false; this._visibleOverride = null; this._options = null; @@ -118,16 +116,16 @@ class Popup { } clearAutoPlayTimer() { - if (this._isInjectedAndLoaded) { - this._invokeApi('clearAutoPlayTimer'); - } + this._invokeApi('clearAutoPlayTimer'); } setContentScale(scale) { this._contentScale = scale; - if (this._isInjectedAndLoaded) { - this._invokeApi('setContentScale', {scale}); - } + this._invokeApi('setContentScale', {scale}); + } + + setDisplayInitialized() { + throw new Error('Override me'); } // Popup-only public functions @@ -147,7 +145,7 @@ class Popup { } isVisibleSync() { - return this._isInjected && (this._visibleOverride !== null ? this._visibleOverride : this._visible); + return (this._visibleOverride !== null ? this._visibleOverride : this._visible); } updateTheme() { @@ -226,7 +224,6 @@ class Popup { return new Promise((resolve) => { const parentFrameId = (typeof this._frameId === 'number' ? this._frameId : null); this._container.addEventListener('load', () => { - this._isInjectedAndLoaded = true; this._invokeApi('initialize', { options: this._options, popupInfo: { @@ -238,12 +235,11 @@ class Popup { childrenSupported: this._childrenSupported, scale: this._contentScale }); - resolve(); + this.setDisplayInitialized = resolve; }); this._observeFullscreen(); this._onFullscreenChanged(); this.setCustomOuterCss(this._options.general.customPopupOuterCss, false); - this._isInjected = true; }); } @@ -328,10 +324,9 @@ class Popup { } _invokeApi(action, params={}) { - if (!this._isInjectedAndLoaded) { - throw new Error('Frame not loaded'); + if (this._container.contentWindow) { + this._container.contentWindow.postMessage({action, params}, '*'); } - this._container.contentWindow.postMessage({action, params}, '*'); } _observeFullscreen() { |