mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
favoriteitems
This commit is contained in:
parent
cae2898da2
commit
72cb4bd169
1 changed files with 155 additions and 82 deletions
|
@ -1,20 +1,32 @@
|
||||||
define(["loading", "libraryBrowser", "cardBuilder", "dom", "apphost", "imageLoader", "globalize", "layoutManager", "scrollStyles", "emby-itemscontainer"], function(loading, libraryBrowser, cardBuilder, dom, appHost, imageLoader, globalize, layoutManager) {
|
define(["loading", "libraryBrowser", "cardBuilder", "dom", "apphost", "imageLoader", "globalize", "layoutManager", "scrollStyles", "emby-itemscontainer"], function (loading, libraryBrowser, cardBuilder, dom, appHost, imageLoader, globalize, layoutManager) {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
function enableScrollX() {
|
function enableScrollX() {
|
||||||
return !layoutManager.desktop
|
return !layoutManager.desktop;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getThumbShape() {
|
function getThumbShape() {
|
||||||
return enableScrollX() ? "overflowBackdrop" : "backdrop"
|
if (enableScrollX()) {
|
||||||
|
return "overflowBackdrop";
|
||||||
|
}
|
||||||
|
|
||||||
|
return "backdrop";
|
||||||
}
|
}
|
||||||
|
|
||||||
function getPosterShape() {
|
function getPosterShape() {
|
||||||
return enableScrollX() ? "overflowPortrait" : "portrait"
|
if (enableScrollX()) {
|
||||||
|
return "overflowPortrait";
|
||||||
|
}
|
||||||
|
|
||||||
|
return "portrait";
|
||||||
}
|
}
|
||||||
|
|
||||||
function getSquareShape() {
|
function getSquareShape() {
|
||||||
return enableScrollX() ? "overflowSquare" : "square"
|
if (enableScrollX()) {
|
||||||
|
return "overflowSquare";
|
||||||
|
}
|
||||||
|
|
||||||
|
return "square";
|
||||||
}
|
}
|
||||||
|
|
||||||
function getSections() {
|
function getSections() {
|
||||||
|
@ -23,147 +35,208 @@ define(["loading", "libraryBrowser", "cardBuilder", "dom", "apphost", "imageLoad
|
||||||
types: "Movie",
|
types: "Movie",
|
||||||
id: "favoriteMovies",
|
id: "favoriteMovies",
|
||||||
shape: getPosterShape(),
|
shape: getPosterShape(),
|
||||||
showTitle: !1,
|
showTitle: false,
|
||||||
overlayPlayButton: !0
|
overlayPlayButton: true
|
||||||
}, {
|
}, {
|
||||||
name: "HeaderFavoriteShows",
|
name: "HeaderFavoriteShows",
|
||||||
types: "Series",
|
types: "Series",
|
||||||
id: "favoriteShows",
|
id: "favoriteShows",
|
||||||
shape: getPosterShape(),
|
shape: getPosterShape(),
|
||||||
showTitle: !1,
|
showTitle: false,
|
||||||
overlayPlayButton: !0
|
overlayPlayButton: true
|
||||||
}, {
|
}, {
|
||||||
name: "HeaderFavoriteEpisodes",
|
name: "HeaderFavoriteEpisodes",
|
||||||
types: "Episode",
|
types: "Episode",
|
||||||
id: "favoriteEpisode",
|
id: "favoriteEpisode",
|
||||||
shape: getThumbShape(),
|
shape: getThumbShape(),
|
||||||
preferThumb: !1,
|
preferThumb: false,
|
||||||
showTitle: !0,
|
showTitle: true,
|
||||||
showParentTitle: !0,
|
showParentTitle: true,
|
||||||
overlayPlayButton: !0,
|
overlayPlayButton: true,
|
||||||
overlayText: !1,
|
overlayText: false,
|
||||||
centerText: !0
|
centerText: true
|
||||||
}, {
|
}, {
|
||||||
name: "HeaderFavoriteVideos",
|
name: "HeaderFavoriteVideos",
|
||||||
types: "Video,MusicVideo",
|
types: "Video,MusicVideo",
|
||||||
id: "favoriteVideos",
|
id: "favoriteVideos",
|
||||||
shape: getThumbShape(),
|
shape: getThumbShape(),
|
||||||
preferThumb: !0,
|
preferThumb: true,
|
||||||
showTitle: !0,
|
showTitle: true,
|
||||||
overlayPlayButton: !0,
|
overlayPlayButton: true,
|
||||||
overlayText: !1,
|
overlayText: false,
|
||||||
centerText: !0
|
centerText: true
|
||||||
}, {
|
}, {
|
||||||
name: "HeaderFavoriteArtists",
|
name: "HeaderFavoriteArtists",
|
||||||
types: "MusicArtist",
|
types: "MusicArtist",
|
||||||
id: "favoriteArtists",
|
id: "favoriteArtists",
|
||||||
shape: getSquareShape(),
|
shape: getSquareShape(),
|
||||||
preferThumb: !1,
|
preferThumb: false,
|
||||||
showTitle: !0,
|
showTitle: true,
|
||||||
overlayText: !1,
|
overlayText: false,
|
||||||
showParentTitle: !1,
|
showParentTitle: false,
|
||||||
centerText: !0,
|
centerText: true,
|
||||||
overlayPlayButton: !0,
|
overlayPlayButton: true,
|
||||||
coverImage: !0
|
coverImage: true
|
||||||
}, {
|
}, {
|
||||||
name: "HeaderFavoriteAlbums",
|
name: "HeaderFavoriteAlbums",
|
||||||
types: "MusicAlbum",
|
types: "MusicAlbum",
|
||||||
id: "favoriteAlbums",
|
id: "favoriteAlbums",
|
||||||
shape: getSquareShape(),
|
shape: getSquareShape(),
|
||||||
preferThumb: !1,
|
preferThumb: false,
|
||||||
showTitle: !0,
|
showTitle: true,
|
||||||
overlayText: !1,
|
overlayText: false,
|
||||||
showParentTitle: !0,
|
showParentTitle: true,
|
||||||
centerText: !0,
|
centerText: true,
|
||||||
overlayPlayButton: !0,
|
overlayPlayButton: true,
|
||||||
coverImage: !0
|
coverImage: true
|
||||||
}, {
|
}, {
|
||||||
name: "HeaderFavoriteSongs",
|
name: "HeaderFavoriteSongs",
|
||||||
types: "Audio",
|
types: "Audio",
|
||||||
id: "favoriteSongs",
|
id: "favoriteSongs",
|
||||||
shape: getSquareShape(),
|
shape: getSquareShape(),
|
||||||
preferThumb: !1,
|
preferThumb: false,
|
||||||
showTitle: !0,
|
showTitle: true,
|
||||||
overlayText: !1,
|
overlayText: false,
|
||||||
showParentTitle: !0,
|
showParentTitle: true,
|
||||||
centerText: !0,
|
centerText: true,
|
||||||
overlayMoreButton: !0,
|
overlayMoreButton: true,
|
||||||
action: "instantmix",
|
action: "instantmix",
|
||||||
coverImage: !0
|
coverImage: true
|
||||||
}]
|
}];
|
||||||
}
|
}
|
||||||
|
|
||||||
function loadSection(elem, userId, topParentId, section, isSingleSection) {
|
function loadSection(elem, userId, topParentId, section, isSingleSection) {
|
||||||
var screenWidth = dom.getWindowSize().innerWidth,
|
var screenWidth = dom.getWindowSize().innerWidth;
|
||||||
options = {
|
var options = {
|
||||||
SortBy: "SortName",
|
SortBy: "SortName",
|
||||||
SortOrder: "Ascending",
|
SortOrder: "Ascending",
|
||||||
Filters: "IsFavorite",
|
Filters: "IsFavorite",
|
||||||
Recursive: !0,
|
Recursive: true,
|
||||||
Fields: "PrimaryImageAspectRatio,BasicSyncInfo",
|
Fields: "PrimaryImageAspectRatio,BasicSyncInfo",
|
||||||
CollapseBoxSetItems: !1,
|
CollapseBoxSetItems: false,
|
||||||
ExcludeLocationTypes: "Virtual",
|
ExcludeLocationTypes: "Virtual",
|
||||||
EnableTotalRecordCount: !1
|
EnableTotalRecordCount: false
|
||||||
};
|
};
|
||||||
topParentId && (options.ParentId = topParentId), isSingleSection || (options.Limit = screenWidth >= 1920 ? 10 : screenWidth >= 1440 ? 8 : 6, enableScrollX() && (options.Limit = 20));
|
|
||||||
|
if (topParentId) {
|
||||||
|
options.ParentId = topParentId;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!isSingleSection) {
|
||||||
|
options.Limit = screenWidth >= 1920 ? 10 : screenWidth >= 1440 ? 8 : 6;
|
||||||
|
|
||||||
|
if (enableScrollX()) {
|
||||||
|
options.Limit = 20;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
var promise;
|
var promise;
|
||||||
return "MusicArtist" === section.types ? promise = ApiClient.getArtists(userId, options) : (options.IncludeItemTypes = section.types, promise = ApiClient.getItems(userId, options)), promise.then(function(result) {
|
|
||||||
|
if ("MusicArtist" === section.types) {
|
||||||
|
promise = ApiClient.getArtists(userId, options);
|
||||||
|
} else {
|
||||||
|
options.IncludeItemTypes = section.types;
|
||||||
|
promise = ApiClient.getItems(userId, options);
|
||||||
|
}
|
||||||
|
|
||||||
|
return promise.then(function (result) {
|
||||||
var html = "";
|
var html = "";
|
||||||
|
|
||||||
if (result.Items.length) {
|
if (result.Items.length) {
|
||||||
if (html += '<div class="sectionTitleContainer sectionTitleContainer-cards padded-left">', !layoutManager.tv && options.Limit && result.Items.length >= options.Limit) {
|
if (html += '<div class="sectionTitleContainer sectionTitleContainer-cards padded-left">', !layoutManager.tv && options.Limit && result.Items.length >= options.Limit) {
|
||||||
html += '<a is="emby-linkbutton" href="' + ("list.html?serverId=" + ApiClient.serverId() + "&type=" + section.types + "&IsFavorite=true") + '" class="more button-flat button-flat-mini sectionTitleTextButton">', html += '<h2 class="sectionTitle sectionTitle-cards">', html += globalize.translate(section.name), html += "</h2>", html += '<i class="md-icon"></i>', html += "</a>"
|
html += '<a is="emby-linkbutton" href="' + ("list.html?serverId=" + ApiClient.serverId() + "&type=" + section.types + "&IsFavorite=true") + '" class="more button-flat button-flat-mini sectionTitleTextButton">';
|
||||||
} else html += '<h2 class="sectionTitle sectionTitle-cards">' + globalize.translate(section.name) + "</h2>";
|
html += '<h2 class="sectionTitle sectionTitle-cards">';
|
||||||
|
html += globalize.translate(section.name);
|
||||||
|
html += "</h2>";
|
||||||
|
html += '<i class="md-icon"></i>';
|
||||||
|
html += "</a>";
|
||||||
|
} else {
|
||||||
|
html += '<h2 class="sectionTitle sectionTitle-cards">' + globalize.translate(section.name) + "</h2>";
|
||||||
|
}
|
||||||
|
|
||||||
if (html += "</div>", enableScrollX()) {
|
if (html += "</div>", enableScrollX()) {
|
||||||
var scrollXClass = "scrollX hiddenScrollX";
|
var scrollXClass = "scrollX hiddenScrollX";
|
||||||
layoutManager.tv && (scrollXClass += " smoothScrollX"), html += '<div is="emby-itemscontainer" class="itemsContainer ' + scrollXClass + ' padded-left padded-right">'
|
|
||||||
} else html += '<div is="emby-itemscontainer" class="itemsContainer vertical-wrap padded-left padded-right">';
|
if (layoutManager.tv) {
|
||||||
var supportsImageAnalysis = appHost.supports("imageanalysis"),
|
scrollXClass += " smoothScrollX";
|
||||||
cardLayout = (appHost.preferVisualCards || supportsImageAnalysis) && section.autoCardLayout && section.showTitle;
|
}
|
||||||
cardLayout = !1, html += cardBuilder.getCardsHtml(result.Items, {
|
|
||||||
|
html += '<div is="emby-itemscontainer" class="itemsContainer ' + scrollXClass + ' padded-left padded-right">';
|
||||||
|
} else {
|
||||||
|
html += '<div is="emby-itemscontainer" class="itemsContainer vertical-wrap padded-left padded-right">';
|
||||||
|
}
|
||||||
|
|
||||||
|
var supportsImageAnalysis = appHost.supports("imageanalysis");
|
||||||
|
var cardLayout = (appHost.preferVisualCards || supportsImageAnalysis) && section.autoCardLayout && section.showTitle;
|
||||||
|
cardLayout = false;
|
||||||
|
html += cardBuilder.getCardsHtml(result.Items, {
|
||||||
preferThumb: section.preferThumb,
|
preferThumb: section.preferThumb,
|
||||||
shape: section.shape,
|
shape: section.shape,
|
||||||
centerText: section.centerText && !cardLayout,
|
centerText: section.centerText && !cardLayout,
|
||||||
overlayText: !1 !== section.overlayText,
|
overlayText: false !== section.overlayText,
|
||||||
showTitle: section.showTitle,
|
showTitle: section.showTitle,
|
||||||
showParentTitle: section.showParentTitle,
|
showParentTitle: section.showParentTitle,
|
||||||
scalable: !0,
|
scalable: true,
|
||||||
coverImage: section.coverImage,
|
coverImage: section.coverImage,
|
||||||
overlayPlayButton: section.overlayPlayButton,
|
overlayPlayButton: section.overlayPlayButton,
|
||||||
overlayMoreButton: section.overlayMoreButton && !cardLayout,
|
overlayMoreButton: section.overlayMoreButton && !cardLayout,
|
||||||
action: section.action,
|
action: section.action,
|
||||||
allowBottomPadding: !enableScrollX(),
|
allowBottomPadding: !enableScrollX(),
|
||||||
cardLayout: cardLayout
|
cardLayout: cardLayout
|
||||||
}), html += "</div>"
|
});
|
||||||
|
html += "</div>";
|
||||||
}
|
}
|
||||||
elem.innerHTML = html, imageLoader.lazyChildren(elem)
|
|
||||||
})
|
elem.innerHTML = html;
|
||||||
|
imageLoader.lazyChildren(elem);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function loadSections(page, userId, topParentId, types) {
|
function loadSections(page, userId, topParentId, types) {
|
||||||
loading.show();
|
loading.show();
|
||||||
var sections = getSections(),
|
var sections = getSections();
|
||||||
sectionid = getParameterByName("sectionid");
|
var sectionid = getParameterByName("sectionid");
|
||||||
sectionid && (sections = sections.filter(function(s) {
|
|
||||||
return s.id === sectionid
|
if (sectionid) {
|
||||||
})), types && (sections = sections.filter(function(s) {
|
sections = sections.filter(function (s) {
|
||||||
return -1 !== types.indexOf(s.id)
|
return s.id === sectionid;
|
||||||
}));
|
});
|
||||||
var i, length, elem = page.querySelector(".favoriteSections");
|
}
|
||||||
|
|
||||||
|
if (types) {
|
||||||
|
sections = sections.filter(function (s) {
|
||||||
|
return -1 !== types.indexOf(s.id);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
var i;
|
||||||
|
var length;
|
||||||
|
var elem = page.querySelector(".favoriteSections");
|
||||||
|
|
||||||
if (!elem.innerHTML) {
|
if (!elem.innerHTML) {
|
||||||
var html = "";
|
var html = "";
|
||||||
for (i = 0, length = sections.length; i < length; i++) html += '<div class="verticalSection section' + sections[i].id + '"></div>';
|
|
||||||
elem.innerHTML = html
|
for (i = 0, length = sections.length; i < length; i++) {
|
||||||
|
html += '<div class="verticalSection section' + sections[i].id + '"></div>';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
elem.innerHTML = html;
|
||||||
|
}
|
||||||
|
|
||||||
var promises = [];
|
var promises = [];
|
||||||
|
|
||||||
for (i = 0, length = sections.length; i < length; i++) {
|
for (i = 0, length = sections.length; i < length; i++) {
|
||||||
var section = sections[i];
|
var section = sections[i];
|
||||||
elem = page.querySelector(".section" + section.id), promises.push(loadSection(elem, userId, topParentId, section, 1 === sections.length))
|
elem = page.querySelector(".section" + section.id);
|
||||||
|
promises.push(loadSection(elem, userId, topParentId, section, 1 === sections.length));
|
||||||
}
|
}
|
||||||
Promise.all(promises).then(function() {
|
|
||||||
loading.hide()
|
Promise.all(promises).then(function () {
|
||||||
})
|
loading.hide();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
render: loadSections
|
render: loadSections
|
||||||
}
|
};
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue