2014-10-15 20:26:39 -07:00
|
|
|
|
(function ($, document) {
|
2014-05-29 12:34:20 -07:00
|
|
|
|
|
|
|
|
|
function getSections() {
|
|
|
|
|
|
|
|
|
|
return [
|
2015-07-08 22:52:25 -07:00
|
|
|
|
{ name: 'HeaderFavoriteMovies', types: "Movie", id: "favoriteMovies", shape: 'backdrop', preferThumb: true, showTitle: false },
|
|
|
|
|
{ name: 'HeaderFavoriteShows', types: "Series", id: "favoriteShows", shape: 'backdrop', preferThumb: true, showTitle: false },
|
|
|
|
|
{ name: 'HeaderFavoriteEpisodes', types: "Episode", id: "favoriteEpisode", shape: 'backdrop', preferThumb: false, showTitle: true, showParentTitle: true },
|
|
|
|
|
{ name: 'HeaderFavoriteGames', types: "Game", id: "favoriteGames", shape: 'autohome', preferThumb: false, showTitle: true },
|
|
|
|
|
{ name: 'HeaderFavoriteAlbums', types: "MusicAlbum", id: "favoriteAlbums", shape: 'square', preferThumb: false, showTitle: true, overlayText: false, showParentTitle: true, centerText: true, overlayPlayButton: true }
|
2014-05-29 12:34:20 -07:00
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function loadSection(elem, userId, section, isSingleSection) {
|
|
|
|
|
|
|
|
|
|
var screenWidth = $(window).width();
|
|
|
|
|
|
|
|
|
|
var options = {
|
|
|
|
|
|
|
|
|
|
SortBy: isSingleSection ? "SortName" : "Random",
|
|
|
|
|
SortOrder: "Ascending",
|
|
|
|
|
IncludeItemTypes: section.types,
|
|
|
|
|
Filters: "IsFavorite",
|
2014-08-11 07:15:53 -07:00
|
|
|
|
Limit: screenWidth >= 1920 ? 10 : (screenWidth >= 1440 ? 8 : 6),
|
2014-05-29 12:34:20 -07:00
|
|
|
|
Recursive: true,
|
2014-12-10 23:20:28 -07:00
|
|
|
|
Fields: "PrimaryImageAspectRatio,SyncInfo",
|
2014-05-29 12:34:20 -07:00
|
|
|
|
CollapseBoxSetItems: false,
|
|
|
|
|
ExcludeLocationTypes: "Virtual"
|
|
|
|
|
};
|
2014-05-30 14:06:57 -07:00
|
|
|
|
|
2014-05-29 12:34:20 -07:00
|
|
|
|
if (isSingleSection) {
|
|
|
|
|
options.Limit = null;
|
|
|
|
|
}
|
|
|
|
|
|
2015-06-17 18:41:22 -07:00
|
|
|
|
return ApiClient.getItems(userId, options).done(function (result) {
|
2014-05-29 12:34:20 -07:00
|
|
|
|
|
|
|
|
|
var html = '';
|
|
|
|
|
|
|
|
|
|
if (result.Items.length) {
|
2015-07-08 22:52:25 -07:00
|
|
|
|
html += '<h1 class="listHeader">' + Globalize.translate(section.name) + '</h1>';
|
2014-05-29 12:34:20 -07:00
|
|
|
|
html += '<div>';
|
|
|
|
|
html += LibraryBrowser.getPosterViewHtml({
|
|
|
|
|
items: result.Items,
|
|
|
|
|
preferThumb: section.preferThumb,
|
|
|
|
|
shape: section.shape,
|
2014-08-01 19:34:45 -07:00
|
|
|
|
overlayText: section.overlayText !== false,
|
2014-05-29 12:34:20 -07:00
|
|
|
|
context: 'home-favorites',
|
|
|
|
|
showTitle: section.showTitle,
|
2014-05-29 21:16:31 -07:00
|
|
|
|
showParentTitle: section.showParentTitle,
|
2015-05-14 19:16:57 -07:00
|
|
|
|
lazy: true,
|
2015-07-08 17:20:01 -07:00
|
|
|
|
showDetailsMenu: true,
|
|
|
|
|
centerText: section.centerText,
|
|
|
|
|
overlayPlayButton: section.overlayPlayButton
|
2014-05-29 12:34:20 -07:00
|
|
|
|
});
|
|
|
|
|
|
2015-06-26 20:27:38 -07:00
|
|
|
|
html += '</div>';
|
|
|
|
|
|
2014-05-29 12:34:20 -07:00
|
|
|
|
if (result.TotalRecordCount > result.Items.length) {
|
2015-07-08 22:52:25 -07:00
|
|
|
|
var href = "secondaryitems.html?type=" + section.types + "&filters=IsFavorite&titlekey=" + section.name;
|
2014-05-29 12:34:20 -07:00
|
|
|
|
|
2015-06-17 18:41:22 -07:00
|
|
|
|
html += '<a class="clearLink" href="' + href + '"><paper-button raised class="more">' + Globalize.translate('ButtonMoreItems') + '</paper-button></a>';
|
2014-05-29 12:34:20 -07:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2015-06-28 07:45:21 -07:00
|
|
|
|
elem.innerHTML = html;
|
|
|
|
|
ImageLoader.lazyChildren(elem);
|
|
|
|
|
$(elem).createCardMenus();
|
2014-05-29 12:34:20 -07:00
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function loadSections(page, userId) {
|
|
|
|
|
|
2015-06-17 18:41:22 -07:00
|
|
|
|
Dashboard.showLoadingMsg();
|
|
|
|
|
|
2014-05-29 12:34:20 -07:00
|
|
|
|
var sections = getSections();
|
|
|
|
|
|
|
|
|
|
var sectionid = getParameterByName('sectionid');
|
|
|
|
|
|
|
|
|
|
if (sectionid) {
|
|
|
|
|
sections = sections.filter(function (s) {
|
|
|
|
|
|
|
|
|
|
return s.id == sectionid;
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var i, length;
|
|
|
|
|
|
|
|
|
|
var elem = $('.sections', page);
|
|
|
|
|
|
|
|
|
|
if (!elem.html().length) {
|
|
|
|
|
var html = '';
|
|
|
|
|
for (i = 0, length = sections.length; i < length; i++) {
|
|
|
|
|
|
|
|
|
|
html += '<div class="homePageSection section' + sections[i].id + '"></div>';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
elem.html(html);
|
|
|
|
|
}
|
|
|
|
|
|
2015-06-17 18:41:22 -07:00
|
|
|
|
var promises = [];
|
|
|
|
|
|
2014-05-29 12:34:20 -07:00
|
|
|
|
for (i = 0, length = sections.length; i < length; i++) {
|
|
|
|
|
|
|
|
|
|
var section = sections[i];
|
|
|
|
|
|
2015-06-28 07:45:21 -07:00
|
|
|
|
elem = page.querySelector('.section' + section.id);
|
2014-05-29 12:34:20 -07:00
|
|
|
|
|
2015-06-17 18:41:22 -07:00
|
|
|
|
promises.push(loadSection(elem, userId, section, sections.length == 1));
|
2014-05-29 12:34:20 -07:00
|
|
|
|
}
|
2015-06-17 18:41:22 -07:00
|
|
|
|
|
|
|
|
|
$.when(promises).done(function () {
|
|
|
|
|
Dashboard.hideLoadingMsg();
|
2015-06-30 10:21:20 -07:00
|
|
|
|
|
|
|
|
|
LibraryBrowser.setLastRefreshed(page);
|
2015-06-17 18:41:22 -07:00
|
|
|
|
});
|
2014-05-29 12:34:20 -07:00
|
|
|
|
}
|
|
|
|
|
|
2015-07-01 08:47:41 -07:00
|
|
|
|
$(document).on('pageinitdepends', "#indexPage", function () {
|
2014-05-29 12:34:20 -07:00
|
|
|
|
|
|
|
|
|
var page = this;
|
2015-07-01 08:47:41 -07:00
|
|
|
|
var tabContent = page.querySelector('.homeFavoritesTabContent');
|
2014-05-29 12:34:20 -07:00
|
|
|
|
|
2015-07-01 22:08:05 -07:00
|
|
|
|
$(page.querySelector('neon-animated-pages')).on('tabchange', function () {
|
2015-07-01 08:47:41 -07:00
|
|
|
|
|
|
|
|
|
if (parseInt(this.selected) == 2) {
|
|
|
|
|
if (LibraryBrowser.needsRefresh(tabContent)) {
|
|
|
|
|
loadSections(tabContent, Dashboard.getCurrentUserId());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
2014-05-29 12:34:20 -07:00
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
2014-10-15 20:26:39 -07:00
|
|
|
|
})(jQuery, document);
|