2016-08-14 15:58:13 -04:00
|
|
|
|
define(['libraryBrowser', 'cardBuilder', 'scrollStyles', 'emby-itemscontainer', 'emby-tabs', 'emby-button'], function (libraryBrowser, cardBuilder) {
|
2014-01-12 10:58:47 -05:00
|
|
|
|
|
2015-12-14 10:43:03 -05:00
|
|
|
|
function enableScrollX() {
|
|
|
|
|
return browserInfo.mobile && AppInfo.enableAppLayouts;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function getPortraitShape() {
|
|
|
|
|
return enableScrollX() ? 'overflowPortrait' : 'portrait';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function getLimit() {
|
|
|
|
|
|
|
|
|
|
return enableScrollX() ? 12 : 8;
|
|
|
|
|
}
|
|
|
|
|
|
2015-05-15 14:28:34 -04:00
|
|
|
|
function loadRecommendedPrograms(page) {
|
2015-07-24 11:20:11 -04:00
|
|
|
|
|
2014-01-12 10:58:47 -05:00
|
|
|
|
Dashboard.showLoadingMsg();
|
|
|
|
|
|
2016-09-06 01:02:05 -04:00
|
|
|
|
var limit = getLimit();
|
|
|
|
|
if (enableScrollX()) {
|
|
|
|
|
limit *= 2;
|
|
|
|
|
}
|
|
|
|
|
|
2014-10-15 23:26:39 -04:00
|
|
|
|
ApiClient.getLiveTvRecommendedPrograms({
|
2014-01-12 10:58:47 -05:00
|
|
|
|
|
|
|
|
|
userId: Dashboard.getCurrentUserId(),
|
|
|
|
|
IsAiring: true,
|
2016-09-06 01:02:05 -04:00
|
|
|
|
limit: limit,
|
2015-08-03 20:09:54 -04:00
|
|
|
|
ImageTypeLimit: 1,
|
2016-05-08 23:13:38 -04:00
|
|
|
|
EnableImageTypes: "Primary",
|
2016-09-05 16:07:36 -04:00
|
|
|
|
EnableTotalRecordCount: false,
|
|
|
|
|
Fields: "ChannelInfo"
|
2014-01-12 10:58:47 -05:00
|
|
|
|
|
2015-12-14 10:43:03 -05:00
|
|
|
|
}).then(function (result) {
|
2015-06-30 01:45:20 -04:00
|
|
|
|
|
2015-12-14 10:43:03 -05:00
|
|
|
|
renderItems(page, result.Items, 'activeProgramItems', 'play');
|
|
|
|
|
Dashboard.hideLoadingMsg();
|
2014-01-12 10:58:47 -05:00
|
|
|
|
});
|
2015-05-15 14:28:34 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function reload(page) {
|
|
|
|
|
|
|
|
|
|
loadRecommendedPrograms(page);
|
2014-01-12 10:58:47 -05:00
|
|
|
|
|
2014-10-15 23:26:39 -04:00
|
|
|
|
ApiClient.getLiveTvRecommendedPrograms({
|
2014-01-12 10:58:47 -05:00
|
|
|
|
|
|
|
|
|
userId: Dashboard.getCurrentUserId(),
|
|
|
|
|
IsAiring: false,
|
|
|
|
|
HasAired: false,
|
2015-12-14 10:43:03 -05:00
|
|
|
|
limit: getLimit(),
|
2015-04-03 12:31:56 -04:00
|
|
|
|
IsMovie: false,
|
2015-08-04 10:26:36 -04:00
|
|
|
|
IsSports: false,
|
|
|
|
|
IsKids: false,
|
2016-05-08 23:13:38 -04:00
|
|
|
|
IsSeries: true,
|
2016-09-05 16:07:36 -04:00
|
|
|
|
EnableTotalRecordCount: false,
|
|
|
|
|
Fields: "ChannelInfo"
|
2014-01-12 10:58:47 -05:00
|
|
|
|
|
2015-12-14 10:43:03 -05:00
|
|
|
|
}).then(function (result) {
|
2014-01-12 10:58:47 -05:00
|
|
|
|
|
2015-12-14 10:43:03 -05:00
|
|
|
|
renderItems(page, result.Items, 'upcomingProgramItems');
|
2014-01-12 10:58:47 -05:00
|
|
|
|
});
|
2015-03-14 16:56:50 -04:00
|
|
|
|
|
|
|
|
|
ApiClient.getLiveTvRecommendedPrograms({
|
|
|
|
|
|
|
|
|
|
userId: Dashboard.getCurrentUserId(),
|
|
|
|
|
IsAiring: false,
|
|
|
|
|
HasAired: false,
|
2015-12-14 10:43:03 -05:00
|
|
|
|
limit: getLimit(),
|
2016-05-08 23:13:38 -04:00
|
|
|
|
IsMovie: true,
|
2016-09-05 16:07:36 -04:00
|
|
|
|
EnableTotalRecordCount: false,
|
|
|
|
|
Fields: "ChannelInfo"
|
2015-03-14 16:56:50 -04:00
|
|
|
|
|
2015-12-14 10:43:03 -05:00
|
|
|
|
}).then(function (result) {
|
|
|
|
|
|
|
|
|
|
renderItems(page, result.Items, 'upcomingTvMovieItems', null, getPortraitShape());
|
2015-03-14 16:56:50 -04:00
|
|
|
|
});
|
2015-04-03 12:31:56 -04:00
|
|
|
|
|
|
|
|
|
ApiClient.getLiveTvRecommendedPrograms({
|
|
|
|
|
|
|
|
|
|
userId: Dashboard.getCurrentUserId(),
|
|
|
|
|
IsAiring: false,
|
|
|
|
|
HasAired: false,
|
2015-12-14 10:43:03 -05:00
|
|
|
|
limit: getLimit(),
|
2016-05-08 23:13:38 -04:00
|
|
|
|
IsSports: true,
|
2016-09-05 16:07:36 -04:00
|
|
|
|
EnableTotalRecordCount: false,
|
|
|
|
|
Fields: "ChannelInfo"
|
2015-04-03 12:31:56 -04:00
|
|
|
|
|
2015-12-14 10:43:03 -05:00
|
|
|
|
}).then(function (result) {
|
|
|
|
|
|
|
|
|
|
renderItems(page, result.Items, 'upcomingSportsItems');
|
2015-04-03 12:31:56 -04:00
|
|
|
|
});
|
2015-08-19 02:12:58 -04:00
|
|
|
|
|
|
|
|
|
ApiClient.getLiveTvRecommendedPrograms({
|
|
|
|
|
|
|
|
|
|
userId: Dashboard.getCurrentUserId(),
|
|
|
|
|
IsAiring: false,
|
|
|
|
|
HasAired: false,
|
2015-12-14 10:43:03 -05:00
|
|
|
|
limit: getLimit(),
|
2016-05-08 23:13:38 -04:00
|
|
|
|
IsKids: true,
|
2016-09-05 16:07:36 -04:00
|
|
|
|
EnableTotalRecordCount: false,
|
|
|
|
|
Fields: "ChannelInfo"
|
2015-08-19 02:12:58 -04:00
|
|
|
|
|
2015-12-14 10:43:03 -05:00
|
|
|
|
}).then(function (result) {
|
|
|
|
|
|
|
|
|
|
renderItems(page, result.Items, 'upcomingKidsItems');
|
2015-08-19 02:12:58 -04:00
|
|
|
|
});
|
2014-01-12 10:58:47 -05:00
|
|
|
|
}
|
|
|
|
|
|
2015-12-14 10:43:03 -05:00
|
|
|
|
function renderItems(page, items, sectionClass, overlayButton, shape) {
|
|
|
|
|
|
2016-07-29 16:06:58 -04:00
|
|
|
|
var html = cardBuilder.getCardsHtml({
|
2015-12-14 10:43:03 -05:00
|
|
|
|
items: items,
|
2016-09-05 16:07:36 -04:00
|
|
|
|
preferThumb: !shape,
|
2016-09-04 11:01:31 -04:00
|
|
|
|
shape: shape || (enableScrollX() ? 'overflowBackdrop' : 'backdrop'),
|
2015-12-14 10:43:03 -05:00
|
|
|
|
showTitle: true,
|
|
|
|
|
centerText: true,
|
|
|
|
|
coverImage: true,
|
|
|
|
|
overlayText: false,
|
|
|
|
|
lazy: true,
|
|
|
|
|
overlayMoreButton: overlayButton != 'play',
|
2016-08-12 11:54:37 -04:00
|
|
|
|
overlayPlayButton: overlayButton == 'play',
|
2016-09-05 01:39:14 -04:00
|
|
|
|
allowBottomPadding: !enableScrollX(),
|
|
|
|
|
showProgramAirInfo: true
|
2016-09-05 16:07:36 -04:00
|
|
|
|
//cardFooterAside: 'logo'
|
2015-12-14 10:43:03 -05:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
var elem = page.querySelector('.' + sectionClass);
|
|
|
|
|
|
|
|
|
|
elem.innerHTML = html;
|
|
|
|
|
ImageLoader.lazyChildren(elem);
|
|
|
|
|
}
|
|
|
|
|
|
2016-05-15 13:11:26 -04:00
|
|
|
|
return function (view, params) {
|
2015-12-14 10:43:03 -05:00
|
|
|
|
|
2016-05-15 13:11:26 -04:00
|
|
|
|
var self = this;
|
2015-08-02 19:47:31 -04:00
|
|
|
|
|
2016-05-15 13:11:26 -04:00
|
|
|
|
self.initTab = function () {
|
2015-08-18 11:52:48 -04:00
|
|
|
|
|
2016-05-15 13:11:26 -04:00
|
|
|
|
var tabContent = view.querySelector('.pageTabContent[data-index=\'' + 0 + '\']');
|
2016-06-02 02:08:47 -04:00
|
|
|
|
|
|
|
|
|
var containers = tabContent.querySelectorAll('.itemsContainer');
|
|
|
|
|
|
|
|
|
|
for (var i = 0, length = containers.length; i < length; i++) {
|
|
|
|
|
if (enableScrollX()) {
|
|
|
|
|
containers[i].classList.add('hiddenScrollX');
|
2016-07-30 01:25:07 -04:00
|
|
|
|
containers[i].classList.remove('vertical-wrap');
|
2016-06-02 02:08:47 -04:00
|
|
|
|
} else {
|
|
|
|
|
containers[i].classList.remove('hiddenScrollX');
|
2016-07-30 01:25:07 -04:00
|
|
|
|
containers[i].classList.add('vertical-wrap');
|
2016-06-02 02:08:47 -04:00
|
|
|
|
}
|
2016-05-15 13:11:26 -04:00
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
self.renderTab = function () {
|
|
|
|
|
var tabContent = view.querySelector('.pageTabContent[data-index=\'' + 0 + '\']');
|
|
|
|
|
reload(tabContent);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
var tabControllers = [];
|
|
|
|
|
var renderedTabs = [];
|
|
|
|
|
|
|
|
|
|
function loadTab(page, index) {
|
|
|
|
|
|
|
|
|
|
var tabContent = page.querySelector('.pageTabContent[data-index=\'' + index + '\']');
|
|
|
|
|
var depends = [];
|
|
|
|
|
|
|
|
|
|
switch (index) {
|
|
|
|
|
|
|
|
|
|
case 0:
|
|
|
|
|
break;
|
|
|
|
|
case 1:
|
2016-05-17 01:45:06 -04:00
|
|
|
|
document.body.classList.add('autoScrollY');
|
2016-05-15 13:11:26 -04:00
|
|
|
|
depends.push('scripts/livetvguide');
|
|
|
|
|
break;
|
|
|
|
|
case 2:
|
2016-05-17 01:45:06 -04:00
|
|
|
|
document.body.classList.remove('autoScrollY');
|
2016-05-15 13:11:26 -04:00
|
|
|
|
depends.push('scripts/livetvchannels');
|
|
|
|
|
break;
|
|
|
|
|
case 3:
|
2016-05-17 01:45:06 -04:00
|
|
|
|
document.body.classList.remove('autoScrollY');
|
2016-05-15 13:11:26 -04:00
|
|
|
|
depends.push('scripts/livetvrecordings');
|
|
|
|
|
break;
|
|
|
|
|
case 4:
|
2016-09-04 11:01:31 -04:00
|
|
|
|
document.body.classList.remove('autoScrollY');
|
|
|
|
|
depends.push('scripts/livetvschedule');
|
|
|
|
|
break;
|
|
|
|
|
case 5:
|
2016-05-17 01:45:06 -04:00
|
|
|
|
document.body.classList.remove('autoScrollY');
|
2016-05-15 13:11:26 -04:00
|
|
|
|
depends.push('scripts/livetvseriestimers');
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
2015-08-18 11:52:48 -04:00
|
|
|
|
}
|
|
|
|
|
|
2016-05-15 13:11:26 -04:00
|
|
|
|
require(depends, function (controllerFactory) {
|
|
|
|
|
|
|
|
|
|
if (index == 0) {
|
|
|
|
|
self.tabContent = tabContent;
|
|
|
|
|
}
|
|
|
|
|
var controller = tabControllers[index];
|
|
|
|
|
if (!controller) {
|
|
|
|
|
controller = index ? new controllerFactory(view, params, tabContent) : self;
|
|
|
|
|
tabControllers[index] = controller;
|
|
|
|
|
|
|
|
|
|
if (controller.initTab) {
|
|
|
|
|
controller.initTab();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (renderedTabs.indexOf(index) == -1) {
|
|
|
|
|
renderedTabs.push(index);
|
|
|
|
|
controller.renderTab();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
2015-08-02 19:47:31 -04:00
|
|
|
|
|
2016-08-15 22:40:29 -04:00
|
|
|
|
var viewTabs = view.querySelector('.libraryViewNav');
|
2015-08-02 19:47:31 -04:00
|
|
|
|
|
2016-09-04 11:01:31 -04:00
|
|
|
|
libraryBrowser.configurePaperLibraryTabs(view, viewTabs, view.querySelectorAll('.pageTabContent'), [0, 2, 3, 4, 5]);
|
2015-08-02 19:47:31 -04:00
|
|
|
|
|
2016-08-15 22:40:29 -04:00
|
|
|
|
viewTabs.addEventListener('tabchange', function (e) {
|
2016-05-15 13:11:26 -04:00
|
|
|
|
loadTab(view, parseInt(e.detail.selectedTabIndex));
|
2015-08-02 19:47:31 -04:00
|
|
|
|
});
|
2014-01-12 10:58:47 -05:00
|
|
|
|
|
2016-05-15 13:11:26 -04:00
|
|
|
|
view.addEventListener('viewbeforehide', function (e) {
|
2016-04-26 14:28:04 -04:00
|
|
|
|
|
2016-05-15 13:11:26 -04:00
|
|
|
|
document.body.classList.remove('autoScrollY');
|
|
|
|
|
});
|
2016-04-26 14:28:04 -04:00
|
|
|
|
|
2016-09-01 12:36:11 -04:00
|
|
|
|
require(["headroom-window"], function (headroom) {
|
|
|
|
|
headroom.add(viewTabs);
|
|
|
|
|
self.headroom = headroom;
|
|
|
|
|
});
|
2016-08-15 22:40:29 -04:00
|
|
|
|
|
2016-05-15 13:11:26 -04:00
|
|
|
|
view.addEventListener('viewdestroy', function (e) {
|
2016-04-26 14:28:04 -04:00
|
|
|
|
|
2016-08-15 22:40:29 -04:00
|
|
|
|
if (self.headroom) {
|
|
|
|
|
self.headroom.remove(viewTabs);
|
|
|
|
|
}
|
2016-05-15 13:11:26 -04:00
|
|
|
|
tabControllers.forEach(function (t) {
|
|
|
|
|
if (t.destroy) {
|
|
|
|
|
t.destroy();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
});
|
2015-08-18 11:52:48 -04:00
|
|
|
|
};
|
2016-03-19 05:26:17 +01:00
|
|
|
|
});
|