2014-05-21 12:45:42 -04:00
|
|
|
|
(function ($, window, document) {
|
|
|
|
|
|
2015-07-03 13:55:29 -04:00
|
|
|
|
function loadForm(page, user) {
|
2014-08-18 21:42:53 -04:00
|
|
|
|
|
2015-07-28 15:42:24 -04:00
|
|
|
|
page.querySelector('.chkDisplayMissingEpisodes').checked = user.Configuration.DisplayMissingEpisodes || false;
|
|
|
|
|
page.querySelector('.chkDisplayUnairedEpisodes').checked = user.Configuration.DisplayUnairedEpisodes || false;
|
|
|
|
|
page.querySelector('.chkDisplayTrailersWithinMovieSuggestions').checked = user.Configuration.IncludeTrailersInSuggestions || false;
|
|
|
|
|
page.querySelector('.chkGroupMoviesIntoCollections').checked = user.Configuration.GroupMoviesIntoBoxSets || false;
|
2014-08-18 21:42:53 -04:00
|
|
|
|
|
2015-07-03 13:55:29 -04:00
|
|
|
|
$('#selectThemeSong', page).val(appStorage.getItem('enableThemeSongs-' + user.Id) || '').selectmenu("refresh");
|
|
|
|
|
$('#selectBackdrop', page).val(appStorage.getItem('enableBackdrops-' + user.Id) || '').selectmenu("refresh");
|
2015-03-31 12:24:16 -04:00
|
|
|
|
|
2015-07-28 15:42:24 -04:00
|
|
|
|
page.querySelector('.chkEnableFullScreen').checked = AppSettings.enableFullScreen();
|
|
|
|
|
page.querySelector('.chkSyncToExternalCard').checked = AppSettings.enableSyncToExternalStorage();
|
2015-07-03 13:55:29 -04:00
|
|
|
|
|
|
|
|
|
Dashboard.hideLoadingMsg();
|
2014-05-21 12:45:42 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function saveUser(page, user) {
|
|
|
|
|
|
2015-07-28 15:42:24 -04:00
|
|
|
|
user.Configuration.DisplayMissingEpisodes = page.querySelector('.chkDisplayMissingEpisodes').checked;
|
|
|
|
|
user.Configuration.DisplayUnairedEpisodes = page.querySelector('.chkDisplayUnairedEpisodes').checked;
|
|
|
|
|
user.Configuration.IncludeTrailersInSuggestions = page.querySelector('.chkDisplayTrailersWithinMovieSuggestions').checked;
|
|
|
|
|
user.Configuration.GroupMoviesIntoBoxSets = page.querySelector('.chkGroupMoviesIntoCollections').checked;
|
2014-09-30 00:47:30 -04:00
|
|
|
|
|
2015-07-28 15:42:24 -04:00
|
|
|
|
AppSettings.enableFullScreen(page.querySelector('.chkEnableFullScreen').checked);
|
2014-06-30 15:24:35 -04:00
|
|
|
|
|
2015-07-03 13:55:29 -04:00
|
|
|
|
appStorage.setItem('enableThemeSongs-' + user.Id, $('#selectThemeSong', page).val());
|
|
|
|
|
appStorage.setItem('enableBackdrops-' + user.Id, $('#selectBackdrop', page).val());
|
2014-08-18 21:42:53 -04:00
|
|
|
|
|
2015-07-28 15:42:24 -04:00
|
|
|
|
AppSettings.enableSyncToExternalStorage(page.querySelector('.chkSyncToExternalCard').checked);
|
2014-08-18 21:42:53 -04:00
|
|
|
|
|
2014-12-18 23:20:07 -05:00
|
|
|
|
ApiClient.updateUserConfiguration(user.Id, user.Configuration).done(function () {
|
2014-05-30 15:23:56 -04:00
|
|
|
|
Dashboard.alert(Globalize.translate('SettingsSaved'));
|
2014-08-18 21:42:53 -04:00
|
|
|
|
|
2015-06-20 20:49:42 -04:00
|
|
|
|
loadForm(page, user);
|
2014-05-21 12:45:42 -04:00
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function onSubmit() {
|
|
|
|
|
|
|
|
|
|
var page = $(this).parents('.page');
|
|
|
|
|
|
|
|
|
|
Dashboard.showLoadingMsg();
|
|
|
|
|
|
|
|
|
|
var userId = getParameterByName('userId') || Dashboard.getCurrentUserId();
|
|
|
|
|
|
2014-08-18 21:42:53 -04:00
|
|
|
|
ApiClient.getUser(userId).done(function (user) {
|
2014-06-04 22:32:40 -04:00
|
|
|
|
|
2014-08-18 21:42:53 -04:00
|
|
|
|
saveUser(page, user);
|
2014-06-04 22:32:40 -04:00
|
|
|
|
|
2014-05-21 12:45:42 -04:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// Disable default form submission
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2015-05-28 01:51:48 -04:00
|
|
|
|
$(document).on('pageinitdepends', "#displayPreferencesPage", function () {
|
2014-05-21 12:45:42 -04:00
|
|
|
|
|
|
|
|
|
var page = this;
|
|
|
|
|
|
2015-07-03 13:55:29 -04:00
|
|
|
|
$('.displayPreferencesForm').off('submit', onSubmit).on('submit', onSubmit);
|
2014-08-18 21:42:53 -04:00
|
|
|
|
|
2015-07-03 13:55:29 -04:00
|
|
|
|
$('.btnSelectSyncPath', page).on('click', function () {
|
2014-08-18 21:42:53 -04:00
|
|
|
|
|
2015-07-03 13:55:29 -04:00
|
|
|
|
require(['nativedirectorychooser'], function () {
|
|
|
|
|
NativeDirectoryChooser.chooseDirectory().done(function (path) {
|
|
|
|
|
$('#txtSyncPath', page).val(path);
|
|
|
|
|
});
|
2014-08-18 21:42:53 -04:00
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
2015-05-28 01:51:48 -04:00
|
|
|
|
}).on('pageshowready', "#displayPreferencesPage", function () {
|
2014-05-21 12:45:42 -04:00
|
|
|
|
|
|
|
|
|
var page = this;
|
|
|
|
|
|
|
|
|
|
Dashboard.showLoadingMsg();
|
|
|
|
|
|
|
|
|
|
var userId = getParameterByName('userId') || Dashboard.getCurrentUserId();
|
|
|
|
|
|
|
|
|
|
ApiClient.getUser(userId).done(function (user) {
|
|
|
|
|
|
|
|
|
|
loadForm(page, user);
|
|
|
|
|
|
2015-07-03 13:55:29 -04:00
|
|
|
|
if (user.Policy.EnableUserPreferenceAccess) {
|
|
|
|
|
$('.requiresUserPreferences', page).show();
|
|
|
|
|
} else {
|
|
|
|
|
$('.requiresUserPreferences', page).hide();
|
|
|
|
|
}
|
2014-05-21 12:45:42 -04:00
|
|
|
|
});
|
2015-07-03 13:55:29 -04:00
|
|
|
|
|
|
|
|
|
$('.fldEnableBackdrops', page).show();
|
|
|
|
|
|
|
|
|
|
if (AppInfo.supportsFullScreen) {
|
|
|
|
|
$('.fldFullscreen', page).show();
|
|
|
|
|
} else {
|
|
|
|
|
$('.fldFullscreen', page).hide();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (AppInfo.supportsSyncPathSetting) {
|
|
|
|
|
$('.syncSettingsSection', page).show();
|
|
|
|
|
} else {
|
|
|
|
|
$('.syncSettingsSection', page).hide();
|
|
|
|
|
}
|
2014-05-21 12:45:42 -04:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
})(jQuery, window, document);
|