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

104 lines
2.7 KiB
JavaScript
Raw Normal View History

2014-03-18 10:05:57 -07:00
(function ($, document) {
// The base query options
var query = {
StartIndex: 0
};
function reloadItems(page) {
Dashboard.showLoadingMsg();
query.UserId = Dashboard.getCurrentUserId();
2014-07-01 22:16:59 -07:00
ApiClient.getJSON(ApiClient.getUrl("Channels", query)).done(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;
}
}
$(document).on('pageinitdepends', "#channelsPage", function () {
var page = this;
var tabs = page.querySelector('paper-tabs');
var pages = page.querySelector('neon-animated-pages');
2015-07-20 11:32:55 -07:00
LibraryBrowser.configurePaperLibraryTabs(page, tabs, pages);
2015-07-18 11:07:03 -07:00
$(tabs).on('iron-select', function () {
var selected = this.selected;
2014-03-18 10:05:57 -07:00
2015-07-18 11:07:03 -07:00
if (LibraryBrowser.navigateOnLibraryTabSelect()) {
2014-03-18 10:05:57 -07:00
2015-07-18 11:07:03 -07:00
if (selected) {
Dashboard.navigate('channels.html?tab=' + selected);
} else {
Dashboard.navigate('channels.html');
}
} else {
page.querySelector('neon-animated-pages').selected = selected;
}
});
$(pages).on('tabchange', function () {
loadTab(page, parseInt(this.selected));
});
2014-03-18 10:05:57 -07:00
});
})(jQuery, document);