aboutsummaryrefslogtreecommitdiff
path: root/ext/js/pages/settings/modal-controller.js
diff options
context:
space:
mode:
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];