summaryrefslogtreecommitdiff
path: root/ext/js/pages/settings/status-footer.js
diff options
context:
space:
mode:
authorDarius Jahandarie <djahandarie@gmail.com>2023-12-06 03:53:16 +0000
committerGitHub <noreply@github.com>2023-12-06 03:53:16 +0000
commitbd5bc1a5db29903bc098995cd9262c4576bf76af (patch)
treec9214189e0214480fcf6539ad1c6327aef6cbd1c /ext/js/pages/settings/status-footer.js
parentfd6bba8a2a869eaf2b2c1fa49001f933fce3c618 (diff)
parent23e6fb76319c9ed7c9bcdc3efba39bc5dd38f288 (diff)
Merge pull request #339 from toasted-nutbread/type-annotations
Type annotations
Diffstat (limited to 'ext/js/pages/settings/status-footer.js')
-rw-r--r--ext/js/pages/settings/status-footer.js34
1 files changed, 28 insertions, 6 deletions
diff --git a/ext/js/pages/settings/status-footer.js b/ext/js/pages/settings/status-footer.js
index 6c64794f..a8f1a8c4 100644
--- a/ext/js/pages/settings/status-footer.js
+++ b/ext/js/pages/settings/status-footer.js
@@ -19,34 +19,52 @@
import {PanelElement} from '../../dom/panel-element.js';
export class StatusFooter extends PanelElement {
+ /**
+ * @param {HTMLElement} node
+ */
constructor(node) {
super({
node,
closingAnimationDuration: 375 // Milliseconds; includes buffer
});
- this._body = node.querySelector('.status-footer');
+ /** @type {HTMLElement} */
+ this._body = /** @type {HTMLElement} */ (node.querySelector('.status-footer'));
}
+ /** */
prepare() {
- this.on('closeCompleted', this._onCloseCompleted.bind(this), false);
- this._body.querySelector('.status-footer-header-close').addEventListener('click', this._onCloseClick.bind(this), false);
+ const closeButton = /** @type {HTMLElement} */ (this._body.querySelector('.status-footer-header-close'));
+ this.on('closeCompleted', this._onCloseCompleted.bind(this));
+ closeButton.addEventListener('click', this._onCloseClick.bind(this), false);
}
+ /**
+ * @param {string} selector
+ * @returns {?HTMLElement}
+ */
getTaskContainer(selector) {
return this._body.querySelector(selector);
}
+ /**
+ * @param {string} selector
+ * @returns {boolean}
+ */
isTaskActive(selector) {
const target = this.getTaskContainer(selector);
- return (target !== null && target.dataset.active);
+ return (target !== null && !!target.dataset.active);
}
+ /**
+ * @param {string} selector
+ * @param {boolean} active
+ */
setTaskActive(selector, active) {
const target = this.getTaskContainer(selector);
if (target === null) { return; }
const activeElements = new Set();
- for (const element of this._body.querySelectorAll('.status-footer-item')) {
+ for (const element of /** @type {NodeListOf<HTMLElement>} */ (this._body.querySelectorAll('.status-footer-item'))) {
if (element.dataset.active) {
activeElements.add(element);
}
@@ -68,13 +86,17 @@ export class StatusFooter extends PanelElement {
// Private
+ /**
+ * @param {MouseEvent} e
+ */
_onCloseClick(e) {
e.preventDefault();
this.setVisible(false);
}
+ /** */
_onCloseCompleted() {
- for (const element of this._body.querySelectorAll('.status-footer-item')) {
+ for (const element of /** @type {NodeListOf<HTMLElement>} */ (this._body.querySelectorAll('.status-footer-item'))) {
if (!element.dataset.active) {
element.hidden = true;
}