(function ($, document, window) {
var showOverlayTimeout;
function onHoverOut() {
if (showOverlayTimeout) {
clearTimeout(showOverlayTimeout);
showOverlayTimeout = null;
}
$('.cardOverlayTarget:visible', this).each(function () {
var elem = this;
$(this).animate({ "height": "0" }, "fast", function () {
$(elem).hide();
});
});
$('.cardOverlayTarget:visible', this).stop().animate({ "height": "0" }, function () {
$(this).hide();
});
}
function getOverlayHtml(item, currentUser, card, commands) {
var html = '';
html += '
';
var className = card.className.toLowerCase();
var isMiniItem = className.indexOf('mini') != -1;
var isSmallItem = isMiniItem || className.indexOf('small') != -1;
var isPortrait = className.indexOf('portrait') != -1;
var isSquare = className.indexOf('square') != -1;
var parentName = isSmallItem || isMiniItem || isPortrait ? null : item.SeriesName;
var name = LibraryBrowser.getPosterViewDisplayName(item, true);
html += '
';
var logoHeight = isSmallItem || isMiniItem ? 20 : 26;
var maxLogoWidth = isPortrait ? 100 : 200;
var imgUrl;
if (parentName && item.ParentLogoItemId) {
imgUrl = ApiClient.getScaledImageUrl(item.ParentLogoItemId, {
height: logoHeight,
type: 'logo',
tag: item.ParentLogoImageTag
});
html += '';
}
else if (item.ImageTags.Logo) {
imgUrl = ApiClient.getScaledImageUrl(item.Id, {
height: logoHeight,
type: 'logo',
tag: item.ImageTags.Logo
});
html += '';
}
else {
html += parentName || name;
}
html += '
';
if (parentName) {
html += '
';
html += name;
html += '
';
} else if (!isSmallItem && !isMiniItem) {
html += '
';
html += LibraryBrowser.getMiscInfoHtml(item);
html += '
';
}
if (!isMiniItem) {
html += '
';
if (isPortrait) {
html += '
';
html += LibraryBrowser.getRatingHtml(item, false);
html += '
';
html += '
';
html += LibraryBrowser.getUserDataIconsHtml(item);
html += '
';
} else {
html += '';
html += LibraryBrowser.getRatingHtml(item, false);
html += '';
html += '';
html += LibraryBrowser.getUserDataIconsHtml(item);
html += '';
}
html += '
';
}
html += '
';
var buttonMargin = isPortrait || isSquare ? "margin:0 4px 0 0;" : "margin:0 10px 0 0;";
var buttonCount = 0;
if (MediaController.canPlay(item)) {
var resumePosition = (item.UserData || {}).PlaybackPositionTicks || 0;
html += '';
buttonCount++;
}
if (commands.indexOf('trailer') != -1) {
html += '';
buttonCount++;
}
html += '';
buttonCount++;
html += '
';
html += '
';
return html;
}
function closeContextMenu() {
// Used by the tab menu, not the slide up
$('.tapHoldMenu').popup('close');
}
function onTrailerButtonClick() {
var id = this.getAttribute('data-itemid');
ApiClient.getLocalTrailers(Dashboard.getCurrentUserId(), id).done(function (trailers) {
MediaController.play({ items: trailers });
});
closeContextMenu();
return false;
}
function onPlayItemButtonClick() {
var id = this.getAttribute('data-itemid');
var type = this.getAttribute('data-itemtype');
var isFolder = this.getAttribute('data-isfolder') == 'true';
var mediaType = this.getAttribute('data-mediatype');
var resumePosition = parseInt(this.getAttribute('data-resumeposition'));
closeContextMenu();
LibraryBrowser.showPlayMenu(this, id, type, isFolder, mediaType, resumePosition);
return false;
}
function onMoreButtonClick() {
var card = $(this).parents('.card')[0];
closeContextMenu();
showContextMenu(card, {
showPlayOptions: false
});
return false;
}
function onAddToPlaylistButtonClick() {
var id = this.getAttribute('data-itemid');
closeContextMenu();
PlaylistManager.showPanel([id]);
return false;
}
function onShuffleButtonClick() {
var id = this.getAttribute('data-itemid');
MediaController.shuffle(id);
closeContextMenu();
return false;
}
function onInstantMixButtonClick() {
var id = this.getAttribute('data-itemid');
MediaController.instantMix(id);
closeContextMenu();
return false;
}
function onQueueButtonClick() {
var id = this.getAttribute('data-itemid');
MediaController.queue(id);
closeContextMenu();
return false;
}
function onPlayButtonClick() {
var id = this.getAttribute('data-itemid');
MediaController.play(id);
closeContextMenu();
return false;
}
function onDeleteButtonClick() {
var id = this.getAttribute('data-itemid');
closeContextMenu();
LibraryBrowser.deleteItem(id);
return false;
}
function onSyncButtonClick() {
var id = this.getAttribute('data-itemid');
closeContextMenu();
SyncManager.showMenu({
items: [
{
Id: id
}]
});
return false;
}
function onExternalPlayerButtonClick() {
closeContextMenu();
var id = this.getAttribute('data-itemid');
ExternalPlayer.showMenu(id);
return false;
}
function onPlayAllFromHereButtonClick() {
var index = this.getAttribute('data-index');
var page = $(this).parents('.page');
var itemsContainer = $('.hasContextMenu', page).parents('.itemsContainer');
closeContextMenu();
itemsContainer.trigger('playallfromhere', [index]);
return false;
}
function onQueueAllFromHereButtonClick() {
var index = this.getAttribute('data-index');
var page = $(this).parents('.page');
var itemsContainer = $('.hasContextMenu', page).parents('.itemsContainer');
closeContextMenu();
itemsContainer.trigger('queueallfromhere', [index]);
return false;
}
function onRemoveFromPlaylistButtonClick() {
var playlistItemId = this.getAttribute('data-playlistitemid');
var page = $(this).parents('.page');
var itemsContainer = $('.hasContextMenu', page).parents('.itemsContainer');
itemsContainer.trigger('removefromplaylist', [playlistItemId]);
closeContextMenu();
return false;
}
function onResumeButtonClick() {
var id = this.getAttribute('data-itemid');
MediaController.play({
ids: [id],
startPositionTicks: parseInt(this.getAttribute('data-ticks'))
});
closeContextMenu();
return false;
}
function onCardTapHold(e) {
showContextMenu(this, {});
e.preventDefault();
return false;
}
function showContextMenu(card, options) {
closeContextMenu();
var displayContextItem = card;
if ($(card).hasClass('listviewMenuButton')) {
card = $(card).parents('.listItem,.card')[0];
}
var itemId = card.getAttribute('data-itemid');
var playlistItemId = card.getAttribute('data-playlistitemid');
var commands = card.getAttribute('data-commands').split(',');
var itemType = card.getAttribute('data-itemtype');
var mediaType = card.getAttribute('data-mediatype');
var playbackPositionTicks = parseInt(card.getAttribute('data-positionticks') || '0');
var playAccess = card.getAttribute('data-playaccess');
var locationType = card.getAttribute('data-locationtype');
var isPlaceHolder = card.getAttribute('data-placeholder') == 'true';
var index = card.getAttribute('data-index');
$(card).addClass('hasContextMenu');
Dashboard.getCurrentUser().done(function (user) {
var html = '
';
html += '
';
html += '
' + Globalize.translate('HeaderMenu') + '
';
var href = card.getAttribute('data-href') || card.href || $('a', card).attr('href');
if (commands.indexOf('playlist') != -1) {
html += '