jellyfin-web/dashboard-ui/scripts/tvlatest.js

92 lines
2.7 KiB
JavaScript
Raw Normal View History

2016-07-29 13:06:58 -07:00
define(['components/categorysyncbuttons', 'components/groupedcards', 'cardBuilder'], function (categorysyncbuttons, groupedcards, cardBuilder) {
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-08-01 22:55:52 -07:00
Fields: "PrimaryImageAspectRatio,BasicSyncInfo",
2016-03-18 12:43:17 -07:00
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') {
2016-07-29 13:06:58 -07:00
html += cardBuilder.getCardsHtml({
2016-03-18 12:43:17 -07:00
items: items,
shape: "backdrop",
preferThumb: true,
inheritThumb: false,
showUnplayedIndicator: false,
showChildCountIndicator: true,
showParentTitle: true,
lazy: true,
showTitle: true,
cardLayout: true
});
} else if (view == 'Thumb') {
2016-07-29 13:06:58 -07:00
html += cardBuilder.getCardsHtml({
2016-03-18 12:43:17 -07:00
items: items,
shape: "backdrop",
preferThumb: true,
inheritThumb: false,
showParentTitle: false,
showUnplayedIndicator: false,
showChildCountIndicator: true,
centerText: true,
lazy: true,
showTitle: false,
2016-10-06 11:55:01 -07:00
overlayPlayButton: true
2016-03-18 12:43:17 -07:00
});
}
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
});