summaryrefslogtreecommitdiff
path: root/ext/fg/js/float.js
diff options
context:
space:
mode:
Diffstat (limited to 'ext/fg/js/float.js')
-rw-r--r--ext/fg/js/float.js12
1 files changed, 9 insertions, 3 deletions
diff --git a/ext/fg/js/float.js b/ext/fg/js/float.js
index 83355c5c..2837f748 100644
--- a/ext/fg/js/float.js
+++ b/ext/fg/js/float.js
@@ -30,6 +30,7 @@ class DisplayFloat extends Display {
this._secret = yomichan.generateId(16);
this._token = null;
this._nestedPopupsPrepared = false;
+ this._ownerFrameId = null;
this._windowMessageHandlers = new Map([
['initialize', {handler: this._onMessageInitialize.bind(this), authenticate: false}],
['configure', {handler: this._onMessageConfigure.bind(this)}],
@@ -60,7 +61,7 @@ class DisplayFloat extends Display {
}
onEscape() {
- window.parent.postMessage('popupClose', '*');
+ this._invoke('closePopup');
}
async setOptionsContext(optionsContext) {
@@ -134,7 +135,8 @@ class DisplayFloat extends Display {
this._initialize(params);
}
- async _onMessageConfigure({messageId, frameId, popupId, optionsContext, childrenSupported, scale}) {
+ async _onMessageConfigure({messageId, frameId, ownerFrameId, popupId, optionsContext, childrenSupported, scale}) {
+ this._ownerFrameId = ownerFrameId;
this.setOptionsContext(optionsContext);
await this.updateOptions();
@@ -173,7 +175,7 @@ class DisplayFloat extends Display {
// Private
_copySelection() {
- window.parent.postMessage('selectionCopy', '*');
+ this._invoke('copySelection');
}
_clearAutoPlayTimer() {
@@ -266,4 +268,8 @@ class DisplayFloat extends Display {
);
await frontend.prepare();
}
+
+ _invoke(action, params={}) {
+ return api.crossFrame.invoke(this._ownerFrameId, action, params);
+ }
}