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

820 lines
25 KiB
JavaScript
Raw Normal View History

2013-02-20 18:33:05 -07:00
var ItemDetailPage = {
onPageShow: function () {
2013-03-05 23:22:19 -07:00
ItemDetailPage.reload();
2013-03-06 16:28:43 -07:00
2013-03-26 16:57:18 -07:00
$('#mediaInfoCollapsible', this).on('expand', ItemDetailPage.onMediaInfoExpand);
2013-03-26 15:53:06 -07:00
$('#scenesCollapsible', this).on('expand', ItemDetailPage.onScenesExpand);
$('#specialsCollapsible', this).on('expand', ItemDetailPage.onSpecialsExpand);
$('#trailersCollapsible', this).on('expand', ItemDetailPage.onTrailersExpand);
2013-03-26 22:20:46 -07:00
$('#castCollapsible', this).on('expand', ItemDetailPage.onCastExpand);
2013-03-06 16:28:43 -07:00
$('#galleryCollapsible', this).on('expand', ItemDetailPage.onGalleryExpand);
2013-03-05 23:22:19 -07:00
},
2013-03-26 14:32:01 -07:00
2013-03-06 16:28:43 -07:00
onPageHide: function () {
2013-03-26 16:57:18 -07:00
$('#mediaInfoCollapsible', this).off('expand', ItemDetailPage.onMediaInfoExpand);
2013-03-26 15:53:06 -07:00
$('#scenesCollapsible', this).off('expand', ItemDetailPage.onScenesExpand);
$('#specialsCollapsible', this).off('expand', ItemDetailPage.onSpecialsExpand);
$('#trailersCollapsible', this).off('expand', ItemDetailPage.onTrailersExpand);
2013-03-26 22:20:46 -07:00
$('#castCollapsible', this).off('expand', ItemDetailPage.onCastExpand);
2013-03-06 16:28:43 -07:00
$('#galleryCollapsible', this).off('expand', ItemDetailPage.onGalleryExpand);
ItemDetailPage.item = null;
},
reload: function () {
2013-02-20 18:33:05 -07:00
var id = getParameterByName('id');
Dashboard.showLoadingMsg();
ApiClient.getItem(Dashboard.getCurrentUserId(), id).done(ItemDetailPage.renderItem);
},
renderItem: function (item) {
2013-03-06 16:28:43 -07:00
ItemDetailPage.item = item;
2013-02-20 18:33:05 -07:00
var page = $.mobile.activePage;
ItemDetailPage.item = item;
var name = item.Name;
2013-03-26 14:32:01 -07:00
2013-02-20 18:33:05 -07:00
if (item.IndexNumber != null) {
name = item.IndexNumber + " - " + name;
}
2013-03-26 15:53:06 -07:00
if (item.ParentIndexNumber != null) {
name = item.ParentIndexNumber + "." + name;
}
2013-02-20 18:33:05 -07:00
Dashboard.setPageTitle(name);
ItemDetailPage.renderImage(item);
ItemDetailPage.renderOverviewBlock(item);
ItemDetailPage.renderGallery(item);
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();
}
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();
}
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();
}
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-03-26 22:20:46 -07:00
if (!item.People || !item.People.length) {
$('#castCollapsible', page).hide();
} else {
$('#castCollapsible', page).show();
}
2013-02-20 18:33:05 -07:00
$('#itemName', page).html(name);
2013-03-26 15:53:06 -07:00
if (item.SeriesName || item.Album) {
var series_name = item.SeriesName || item.Album;
$('#seriesName', page).html(series_name).show();
}
2013-03-28 22:51:45 -07:00
ItemDetailPage.renderFav(item);
2013-04-09 11:38:58 -07:00
LibraryBrowser.renderLinks(item);
2013-03-28 22:51:45 -07:00
2013-02-20 18:33:05 -07:00
Dashboard.hideLoadingMsg();
},
renderImage: function (item) {
var page = $.mobile.activePage;
var imageTags = item.ImageTags || {};
var html = '';
var url;
var useBackgroundColor;
if (imageTags.Primary) {
url = ApiClient.getImageUrl(item.Id, {
type: "Primary",
width: 800,
tag: item.ImageTags.Primary
});
}
else if (item.BackdropImageTags && item.BackdropImageTags.length) {
url = ApiClient.getImageUrl(item.Id, {
type: "Backdrop",
width: 800,
tag: item.BackdropImageTags[0]
});
}
else if (imageTags.Thumb) {
url = ApiClient.getImageUrl(item.Id, {
type: "Thumb",
width: 800,
tag: item.ImageTags.Thumb
});
}
else if (imageTags.Disc) {
url = ApiClient.getImageUrl(item.Id, {
type: "Disc",
width: 800,
tag: item.ImageTags.Disc
});
}
else if (item.MediaType == "Audio") {
2013-03-26 10:04:50 -07:00
url = "css/images/items/detail/audio.png";
2013-02-20 18:33:05 -07:00
useBackgroundColor = true;
}
else if (item.MediaType == "Game") {
2013-03-26 10:04:50 -07:00
url = "css/images/items/detail/game.png";
2013-02-20 18:33:05 -07:00
useBackgroundColor = true;
}
else {
2013-03-26 10:04:50 -07:00
url = "css/images/items/detail/video.png";
2013-02-20 18:33:05 -07:00
useBackgroundColor = true;
}
if (url) {
2013-04-01 22:14:37 -07:00
var style = useBackgroundColor ? "background-color:" + LibraryBrowser.getMetroColor(item.Id) + ";" : "";
2013-02-20 18:33:05 -07:00
html += "<img class='itemDetailImage' src='" + url + "' style='" + style + "' />";
}
$('#itemImage', page).html(html);
},
renderOverviewBlock: function (item) {
2013-03-26 16:57:18 -07:00
2013-02-20 18:33:05 -07:00
var page = $.mobile.activePage;
if (item.Taglines && item.Taglines.length) {
$('#itemTagline', page).html(item.Taglines[0]).show();
} else {
$('#itemTagline', page).hide();
}
2013-03-26 15:53:06 -07:00
if (item.Overview || item.OverviewHtml) {
var overview = item.OverviewHtml || item.Overview;
$('#itemOverview', page).html(overview).show();
2013-03-29 07:12:14 -07:00
$('#itemOverview a').each(function () {
$(this).attr("target", "_blank");
2013-03-26 15:53:06 -07:00
});
2013-02-20 18:33:05 -07:00
} else {
$('#itemOverview', page).hide();
}
if (item.CommunityRating) {
$('#itemCommunityRating', page).html(ItemDetailPage.getStarRating(item)).show().attr('title', item.CommunityRating);
} else {
$('#itemCommunityRating', page).hide();
}
if (MediaPlayer.canPlay(item)) {
$('#btnPlay', page).show();
$('#playButtonShadow', page).show();
} else {
$('#btnPlay', page).hide();
$('#playButtonShadow', page).hide();
}
var miscInfo = [];
if (item.ProductionYear) {
miscInfo.push(item.ProductionYear);
}
if (item.OfficialRating) {
miscInfo.push(item.OfficialRating);
}
if (item.RunTimeTicks) {
var minutes = item.RunTimeTicks / 600000000;
minutes = minutes || 1;
miscInfo.push(parseInt(minutes) + "min");
}
if (item.DisplayMediaType) {
miscInfo.push(item.DisplayMediaType);
}
if (item.VideoFormat && item.VideoFormat !== 'Standard') {
miscInfo.push(item.VideoFormat);
}
$('#itemMiscInfo', page).html(miscInfo.join('&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'));
ItemDetailPage.renderGenres(item);
ItemDetailPage.renderStudios(item);
},
renderGenres: function (item) {
var page = $.mobile.activePage;
if (item.Genres && item.Genres.length) {
var elem = $('#itemGenres', page).show();
var html = 'Genres:&nbsp;&nbsp;';
for (var i = 0, length = item.Genres.length; i < length; i++) {
if (i > 0) {
html += '&nbsp;&nbsp;/&nbsp;&nbsp;';
}
2013-03-29 07:12:14 -07:00
html += '<a href="itembynamedetails.html?genre=' + item.Genres[i] + '">' + item.Genres[i] + '</a>';
2013-02-20 18:33:05 -07:00
}
2013-03-26 20:04:51 -07:00
elem.html(html).trigger('create');
2013-02-20 18:33:05 -07:00
} else {
$('#itemGenres', page).hide();
}
},
renderStudios: function (item) {
var page = $.mobile.activePage;
if (item.Studios && item.Studios.length) {
var elem = $('#itemStudios', page).show();
var html = 'Studios:&nbsp;&nbsp;';
for (var i = 0, length = item.Studios.length; i < length; i++) {
if (i > 0) {
html += '&nbsp;&nbsp;/&nbsp;&nbsp;';
}
2013-03-29 07:12:14 -07:00
html += '<a href="itembynamedetails.html?studio=' + item.Studios[i] + '">' + item.Studios[i] + '</a>';
2013-02-20 18:33:05 -07:00
}
2013-03-26 20:04:51 -07:00
elem.html(html).trigger('create');
2013-02-20 18:33:05 -07:00
} else {
$('#itemStudios', page).hide();
}
},
getStarRating: function (item) {
var rating = item.CommunityRating;
var html = "";
for (var i = 1; i <= 10; i++) {
if (rating < i - 1) {
html += "<div class='starRating emptyStarRating'></div>";
}
else if (rating < i) {
html += "<div class='starRating halfStarRating'></div>";
}
else {
html += "<div class='starRating'></div>";
}
}
return html;
},
2013-03-26 14:32:01 -07:00
onScenesExpand: function () {
if (ItemDetailPage.item) {
ItemDetailPage.renderScenes(ItemDetailPage.item);
$(this).off('expand', ItemDetailPage.onScenesExpand);
}
},
2013-02-20 18:33:05 -07:00
renderScenes: function (item) {
var html = '';
var page = $.mobile.activePage;
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-03-26 14:32:01 -07:00
var chapter_name = chapter.Name || "Chapter " + i;
html += '<div class="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, {
width: 500,
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
html += '<div class="posterViewItemText posterViewItemPrimaryText">' + chapter_name + '</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);
},
play: function (startPosition) {
MediaPlayer.play([ItemDetailPage.item], startPosition);
2013-02-20 18:33:05 -07:00
},
2013-03-26 14:32:01 -07:00
onGalleryExpand: function () {
2013-03-06 16:28:43 -07:00
if (ItemDetailPage.item) {
ItemDetailPage.renderGallery(ItemDetailPage.item);
$(this).off('expand', ItemDetailPage.onGalleryExpand);
}
},
2013-02-20 18:33:05 -07:00
renderGallery: function (item) {
var page = $.mobile.activePage;
var imageTags = item.ImageTags || {};
var html = '';
if (imageTags.Logo) {
2013-03-26 08:26:29 -07:00
html += ItemDetailPage.createGalleryImage(item.Id, "Logo", item.ImageTags.Logo);
2013-02-20 18:33:05 -07:00
}
if (imageTags.Thumb) {
2013-03-26 08:26:29 -07:00
html += ItemDetailPage.createGalleryImage(item.Id, "Thumb", item.ImageTags.Thumb);
2013-02-20 18:33:05 -07:00
}
if (imageTags.Art) {
2013-03-26 08:26:29 -07:00
html += ItemDetailPage.createGalleryImage(item.Id, "Art", item.ImageTags.Art);
2013-02-20 18:33:05 -07:00
}
if (imageTags.Menu) {
2013-03-26 08:26:29 -07:00
html += ItemDetailPage.createGalleryImage(item.Id, "Menu", item.ImageTags.Menu);
2013-02-20 18:33:05 -07:00
}
if (imageTags.Disc) {
2013-03-26 08:26:29 -07:00
html += ItemDetailPage.createGalleryImage(item.Id, "Disc", item.ImageTags.Disc);
2013-02-20 18:33:05 -07:00
}
if (imageTags.Box) {
2013-03-26 08:26:29 -07:00
html += ItemDetailPage.createGalleryImage(item.Id, "Box", item.ImageTags.Box);
2013-02-20 18:33:05 -07:00
}
if (item.BackdropImageTags) {
for (var i = 0, length = item.BackdropImageTags.length; i < length; i++) {
html += ItemDetailPage.createGalleryImage(item.Id, "Backdrop", item.BackdropImageTags[0], i);
2013-02-20 18:33:05 -07:00
}
}
$('#galleryContent', page).html(html).trigger('create');
},
2013-03-26 14:32:01 -07:00
createGalleryImage: function (itemId, type, tag, index) {
var downloadWidth = 400;
var lightboxWidth = 800;
var html = '';
2013-03-26 14:32:01 -07:00
if (typeof (index) == "undefined") index = 0;
html += '<div class="posterViewItem" style="padding-bottom:0px;">';
2013-03-26 14:32:01 -07:00
html += '<a href="#pop_' + index + '_' + tag + '" data-transition="fade" data-rel="popup" data-position-to="window">';
2013-03-26 08:26:29 -07:00
html += '<img class="galleryImage" src="' + ApiClient.getImageUrl(itemId, {
type: type,
2013-03-27 19:20:48 -07:00
maxwidth: downloadWidth,
tag: tag,
index: index
}) + '" />';
html += '</div>';
2013-03-26 14:32:01 -07:00
html += '<div class="galleryPopup" id="pop_' + index + '_' + tag + '" data-role="popup" data-theme="d" data-corners="false" data-overlay-theme="a">';
html += '<a href="#" data-rel="back" data-role="button" data-theme="a" data-icon="delete" data-iconpos="notext" class="ui-btn-right">Close</a>';
2013-03-26 08:26:29 -07:00
html += '<img class="" src="' + ApiClient.getImageUrl(itemId, {
type: type,
2013-03-26 15:53:06 -07:00
maxwidth: lightboxWidth,
tag: tag,
index: index
}) + '" />';
html += '</div>';
return html;
2013-02-20 18:33:05 -07:00
},
2013-03-26 14:32:01 -07:00
2013-03-26 16:57:18 -07:00
onMediaInfoExpand: function () {
if (ItemDetailPage.item) {
ItemDetailPage.renderMediaInfo(ItemDetailPage.item);
$(this).off('expand', ItemDetailPage.onMediaInfoExpand);
}
},
2013-03-26 14:32:01 -07:00
renderMediaInfo: function (item) {
2013-02-20 18:33:05 -07:00
var page = $.mobile.activePage;
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>';
html += '<ul class="mediaInfoDetails">';
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>';
}
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 11:38:58 -07:00
var framerate = stream.AverageFrameRate || stream.RealFrameRate;
if (framerate) {
html += '<li><span class="mediaInfoLabel">Framerate</span> ' + framerate + '</li>';
}
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-09 11:38:58 -07:00
2013-02-20 18:33:05 -07:00
$('#mediaInfoCollapsible', page).show();
},
playTrailer: function (index) {
ApiClient.getLocalTrailers(Dashboard.getCurrentUserId(), ItemDetailPage.item.Id).done(function (trailers) {
MediaPlayer.play([trailers[index]]);
});
},
2013-03-26 14:32:01 -07:00
onTrailersExpand: function () {
if (ItemDetailPage.item) {
ItemDetailPage.renderTrailers(ItemDetailPage.item);
$(this).off('expand', ItemDetailPage.onTrailersExpand);
}
},
renderTrailers: function (item) {
var html = '';
var page = $.mobile.activePage;
ApiClient.getLocalTrailers(Dashboard.getCurrentUserId(), item.Id).done(function (trailers) {
for (var i = 0, length = trailers.length; i < length; i++) {
2013-03-26 14:32:01 -07:00
var trailer = trailers[i];
2013-03-26 14:32:01 -07:00
html += '<div class="posterViewItem posterViewItemWithDualText">';
html += '<a href="#play-Trailer-' + i + '" onclick="ItemDetailPage.playTrailer(' + i + ');">';
2013-03-26 14:32:01 -07:00
var imageTags = trailer.ImageTags || {};
2013-03-29 07:12:14 -07:00
2013-03-26 14:32:01 -07:00
if (imageTags.Primary) {
2013-03-26 14:32:01 -07:00
var imgUrl = ApiClient.getImageUrl(trailer.Id, {
maxwidth: 500,
tag: imageTags.Primary,
type: "primary"
});
2013-03-26 14:32:01 -07:00
html += '<img src="' + imgUrl + '" />';
} else {
html += '<img src="css/images/items/detail/video.png"/>';
}
2013-03-26 14:32:01 -07:00
html += '<div class="posterViewItemText posterViewItemPrimaryText">' + trailer.Name + '</div>';
html += '<div class="posterViewItemText">';
2013-03-26 14:32:01 -07:00
if (trailer.RunTimeTicks != "") {
html += ticks_to_human(trailer.RunTimeTicks);
2013-03-26 14:32:01 -07:00
}
else {
html += "&nbsp;";
2013-03-26 14:32:01 -07:00
}
html += '</div>';
2013-03-26 14:32:01 -07:00
html += '</a>';
2013-03-26 14:32:01 -07:00
html += '</div>';
}
$('#trailersContent', page).html(html);
});
},
playSpecial: function (index) {
ApiClient.getSpecialFeatures(Dashboard.getCurrentUserId(), ItemDetailPage.item.Id).done(function (specials) {
MediaPlayer.play([specials[index]]);
});
},
2013-03-26 14:32:01 -07:00
onSpecialsExpand: function () {
if (ItemDetailPage.item) {
ItemDetailPage.renderSpecials(ItemDetailPage.item);
$(this).off('expand', ItemDetailPage.onSpecialsExpand);
}
},
renderSpecials: function (item) {
var html = '';
var page = $.mobile.activePage;
ApiClient.getSpecialFeatures(Dashboard.getCurrentUserId(), item.Id).done(function (specials) {
for (var i = 0, length = specials.length; i < length; i++) {
var special = specials[i];
html += '<div class="posterViewItem posterViewItemWithDualText">';
2013-03-26 14:32:01 -07:00
html += '<a href="#play-Special-' + i + '" onclick="ItemDetailPage.playSpecial(' + i + ');">';
2013-03-26 14:32:01 -07:00
var imageTags = special.ImageTags || {};
2013-03-26 14:32:01 -07:00
if (imageTags.Primary) {
var imgUrl = ApiClient.getImageUrl(special.Id, {
maxwidth: 500,
tag: imageTags.Primary,
type: "primary"
});
html += '<img src="' + imgUrl + '" />';
} else {
2013-03-26 14:32:01 -07:00
html += '<img src="css/images/items/detail/video.png"/>';
}
html += '<div class="posterViewItemText posterViewItemPrimaryText">' + special.Name + '</div>';
html += '<div class="posterViewItemText">';
if (special.RunTimeTicks != "") {
html += ticks_to_human(special.RunTimeTicks);
}
else {
html += "&nbsp;";
}
html += '</div>';
html += '</a>';
html += '</div>';
}
$('#specialsContent', page).html(html);
});
2013-03-26 22:20:46 -07:00
},
onCastExpand: function () {
if (ItemDetailPage.item) {
ItemDetailPage.renderCast(ItemDetailPage.item);
$(this).off('expand', ItemDetailPage.onCastExpand);
}
},
renderCast: function (item) {
var html = '';
var page = $.mobile.activePage;
var casts = item.People || {};
for (var i = 0, length = casts.length; i < length; i++) {
var cast = casts[i];
var role = cast.Role || cast.Type;
2013-03-29 07:12:14 -07:00
html += '<a href="itembynamedetails.html?person=' + cast.Name + '">';
2013-03-26 22:20:46 -07:00
html += '<div class="posterViewItem posterViewItemWithDualText">';
if (cast.PrimaryImageTag) {
var imgUrl = ApiClient.getPersonImageUrl(cast.Name, {
2013-03-27 05:42:06 -07:00
width: 185,
2013-03-26 22:20:46 -07:00
tag: cast.PrimaryImageTag,
type: "primary"
});
html += '<img src="' + imgUrl + '" />';
} else {
2013-04-01 22:14:37 -07:00
var style = "background-color:" + LibraryBrowser.getMetroColor(cast.Name) + ";";
2013-04-09 11:38:58 -07:00
html += '<img src="css/images/items/list/person.png" style="max-width:185px; ' + style + '"/>';
2013-03-26 22:20:46 -07:00
}
html += '<div class="posterViewItemText posterViewItemPrimaryText">' + cast.Name + '</div>';
html += '<div class="posterViewItemText">' + role + '</div>';
2013-03-27 21:27:15 -07:00
html += '</div></a>';
2013-03-26 22:20:46 -07:00
}
$('#castContent', page).html(html);
2013-03-28 22:51:45 -07:00
},
renderFav: function (item) {
var html = '';
var page = $.mobile.activePage;
2013-03-29 07:12:14 -07:00
var userData = item.UserData || {};
2013-04-04 10:27:36 -07:00
//played/unplayed
if (userData.Played) {
2013-04-04 21:15:00 -07:00
html += '<img class="imgUserItemRating" src="css/images/userdata/played.png" alt="Played" title="Played" onclick="ItemDetailPage.setPlayed();" />';
2013-04-04 10:27:36 -07:00
} else {
2013-04-04 21:15:00 -07:00
html += '<img class="imgUserItemRating" src="css/images/userdata/unplayed.png" alt="Played" title="Played" onclick="ItemDetailPage.setPlayed();" />';
2013-04-04 10:27:36 -07:00
}
2013-03-29 07:12:14 -07:00
if (typeof userData.Likes == "undefined") {
2013-04-04 21:15:00 -07:00
html += '<img class="imgUserItemRating" src="css/images/userdata/thumbs_down_off.png" alt="Dislike" title="Dislike" onclick="ItemDetailPage.setDislike();" />';
html += '<img class="imgUserItemRating" src="css/images/userdata/thumbs_up_off.png" alt="Like" title="Like" onclick="ItemDetailPage.setLike();" />';
2013-03-29 07:12:14 -07:00
} else if (userData.Likes) {
2013-04-04 21:15:00 -07:00
html += '<img class="imgUserItemRating" src="css/images/userdata/thumbs_down_off.png" alt="Dislike" title="Dislike" onclick="ItemDetailPage.setDislike();" />';
html += '<img class="imgUserItemRating" src="css/images/userdata/thumbs_up_on.png" alt="Liked" title="Like" onclick="ItemDetailPage.clearLike();" />';
2013-03-28 22:51:45 -07:00
} else {
2013-04-04 21:15:00 -07:00
html += '<img class="imgUserItemRating" src="css/images/userdata/thumbs_down_on.png" alt="Dislike" title="Dislike" onclick="ItemDetailPage.clearLike();" />';
html += '<img class="imgUserItemRating" src="css/images/userdata/thumbs_up_off.png" alt="Like" title="Like" onclick="ItemDetailPage.setLike();" />';
2013-03-28 22:51:45 -07:00
}
2013-03-29 07:12:14 -07:00
if (userData.IsFavorite) {
2013-04-04 21:15:00 -07:00
html += '<img class="imgUserItemRating" src="css/images/userdata/heart_on.png" alt="Favorite" title="Favorite" onclick="ItemDetailPage.setFavorite();" />';
2013-03-29 07:12:14 -07:00
} else {
2013-04-04 21:15:00 -07:00
html += '<img class="imgUserItemRating" src="css/images/userdata/heart_off.png" alt="Favorite" title="Favorite" onclick="ItemDetailPage.setFavorite();" />';
2013-03-28 22:51:45 -07:00
}
2013-03-29 07:12:14 -07:00
$('#itemRatings', page).html(html);
2013-03-28 22:51:45 -07:00
},
setFavorite: function () {
var item = ItemDetailPage.item;
2013-03-29 07:12:14 -07:00
item.UserData = item.UserData || {};
2013-03-28 22:51:45 -07:00
var setting = !item.UserData.IsFavorite;
item.UserData.IsFavorite = setting;
ApiClient.updateFavoriteStatus(Dashboard.getCurrentUserId(), item.Id, setting);
ItemDetailPage.renderFav(item);
},
setLike: function () {
2013-03-29 07:12:14 -07:00
2013-03-28 22:51:45 -07:00
var item = ItemDetailPage.item;
2013-03-29 07:12:14 -07:00
item.UserData = item.UserData || {};
2013-03-28 22:51:45 -07:00
item.UserData.Likes = true;
ApiClient.updateUserItemRating(Dashboard.getCurrentUserId(), item.Id, true);
ItemDetailPage.renderFav(item);
},
clearLike: function () {
2013-03-29 07:12:14 -07:00
2013-03-28 22:51:45 -07:00
var item = ItemDetailPage.item;
2013-03-29 07:12:14 -07:00
item.UserData = item.UserData || {};
item.UserData.Likes = undefined;
2013-03-28 22:51:45 -07:00
ApiClient.clearUserItemRating(Dashboard.getCurrentUserId(), item.Id);
ItemDetailPage.renderFav(item);
},
setDislike: function () {
var item = ItemDetailPage.item;
2013-03-29 07:12:14 -07:00
item.UserData = item.UserData || {};
2013-03-28 22:51:45 -07:00
item.UserData.Likes = false;
ApiClient.updateUserItemRating(Dashboard.getCurrentUserId(), item.Id, false);
ItemDetailPage.renderFav(item);
},
2013-04-09 11:38:58 -07:00
setPlayed: function () {
var item = ItemDetailPage.item;
2013-04-09 11:38:58 -07:00
item.UserData = item.UserData || {};
2013-04-09 11:38:58 -07:00
var setting = !item.UserData.Played;
item.UserData.Played = setting;
2013-04-09 11:38:58 -07:00
ApiClient.updatePlayedStatus(Dashboard.getCurrentUserId(), item.Id, setting);
2013-04-09 11:38:58 -07:00
ItemDetailPage.renderFav(item);
}
2013-03-28 22:51:45 -07:00
2013-02-20 18:33:05 -07:00
};
2013-03-06 16:28:43 -07:00
$(document).on('pageshow', "#itemDetailPage", ItemDetailPage.onPageShow).on('pagehide', "#itemDetailPage", ItemDetailPage.onPageHide);