mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
Migration of wizard to ES6 modules
This commit is contained in:
parent
a9246f8f39
commit
c11977c9fe
6 changed files with 235 additions and 227 deletions
|
@ -1,48 +1,49 @@
|
|||
define(['jQuery', 'loading', 'emby-button', 'emby-select'], function ($, loading) {
|
||||
'use strict';
|
||||
import $ from 'jQuery';
|
||||
import loading from 'loading';
|
||||
import 'emby-button';
|
||||
import 'emby-select';
|
||||
|
||||
function loadPage(page, config, languageOptions) {
|
||||
$('#selectLocalizationLanguage', page).html(languageOptions.map(function (l) {
|
||||
return '<option value="' + l.Value + '">' + l.Name + '</option>';
|
||||
})).val(config.UICulture);
|
||||
loading.hide();
|
||||
}
|
||||
function loadPage(page, config, languageOptions) {
|
||||
$('#selectLocalizationLanguage', page).html(languageOptions.map(function (l) {
|
||||
return '<option value="' + l.Value + '">' + l.Name + '</option>';
|
||||
})).val(config.UICulture);
|
||||
loading.hide();
|
||||
}
|
||||
|
||||
function save(page) {
|
||||
function save(page) {
|
||||
loading.show();
|
||||
const apiClient = ApiClient;
|
||||
apiClient.getJSON(apiClient.getUrl('Startup/Configuration')).then(function (config) {
|
||||
config.UICulture = $('#selectLocalizationLanguage', page).val();
|
||||
apiClient.ajax({
|
||||
type: 'POST',
|
||||
data: config,
|
||||
url: apiClient.getUrl('Startup/Configuration')
|
||||
}).then(function () {
|
||||
Dashboard.navigate('wizarduser.html');
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function onSubmit() {
|
||||
save($(this).parents('.page'));
|
||||
return false;
|
||||
}
|
||||
|
||||
export default function (view, params) {
|
||||
$('.wizardStartForm', view).on('submit', onSubmit);
|
||||
view.addEventListener('viewshow', function () {
|
||||
document.querySelector('.skinHeader').classList.add('noHomeButtonHeader');
|
||||
loading.show();
|
||||
var apiClient = ApiClient;
|
||||
apiClient.getJSON(apiClient.getUrl('Startup/Configuration')).then(function (config) {
|
||||
config.UICulture = $('#selectLocalizationLanguage', page).val();
|
||||
apiClient.ajax({
|
||||
type: 'POST',
|
||||
data: config,
|
||||
url: apiClient.getUrl('Startup/Configuration')
|
||||
}).then(function () {
|
||||
Dashboard.navigate('wizarduser.html');
|
||||
});
|
||||
const page = this;
|
||||
const apiClient = ApiClient;
|
||||
const promise1 = apiClient.getJSON(apiClient.getUrl('Startup/Configuration'));
|
||||
const promise2 = apiClient.getJSON(apiClient.getUrl('Localization/Options'));
|
||||
Promise.all([promise1, promise2]).then(function (responses) {
|
||||
loadPage(page, responses[0], responses[1]);
|
||||
});
|
||||
}
|
||||
|
||||
function onSubmit() {
|
||||
save($(this).parents('.page'));
|
||||
return false;
|
||||
}
|
||||
|
||||
return function (view, params) {
|
||||
$('.wizardStartForm', view).on('submit', onSubmit);
|
||||
view.addEventListener('viewshow', function () {
|
||||
document.querySelector('.skinHeader').classList.add('noHomeButtonHeader');
|
||||
loading.show();
|
||||
var page = this;
|
||||
var apiClient = ApiClient;
|
||||
var promise1 = apiClient.getJSON(apiClient.getUrl('Startup/Configuration'));
|
||||
var promise2 = apiClient.getJSON(apiClient.getUrl('Localization/Options'));
|
||||
Promise.all([promise1, promise2]).then(function (responses) {
|
||||
loadPage(page, responses[0], responses[1]);
|
||||
});
|
||||
});
|
||||
view.addEventListener('viewhide', function () {
|
||||
document.querySelector('.skinHeader').classList.remove('noHomeButtonHeader');
|
||||
});
|
||||
};
|
||||
});
|
||||
});
|
||||
view.addEventListener('viewhide', function () {
|
||||
document.querySelector('.skinHeader').classList.remove('noHomeButtonHeader');
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue