diff --git a/ext/js/display/search-main.js b/ext/js/display/search-main.js index 050fe167bb..377953f68f 100644 --- a/ext/js/display/search-main.js +++ b/ext/js/display/search-main.js @@ -54,8 +54,8 @@ await Application.main(true, async (application) => { const searchDisplayController = new SearchDisplayController(display, displayAudio, searchPersistentStateController); await searchDisplayController.prepare(); - const modalController = new ModalController(); - modalController.prepare(); + const modalController = new ModalController([]); + await modalController.prepare(); const settingsController = new SettingsController(application); await settingsController.prepare(); diff --git a/ext/js/pages/permissions-main.js b/ext/js/pages/permissions-main.js index 9f37f11bfd..cc31f8d6ba 100644 --- a/ext/js/pages/permissions-main.js +++ b/ext/js/pages/permissions-main.js @@ -87,8 +87,8 @@ function setupPermissionsToggles() { } await Application.main(true, async (application) => { - const modalController = new ModalController(); - modalController.prepare(); + const modalController = new ModalController([]); + await modalController.prepare(); const settingsController = new SettingsController(application); await settingsController.prepare(); diff --git a/ext/js/pages/settings/modal-controller.js b/ext/js/pages/settings/modal-controller.js index 36e8505542..fb3a0dbc14 100644 --- a/ext/js/pages/settings/modal-controller.js +++ b/ext/js/pages/settings/modal-controller.js @@ -16,18 +16,34 @@ * along with this program. If not, see . */ +import {HtmlTemplateCollection} from '../../dom/html-template-collection.js'; import {Modal} from './modal.js'; export class ModalController { - constructor() { + /** + * @param {string[]} templateNames + */ + constructor(templateNames) { /** @type {Modal[]} */ this._modals = []; /** @type {Map} */ this._modalMap = new Map(); + /** @type {HtmlTemplateCollection} */ + this._templates = new HtmlTemplateCollection(); + /** @type {string[]} */ + this._templateNames = templateNames; } /** */ - prepare() { + async prepare() { + if (this._templateNames.length > 0) { + await this._templates.loadFromFiles(['/templates-modals.html']); + for (const name of this._templateNames) { + const template = this._templates.getTemplateContent(name); + document.body.appendChild(template); + } + } + const idSuffix = '-modal'; for (const node of /** @type {NodeListOf} */ (document.querySelectorAll('.modal'))) { let {id} = node; diff --git a/ext/js/pages/settings/settings-main.js b/ext/js/pages/settings/settings-main.js index ebb51276c3..f070c03876 100644 --- a/ext/js/pages/settings/settings-main.js +++ b/ext/js/pages/settings/settings-main.js @@ -85,8 +85,8 @@ await Application.main(true, async (application) => { const preparePromises = []; - const modalController = new ModalController(); - modalController.prepare(); + const modalController = new ModalController(['shared-modals', 'settings-modals']); + await modalController.prepare(); const settingsController = new SettingsController(application); await settingsController.prepare(); diff --git a/ext/js/pages/welcome-main.js b/ext/js/pages/welcome-main.js index 349b09ac49..ae00c0c637 100644 --- a/ext/js/pages/welcome-main.js +++ b/ext/js/pages/welcome-main.js @@ -60,8 +60,8 @@ async function checkNeedsCustomTemplatesWarning() { } await Application.main(true, async (application) => { - const modalController = new ModalController(); - modalController.prepare(); + const modalController = new ModalController(['shared-modals']); + await modalController.prepare(); const settingsController = new SettingsController(application); await settingsController.prepare(); diff --git a/ext/settings.html b/ext/settings.html index dc751d9292..dc056e8013 100644 --- a/ext/settings.html +++ b/ext/settings.html @@ -2376,1481 +2376,5 @@

Yomitan Settings

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/ext/templates-modals.html b/ext/templates-modals.html new file mode 100644 index 0000000000..09e4eb997c --- /dev/null +++ b/ext/templates-modals.html @@ -0,0 +1,1477 @@ +Templates + + + + + + diff --git a/ext/welcome.html b/ext/welcome.html index 30ba352118..2d292df53d 100644 --- a/ext/welcome.html +++ b/ext/welcome.html @@ -199,338 +199,5 @@

Basic customization

- - - - - - - - - - - - - - - - - - - - - - - -