1
0
Fork 0
mirror of https://github.com/jellyfin/jellyfin-web synced 2025-03-30 19:56:21 +00:00
jellyfin-web/dashboard-ui/scripts/movies.js

169 lines
4.8 KiB
JavaScript
Raw Normal View History

(function ($, document) {
2013-04-11 01:27:27 -04:00
var view = "Tile";
2013-04-08 17:05:00 -04:00
2013-04-01 23:28:20 -04:00
// The base query options
var query = {
2013-04-01 23:28:20 -04:00
SortBy: "SortName",
SortOrder: "Ascending",
IncludeItemTypes: "Movie",
Recursive: true,
2013-04-10 00:38:04 -04:00
Fields: "PrimaryImageAspectRatio,UserData,DisplayMediaType,ItemCounts,DateCreated",
2013-04-09 12:42:55 -04:00
Limit: LibraryBrowser.getDetaultPageSize(),
2013-04-08 17:05:00 -04:00
StartIndex: 0
2013-04-01 23:28:20 -04:00
};
function reloadItems(page) {
Dashboard.showLoadingMsg();
2013-04-11 01:27:27 -04:00
2013-04-01 23:28:20 -04:00
ApiClient.getItems(Dashboard.getCurrentUserId(), query).done(function (result) {
2013-04-08 17:05:00 -04:00
var html = '';
var showPaging = result.TotalRecordCount > query.Limit;
if (showPaging) {
2013-04-11 08:23:02 -04:00
html += LibraryBrowser.getPagingHtml(query, result.TotalRecordCount, true);
2013-04-08 17:05:00 -04:00
}
2013-04-11 01:27:27 -04:00
if (view == "Tile") {
html += LibraryBrowser.getPosterDetailViewHtml({
items: result.Items,
useAverageAspectRatio: true,
preferBackdrop: true
});
}
else if (view == "Poster") {
2013-04-11 11:43:57 -04:00
html += LibraryBrowser.getPosterDetailViewHtml({
2013-04-05 00:15:00 -04:00
items: result.Items,
useAverageAspectRatio: true
2013-04-08 17:05:00 -04:00
});
2013-04-05 00:15:00 -04:00
}
2013-04-08 17:05:00 -04:00
if (showPaging) {
2013-04-09 01:06:13 -04:00
html += LibraryBrowser.getPagingHtml(query, result.TotalRecordCount);
2013-04-05 00:15:00 -04:00
}
2013-04-01 23:28:20 -04:00
2013-04-11 15:36:50 -04:00
var elem = $('#items', page).html(html).trigger('create');
2013-04-08 17:05:00 -04:00
2013-04-11 01:27:27 -04:00
$('select', elem).on('change', function () {
2013-04-08 17:05:00 -04:00
query.StartIndex = (parseInt(this.value) - 1) * query.Limit;
reloadItems(page);
});
2013-04-01 23:28:20 -04:00
Dashboard.hideLoadingMsg();
});
2013-04-01 23:28:20 -04:00
}
2013-04-01 23:28:20 -04:00
$(document).on('pageinit', "#moviesPage", function () {
var page = this;
2013-04-01 23:28:20 -04:00
$('.radioSortBy', this).on('click', function () {
2013-04-08 17:05:00 -04:00
query.StartIndex = 0;
2013-04-01 23:28:20 -04:00
query.SortBy = this.getAttribute('data-sortby');
reloadItems(page);
});
$('.radioSortOrder', this).on('click', function () {
2013-04-08 17:05:00 -04:00
query.StartIndex = 0;
2013-04-01 23:28:20 -04:00
query.SortOrder = this.getAttribute('data-sortorder');
reloadItems(page);
});
$('.chkStandardFilter', this).on('change', function () {
var filterName = this.getAttribute('data-filter');
var filters = query.Filters || "";
filters = (',' + filters).replace(',' + filterName, '').substring(1);
if (this.checked) {
filters = filters ? (filters + ',' + filterName) : filterName;
}
2013-04-08 17:05:00 -04:00
query.StartIndex = 0;
2013-04-01 23:28:20 -04:00
query.Filters = filters;
reloadItems(page);
});
2013-04-04 11:38:41 -04:00
$('.chkVideoTypeFilter', this).on('change', function () {
var filterName = this.getAttribute('data-filter');
var filters = query.VideoTypes || "";
filters = (',' + filters).replace(',' + filterName, '').substring(1);
if (this.checked) {
filters = filters ? (filters + ',' + filterName) : filterName;
}
2013-04-08 17:05:00 -04:00
query.StartIndex = 0;
2013-04-04 11:38:41 -04:00
query.VideoTypes = filters;
reloadItems(page);
});
2013-04-08 17:05:00 -04:00
2013-04-05 00:15:00 -04:00
$('#selectView', this).on('change', function () {
view = this.value;
reloadItems(page);
});
2013-04-04 11:38:41 -04:00
2013-04-07 09:34:46 -04:00
$('#chk3D', this).on('change', function () {
2013-04-08 17:05:00 -04:00
query.StartIndex = 0;
2013-04-07 09:34:46 -04:00
query.VideoFormats = this.checked ? this.getAttribute('data-filter') : null;
reloadItems(page);
});
2013-04-08 17:05:00 -04:00
}).on('pagebeforeshow', "#moviesPage", function () {
reloadItems(this);
2013-04-08 17:05:00 -04:00
2013-04-01 23:28:20 -04:00
}).on('pageshow', "#moviesPage", function () {
// Reset form values using the last used query
$('.radioSortBy', this).each(function () {
this.checked = query.SortBy == this.getAttribute('data-sortby');
}).checkboxradio('refresh');
$('.radioSortOrder', this).each(function () {
this.checked = query.SortOrder == this.getAttribute('data-sortorder');
}).checkboxradio('refresh');
$('.chkStandardFilter', this).each(function () {
var filters = "," + (query.Filters || "");
var filterName = this.getAttribute('data-filter');
this.checked = filters.indexOf(',' + filterName) != -1;
}).checkboxradio('refresh');
2013-04-04 11:38:41 -04:00
$('.chkVideoTypeFilter', this).each(function () {
var filters = "," + (query.VideoTypes || "");
var filterName = this.getAttribute('data-filter');
this.checked = filters.indexOf(',' + filterName) != -1;
}).checkboxradio('refresh');
2013-04-06 14:59:21 -04:00
$('#selectView', this).val(view).selectmenu('refresh');
2013-04-08 17:05:00 -04:00
2013-04-07 09:34:46 -04:00
$('#chk3D', this).checked(query.VideoFormats == "Digital3D,Sbs3D").checkboxradio('refresh');
2013-04-01 23:28:20 -04:00
});
})(jQuery, document);