jellyfin-web/dashboard-ui/scripts/channels.js

87 lines
2.2 KiB
JavaScript
Raw Normal View History

2016-07-29 13:06:58 -07:00
define(['libraryBrowser', 'cardBuilder', 'emby-itemscontainer'], 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-01-27 12:28:12 -07:00
pageIdOn('pageinit', "channelsPage", function () {
2015-07-18 11:07:03 -07:00
var page = this;
2016-05-15 09:30:32 -07:00
var mdlTabs = page.querySelector('.libraryViewNav');
2015-07-18 11:07:03 -07:00
2016-05-16 10:11:49 -07:00
libraryBrowser.configurePaperLibraryTabs(page, mdlTabs, page.querySelectorAll('.pageTabContent'), [0, 1]);
2016-05-09 12:27:38 -07:00
mdlTabs.addEventListener('tabchange', function (e) {
2016-03-24 11:11:03 -07:00
loadTab(page, parseInt(e.detail.selectedTabIndex));
2015-07-18 11:07:03 -07:00
});
2014-03-18 10:05:57 -07:00
});
});