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

restore grouped card click handler

This commit is contained in:
Luke Pulverenti 2016-07-23 16:00:56 -04:00
parent f52a94d778
commit 2efd8e3c32
4 changed files with 70 additions and 9 deletions

View file

@ -13,9 +13,14 @@ define([], function () {
return elem;
}
function parentWithTag(elem, tagName) {
function parentWithTag(elem, tagNames) {
while (elem.tagName != tagName) {
// accept both string and array passed in
if (!Array.isArray(tagNames)) {
tagNames = [tagNames];
}
while (tagNames.indexOf(elem.tagName || '') == -1) {
elem = elem.parentNode;
if (!elem) {

View file

@ -0,0 +1,53 @@
define(['dom'], function (dom) {
function onGroupedCardClick(e, card) {
var itemId = card.getAttribute('data-id');
var userId = Dashboard.getCurrentUserId();
var playedIndicator = card.querySelector('.playedIndicator');
var playedIndicatorHtml = playedIndicator ? playedIndicator.innerHTML : null;
var options = {
Limit: parseInt(playedIndicatorHtml || '10'),
Fields: "PrimaryImageAspectRatio,DateCreated",
ParentId: itemId,
GroupItems: false
};
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 (items.length == 1) {
Dashboard.navigate(LibraryBrowser.getHref(items[0]));
return;
}
var url = 'itemdetails.html?id=' + itemId;
Dashboard.navigate(url);
});
e.stopPropagation();
e.preventDefault();
return false;
}
function onItemsContainerClick(e) {
var groupedCard = dom.parentWithClass(e.target, 'groupedCard');
if (groupedCard) {
onGroupedCardClick(e, groupedCard);
}
}
return {
onItemsContainerClick: onItemsContainerClick
};
});

View file

@ -1,4 +1,4 @@
define(['libraryBrowser', 'appSettings', 'scrollStyles', 'emby-button', 'paper-icon-button-light', 'emby-itemscontainer'], function (LibraryBrowser, appSettings) {
define(['libraryBrowser', 'appSettings', 'components/groupedcards', 'scrollStyles', 'emby-button', 'paper-icon-button-light', 'emby-itemscontainer'], function (LibraryBrowser, appSettings, groupedcards) {
function getUserViews(userId) {
@ -321,6 +321,7 @@
}
elem.innerHTML = html;
elem.addEventListener('click', groupedcards.onItemsContainerClick);
ImageLoader.lazyChildren(elem);
});
}

View file

@ -1,4 +1,4 @@
define(['components/categorysyncbuttons'], function (categorysyncbuttons) {
define(['components/categorysyncbuttons', 'components/groupedcards'], function (categorysyncbuttons, groupedcards) {
function getView() {
@ -84,9 +84,11 @@
latestPromise = getLatestPromise(view, params);
};
self.renderTab = function() {
self.renderTab = function () {
loadLatest(tabContent, params, latestPromise);
};
tabContent.querySelector('#latestEpisodes').addEventListener('click', groupedcards.onItemsContainerClick);
};
});