diff options
| author | toasted-nutbread <toasted-nutbread@users.noreply.github.com> | 2021-01-30 19:47:16 -0500 | 
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-01-30 19:47:16 -0500 | 
| commit | 60c38ab83c429d9e4853dbd4ea9fa06eb8f9efa6 (patch) | |
| tree | 9cee934377c6d80ab53b852b876a9d82e48f9882 /ext/bg/js/settings/modal-controller.js | |
| parent | 828c4b11c14a13abe6ce352177ece341471e374f (diff) | |
Modal refactor (#1335)
* Rename modal-container to modal
* Update how modal IDs are handled
* Fix invalid modal check
* Update modal IDs
Diffstat (limited to 'ext/bg/js/settings/modal-controller.js')
| -rw-r--r-- | ext/bg/js/settings/modal-controller.js | 16 | 
1 files changed, 12 insertions, 4 deletions
| diff --git a/ext/bg/js/settings/modal-controller.js b/ext/bg/js/settings/modal-controller.js index 832ea437..fe4f911b 100644 --- a/ext/bg/js/settings/modal-controller.js +++ b/ext/bg/js/settings/modal-controller.js @@ -26,17 +26,25 @@ class ModalController {      }      prepare() { -        for (const node of document.querySelectorAll('.modal,.modal-container')) { -            const {id} = node; +        const idSuffix = '-modal'; +        for (const node of document.querySelectorAll('.modal')) { +            let {id} = node; +            if (typeof id !== 'string') { continue; } + +            if (id.endsWith(idSuffix)) { +                id = id.substring(0, id.length - idSuffix.length); +            } +              const modal = new Modal(node);              modal.prepare();              this._modalMap.set(id, modal); +            this._modalMap.set(node, modal);              this._modals.push(modal);          }      } -    getModal(name) { -        const modal = this._modalMap.get(name); +    getModal(nameOrNode) { +        const modal = this._modalMap.get(nameOrNode);          return (typeof modal !== 'undefined' ? modal : null);      } |