2016-07-18 20:57:55 -07:00
|
|
|
|
define(['libraryBrowser'], function (libraryBrowser) {
|
2014-03-17 07:48:16 -07:00
|
|
|
|
|
2015-07-06 00:06:09 -07:00
|
|
|
|
function isClickable(target) {
|
|
|
|
|
|
|
|
|
|
while (target != null) {
|
|
|
|
|
var tagName = target.tagName || '';
|
2015-07-14 09:39:34 -07:00
|
|
|
|
if (tagName == 'A' || tagName.indexOf('BUTTON') != -1 || tagName.indexOf('INPUT') != -1) {
|
2015-07-06 00:06:09 -07:00
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
//target = target.parentNode;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2015-09-27 16:32:09 -07:00
|
|
|
|
function onGroupedCardClick(e, card) {
|
|
|
|
|
|
2016-07-17 19:55:07 -07:00
|
|
|
|
var itemId = card.getAttribute('data-id');
|
2014-08-01 19:34:45 -07:00
|
|
|
|
var context = card.getAttribute('data-context');
|
2014-07-15 12:16:16 -07:00
|
|
|
|
|
2014-07-04 22:21:13 -07:00
|
|
|
|
var userId = Dashboard.getCurrentUserId();
|
|
|
|
|
|
2016-05-28 23:04:11 -07:00
|
|
|
|
var playedIndicator = card.querySelector('.playedIndicator');
|
|
|
|
|
var playedIndicatorHtml = playedIndicator ? playedIndicator.innerHTML : null;
|
2014-07-04 22:21:13 -07:00
|
|
|
|
var options = {
|
|
|
|
|
|
2016-05-28 23:04:11 -07:00
|
|
|
|
Limit: parseInt(playedIndicatorHtml || '10'),
|
2014-07-05 08:01:29 -07:00
|
|
|
|
Fields: "PrimaryImageAspectRatio,DateCreated",
|
2014-07-04 22:21:13 -07:00
|
|
|
|
ParentId: itemId,
|
|
|
|
|
GroupItems: false
|
|
|
|
|
};
|
|
|
|
|
|
2015-06-28 07:45:21 -07:00
|
|
|
|
var target = e.target;
|
2015-07-06 00:06:09 -07:00
|
|
|
|
if (isClickable(target)) {
|
2015-06-07 20:16:42 -07:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2015-12-14 08:43:03 -07:00
|
|
|
|
ApiClient.getJSON(ApiClient.getUrl('Users/' + userId + '/Items/Latest', options)).then(function (items) {
|
2015-05-14 19:16:57 -07:00
|
|
|
|
|
2015-06-07 18:23:56 -07:00
|
|
|
|
if (items.length == 1) {
|
2016-07-17 23:45:29 -07:00
|
|
|
|
Dashboard.navigate(libraryBrowser.getHref(items[0], context));
|
2015-06-07 18:23:56 -07:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2015-09-21 08:43:10 -07:00
|
|
|
|
var url = 'itemdetails.html?id=' + itemId;
|
|
|
|
|
if (context) {
|
|
|
|
|
url += '&context=' + context;
|
|
|
|
|
}
|
|
|
|
|
|
2015-12-14 08:43:03 -07:00
|
|
|
|
Dashboard.navigate(url);
|
2015-05-14 19:16:57 -07:00
|
|
|
|
});
|
|
|
|
|
|
2015-12-14 08:43:03 -07:00
|
|
|
|
e.stopPropagation();
|
2015-05-14 19:16:57 -07:00
|
|
|
|
e.preventDefault();
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2016-02-29 23:02:03 -07:00
|
|
|
|
});
|