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/itemlistpage.js

77 lines
2.1 KiB
JavaScript
Raw Normal View History

(function ($, document) {
2013-03-26 22:48:33 -04:00
// The base query options
var query = {
2013-03-06 01:22:19 -05:00
SortBy: "SortName",
SortOrder: "Ascending",
Fields: "PrimaryImageAspectRatio,UserData,DisplayMediaType,ItemCounts,DateCreated",
Limit: LibraryBrowser.getDetaultPageSize(),
StartIndex: 0
};
2013-03-06 01:22:19 -05:00
function reloadItems(page) {
2013-03-30 10:57:30 -04:00
Dashboard.showLoadingMsg();
var userId = Dashboard.getCurrentUserId();
2013-03-06 01:22:19 -05:00
ApiClient.getItems(userId, query).done(function (result) {
2013-03-30 10:57:30 -04:00
var html = '';
2013-03-26 22:48:33 -04:00
var showPaging = result.TotalRecordCount > query.Limit;
2013-03-06 01:22:19 -05:00
if (showPaging) {
html += LibraryBrowser.getPagingHtml(query, result.TotalRecordCount, true);
}
2013-03-06 01:22:19 -05:00
html += LibraryBrowser.getPosterDetailViewHtml({
items: result.Items,
useAverageAspectRatio: true
});
2013-03-30 10:57:30 -04:00
if (showPaging) {
html += LibraryBrowser.getPagingHtml(query, result.TotalRecordCount);
}
2013-03-26 22:48:33 -04:00
var elem = $('#items', page).html(html).trigger('create');
2013-03-26 22:48:33 -04:00
$('select', elem).on('change', function () {
query.StartIndex = (parseInt(this.value) - 1) * query.Limit;
reloadItems(page);
});
2013-03-06 01:22:19 -05:00
2013-04-15 18:03:05 -04:00
$('.btnNextPage', elem).on('click', function () {
query.StartIndex += query.Limit;
reloadItems(page);
});
$('.btnPreviousPage', elem).on('click', function () {
query.StartIndex -= query.Limit;
reloadItems(page);
});
Dashboard.hideLoadingMsg();
});
ApiClient.getItem(userId, query.ParentId).done(function (item) {
$('#itemName', page).html(item.Name);
});
}
2013-03-30 10:57:30 -04:00
$(document).on('pageinit', "#itemListPage", function () {
2013-03-30 10:57:30 -04:00
}).on('pagebeforeshow', "#itemListPage", function () {
2013-03-30 10:57:30 -04:00
query.ParentId = getParameterByName('parentId');
reloadItems(this);
2013-03-30 10:57:30 -04:00
}).on('pageshow', "#itemListPage", function () {
2013-03-30 10:57:30 -04:00
});
2013-03-06 01:22:19 -05:00
})(jQuery, document);