aboutsummaryrefslogtreecommitdiff
path: root/ext/bg/js/settings/modal.js
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2020-10-08 22:44:55 -0400
committerGitHub <noreply@github.com>2020-10-08 22:44:55 -0400
commit1ae8fb4bfa356cd14ab2a038bd86d7b49fada359 (patch)
tree8849089606d1237dfdf05bd3e51b9bffc3671be3 /ext/bg/js/settings/modal.js
parentbedcad6ab2d39ab8ae74b70803fe92fa09d07db3 (diff)
Modal updates 2 (#901)
* Fix incorrect visible value * Focus element when visibility is set * Add isVisible function
Diffstat (limited to 'ext/bg/js/settings/modal.js')
-rw-r--r--ext/bg/js/settings/modal.js16
1 files changed, 14 insertions, 2 deletions
diff --git a/ext/bg/js/settings/modal.js b/ext/bg/js/settings/modal.js
index f9a8ec6b..55f73406 100644
--- a/ext/bg/js/settings/modal.js
+++ b/ext/bg/js/settings/modal.js
@@ -29,11 +29,23 @@ class Modal extends EventDispatcher {
return this._node;
}
+ isVisible() {
+ if (this._useJqueryModal()) {
+ return !!(this._getWrappedNode().data('bs.modal') || {}).isShown;
+ } else {
+ return this._node.classList.contains(this._visibleClassName);
+ }
+ }
+
setVisible(value) {
+ value = !!value;
if (this._useJqueryModal()) {
this._getWrappedNode().modal(value ? 'show' : 'hide');
} else {
- this._node.classList.toggle(this._visibleClassName, value);
+ const {classList} = this._node;
+ if (classList.contains(this._visibleClassName) === value) { return; }
+ classList.toggle(this._visibleClassName, value);
+ if (value) { this._node.focus(); }
}
}
@@ -86,7 +98,7 @@ class Modal extends EventDispatcher {
const visible = this._node.classList.contains(this._visibleClassName);
if (this._visible === visible) { return; }
this._visible = visible;
- this.trigger('visibilityChanged', {visible: false});
+ this.trigger('visibilityChanged', {visible});
}
_useJqueryModal() {