1
0
Fork 0
mirror of https://github.com/jellyfin/jellyfin-web synced 2025-03-30 19:56:21 +00:00

merge from dev

This commit is contained in:
Luke Pulverenti 2015-12-14 10:43:03 -05:00
parent 1c8f02ce0f
commit 33b01d778c
911 changed files with 34157 additions and 57125 deletions

View file

@ -1,7 +1,7 @@
(function ($, document) {
function enableScrollX() {
return $.browser.mobile && AppInfo.enableAppLayouts;
return browserInfo.mobile && AppInfo.enableAppLayouts;
}
function getThumbShape() {
@ -23,11 +23,13 @@
{ name: 'HeaderFavoriteShows', types: "Series", id: "favoriteShows", shape: getPosterShape(), showTitle: false },
{ name: 'HeaderFavoriteEpisodes', types: "Episode", id: "favoriteEpisode", shape: getThumbShape(), preferThumb: false, showTitle: true, showParentTitle: true },
{ name: 'HeaderFavoriteGames', types: "Game", id: "favoriteGames", shape: getSquareShape(), preferThumb: false, showTitle: true },
{ name: 'HeaderFavoriteAlbums', types: "MusicAlbum", id: "favoriteAlbums", shape: getSquareShape(), preferThumb: false, showTitle: true, overlayText: false, showParentTitle: true, centerText: true, overlayPlayButton: true }
{ name: 'HeaderFavoriteArtists', types: "MusicArtist", id: "favoriteArtists", shape: getSquareShape(), preferThumb: false, showTitle: true, overlayText: false, showParentTitle: true, centerText: true, overlayMoreButton: true, defaultAction: 'play' },
{ name: 'HeaderFavoriteAlbums', types: "MusicAlbum", id: "favoriteAlbums", shape: getSquareShape(), preferThumb: false, showTitle: true, overlayText: false, showParentTitle: true, centerText: true, overlayMoreButton: true, defaultAction: 'play' },
{ name: 'HeaderFavoriteSongs', types: "Audio", id: "favoriteSongs", shape: getSquareShape(), preferThumb: false, showTitle: true, overlayText: false, showParentTitle: true, centerText: true, overlayMoreButton: true, defaultAction: 'instantmix' }
];
}
function loadSection(elem, userId, section, isSingleSection) {
function loadSection(elem, userId, topParentId, section, isSingleSection) {
var screenWidth = $(window).width();
@ -35,20 +37,35 @@
SortBy: "SortName",
SortOrder: "Ascending",
IncludeItemTypes: section.types,
Filters: "IsFavorite",
Limit: screenWidth >= 1920 ? 10 : (screenWidth >= 1440 ? 8 : 6),
Recursive: true,
Fields: "PrimaryImageAspectRatio,SyncInfo",
CollapseBoxSetItems: false,
ExcludeLocationTypes: "Virtual"
};
if (isSingleSection) {
options.Limit = null;
if (topParentId) {
options.ParentId = topParentId;
}
return ApiClient.getItems(userId, options).done(function (result) {
if (!isSingleSection) {
options.Limit = screenWidth >= 1920 ? 10 : (screenWidth >= 1440 ? 8 : 6);
if (enableScrollX()) {
options.Limit = 12;
}
}
var promise;
if (section.types == 'MusicArtist') {
promise = ApiClient.getArtists(userId, options);
} else {
options.IncludeItemTypes = section.types;
promise = ApiClient.getItems(userId, options);
}
return promise.then(function (result) {
var html = '';
@ -82,7 +99,9 @@
showDetailsMenu: true,
centerText: section.centerText,
overlayPlayButton: section.overlayPlayButton,
context: 'home-favorites'
overlayMoreButton: section.overlayMoreButton,
context: 'home-favorites',
defaultAction: section.defaultAction
});
html += '</div>';
@ -94,7 +113,7 @@
});
}
function loadSections(page, userId) {
function loadSections(page, userId, topParentId, types) {
Dashboard.showLoadingMsg();
@ -109,9 +128,16 @@
});
}
if (types) {
sections = sections.filter(function (s) {
return types.indexOf(s.id) != -1;
});
}
var i, length;
var elem = page.querySelector('.sections');
var elem = page.querySelector('.favoriteSections');
if (!elem.innerHTML) {
var html = '';
@ -131,10 +157,10 @@
elem = page.querySelector('.section' + section.id);
promises.push(loadSection(elem, userId, section, sections.length == 1));
promises.push(loadSection(elem, userId, topParentId, section, sections.length == 1));
}
$.when(promises).done(function () {
Promise.all(promises).then(function () {
Dashboard.hideLoadingMsg();
LibraryBrowser.setLastRefreshed(page);
@ -143,16 +169,20 @@
function initHomePage() {
window.HomePage.renderFavorites = function (page, tabContent) {
if (LibraryBrowser.needsRefresh(tabContent)) {
loadSections(tabContent, Dashboard.getCurrentUserId());
}
};
if (window.HomePage) {
window.HomePage.renderFavorites = function (page, tabContent) {
if (LibraryBrowser.needsRefresh(tabContent)) {
loadSections(tabContent, Dashboard.getCurrentUserId());
}
};
}
}
initHomePage();
pageIdOn('pageshow', "favoritesPage", function () {
pageIdOn('pageinit', "indexPage", initHomePage);
pageIdOn('pagebeforeshow', "favoritesPage", function () {
var page = this;
@ -161,4 +191,8 @@
}
});
window.FavoriteItems = {
render: loadSections
};
})(jQuery, document);