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

71 lines
2.2 KiB
JavaScript
Raw Normal View History

2016-11-24 23:58:38 -07:00
define(['components/categorysyncbuttons', 'cardBuilder', 'apphost', 'imageLoader', 'emby-itemscontainer'], function (categorysyncbuttons, cardBuilder, appHost, imageLoader) {
2016-10-22 22:11:46 -07:00
'use strict';
2016-03-30 23:33:37 -07:00
2016-06-29 09:31:01 -07:00
function getNextUpPromise() {
2016-03-30 23:33:37 -07:00
var query = {
2016-05-16 10:11:49 -07:00
Limit: 24,
2016-08-01 22:55:52 -07:00
Fields: "PrimaryImageAspectRatio,SeriesInfo,DateCreated,BasicSyncInfo",
2016-03-30 23:33:37 -07:00
UserId: Dashboard.getCurrentUserId(),
ImageTypeLimit: 1,
2016-07-04 22:40:18 -07:00
EnableImageTypes: "Primary,Backdrop,Thumb"
2016-03-30 23:33:37 -07:00
};
2016-06-29 09:31:01 -07:00
return ApiClient.getNextUpEpisodes(query);
}
function loadNextUp(page, promise) {
promise.then(function (result) {
2016-03-30 23:33:37 -07:00
if (result.Items.length) {
page.querySelector('.noNextUpItems').classList.add('hide');
} else {
page.querySelector('.noNextUpItems').classList.remove('hide');
}
var html = '';
2016-10-06 11:55:01 -07:00
var supportsImageAnalysis = appHost.supports('imageanalysis');
2016-07-29 13:06:58 -07:00
html += cardBuilder.getCardsHtml({
2016-03-30 23:33:37 -07:00
items: result.Items,
shape: "backdrop",
showTitle: true,
showParentTitle: true,
overlayText: false,
lazy: true,
preferThumb: true,
showDetailsMenu: true,
2016-10-10 23:46:59 -07:00
centerText: !supportsImageAnalysis,
2016-10-06 11:55:01 -07:00
overlayPlayButton: AppInfo.enableAppLayouts && !supportsImageAnalysis,
context: 'home-nextup',
cardLayout: supportsImageAnalysis,
vibrant: supportsImageAnalysis
2016-03-30 23:33:37 -07:00
});
var elem = page.querySelector('#nextUpItems');
elem.innerHTML = html;
2016-11-24 23:58:38 -07:00
imageLoader.lazyChildren(elem);
2016-03-30 23:33:37 -07:00
Dashboard.hideLoadingMsg();
});
2015-06-29 11:45:42 -07:00
}
2016-03-30 23:33:37 -07:00
return function (view, params, tabContent) {
2016-06-29 09:31:01 -07:00
var self = this;
var nextUpPromise;
2016-07-18 20:57:55 -07:00
categorysyncbuttons.init(view);
2016-06-29 09:31:01 -07:00
self.preRender = function () {
nextUpPromise = getNextUpPromise();
};
2016-03-30 23:33:37 -07:00
self.renderTab = function () {
2016-06-29 09:31:01 -07:00
Dashboard.showLoadingMsg();
loadNextUp(view, nextUpPromise);
2016-03-30 23:33:37 -07:00
};
};
});