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

46 lines
1.6 KiB
JavaScript
Raw Normal View History

2020-06-16 18:45:21 +01:00
/* eslint-disable indent */
import dom from 'dom';
import appRouter from 'appRouter';
import connectionManager from 'connectionManager';
2020-05-04 12:44:12 +02:00
'use strict';
2018-10-23 01:05:09 +03:00
function onGroupedCardClick(e, card) {
2020-05-04 12:44:12 +02:00
var itemId = card.getAttribute('data-id');
var serverId = card.getAttribute('data-serverid');
2019-10-09 19:26:18 +03:00
var apiClient = connectionManager.getApiClient(serverId);
var userId = apiClient.getCurrentUserId();
2020-05-04 12:44:12 +02:00
var playedIndicator = card.querySelector('.playedIndicator');
2019-10-09 19:26:18 +03:00
var playedIndicatorHtml = playedIndicator ? playedIndicator.innerHTML : null;
var options = {
2020-05-04 12:44:12 +02:00
Limit: parseInt(playedIndicatorHtml || '10'),
Fields: 'PrimaryImageAspectRatio,DateCreated',
2019-10-09 19:26:18 +03:00
ParentId: itemId,
GroupItems: false
};
2020-05-04 12:44:12 +02:00
var actionableParent = dom.parentWithTag(e.target, ['A', 'BUTTON', 'INPUT']);
2019-10-09 19:26:18 +03:00
2020-05-04 12:44:12 +02:00
if (!actionableParent || actionableParent.classList.contains('cardContent')) {
apiClient.getJSON(apiClient.getUrl('Users/' + userId + '/Items/Latest', options)).then(function (items) {
2019-10-09 19:26:18 +03:00
if (1 === items.length) {
return void appRouter.showItem(items[0]);
}
2020-05-04 12:44:12 +02:00
var url = 'itemdetails.html?id=' + itemId + '&serverId=' + serverId;
2019-10-09 19:26:18 +03:00
Dashboard.navigate(url);
});
e.stopPropagation();
e.preventDefault();
return false;
}
2018-10-23 01:05:09 +03:00
}
2020-06-16 18:45:21 +01:00
export function onItemsContainerClick(e) {
2020-05-04 12:44:12 +02:00
var groupedCard = dom.parentWithClass(e.target, 'groupedCard');
2019-10-09 19:26:18 +03:00
if (groupedCard) {
onGroupedCardClick(e, groupedCard);
}
2018-10-23 01:05:09 +03:00
}