diff --git a/src/components/imageOptionsEditor/imageOptionsEditor.js b/src/components/imageOptionsEditor/imageOptionsEditor.js index 8177e1b779..b857548ec3 100644 --- a/src/components/imageOptionsEditor/imageOptionsEditor.js +++ b/src/components/imageOptionsEditor/imageOptionsEditor.js @@ -89,29 +89,37 @@ import 'emby-input'; }); } -export class showEditor { - constructor(itemType, options, availableOptions) { - return import('text!./components/imageOptionsEditor/imageOptionsEditor.template.html').then(({default: template}) => { - return new Promise((resolve) => { - const dlg = dialogHelper.createDialog({ - size: 'small', - removeOnClose: true, - scrollY: false - }); - dlg.classList.add('formDialog'); - dlg.innerHTML = globalize.translateDocument(template); - dlg.addEventListener('close', () => { - saveValues(dlg, options); - }); - loadValues(dlg, itemType, options, availableOptions); - dialogHelper.open(dlg).then(resolve, resolve); - dlg.querySelector('.btnCancel').addEventListener('click', () => { - dialogHelper.close(dlg); - }); - }); + async function showEditor(itemType, options, availableOptions) { + const response = await fetch('components/imageOptionsEditor/imageOptionsEditor.template.html'); + const template = await response.text(); + + var dlg = dialogHelper.createDialog({ + size: 'small', + removeOnClose: true, + scrollY: false }); + dlg.classList.add('formDialog'); + dlg.innerHTML = globalize.translateDocument(template); + dlg.addEventListener('close', function () { + saveValues(dlg, options); + }); + loadValues(dlg, itemType, options, availableOptions); + dialogHelper.open(dlg).then(() => { + return; + }).catch(() => { + return; + }); + dlg.querySelector('.btnCancel').addEventListener('click', function () { + dialogHelper.close(dlg); + }); + + } + +export class editor { + constructor() { + this.show = showEditor; } } /* eslint-enable indent */ -export default showEditor; +export default editor; diff --git a/src/components/libraryoptionseditor/libraryoptionseditor.js b/src/components/libraryoptionseditor/libraryoptionseditor.js index f7c1ff1361..5d28fbbaa1 100644 --- a/src/components/libraryoptionseditor/libraryoptionseditor.js +++ b/src/components/libraryoptionseditor/libraryoptionseditor.js @@ -306,7 +306,7 @@ import 'emby-input'; } function showImageOptionsForType(type) { - import('imageoptionseditor').then(ImageOptionsEditor => { + import('imageoptionseditor').then(({default: ImageOptionsEditor}) => { let typeOptions = getTypeOptions(currentLibraryOptions, type); if (!typeOptions) { typeOptions = { @@ -315,7 +315,8 @@ import 'emby-input'; currentLibraryOptions.TypeOptions.push(typeOptions); } const availableOptions = getTypeOptions(currentAvailableOptions || {}, type); - new ImageOptionsEditor.showEditor(type, typeOptions, availableOptions); + const imageOptionsEditor = new ImageOptionsEditor(); + imageOptionsEditor.show(type, typeOptions, availableOptions); }); } @@ -356,25 +357,23 @@ import 'emby-input'; parent.querySelector('.imageFetchers').addEventListener('click', onImageFetchersContainerClick); } - export function embed(parent, contentType, libraryOptions) { + export async function embed(parent, contentType, libraryOptions) { currentLibraryOptions = { TypeOptions: [] }; currentAvailableOptions = null; const isNewLibrary = null === libraryOptions; isNewLibrary && parent.classList.add('newlibrary'); - return import('text!./libraryoptionseditor.template.html').then(({default: template}) => { - return new Promise((resolve) => { - parent.innerHTML = globalize.translateDocument(template); - populateRefreshInterval(parent.querySelector('#selectAutoRefreshInterval')); - const promises = [populateLanguages(parent), populateCountries(parent.querySelector('#selectCountry'))]; - Promise.all(promises).then(() => { - return setContentType(parent, contentType).then(() => { - libraryOptions && setLibraryOptions(parent, libraryOptions); - bindEvents(parent); - resolve(); - }); - }); + const response = await fetch('components/libraryoptionseditor/libraryoptionseditor.template.html'); + const template = await response.text(); + parent.innerHTML = globalize.translateDocument(template); + populateRefreshInterval(parent.querySelector('#selectAutoRefreshInterval')); + const promises = [populateLanguages(parent), populateCountries(parent.querySelector('#selectCountry'))]; + Promise.all(promises).then(function() { + return setContentType(parent, contentType).then(function() { + libraryOptions && setLibraryOptions(parent, libraryOptions); + bindEvents(parent); + return; }); }); }