summaryrefslogtreecommitdiff
path: root/ext/js/pages/settings/modal-controller.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/modal-controller.js
parentfd6bba8a2a869eaf2b2c1fa49001f933fce3c618 (diff)
parent23e6fb76319c9ed7c9bcdc3efba39bc5dd38f288 (diff)
Merge pull request #339 from toasted-nutbread/type-annotations
Type annotations
Diffstat (limited to 'ext/js/pages/settings/modal-controller.js')
-rw-r--r--ext/js/pages/settings/modal-controller.js12
1 files changed, 11 insertions, 1 deletions
diff --git a/ext/js/pages/settings/modal-controller.js b/ext/js/pages/settings/modal-controller.js
index 517a19b3..852bdcc5 100644
--- a/ext/js/pages/settings/modal-controller.js
+++ b/ext/js/pages/settings/modal-controller.js
@@ -20,13 +20,16 @@ import {Modal} from './modal.js';
export class ModalController {
constructor() {
+ /** @type {Modal[]} */
this._modals = [];
+ /** @type {Map<string|Element, Modal>} */
this._modalMap = new Map();
}
+ /** */
prepare() {
const idSuffix = '-modal';
- for (const node of document.querySelectorAll('.modal')) {
+ for (const node of /** @type {NodeListOf<HTMLElement>} */ (document.querySelectorAll('.modal'))) {
let {id} = node;
if (typeof id !== 'string') { continue; }
@@ -42,11 +45,18 @@ export class ModalController {
}
}
+ /**
+ * @param {string|Element} nameOrNode
+ * @returns {?Modal}
+ */
getModal(nameOrNode) {
const modal = this._modalMap.get(nameOrNode);
return (typeof modal !== 'undefined' ? modal : null);
}
+ /**
+ * @returns {?Modal}
+ */
getTopVisibleModal() {
for (let i = this._modals.length - 1; i >= 0; --i) {
const modal = this._modals[i];