jellyfin-web/dashboard-ui/scripts/mypreferencesdisplay.js

96 lines
3.2 KiB
JavaScript
Raw Normal View History

2014-05-21 09:45:42 -07:00
(function ($, window, document) {
2015-07-03 10:55:29 -07:00
function loadForm(page, user) {
2014-08-18 18:42:53 -07:00
2015-07-28 12:42:24 -07:00
page.querySelector('.chkDisplayMissingEpisodes').checked = user.Configuration.DisplayMissingEpisodes || false;
page.querySelector('.chkDisplayUnairedEpisodes').checked = user.Configuration.DisplayUnairedEpisodes || false;
page.querySelector('.chkGroupMoviesIntoCollections').checked = user.Configuration.GroupMoviesIntoBoxSets || false;
2014-08-18 18:42:53 -07:00
2015-09-03 10:01:51 -07:00
$('#selectThemeSong', page).val(appStorage.getItem('enableThemeSongs-' + user.Id) || '');
$('#selectBackdrop', page).val(appStorage.getItem('enableBackdrops-' + user.Id) || '');
2015-03-31 09:24:16 -07:00
2015-09-03 10:01:51 -07:00
$('#selectLanguage', page).val(AppSettings.displayLanguage());
2015-08-04 11:14:16 -07:00
2015-07-28 12:42:24 -07:00
page.querySelector('.chkEnableFullScreen').checked = AppSettings.enableFullScreen();
2015-07-03 10:55:29 -07:00
Dashboard.hideLoadingMsg();
2014-05-21 09:45:42 -07:00
}
function saveUser(page, user) {
2015-07-28 12:42:24 -07:00
user.Configuration.DisplayMissingEpisodes = page.querySelector('.chkDisplayMissingEpisodes').checked;
user.Configuration.DisplayUnairedEpisodes = page.querySelector('.chkDisplayUnairedEpisodes').checked;
user.Configuration.GroupMoviesIntoBoxSets = page.querySelector('.chkGroupMoviesIntoCollections').checked;
2014-09-29 21:47:30 -07:00
2015-07-28 12:42:24 -07:00
AppSettings.enableFullScreen(page.querySelector('.chkEnableFullScreen').checked);
2015-08-04 11:14:16 -07:00
AppSettings.displayLanguage(page.querySelector('#selectLanguage').value);
2015-07-03 10:55:29 -07:00
appStorage.setItem('enableThemeSongs-' + user.Id, $('#selectThemeSong', page).val());
appStorage.setItem('enableBackdrops-' + user.Id, $('#selectBackdrop', page).val());
2014-08-18 18:42:53 -07:00
2014-12-18 21:20:07 -07:00
ApiClient.updateUserConfiguration(user.Id, user.Configuration).done(function () {
2014-05-30 12:23:56 -07:00
Dashboard.alert(Globalize.translate('SettingsSaved'));
2014-08-18 18:42:53 -07:00
2015-06-20 17:49:42 -07:00
loadForm(page, user);
2014-05-21 09:45:42 -07:00
});
}
function onSubmit() {
2015-07-29 13:31:15 -07:00
var page = $(this).parents('.page')[0];
2014-05-21 09:45:42 -07:00
Dashboard.showLoadingMsg();
var userId = getParameterByName('userId') || Dashboard.getCurrentUserId();
2014-08-18 18:42:53 -07:00
ApiClient.getUser(userId).done(function (user) {
2014-06-04 19:32:40 -07:00
2014-08-18 18:42:53 -07:00
saveUser(page, user);
2014-06-04 19:32:40 -07:00
2014-05-21 09:45:42 -07:00
});
// Disable default form submission
return false;
}
2015-09-01 07:01:59 -07:00
$(document).on('pageinit', "#displayPreferencesPage", function () {
2014-05-21 09:45:42 -07:00
var page = this;
2015-07-03 10:55:29 -07:00
$('.displayPreferencesForm').off('submit', onSubmit).on('submit', onSubmit);
2014-08-18 18:42:53 -07:00
2015-09-24 10:08:10 -07:00
}).on('pageshow', "#displayPreferencesPage", function () {
2014-05-21 09:45:42 -07:00
var page = this;
Dashboard.showLoadingMsg();
var userId = getParameterByName('userId') || Dashboard.getCurrentUserId();
ApiClient.getUser(userId).done(function (user) {
loadForm(page, user);
2015-07-03 10:55:29 -07:00
if (user.Policy.EnableUserPreferenceAccess) {
$('.requiresUserPreferences', page).show();
} else {
$('.requiresUserPreferences', page).hide();
}
2014-05-21 09:45:42 -07:00
});
2015-07-03 10:55:29 -07:00
$('.fldEnableBackdrops', page).show();
if (AppInfo.supportsFullScreen) {
$('.fldFullscreen', page).show();
} else {
$('.fldFullscreen', page).hide();
}
2015-08-04 11:14:16 -07:00
if (AppInfo.supportsUserDisplayLanguageSetting) {
$('.languageSection', page).show();
} else {
$('.languageSection', page).hide();
}
2014-05-21 09:45:42 -07:00
});
})(jQuery, window, document);