(function ($, document, window) {
var showOverlayTimeout;
function onHoverOut() {
if (showOverlayTimeout) {
clearTimeout(showOverlayTimeout);
showOverlayTimeout = null;
}
$('.posterItemOverlayTarget:visible', this).each(function () {
var elem = this;
$(this).animate({ "height": "0" }, "fast", function () {
$(elem).hide();
});
});
$('.posterItemOverlayTarget:visible', this).stop().animate({ "height": "0" }, function () {
$(this).hide();
});
}
function getOverlayHtml(item, currentUser, posterItem, commands) {
var html = '';
html += '
';
var isSmallItem = $(posterItem).hasClass('smallBackdropPosterItem') || $(posterItem).hasClass('miniBackdropPosterItem');
var isMiniItem = $(posterItem).hasClass('miniBackdropPosterItem');
var isPortrait = $(posterItem).hasClass('portraitPosterItem');
var isSquare = $(posterItem).hasClass('squarePosterItem');
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 += '
';
html += '';
html += LibraryBrowser.getRatingHtml(item, false);
html += '';
if (isPortrait) {
html += '';
html += LibraryBrowser.getUserDataIconsHtml(item);
html += '';
} else {
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;
var onPlayClick = 'LibraryBrowser.showPlayMenu(this, \'' + item.Id + '\', \'' + item.Type + '\', ' + item.IsFolder + ', \'' + item.MediaType + '\', ' + resumePosition + ');return false;';
html += '';
buttonCount++;
}
if (commands.indexOf('trailer') != -1) {
html += '';
buttonCount++;
}
if (currentUser.Configuration.IsAdministrator && commands.indexOf('edit') != -1) {
html += '' + Globalize.translate('ButtonEdit') + '';
buttonCount++;
}
html += '
';
html += '
';
return html;
}
function onTrailerButtonClick() {
var id = this.getAttribute('data-itemid');
ApiClient.getLocalTrailers(Dashboard.getCurrentUserId(), id).done(function (trailers) {
MediaController.play({ items: trailers });
});
// Used by the tab menu, not the slide up
$('.tapHoldMenu').popup('close');
return false;
}
function onShuffleButtonClick() {
var id = this.getAttribute('data-itemid');
MediaController.shuffle(id);
// Used by the tab menu, not the slide up
$('.tapHoldMenu').popup('close');
return false;
}
function onInstantMixButtonClick() {
var id = this.getAttribute('data-itemid');
MediaController.instantMix(id);
// Used by the tab menu, not the slide up
$('.tapHoldMenu').popup('close');
return false;
}
function onQueueButtonClick() {
var id = this.getAttribute('data-itemid');
MediaController.queue(id);
// Used by the tab menu, not the slide up
$('.tapHoldMenu').popup('close');
return false;
}
function onPlayButtonClick() {
var id = this.getAttribute('data-itemid');
MediaController.play(id);
// Used by the tab menu, not the slide up
$('.tapHoldMenu').popup('close');
return false;
}
function onResumeButtonClick() {
var id = this.getAttribute('data-itemid');
MediaController.play({
ids: [id],
startPositionTicks: parseInt(this.getAttribute('data-ticks'))
});
// Used by the tab menu, not the slide up
$('.tapHoldMenu').popup('close');
return false;
}
function onPosterItemTapHold(e) {
showContextMenu(this);
e.preventDefault();
return false;
}
function showContextMenu(posterItem) {
$('.tapHoldMenu').popup("close").remove();
var itemId = posterItem.getAttribute('data-itemid');
var commands = posterItem.getAttribute('data-commands').split(',');
$(posterItem).addClass('hasContextMenu');
var promise1 = ApiClient.getItem(Dashboard.getCurrentUserId(), itemId);
var promise2 = Dashboard.getCurrentUser();
$.when(promise1, promise2).done(function (response1, response2) {
var item = response1[0];
var user = response2[0];
var html = '
';
html += '
';
html += '
' + Globalize.translate('HeaderMenu') + '
';
var href = posterItem.getAttribute('data-href') || posterItem.href;
html += '