2016-07-23 13:00:56 -07:00
|
|
|
|
define(['dom'], function (dom) {
|
2016-10-22 22:11:46 -07:00
|
|
|
|
'use strict';
|
2016-07-23 13:00:56 -07:00
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
};
|
|
|
|
|
});
|