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

100 lines
2.9 KiB
JavaScript
Raw Normal View History

2015-06-29 11:45:42 -07:00
(function ($, document) {
function getView() {
return 'Thumb';
}
function reload(page) {
Dashboard.showLoadingMsg();
2015-07-01 08:47:41 -07:00
loadNextUp(page, 'home-nextup');
2015-06-29 11:45:42 -07:00
}
function loadNextUp(page, context) {
var limit = AppInfo.hasLowImageBandwidth ?
16 :
24;
var query = {
Limit: limit,
Fields: "PrimaryImageAspectRatio,SeriesInfo,DateCreated,SyncInfo",
UserId: Dashboard.getCurrentUserId(),
ExcludeLocationTypes: "Virtual",
ImageTypeLimit: 1,
EnableImageTypes: "Primary,Backdrop,Banner,Thumb"
};
query.ParentId = LibraryMenu.getTopParentId();
ApiClient.getNextUpEpisodes(query).done(function (result) {
if (result.Items.length) {
2015-07-01 08:47:41 -07:00
page.querySelector('.noNextUpItems').classList.add('hide');
2015-06-29 11:45:42 -07:00
} else {
2015-07-01 08:47:41 -07:00
page.querySelector('.noNextUpItems').classList.remove('hide');
2015-06-29 11:45:42 -07:00
}
var view = getView();
var html = '';
if (view == 'ThumbCard') {
html += LibraryBrowser.getPosterViewHtml({
items: result.Items,
shape: "backdrop",
showTitle: true,
preferThumb: true,
showParentTitle: true,
lazy: true,
cardLayout: true,
context: 'tv',
showDetailsMenu: true
});
} else if (view == 'Thumb') {
html += LibraryBrowser.getPosterViewHtml({
items: result.Items,
shape: "backdrop",
showTitle: true,
showParentTitle: true,
overlayText: false,
context: context,
lazy: true,
preferThumb: true,
2015-07-17 15:32:00 -07:00
showDetailsMenu: true,
centerText: true,
overlayPlayButton: AppInfo.enableAppLayouts,
fullWidthOnMobile: AppInfo.enableAppLayouts
2015-06-29 11:45:42 -07:00
});
}
var elem = page.querySelector('#nextUpItems');
elem.innerHTML = html;
ImageLoader.lazyChildren(elem);
Dashboard.hideLoadingMsg();
2015-06-29 22:45:20 -07:00
LibraryBrowser.setLastRefreshed(page);
2015-06-29 11:45:42 -07:00
});
}
2015-07-01 08:47:41 -07:00
$(document).on('pageinitdepends', "#indexPage", function () {
2015-06-29 11:45:42 -07:00
2015-07-01 08:47:41 -07:00
var page = this;
var tabContent = page.querySelector('.homeNextUpTabContent');
2015-06-29 11:45:42 -07:00
2015-07-01 22:08:05 -07:00
$(page.querySelector('neon-animated-pages')).on('tabchange', function () {
2015-07-01 08:47:41 -07:00
if (parseInt(this.selected) == 1) {
if (LibraryBrowser.needsRefresh(tabContent)) {
2015-06-29 11:45:42 -07:00
2015-07-01 08:47:41 -07:00
reload(tabContent);
}
2015-06-29 11:45:42 -07:00
}
});
});
})(jQuery, document);