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:
parent
f52a94d778
commit
2efd8e3c32
4 changed files with 70 additions and 9 deletions
|
@ -13,9 +13,14 @@ define([], function () {
|
||||||
return elem;
|
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;
|
elem = elem.parentNode;
|
||||||
|
|
||||||
if (!elem) {
|
if (!elem) {
|
||||||
|
|
53
dashboard-ui/components/groupedcards.js
Normal file
53
dashboard-ui/components/groupedcards.js
Normal 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
|
||||||
|
};
|
||||||
|
});
|
|
@ -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) {
|
function getUserViews(userId) {
|
||||||
|
|
||||||
|
@ -321,6 +321,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
elem.innerHTML = html;
|
elem.innerHTML = html;
|
||||||
|
elem.addEventListener('click', groupedcards.onItemsContainerClick);
|
||||||
ImageLoader.lazyChildren(elem);
|
ImageLoader.lazyChildren(elem);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
define(['components/categorysyncbuttons'], function (categorysyncbuttons) {
|
define(['components/categorysyncbuttons', 'components/groupedcards'], function (categorysyncbuttons, groupedcards) {
|
||||||
|
|
||||||
function getView() {
|
function getView() {
|
||||||
|
|
||||||
|
@ -74,19 +74,21 @@
|
||||||
Dashboard.hideLoadingMsg();
|
Dashboard.hideLoadingMsg();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
return function (view, params, tabContent) {
|
return function (view, params, tabContent) {
|
||||||
|
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
||||||
categorysyncbuttons.init(tabContent);
var latestPromise;
|
categorysyncbuttons.init(tabContent);
var latestPromise;
|
||||||
|
|
||||||
self.preRender = function () {
|
self.preRender = function () {
|
||||||
latestPromise = getLatestPromise(view, params);
|
latestPromise = getLatestPromise(view, params);
|
||||||
};
|
};
|
||||||
|
|
||||||
self.renderTab = function() {
|
self.renderTab = function () {
|
||||||
|
|
||||||
loadLatest(tabContent, params, latestPromise);
|
loadLatest(tabContent, params, latestPromise);
|
||||||
};
|
};
|
||||||
};
|
|
||||||
|
tabContent.querySelector('#latestEpisodes').addEventListener('click', groupedcards.onItemsContainerClick);
|
||||||
|
};
|
||||||
});
|
});
|
Loading…
Add table
Add a link
Reference in a new issue