2016-07-23 13:00:56 -07:00
|
|
|
|
define(['components/categorysyncbuttons', 'components/groupedcards'], function (categorysyncbuttons, groupedcards) {
|
2016-03-18 12:43:17 -07:00
|
|
|
|
|
|
|
|
|
function getView() {
|
|
|
|
|
|
|
|
|
|
return 'Thumb';
|
|
|
|
|
}
|
|
|
|
|
|
2016-06-29 10:43:34 -07:00
|
|
|
|
function getLatestPromise(context, params) {
|
2016-03-18 12:43:17 -07:00
|
|
|
|
|
|
|
|
|
Dashboard.showLoadingMsg();
|
|
|
|
|
|
|
|
|
|
var userId = Dashboard.getCurrentUserId();
|
|
|
|
|
|
|
|
|
|
var parentId = params.topParentId;
|
|
|
|
|
|
|
|
|
|
var options = {
|
|
|
|
|
|
|
|
|
|
IncludeItemTypes: "Episode",
|
2016-05-16 10:11:49 -07:00
|
|
|
|
Limit: 30,
|
2016-03-18 12:43:17 -07:00
|
|
|
|
Fields: "PrimaryImageAspectRatio,SyncInfo",
|
|
|
|
|
ParentId: parentId,
|
|
|
|
|
ImageTypeLimit: 1,
|
2016-07-04 22:40:18 -07:00
|
|
|
|
EnableImageTypes: "Primary,Backdrop,Thumb"
|
2016-03-18 12:43:17 -07:00
|
|
|
|
};
|
|
|
|
|
|
2016-06-29 10:43:34 -07:00
|
|
|
|
return ApiClient.getJSON(ApiClient.getUrl('Users/' + userId + '/Items/Latest', options));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function loadLatest(context, params, promise) {
|
|
|
|
|
|
|
|
|
|
promise.then(function (items) {
|
2016-03-18 12:43:17 -07:00
|
|
|
|
|
|
|
|
|
var view = getView();
|
|
|
|
|
var html = '';
|
|
|
|
|
|
|
|
|
|
if (view == 'ThumbCard') {
|
|
|
|
|
|
|
|
|
|
html += LibraryBrowser.getPosterViewHtml({
|
|
|
|
|
items: items,
|
|
|
|
|
shape: "backdrop",
|
|
|
|
|
preferThumb: true,
|
|
|
|
|
inheritThumb: false,
|
|
|
|
|
showUnplayedIndicator: false,
|
|
|
|
|
showChildCountIndicator: true,
|
|
|
|
|
overlayText: false,
|
|
|
|
|
showParentTitle: true,
|
|
|
|
|
lazy: true,
|
|
|
|
|
showTitle: true,
|
|
|
|
|
cardLayout: true
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
} else if (view == 'Thumb') {
|
|
|
|
|
|
|
|
|
|
html += LibraryBrowser.getPosterViewHtml({
|
|
|
|
|
items: items,
|
|
|
|
|
shape: "backdrop",
|
|
|
|
|
preferThumb: true,
|
|
|
|
|
inheritThumb: false,
|
|
|
|
|
showParentTitle: false,
|
|
|
|
|
showUnplayedIndicator: false,
|
|
|
|
|
showChildCountIndicator: true,
|
|
|
|
|
overlayText: false,
|
|
|
|
|
centerText: true,
|
|
|
|
|
lazy: true,
|
|
|
|
|
showTitle: false,
|
|
|
|
|
overlayPlayButton: AppInfo.enableAppLayouts
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var elem = context.querySelector('#latestEpisodes');
|
|
|
|
|
elem.innerHTML = html;
|
|
|
|
|
ImageLoader.lazyChildren(elem);
|
|
|
|
|
|
|
|
|
|
Dashboard.hideLoadingMsg();
|
|
|
|
|
});
|
2015-05-12 21:55:19 -07:00
|
|
|
|
}
|
2016-07-23 13:00:56 -07:00
|
|
|
|
return function (view, params, tabContent) {
|
2016-03-18 12:43:17 -07:00
|
|
|
|
|
|
|
|
|
var self = this;
|
2016-07-18 20:57:55 -07:00
|
|
|
|
|
|
|
|
|
categorysyncbuttons.init(tabContent);
var latestPromise;
|
2016-06-29 10:43:34 -07:00
|
|
|
|
|
2016-07-23 13:00:56 -07:00
|
|
|
|
self.preRender = function () {
|
|
|
|
|
latestPromise = getLatestPromise(view, params);
|
2016-06-29 10:43:34 -07:00
|
|
|
|
};
|
2016-03-18 12:43:17 -07:00
|
|
|
|
|
2016-07-23 13:00:56 -07:00
|
|
|
|
self.renderTab = function () {
|
2016-03-18 12:43:17 -07:00
|
|
|
|
|
2016-06-29 10:43:34 -07:00
|
|
|
|
loadLatest(tabContent, params, latestPromise);
|
2014-02-22 22:52:30 -07:00
|
|
|
|
};
|
2016-07-23 13:00:56 -07:00
|
|
|
|
|
|
|
|
|
tabContent.querySelector('#latestEpisodes').addEventListener('click', groupedcards.onItemsContainerClick);
|
|
|
|
|
};
|
2016-03-18 12:43:17 -07:00
|
|
|
|
});
|