(function ($, document, LibraryBrowser, window) { var currentItem; function reload(page) { var id = getParameterByName('id'); Dashboard.showLoadingMsg(); ApiClient.getItem(Dashboard.getCurrentUserId(), id).done(function (item) { currentItem = item; renderHeader(page, item); $('#itemImage', page).html(LibraryBrowser.getDetailImageHtml(item)); LibraryBrowser.renderTitle(item, $('#itemName', page), $('#parentName', page), $('#grandParentName', page)); var context = getContext(item); setInitialCollapsibleState(page, item, context); renderDetails(page, item, context); if (MediaPlayer.canPlay(item)) { $('#playButtonContainer', page).show(); } else { $('#playButtonContainer', page).hide(); } Dashboard.getCurrentUser().done(function (user) { if (user.Configuration.IsAdministrator) { $('#editButtonContainer', page).show(); } else { $('#editButtonContainer', page).hide(); } }); $(".autoNumeric").autoNumeric('init'); Dashboard.hideLoadingMsg(); }); } function getContext(item) { // should return either movies, tv, music or games 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 ""; } 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(); } else if (item.Type == "Audio" || item.Type == "MusicAlbum") { enableCustomHeader(page, "Music"); $('#standardLogo', page).hide(); } else if (item.MediaType == "Game" || item.Type == "GamePlatform") { enableCustomHeader(page, "Games"); $('#standardLogo', page).hide(); } else { $('.libraryPageHeader', page).hide(); $('#standardLogo', page).show(); } $('.itemTabs', page).hide(); if (item.Type == "MusicAlbum") { $('#albumTabs', page).show(); } if (item.Type == "Audio") { $('#songTabs', page).show(); } if (item.Type == "Movie") { $('#movieTabs', page).show(); } if (item.MediaType == "Game") { $('#gameTabs', page).show(); } if (item.Type == "GamePlatform") { $('#gameSystemTabs', page).show(); } if (item.Type == "BoxSet") { $('#boxsetTabs', page).show(); } if (item.Type == "Trailer") { $('#trailerTabs', page).show(); } if (item.Type == "Episode" || item.Type == "Season" || item.Type == "Series") { $('#tvShowsTabs', page).show(); } } function setInitialCollapsibleState(page, item, context) { if (item.ChildCount && item.Type == "MusicAlbum") { $('#itemSongs', page).show(); $('#childrenCollapsible', page).hide(); renderChildren(page, item); } else if (item.ChildCount) { $('#itemSongs', page).hide(); $('#childrenCollapsible', page).show(); renderChildren(page, item); } else { $('#itemSongs', page).hide(); $('#childrenCollapsible', page).hide(); } if (LibraryBrowser.shouldDisplayGallery(item)) { $('#galleryCollapsible', page).show(); renderGallery(page, item); } else { $('#galleryCollapsible', page).hide(); } if (!item.MediaStreams || !item.MediaStreams.length) { $('#mediaInfoCollapsible', page).hide(); } else { $('#mediaInfoCollapsible', page).show(); renderMediaInfo(page, item); } if (!item.Chapters || !item.Chapters.length) { $('#scenesCollapsible', page).hide(); } else { $('#scenesCollapsible', page).show(); renderScenes(page, item); } if (!item.LocalTrailerCount || item.LocalTrailerCount == 0) { $('#trailersCollapsible', page).hide(); } else { $('#trailersCollapsible', page).show(); renderTrailers(page, item); } if (!item.SpecialFeatureCount || item.SpecialFeatureCount == 0) { $('#specialsCollapsible', page).hide(); } else { $('#specialsCollapsible', page).show(); renderSpecials(page, item); } if (!item.People || !item.People.length) { $('#castCollapsible', page).hide(); } else { $('#castCollapsible', page).show(); renderCast(page, item, context); } $('#themeSongsCollapsible', page).hide(); $('#themeVideosCollapsible', page).hide(); ApiClient.getThemeSongs(Dashboard.getCurrentUserId(), item.Id).done(function (result) { renderThemeSongs(page, item, result); }); ApiClient.getThemeVideos(Dashboard.getCurrentUserId(), item.Id).done(function (result) { renderThemeVideos(page, item, result); }); } function renderDetails(page, item, context) { if (item.Taglines && item.Taglines.length) { $('#itemTagline', page).html(item.Taglines[0]).show(); } else { $('#itemTagline', page).hide(); } LibraryBrowser.renderOverview($('#itemOverview', page), item); if (item.CommunityRating || item.CriticRating) { $('#itemCommunityRating', page).html(LibraryBrowser.getRatingHtml(item)).show(); } else { $('#itemCommunityRating', page).hide(); } if (item.Type != "Episode") { var premiereDateElem = $('#itemPremiereDate', page).show(); LibraryBrowser.renderPremiereDate(premiereDateElem, item); } else { $('#itemPremiereDate', page).hide(); } LibraryBrowser.renderBudget($('#itemBudget', page), item); LibraryBrowser.renderRevenue($('#itemRevenue', page), item); $('#itemMiscInfo', page).html(LibraryBrowser.getMiscInfoHtml(item)); LibraryBrowser.renderGenres($('#itemGenres', page), item, context); LibraryBrowser.renderStudios($('#itemStudios', page), item, context); renderUserDataIcons(page, item); LibraryBrowser.renderLinks($('#itemLinks', page), item); if (item.CriticRatingSummary) { $('#criticRatingSummary', page).show(); $('#criticRatingSummaryText', page).html(item.CriticRatingSummary); } else { $('#criticRatingSummary', page).hide(); } renderTags(page, item); } function renderTags(page, item) { if (item.Tags && item.Tags.length) { var html = ''; for (var i = 0, length = item.Tags.length; i < length; i++) { html += '
' + type + '
'; html += '