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

101 lines
3.9 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');
2015-07-14 09:39:34 -07:00
$('#chkOtherTrailers', page).checked(config.EnableIntrosFromSimilarMovies).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();
}
2015-06-08 14:32:20 -07:00
function onSubmit() {
Dashboard.showLoadingMsg();
var form = this;
var page = $(form).parents('.page');
ApiClient.getNamedConfiguration("cinemamode").done(function (config) {
config.CustomIntroPath = $('#txtCustomIntrosPath', page).val();
config.TrailerLimit = $('#txtNumTrailers', page).val();
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();
config.EnableIntrosFromUpcomingTrailers = $('#chkUpcomingTheaterTrailers', page).checked();
config.EnableIntrosFromUpcomingDvdMovies = $('#chkUpcomingDvdTrailers', page).checked();
config.EnableIntrosFromUpcomingStreamingMovies = $('#chkUpcomingStreamingTrailers', page).checked();
2015-07-14 09:39:34 -07:00
config.EnableIntrosFromSimilarMovies = $('#chkOtherTrailers', page).checked();
2015-06-08 14:32:20 -07:00
ApiClient.updateNamedConfiguration("cinemamode", config).done(Dashboard.processServerConfigurationUpdateResult);
});
// Disable default form submission
return false;
}
2015-09-01 07:01:59 -07:00
$(document).on('pageinit', "#cinemaModeConfigurationPage", function () {
2014-09-22 17:04:50 -07:00
var page = this;
$('#btnSelectCustomIntrosPath', page).on("click.selectDirectory", function () {
2015-10-13 12:22:45 -07:00
require(['directorybrowser'], function (directoryBrowser) {
2014-09-22 17:04:50 -07:00
2015-10-13 12:22:45 -07:00
var picker = new directoryBrowser();
2014-09-22 17:04:50 -07:00
2015-10-13 12:22:45 -07:00
picker.show({
2014-09-22 17:04:50 -07:00
2015-10-13 12:22:45 -07:00
callback: function (path) {
2014-09-22 17:04:50 -07:00
2015-10-13 12:22:45 -07:00
if (path) {
$('#txtCustomIntrosPath', page).val(path);
}
picker.close();
},
header: Globalize.translate('HeaderSelectCustomIntrosPath')
});
2014-09-22 17:04:50 -07:00
});
});
2015-06-08 14:32:20 -07:00
$('.cinemaModeConfigurationForm').off('submit', onSubmit).on('submit', onSubmit);
2015-09-24 10:08:10 -07:00
}).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
});
})(jQuery, document, window);