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

81 lines
2.4 KiB
JavaScript
Raw Normal View History

2016-11-24 23:58:38 -07:00
define(['components/categorysyncbuttons', 'components/groupedcards', 'cardBuilder', 'apphost', 'imageLoader'], function (categorysyncbuttons, groupedcards, cardBuilder, appHost, imageLoader) {
2016-10-22 22:11:46 -07:00
'use strict';
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 html = '';
2016-11-05 12:34:03 -07:00
var supportsImageAnalysis = appHost.supports('imageanalysis');
2016-11-05 13:16:16 -07:00
var cardLayout = supportsImageAnalysis;
2016-11-05 12:34:03 -07:00
html += cardBuilder.getCardsHtml({
items: items,
shape: "backdrop",
preferThumb: true,
showTitle: true,
showSeriesYear: true,
showParentTitle: true,
overlayText: false,
2016-11-05 13:16:16 -07:00
cardLayout: cardLayout,
2016-11-05 12:34:03 -07:00
showUnplayedIndicator: false,
showChildCountIndicator: true,
2016-11-05 13:16:16 -07:00
centerText: !cardLayout,
2016-11-05 12:34:03 -07:00
lazy: true,
overlayPlayButton: true,
vibrant: supportsImageAnalysis,
lines: 2
});
2016-03-18 12:43:17 -07:00
var elem = context.querySelector('#latestEpisodes');
elem.innerHTML = html;
2016-11-24 23:58:38 -07:00
imageLoader.lazyChildren(elem);
2016-03-18 12:43:17 -07:00
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
});