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

1464 lines
44 KiB
JavaScript
Raw Normal View History

2013-04-10 14:14:25 -07:00
(function ($, document, LibraryBrowser, window) {
2013-02-20 18:33:05 -07:00
2013-04-10 14:14:25 -07:00
var currentItem;
2013-02-20 18:33:05 -07:00
2013-04-10 14:14:25 -07:00
function reload(page) {
2013-03-06 16:28:43 -07:00
2013-02-20 18:33:05 -07:00
var id = getParameterByName('id');
Dashboard.showLoadingMsg();
2013-04-10 14:14:25 -07:00
ApiClient.getItem(Dashboard.getCurrentUserId(), id).done(function (item) {
2013-02-20 18:33:05 -07:00
2013-04-10 14:14:25 -07:00
currentItem = item;
2013-02-20 18:33:05 -07:00
2013-04-22 07:44:11 -07:00
renderHeader(page, item);
LibraryBrowser.renderName(item, $('.itemName', page));
LibraryBrowser.renderParentName(item, $('.parentName', page));
2013-04-10 14:14:25 -07:00
2013-04-23 07:46:27 -07:00
var context = getContext(item);
Dashboard.getCurrentUser().done(function (user) {
2013-11-27 12:04:19 -07:00
var imageHref = user.Configuration.IsAdministrator ? "edititemimages.html?id=" + item.Id : "";
2013-11-28 11:27:29 -07:00
2013-11-27 12:04:19 -07:00
$('#itemImage', page).html(LibraryBrowser.getDetailImageHtml(item, imageHref));
setInitialCollapsibleState(page, item, context, user);
renderDetails(page, item, context);
LibraryBrowser.renderDetailPageBackdrop(page, item);
$("#remoteButtonContainer", page).show();
if (user.Configuration.IsAdministrator) {
$('#editButtonContainer', page).show();
} else {
$('#editButtonContainer', page).hide();
}
if (MediaPlayer.canPlay(item, user)) {
var url = MediaPlayer.getPlayUrl(item);
if (url) {
$('#playExternalButtonContainer', page).show();
$('#playButtonContainer', page).hide();
} else {
$('#playButtonContainer', page).show();
$('#playExternalButtonContainer', page).hide();
}
$('#btnPlayExternal', page).attr('href', url || '#');
} else {
$('#playButtonContainer', page).hide();
$('#playExternalButtonContainer', page).hide();
}
2014-03-19 10:44:55 -07:00
if (item.LocalTrailerCount && item.PlayAccess == 'Full') {
$('#trailerButtonContainer', page).show();
} else {
$('#trailerButtonContainer', page).hide();
}
2014-03-19 10:44:55 -07:00
if (!item.LocalTrailerCount && item.RemoteTrailers.length && item.PlayAccess == 'Full') {
$('#externalTrailerButtonContainer', page).show();
$('#btnPlayExternalTrailer', page).attr('href', item.RemoteTrailers[0].Url);
} else {
$('#externalTrailerButtonContainer', page).hide();
$('#btnPlayExternalTrailer', page).attr('href', '#');
}
2014-03-20 20:31:40 -07:00
if (user.Configuration.IsAdministrator && item.MediaVersions && item.MediaVersions.length > 1) {
$('.splitVersionContainer', page).show();
2014-03-19 10:44:55 -07:00
} else {
2014-03-20 20:31:40 -07:00
$('.splitVersionContainer', page).hide();
2014-03-19 10:44:55 -07:00
}
});
2013-02-20 18:33:05 -07:00
2013-07-29 08:05:09 -07:00
if (item.LocationType == "Offline") {
2013-07-29 08:05:09 -07:00
$('#offlineIndicator', page).show();
}
else {
2013-07-29 08:05:09 -07:00
$('#offlineIndicator', page).hide();
}
var isMissingEpisode = false;
if (item.LocationType == "Virtual" && item.Type == "Episode") {
try {
if (item.PremiereDate && (new Date().getTime() >= parseISO8601Date(item.PremiereDate, { toLocal: true }).getTime())) {
isMissingEpisode = true;
}
} catch (err) {
}
}
if (isMissingEpisode) {
$('#missingIndicator', page).show();
}
else {
$('#missingIndicator', page).hide();
}
2013-04-30 20:28:26 -07:00
$(".autoNumeric").autoNumeric('init');
setPeopleHeader(page, item);
2013-05-10 05:18:07 -07:00
if (ApiClient.isWebSocketOpen()) {
2013-05-21 20:59:55 -07:00
ApiClient.sendWebSocketMessage("Context", [item.Type, item.Id, item.Name, context].join('|'));
2013-05-10 05:18:07 -07:00
}
2013-04-10 14:14:25 -07:00
Dashboard.hideLoadingMsg();
});
$('#btnEdit', page).attr('href', "edititemmetadata.html?id=" + id);
2013-04-10 14:14:25 -07:00
}
2013-04-24 13:28:42 -07:00
function setPeopleHeader(page, item) {
if (item.Type == "Audio" || item.Type == "MusicAlbum" || item.MediaType == "Book" || item.MediaType == "Photo") {
$('#peopleHeader', page).html('People');
} else {
$('#peopleHeader', page).html('Cast & Crew');
}
}
2013-04-23 07:46:27 -07:00
function getContext(item) {
// should return either movies, tv, music or games
2013-04-24 13:28:42 -07:00
2013-04-23 07:46:27 -07:00
if (item.Type == "Episode" || item.Type == "Series" || item.Type == "Season") {
return "tv";
}
if (item.Type == "Movie" || item.Type == "Trailer") {
2013-04-23 07:46:27 -07:00
return "movies";
}
2013-11-21 13:48:26 -07:00
if (item.Type == "Audio" || item.Type == "MusicAlbum" || item.Type == "MusicArtist" || item.Type == "MusicVideo") {
2013-04-23 07:46:27 -07:00
return "music";
}
if (item.MediaType == "Game") {
return "games";
}
if (item.Type == "BoxSet") {
return "boxsets";
}
2013-04-23 07:46:27 -07:00
return "";
}
2013-04-22 07:44:11 -07:00
function renderHeader(page, item) {
2013-04-28 11:47:19 -07:00
$('.itemTabs', page).hide();
2013-04-22 08:10:54 -07:00
if (item.Type == "MusicAlbum") {
$('#albumTabs', page).show();
}
if (item.Type == "MusicVideo") {
$('#musicVideoTabs', page).show();
}
2013-04-22 07:44:11 -07:00
if (item.Type == "Audio") {
$('#songTabs', page).show();
}
if (item.Type == "Movie") {
$('#movieTabs', page).show();
}
2013-04-24 13:28:42 -07:00
if (item.MediaType == "Game") {
$('#gameTabs', page).show();
2013-04-28 11:47:19 -07:00
}
2013-09-21 14:00:04 -07:00
if (item.Type == "GameSystem") {
2013-04-28 11:47:19 -07:00
$('#gameSystemTabs', page).show();
2013-04-24 13:28:42 -07:00
}
2013-04-22 07:44:11 -07:00
if (item.Type == "Trailer") {
$('#trailerTabs', page).show();
}
2013-04-28 11:47:19 -07:00
2013-04-22 07:44:11 -07:00
if (item.Type == "Episode" || item.Type == "Season" || item.Type == "Series") {
$('#tvShowsTabs', page).show();
}
}
function setInitialCollapsibleState(page, item, context, user) {
2013-04-14 08:14:10 -07:00
2014-03-08 11:17:05 -07:00
$('.collectionItems', page).empty();
if (item.IsFolder) {
2014-03-08 11:17:05 -07:00
if (item.Type == "BoxSet") {
$('#childrenCollapsible', page).addClass('hide');
} else {
$('#childrenCollapsible', page).removeClass('hide');
}
renderChildren(page, item, user);
2013-04-22 20:56:11 -07:00
}
else {
2013-05-18 15:48:19 -07:00
$('#childrenCollapsible', page).addClass('hide');
2013-04-22 07:44:11 -07:00
}
2014-03-20 20:31:40 -07:00
if (item.MediaVersions && item.MediaVersions.length) {
renderMediaVersions(page, item);
2013-03-26 16:57:18 -07:00
}
2014-03-20 20:31:40 -07:00
var primaryVersion = (item.MediaVersions || []).filter(function (v) {
return v.IsPrimaryVersion;
})[0];
var chapters = primaryVersion ? (primaryVersion.Chapters || []) : [];
if (!chapters.length) {
2013-03-26 14:32:01 -07:00
$('#scenesCollapsible', page).hide();
} else {
2013-03-26 15:53:06 -07:00
$('#scenesCollapsible', page).show();
renderScenes(page, item, user, 4);
}
2014-03-19 10:44:55 -07:00
2013-09-05 05:48:14 -07:00
if (!item.SpecialFeatureCount || item.SpecialFeatureCount == 0 || item.Type == "Series") {
2013-05-18 15:48:19 -07:00
$('#specialsCollapsible', page).addClass('hide');
2013-03-26 14:32:01 -07:00
} else {
2013-05-18 15:48:19 -07:00
$('#specialsCollapsible', page).removeClass('hide');
renderSpecials(page, item, user, 6);
}
2013-03-26 22:20:46 -07:00
if (!item.People || !item.People.length) {
$('#castCollapsible', page).hide();
} else {
$('#castCollapsible', page).show();
2014-01-16 15:49:31 -07:00
renderCast(page, item, context, 6);
2013-03-26 22:20:46 -07:00
}
2013-04-24 09:03:10 -07:00
if (!item.PartCount || item.PartCount < 2) {
$('#additionalPartsCollapsible', page).addClass('hide');
} else {
$('#additionalPartsCollapsible', page).removeClass('hide');
renderAdditionalParts(page, item, user);
}
if (!item.AlternateVersionCount) {
$('#alternateVersionsCollapsible', page).addClass('hide');
} else {
$('#alternateVersionsCollapsible', page).removeClass('hide');
renderAlternateVersions(page, item, user);
}
2013-04-24 09:03:10 -07:00
$('#themeSongsCollapsible', page).hide();
$('#themeVideosCollapsible', page).hide();
2013-04-24 09:03:10 -07:00
2013-07-16 09:03:28 -07:00
if (!item.SoundtrackIds || !item.SoundtrackIds.length) {
$('#soundtracksCollapsible', page).hide();
} else {
$('#soundtracksCollapsible', page).show();
renderSoundtracks(page, item);
}
2013-07-29 12:12:21 -07:00
if (item.Type == "MusicAlbum") {
renderMusicVideos(page, item, user);
2013-07-29 12:12:21 -07:00
} else {
$('#musicVideosCollapsible', page).hide();
2013-07-29 12:12:21 -07:00
}
renderThemeSongs(page, item, user);
renderThemeVideos(page, item, user);
2013-05-11 23:05:51 -07:00
renderCriticReviews(page, item, 1);
2013-04-10 14:14:25 -07:00
}
2013-04-23 07:46:27 -07:00
function renderDetails(page, item, context) {
2013-02-20 18:33:05 -07:00
renderSimilarItems(page, item);
renderSiblingLinks(page, item);
2013-02-20 18:33:05 -07:00
if (item.Taglines && item.Taglines.length) {
$('#itemTagline', page).html(item.Taglines[0]).show();
} else {
$('#itemTagline', page).hide();
}
LibraryBrowser.renderOverview($('.itemOverview', page), item);
2013-02-20 18:33:05 -07:00
2014-01-17 22:55:21 -07:00
$('.itemCommunityRating', page).html(LibraryBrowser.getRatingHtml(item));
2013-02-20 18:33:05 -07:00
if (item.Type != "Episode" && item.Type != "Movie" && item.Type != "Series") {
2013-05-04 12:53:13 -07:00
var premiereDateElem = $('#itemPremiereDate', page).show();
LibraryBrowser.renderPremiereDate(premiereDateElem, item);
} else {
$('#itemPremiereDate', page).hide();
}
2013-04-12 08:25:00 -07:00
LibraryBrowser.renderBudget($('#itemBudget', page), item);
2013-04-18 07:05:38 -07:00
LibraryBrowser.renderRevenue($('#itemRevenue', page), item);
2014-01-18 11:10:21 -07:00
LibraryBrowser.renderAwardSummary($('#awardSummary', page), item);
2013-04-12 08:25:00 -07:00
$('.itemMiscInfo', page).html(LibraryBrowser.getMiscInfoHtml(item));
2013-02-20 18:33:05 -07:00
LibraryBrowser.renderGenres($('.itemGenres', page), item, context);
LibraryBrowser.renderStudios($('.itemStudios', page), item, context);
2013-04-10 14:14:25 -07:00
renderUserDataIcons(page, item);
LibraryBrowser.renderLinks($('.itemExternalLinks', page), item);
$('.criticRatingScore', page).html((item.CriticRating || '0') + '%');
2013-05-06 20:00:24 -07:00
2013-05-05 21:50:40 -07:00
if (item.CriticRatingSummary) {
$('#criticRatingSummary', page).show();
$('.criticRatingSummaryText', page).html(item.CriticRatingSummary);
2013-05-05 21:50:40 -07:00
} else {
$('#criticRatingSummary', page).hide();
}
2013-05-06 20:00:24 -07:00
renderTags(page, item);
2014-03-20 08:55:22 -07:00
renderKeywords(page, item);
2013-05-14 22:04:12 -07:00
renderSeriesAirTime(page, item, context);
2013-05-16 20:24:41 -07:00
if (item.Players) {
$('#players', page).show().html(item.Players + ' Player');
} else {
$('#players', page).hide();
}
2013-12-20 13:09:49 -07:00
if (item.Artists && item.Artists.length && item.Type != "MusicAlbum") {
$('#artist', page).show().html(getArtistLinksHtml(item.Artists)).trigger('create');
2013-05-16 20:24:41 -07:00
} else {
$('#artist', page).hide();
}
2014-03-20 08:55:22 -07:00
renderTabButtons(page, item);
}
function renderTabButtons(page, item) {
var tabsHtml = '';
var elem = $('.tabDetails', page)[0];
2013-05-28 13:01:33 -07:00
var text = elem.textContent || elem.innerText;
2014-03-20 08:55:22 -07:00
if (text.trim()) {
tabsHtml += '<input type="radio" name="radioDetailTab" class="radioDetailTab" id="radioDetails" value="tabDetails">';
tabsHtml += '<label for="radioDetails" class="lblDetailTab">Details</label>';
}
2014-03-20 20:31:40 -07:00
2014-03-20 08:55:22 -07:00
if (item.MediaType == "Audio" || item.MediaType == "Video") {
tabsHtml += '<input type="radio" name="radioDetailTab" class="radioDetailTab" id="radioMediaInfo" value="tabMediaInfo">';
tabsHtml += '<label for="radioMediaInfo" class="lblDetailTab">Media Info</label>';
}
elem = $('.tabTags', page)[0];
text = elem.textContent || elem.innerText;
if (text.trim()) {
tabsHtml += '<input type="radio" name="radioDetailTab" class="radioDetailTab" id="radioTags" value="tabTags">';
tabsHtml += '<label for="radioTags" class="lblDetailTab">Tags</label>';
}
if (tabsHtml) {
tabsHtml = '<div data-role="controlgroup" data-type="horizontal" data-mini="true" class="detailTabs">' + tabsHtml;
tabsHtml += '</div>';
$('.tabButtons', page).html(tabsHtml).trigger('create');
$('#detailsSection', page).removeClass('hide');
var elems = $('.radioDetailTab', page).on('change', function () {
$('.detailTab', page).hide();
$('.' + this.value, page).show();
});
elems[0].click();
$(elems[0]).trigger('change');
2013-05-28 13:01:33 -07:00
} else {
2014-03-20 08:55:22 -07:00
$('#detailsSection', page).addClass('hide');
$('.tabButtons', page).empty();
2013-05-28 13:01:33 -07:00
}
2014-03-20 08:55:22 -07:00
//var elem = $('.detailSectionContent', detailsSection)[0];
//var text = elem.textContent || elem.innerText;
//if (!text.trim()) {
// detailsSection.addClass('hide');
//} else {
// detailsSection.removeClass('hide');
//}
2013-05-15 06:57:13 -07:00
}
function getArtistLinksHtml(artists) {
var html = [];
for (var i = 0, length = artists.length; i < length; i++) {
var artist = artists[i];
2013-11-21 13:48:26 -07:00
html.push('<a class="textlink" href="itembynamedetails.html?context=music&musicartist=' + ApiClient.encodeName(artist) + '">' + artist + '</a>');
}
html = html.join(' / ');
if (artists.length == 1) {
return 'Artist:&nbsp;&nbsp;' + html;
}
if (artists.length > 1) {
return 'Artists:&nbsp;&nbsp;' + html;
}
return html;
}
2013-07-29 12:12:21 -07:00
2013-07-16 09:03:28 -07:00
function renderSoundtracks(page, item) {
2013-07-29 12:12:21 -07:00
2013-07-16 09:03:28 -07:00
if (item.Type == "MusicAlbum") {
$('#soundtracksHeader', page).html("This album is the soundtrack for ...");
} else {
$('#soundtracksHeader', page).html("Soundtrack(s)");
}
ApiClient.getItems(Dashboard.getCurrentUserId(), {
Ids: item.SoundtrackIds.join(","),
ItemFields: "PrimaryImageAspectRatio,ItemCounts,AudioInfo",
2013-07-16 09:03:28 -07:00
SortBy: "SortName"
}).done(function (result) {
var html = LibraryBrowser.getPosterViewHtml({
items: result.Items,
useAverageAspectRatio: true,
shape: item.Type == "MusicAlbum" ? "portrait" : "square"
});
$('#soundtracksContent', page).html(html);
});
}
2013-05-15 15:55:24 -07:00
function renderSiblingLinks(page, item) {
$('.lnkSibling', page).addClass('hide');
if ((item.Type != "Episode" && item.Type != "Season" && item.Type != "Audio") || item.IndexNumber == null) {
return;
}
var promise;
if (item.Type == "Season") {
promise = ApiClient.getSeasons(item.SeriesId, {
userId: Dashboard.getCurrentUserId(),
AdjacentTo: item.Id
});
}
else if (item.Type == "Episode") {
// Use dedicated episodes endpoint
promise = ApiClient.getEpisodes(item.SeriesId, {
seasonId: item.SeasonId,
userId: Dashboard.getCurrentUserId(),
AdjacentTo: item.Id
});
} else {
promise = ApiClient.getItems(Dashboard.getCurrentUserId(), {
AdjacentTo: item.Id,
ParentId: item.ParentId
});
}
promise.done(function (result) {
for (var i = 0, length = result.Items.length; i < length; i++) {
var curr = result.Items[i];
if (curr.IndexNumber == null) {
continue;
}
if (curr.IndexNumber < item.IndexNumber) {
2014-01-24 11:09:50 -07:00
$('.lnkPreviousItem', page).removeClass('hide').attr('href', 'itemdetails.html?id=' + curr.Id);
}
else if (curr.IndexNumber > item.IndexNumber) {
2014-01-24 11:09:50 -07:00
$('.lnkNextItem', page).removeClass('hide').attr('href', 'itemdetails.html?id=' + curr.Id);
}
}
});
}
function renderSimilarItems(page, item) {
2013-05-15 15:55:24 -07:00
var promise;
2013-05-15 15:55:24 -07:00
var options = {
userId: Dashboard.getCurrentUserId(),
2014-03-20 08:55:22 -07:00
limit: item.Type == "MusicAlbum" ? 4 : 6,
fields: "PrimaryImageAspectRatio,UserData"
};
2013-05-28 13:01:33 -07:00
if (item.Type == "Movie") {
promise = ApiClient.getSimilarMovies(item.Id, options);
}
else if (item.Type == "Trailer") {
promise = ApiClient.getSimilarTrailers(item.Id, options);
}
else if (item.Type == "MusicAlbum") {
promise = ApiClient.getSimilarAlbums(item.Id, options);
}
else if (item.Type == "Series") {
promise = ApiClient.getSimilarShows(item.Id, options);
}
else if (item.MediaType == "Game") {
promise = ApiClient.getSimilarGames(item.Id, options);
} else {
2013-05-15 15:55:24 -07:00
$('#similarCollapsible', page).hide();
return;
}
promise.done(function (result) {
2013-05-15 15:55:24 -07:00
if (!result.Items.length) {
$('#similarCollapsible', page).hide();
return;
}
var elem = $('#similarCollapsible', page).show();
$('.detailSectionHeader', elem).html('If you like ' + item.Name + ', check these out...');
var html = LibraryBrowser.getPosterViewHtml({
items: result.Items,
2013-05-16 13:46:18 -07:00
useAverageAspectRatio: item.MediaType != "Game",
2013-12-29 11:53:56 -07:00
shape: item.Type == "MusicAlbum" ? "square" : "portrait",
showParentTitle: item.Type == "MusicAlbum",
2014-01-14 22:01:58 -07:00
centerText: item.Type != "MusicAlbum",
2013-12-29 11:53:56 -07:00
showTitle: item.Type == "MusicAlbum" || item.Type == "Game",
borderless: item.Type == "Game"
2013-05-15 15:55:24 -07:00
});
$('#similarContent', page).html(html).createPosterItemMenus();
2013-05-15 15:55:24 -07:00
});
}
2013-05-15 06:57:13 -07:00
function renderSeriesAirTime(page, item, context) {
2013-05-15 15:55:24 -07:00
2013-05-15 06:57:13 -07:00
if (item.Type != "Series") {
$('#seriesAirTime', page).hide();
return;
}
2013-06-04 09:48:23 -07:00
var html = '';
2013-05-15 15:55:24 -07:00
if (item.AirDays && item.AirDays.length) {
2013-06-04 09:48:23 -07:00
html += item.AirDays.length == 7 ? 'daily' : item.AirDays.map(function (a) {
2013-05-15 06:57:13 -07:00
return a + "s";
}).join(',');
}
2013-05-15 15:55:24 -07:00
2013-05-15 06:57:13 -07:00
if (item.AirTime) {
html += ' at ' + item.AirTime;
}
if (item.Studios.length) {
html += ' on <a class="textlink" href="itembynamedetails.html?context=' + context + '&studio=' + ApiClient.encodeName(item.Studios[0].Name) + '">' + item.Studios[0].Name + '</a>';
}
2013-06-04 09:48:23 -07:00
if (html) {
html = (item.Status == 'Ended' ? 'Aired ' : 'Airs ') + html;
2013-06-04 09:48:23 -07:00
$('#seriesAirTime', page).show().html(html).trigger('create');
} else {
$('#seriesAirTime', page).hide();
}
2013-05-06 20:00:24 -07:00
}
function renderTags(page, item) {
if (item.Tags && item.Tags.length) {
var html = '';
2014-03-20 08:55:22 -07:00
html += '<p>Tags</p>';
2013-05-06 20:00:24 -07:00
for (var i = 0, length = item.Tags.length; i < length; i++) {
html += '<div class="itemTag">' + item.Tags[i] + '</div>';
}
$('.itemTags', page).show().html(html);
2013-05-06 20:00:24 -07:00
} else {
$('.itemTags', page).hide();
2013-05-06 20:00:24 -07:00
}
2013-04-10 14:14:25 -07:00
}
2014-03-20 08:55:22 -07:00
function renderKeywords(page, item) {
if (item.Keywords && item.Keywords.length) {
var html = '';
html += '<p>Plot Keywords</p>';
for (var i = 0, length = item.Keywords.length; i < length; i++) {
html += '<div class="itemTag">' + item.Keywords[i] + '</div>';
}
$('.itemKeywords', page).show().html(html);
} else {
$('.itemKeywords', page).hide();
}
}
function renderChildren(page, item, user) {
var fields = "ItemCounts,AudioInfo,PrimaryImageAspectRatio";
var query = {
ParentId: item.Id,
2013-12-29 11:53:56 -07:00
Fields: fields
};
2014-01-01 20:53:27 -07:00
// Let the server pre-sort boxsets
if (item.Type !== "BoxSet") {
query.SortBy = "SortName";
}
2013-04-22 07:44:11 -07:00
var promise;
2013-11-28 11:27:29 -07:00
if (item.Type == "Series") {
2013-11-28 11:27:29 -07:00
promise = ApiClient.getSeasons(item.Id, {
2013-11-15 14:31:33 -07:00
2013-12-29 11:53:56 -07:00
userId: user.Id,
Fields: fields
});
2013-11-15 14:31:33 -07:00
}
2013-12-01 19:24:14 -07:00
else if (item.Type == "Season") {
2013-11-15 14:31:33 -07:00
// Use dedicated episodes endpoint
promise = ApiClient.getEpisodes(item.SeriesId, {
2013-11-28 11:27:29 -07:00
seasonId: item.Id,
2013-12-29 11:53:56 -07:00
userId: user.Id,
Fields: fields
});
}
promise = promise || ApiClient.getItems(Dashboard.getCurrentUserId(), query);
promise.done(function (result) {
2013-04-22 07:44:11 -07:00
2013-04-22 13:06:43 -07:00
if (item.Type == "MusicAlbum") {
2013-04-22 07:44:11 -07:00
$('#childrenContent', page).html(LibraryBrowser.getSongTableHtml(result.Items, { showArtist: true })).trigger('create');
2013-04-22 13:06:43 -07:00
} else {
2013-04-28 11:47:19 -07:00
2014-03-07 21:20:31 -07:00
var html = '';
2013-12-29 11:53:56 -07:00
2014-03-08 11:17:05 -07:00
if (item.Type == "Series") {
2013-12-29 11:53:56 -07:00
html = LibraryBrowser.getPosterViewHtml({
items: result.Items,
shape: "portrait",
useAverageAspectRatio: true,
2014-01-14 22:01:58 -07:00
showTitle: true,
centerText: true
2013-12-29 11:53:56 -07:00
});
}
else if (item.Type == "Season") {
html = LibraryBrowser.getPosterViewHtml({
items: result.Items,
shape: "smallBackdrop",
useAverageAspectRatio: true,
showTitle: true,
displayAsSpecial: item.Type == "Season" && item.IndexNumber
});
}
2014-01-04 22:15:38 -07:00
else if (item.Type == "GameSystem") {
html = LibraryBrowser.getPosterViewHtml({
items: result.Items,
shape: "auto",
context: 'games',
useAverageAspectRatio: false,
2014-01-14 22:01:58 -07:00
showTitle: true,
centerText: true
2014-01-04 22:15:38 -07:00
});
}
2013-04-22 13:06:43 -07:00
$('#childrenContent', page).html(html).createPosterItemMenus();
2013-04-22 13:06:43 -07:00
2014-03-08 11:17:05 -07:00
if (item.Type == "BoxSet") {
var collectionItemTypes = [
{ name: 'Movies', type: 'Movie' },
{ name: 'Series', type: 'Series' },
{ name: 'Albums', type: 'MusicAlbum' },
{ name: 'Games', type: 'Game' },
{ name: 'Books', type: 'Book' }
];
renderCollectionItems(page, collectionItemTypes, result.Items, user);
}
2013-04-22 13:06:43 -07:00
}
2013-04-22 07:44:11 -07:00
});
if (item.Type == "Season") {
$('#childrenTitle', page).html('Episodes');
2013-04-22 07:44:11 -07:00
}
else if (item.Type == "Series") {
$('#childrenTitle', page).html('Seasons');
2013-04-22 07:44:11 -07:00
}
2013-04-22 08:10:54 -07:00
else if (item.Type == "MusicAlbum") {
$('#childrenTitle', page).html('Tracks');
2013-04-22 08:10:54 -07:00
}
2013-09-21 14:00:04 -07:00
else if (item.Type == "GameSystem") {
$('#childrenTitle', page).html('Games');
2013-04-28 11:47:19 -07:00
}
2013-04-22 07:44:11 -07:00
else {
$('#childrenTitle', page).html('Items');
2013-04-22 07:44:11 -07:00
}
}
2014-03-08 11:17:05 -07:00
function renderCollectionItems(page, types, items, user) {
for (var i = 0, length = types.length; i < length; i++) {
var type = types[i];
var typeItems = items.filter(function (curr) {
return curr.Type == type.type;
});
if (!typeItems.length) {
continue;
}
renderCollectionItemType(page, type, typeItems, user);
}
var otherType = { name: 'Other Items' };
var otherTypeItems = items.filter(function (curr) {
return !types.filter(function (t) {
2014-03-08 11:17:05 -07:00
return t.type == curr.Type;
}).length;
});
if (otherTypeItems.length) {
renderCollectionItemType(page, otherType, otherTypeItems, user);
}
2014-03-08 11:17:05 -07:00
if (!items.length) {
renderCollectionItemType(page, { name: 'Titles' }, items, user);
2014-03-08 11:17:05 -07:00
}
$('.collectionItems', page).trigger('create').createPosterItemMenus();
2014-03-08 11:17:05 -07:00
}
function renderCollectionItemType(page, type, items, user) {
var html = '';
html += '<div class="detailSection">';
html += '<div class="detailSectionHeader" style="position: relative;">';
html += '<span>' + type.name + '</span>';
if (user.Configuration.IsAdministrator) {
html += '<a href="editcollectionitems.html?id=' + currentItem.Id + '" data-role="button" data-icon="edit" data-iconpos="notext" data-inline="true" style="position: absolute; right: 0; top: 6px; margin-top: 0; margin-bottom: 0;">Edit</a>';
}
html += '</div>';
html += '<div class="detailSectionContent">';
var shape = type.type == 'MusicAlbum' ? 'square' : 'portrait';
html += LibraryBrowser.getPosterViewHtml({
items: items,
shape: shape,
useAverageAspectRatio: true,
showTitle: true,
centerText: true
});
html += '</div>';
html += '</div>';
$('.collectionItems', page).append(html);
}
2013-04-10 14:14:25 -07:00
function renderUserDataIcons(page, item) {
$('.userDataIcons', page).html(LibraryBrowser.getUserDataIconsHtml(item));
2013-04-10 14:14:25 -07:00
}
2013-04-24 13:28:42 -07:00
2013-05-11 23:05:51 -07:00
function renderCriticReviews(page, item, limit) {
if (item.Type != "Movie" && item.Type != "Trailer" && item.Type != "MusicVideo") {
$('#criticReviewsCollapsible', page).hide();
return;
}
2013-05-11 23:05:51 -07:00
var options = {};
if (limit) {
options.limit = limit;
}
ApiClient.getCriticReviews(item.Id, options).done(function (result) {
2014-03-19 10:44:55 -07:00
if (result.TotalRecordCount || item.CriticRatingSummary || item.AwardSummary) {
2013-05-11 23:05:51 -07:00
$('#criticReviewsCollapsible', page).show();
renderCriticReviewsContent(page, result, limit);
} else {
$('#criticReviewsCollapsible', page).hide();
}
});
}
function renderCriticReviewsContent(page, result, limit) {
var html = '';
2013-11-28 11:27:29 -07:00
var reviews = result.Items;
2013-05-11 23:05:51 -07:00
for (var i = 0, length = reviews.length; i < length; i++) {
var review = reviews[i];
html += '<div class="criticReview">';
html += '<div class="reviewScore">';
if (review.Score != null) {
html += review.Score;
}
else if (review.Likes != null) {
if (review.Likes) {
html += '<img src="css/images/fresh.png" />';
} else {
html += '<img src="css/images/rotten.png" />';
}
}
2013-05-11 23:05:51 -07:00
html += '</div>';
html += '<div class="reviewCaption">' + review.Caption + '</div>';
var vals = [];
if (review.ReviewerName) {
vals.push(review.ReviewerName);
}
if (review.Publisher) {
vals.push(review.Publisher);
}
html += '<div class="reviewerName">' + vals.join(', ') + '.';
if (review.Date) {
try {
var date = parseISO8601Date(review.Date, { toLocal: true }).toLocaleDateString();
2013-05-11 23:05:51 -07:00
html += '<span class="reviewDate">' + date + '</span>';
}
catch (error) {
}
}
html += '</div>';
if (review.Url) {
html += '<div class="reviewLink"><a class="textlink" href="' + review.Url + '" target="_blank">Full review</a></div>';
}
html += '</div>';
}
if (limit && result.TotalRecordCount > limit) {
2013-12-22 14:11:32 -07:00
html += '<p style="margin: 0;padding-left: .5em;"><button class="moreCriticReviews" data-inline="true" data-mini="true">More ...</button></p>';
2013-05-11 23:05:51 -07:00
}
$('#criticReviewsContent', page).html(html).trigger('create');
}
function renderThemeSongs(page, item) {
2013-04-24 13:28:42 -07:00
ApiClient.getThemeSongs(Dashboard.getCurrentUserId(), item.Id).done(function (result) {
if (result.Items.length) {
2013-04-24 13:28:42 -07:00
$('#themeSongsCollapsible', page).show();
$('#themeSongsContent', page).html(LibraryBrowser.getSongTableHtml(result.Items, { showArtist: true, showAlbum: true })).trigger('create');
} else {
$('#themeSongsCollapsible', page).hide();
}
});
2013-04-24 09:03:10 -07:00
}
2013-02-20 18:33:05 -07:00
function renderMusicVideos(page, item, user) {
2013-07-29 12:12:21 -07:00
ApiClient.getItems(user.Id, {
2013-07-29 12:12:21 -07:00
SortBy: "SortName",
SortOrder: "Ascending",
IncludeItemTypes: "MusicVideo",
Recursive: true,
Fields: "DateCreated",
Albums: item.Name
2013-07-29 12:12:21 -07:00
}).done(function (result) {
if (result.Items.length) {
$('#musicVideosCollapsible', page).show();
$('#musicVideosContent', page).html(getVideosHtml(result.Items, user)).trigger('create');
2013-07-29 12:12:21 -07:00
} else {
$('#musicVideosCollapsible', page).hide();
}
});
}
function renderThemeVideos(page, item, user) {
2013-04-28 10:21:56 -07:00
ApiClient.getThemeVideos(user.Id, item.Id).done(function (result) {
if (result.Items.length) {
2013-04-28 10:21:56 -07:00
$('#themeVideosCollapsible', page).show();
$('#themeVideosContent', page).html(getVideosHtml(result.Items, user)).trigger('create');
} else {
$('#themeVideosCollapsible', page).hide();
}
});
2013-04-28 10:21:56 -07:00
}
function renderAdditionalParts(page, item, user) {
ApiClient.getAdditionalVideoParts(user.Id, item.Id).done(function (result) {
if (result.Items.length) {
$('#additionalPartsCollapsible', page).show();
$('#additionalPartsContent', page).html(getVideosHtml(result.Items, user)).trigger('create');
} else {
$('#additionalPartsCollapsible', page).hide();
}
});
}
function renderAlternateVersions(page, item, user) {
2014-03-19 10:44:55 -07:00
var url = ApiClient.getUrl("Videos/" + item.Id + "/Versions", {
userId: user.Id
});
2014-03-18 21:59:45 -07:00
$.getJSON(url).done(function (items) {
2014-03-18 21:59:45 -07:00
if (items.length) {
$('#alternateVersionsCollapsible', page).show();
var html = LibraryBrowser.getPosterViewHtml({
2014-03-18 21:59:45 -07:00
items: items.map(function (i) {
var extended = $.extend({}, item, i);
extended.Id = item.Id;
return extended;
}),
shape: "portrait",
context: 'movies',
useAverageAspectRatio: true,
showTitle: true,
centerText: true,
2014-03-18 21:59:45 -07:00
linkItem: false,
2014-03-19 10:44:55 -07:00
showProgress: false,
showUnplayedIndicator: false
});
2014-03-18 21:59:45 -07:00
$('#alternateVersionsContent', page).html(html).trigger('create');
} else {
$('#alternateVersionsCollapsible', page).hide();
}
});
}
function renderScenes(page, item, user, limit) {
2013-02-20 18:33:05 -07:00
var html = '';
2013-04-10 14:14:25 -07:00
2014-03-20 20:31:40 -07:00
var primaryVersion = (item.MediaVersions || []).filter(function (v) {
return v.IsPrimaryVersion;
})[0];
var chapters = primaryVersion ? (primaryVersion.Chapters || []) : [];
2013-02-20 18:33:05 -07:00
for (var i = 0, length = chapters.length; i < length; i++) {
2013-05-11 23:05:51 -07:00
if (limit && i >= limit) {
break;
}
var chapter = chapters[i];
2013-04-10 10:11:23 -07:00
var chapterName = chapter.Name || "Chapter " + i;
2014-02-20 22:35:56 -07:00
var onclick = item.PlayAccess == 'Full' ? ' onclick="ItemDetailPage.play(' + chapter.StartPositionTicks + ');"' : '';
html += '<a class="posterItem smallBackdropPosterItem" href="#play-Chapter-' + i + '"' + onclick + '>';
2013-05-03 13:50:13 -07:00
var imgUrl;
if (chapter.ImageTag) {
2013-05-03 13:50:13 -07:00
imgUrl = ApiClient.getImageUrl(item.Id, {
maxwidth: 400,
tag: chapter.ImageTag,
type: "Chapter",
index: i
});
} else {
2013-05-03 13:50:13 -07:00
imgUrl = "css/images/items/list/chapter.png";
}
2013-02-20 18:33:05 -07:00
2013-05-03 13:50:13 -07:00
html += '<div class="posterItemImage" style="background-image:url(\'' + imgUrl + '\');"></div>';
2013-12-22 14:11:32 -07:00
html += '<div class="posterItemTextOverlay">';
2013-05-03 13:50:13 -07:00
html += '<div class="posterItemText">' + chapterName + '</div>';
html += '<div class="posterItemText">';
2013-02-20 18:33:05 -07:00
2013-06-07 10:29:33 -07:00
html += Dashboard.getDisplayTime(chapter.StartPositionTicks);
2013-03-26 15:53:06 -07:00
2013-12-22 14:11:32 -07:00
html += '</div>';
html += '</div>';
html += '</a>';
2013-02-20 18:33:05 -07:00
}
2013-05-11 23:05:51 -07:00
if (limit && chapters.length > limit) {
2013-12-22 14:11:32 -07:00
html += '<p style="margin: 0;padding-left: .5em;"><button class="moreScenes" data-inline="true" data-mini="true">More ...</button></p>';
2013-05-11 23:05:51 -07:00
}
$('#scenesContent', page).html(html).trigger('create');
2013-04-10 14:14:25 -07:00
}
2013-03-06 16:28:43 -07:00
2014-03-20 20:31:40 -07:00
function renderMediaVersions(page, item) {
var html = item.MediaVersions.map(function (v) {
return getMediaVersionHtml(item, v);
}).join('<div style="border-top:1px solid #444;margin: 1em 0;"></div>');
if (item.MediaVersions.length > 1) {
html = '<br/>' + html;
}
$('#mediaInfoContent', page).html(html).trigger('create');
}
function getMediaVersionHtml(item, version) {
2013-03-26 14:32:01 -07:00
2013-03-26 16:57:18 -07:00
var html = '';
2014-03-20 20:31:40 -07:00
if (version.Name && item.MediaVersions.length > 1) {
html += '<span class="mediaInfoAttribute">' + version.Name + '</span><br/>';
}
2013-03-26 16:57:18 -07:00
2014-03-20 20:31:40 -07:00
for (var i = 0, length = version.MediaStreams.length; i < length; i++) {
var stream = version.MediaStreams[i];
2013-03-26 16:57:18 -07:00
2013-04-09 11:01:39 -07:00
if (stream.Type == "Data") {
continue;
}
2013-04-09 11:38:58 -07:00
var type;
if (item.MediaType == "Audio" && stream.Type == "Video") {
type = "Embedded Image";
} else {
type = stream.Type;
}
2013-04-09 11:38:58 -07:00
html += '<div class="mediaInfoStream">';
2013-03-26 16:57:18 -07:00
html += '<div class="mediaInfoStreamType">' + type + '</div>';
2013-04-09 19:28:24 -07:00
2013-05-15 20:39:15 -07:00
var attributes = [];
2013-04-09 19:28:24 -07:00
2014-01-18 12:25:20 -07:00
if (stream.Language && stream.Type != "Video") {
attributes.push(createAttribute("Language", stream.Language));
2013-11-12 09:08:23 -07:00
}
2013-09-03 14:06:33 -07:00
if (stream.Codec && stream.Codec != "dca") {
attributes.push(createAttribute("Codec", stream.Codec.toUpperCase()));
2013-04-09 11:38:58 -07:00
}
2013-09-03 14:06:33 -07:00
if (stream.Profile && stream.Codec == "dca") {
attributes.push(createAttribute("Codec", stream.Profile.toUpperCase()));
2014-03-20 08:55:22 -07:00
}
else if (stream.Profile) {
attributes.push(createAttribute("Profile", stream.Profile));
2014-03-20 08:55:22 -07:00
}
if (stream.Level) {
attributes.push(createAttribute("Level", stream.Level));
2013-04-09 11:38:58 -07:00
}
2013-09-03 14:06:33 -07:00
if (stream.Width || stream.Height) {
attributes.push(createAttribute("Resolution", stream.Width + 'x' + stream.Height));
2013-04-09 11:38:58 -07:00
}
2013-05-15 20:39:15 -07:00
if (stream.AspectRatio && stream.Codec != "mjpeg") {
attributes.push(createAttribute("Aspect Ratio", stream.AspectRatio));
2014-03-20 08:55:22 -07:00
}
if (type == "Video") {
attributes.push(createAttribute("Interlaced", (stream.IsInterlaced ? 'Yes' : 'No')));
2014-03-20 08:55:22 -07:00
}
if (stream.AverageFrameRate || stream.RealFrameRate) {
attributes.push(createAttribute("Framerate", (stream.AverageFrameRate || stream.RealFrameRate)));
2013-04-09 11:38:58 -07:00
}
2013-05-15 20:39:15 -07:00
2013-11-12 09:08:23 -07:00
if (stream.ChannelLayout) {
attributes.push(createAttribute("Layout", stream.ChannelLayout));
}
2013-11-12 09:08:23 -07:00
else if (stream.Channels) {
attributes.push(createAttribute("Channels", stream.Channels + ' ch'));
2013-03-26 16:57:18 -07:00
}
2013-05-15 20:39:15 -07:00
2013-11-12 09:08:23 -07:00
if (stream.BitRate && stream.Codec != "mjpeg") {
attributes.push(createAttribute("Bitrate", (parseInt(stream.BitRate / 1000)) + ' kbps'));
2013-11-12 09:08:23 -07:00
}
2014-03-20 08:55:22 -07:00
if (stream.SampleRate) {
attributes.push(createAttribute("Sample Rate", stream.SampleRate + ' khz'));
2013-04-09 11:38:58 -07:00
}
2014-03-20 08:55:22 -07:00
if (stream.Type != "Video") {
attributes.push(createAttribute("Default", (stream.IsDefault ? 'Yes' : 'No')));
2013-05-15 20:39:15 -07:00
}
2014-03-20 08:55:22 -07:00
if (stream.Type == "Subtitle") {
attributes.push(createAttribute("Forced", (stream.IsForced ? 'Yes' : 'No')));
attributes.push(createAttribute("External", (stream.IsExternal ? 'Yes' : 'No')));
2013-03-26 16:57:18 -07:00
}
2014-03-20 08:55:22 -07:00
html += attributes.join('<br/>');
2013-04-09 11:38:58 -07:00
html += '</div>';
2013-02-20 18:33:05 -07:00
}
2014-03-20 20:31:40 -07:00
if (version.Path) {
html += '<br/><span class="mediaInfoLabel">Path</span><span class="mediaInfoAttribute">' + version.Path + '</span>';
}
return html;
2013-04-10 14:14:25 -07:00
}
function createAttribute(label, value) {
return '<span class="mediaInfoLabel">' + label + '</span><span class="mediaInfoAttribute">' + value + '</span>'
}
function getVideosHtml(items, user, limit, moreButtonClass) {
2013-04-28 10:21:56 -07:00
var html = '';
2013-04-28 10:21:56 -07:00
for (var i = 0, length = items.length; i < length; i++) {
2013-05-11 23:05:51 -07:00
if (limit && i >= limit) {
break;
}
2013-04-28 10:21:56 -07:00
var item = items[i];
2013-05-11 23:05:51 -07:00
var cssClass = "posterItem smallBackdropPosterItem";
2013-07-29 12:12:21 -07:00
var href = "itemdetails.html?id=" + item.Id;
2014-02-20 22:35:56 -07:00
var onclick = item.PlayAccess == 'Full' ? ' onclick="MediaPlayer.playById(\'' + item.Id + '\'); return false;"' : "";
html += '<a class="' + cssClass + '" href="' + href + '"' + onclick + '>';
2013-04-28 10:21:56 -07:00
var imageTags = item.ImageTags || {};
2013-04-28 10:39:16 -07:00
var imgUrl;
2013-04-28 10:21:56 -07:00
if (imageTags.Primary) {
2013-03-29 07:12:14 -07:00
2013-04-28 10:39:16 -07:00
imgUrl = ApiClient.getImageUrl(item.Id, {
2013-04-28 10:21:56 -07:00
maxwidth: 500,
tag: imageTags.Primary,
type: "primary"
});
2013-04-28 10:21:56 -07:00
} else {
2013-04-28 10:39:16 -07:00
imgUrl = "css/images/items/detail/video.png";
2013-04-28 10:21:56 -07:00
}
2013-04-28 10:39:16 -07:00
html += '<div class="posterItemImage" style="background-image:url(\'' + imgUrl + '\');"></div>';
2013-12-22 14:11:32 -07:00
html += '<div class="posterItemTextOverlay">';
2013-04-28 10:39:16 -07:00
html += '<div class="posterItemText">' + item.Name + '</div>';
html += '<div class="posterItemText">';
2013-04-28 10:21:56 -07:00
if (item.RunTimeTicks != "") {
2013-06-07 10:29:33 -07:00
html += Dashboard.getDisplayTime(item.RunTimeTicks);
2013-04-28 10:21:56 -07:00
}
else {
html += "&nbsp;";
}
html += '</div>';
2013-12-22 14:11:32 -07:00
html += '</div>';
2013-04-28 10:21:56 -07:00
html += '</a>';
2013-04-28 10:21:56 -07:00
}
2013-05-11 23:05:51 -07:00
if (limit && items.length > limit) {
2013-12-22 14:11:32 -07:00
html += '<p style="margin: 0;padding-left: .5em;"><button class="' + moreButtonClass + '" data-inline="true" data-mini="true">More ...</button></p>';
2013-05-11 23:05:51 -07:00
}
2013-04-28 10:21:56 -07:00
return html;
}
function renderSpecials(page, item, user, limit) {
2013-04-28 10:21:56 -07:00
ApiClient.getSpecialFeatures(user.Id, item.Id).done(function (specials) {
$('#specialsContent', page).html(getVideosHtml(specials, user, limit, "moreSpecials")).trigger('create');
});
2013-04-10 14:14:25 -07:00
}
2013-05-11 23:05:51 -07:00
function renderCast(page, item, context, limit) {
2013-03-26 22:20:46 -07:00
var html = '';
2013-04-10 14:14:25 -07:00
var casts = item.People || [];
2013-03-26 22:20:46 -07:00
for (var i = 0, length = casts.length; i < length; i++) {
2013-05-11 23:05:51 -07:00
if (limit && i >= limit) {
break;
}
2013-04-22 07:44:11 -07:00
var cast = casts[i];
2013-03-26 22:20:46 -07:00
2013-05-11 23:05:51 -07:00
html += '<a class="tileItem smallPosterTileItem" href="itembynamedetails.html?context=' + context + '&person=' + ApiClient.encodeName(cast.Name) + '">';
var imgUrl;
if (cast.PrimaryImageTag) {
imgUrl = ApiClient.getPersonImageUrl(cast.Name, {
width: 130,
tag: cast.PrimaryImageTag,
type: "primary"
});
} else {
imgUrl = "css/images/items/list/person.png";
}
html += '<div class="tileImage" style="background-image:url(\'' + imgUrl + '\');"></div>';
html += '<div class="tileContent">';
html += '<p>' + cast.Name + '</p>';
var role = cast.Role ? "as " + cast.Role : cast.Type;
if (role == "GuestStar") {
role = "Guest star";
}
2013-05-11 23:05:51 -07:00
role = role || "";
var maxlength = 40;
if (role.length > maxlength) {
role = role.substring(0, maxlength - 3) + '...';
}
html += '<p>' + role + '</p>';
2013-05-11 23:05:51 -07:00
html += '</div>';
html += '</a>';
2013-03-26 22:20:46 -07:00
}
2013-05-11 23:05:51 -07:00
if (limit && casts.length > limit) {
2014-03-20 08:55:22 -07:00
html += '<p style="margin: 0;padding-left: .5em;"><button class="morePeople" data-inline="true" data-mini="true">More ...</button></p>';
2013-05-11 23:05:51 -07:00
}
$('#castContent', page).html(html).trigger('create');
2013-04-10 14:14:25 -07:00
}
2013-04-14 08:14:10 -07:00
2013-04-10 14:14:25 -07:00
function play(startPosition) {
2013-03-28 22:51:45 -07:00
2013-04-10 14:14:25 -07:00
MediaPlayer.play([currentItem], startPosition);
}
2013-03-28 22:51:45 -07:00
2014-03-19 10:44:55 -07:00
function splitVersions(page) {
var id = getParameterByName('id');
Dashboard.confirm("Are you sure you wish to split the versions apart into separate items?", "Split Versions Apart", function (confirmResult) {
if (confirmResult) {
Dashboard.showLoadingMsg();
$.ajax({
type: "DELETE",
url: ApiClient.getUrl("Videos/" + id + "/AlternateVersions")
}).done(function () {
Dashboard.hideLoadingMsg();
reload(page);
});
}
});
}
function playTrailer(page) {
ApiClient.getLocalTrailers(Dashboard.getCurrentUserId(), currentItem.Id).done(function (trailers) {
MediaPlayer.play(trailers);
});
}
2013-04-10 14:14:25 -07:00
$(document).on('pageinit', "#itemDetailPage", function () {
2013-03-29 07:12:14 -07:00
2013-04-10 14:14:25 -07:00
var page = this;
2013-04-04 10:27:36 -07:00
2013-04-10 14:14:25 -07:00
$('#btnPlay', page).on('click', function () {
var userdata = currentItem.UserData || {};
2013-08-08 07:53:25 -07:00
var mediaType = currentItem.MediaType;
2013-08-08 07:53:25 -07:00
if (currentItem.Type == "MusicArtist" || currentItem.Type == "MusicAlbum") {
mediaType = "Audio";
}
2013-08-08 07:53:25 -07:00
LibraryBrowser.showPlayMenu(this, currentItem.Id, currentItem.Type, mediaType, userdata.PlaybackPositionTicks);
2013-04-14 08:14:10 -07:00
});
2014-01-10 06:52:01 -07:00
$('#btnPlayTrailer', page).on('click', function () {
2014-03-19 10:44:55 -07:00
playTrailer(page);
2014-01-10 06:52:01 -07:00
});
$('#btnPlayExternal', page).on('click', function () {
ApiClient.markPlayed(Dashboard.getCurrentUserId(), currentItem.Id, new Date());
});
2013-05-28 18:45:39 -07:00
$('#btnRemote', page).on('click', function () {
2013-07-11 13:25:12 -07:00
RemoteControl.showMenuForItem({
2013-06-04 09:48:23 -07:00
2013-05-30 12:58:07 -07:00
item: currentItem,
context: getContext(currentItem),
2013-06-04 09:48:23 -07:00
2013-05-30 12:58:07 -07:00
themeSongs: $('#themeSongsCollapsible:visible', page).length > 0,
themeVideos: $('#themeVideosCollapsible:visible', page).length > 0
});
2013-05-28 18:45:39 -07:00
});
2014-03-19 10:44:55 -07:00
$('.btnSplitVersions', page).on('click', function () {
splitVersions(page);
});
2013-04-10 14:14:25 -07:00
}).on('pageshow', "#itemDetailPage", function () {
2013-03-28 22:51:45 -07:00
2013-04-10 14:14:25 -07:00
var page = this;
2013-03-28 22:51:45 -07:00
2013-05-11 23:05:51 -07:00
$(page).on("click.moreScenes", ".moreScenes", function () {
Dashboard.getCurrentUser().done(function (user) {
renderScenes(page, currentItem, user);
});
2013-05-11 23:05:51 -07:00
}).on("click.morePeople", ".morePeople", function () {
renderCast(page, currentItem, getContext(currentItem));
}).on("click.moreSpecials", ".moreSpecials", function () {
Dashboard.getCurrentUser().done(function (user) {
renderSpecials(page, currentItem, user);
});
2013-05-11 23:05:51 -07:00
}).on("click.moreCriticReviews", ".moreCriticReviews", function () {
renderCriticReviews(page, currentItem);
2013-05-11 23:05:51 -07:00
});
2013-04-10 14:14:25 -07:00
reload(page);
2013-03-28 22:51:45 -07:00
2013-04-10 14:14:25 -07:00
}).on('pagehide', "#itemDetailPage", function () {
2013-04-10 14:14:25 -07:00
currentItem = null;
2013-05-11 23:05:51 -07:00
var page = this;
$(page).off("click.moreScenes").off("click.morePeople").off("click.moreSpecials").off("click.moreCriticReviews");
2013-04-10 14:14:25 -07:00
});
2013-04-14 08:14:10 -07:00
2013-04-10 14:14:25 -07:00
function itemDetailPage() {
2013-04-10 14:14:25 -07:00
var self = this;
2013-04-10 14:14:25 -07:00
self.play = play;
2013-04-09 11:38:58 -07:00
}
2013-03-28 22:51:45 -07:00
2013-04-10 14:14:25 -07:00
window.ItemDetailPage = new itemDetailPage();
2013-02-20 18:33:05 -07:00
2013-04-10 14:14:25 -07:00
})(jQuery, document, LibraryBrowser, window);