mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
update listviews
This commit is contained in:
parent
3197c48232
commit
1032fa887e
54 changed files with 2271 additions and 376 deletions
|
@ -1192,75 +1192,6 @@
|
|||
|
||||
},
|
||||
|
||||
getListViewIndex: function (item, options) {
|
||||
|
||||
if (options.index == 'disc') {
|
||||
|
||||
return item.ParentIndexNumber == null ? '' : Globalize.translate('ValueDiscNumber', item.ParentIndexNumber);
|
||||
}
|
||||
|
||||
var sortBy = (options.sortBy || '').toLowerCase();
|
||||
var code, name;
|
||||
|
||||
if (sortBy.indexOf('sortname') == 0) {
|
||||
|
||||
if (item.Type == 'Episode') return '';
|
||||
|
||||
// SortName
|
||||
name = (item.SortName || item.Name || '?')[0].toUpperCase();
|
||||
|
||||
code = name.charCodeAt(0);
|
||||
if (code < 65 || code > 90) {
|
||||
return '#';
|
||||
}
|
||||
|
||||
return name.toUpperCase();
|
||||
}
|
||||
if (sortBy.indexOf('officialrating') == 0) {
|
||||
|
||||
return item.OfficialRating || Globalize.translate('HeaderUnrated');
|
||||
}
|
||||
if (sortBy.indexOf('communityrating') == 0) {
|
||||
|
||||
if (item.CommunityRating == null) {
|
||||
return Globalize.translate('HeaderUnrated');
|
||||
}
|
||||
|
||||
return Math.floor(item.CommunityRating);
|
||||
}
|
||||
if (sortBy.indexOf('criticrating') == 0) {
|
||||
|
||||
if (item.CriticRating == null) {
|
||||
return Globalize.translate('HeaderUnrated');
|
||||
}
|
||||
|
||||
return Math.floor(item.CriticRating);
|
||||
}
|
||||
if (sortBy.indexOf('metascore') == 0) {
|
||||
|
||||
if (item.Metascore == null) {
|
||||
return Globalize.translate('HeaderUnrated');
|
||||
}
|
||||
|
||||
return Math.floor(item.Metascore);
|
||||
}
|
||||
if (sortBy.indexOf('albumartist') == 0) {
|
||||
|
||||
// SortName
|
||||
if (!item.AlbumArtist) return '';
|
||||
|
||||
name = item.AlbumArtist[0].toUpperCase();
|
||||
|
||||
code = name.charCodeAt(0);
|
||||
if (code < 65 || code > 90) {
|
||||
return '#';
|
||||
}
|
||||
|
||||
return name.toUpperCase();
|
||||
}
|
||||
return '';
|
||||
},
|
||||
|
||||
getUserDataCssClass: function (key) {
|
||||
|
||||
if (!key) return '';
|
||||
|
@ -1268,208 +1199,6 @@
|
|||
return 'libraryItemUserData' + key.replace(new RegExp(' ', 'g'), '');
|
||||
},
|
||||
|
||||
getListViewHtml: function (options) {
|
||||
|
||||
require(['listViewStyle', 'material-icons']);
|
||||
|
||||
var outerHtml = "";
|
||||
|
||||
if (options.title) {
|
||||
outerHtml += '<h1>';
|
||||
outerHtml += options.title;
|
||||
outerHtml += '</h1>';
|
||||
}
|
||||
|
||||
outerHtml += '<div class="paperList itemsListview">';
|
||||
|
||||
var index = 0;
|
||||
var groupTitle = '';
|
||||
|
||||
outerHtml += options.items.map(function (item) {
|
||||
|
||||
var html = '';
|
||||
|
||||
if (options.showIndex !== false) {
|
||||
|
||||
var itemGroupTitle = LibraryBrowser.getListViewIndex(item, options);
|
||||
|
||||
if (itemGroupTitle != groupTitle) {
|
||||
|
||||
outerHtml += '</div>';
|
||||
|
||||
if (index == 0) {
|
||||
html += '<h1>';
|
||||
}
|
||||
else {
|
||||
html += '<h1 style="margin-top:2em;">';
|
||||
}
|
||||
html += itemGroupTitle;
|
||||
html += '</h1>';
|
||||
|
||||
html += '<div class="paperList itemsListview">';
|
||||
|
||||
groupTitle = itemGroupTitle;
|
||||
}
|
||||
}
|
||||
|
||||
var dataAttributes = LibraryBrowser.getItemDataAttributes(item, options, index);
|
||||
|
||||
var cssClass = 'listItem';
|
||||
|
||||
var href = LibraryBrowser.getHref(item, options.context);
|
||||
html += '<div class="' + cssClass + '"' + dataAttributes + ' data-itemid="' + item.Id + '" data-playlistitemid="' + (item.PlaylistItemId || '') + '" data-href="' + href + '" data-icon="false">';
|
||||
|
||||
var imgUrl;
|
||||
|
||||
var downloadWidth = options.smallIcon ? 70 : 80;
|
||||
// Scaling 400w episode images to 80 doesn't turn out very well
|
||||
var minScale = item.Type == 'Episode' || item.Type == 'Game' || options.smallIcon ? 2 : 1.5;
|
||||
|
||||
if (item.ImageTags.Primary) {
|
||||
|
||||
imgUrl = ApiClient.getScaledImageUrl(item.Id, {
|
||||
maxWidth: downloadWidth,
|
||||
tag: item.ImageTags.Primary,
|
||||
type: "Primary",
|
||||
index: 0,
|
||||
minScale: minScale
|
||||
});
|
||||
|
||||
}
|
||||
else if (item.AlbumId && item.AlbumPrimaryImageTag) {
|
||||
|
||||
imgUrl = ApiClient.getScaledImageUrl(item.AlbumId, {
|
||||
type: "Primary",
|
||||
maxWidth: downloadWidth,
|
||||
tag: item.AlbumPrimaryImageTag,
|
||||
minScale: minScale
|
||||
});
|
||||
|
||||
}
|
||||
else if (item.SeriesId && item.SeriesPrimaryImageTag) {
|
||||
|
||||
imgUrl = ApiClient.getScaledImageUrl(item.SeriesId, {
|
||||
type: "Primary",
|
||||
maxWidth: downloadWidth,
|
||||
tag: item.SeriesPrimaryImageTag,
|
||||
minScale: minScale
|
||||
});
|
||||
|
||||
}
|
||||
else if (item.ParentPrimaryImageTag) {
|
||||
|
||||
imgUrl = ApiClient.getScaledImageUrl(item.ParentPrimaryImageItemId, {
|
||||
type: "Primary",
|
||||
maxWidth: downloadWidth,
|
||||
tag: item.ParentPrimaryImageTag,
|
||||
minScale: minScale
|
||||
});
|
||||
}
|
||||
|
||||
if (imgUrl) {
|
||||
if (options.smallIcon) {
|
||||
html += '<div class="listItemImage lazy small" data-src="' + imgUrl + '" item-icon></div>';
|
||||
} else {
|
||||
html += '<div class="listItemImage lazy" data-src="' + imgUrl + '" item-icon></div>';
|
||||
}
|
||||
} else {
|
||||
if (options.smallIcon) {
|
||||
html += '<div class="listItemImage small" item-icon></div>';
|
||||
} else {
|
||||
html += '<div class="listItemImage" item-icon></div>';
|
||||
}
|
||||
}
|
||||
|
||||
var textlines = [];
|
||||
|
||||
if (item.Type == 'Episode') {
|
||||
textlines.push(item.SeriesName || ' ');
|
||||
} else if (item.Type == 'MusicAlbum') {
|
||||
textlines.push(item.AlbumArtist || ' ');
|
||||
}
|
||||
|
||||
var displayName = itemHelper.getDisplayName(item);
|
||||
|
||||
if (options.showIndexNumber && item.IndexNumber != null) {
|
||||
displayName = item.IndexNumber + ". " + displayName;
|
||||
}
|
||||
textlines.push(displayName);
|
||||
|
||||
if (item.Type == 'Audio') {
|
||||
textlines.push(item.ArtistItems.map(function (a) {
|
||||
return a.Name;
|
||||
|
||||
}).join(', ') || ' ');
|
||||
}
|
||||
|
||||
if (item.Type == 'Game') {
|
||||
textlines.push(item.GameSystem || ' ');
|
||||
}
|
||||
|
||||
else if (item.Type == 'MusicGenre') {
|
||||
textlines.push(' ');
|
||||
}
|
||||
else if (item.Type == 'MusicArtist') {
|
||||
textlines.push(' ');
|
||||
}
|
||||
else if (item.Type == 'TvChannel') {
|
||||
|
||||
if (item.CurrentProgram) {
|
||||
textlines.push(itemHelper.getDisplayName(item.CurrentProgram));
|
||||
}
|
||||
}
|
||||
else {
|
||||
textlines.push('<div class="itemMiscInfo">' + mediaInfo.getPrimaryMediaInfoHtml(item, {
|
||||
endsAt: false
|
||||
}) + '</div>');
|
||||
}
|
||||
|
||||
var defaultAction = options.defaultAction;
|
||||
if (defaultAction == 'play' || defaultAction == 'playallfromhere') {
|
||||
if (item.PlayAccess != 'Full') {
|
||||
defaultAction = null;
|
||||
}
|
||||
}
|
||||
|
||||
var bodyCssClass = 'mediaItem clearLink listItemBody';
|
||||
if (textlines.length > 2) {
|
||||
bodyCssClass += ' three-line';
|
||||
} else {
|
||||
bodyCssClass += ' two-line';
|
||||
}
|
||||
var defaultActionAttribute = defaultAction ? (' data-action="' + defaultAction + '" class="itemWithAction ' + bodyCssClass + '"') : ' class="' + bodyCssClass + '"';
|
||||
html += '<a' + defaultActionAttribute + ' href="' + href + '">';
|
||||
|
||||
for (var i = 0, textLinesLength = textlines.length; i < textLinesLength; i++) {
|
||||
|
||||
if (i == 0) {
|
||||
html += '<div>';
|
||||
} else {
|
||||
html += '<div class="secondary">';
|
||||
}
|
||||
html += textlines[i] || ' ';
|
||||
html += '</div>';
|
||||
}
|
||||
|
||||
html += '</a>';
|
||||
|
||||
html += '<button is="paper-icon-button-light" class="listviewMenuButton autoSize"><i class="md-icon">' + AppInfo.moreIcon.replace('-', '_') + '</i></button>';
|
||||
html += '<span class="listViewUserDataButtons">';
|
||||
html += LibraryBrowser.getUserDataIconsHtml(item);
|
||||
html += '</span>';
|
||||
|
||||
html += '</div>';
|
||||
|
||||
index++;
|
||||
return html;
|
||||
|
||||
}).join('');
|
||||
|
||||
outerHtml += '</div>';
|
||||
|
||||
return outerHtml;
|
||||
},
|
||||
|
||||
getItemDataAttributesList: function (item, options, index) {
|
||||
|
||||
var atts = [];
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue