aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsiikamiika <siikamiika@users.noreply.github.com>2019-09-01 19:47:33 +0300
committertoasted-nutbread <toasted-nutbread@users.noreply.github.com>2019-09-02 19:33:52 -0400
commit2df9a7f97794df46aac70a23bb2b62dbd2752a5a (patch)
tree4da8c108f21b1943c8b2d2d4c47ff498ddb068c2
parent97be029deee4ec34ad2e90081af15d573dede0cd (diff)
change Popup.children to Popup.child
-rw-r--r--ext/fg/js/popup-proxy-host.js2
-rw-r--r--ext/fg/js/popup-proxy.js2
-rw-r--r--ext/fg/js/popup.js18
3 files changed, 6 insertions, 16 deletions
diff --git a/ext/fg/js/popup-proxy-host.js b/ext/fg/js/popup-proxy-host.js
index 1048f410..fa61aeb4 100644
--- a/ext/fg/js/popup-proxy-host.js
+++ b/ext/fg/js/popup-proxy-host.js
@@ -57,7 +57,7 @@ class PopupProxyHost {
const popup = new Popup(id, depth, this.frameIdPromise);
if (parent !== null) {
popup.parent = parent;
- parent.children.push(popup);
+ parent.child = popup;
}
this.popups[id] = popup;
return popup;
diff --git a/ext/fg/js/popup-proxy.js b/ext/fg/js/popup-proxy.js
index 112b998e..f6295079 100644
--- a/ext/fg/js/popup-proxy.js
+++ b/ext/fg/js/popup-proxy.js
@@ -24,7 +24,7 @@ class PopupProxy {
this.id = null;
this.idPromise = null;
this.parent = null;
- this.children = [];
+ this.child = null;
this.depth = 0;
this.container = null;
diff --git a/ext/fg/js/popup.js b/ext/fg/js/popup.js
index 61a5e4d0..3bc0b6f8 100644
--- a/ext/fg/js/popup.js
+++ b/ext/fg/js/popup.js
@@ -24,7 +24,7 @@ class Popup {
this.frameIdPromise = frameIdPromise;
this.frameId = null;
this.parent = null;
- this.children = [];
+ this.child = null;
this.container = document.createElement('iframe');
this.container.id = 'yomichan-float';
this.container.addEventListener('mousedown', e => e.stopPropagation());
@@ -212,19 +212,9 @@ class Popup {
}
hideChildren() {
- if (this.children.length === 0) {
- return;
- }
-
- const targets = this.children.slice(0);
- while (targets.length > 0) {
- const target = targets.shift();
- if (target.isContainerHidden()) { continue; }
-
- target.hide();
- for (const child of target.children) {
- targets.push(child);
- }
+ // recursively hides all children
+ if (this.child && !this.child.isContainerHidden()) {
+ this.child.hide();
}
}