mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
adding tile view
This commit is contained in:
parent
607e81029b
commit
c73b73b586
11 changed files with 360 additions and 208 deletions
|
@ -1,5 +1,7 @@
|
|||
(function ($, document) {
|
||||
|
||||
var view = "Tile";
|
||||
|
||||
// The base query options
|
||||
var query = {
|
||||
|
||||
|
@ -7,91 +9,57 @@
|
|||
SortOrder: "Ascending",
|
||||
IncludeItemTypes: "Series",
|
||||
Recursive: true,
|
||||
Fields: "PrimaryImageAspectRatio,SeriesInfo,ItemCounts,DateCreated"
|
||||
Fields: "PrimaryImageAspectRatio,SeriesInfo,ItemCounts,DateCreated",
|
||||
Limit: LibraryBrowser.getDetaultPageSize(),
|
||||
StartIndex: 0
|
||||
};
|
||||
|
||||
function getTableHtml(items) {
|
||||
|
||||
var html = '<div class="libraryItemsGridContainer"><table data-role="table" data-mode="reflow" class="ui-responsive table-stroke libraryItemsGrid">';
|
||||
|
||||
html += '<thead>';
|
||||
|
||||
html += '<tr>';
|
||||
html += '<th> </th>';
|
||||
html += '<th>Name</th>';
|
||||
html += '<th>Year</th>';
|
||||
html += '<th>Official Rating</th>';
|
||||
html += '<th>Runtime</th>';
|
||||
html += '<th>Community Rating</th>';
|
||||
html += '</tr>';
|
||||
|
||||
html += '</thead>';
|
||||
|
||||
html += '<tbody>';
|
||||
|
||||
for (var i = 0, length = items.length; i < length; i++) {
|
||||
|
||||
html += getRowHtml(items[i]);
|
||||
}
|
||||
|
||||
html += '</tbody>';
|
||||
|
||||
html += '</table></div>';
|
||||
|
||||
return html;
|
||||
}
|
||||
|
||||
function getRowHtml(item) {
|
||||
|
||||
var html = '<tr>';
|
||||
|
||||
html += '<td>';
|
||||
|
||||
var url = "tvseries.html?id=" + item.Id;
|
||||
|
||||
var imageTags = item.ImageTags;
|
||||
|
||||
html += '<a href="' + url + '">';
|
||||
|
||||
if (imageTags.Primary) {
|
||||
|
||||
html += '<img class="libraryGridImage" src="' + ApiClient.getImageUrl(item.Id, {
|
||||
type: "Primary",
|
||||
height: 150,
|
||||
tag: item.ImageTags.Primary
|
||||
}) + '" />';
|
||||
|
||||
}
|
||||
else {
|
||||
html += '<img class="libraryGridImage" style="background:' + LibraryBrowser.getMetroColor(item.Id) + ';" src="css/images/items/list/collection.png" />';
|
||||
}
|
||||
|
||||
html += '</a></td>';
|
||||
|
||||
html += '<td><a href="' + url + '">' + item.Name + '</a></td>';
|
||||
|
||||
html += '<td>' + (item.ProductionYear || "") + '</td>';
|
||||
|
||||
html += '<td>' + (item.OfficialRating || "") + '</td>';
|
||||
html += '<td>' + (item.RunTimeTicks || "") + '</td>';
|
||||
html += '<td>' + (item.CommunityRating || "") + '</td>';
|
||||
|
||||
html += '</tr>';
|
||||
return html;
|
||||
}
|
||||
|
||||
function reloadItems(page) {
|
||||
|
||||
Dashboard.showLoadingMsg();
|
||||
|
||||
ApiClient.getItems(Dashboard.getCurrentUserId(), query).done(function (result) {
|
||||
|
||||
$('#items', page).html(LibraryBrowser.getSeriesPosterViewHtml({
|
||||
var html = '';
|
||||
|
||||
items: result.Items,
|
||||
useAverageAspectRatio: true
|
||||
var showPaging = result.TotalRecordCount > query.Limit;
|
||||
|
||||
}))/*.html(getTableHtml(result.Items)).trigger('create')*/;
|
||||
if (showPaging) {
|
||||
html += LibraryBrowser.getPagingHtml(query, result.TotalRecordCount);
|
||||
}
|
||||
|
||||
if (view == "Tile") {
|
||||
html += LibraryBrowser.getPosterDetailViewHtml({
|
||||
items: result.Items,
|
||||
useAverageAspectRatio: true,
|
||||
preferBackdrop: true
|
||||
});
|
||||
}
|
||||
else if (view == "Poster") {
|
||||
html += LibraryBrowser.getPosterViewHtml({
|
||||
items: result.Items,
|
||||
useAverageAspectRatio: true
|
||||
});
|
||||
}
|
||||
else if (view == "Grid") {
|
||||
html += getTableHtml(result);
|
||||
}
|
||||
|
||||
if (showPaging) {
|
||||
html += LibraryBrowser.getPagingHtml(query, result.TotalRecordCount);
|
||||
}
|
||||
|
||||
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();
|
||||
});
|
||||
|
@ -159,6 +127,13 @@
|
|||
reloadItems(page);
|
||||
});
|
||||
|
||||
$('#selectView', this).on('change', function () {
|
||||
|
||||
view = this.value;
|
||||
|
||||
reloadItems(page);
|
||||
});
|
||||
|
||||
}).on('pagebeforeshow', "#tvShowsPage", function () {
|
||||
|
||||
reloadItems(this);
|
||||
|
@ -204,6 +179,8 @@
|
|||
this.checked = filters.indexOf(',' + filterName) != -1;
|
||||
|
||||
}).checkboxradio('refresh');
|
||||
|
||||
$('#selectView', this).val(view).selectmenu('refresh');
|
||||
});
|
||||
|
||||
})(jQuery, document);
|
Loading…
Add table
Add a link
Reference in a new issue