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

101 lines
3.7 KiB
JavaScript
Raw Normal View History

2014-09-22 14:56:54 -07:00
(function ($, document, window) {
function loadPage(page, config) {
$('#chkMovies', page).checked(config.EnableIntrosForMovies).checkboxradio('refresh');
$('#chkEpisodes', page).checked(config.EnableIntrosForEpisodes).checkboxradio('refresh');
$('#chkMyMovieTrailers', page).checked(config.EnableIntrosFromMoviesInLibrary).checkboxradio('refresh');
2014-09-29 21:47:30 -07:00
2014-09-22 14:56:54 -07:00
$('#chkUpcomingTheaterTrailers', page).checked(config.EnableIntrosFromUpcomingTrailers).checkboxradio('refresh');
2014-09-29 21:47:30 -07:00
$('#chkUpcomingDvdTrailers', page).checked(config.EnableIntrosFromUpcomingDvdMovies).checkboxradio('refresh');
$('#chkUpcomingStreamingTrailers', page).checked(config.EnableIntrosFromUpcomingStreamingMovies).checkboxradio('refresh');
2014-09-22 14:56:54 -07:00
$('#chkUnwatchedOnly', page).checked(!config.EnableIntrosForWatchedContent).checkboxradio('refresh');
$('#chkEnableParentalControl', page).checked(config.EnableIntrosParentalControl).checkboxradio('refresh');
2014-09-22 17:04:50 -07:00
$('#txtCustomIntrosPath', page).val(config.CustomIntroPath || '');
2014-10-09 15:22:04 -07:00
$('#txtNumTrailers', page).val(config.TrailerLimit);
2014-09-22 17:04:50 -07:00
2014-09-22 14:56:54 -07:00
Dashboard.hideLoadingMsg();
}
2014-09-22 17:04:50 -07:00
$(document).on('pageinit', "#cinemaModeConfigurationPage", function () {
var page = this;
$('#btnSelectCustomIntrosPath', page).on("click.selectDirectory", function () {
var picker = new DirectoryBrowser(page);
picker.show({
callback: function (path) {
if (path) {
$('#txtCustomIntrosPath', page).val(path);
}
picker.close();
},
header: Globalize.translate('HeaderSelectCustomIntrosPath')
});
});
}).on('pageshow', "#cinemaModeConfigurationPage", function () {
2014-09-22 14:56:54 -07:00
Dashboard.showLoadingMsg();
var page = this;
ApiClient.getNamedConfiguration("cinemamode").done(function (config) {
loadPage(page, config);
});
2015-05-21 13:53:14 -07:00
if (AppInfo.enableSupporterMembership) {
$('.lnkSupporterLearnMore', page).show();
} else {
$('.lnkSupporterLearnMore', page).hide();
}
2014-09-22 14:56:54 -07:00
});
function cinemaModeConfigurationPage() {
var self = this;
self.onSubmit = function () {
Dashboard.showLoadingMsg();
var form = this;
var page = $(form).parents('.page');
ApiClient.getNamedConfiguration("cinemamode").done(function (config) {
2014-09-22 17:04:50 -07:00
config.CustomIntroPath = $('#txtCustomIntrosPath', page).val();
2014-10-09 15:22:04 -07:00
config.TrailerLimit = $('#txtNumTrailers', page).val();
2014-09-22 17:04:50 -07:00
2014-09-22 14:56:54 -07:00
config.EnableIntrosForMovies = $('#chkMovies', page).checked();
config.EnableIntrosForEpisodes = $('#chkEpisodes', page).checked();
config.EnableIntrosFromMoviesInLibrary = $('#chkMyMovieTrailers', page).checked();
config.EnableIntrosForWatchedContent = !$('#chkUnwatchedOnly', page).checked();
config.EnableIntrosParentalControl = $('#chkEnableParentalControl', page).checked();
2014-09-29 21:47:30 -07:00
config.EnableIntrosFromUpcomingTrailers = $('#chkUpcomingTheaterTrailers', page).checked();
config.EnableIntrosFromUpcomingDvdMovies = $('#chkUpcomingDvdTrailers', page).checked();
config.EnableIntrosFromUpcomingStreamingMovies = $('#chkUpcomingStreamingTrailers', page).checked();
2014-09-22 14:56:54 -07:00
ApiClient.updateNamedConfiguration("cinemamode", config).done(Dashboard.processServerConfigurationUpdateResult);
});
// Disable default form submission
return false;
};
}
window.CinemaModeConfigurationPage = new cinemaModeConfigurationPage();
})(jQuery, document, window);