summaryrefslogtreecommitdiff
path: root/ext/fg/js/popup.js
diff options
context:
space:
mode:
authorsiikamiika <siikamiika@users.noreply.github.com>2020-03-13 23:23:08 +0200
committersiikamiika <siikamiika@users.noreply.github.com>2020-03-21 22:13:07 +0200
commit962c2a381f3dace4d97fd0625504ec841e378354 (patch)
tree92ea4bee6a3a70f61965e98ca143b2a18cfcdad3 /ext/fg/js/popup.js
parent647769f2baae338f201690f21c4bf8983bcb10b0 (diff)
apply all options on profile change
Diffstat (limited to 'ext/fg/js/popup.js')
-rw-r--r--ext/fg/js/popup.js34
1 files changed, 15 insertions, 19 deletions
diff --git a/ext/fg/js/popup.js b/ext/fg/js/popup.js
index d752812e..e6e93a76 100644
--- a/ext/fg/js/popup.js
+++ b/ext/fg/js/popup.js
@@ -210,11 +210,9 @@ class Popup {
const parentFrameId = (typeof this._frameId === 'number' ? this._frameId : null);
this._container.setAttribute('src', chrome.runtime.getURL('/fg/float.html'));
this._container.addEventListener('load', () => {
- const uniqueId = yomichan.generateId(32);
- Popup._listenForDisplayPrepareCompleted(uniqueId, resolve);
+ this._listenForDisplayPrepareCompleted(resolve);
this._invokeApi('prepare', {
- options: this._options,
popupInfo: {
id: this._id,
depth: this._depth,
@@ -222,8 +220,7 @@ class Popup {
},
url: this.url,
childrenSupported: this._childrenSupported,
- scale: this._contentScale,
- uniqueId
+ scale: this._contentScale
});
});
this._observeFullscreen(true);
@@ -364,23 +361,12 @@ class Popup {
contentWindow.postMessage({action, params, token}, this._targetOrigin);
}
- static _getFullscreenElement() {
- return (
- document.fullscreenElement ||
- document.msFullscreenElement ||
- document.mozFullScreenElement ||
- document.webkitFullscreenElement ||
- null
- );
- }
-
- static _listenForDisplayPrepareCompleted(uniqueId, resolve) {
+ _listenForDisplayPrepareCompleted(resolve) {
const runtimeMessageCallback = ({action, params}, sender, callback) => {
if (
action === 'popupPrepareCompleted' &&
- typeof params === 'object' &&
- params !== null &&
- params.uniqueId === uniqueId
+ isObject(params) &&
+ params.targetPopupId === this._id
) {
chrome.runtime.onMessage.removeListener(runtimeMessageCallback);
callback();
@@ -391,6 +377,16 @@ class Popup {
chrome.runtime.onMessage.addListener(runtimeMessageCallback);
}
+ static _getFullscreenElement() {
+ return (
+ document.fullscreenElement ||
+ document.msFullscreenElement ||
+ document.mozFullScreenElement ||
+ document.webkitFullscreenElement ||
+ null
+ );
+ }
+
static _getPositionForHorizontalText(elementRect, width, height, viewport, offsetScale, optionsGeneral) {
const preferBelow = (optionsGeneral.popupHorizontalTextPosition === 'below');
const horizontalOffset = optionsGeneral.popupHorizontalOffset * offsetScale;