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
|
|
|
|
|
|
|
|
|
$('#chkDisplayMissingEpisodes', page).checked(user.Configuration.DisplayMissingEpisodes || false).checkboxradio("refresh");
|
|
|
|
|
$('#chkDisplayUnairedEpisodes', page).checked(user.Configuration.DisplayUnairedEpisodes || false).checkboxradio("refresh");
|
|
|
|
|
|
2014-09-30 00:47:30 -04:00
|
|
|
|
$('#chkDisplayTrailersWithinMovieSuggestions', page).checked(user.Configuration.IncludeTrailersInSuggestions || false).checkboxradio("refresh");
|
|
|
|
|
|
2014-08-18 21:42:53 -04:00
|
|
|
|
$('#chkGroupMoviesIntoCollections', page).checked(user.Configuration.GroupMoviesIntoBoxSets || false).checkboxradio("refresh");
|
|
|
|
|
|
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-03 13:55:29 -04:00
|
|
|
|
$('#selectEnableItemPreviews', page).val(AppSettings.enableItemPreviews().toString().toLowerCase()).selectmenu("refresh");
|
|
|
|
|
|
|
|
|
|
$('#chkEnableFullScreen', page).checked(AppSettings.enableFullScreen()).checkboxradio("refresh");
|
|
|
|
|
|
2015-07-26 17:02:23 -04:00
|
|
|
|
$('#chkSyncToExternalCard', page).checked(AppSettings.enableSyncToExternalStorage()).checkboxradio("refresh");
|
2015-07-03 13:55:29 -04:00
|
|
|
|
|
|
|
|
|
Dashboard.hideLoadingMsg();
|
2014-05-21 12:45:42 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function saveUser(page, user) {
|
|
|
|
|
|
|
|
|
|
user.Configuration.DisplayMissingEpisodes = $('#chkDisplayMissingEpisodes', page).checked();
|
|
|
|
|
user.Configuration.DisplayUnairedEpisodes = $('#chkDisplayUnairedEpisodes', page).checked();
|
|
|
|
|
user.Configuration.GroupMoviesIntoBoxSets = $('#chkGroupMoviesIntoCollections', page).checked();
|
2014-09-30 00:47:30 -04:00
|
|
|
|
user.Configuration.IncludeTrailersInSuggestions = $('#chkDisplayTrailersWithinMovieSuggestions', page).checked();
|
|
|
|
|
|
2015-07-03 13:55:29 -04:00
|
|
|
|
AppSettings.enableItemPreviews($('#selectEnableItemPreviews', page).val() == 'true');
|
|
|
|
|
AppSettings.enableFullScreen($('#chkEnableFullScreen', page).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-26 17:02:23 -04:00
|
|
|
|
AppSettings.enableSyncToExternalStorage($('#chkSyncToExternalCard', page).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);
|