aboutsummaryrefslogtreecommitdiff
path: root/ext/fg/js/popup.js
diff options
context:
space:
mode:
authorAlex Yatskov <FooSoft@users.noreply.github.com>2019-10-05 19:48:21 -0700
committerGitHub <noreply@github.com>2019-10-05 19:48:21 -0700
commita4d2bde5dfbe17c03e5aede38ccd4b27753aef48 (patch)
tree7f60cf5f6004145496351139e42d4b5c71cfbb5a /ext/fg/js/popup.js
parentbac237336e4578e339069a8d9d8f83703a3cee5d (diff)
parent113cc725c1764e5eb814a22ace23a7e7150d016f (diff)
Merge pull request #240 from toasted-nutbread/fix-focus
Fix focus
Diffstat (limited to 'ext/fg/js/popup.js')
-rw-r--r--ext/fg/js/popup.js49
1 files changed, 24 insertions, 25 deletions
diff --git a/ext/fg/js/popup.js b/ext/fg/js/popup.js
index 9dff6f28..9ca91afa 100644
--- a/ext/fg/js/popup.js
+++ b/ext/fg/js/popup.js
@@ -34,6 +34,9 @@ class Popup {
this.container.style.height = '0px';
this.injectPromise = null;
this.isInjected = false;
+ this.visible = false;
+ this.visibleOverride = null;
+ this.updateVisibility();
}
inject(options) {
@@ -105,9 +108,11 @@ class Popup {
container.style.top = `${y}px`;
container.style.width = `${width}px`;
container.style.height = `${height}px`;
- container.style.visibility = 'visible';
- this.hideChildren(true);
+ this.setVisible(true);
+ if (this.child !== null) {
+ this.child.hide(true);
+ }
}
static getPositionForHorizontalText(elementRect, width, height, maxWidth, maxHeight, optionsGeneral) {
@@ -209,41 +214,35 @@ class Popup {
}
hide(changeFocus) {
- if (this.isContainerHidden()) {
- changeFocus = false;
+ if (!this.isVisible()) {
+ return;
+ }
+
+ this.setVisible(false);
+ if (this.child !== null) {
+ this.child.hide(false);
}
- this.hideChildren(changeFocus);
- this.hideContainer();
if (changeFocus) {
this.focusParent();
}
}
- hideChildren(changeFocus) {
- // Recursively hides all children.
- if (this.child !== null && !this.child.isContainerHidden()) {
- this.child.hide(changeFocus);
- }
- }
-
- hideContainer() {
- this.container.style.visibility = 'hidden';
+ isVisible() {
+ return this.isInjected && (this.visibleOverride !== null ? this.visibleOverride : this.visible);
}
- isContainerHidden() {
- return (this.container.style.visibility === 'hidden');
+ setVisible(visible) {
+ this.visible = visible;
+ this.updateVisibility();
}
- isVisible() {
- return this.isInjected && this.container.style.visibility !== 'hidden';
+ setVisibleOverride(visible) {
+ this.visibleOverride = visible;
+ this.updateVisibility();
}
- setVisible(visible) {
- if (visible) {
- this.container.style.setProperty('display', '');
- } else {
- this.container.style.setProperty('display', 'none', 'important');
- }
+ updateVisibility() {
+ this.container.style.setProperty('visibility', this.isVisible() ? 'visible' : 'hidden', 'important');
}
focusParent() {