restore grouped card click handler
This commit is contained in:
+7
-2
@@ -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) {
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -321,6 +321,7 @@
|
||||
}
|
||||
|
||||
elem.innerHTML = html;
|
||||
elem.addEventListener('click', groupedcards.onItemsContainerClick);
|
||||
ImageLoader.lazyChildren(elem);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
define(['components/categorysyncbuttons'], function (categorysyncbuttons) {
|
||||
define(['components/categorysyncbuttons', 'components/groupedcards'], function (categorysyncbuttons, groupedcards) {
|
||||
|
||||
function getView() {
|
||||
|
||||
@@ -74,19 +74,21 @@
|
||||
Dashboard.hideLoadingMsg();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
return function (view, params, tabContent) {
|
||||
|
||||
var self = this;
|
||||
|
||||
categorysyncbuttons.init(tabContent);
|
||||
|
||||
var latestPromise;
|
||||
|
||||
var latestPromise;
|
||||
|
||||
self.preRender = function () {
|
||||
|
||||
|
||||
latestPromise = getLatestPromise(view, params);
|
||||
};
|
||||
|
||||
self.renderTab = function() {
|
||||
self.renderTab = function () {
|
||||
|
||||
loadLatest(tabContent, params, latestPromise);
|
||||
};
|
||||
Reference in New Issue
Block a user