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

starting dashboard paging

This commit is contained in:
Luke Pulverenti 2013-04-08 17:05:00 -04:00
parent 310456481f
commit d20d2a8c03
3 changed files with 92 additions and 23 deletions

View file

@ -32,7 +32,6 @@
.listHeader { .listHeader {
margin-top: 1em; margin-top: 1em;
margin-bottom: 5px; margin-bottom: 5px;
font-weight: normal;
} }
.firstListHeader { .firstListHeader {
@ -54,7 +53,7 @@
.viewSettings { .viewSettings {
text-align: center; text-align: center;
margin: 1.5em 0; margin: 1em 0;
} }
.libraryItemsGrid th { .libraryItemsGrid th {
@ -62,7 +61,7 @@
} }
.libraryGridImage { .libraryGridImage {
width: 120px; width: 110px;
} }
.thName, .tdName { .thName, .tdName {
@ -87,12 +86,17 @@
} }
.libraryItemsGrid th { .libraryItemsGrid th {
padding-bottom: 1em; padding-bottom: 10px;
padding-top: 0;
} }
.libraryItemsGrid td { .libraryItemsGrid td, .libraryItemsGrid th {
border-top: 1px solid #555; border-top: 1px solid #555;
border-bottom: 1px solid #555;
}
.listPaging {
text-align: center;
margin: .5em 0 .75em;
} }
.tabletColumn, .desktopColumn { .tabletColumn, .desktopColumn {
@ -111,6 +115,12 @@
} }
} }
/*@media all and (min-width: 1000px) {
.libraryPage > .ui-content, .libraryPage > .ui-panel-content-wrap {
margin-top: -20px!important;
}
}*/
@media all and (min-width: 1200px) { @media all and (min-width: 1200px) {
.libraryPage .ui-content { .libraryPage .ui-content {

View file

@ -419,7 +419,7 @@ form, .readOnlyContent {
.posterViewItem img { .posterViewItem img {
max-width: 155px; max-width: 155px;
max-height: 125px; max-height: 110px;
vertical-align: bottom; vertical-align: bottom;
} }

View file

@ -9,13 +9,18 @@
SortOrder: "Ascending", SortOrder: "Ascending",
IncludeItemTypes: "Movie", IncludeItemTypes: "Movie",
Recursive: true, Recursive: true,
Fields: "PrimaryImageAspectRatio,UserData,DisplayMediaType" Fields: "PrimaryImageAspectRatio,UserData,DisplayMediaType",
Limit: 100,
StartIndex: 0
}; };
function getTableHtml(items) { function getTableHtml(result) {
var html = '<table class="libraryItemsGrid">'; var items = result.Items;
var html = '';
html += '<table class="libraryItemsGrid">';
html += '<thead>'; html += '<thead>';
html += '<tr>'; html += '<tr>';
@ -59,7 +64,7 @@
html += '<img class="libraryGridImage" src="' + ApiClient.getImageUrl(item.Id, { html += '<img class="libraryGridImage" src="' + ApiClient.getImageUrl(item.Id, {
type: "Backdrop", type: "Backdrop",
width: 240, width: 220,
tag: item.BackdropImageTags[0], tag: item.BackdropImageTags[0],
index: 0 index: 0
}) + '" />'; }) + '" />';
@ -68,14 +73,14 @@
else if (item.ImageTags && item.ImageTags.Thumb) { else if (item.ImageTags && item.ImageTags.Thumb) {
html += '<img class="libraryGridImage" src="' + ApiClient.getImageUrl(item.Id, { html += '<img class="libraryGridImage" src="' + ApiClient.getImageUrl(item.Id, {
type: "Thumb", type: "Thumb",
width: 240, width: 220,
tag: item.ImageTags.Thumb tag: item.ImageTags.Thumb
}) + '" />'; }) + '" />';
} }
else if (item.ImageTags && item.ImageTags.Primary) { else if (item.ImageTags && item.ImageTags.Primary) {
html += '<img class="libraryGridImage" src="' + ApiClient.getImageUrl(item.Id, { html += '<img class="libraryGridImage" src="' + ApiClient.getImageUrl(item.Id, {
type: "Primary", type: "Primary",
width: 240, width: 220,
tag: item.ImageTags.Primary tag: item.ImageTags.Primary
}) + '" />'; }) + '" />';
} }
@ -133,22 +138,71 @@
return html; return html;
} }
function getPagingHtml(result) {
var html = '';
var pageCount = Math.round(result.TotalRecordCount / query.Limit);
var pageNumber = (query.StartIndex / query.Limit) + 1;
var dropdownHtml = '<select data-enhance="false" data-role="none">';
for (var i = 1; i <= pageCount; i++) {
if (i == pageNumber) {
dropdownHtml += '<option value="' + i + '" selected="selected">' + i + '</option>';
} else {
dropdownHtml += '<option value="' + i + '">' + i + '</option>';
}
}
dropdownHtml += '</select>';
html += '<div class="listPaging">';
html += 'Results ' + (query.StartIndex + 1) + '-' + (query.StartIndex + query.Limit) + ' of ' + result.TotalRecordCount + ', page ' + dropdownHtml + ' of ' + pageCount;
html += '</div>';
return html;
}
function reloadItems(page) { function reloadItems(page) {
Dashboard.showLoadingMsg(); Dashboard.showLoadingMsg();
ApiClient.getItems(Dashboard.getCurrentUserId(), query).done(function (result) { ApiClient.getItems(Dashboard.getCurrentUserId(), query).done(function (result) {
var html = '';
var showPaging = result.TotalRecordCount > query.Limit;
if (showPaging) {
html += getPagingHtml(result);
}
if (view == "Poster") { if (view == "Poster") {
$('#items', page).html(LibraryBrowser.getPosterViewHtml({ html += LibraryBrowser.getPosterViewHtml({
items: result.Items, items: result.Items,
useAverageAspectRatio: true useAverageAspectRatio: true
})); });
} }
else if (view == "Grid") { else if (view == "Grid") {
$('#items', page).html(getTableHtml(result.Items)).trigger('create'); html += getTableHtml(result);
} }
if (showPaging) {
html += getPagingHtml(result);
}
var elem = $('#items', page);
// cleanup existing event handlers
$('select', elem).off('change');
elem.html(html).trigger('create');
$('select', elem).on('change', function() {
query.StartIndex = (parseInt(this.value) - 1) * query.Limit;
reloadItems(page);
});
Dashboard.hideLoadingMsg(); Dashboard.hideLoadingMsg();
}); });
} }
@ -158,11 +212,13 @@
var page = this; var page = this;
$('.radioSortBy', this).on('click', function () { $('.radioSortBy', this).on('click', function () {
query.StartIndex = 0;
query.SortBy = this.getAttribute('data-sortby'); query.SortBy = this.getAttribute('data-sortby');
reloadItems(page); reloadItems(page);
}); });
$('.radioSortOrder', this).on('click', function () { $('.radioSortOrder', this).on('click', function () {
query.StartIndex = 0;
query.SortOrder = this.getAttribute('data-sortorder'); query.SortOrder = this.getAttribute('data-sortorder');
reloadItems(page); reloadItems(page);
}); });
@ -178,6 +234,7 @@
filters = filters ? (filters + ',' + filterName) : filterName; filters = filters ? (filters + ',' + filterName) : filterName;
} }
query.StartIndex = 0;
query.Filters = filters; query.Filters = filters;
reloadItems(page); reloadItems(page);
@ -195,6 +252,7 @@
filters = filters ? (filters + ',' + filterName) : filterName; filters = filters ? (filters + ',' + filterName) : filterName;
} }
query.StartIndex = 0;
query.VideoTypes = filters; query.VideoTypes = filters;
reloadItems(page); reloadItems(page);
@ -209,6 +267,7 @@
$('#chk3D', this).on('change', function () { $('#chk3D', this).on('change', function () {
query.StartIndex = 0;
query.VideoFormats = this.checked ? this.getAttribute('data-filter') : null; query.VideoFormats = this.checked ? this.getAttribute('data-filter') : null;
reloadItems(page); reloadItems(page);