aboutsummaryrefslogtreecommitdiff
path: root/ext/fg/js/popup.js
diff options
context:
space:
mode:
authorsiikamiika <siikamiika@users.noreply.github.com>2020-03-21 22:29:07 +0200
committerGitHub <noreply@github.com>2020-03-21 22:29:07 +0200
commit08d38d8db2c97ff9f016a6de640f645b609088d1 (patch)
tree9060deb6f870e472c601b6cec050a2f60f62abca /ext/fg/js/popup.js
parent647769f2baae338f201690f21c4bf8983bcb10b0 (diff)
parentb616bac66ed0735c1e7ebbaf1ceba20b081f1a6f (diff)
Merge pull request #411 from siikamiika/apply-all-options-profile-change
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;