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

groupedcards

This commit is contained in:
grafixeyehero 2019-10-09 19:26:18 +03:00
parent 72cb4bd169
commit 08ae592e0b

View file

@ -1,32 +1,45 @@
define(["dom", "appRouter", "connectionManager"], function(dom, appRouter, connectionManager) { define(["dom", "appRouter", "connectionManager"], function (dom, appRouter, connectionManager) {
"use strict"; "use strict";
function onGroupedCardClick(e, card) { function onGroupedCardClick(e, card) {
var itemId = card.getAttribute("data-id"), var itemId = card.getAttribute("data-id");
serverId = card.getAttribute("data-serverid"), var serverId = card.getAttribute("data-serverid");
apiClient = connectionManager.getApiClient(serverId), var apiClient = connectionManager.getApiClient(serverId);
userId = apiClient.getCurrentUserId(), var userId = apiClient.getCurrentUserId();
playedIndicator = card.querySelector(".playedIndicator"), var playedIndicator = card.querySelector(".playedIndicator");
playedIndicatorHtml = playedIndicator ? playedIndicator.innerHTML : null, var playedIndicatorHtml = playedIndicator ? playedIndicator.innerHTML : null;
options = { var options = {
Limit: parseInt(playedIndicatorHtml || "10"), Limit: parseInt(playedIndicatorHtml || "10"),
Fields: "PrimaryImageAspectRatio,DateCreated", Fields: "PrimaryImageAspectRatio,DateCreated",
ParentId: itemId, ParentId: itemId,
GroupItems: !1 GroupItems: false
}, };
actionableParent = dom.parentWithTag(e.target, ["A", "BUTTON", "INPUT"]); var actionableParent = dom.parentWithTag(e.target, ["A", "BUTTON", "INPUT"]);
if (!actionableParent || actionableParent.classList.contains("cardContent")) return apiClient.getJSON(apiClient.getUrl("Users/" + userId + "/Items/Latest", options)).then(function(items) {
if (1 === items.length) return void appRouter.showItem(items[0]); if (!actionableParent || actionableParent.classList.contains("cardContent")) {
apiClient.getJSON(apiClient.getUrl("Users/" + userId + "/Items/Latest", options)).then(function (items) {
if (1 === items.length) {
return void appRouter.showItem(items[0]);
}
var url = "itemdetails.html?id=" + itemId + "&serverId=" + serverId; var url = "itemdetails.html?id=" + itemId + "&serverId=" + serverId;
Dashboard.navigate(url) Dashboard.navigate(url);
}), e.stopPropagation(), e.preventDefault(), !1 });
e.stopPropagation();
e.preventDefault();
return false;
}
} }
function onItemsContainerClick(e) { function onItemsContainerClick(e) {
var groupedCard = dom.parentWithClass(e.target, "groupedCard"); var groupedCard = dom.parentWithClass(e.target, "groupedCard");
groupedCard && onGroupedCardClick(e, groupedCard)
if (groupedCard) {
onGroupedCardClick(e, groupedCard);
} }
}
return { return {
onItemsContainerClick: onItemsContainerClick onItemsContainerClick: onItemsContainerClick
} };
}); });