mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
update shared components
This commit is contained in:
parent
ce0fd77a63
commit
41eeda7bab
11 changed files with 108 additions and 277 deletions
|
@ -1,4 +1,4 @@
|
|||
define(['datetime', 'imageLoader', 'itemShortcuts', 'connectionManager'], function (datetime, imageLoader, itemShortcuts, connectionManager) {
|
||||
define(['datetime', 'imageLoader', 'connectionManager'], function (datetime, imageLoader, connectionManager) {
|
||||
|
||||
function buildChapterCardsHtml(item, chapters, options) {
|
||||
|
||||
|
@ -9,12 +9,12 @@ define(['datetime', 'imageLoader', 'itemShortcuts', 'connectionManager'], functi
|
|||
return i.Type == 'Video';
|
||||
})[0] || {};
|
||||
|
||||
var shape = 'backdropCard';
|
||||
var shape = (options.backdropShape || 'backdrop') + 'Card';
|
||||
|
||||
if (videoStream.Width && videoStream.Height) {
|
||||
|
||||
if ((videoStream.Width / videoStream.Height) <= 1.34) {
|
||||
shape = 'squareCard';
|
||||
shape = (options.squareShape || 'square') + 'Card';
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -121,9 +121,6 @@ define(['datetime', 'imageLoader', 'itemShortcuts', 'connectionManager'], functi
|
|||
options.itemsContainer.innerHTML = html;
|
||||
|
||||
imageLoader.lazyChildren(options.itemsContainer);
|
||||
|
||||
itemShortcuts.off(options.itemsContainer);
|
||||
itemShortcuts.on(options.itemsContainer);
|
||||
}
|
||||
|
||||
return {
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
define(['imageLoader', 'itemShortcuts'], function (imageLoader, itemShortcuts) {
|
||||
define(['imageLoader', 'itemShortcuts', 'connectionManager'], function (imageLoader, itemShortcuts, connectionManager) {
|
||||
|
||||
function buildPeopleCardsHtml(people, options) {
|
||||
|
||||
var className = 'card portraitCard personCard';
|
||||
var className = 'card ' + (options.shape || 'portrait') + 'Card personCard';
|
||||
|
||||
if (options.block || options.rows) {
|
||||
className += ' block';
|
||||
|
@ -12,6 +12,7 @@ define(['imageLoader', 'itemShortcuts'], function (imageLoader, itemShortcuts) {
|
|||
var itemsInRow = 0;
|
||||
|
||||
var serverId = options.serverId;
|
||||
var apiClient = connectionManager.getApiClient(serverId);
|
||||
|
||||
for (var i = 0, length = people.length; i < length; i++) {
|
||||
|
||||
|
@ -21,7 +22,7 @@ define(['imageLoader', 'itemShortcuts'], function (imageLoader, itemShortcuts) {
|
|||
|
||||
var person = people[i];
|
||||
|
||||
html += buildPersonCard(person, serverId, options, className);
|
||||
html += buildPersonCard(person, apiClient, serverId, options, className);
|
||||
itemsInRow++;
|
||||
|
||||
if (options.rows && itemsInRow >= options.rows) {
|
||||
|
@ -33,11 +34,26 @@ define(['imageLoader', 'itemShortcuts'], function (imageLoader, itemShortcuts) {
|
|||
return html;
|
||||
}
|
||||
|
||||
function buildPersonCard(person, serverId, options, className) {
|
||||
function getImgUrl(person, maxWidth, apiClient) {
|
||||
|
||||
if (person.PrimaryImageTag) {
|
||||
|
||||
return apiClient.getScaledImageUrl(person.Id, {
|
||||
|
||||
maxWidth: maxWidth,
|
||||
tag: person.PrimaryImageTag,
|
||||
type: "Primary"
|
||||
});
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
function buildPersonCard(person, apiClient, serverId, options, className) {
|
||||
|
||||
className += " itemAction scalableCard";
|
||||
|
||||
var imgUrl = person.images ? person.images.primary : '';
|
||||
var imgUrl = getImgUrl(person, options.width, apiClient);
|
||||
|
||||
var cardImageContainerClass = 'cardImageContainer';
|
||||
if (options.coverImage) {
|
||||
|
@ -79,12 +95,12 @@ define(['imageLoader', 'itemShortcuts'], function (imageLoader, itemShortcuts) {
|
|||
|
||||
function buildPeopleCards(items, options) {
|
||||
|
||||
// Abort if the container has been disposed
|
||||
if (!document.body.contains(options.parentContainer)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (options.parentContainer) {
|
||||
// Abort if the container has been disposed
|
||||
if (!document.body.contains(options.parentContainer)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (items.length) {
|
||||
options.parentContainer.classList.remove('hide');
|
||||
} else {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue