2016-11-24 23:58:38 -07:00
|
|
|
|
define(['datetime', 'libraryBrowser', 'cardBuilder', 'apphost', 'imageLoader', 'scrollStyles', 'emby-itemscontainer'], function (datetime, libraryBrowser, cardBuilder, appHost, imageLoader) {
|
2016-10-22 22:11:46 -07:00
|
|
|
|
'use strict';
|
2016-03-18 12:43:17 -07:00
|
|
|
|
|
2016-06-29 10:43:34 -07:00
|
|
|
|
function getUpcomingPromise(context, params) {
|
2016-03-18 12:43:17 -07:00
|
|
|
|
|
|
|
|
|
Dashboard.showLoadingMsg();
|
|
|
|
|
|
|
|
|
|
var query = {
|
|
|
|
|
|
2016-05-16 10:11:49 -07:00
|
|
|
|
Limit: 40,
|
2016-08-01 22:55:52 -07:00
|
|
|
|
Fields: "AirTime,UserData",
|
2016-03-18 12:43:17 -07:00
|
|
|
|
UserId: Dashboard.getCurrentUserId(),
|
|
|
|
|
ImageTypeLimit: 1,
|
2016-05-08 20:13:38 -07:00
|
|
|
|
EnableImageTypes: "Primary,Backdrop,Banner,Thumb",
|
2016-05-19 10:27:39 -07:00
|
|
|
|
EnableTotalRecordCount: false
|
2016-03-18 12:43:17 -07:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
query.ParentId = params.topParentId;
|
|
|
|
|
|
2016-06-29 10:43:34 -07:00
|
|
|
|
return ApiClient.getJSON(ApiClient.getUrl("Shows/Upcoming", query));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function loadUpcoming(context, params, promise) {
|
|
|
|
|
|
|
|
|
|
promise.then(function (result) {
|
2016-03-18 12:43:17 -07:00
|
|
|
|
|
|
|
|
|
var items = result.Items;
|
|
|
|
|
|
|
|
|
|
if (items.length) {
|
|
|
|
|
context.querySelector('.noItemsMessage').style.display = 'none';
|
|
|
|
|
} else {
|
|
|
|
|
context.querySelector('.noItemsMessage').style.display = 'block';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var elem = context.querySelector('#upcomingItems');
|
|
|
|
|
renderUpcoming(elem, items);
|
|
|
|
|
|
|
|
|
|
Dashboard.hideLoadingMsg();
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function enableScrollX() {
|
|
|
|
|
return browserInfo.mobile && AppInfo.enableAppLayouts;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function getThumbShape() {
|
|
|
|
|
return enableScrollX() ? 'overflowBackdrop' : 'backdrop';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function renderUpcoming(elem, items) {
|
|
|
|
|
|
|
|
|
|
var groups = [];
|
|
|
|
|
|
|
|
|
|
var currentGroupName = '';
|
|
|
|
|
var currentGroup = [];
|
|
|
|
|
|
|
|
|
|
var i, length;
|
|
|
|
|
|
|
|
|
|
for (i = 0, length = items.length; i < length; i++) {
|
|
|
|
|
|
|
|
|
|
var item = items[i];
|
|
|
|
|
|
|
|
|
|
var dateText = '';
|
|
|
|
|
|
|
|
|
|
if (item.PremiereDate) {
|
|
|
|
|
try {
|
|
|
|
|
|
2016-05-05 21:50:06 -07:00
|
|
|
|
var premiereDate = datetime.parseISO8601Date(item.PremiereDate, true);
|
2016-04-16 12:03:19 -07:00
|
|
|
|
|
2016-08-24 21:53:12 -07:00
|
|
|
|
if (datetime.isRelativeDay(premiereDate, -1)) {
|
2016-04-16 12:03:19 -07:00
|
|
|
|
dateText = Globalize.translate('Yesterday');
|
|
|
|
|
} else {
|
2016-07-18 20:57:55 -07:00
|
|
|
|
dateText = libraryBrowser.getFutureDateText(premiereDate, true);
|
2016-04-16 12:03:19 -07:00
|
|
|
|
}
|
2016-03-18 12:43:17 -07:00
|
|
|
|
|
|
|
|
|
} catch (err) {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (dateText != currentGroupName) {
|
|
|
|
|
|
|
|
|
|
if (currentGroup.length) {
|
|
|
|
|
groups.push({
|
|
|
|
|
name: currentGroupName,
|
|
|
|
|
items: currentGroup
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
currentGroupName = dateText;
|
|
|
|
|
currentGroup = [item];
|
|
|
|
|
} else {
|
|
|
|
|
currentGroup.push(item);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var html = '';
|
|
|
|
|
|
|
|
|
|
for (i = 0, length = groups.length; i < length; i++) {
|
|
|
|
|
|
|
|
|
|
var group = groups[i];
|
|
|
|
|
|
|
|
|
|
html += '<div class="homePageSection">';
|
|
|
|
|
html += '<h1 class="listHeader">' + group.name + '</h1>';
|
|
|
|
|
|
2016-08-12 08:54:37 -07:00
|
|
|
|
var allowBottomPadding = true;
|
|
|
|
|
|
2016-03-18 12:43:17 -07:00
|
|
|
|
if (enableScrollX()) {
|
2016-08-12 08:54:37 -07:00
|
|
|
|
allowBottomPadding = false;
|
2016-07-17 11:55:07 -07:00
|
|
|
|
html += '<div is="emby-itemscontainer" class="itemsContainer hiddenScrollX">';
|
2016-03-18 12:43:17 -07:00
|
|
|
|
} else {
|
2016-07-29 22:25:07 -07:00
|
|
|
|
html += '<div is="emby-itemscontainer" class="itemsContainer vertical-wrap">';
|
2016-03-18 12:43:17 -07:00
|
|
|
|
}
|
|
|
|
|
|
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-18 12:43:17 -07:00
|
|
|
|
items: group.items,
|
|
|
|
|
showLocationTypeIndicator: false,
|
|
|
|
|
shape: getThumbShape(),
|
|
|
|
|
showTitle: true,
|
|
|
|
|
preferThumb: true,
|
|
|
|
|
lazy: true,
|
|
|
|
|
showDetailsMenu: true,
|
2016-10-10 23:46:59 -07:00
|
|
|
|
centerText: !supportsImageAnalysis,
|
2016-08-12 08:54:37 -07:00
|
|
|
|
showParentTitle: true,
|
2016-12-17 19:35:21 -07:00
|
|
|
|
overlayText: false,
|
2016-10-05 08:20:11 -07:00
|
|
|
|
allowBottomPadding: allowBottomPadding,
|
2016-10-06 11:55:01 -07:00
|
|
|
|
cardLayout: supportsImageAnalysis,
|
|
|
|
|
vibrant: supportsImageAnalysis
|
2016-03-18 12:43:17 -07:00
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
html += '</div>';
|
|
|
|
|
|
|
|
|
|
html += '</div>';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
elem.innerHTML = html;
|
2016-11-24 23:58:38 -07:00
|
|
|
|
imageLoader.lazyChildren(elem);
|
2015-07-12 12:33:00 -07:00
|
|
|
|
}
|
2016-03-18 12:43:17 -07:00
|
|
|
|
return function (view, params, tabContent) {
|
|
|
|
|
|
2016-06-29 10:43:34 -07:00
|
|
|
|
var self = this;
|
|
|
|
|
var upcomingPromise;
|
|
|
|
|
|
|
|
|
|
self.preRender = function () {
|
|
|
|
|
upcomingPromise = getUpcomingPromise(view, params);
|
|
|
|
|
};
|
2016-03-18 12:43:17 -07:00
|
|
|
|
|
|
|
|
|
self.renderTab = function () {
|
|
|
|
|
|
2016-06-29 10:43:34 -07:00
|
|
|
|
loadUpcoming(tabContent, params, upcomingPromise);
|
2016-03-18 12:43:17 -07:00
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
});
|