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

128 lines
3.5 KiB
JavaScript
Raw Normal View History

2013-04-10 10:36:34 -07:00
(function ($, document, LibraryBrowser) {
2013-04-04 21:13:43 -07:00
2013-04-16 20:15:18 -07:00
var currentItem;
2013-04-10 10:36:34 -07:00
function reload(page) {
2013-04-04 21:13:43 -07:00
2013-04-04 21:40:42 -07:00
var id = getParameterByName('id');
2013-04-04 21:13:43 -07:00
2013-04-04 21:40:42 -07:00
Dashboard.showLoadingMsg();
2013-04-04 21:13:43 -07:00
2013-04-10 10:36:34 -07:00
ApiClient.getItem(Dashboard.getCurrentUserId(), id).done(function (item) {
2013-04-04 21:13:43 -07:00
2013-04-16 20:15:18 -07:00
currentItem = item;
2013-04-10 10:36:34 -07:00
var name = item.Name;
2013-04-04 21:13:43 -07:00
2013-04-10 10:36:34 -07:00
$('#itemImage', page).html(LibraryBrowser.getDetailImageHtml(item));
2013-04-04 21:13:43 -07:00
2013-04-10 10:36:34 -07:00
Dashboard.setPageTitle(name);
2013-04-04 21:13:43 -07:00
2013-04-10 10:36:34 -07:00
$('#itemName', page).html(name);
2013-04-04 21:13:43 -07:00
2013-04-10 10:36:34 -07:00
renderDetails(page, item);
2013-04-04 21:13:43 -07:00
2013-04-16 20:15:18 -07:00
if (LibraryBrowser.shouldDisplayGallery(item)) {
$('#galleryCollapsible', page).show();
} else {
$('#galleryCollapsible', page).hide();
}
2013-04-10 10:36:34 -07:00
Dashboard.hideLoadingMsg();
});
}
2013-04-04 21:13:43 -07:00
2013-04-10 10:36:34 -07:00
function renderDetails(page, item) {
2013-04-04 21:13:43 -07:00
2013-04-04 21:40:42 -07:00
if (item.Taglines && item.Taglines.length) {
$('#itemTagline', page).html(item.Taglines[0]).show();
} else {
$('#itemTagline', page).hide();
}
2013-04-04 21:13:43 -07:00
2013-04-04 21:40:42 -07:00
if (item.Overview || item.OverviewHtml) {
var overview = item.OverviewHtml || item.Overview;
2013-04-04 21:13:43 -07:00
2013-04-04 21:40:42 -07:00
$('#itemOverview', page).html(overview).show();
$('#itemOverview a').each(function () {
$(this).attr("target", "_blank");
});
} else {
$('#itemOverview', page).hide();
}
2013-04-04 21:13:43 -07:00
2013-04-04 21:40:42 -07:00
if (item.CommunityRating) {
2013-04-10 06:53:44 -07:00
$('#itemCommunityRating', page).html(LibraryBrowser.getStarRatingHtml(item)).show().attr('title', item.CommunityRating);
2013-04-04 21:40:42 -07:00
} else {
$('#itemCommunityRating', page).hide();
}
2013-04-04 21:13:43 -07:00
2013-04-10 10:36:34 -07:00
$('#itemMiscInfo', page).html(LibraryBrowser.getMiscInfoHtml(item));
2013-04-04 21:13:43 -07:00
LibraryBrowser.renderGenres($('#itemGenres', page), item);
LibraryBrowser.renderStudios($('#itemStudios', page), item);
2013-04-10 10:36:34 -07:00
renderUserDataIcons(page, item);
2013-04-14 08:14:10 -07:00
LibraryBrowser.renderLinks($('#itemLinks', page), item);
2013-04-10 10:36:34 -07:00
}
2013-04-04 21:13:43 -07:00
2013-04-10 10:36:34 -07:00
function renderUserDataIcons(page, item) {
$('#itemRatings', page).html(LibraryBrowser.getUserDataIconsHtml(item));
2013-04-04 21:40:42 -07:00
}
2013-04-04 21:13:43 -07:00
2013-04-15 16:08:03 -07:00
function renderMovies(page) {
ApiClient.getItems(Dashboard.getCurrentUserId(), {
ParentId: getParameterByName('id'),
SortBy: "SortName",
Fields: "PrimaryImageAspectRatio,ItemCounts,DisplayMediaType,DateCreated,UserData"
2013-04-15 16:08:03 -07:00
}).done(function (result) {
var html = LibraryBrowser.getPosterDetailViewHtml({
items: result.Items,
useAverageAspectRatio: true
});
$('#moviesContent', page).html(html);
});
}
2013-04-16 20:15:18 -07:00
function renderGallery(page, item) {
var html = LibraryBrowser.getGalleryHtml(item);
$('#galleryContent', page).html(html).trigger('create');
}
2013-04-10 10:36:34 -07:00
$(document).on('pageshow', "#boxsetPage", function () {
2013-04-15 16:08:03 -07:00
var page = this;
reload(page);
$('#moviesCollapsible', page).on('expand.lazyload', function () {
renderMovies(page);
$(this).off('expand.lazyload');
});
2013-04-16 20:15:18 -07:00
$('#galleryCollapsible', page).on('expand.lazyload', function () {
renderGallery(page, currentItem);
$(this).off('expand.lazyload');
});
2013-04-15 16:08:03 -07:00
}).on('pagehide', "#boxsetPage", function () {
var page = this;
$('#moviesCollapsible', page).off('expand.lazyload');
2013-04-16 20:15:18 -07:00
$('#galleryCollapsible', page).off('expand.lazyload');
2013-04-10 10:36:34 -07:00
});
2013-04-04 21:13:43 -07:00
2013-04-10 10:36:34 -07:00
})(jQuery, document, LibraryBrowser);