2016-05-05 21:50:06 -07:00
|
|
|
|
define(['datetime', 'scrollStyles'], function (datetime) {
|
2016-03-30 23:33:37 -07:00
|
|
|
|
|
|
|
|
|
function loadUpcoming(page) {
|
|
|
|
|
Dashboard.showLoadingMsg();
|
|
|
|
|
|
|
|
|
|
var limit = AppInfo.hasLowImageBandwidth && !enableScrollX() ?
|
|
|
|
|
24 :
|
|
|
|
|
40;
|
|
|
|
|
|
|
|
|
|
var query = {
|
|
|
|
|
|
|
|
|
|
Limit: limit,
|
|
|
|
|
Fields: "AirTime,UserData,SeriesStudio,SyncInfo",
|
|
|
|
|
UserId: Dashboard.getCurrentUserId(),
|
|
|
|
|
ImageTypeLimit: 1,
|
2016-05-08 20:13:38 -07:00
|
|
|
|
EnableImageTypes: "Primary,Backdrop,Banner,Thumb",
|
|
|
|
|
EnableTotalRecordCount: 0
|
2016-03-30 23:33:37 -07:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
ApiClient.getJSON(ApiClient.getUrl("Shows/Upcoming", query)).then(function (result) {
|
|
|
|
|
|
|
|
|
|
var items = result.Items;
|
|
|
|
|
|
|
|
|
|
if (items.length) {
|
|
|
|
|
page.querySelector('.noItemsMessage').style.display = 'none';
|
|
|
|
|
} else {
|
|
|
|
|
page.querySelector('.noItemsMessage').style.display = 'block';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var elem = page.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
|
|
|
|
|
|
|
|
|
if (premiereDate.getDate() == new Date().getDate() - 1) {
|
|
|
|
|
dateText = Globalize.translate('Yesterday');
|
|
|
|
|
} else {
|
|
|
|
|
dateText = LibraryBrowser.getFutureDateText(premiereDate, true);
|
|
|
|
|
}
|
2016-03-30 23:33:37 -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>';
|
|
|
|
|
|
|
|
|
|
if (enableScrollX()) {
|
|
|
|
|
html += '<div class="itemsContainer hiddenScrollX">';
|
|
|
|
|
} else {
|
|
|
|
|
html += '<div class="itemsContainer">';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
html += LibraryBrowser.getPosterViewHtml({
|
|
|
|
|
items: group.items,
|
|
|
|
|
showLocationTypeIndicator: false,
|
|
|
|
|
shape: getThumbShape(),
|
|
|
|
|
showTitle: true,
|
|
|
|
|
showPremiereDate: true,
|
|
|
|
|
preferThumb: true,
|
|
|
|
|
lazy: true,
|
|
|
|
|
showDetailsMenu: true,
|
|
|
|
|
centerText: true,
|
|
|
|
|
context: 'home-upcoming',
|
|
|
|
|
overlayMoreButton: true
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
html += '</div>';
|
|
|
|
|
|
|
|
|
|
html += '</div>';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
elem.innerHTML = html;
|
|
|
|
|
ImageLoader.lazyChildren(elem);
|
2015-07-12 12:33:00 -07:00
|
|
|
|
}
|
2016-03-30 23:33:37 -07:00
|
|
|
|
return function (view, params, tabContent) {
|
|
|
|
|
|
|
|
|
|
var self = this;
|
|
|
|
|
|
|
|
|
|
self.renderTab = function () {
|
|
|
|
|
|
|
|
|
|
loadUpcoming(tabContent);
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
2016-03-18 21:26:17 -07:00
|
|
|
|
});
|