aboutsummaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2020-10-18 09:39:55 -0400
committerGitHub <noreply@github.com>2020-10-18 09:39:55 -0400
commitd35d1fd44a20175aa8eff72f7e96234f4868bfd8 (patch)
treedd35fc1ca19f8bf511175b76cedce8d3fa7016be /ext
parent6f1bdf0c6664a0af608913093fd086b43bdf8700 (diff)
Generalize modal, move to popup-elements.js (#931)
Diffstat (limited to 'ext')
-rw-r--r--ext/bg/js/settings/popup-elements.js (renamed from ext/bg/js/settings/modal.js)32
1 files changed, 18 insertions, 14 deletions
diff --git a/ext/bg/js/settings/modal.js b/ext/bg/js/settings/popup-elements.js
index dadab111..1a35ddc9 100644
--- a/ext/bg/js/settings/modal.js
+++ b/ext/bg/js/settings/popup-elements.js
@@ -15,16 +15,16 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
-class Modal extends EventDispatcher {
- constructor(node) {
+class PopupElement extends EventDispatcher {
+ constructor({node, visibleClassName, openingClassName, closingClassName, closingAnimationDuration}) {
super();
this._node = node;
+ this._visibleClassName = visibleClassName;
+ this._openingClassName = openingClassName;
+ this._closingClassName = closingClassName;
+ this._closingAnimationDuration = closingAnimationDuration;
this._mutationObserver = null;
this._visible = false;
- this._visibleClassName = 'modal-container-open';
- this._openingClassName = 'modal-container-opening';
- this._closingClassName = 'modal-container-closing';
- this._closingAnimationDuration = 375; // Milliseconds; includes buffer
this._closeTimer = null;
}
@@ -93,14 +93,6 @@ class Modal extends EventDispatcher {
// Private
- _onModalHide() {
- this.trigger('visibilityChanged', {visible: false});
- }
-
- _onModalShow() {
- this.trigger('visibilityChanged', {visible: true});
- }
-
_onMutation() {
const visible = this._node.classList.contains(this._visibleClassName);
if (this._visible === visible) { return; }
@@ -108,3 +100,15 @@ class Modal extends EventDispatcher {
this.trigger('visibilityChanged', {visible});
}
}
+
+class Modal extends EventDispatcher {
+ constructor(node) {
+ super({
+ node,
+ visibleClassName: 'modal-container-open',
+ openingClassName: 'modal-container-opening',
+ closingClassName: 'modal-container-closing',
+ closingAnimationDuration: 375 // Milliseconds; includes buffer
+ });
+ }
+}