2016-08-15 19:40:29 -07:00
|
|
|
|
define(['libraryBrowser', 'cardBuilder', 'emby-itemscontainer', 'emby-tabs', 'emby-button', 'scripts/channelslatest', 'scripts/sections'], function (libraryBrowser, cardBuilder) {
|
2014-03-18 10:05:57 -07:00
|
|
|
|
|
|
|
|
|
// The base query options
|
|
|
|
|
var query = {
|
|
|
|
|
|
|
|
|
|
StartIndex: 0
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
function reloadItems(page) {
|
|
|
|
|
|
|
|
|
|
Dashboard.showLoadingMsg();
|
|
|
|
|
|
|
|
|
|
query.UserId = Dashboard.getCurrentUserId();
|
|
|
|
|
|
2015-12-14 08:43:03 -07:00
|
|
|
|
ApiClient.getJSON(ApiClient.getUrl("Channels", query)).then(function (result) {
|
2014-03-18 10:05:57 -07:00
|
|
|
|
|
|
|
|
|
// Scroll back up so they can see the results from the beginning
|
2015-06-28 07:45:21 -07:00
|
|
|
|
window.scrollTo(0, 0);
|
2014-03-18 10:05:57 -07:00
|
|
|
|
|
|
|
|
|
var html = '';
|
|
|
|
|
|
2015-05-12 21:55:19 -07:00
|
|
|
|
var view = 'Thumb';
|
|
|
|
|
|
|
|
|
|
if (view == "Thumb") {
|
|
|
|
|
|
2016-07-29 13:06:58 -07:00
|
|
|
|
html = cardBuilder.getCardsHtml({
|
2015-05-12 21:55:19 -07:00
|
|
|
|
items: result.Items,
|
|
|
|
|
shape: "backdrop",
|
|
|
|
|
context: 'channels',
|
|
|
|
|
showTitle: true,
|
2015-06-09 21:01:14 -07:00
|
|
|
|
lazy: true,
|
2015-05-12 21:55:19 -07:00
|
|
|
|
centerText: true,
|
|
|
|
|
preferThumb: true
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else if (view == "ThumbCard") {
|
|
|
|
|
|
2016-07-29 13:06:58 -07:00
|
|
|
|
html = cardBuilder.getCardsHtml({
|
2015-05-12 21:55:19 -07:00
|
|
|
|
items: result.Items,
|
|
|
|
|
shape: "backdrop",
|
|
|
|
|
preferThumb: true,
|
|
|
|
|
context: 'channels',
|
|
|
|
|
lazy: true,
|
|
|
|
|
cardLayout: true,
|
|
|
|
|
showTitle: true
|
|
|
|
|
});
|
|
|
|
|
}
|
2014-03-18 10:05:57 -07:00
|
|
|
|
|
2015-06-28 07:45:21 -07:00
|
|
|
|
var elem = page.querySelector('#items');
|
|
|
|
|
elem.innerHTML = html;
|
|
|
|
|
ImageLoader.lazyChildren(elem);
|
2014-03-18 10:05:57 -07:00
|
|
|
|
|
2016-05-09 12:27:38 -07:00
|
|
|
|
libraryBrowser.saveQueryValues('channels', query);
|
2014-03-18 10:05:57 -07:00
|
|
|
|
|
|
|
|
|
Dashboard.hideLoadingMsg();
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2015-07-18 11:07:03 -07:00
|
|
|
|
function loadTab(page, index) {
|
|
|
|
|
|
|
|
|
|
switch (index) {
|
|
|
|
|
|
|
|
|
|
case 1:
|
2016-05-09 12:27:38 -07:00
|
|
|
|
libraryBrowser.loadSavedQueryValues('channels', query);
|
2015-07-18 11:07:03 -07:00
|
|
|
|
reloadItems(page);
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-08-15 19:40:29 -07:00
|
|
|
|
return function (view, params) {
|
2015-07-18 11:07:03 -07:00
|
|
|
|
|
2016-08-15 19:40:29 -07:00
|
|
|
|
var self = this;
|
|
|
|
|
var viewTabs = view.querySelector('.libraryViewNav');
|
2015-07-18 11:07:03 -07:00
|
|
|
|
|
2016-08-15 19:40:29 -07:00
|
|
|
|
libraryBrowser.configurePaperLibraryTabs(view, viewTabs, view.querySelectorAll('.pageTabContent'), [0, 1]);
|
2015-07-18 11:07:03 -07:00
|
|
|
|
|
2016-08-15 19:40:29 -07:00
|
|
|
|
viewTabs.addEventListener('tabchange', function (e) {
|
|
|
|
|
loadTab(view, parseInt(e.detail.selectedTabIndex));
|
2015-07-18 11:07:03 -07:00
|
|
|
|
});
|
2014-03-18 10:05:57 -07:00
|
|
|
|
|
2016-08-15 19:40:29 -07:00
|
|
|
|
if (AppInfo.enableHeadRoom) {
|
|
|
|
|
require(["headroom-window"], function (headroom) {
|
|
|
|
|
headroom.add(viewTabs);
|
|
|
|
|
self.headroom = headroom;
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
view.addEventListener('viewdestroy', function (e) {
|
2014-03-18 10:05:57 -07:00
|
|
|
|
|
2016-08-15 19:40:29 -07:00
|
|
|
|
if (self.headroom) {
|
|
|
|
|
self.headroom.remove(viewTabs);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
};
|
2016-03-18 21:26:17 -07:00
|
|
|
|
});
|