aboutsummaryrefslogtreecommitdiff
path: root/ext/fg
diff options
context:
space:
mode:
authorsiikamiika <siikamiika@users.noreply.github.com>2020-02-13 13:18:54 +0200
committersiikamiika <siikamiika@users.noreply.github.com>2020-02-13 13:18:54 +0200
commitc0225f1f844376e5f61222a4d8186a2c914026eb (patch)
treec24d7b5c069a00e3781f14f7a627a712d05783b6 /ext/fg
parentdf37acd17f9459c17185552f11dc4cc424e01958 (diff)
notify popup about initialization
Diffstat (limited to 'ext/fg')
-rw-r--r--ext/fg/js/float.js2
-rw-r--r--ext/fg/js/popup.js20
2 files changed, 21 insertions, 1 deletions
diff --git a/ext/fg/js/float.js b/ext/fg/js/float.js
index 3766d5a4..8871160f 100644
--- a/ext/fg/js/float.js
+++ b/ext/fg/js/float.js
@@ -45,6 +45,8 @@ class DisplayFloat extends Display {
}
this.setContentScale(scale);
+
+ window.parent.postMessage('initialized', '*');
}
onError(error) {
diff --git a/ext/fg/js/popup.js b/ext/fg/js/popup.js
index e7dae93e..6cfe49e5 100644
--- a/ext/fg/js/popup.js
+++ b/ext/fg/js/popup.js
@@ -45,6 +45,8 @@ class Popup {
this._container.style.height = '0px';
this._updateVisibility();
+
+ window.addEventListener('message', (e) => this.onMessage(e), false);
}
// Public properties
@@ -129,6 +131,18 @@ class Popup {
}
}
+ onMessage(e) {
+ const action = e.data;
+ const handler = Popup._windowMessageHandlers.get(action);
+ if (typeof handler !== 'function') { return; }
+
+ handler(this);
+ }
+
+ setInitialized() {
+ throw new Error('Override me');
+ }
+
// Popup-only public functions
setParent(parent) {
@@ -237,7 +251,7 @@ class Popup {
childrenSupported: this._childrenSupported,
scale: this._contentScale
});
- resolve();
+ this.setInitialized = resolve;
});
this._observeFullscreen();
this._onFullscreenChanged();
@@ -535,4 +549,8 @@ class Popup {
}
}
+Popup._windowMessageHandlers = new Map([
+ ['initialized', (self) => self.setInitialized()]
+]);
+
Popup.outerStylesheet = null;