2013-04-15 16:32:41 -07:00
|
|
|
(function ($, document, LibraryBrowser, window) {
|
|
|
|
|
|
|
|
var currentItem;
|
2013-04-09 21:54:16 -07:00
|
|
|
|
2013-04-10 06:53:44 -07:00
|
|
|
function reload(page) {
|
2013-04-09 21:54:16 -07:00
|
|
|
|
2013-04-10 06:53:44 -07:00
|
|
|
var id = getParameterByName('id');
|
2013-04-09 21:54:16 -07:00
|
|
|
|
2013-04-10 06:53:44 -07:00
|
|
|
Dashboard.showLoadingMsg();
|
2013-04-09 21:54:16 -07:00
|
|
|
|
2013-04-10 06:53:44 -07:00
|
|
|
ApiClient.getItem(Dashboard.getCurrentUserId(), id).done(function (item) {
|
2013-04-09 21:54:16 -07:00
|
|
|
|
2013-04-15 16:32:41 -07:00
|
|
|
currentItem = item;
|
|
|
|
|
|
|
|
var name = item.Name;
|
2013-04-09 21:54:16 -07:00
|
|
|
|
2013-04-10 10:11:23 -07:00
|
|
|
$('#itemImage', page).html(LibraryBrowser.getDetailImageHtml(item));
|
2013-04-09 21:54:16 -07:00
|
|
|
|
2013-04-10 10:11:23 -07:00
|
|
|
Dashboard.setPageTitle(name);
|
2013-04-09 21:54:16 -07:00
|
|
|
|
2013-04-10 06:53:44 -07:00
|
|
|
$('#itemName', page).html(name);
|
2013-04-09 21:54:16 -07:00
|
|
|
|
2013-04-15 16:32:41 -07:00
|
|
|
setInitialCollapsibleState(page, item);
|
2013-04-16 20:10:05 -07:00
|
|
|
renderDetails(page, item);
|
|
|
|
|
|
|
|
if (LibraryBrowser.shouldDisplayGallery(item)) {
|
|
|
|
$('#galleryCollapsible', page).show();
|
|
|
|
} else {
|
|
|
|
$('#galleryCollapsible', page).hide();
|
|
|
|
}
|
2013-04-09 21:54:16 -07:00
|
|
|
|
2013-04-10 06:53:44 -07:00
|
|
|
Dashboard.hideLoadingMsg();
|
|
|
|
});
|
|
|
|
}
|
2013-04-09 21:54:16 -07:00
|
|
|
|
2013-04-15 16:32:41 -07:00
|
|
|
function setInitialCollapsibleState(page, item) {
|
|
|
|
|
|
|
|
if (!item.People || !item.People.length) {
|
|
|
|
$('#castCollapsible', page).hide();
|
|
|
|
} else {
|
|
|
|
$('#castCollapsible', page).show();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-04-10 06:53:44 -07:00
|
|
|
function renderDetails(page, item) {
|
2013-04-10 10:11:23 -07:00
|
|
|
|
2013-04-10 06:53:44 -07:00
|
|
|
if (item.Taglines && item.Taglines.length) {
|
|
|
|
$('#itemTagline', page).html(item.Taglines[0]).show();
|
|
|
|
} else {
|
|
|
|
$('#itemTagline', page).hide();
|
|
|
|
}
|
2013-04-09 21:54:16 -07:00
|
|
|
|
2013-04-10 06:53:44 -07:00
|
|
|
if (item.Overview || item.OverviewHtml) {
|
|
|
|
var overview = item.OverviewHtml || item.Overview;
|
2013-04-09 21:54:16 -07:00
|
|
|
|
2013-04-10 06:53:44 -07:00
|
|
|
$('#itemOverview', page).html(overview).show();
|
|
|
|
$('#itemOverview a').each(function () {
|
|
|
|
$(this).attr("target", "_blank");
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
$('#itemOverview', page).hide();
|
|
|
|
}
|
2013-04-09 21:54:16 -07:00
|
|
|
|
2013-04-10 06:53:44 -07:00
|
|
|
if (item.CommunityRating) {
|
|
|
|
$('#itemCommunityRating', page).html(LibraryBrowser.getStarRatingHtml(item)).show().attr('title', item.CommunityRating);
|
|
|
|
} else {
|
|
|
|
$('#itemCommunityRating', page).hide();
|
|
|
|
}
|
2013-04-09 21:54:16 -07:00
|
|
|
|
2013-04-10 10:11:23 -07:00
|
|
|
$('#itemMiscInfo', page).html(LibraryBrowser.getMiscInfoHtml(item));
|
2013-04-09 21:54:16 -07:00
|
|
|
|
2013-04-10 12:25:34 -07:00
|
|
|
LibraryBrowser.renderGenres($('#itemGenres', page), item);
|
|
|
|
LibraryBrowser.renderStudios($('#itemStudios', page), item);
|
2013-04-10 10:11:23 -07:00
|
|
|
renderUserDataIcons(page, item);
|
2013-04-14 08:14:10 -07:00
|
|
|
LibraryBrowser.renderLinks($('#itemLinks', page), item);
|
2013-04-10 06:53:44 -07:00
|
|
|
}
|
|
|
|
|
2013-04-10 10:11:23 -07:00
|
|
|
function renderUserDataIcons(page, item) {
|
|
|
|
$('#itemRatings', page).html(LibraryBrowser.getUserDataIconsHtml(item));
|
2013-04-10 06:53:44 -07:00
|
|
|
}
|
2013-04-09 21:54:16 -07:00
|
|
|
|
2013-04-15 16:44:03 -07:00
|
|
|
function renderSeasons(page) {
|
2013-04-15 16:00:17 -07:00
|
|
|
|
|
|
|
ApiClient.getItems(Dashboard.getCurrentUserId(), {
|
|
|
|
|
|
|
|
ParentId: getParameterByName('id'),
|
|
|
|
SortBy: "SortName"
|
|
|
|
|
|
|
|
}).done(function(result) {
|
|
|
|
|
|
|
|
var html = LibraryBrowser.getPosterDetailViewHtml({
|
|
|
|
items: result.Items,
|
2013-04-16 20:37:14 -07:00
|
|
|
useAverageAspectRatio: true,
|
|
|
|
Fields: "PrimaryImageAspectRatio,ItemCounts,DisplayMediaType,DateCreated,UserData"
|
2013-04-15 16:00:17 -07:00
|
|
|
});
|
|
|
|
|
|
|
|
$('#seasonsContent', page).html(html);
|
|
|
|
});
|
|
|
|
}
|
2013-04-09 21:54:16 -07:00
|
|
|
|
2013-04-15 16:32:41 -07:00
|
|
|
function renderGallery(page, item) {
|
|
|
|
|
2013-04-15 18:15:34 -07:00
|
|
|
var html = LibraryBrowser.getGalleryHtml(item);
|
2013-04-15 16:32:41 -07:00
|
|
|
|
|
|
|
$('#galleryContent', page).html(html).trigger('create');
|
|
|
|
}
|
|
|
|
|
|
|
|
function renderCast(page, item) {
|
|
|
|
var html = '';
|
|
|
|
|
|
|
|
var casts = item.People || [];
|
|
|
|
|
|
|
|
for (var i = 0, length = casts.length; i < length; i++) {
|
|
|
|
|
|
|
|
var cast = casts[i];
|
|
|
|
|
|
|
|
html += LibraryBrowser.createCastImage(cast);
|
|
|
|
}
|
|
|
|
|
|
|
|
$('#castContent', page).html(html);
|
|
|
|
}
|
|
|
|
|
|
|
|
$(document).on('pageinit', "#tvSeriesPage", function () {
|
|
|
|
|
|
|
|
var page = this;
|
|
|
|
|
|
|
|
}).on('pageshow', "#tvSeriesPage", function () {
|
|
|
|
|
|
|
|
var page = this;
|
|
|
|
|
|
|
|
reload(page);
|
|
|
|
|
2013-04-15 16:44:03 -07:00
|
|
|
$('#seasonsCollapsible', page).on('expand.lazyload', function () {
|
|
|
|
|
|
|
|
renderSeasons(page);
|
|
|
|
|
|
|
|
$(this).off('expand.lazyload');
|
|
|
|
});
|
|
|
|
|
2013-04-15 16:32:41 -07:00
|
|
|
$('#castCollapsible', page).on('expand.lazyload', function () {
|
|
|
|
renderCast(page, currentItem);
|
|
|
|
|
|
|
|
$(this).off('expand.lazyload');
|
|
|
|
});
|
|
|
|
|
|
|
|
$('#galleryCollapsible', page).on('expand.lazyload', function () {
|
|
|
|
|
|
|
|
renderGallery(page, currentItem);
|
|
|
|
|
|
|
|
$(this).off('expand.lazyload');
|
|
|
|
});
|
|
|
|
|
|
|
|
}).on('pagehide', "#tvSeriesPage", function () {
|
|
|
|
|
|
|
|
currentItem = null;
|
|
|
|
var page = this;
|
|
|
|
|
2013-04-15 16:44:03 -07:00
|
|
|
$('#seasonsCollapsible', page).off('expand.lazyload');
|
2013-04-15 16:32:41 -07:00
|
|
|
$('#castCollapsible', page).off('expand.lazyload');
|
|
|
|
$('#galleryCollapsible', page).off('expand.lazyload');
|
|
|
|
});
|
|
|
|
|
|
|
|
function tvSeriesPage() {
|
|
|
|
|
|
|
|
var self = this;
|
|
|
|
|
|
|
|
}
|
2013-04-09 21:54:16 -07:00
|
|
|
|
2013-04-15 16:32:41 -07:00
|
|
|
window.TvSeriesPage = new tvSeriesPage();
|
2013-04-09 21:54:16 -07:00
|
|
|
|
2013-04-15 16:44:03 -07:00
|
|
|
})(jQuery, document, LibraryBrowser, window);
|