Merge pull request #4881 from thornbill/remove-poster-click
This commit is contained in:
commit
500312de33
4 changed files with 89 additions and 25 deletions
|
@ -261,7 +261,7 @@ function buildCardsHtmlInternal(items, options) {
|
||||||
* @param {string} shape - Shape of the desired image.
|
* @param {string} shape - Shape of the desired image.
|
||||||
* @returns {CardImageUrl} Object representing the URL of the card's image.
|
* @returns {CardImageUrl} Object representing the URL of the card's image.
|
||||||
*/
|
*/
|
||||||
function getCardImageUrl(item, apiClient, options, shape) {
|
export function getCardImageUrl(item, apiClient, options, shape) {
|
||||||
item = item.ProgramInfo || item;
|
item = item.ProgramInfo || item;
|
||||||
|
|
||||||
const width = options.width;
|
const width = options.width;
|
||||||
|
@ -1049,7 +1049,7 @@ function buildCard(index, item, apiClient, options) {
|
||||||
cardImageContainerOpen += getDefaultText(item, options);
|
cardImageContainerOpen += getDefaultText(item, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
const tagName = (layoutManager.tv) && !overlayButtons ? 'button' : 'div';
|
const tagName = layoutManager.tv && !overlayButtons ? 'button' : 'div';
|
||||||
|
|
||||||
const nameWithPrefix = (item.SortName || item.Name || '');
|
const nameWithPrefix = (item.SortName || item.Name || '');
|
||||||
let prefix = nameWithPrefix.substring(0, Math.min(3, nameWithPrefix.length));
|
let prefix = nameWithPrefix.substring(0, Math.min(3, nameWithPrefix.length));
|
||||||
|
|
74
src/components/cardbuilder/cardImage.ts
Normal file
74
src/components/cardbuilder/cardImage.ts
Normal file
|
@ -0,0 +1,74 @@
|
||||||
|
import type { BaseItemDto } from '@jellyfin/sdk/lib/generated-client/models/base-item-dto';
|
||||||
|
import { BaseItemKind } from '@jellyfin/sdk/lib/generated-client/models/base-item-kind';
|
||||||
|
import type { ApiClient } from 'jellyfin-apiclient';
|
||||||
|
|
||||||
|
import type { CardOptions } from 'types/cardOptions';
|
||||||
|
import { CardShape } from 'utils/card';
|
||||||
|
|
||||||
|
import { getCardImageUrl, getDefaultText } from './cardBuilder';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Builds an html string for a basic image only card.
|
||||||
|
*/
|
||||||
|
export function buildCardImage(
|
||||||
|
apiClient: ApiClient,
|
||||||
|
item: BaseItemDto,
|
||||||
|
options: CardOptions
|
||||||
|
): string {
|
||||||
|
let shape: CardShape = CardShape.Square;
|
||||||
|
if (item.PrimaryImageAspectRatio) {
|
||||||
|
if (item.PrimaryImageAspectRatio >= 3) {
|
||||||
|
shape = CardShape.Banner;
|
||||||
|
} else if (item.PrimaryImageAspectRatio >= 1.33) {
|
||||||
|
shape = CardShape.Backdrop;
|
||||||
|
} else if (item.PrimaryImageAspectRatio > 0.71) {
|
||||||
|
shape = CardShape.Square;
|
||||||
|
} else {
|
||||||
|
shape = CardShape.Portrait;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const image = getCardImageUrl(
|
||||||
|
item,
|
||||||
|
apiClient,
|
||||||
|
options,
|
||||||
|
shape
|
||||||
|
);
|
||||||
|
|
||||||
|
if (!image) return '';
|
||||||
|
|
||||||
|
const { blurhash, imgUrl } = image;
|
||||||
|
|
||||||
|
let cardPadderIcon = '';
|
||||||
|
// TV Channel logos are transparent so skip the placeholder to avoid overlapping
|
||||||
|
if (imgUrl && item.Type !== BaseItemKind.TvChannel) {
|
||||||
|
cardPadderIcon = getDefaultText(item, {
|
||||||
|
// Always use an icon
|
||||||
|
defaultCardImageIcon: 'folder',
|
||||||
|
...options
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
let blurhashAttrib = '';
|
||||||
|
if (blurhash && blurhash.length > 0) {
|
||||||
|
blurhashAttrib = `data-blurhash="${blurhash}"`;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
`<div class="card ${shape}Card">
|
||||||
|
<div class="cardBox">
|
||||||
|
<div class="cardScalable">
|
||||||
|
<div class="cardPadder cardPadder-${shape}">
|
||||||
|
${cardPadderIcon}
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
class="cardImageContainer coveredImage cardContent lazy"
|
||||||
|
style="cursor: default;"
|
||||||
|
data-src="${imgUrl}"
|
||||||
|
${blurhashAttrib}
|
||||||
|
></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>`
|
||||||
|
);
|
||||||
|
}
|
|
@ -7,6 +7,7 @@ import isEqual from 'lodash-es/isEqual';
|
||||||
import { appHost } from 'components/apphost';
|
import { appHost } from 'components/apphost';
|
||||||
import { clearBackdrop, setBackdrops } from 'components/backdrop/backdrop';
|
import { clearBackdrop, setBackdrops } from 'components/backdrop/backdrop';
|
||||||
import cardBuilder from 'components/cardbuilder/cardBuilder';
|
import cardBuilder from 'components/cardbuilder/cardBuilder';
|
||||||
|
import { buildCardImage } from 'components/cardbuilder/cardImage';
|
||||||
import confirm from 'components/confirm/confirm';
|
import confirm from 'components/confirm/confirm';
|
||||||
import imageLoader from 'components/images/imageLoader';
|
import imageLoader from 'components/images/imageLoader';
|
||||||
import itemContextMenu from 'components/itemContextMenu';
|
import itemContextMenu from 'components/itemContextMenu';
|
||||||
|
@ -526,7 +527,7 @@ function reloadFromItem(instance, page, params, item, user) {
|
||||||
libraryMenu.setTitle('');
|
libraryMenu.setTitle('');
|
||||||
|
|
||||||
// Start rendering the artwork first
|
// Start rendering the artwork first
|
||||||
renderImage(page, item);
|
renderImage(page, item, apiClient);
|
||||||
// Save some screen real estate in TV mode
|
// Save some screen real estate in TV mode
|
||||||
if (!layoutManager.tv) {
|
if (!layoutManager.tv) {
|
||||||
renderLogo(page, item, apiClient);
|
renderLogo(page, item, apiClient);
|
||||||
|
@ -717,31 +718,20 @@ function renderLinks(page, item) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function renderDetailImage(elem, item, loader) {
|
function renderDetailImage(apiClient, elem, item, loader) {
|
||||||
const itemArray = [];
|
const html = buildCardImage(
|
||||||
itemArray.push(item);
|
apiClient,
|
||||||
const cardHtml = cardBuilder.getCardsHtml(itemArray, {
|
item,
|
||||||
shape: 'auto',
|
{ width: dom.getWindowSize().innerWidth * 0.25 }
|
||||||
showTitle: false,
|
);
|
||||||
centerText: true,
|
|
||||||
overlayText: false,
|
|
||||||
transition: false,
|
|
||||||
disableHoverMenu: true,
|
|
||||||
disableIndicators: true,
|
|
||||||
overlayPlayButton: layoutManager.desktop,
|
|
||||||
action: layoutManager.desktop ? 'resume' : 'none',
|
|
||||||
width: dom.getWindowSize().innerWidth * 0.25
|
|
||||||
});
|
|
||||||
|
|
||||||
elem.innerHTML = cardHtml;
|
elem.innerHTML = html;
|
||||||
loader.lazyChildren(elem);
|
loader.lazyChildren(elem);
|
||||||
|
|
||||||
// Avoid breaking the design by preventing focus of the poster using the keyboard.
|
|
||||||
elem.querySelector('a, button').tabIndex = -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function renderImage(page, item) {
|
function renderImage(page, item, apiClient) {
|
||||||
renderDetailImage(
|
renderDetailImage(
|
||||||
|
apiClient,
|
||||||
page.querySelector('.detailImageContainer'),
|
page.querySelector('.detailImageContainer'),
|
||||||
item,
|
item,
|
||||||
imageLoader
|
imageLoader
|
||||||
|
@ -2016,7 +2006,6 @@ export default function (view, params) {
|
||||||
bindAll(view, '.btnCancelSeriesTimer', 'click', onCancelSeriesTimerClick);
|
bindAll(view, '.btnCancelSeriesTimer', 'click', onCancelSeriesTimerClick);
|
||||||
bindAll(view, '.btnCancelTimer', 'click', onCancelTimerClick);
|
bindAll(view, '.btnCancelTimer', 'click', onCancelTimerClick);
|
||||||
bindAll(view, '.btnDownload', 'click', onDownloadClick);
|
bindAll(view, '.btnDownload', 'click', onDownloadClick);
|
||||||
view.querySelector('.detailImageContainer').addEventListener('click', onPlayClick);
|
|
||||||
view.querySelector('.trackSelections').addEventListener('submit', onTrackSelectionsSubmit);
|
view.querySelector('.trackSelections').addEventListener('submit', onTrackSelectionsSubmit);
|
||||||
view.querySelector('.btnSplitVersions').addEventListener('click', function () {
|
view.querySelector('.btnSplitVersions').addEventListener('click', function () {
|
||||||
splitVersions(self, view, apiClient, params);
|
splitVersions(self, view, apiClient, params);
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
enum CardShape {
|
export enum CardShape {
|
||||||
Backdrop = 'backdrop',
|
Backdrop = 'backdrop',
|
||||||
BackdropOverflow = 'overflowBackdrop',
|
BackdropOverflow = 'overflowBackdrop',
|
||||||
|
Banner = 'banner',
|
||||||
Portrait = 'portrait',
|
Portrait = 'portrait',
|
||||||
PortraitOverflow = 'overflowPortrait',
|
PortraitOverflow = 'overflowPortrait',
|
||||||
Square = 'square',
|
Square = 'square',
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue