2016-03-18 21:26:17 -07:00
|
|
|
|
define(['jQuery'], function ($) {
|
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") {
|
|
|
|
|
|
|
|
|
|
html = LibraryBrowser.getPosterViewHtml({
|
|
|
|
|
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") {
|
|
|
|
|
|
|
|
|
|
html = LibraryBrowser.getPosterViewHtml({
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
LibraryBrowser.saveQueryValues('channels', query);
|
|
|
|
|
|
|
|
|
|
Dashboard.hideLoadingMsg();
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2015-07-18 11:07:03 -07:00
|
|
|
|
function loadTab(page, index) {
|
|
|
|
|
|
|
|
|
|
switch (index) {
|
|
|
|
|
|
|
|
|
|
case 1:
|
|
|
|
|
LibraryBrowser.loadSavedQueryValues('channels', query);
|
|
|
|
|
reloadItems(page);
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-01-27 12:28:12 -07:00
|
|
|
|
pageIdOn('pageinit', "channelsPage", function () {
|
2015-07-18 11:07:03 -07:00
|
|
|
|
|
|
|
|
|
var page = this;
|
|
|
|
|
|
|
|
|
|
var tabs = page.querySelector('paper-tabs');
|
|
|
|
|
var pages = page.querySelector('neon-animated-pages');
|
|
|
|
|
|
2015-09-01 08:31:50 -07:00
|
|
|
|
LibraryBrowser.configurePaperLibraryTabs(page, tabs, pages, 'channels.html');
|
2015-07-18 11:07:03 -07:00
|
|
|
|
|
2015-12-14 08:43:03 -07:00
|
|
|
|
pages.addEventListener('tabchange', function (e) {
|
|
|
|
|
loadTab(page, parseInt(e.target.selected));
|
2015-07-18 11:07:03 -07:00
|
|
|
|
});
|
2014-03-18 10:05:57 -07:00
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
2016-03-18 21:26:17 -07:00
|
|
|
|
});
|