From 613f0024bc0b1fa46c5997f9def0a5dd6f2fe6e2 Mon Sep 17 00:00:00 2001 From: Cameron Date: Thu, 9 Jul 2020 08:54:47 +0100 Subject: [PATCH] Migration of general and library details to ES6 Modules --- package.json | 2 ++ src/controllers/dashboard/general.js | 23 ++++++++++++++------- src/controllers/dashboard/librarydisplay.js | 15 ++++++++++---- 3 files changed, 29 insertions(+), 11 deletions(-) diff --git a/package.json b/package.json index 054bcb7939..5e40babfef 100644 --- a/package.json +++ b/package.json @@ -131,6 +131,8 @@ "src/components/syncPlay/timeSyncManager.js", "src/controllers/dashboard/logs.js", "src/controllers/user/subtitles.js", + "src/controllers/dashboard/general.js", + "src/controllers/dashboard/librarydisplay.js", "src/controllers/dashboard/metadataImages.js", "src/controllers/dashboard/metadatanfo.js", "src/controllers/dashboard/plugins/repositories.js", diff --git a/src/controllers/dashboard/general.js b/src/controllers/dashboard/general.js index f215ace28b..2defc6d449 100644 --- a/src/controllers/dashboard/general.js +++ b/src/controllers/dashboard/general.js @@ -1,5 +1,13 @@ -define(['jQuery', 'loading', 'globalize', 'emby-checkbox', 'emby-textarea', 'emby-input', 'emby-select', 'emby-button'], function ($, loading, globalize) { - 'use strict'; +import $ from 'jQuery'; +import loading from 'loading'; +import globalize from 'globalize'; +import 'emby-checkbox'; +import 'emby-textarea'; +import 'emby-input'; +import 'emby-select'; +import 'emby-button'; + +/* eslint-disable indent */ function loadPage(page, config, languageOptions, systemInfo) { page.querySelector('#txtServerName').value = systemInfo.ServerName; @@ -43,7 +51,7 @@ define(['jQuery', 'loading', 'globalize', 'emby-checkbox', 'emby-textarea', 'emb }); }); }, function () { - require(['alert'], function (alert) { + import('alert').then(({default: alert}) => { alert(globalize.translate('DefaultErrorMessage')); }); @@ -56,9 +64,9 @@ define(['jQuery', 'loading', 'globalize', 'emby-checkbox', 'emby-textarea', 'emb var currentBrandingOptions; var currentLanguage; var brandingConfigKey = 'branding'; - return function (view, params) { + export default function (view, params) { $('#btnSelectCachePath', view).on('click.selectDirectory', function () { - require(['directorybrowser'], function (directoryBrowser) { + import('directorybrowser').then(({default: directoryBrowser}) => { var picker = new directoryBrowser(); picker.show({ callback: function (path) { @@ -75,7 +83,7 @@ define(['jQuery', 'loading', 'globalize', 'emby-checkbox', 'emby-textarea', 'emb }); }); $('#btnSelectMetadataPath', view).on('click.selectDirectory', function () { - require(['directorybrowser'], function (directoryBrowser) { + import('directorybrowser').then(({default: directoryBrowser}) => { var picker = new directoryBrowser(); picker.show({ path: $('#txtMetadataPath', view).val(), @@ -113,4 +121,5 @@ define(['jQuery', 'loading', 'globalize', 'emby-checkbox', 'emby-textarea', 'emb }); }); }; -}); + +/* eslint-enable indent */ diff --git a/src/controllers/dashboard/librarydisplay.js b/src/controllers/dashboard/librarydisplay.js index a820c37528..95475cfb9b 100644 --- a/src/controllers/dashboard/librarydisplay.js +++ b/src/controllers/dashboard/librarydisplay.js @@ -1,5 +1,11 @@ -define(['globalize', 'loading', 'libraryMenu', 'emby-checkbox', 'emby-button', 'emby-button'], function(globalize, loading, libraryMenu) { - 'use strict'; +import globalize from 'globalize'; +import loading from 'loading'; +import libraryMenu from 'libraryMenu'; +import 'emby-checkbox'; +import 'emby-button'; +import 'emby-button'; + +/* eslint-disable indent */ function getTabs() { return [{ @@ -17,7 +23,7 @@ define(['globalize', 'loading', 'libraryMenu', 'emby-checkbox', 'emby-button', ' }]; } - return function(view, params) { + export default function(view, params) { function loadData() { ApiClient.getServerConfiguration().then(function(config) { view.querySelector('.chkFolderView').checked = config.EnableFolderView; @@ -64,4 +70,5 @@ define(['globalize', 'loading', 'libraryMenu', 'emby-checkbox', 'emby-button', ' }); }); }; -}); + + /* eslint-enable indent */