From 4da4827bcbcdd1ef163f635d9b29416ff272b0bb Mon Sep 17 00:00:00 2001 From: toasted-nutbread Date: Mon, 27 Nov 2023 12:48:14 -0500 Subject: Add JSDoc type annotations to project (rebased) --- ext/js/pages/settings/modal-controller.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'ext/js/pages/settings/modal-controller.js') 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} */ this._modalMap = new Map(); } + /** */ prepare() { const idSuffix = '-modal'; - for (const node of document.querySelectorAll('.modal')) { + for (const node of /** @type {NodeListOf} */ (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]; -- cgit v1.2.3