summaryrefslogtreecommitdiff
path: root/ext/js/display/display-notification.js
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2023-11-27 12:48:14 -0500
committertoasted-nutbread <toasted-nutbread@users.noreply.github.com>2023-11-27 12:48:14 -0500
commit4da4827bcbcdd1ef163f635d9b29416ff272b0bb (patch)
treea8a0f1a8befdb78a554e1be91f2c6059ca3ad5f9 /ext/js/display/display-notification.js
parentfd6bba8a2a869eaf2b2c1fa49001f933fce3c618 (diff)
Add JSDoc type annotations to project (rebased)
Diffstat (limited to 'ext/js/display/display-notification.js')
-rw-r--r--ext/js/display/display-notification.js32
1 files changed, 30 insertions, 2 deletions
diff --git a/ext/js/display/display-notification.js b/ext/js/display/display-notification.js
index 0c26c613..b3f20700 100644
--- a/ext/js/display/display-notification.js
+++ b/ext/js/display/display-notification.js
@@ -19,23 +19,36 @@
import {EventListenerCollection} from '../core.js';
export class DisplayNotification {
+ /**
+ * @param {HTMLElement} container
+ * @param {HTMLElement} node
+ */
constructor(container, node) {
+ /** @type {HTMLElement} */
this._container = container;
+ /** @type {HTMLElement} */
this._node = node;
- this._body = node.querySelector('.footer-notification-body');
- this._closeButton = node.querySelector('.footer-notification-close-button');
+ /** @type {HTMLElement} */
+ this._body = /** @type {HTMLElement} */ (node.querySelector('.footer-notification-body'));
+ /** @type {HTMLElement} */
+ this._closeButton = /** @type {HTMLElement} */ (node.querySelector('.footer-notification-close-button'));
+ /** @type {EventListenerCollection} */
this._eventListeners = new EventListenerCollection();
+ /** @type {?number} */
this._closeTimer = null;
}
+ /** @type {HTMLElement} */
get container() {
return this._container;
}
+ /** @type {HTMLElement} */
get node() {
return this._node;
}
+ /** */
open() {
if (!this.isClosed()) { return; }
@@ -50,6 +63,9 @@ export class DisplayNotification {
this._eventListeners.addEventListener(this._closeButton, 'click', this._onCloseButtonClick.bind(this), false);
}
+ /**
+ * @param {boolean} [animate]
+ */
close(animate=false) {
if (this.isClosed()) { return; }
@@ -69,6 +85,9 @@ export class DisplayNotification {
}
}
+ /**
+ * @param {string|Node} value
+ */
setContent(value) {
if (typeof value === 'string') {
this._body.textContent = value;
@@ -78,25 +97,34 @@ export class DisplayNotification {
}
}
+ /**
+ * @returns {boolean}
+ */
isClosing() {
return this._closeTimer !== null;
}
+ /**
+ * @returns {boolean}
+ */
isClosed() {
return this._node.parentNode === null;
}
// Private
+ /** */
_onCloseButtonClick() {
this.close(true);
}
+ /** */
_onDelayClose() {
this._closeTimer = null;
this.close(false);
}
+ /** */
_clearTimer() {
if (this._closeTimer !== null) {
clearTimeout(this._closeTimer);