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

629 lines
20 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);
2013-04-10 14:14:25 -07:00
var name = item.Name;
2013-03-06 16:28:43 -07:00
2013-04-10 14:14:25 -07:00
if (item.IndexNumber != null) {
name = item.IndexNumber + " - " + name;
}
if (item.ParentIndexNumber != null) {
name = item.ParentIndexNumber + "." + name;
}
2013-02-20 18:33:05 -07:00
2013-04-10 14:14:25 -07:00
$('#itemImage', page).html(LibraryBrowser.getDetailImageHtml(item));
2013-02-20 18:33:05 -07:00
2013-04-10 14:14:25 -07:00
Dashboard.setPageTitle(name);
2013-03-26 14:32:01 -07:00
2013-04-10 14:14:25 -07:00
$('#itemName', page).html(name);
2013-02-20 18:33:05 -07:00
2013-04-25 18:52:29 -07:00
if (item.AlbumArtist && item.Type == "Audio") {
$('#albumArtist', page).html('<a class="detailPageParentLink" href="itembynamedetails.html?context=music&artist=' + item.AlbumArtist + '">' + item.AlbumArtist + '</a>').show().trigger('create');
}
else {
$('#albumArtist', page).hide();
}
2013-04-17 21:01:23 -07:00
if (item.SeriesName) {
2013-04-22 07:44:11 -07:00
$('#seriesName', page).html('<a class="detailPageParentLink" href="itemdetails.html?id=' + item.SeriesId + '">' + item.SeriesName + '</a>').show().trigger('create');
2013-04-17 21:01:23 -07:00
}
2013-04-24 09:03:10 -07:00
else if (item.Album && item.Type == "Audio" && item.ParentId) {
$('#seriesName', page).html('<a class="detailPageParentLink" href="itemdetails.html?id=' + item.ParentId + '">' + item.Album + '</a>').show().trigger('create');
2013-04-25 18:52:29 -07:00
}
else if (item.AlbumArtist && item.Type == "MusicAlbum") {
$('#seriesName', page).html('<a class="detailPageParentLink" href="itembynamedetails.html?context=music&artist=' + item.AlbumArtist + '">' + item.AlbumArtist + '</a>').show().trigger('create');
}
2013-04-17 21:01:23 -07:00
else if (item.Album) {
$('#seriesName', page).html(item.Album).show();
2013-04-22 07:44:11 -07:00
}
else {
2013-04-17 21:01:23 -07:00
$('#seriesName', page).hide();
2013-04-10 14:14:25 -07:00
}
2013-04-23 07:46:27 -07:00
var context = getContext(item);
setInitialCollapsibleState(page, item, context);
renderDetails(page, item, context);
2013-02-20 18:33:05 -07:00
2013-04-10 14:14:25 -07:00
if (MediaPlayer.canPlay(item)) {
$('#btnPlayMenu', page).show();
$('#playButtonShadow', page).show();
if (MediaPlayer.isPlaying())
2013-04-22 07:44:11 -07:00
$('#btnQueueMenu', page).show();
else
$('#btnQueueMenu', page).hide();
2013-04-10 14:14:25 -07:00
} else {
$('#btnPlayMenu', page).hide();
$('#playButtonShadow', page).hide();
2013-04-14 08:14:10 -07:00
$('#btnQueueMenu', page).hide();
2013-04-10 14:14:25 -07:00
}
2013-04-17 18:32:38 -07:00
2013-04-10 14:14:25 -07:00
Dashboard.hideLoadingMsg();
});
}
2013-04-24 13:28:42 -07:00
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" || item.Type == "BoxSet") {
return "movies";
}
if (item.Type == "Audio" || item.Type == "MusicAlbum" || item.Type == "MusicArtist" || item.Type == "Artist") {
return "music";
}
if (item.MediaType == "Game") {
return "games";
}
return "";
}
2013-04-22 07:44:11 -07:00
function enableCustomHeader(page, text) {
var elem = $('.libraryPageHeader', page).show();
$('span', elem).html(text);
}
function renderHeader(page, item) {
if (item.Type == "Movie" || item.Type == "Trailer" || item.Type == "BoxSet") {
enableCustomHeader(page, "Movies");
$('#standardLogo', page).hide();
}
else if (item.Type == "Episode" || item.Type == "Season" || item.Type == "Series") {
enableCustomHeader(page, "TV Shows");
$('#standardLogo', page).hide();
}
2013-04-22 08:10:54 -07:00
else if (item.Type == "Audio" || item.Type == "MusicAlbum") {
2013-04-22 07:44:11 -07:00
enableCustomHeader(page, "Music");
$('#standardLogo', page).hide();
}
2013-04-24 13:28:42 -07:00
else if (item.MediaType == "Game") {
enableCustomHeader(page, "Games");
$('#standardLogo', page).hide();
}
2013-04-22 07:44:11 -07:00
else {
$('.libraryPageHeader', page).hide();
$('#standardLogo', page).show();
}
2013-04-22 08:10:54 -07:00
if (item.Type == "MusicAlbum") {
$('#albumTabs', page).show();
} else {
$('#albumTabs', page).hide();
}
2013-04-22 07:44:11 -07:00
if (item.Type == "Audio") {
$('#songTabs', page).show();
} else {
$('#songTabs', page).hide();
}
if (item.Type == "Movie") {
$('#movieTabs', page).show();
} else {
$('#movieTabs', page).hide();
}
2013-04-24 13:28:42 -07:00
if (item.MediaType == "Game") {
$('#gameTabs', page).show();
} else {
$('#gameTabs', page).hide();
}
2013-04-22 07:44:11 -07:00
if (item.Type == "BoxSet") {
$('#boxsetTabs', page).show();
} else {
$('#boxsetTabs', page).hide();
}
if (item.Type == "Trailer") {
$('#trailerTabs', page).show();
} else {
$('#trailerTabs', page).hide();
}
if (item.Type == "Episode" || item.Type == "Season" || item.Type == "Series") {
$('#tvShowsTabs', page).show();
} else {
$('#tvShowsTabs', page).hide();
}
}
2013-04-23 07:46:27 -07:00
function setInitialCollapsibleState(page, item, context) {
2013-04-14 08:14:10 -07:00
2013-04-22 20:56:11 -07:00
if (item.ChildCount && item.Type == "MusicAlbum") {
$('#itemSongs', page).show();
$('#childrenCollapsible', page).hide();
renderChildren(page, item);
}
else if (item.ChildCount) {
$('#itemSongs', page).hide();
2013-04-22 07:44:11 -07:00
$('#childrenCollapsible', page).show();
renderChildren(page, item);
2013-04-22 20:56:11 -07:00
}
else {
$('#itemSongs', page).hide();
2013-04-22 07:44:11 -07:00
$('#childrenCollapsible', page).hide();
}
if (LibraryBrowser.shouldDisplayGallery(item)) {
$('#galleryCollapsible', page).show();
renderGallery(page, item);
} else {
$('#galleryCollapsible', page).hide();
}
2013-03-26 16:57:18 -07:00
if (!item.MediaStreams || !item.MediaStreams.length) {
$('#mediaInfoCollapsible', page).hide();
2013-03-29 07:12:14 -07:00
} else {
2013-03-26 16:57:18 -07:00
$('#mediaInfoCollapsible', page).show();
2013-04-22 07:44:11 -07:00
renderMediaInfo(page, item);
2013-03-26 16:57:18 -07:00
}
if (!item.Chapters || !item.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();
2013-04-22 07:44:11 -07:00
renderScenes(page, item);
}
if (!item.LocalTrailerCount || item.LocalTrailerCount == 0) {
2013-03-26 14:32:01 -07:00
$('#trailersCollapsible', page).hide();
} else {
2013-03-26 15:53:06 -07:00
$('#trailersCollapsible', page).show();
2013-04-22 07:44:11 -07:00
renderTrailers(page, item);
}
if (!item.SpecialFeatureCount || item.SpecialFeatureCount == 0) {
2013-03-26 14:32:01 -07:00
$('#specialsCollapsible', page).hide();
} else {
2013-03-26 15:53:06 -07:00
$('#specialsCollapsible', page).show();
2013-04-22 07:44:11 -07:00
renderSpecials(page, item);
}
2013-03-26 22:20:46 -07:00
if (!item.People || !item.People.length) {
$('#castCollapsible', page).hide();
} else {
$('#castCollapsible', page).show();
2013-04-23 07:46:27 -07:00
renderCast(page, item, context);
2013-03-26 22:20:46 -07:00
}
2013-04-24 09:03:10 -07:00
$('#themeSongsCollapsible', page).hide();
$('#themeVideosCollapsible', page).hide();
2013-04-24 09:03:10 -07:00
2013-04-24 09:37:12 -07:00
ApiClient.getThemeSongs(Dashboard.getCurrentUserId(), item.Id).done(function (result) {
renderThemeSongs(page, item, result);
2013-04-24 09:03:10 -07:00
});
2013-04-28 10:21:56 -07:00
ApiClient.getThemeVideos(Dashboard.getCurrentUserId(), item.Id).done(function (result) {
renderThemeVideos(page, item, result);
2013-04-28 10:21:56 -07:00
});
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
if (item.Taglines && item.Taglines.length) {
$('#itemTagline', page).html(item.Taglines[0]).show();
} else {
$('#itemTagline', page).hide();
}
2013-04-21 21:38:03 -07:00
LibraryBrowser.renderOverview($('#itemOverview', page), item);
2013-02-20 18:33:05 -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-02-20 18:33:05 -07:00
} else {
$('#itemCommunityRating', page).hide();
}
2013-04-18 07:27:21 -07:00
LibraryBrowser.renderPremiereDate($('#itemPremiereDate', page), item);
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);
2013-04-12 08:25:00 -07:00
2013-04-10 14:14:25 -07:00
$('#itemMiscInfo', page).html(LibraryBrowser.getMiscInfoHtml(item));
2013-02-20 18:33:05 -07:00
2013-04-23 07:46:27 -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);
2013-04-14 08:14:10 -07:00
LibraryBrowser.renderLinks($('#itemLinks', page), item);
2013-04-10 14:14:25 -07:00
}
2013-04-22 07:44:11 -07:00
function renderChildren(page, item) {
ApiClient.getItems(Dashboard.getCurrentUserId(), {
ParentId: getParameterByName('id'),
SortBy: "SortName",
2013-04-25 20:31:10 -07:00
Fields: "PrimaryImageAspectRatio,ItemCounts,DisplayMediaType,DateCreated,UserData,AudioInfo"
2013-04-22 07:44:11 -07:00
}).done(function (result) {
2013-04-22 13:06:43 -07:00
if (item.Type == "MusicAlbum") {
2013-04-22 07:44:11 -07:00
2013-04-25 20:31:10 -07:00
$('#itemSongs', page).html(LibraryBrowser.getSongTableHtml(result.Items, { showArtist: true })).trigger('create');
2013-04-22 13:06:43 -07:00
} else {
var html = LibraryBrowser.getPosterDetailViewHtml({
items: result.Items,
useAverageAspectRatio: true
});
$('#childrenContent', page).html(html);
}
2013-04-22 07:44:11 -07:00
});
if (item.Type == "Season") {
$('#childrenTitle', page).html('Episodes (' + item.ChildCount + ')');
}
else if (item.Type == "Series") {
$('#childrenTitle', page).html('Seasons (' + item.ChildCount + ')');
}
else if (item.Type == "BoxSet") {
$('#childrenTitle', page).html('Movies (' + item.ChildCount + ')');
}
2013-04-22 08:10:54 -07:00
else if (item.Type == "MusicAlbum") {
2013-04-22 13:06:43 -07:00
$('#childrenTitle', page).html('Tracks (' + item.ChildCount + ')');
2013-04-22 08:10:54 -07:00
}
2013-04-22 07:44:11 -07:00
else {
$('#childrenTitle', page).html('Items (' + item.ChildCount + ')');
}
}
2013-04-10 14:14:25 -07:00
function renderUserDataIcons(page, item) {
$('#itemRatings', page).html(LibraryBrowser.getUserDataIconsHtml(item));
}
2013-04-24 13:28:42 -07:00
2013-04-24 09:37:12 -07:00
function renderThemeSongs(page, item, result) {
2013-04-24 13:28:42 -07:00
2013-04-24 09:37:12 -07:00
if (result.Items.length) {
2013-04-24 13:28:42 -07:00
2013-04-24 09:03:10 -07:00
$('#themeSongsCollapsible', page).show();
2013-04-24 13:28:42 -07:00
$('#themeSongsContent', page).html(LibraryBrowser.getSongTableHtml(result.Items, { showArtist: true, showAlbum: true })).trigger('create');
2013-04-24 09:03:10 -07:00
}
}
2013-02-20 18:33:05 -07:00
function renderThemeVideos(page, item, result) {
2013-04-28 10:21:56 -07:00
if (result.Items.length) {
$('#themeVideosCollapsible', page).show();
2013-04-28 10:21:56 -07:00
$('#themeVideosContent', page).html(getVideosHtml(result.Items)).trigger('create');
2013-04-28 10:21:56 -07:00
}
}
2013-04-10 14:14:25 -07:00
function renderScenes(page, item) {
2013-02-20 18:33:05 -07:00
var html = '';
2013-04-10 14:14:25 -07:00
var chapters = item.Chapters || {};
2013-02-20 18:33:05 -07:00
for (var i = 0, length = chapters.length; i < length; i++) {
var chapter = chapters[i];
2013-04-10 10:11:23 -07:00
var chapterName = chapter.Name || "Chapter " + i;
2013-04-22 07:44:11 -07:00
html += '<div class="scenePosterViewItem posterViewItem posterViewItemWithDualText">';
2013-03-26 14:32:01 -07:00
html += '<a href="#play-Chapter-' + i + '" onclick="ItemDetailPage.play(' + chapter.StartPositionTicks + ');">';
if (chapter.ImageTag) {
var imgUrl = ApiClient.getImageUrl(item.Id, {
2013-04-22 07:44:11 -07:00
width: 400,
tag: chapter.ImageTag,
type: "Chapter",
index: i
});
2013-02-20 18:33:05 -07:00
html += '<img src="' + imgUrl + '" />';
} else {
2013-03-26 10:21:14 -07:00
html += '<img src="css/images/items/list/chapter.png"/>';
}
2013-02-20 18:33:05 -07:00
2013-04-10 10:11:23 -07:00
html += '<div class="posterViewItemText posterViewItemPrimaryText">' + chapterName + '</div>';
html += '<div class="posterViewItemText">';
2013-02-20 18:33:05 -07:00
2013-03-26 15:53:06 -07:00
html += ticks_to_human(chapter.StartPositionTicks);
html += '</div>';
html += '</a>';
html += '</div>';
2013-02-20 18:33:05 -07:00
}
$('#scenesContent', page).html(html);
2013-04-10 14:14:25 -07:00
}
2013-03-06 16:28:43 -07:00
2013-04-10 14:14:25 -07:00
function renderGallery(page, item) {
2013-02-20 18:33:05 -07:00
2013-04-15 18:09:27 -07:00
var html = LibraryBrowser.getGalleryHtml(item);
2013-04-15 15:13:55 -07:00
$('#galleryContent', page).html(html).trigger('create');
2013-04-10 14:14:25 -07:00
}
2013-04-10 14:14:25 -07:00
function renderMediaInfo(page, item) {
2013-03-26 14:32:01 -07:00
2013-03-26 16:57:18 -07:00
var html = '';
for (var i = 0, length = item.MediaStreams.length; i < length; i++) {
var stream = item.MediaStreams[i];
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
2013-04-09 11:38:58 -07:00
html += '<p class="mediaInfoStreamType">' + type + '</p>';
2013-04-09 19:28:24 -07:00
2013-04-09 11:38:58 -07:00
html += '<ul class="mediaInfoDetails">';
2013-04-09 19:28:24 -07:00
2013-04-09 11:38:58 -07:00
if (stream.Codec) {
html += '<li><span class="mediaInfoLabel">Codec</span> ' + stream.Codec + '</li>';
}
if (stream.Profile) {
html += '<li><span class="mediaInfoLabel">Profile</span> ' + stream.Profile + '</li>';
}
if (stream.Level) {
html += '<li><span class="mediaInfoLabel">Level</span> ' + stream.Level + '</li>';
}
if (stream.Language) {
2013-04-09 11:38:58 -07:00
html += '<li><span class="mediaInfoLabel">Language</span> ' + stream.Language + '</li>';
}
if (stream.Width) {
html += '<li><span class="mediaInfoLabel">Width</span> ' + stream.Width + '</li>';
}
if (stream.Height) {
html += '<li><span class="mediaInfoLabel">Height</span> ' + stream.Height + '</li>';
}
if (stream.AspectRatio) {
html += '<li><span class="mediaInfoLabel">Aspect Ratio</span> ' + stream.AspectRatio + '</li>';
}
2013-04-18 09:12:07 -07:00
if (stream.BitRate) {
html += '<li><span class="mediaInfoLabel">Bitrate</span> ' + stream.BitRate + '</li>';
}
if (stream.Channels) {
2013-04-09 11:38:58 -07:00
html += '<li><span class="mediaInfoLabel">Channels</span> ' + stream.Channels + '</li>';
2013-03-26 16:57:18 -07:00
}
2013-04-09 12:38:19 -07:00
if (stream.SampleRate) {
html += '<li><span class="mediaInfoLabel">Sample Rate</span> ' + stream.SampleRate + '</li>';
}
2013-04-09 11:38:58 -07:00
var framerate = stream.AverageFrameRate || stream.RealFrameRate;
2013-04-09 19:28:24 -07:00
2013-04-09 11:38:58 -07:00
if (framerate) {
html += '<li><span class="mediaInfoLabel">Framerate</span> ' + framerate + '</li>';
}
2013-04-09 19:28:24 -07:00
2013-04-09 12:38:19 -07:00
if (stream.PixelFormat) {
html += '<li><span class="mediaInfoLabel">Pixel Format</span> ' + stream.PixelFormat + '</li>';
}
2013-04-09 11:38:58 -07:00
if (stream.IsDefault) {
html += '<li>Default</li>';
}
if (stream.IsForced) {
html += '<li>Forced</li>';
}
if (stream.IsExternal) {
html += '<li>External</li>';
}
if (stream.Path) {
html += '<li><span class="mediaInfoLabel">Path</span> ' + stream.Path + '</li>';
2013-03-26 16:57:18 -07:00
}
2013-04-09 11:38:58 -07:00
html += '</ul>';
2013-04-09 11:38:58 -07:00
html += '</div>';
2013-02-20 18:33:05 -07:00
}
2013-03-26 16:57:18 -07:00
$('#mediaInfoContent', page).html(html).trigger('create');
2013-04-10 14:14:25 -07:00
}
2013-04-28 10:21:56 -07:00
function getVideosHtml(items) {
var html = '';
2013-04-28 10:21:56 -07:00
for (var i = 0, length = items.length; i < length; i++) {
2013-04-28 10:21:56 -07:00
var item = items[i];
2013-04-28 10:39:16 -07:00
html += '<a class="posterItem backdropPosterItem" href="#" onclick="ItemDetailPage.playById(\'' + item.Id + '\');">';
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>';
html += '<div class="posterItemText">' + item.Name + '</div>';
html += '<div class="posterItemText">';
2013-04-28 10:21:56 -07:00
if (item.RunTimeTicks != "") {
html += ticks_to_human(item.RunTimeTicks);
}
else {
html += "&nbsp;";
}
html += '</div>';
2013-04-28 10:21:56 -07:00
html += '</a>';
2013-04-28 10:21:56 -07:00
}
2013-04-28 10:21:56 -07:00
return html;
}
function renderSpecials(page, item) {
ApiClient.getSpecialFeatures(Dashboard.getCurrentUserId(), item.Id).done(function (specials) {
2013-04-28 10:21:56 -07:00
$('#specialsContent', page).html(getVideosHtml(specials));
});
2013-04-10 14:14:25 -07:00
}
2013-04-10 14:14:25 -07:00
function renderTrailers(page, item) {
2013-04-10 14:14:25 -07:00
ApiClient.getLocalTrailers(Dashboard.getCurrentUserId(), item.Id).done(function (trailers) {
2013-04-28 10:21:56 -07:00
$('#trailersContent', page).html(getVideosHtml(trailers));
});
2013-04-10 14:14:25 -07:00
}
2013-03-26 22:20:46 -07:00
2013-04-23 07:46:27 -07:00
function renderCast(page, item, context) {
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-04-22 07:44:11 -07:00
var cast = casts[i];
2013-03-26 22:20:46 -07:00
2013-04-23 07:46:27 -07:00
html += LibraryBrowser.createCastImage(cast, context);
2013-03-26 22:20:46 -07:00
}
$('#castContent', page).html(html);
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
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
$('#btnPlayMenu', page).on('click', function () {
2013-03-28 22:51:45 -07:00
2013-04-10 14:14:25 -07:00
var userdata = currentItem.UserData || {};
2013-03-28 22:51:45 -07:00
if (userdata.PlaybackPositionTicks) {
2013-03-28 22:51:45 -07:00
2013-04-10 14:14:25 -07:00
var pos = $('#playMenuAnchor', page).offset();
2013-03-28 22:51:45 -07:00
2013-04-10 14:14:25 -07:00
$('#playMenu', page).popup("open", {
x: pos.left + 125,
y: pos.top + 20
});
2013-03-29 07:12:14 -07:00
}
else {
play();
}
2013-04-10 14:14:25 -07:00
});
2013-03-28 22:51:45 -07:00
2013-04-14 08:14:10 -07:00
$('#btnQueueMenu', page).on('click', function () {
var pos = $('#queueMenuAnchor', page).offset();
2013-04-14 08:14:10 -07:00
$('#queueMenu', page).popup("open", {
x: pos.left + 165,
y: pos.top + 20
});
});
2013-04-10 14:14:25 -07:00
$('#btnPlay', page).on('click', function () {
2013-03-28 22:51:45 -07:00
2013-04-10 14:14:25 -07:00
$('#playMenu', page).popup("close");
play();
});
2013-03-28 22:51:45 -07:00
2013-04-10 14:14:25 -07:00
$('#btnResume', page).on('click', function () {
2013-03-29 07:12:14 -07:00
2013-04-10 14:14:25 -07:00
$('#playMenu', page).popup("close");
2013-03-28 22:51:45 -07:00
2013-04-10 14:14:25 -07:00
var userdata = currentItem.UserData || {};
2013-04-14 08:14:10 -07:00
2013-04-10 14:14:25 -07:00
play(userdata.PlaybackPositionTicks);
});
2013-03-29 07:12:14 -07:00
2013-04-14 08:14:10 -07:00
$('#btnQueue', page).on('click', function () {
2013-04-14 08:14:10 -07:00
$('#queueMenu', page).popup("close");
Playlist.add(currentItem);
});
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-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-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-28 10:21:56 -07:00
self.playById = function (id) {
ApiClient.getItem(Dashboard.getCurrentUserId(), id).done(function (item) {
MediaPlayer.play([item]);
2013-04-10 14:14:25 -07:00
});
};
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);