2014-03-17 07:48:16 -07:00
|
|
|
|
(function ($, document, window) {
|
|
|
|
|
|
|
|
|
|
var showOverlayTimeout;
|
|
|
|
|
|
|
|
|
|
function onHoverOut() {
|
|
|
|
|
|
|
|
|
|
if (showOverlayTimeout) {
|
|
|
|
|
clearTimeout(showOverlayTimeout);
|
|
|
|
|
showOverlayTimeout = null;
|
|
|
|
|
}
|
|
|
|
|
|
2014-08-01 19:34:45 -07:00
|
|
|
|
$('.cardOverlayTarget:visible', this).each(function () {
|
2014-03-17 07:48:16 -07:00
|
|
|
|
|
|
|
|
|
var elem = this;
|
|
|
|
|
|
|
|
|
|
$(this).animate({ "height": "0" }, "fast", function () {
|
|
|
|
|
|
|
|
|
|
$(elem).hide();
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
2014-08-01 19:34:45 -07:00
|
|
|
|
$('.cardOverlayTarget:visible', this).stop().animate({ "height": "0" }, function () {
|
2014-03-17 07:48:16 -07:00
|
|
|
|
|
|
|
|
|
$(this).hide();
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2014-08-01 19:34:45 -07:00
|
|
|
|
function getOverlayHtml(item, currentUser, card, commands) {
|
2014-03-17 07:48:16 -07:00
|
|
|
|
|
|
|
|
|
var html = '';
|
|
|
|
|
|
2014-08-01 19:34:45 -07:00
|
|
|
|
html += '<div class="cardOverlayInner">';
|
2014-03-17 07:48:16 -07:00
|
|
|
|
|
2014-08-01 19:34:45 -07:00
|
|
|
|
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;
|
2014-03-17 07:48:16 -07:00
|
|
|
|
|
2014-06-23 09:05:19 -07:00
|
|
|
|
var parentName = isSmallItem || isMiniItem || isPortrait ? null : item.SeriesName;
|
2014-03-17 07:48:16 -07:00
|
|
|
|
var name = LibraryBrowser.getPosterViewDisplayName(item, true);
|
|
|
|
|
|
2014-08-01 19:34:45 -07:00
|
|
|
|
html += '<div style="margin-bottom:1em;">';
|
2014-06-23 09:05:19 -07:00
|
|
|
|
var logoHeight = isSmallItem || isMiniItem ? 20 : 26;
|
2014-03-17 07:48:16 -07:00
|
|
|
|
var maxLogoWidth = isPortrait ? 100 : 200;
|
|
|
|
|
var imgUrl;
|
|
|
|
|
|
|
|
|
|
if (parentName && item.ParentLogoItemId) {
|
|
|
|
|
|
2014-05-23 16:58:28 -07:00
|
|
|
|
imgUrl = ApiClient.getScaledImageUrl(item.ParentLogoItemId, {
|
|
|
|
|
height: logoHeight,
|
2014-03-17 07:48:16 -07:00
|
|
|
|
type: 'logo',
|
|
|
|
|
tag: item.ParentLogoImageTag
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
html += '<img src="' + imgUrl + '" style="max-height:' + logoHeight + 'px;max-width:' + maxLogoWidth + 'px;" />';
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else if (item.ImageTags.Logo) {
|
|
|
|
|
|
2014-05-23 16:58:28 -07:00
|
|
|
|
imgUrl = ApiClient.getScaledImageUrl(item.Id, {
|
|
|
|
|
height: logoHeight,
|
|
|
|
|
type: 'logo',
|
|
|
|
|
tag: item.ImageTags.Logo
|
2014-03-17 07:48:16 -07:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
html += '<img src="' + imgUrl + '" style="max-height:' + logoHeight + 'px;max-width:' + maxLogoWidth + 'px;" />';
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
html += parentName || name;
|
|
|
|
|
}
|
|
|
|
|
html += '</div>';
|
|
|
|
|
|
|
|
|
|
if (parentName) {
|
|
|
|
|
html += '<p>';
|
|
|
|
|
html += name;
|
|
|
|
|
html += '</p>';
|
2014-06-23 09:05:19 -07:00
|
|
|
|
} else if (!isSmallItem && !isMiniItem) {
|
2014-03-17 07:48:16 -07:00
|
|
|
|
html += '<p class="itemMiscInfo" style="white-space:nowrap;">';
|
|
|
|
|
html += LibraryBrowser.getMiscInfoHtml(item);
|
|
|
|
|
html += '</p>';
|
|
|
|
|
}
|
|
|
|
|
|
2014-06-23 09:05:19 -07:00
|
|
|
|
if (!isMiniItem) {
|
|
|
|
|
html += '<div style="margin:1.25em 0;">';
|
|
|
|
|
html += '<span class="itemCommunityRating">';
|
|
|
|
|
html += LibraryBrowser.getRatingHtml(item, false);
|
2014-03-17 07:48:16 -07:00
|
|
|
|
html += '</span>';
|
2014-06-23 09:05:19 -07:00
|
|
|
|
|
|
|
|
|
if (isPortrait) {
|
|
|
|
|
html += '<span class="userDataIcons" style="display:block;margin:1.25em 0;">';
|
|
|
|
|
html += LibraryBrowser.getUserDataIconsHtml(item);
|
|
|
|
|
html += '</span>';
|
|
|
|
|
} else {
|
|
|
|
|
html += '<span class="userDataIcons">';
|
|
|
|
|
html += LibraryBrowser.getUserDataIconsHtml(item);
|
|
|
|
|
html += '</span>';
|
|
|
|
|
}
|
|
|
|
|
html += '</div>';
|
2014-03-17 07:48:16 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
html += '<div>';
|
|
|
|
|
|
|
|
|
|
var buttonMargin = isPortrait || isSquare ? "margin:0 4px 0 0;" : "margin:0 10px 0 0;";
|
|
|
|
|
|
|
|
|
|
var buttonCount = 0;
|
|
|
|
|
|
2014-03-29 08:40:32 -07:00
|
|
|
|
if (MediaController.canPlay(item)) {
|
2014-03-17 07:48:16 -07:00
|
|
|
|
|
|
|
|
|
var resumePosition = (item.UserData || {}).PlaybackPositionTicks || 0;
|
2014-03-29 08:40:32 -07:00
|
|
|
|
var onPlayClick = 'LibraryBrowser.showPlayMenu(this, \'' + item.Id + '\', \'' + item.Type + '\', ' + item.IsFolder + ', \'' + item.MediaType + '\', ' + resumePosition + ');return false;';
|
2014-03-17 07:48:16 -07:00
|
|
|
|
|
2014-05-30 12:23:56 -07:00
|
|
|
|
html += '<button type="button" data-mini="true" data-inline="true" data-icon="play" data-iconpos="notext" title="' + Globalize.translate('ButtonPlay') + '" onclick="' + onPlayClick + '" style="' + buttonMargin + '">' + Globalize.translate('ButtonPlay') + '</button>';
|
2014-03-17 07:48:16 -07:00
|
|
|
|
buttonCount++;
|
|
|
|
|
}
|
|
|
|
|
|
2014-06-30 19:29:27 -07:00
|
|
|
|
if (commands.indexOf('trailer') != -1) {
|
2014-05-30 12:23:56 -07:00
|
|
|
|
html += '<button type="button" data-mini="true" data-inline="true" data-icon="video" data-iconpos="notext" class="btnPlayTrailer" data-itemid="' + item.Id + '" title="' + Globalize.translate('ButtonPlayTrailer') + '" style="' + buttonMargin + '">' + Globalize.translate('ButtonPlayTrailer') + '</button>';
|
2014-03-17 07:48:16 -07:00
|
|
|
|
buttonCount++;
|
|
|
|
|
}
|
|
|
|
|
|
2014-06-30 19:29:27 -07:00
|
|
|
|
if (currentUser.Configuration.IsAdministrator && commands.indexOf('edit') != -1) {
|
2014-07-18 12:07:28 -07:00
|
|
|
|
html += '<a data-role="button" data-mini="true" data-inline="true" data-icon="edit" data-iconpos="notext" title="' + Globalize.translate('ButtonEdit') + '" href="edititemmetadata.html?id=' + item.Id + '" style="' + buttonMargin + '">' + Globalize.translate('ButtonEdit') + '</button>';
|
2014-03-17 07:48:16 -07:00
|
|
|
|
buttonCount++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
html += '</div>';
|
|
|
|
|
|
|
|
|
|
html += '</div>';
|
|
|
|
|
|
|
|
|
|
return html;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function onTrailerButtonClick() {
|
|
|
|
|
|
|
|
|
|
var id = this.getAttribute('data-itemid');
|
|
|
|
|
|
|
|
|
|
ApiClient.getLocalTrailers(Dashboard.getCurrentUserId(), id).done(function (trailers) {
|
2014-03-29 08:40:32 -07:00
|
|
|
|
MediaController.play({ items: trailers });
|
2014-03-17 07:48:16 -07:00
|
|
|
|
});
|
|
|
|
|
|
2014-06-30 19:29:27 -07:00
|
|
|
|
// Used by the tab menu, not the slide up
|
|
|
|
|
$('.tapHoldMenu').popup('close');
|
|
|
|
|
|
2014-03-17 07:48:16 -07:00
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2014-06-30 19:29:27 -07:00
|
|
|
|
function onShuffleButtonClick() {
|
2014-03-17 07:48:16 -07:00
|
|
|
|
|
2014-06-30 19:29:27 -07:00
|
|
|
|
var id = this.getAttribute('data-itemid');
|
2014-03-18 18:35:40 -07:00
|
|
|
|
|
2014-06-30 19:29:27 -07:00
|
|
|
|
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;
|
2014-03-18 18:35:40 -07:00
|
|
|
|
}
|
|
|
|
|
|
2014-08-01 19:34:45 -07:00
|
|
|
|
function onCardTapHold(e) {
|
2014-06-30 19:29:27 -07:00
|
|
|
|
|
2014-07-05 14:15:25 -07:00
|
|
|
|
showContextMenu(this);
|
2014-06-30 19:29:27 -07:00
|
|
|
|
|
2014-07-05 14:15:25 -07:00
|
|
|
|
e.preventDefault();
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2014-08-01 19:34:45 -07:00
|
|
|
|
function showContextMenu(card) {
|
2014-07-05 14:15:25 -07:00
|
|
|
|
|
|
|
|
|
$('.tapHoldMenu').popup("close").remove();
|
2014-06-30 19:29:27 -07:00
|
|
|
|
|
2014-08-01 19:34:45 -07:00
|
|
|
|
var displayContextItem = card;
|
2014-07-19 21:46:29 -07:00
|
|
|
|
|
2014-08-01 19:34:45 -07:00
|
|
|
|
if ($(card).hasClass('listviewMenuButton')) {
|
|
|
|
|
card = $(card).parents('.listItem')[0];
|
2014-07-19 21:46:29 -07:00
|
|
|
|
}
|
|
|
|
|
|
2014-08-01 19:34:45 -07:00
|
|
|
|
var itemId = card.getAttribute('data-itemid');
|
|
|
|
|
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';
|
2014-03-18 18:35:40 -07:00
|
|
|
|
|
2014-08-01 19:34:45 -07:00
|
|
|
|
$(card).addClass('hasContextMenu');
|
2014-07-04 12:17:22 -07:00
|
|
|
|
|
2014-07-19 21:46:29 -07:00
|
|
|
|
Dashboard.getCurrentUser().done(function (user) {
|
2014-03-18 18:35:40 -07:00
|
|
|
|
|
2014-06-30 19:29:27 -07:00
|
|
|
|
var html = '<div data-role="popup" class="tapHoldMenu" data-theme="a">';
|
2014-03-18 18:35:40 -07:00
|
|
|
|
|
2014-06-30 19:29:27 -07:00
|
|
|
|
html += '<ul data-role="listview" style="min-width: 240px;">';
|
|
|
|
|
html += '<li data-role="list-divider">' + Globalize.translate('HeaderMenu') + '</li>';
|
2014-03-18 21:59:45 -07:00
|
|
|
|
|
2014-08-01 19:34:45 -07:00
|
|
|
|
var href = card.getAttribute('data-href') || card.href;
|
2014-07-15 12:16:16 -07:00
|
|
|
|
|
2014-07-05 14:15:25 -07:00
|
|
|
|
html += '<li><a href="' + href + '">' + Globalize.translate('ButtonOpen') + '</a></li>';
|
|
|
|
|
html += '<li><a href="' + href + '" target="_blank">' + Globalize.translate('ButtonOpenInNewTab') + '</a></li>';
|
2014-06-30 19:29:27 -07:00
|
|
|
|
|
2014-06-30 21:26:50 -07:00
|
|
|
|
if (user.Configuration.IsAdministrator && commands.indexOf('edit') != -1) {
|
|
|
|
|
html += '<li data-icon="edit"><a href="edititemmetadata.html?id=' + itemId + '">' + Globalize.translate('ButtonEdit') + '</a></li>';
|
|
|
|
|
}
|
|
|
|
|
|
2014-07-19 21:46:29 -07:00
|
|
|
|
if (MediaController.canPlayByAttributes(itemType, mediaType, playAccess, locationType, isPlaceHolder)) {
|
2014-06-30 19:29:27 -07:00
|
|
|
|
html += '<li data-icon="play"><a href="#" class="btnPlay" data-itemid="' + itemId + '">' + Globalize.translate('ButtonPlay') + '</a></li>';
|
|
|
|
|
}
|
|
|
|
|
|
2014-07-19 21:46:29 -07:00
|
|
|
|
if (playbackPositionTicks && mediaType != "Audio") {
|
|
|
|
|
html += '<li data-icon="play"><a href="#" class="btnResume" data-ticks="' + playbackPositionTicks + '" data-itemid="' + itemId + '">' + Globalize.translate('ButtonResume') + '</a></li>';
|
2014-06-30 19:29:27 -07:00
|
|
|
|
}
|
|
|
|
|
|
2014-06-30 21:26:50 -07:00
|
|
|
|
if (commands.indexOf('trailer') != -1) {
|
|
|
|
|
html += '<li data-icon="video"><a href="#" class="btnPlayTrailer" data-itemid="' + itemId + '">' + Globalize.translate('ButtonPlayTrailer') + '</a></li>';
|
|
|
|
|
}
|
|
|
|
|
|
2014-07-19 21:46:29 -07:00
|
|
|
|
if (MediaController.canQueueMediaType(mediaType, itemType)) {
|
2014-06-30 19:29:27 -07:00
|
|
|
|
html += '<li data-icon="plus"><a href="#" class="btnQueue" data-itemid="' + itemId + '">' + Globalize.translate('ButtonQueue') + '</a></li>';
|
|
|
|
|
}
|
|
|
|
|
|
2014-07-19 21:46:29 -07:00
|
|
|
|
if (commands.indexOf('instantmix') != -1) {
|
2014-06-30 19:29:27 -07:00
|
|
|
|
html += '<li data-icon="recycle"><a href="#" class="btnInstantMix" data-itemid="' + itemId + '">' + Globalize.translate('ButtonInstantMix') + '</a></li>';
|
|
|
|
|
}
|
2014-03-18 21:59:45 -07:00
|
|
|
|
|
2014-07-19 21:46:29 -07:00
|
|
|
|
if (commands.indexOf('shuffle') != -1) {
|
2014-06-30 19:29:27 -07:00
|
|
|
|
html += '<li data-icon="recycle"><a href="#" class="btnShuffle" data-itemid="' + itemId + '">' + Globalize.translate('ButtonShuffle') + '</a></li>';
|
2014-03-18 21:59:45 -07:00
|
|
|
|
}
|
2014-06-30 19:29:27 -07:00
|
|
|
|
|
|
|
|
|
html += '</ul>';
|
|
|
|
|
|
|
|
|
|
html += '</div>';
|
|
|
|
|
|
|
|
|
|
$($.mobile.activePage).append(html);
|
|
|
|
|
|
2014-07-19 21:46:29 -07:00
|
|
|
|
var elem = $('.tapHoldMenu').popup({ positionTo: displayContextItem }).trigger('create').popup("open").on("popupafterclose", function () {
|
2014-06-30 19:29:27 -07:00
|
|
|
|
|
|
|
|
|
$(this).off("popupafterclose").remove();
|
2014-08-01 19:34:45 -07:00
|
|
|
|
$(card).removeClass('hasContextMenu');
|
2014-06-30 19:29:27 -07:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
$('.btnPlay', elem).on('click', onPlayButtonClick);
|
|
|
|
|
$('.btnResume', elem).on('click', onResumeButtonClick);
|
|
|
|
|
$('.btnQueue', elem).on('click', onQueueButtonClick);
|
|
|
|
|
$('.btnInstantMix', elem).on('click', onInstantMixButtonClick);
|
|
|
|
|
$('.btnShuffle', elem).on('click', onShuffleButtonClick);
|
2014-06-30 21:06:28 -07:00
|
|
|
|
$('.btnPlayTrailer', elem).on('click', onTrailerButtonClick);
|
2014-03-18 18:35:40 -07:00
|
|
|
|
});
|
2014-07-05 14:15:25 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function onListViewMenuButtonClick(e) {
|
|
|
|
|
|
|
|
|
|
showContextMenu(this);
|
2014-03-18 21:59:45 -07:00
|
|
|
|
|
2014-06-30 19:29:27 -07:00
|
|
|
|
e.preventDefault();
|
|
|
|
|
return false;
|
2014-03-17 07:48:16 -07:00
|
|
|
|
}
|
|
|
|
|
|
2014-08-01 19:34:45 -07:00
|
|
|
|
function onGroupedCardClick(e) {
|
2014-07-04 22:21:13 -07:00
|
|
|
|
|
2014-07-15 12:57:27 -07:00
|
|
|
|
var target = $(e.target);
|
2014-07-11 19:31:08 -07:00
|
|
|
|
|
2014-08-01 19:34:45 -07:00
|
|
|
|
var card = this;
|
|
|
|
|
var itemId = card.getAttribute('data-itemid');
|
|
|
|
|
var context = card.getAttribute('data-context');
|
2014-07-15 12:16:16 -07:00
|
|
|
|
|
2014-08-01 19:34:45 -07:00
|
|
|
|
$(card).addClass('hasContextMenu');
|
2014-07-04 22:21:13 -07:00
|
|
|
|
|
|
|
|
|
var userId = Dashboard.getCurrentUserId();
|
|
|
|
|
|
|
|
|
|
var promise1 = ApiClient.getItem(userId, itemId);
|
|
|
|
|
|
|
|
|
|
var options = {
|
|
|
|
|
|
2014-08-01 19:34:45 -07:00
|
|
|
|
Limit: parseInt($('.playedIndicator', card).html() || '10'),
|
2014-07-05 08:01:29 -07:00
|
|
|
|
Fields: "PrimaryImageAspectRatio,DateCreated",
|
2014-07-04 22:21:13 -07:00
|
|
|
|
ParentId: itemId,
|
|
|
|
|
IsFolder: false,
|
|
|
|
|
GroupItems: false
|
|
|
|
|
};
|
|
|
|
|
|
2014-08-01 19:34:45 -07:00
|
|
|
|
if ($(card).hasClass('unplayedGroupings')) {
|
2014-07-04 22:21:13 -07:00
|
|
|
|
options.IsPlayed = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var promise2 = ApiClient.getJSON(ApiClient.getUrl('Users/' + userId + '/Items/Latest', options));
|
|
|
|
|
|
|
|
|
|
$.when(promise1, promise2).done(function (response1, response2) {
|
|
|
|
|
|
|
|
|
|
var item = response1[0];
|
|
|
|
|
var latestItems = response2[0];
|
|
|
|
|
|
2014-07-08 19:53:04 -07:00
|
|
|
|
if (latestItems.length == 1) {
|
2014-07-15 12:57:27 -07:00
|
|
|
|
|
|
|
|
|
if (!target.is('a,button')) {
|
|
|
|
|
var first = latestItems[0];
|
2014-07-19 21:46:29 -07:00
|
|
|
|
Dashboard.navigate(LibraryBrowser.getHref(first, context));
|
2014-07-15 12:57:27 -07:00
|
|
|
|
return;
|
|
|
|
|
}
|
2014-07-08 19:53:04 -07:00
|
|
|
|
}
|
2014-07-04 22:21:13 -07:00
|
|
|
|
|
|
|
|
|
var html = '<div data-role="popup" class="groupingMenu" data-theme="a">';
|
|
|
|
|
|
|
|
|
|
html += '<a href="#" data-rel="back" class="ui-btn ui-corner-all ui-shadow ui-btn-b ui-icon-delete ui-btn-icon-notext ui-btn-right">Close</a>';
|
|
|
|
|
html += '<div>';
|
|
|
|
|
html += '<ul data-role="listview">';
|
|
|
|
|
|
2014-08-01 19:34:45 -07:00
|
|
|
|
var href = card.href || LibraryBrowser.getHref(item, context);
|
2014-07-04 22:21:13 -07:00
|
|
|
|
var header = Globalize.translate('HeaderLatestFromChannel').replace('{0}', '<a href="' + href + '">' + item.Name + '</a>');
|
|
|
|
|
html += '<li data-role="list-divider">' + header + '</li>';
|
|
|
|
|
|
|
|
|
|
html += '</ul>';
|
|
|
|
|
|
|
|
|
|
html += '<div class="groupingMenuScroller">';
|
|
|
|
|
html += '<ul data-role="listview">';
|
|
|
|
|
|
|
|
|
|
html += latestItems.map(function (latestItem) {
|
|
|
|
|
|
|
|
|
|
var itemHtml = '';
|
|
|
|
|
|
2014-07-19 21:46:29 -07:00
|
|
|
|
href = LibraryBrowser.getHref(latestItem, context);
|
2014-07-05 09:51:39 -07:00
|
|
|
|
itemHtml += '<li class="ui-li-has-thumb"><a href="' + href + '">';
|
2014-07-04 22:21:13 -07:00
|
|
|
|
|
2014-07-05 09:51:39 -07:00
|
|
|
|
var imgUrl;
|
2014-07-04 22:21:13 -07:00
|
|
|
|
|
|
|
|
|
if (latestItem.ImageTags.Primary) {
|
|
|
|
|
|
2014-07-05 12:57:18 -07:00
|
|
|
|
// Scaling 400w episode images to 80 doesn't turn out very well
|
|
|
|
|
var width = latestItem.Type == 'Episode' ? 160 : 80;
|
2014-07-04 22:21:13 -07:00
|
|
|
|
imgUrl = ApiClient.getScaledImageUrl(latestItem.Id, {
|
2014-07-05 12:57:18 -07:00
|
|
|
|
width: width,
|
2014-07-04 22:21:13 -07:00
|
|
|
|
tag: latestItem.ImageTags.Primary,
|
|
|
|
|
type: "Primary",
|
|
|
|
|
index: 0
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
}
|
2014-07-05 09:51:39 -07:00
|
|
|
|
if (imgUrl) {
|
|
|
|
|
itemHtml += '<div class="listviewImage ui-li-thumb" style="background-image:url(\'' + imgUrl + '\');"></div>';
|
|
|
|
|
}
|
2014-07-04 22:21:13 -07:00
|
|
|
|
|
|
|
|
|
itemHtml += '<h3>';
|
|
|
|
|
itemHtml += LibraryBrowser.getPosterViewDisplayName(latestItem);
|
|
|
|
|
itemHtml += '</h3>';
|
|
|
|
|
|
2014-07-05 08:01:29 -07:00
|
|
|
|
var date = parseISO8601Date(latestItem.DateCreated, { toLocal: true });
|
2014-07-04 22:21:13 -07:00
|
|
|
|
|
|
|
|
|
itemHtml += '<p>';
|
|
|
|
|
itemHtml += Globalize.translate('LabelAddedOnDate').replace('{0}', date.toLocaleDateString());
|
|
|
|
|
itemHtml += '</p>';
|
|
|
|
|
|
|
|
|
|
itemHtml += '</a></li>';
|
|
|
|
|
|
|
|
|
|
return itemHtml;
|
|
|
|
|
|
|
|
|
|
}).join('');
|
|
|
|
|
|
|
|
|
|
html += '</ul>';
|
|
|
|
|
html += '</div>';
|
|
|
|
|
|
|
|
|
|
html += '</div>';
|
|
|
|
|
html += '</div>';
|
|
|
|
|
|
|
|
|
|
$($.mobile.activePage).append(html);
|
|
|
|
|
|
|
|
|
|
var elem = $('.groupingMenu').popup().trigger('create').popup("open").on("popupafterclose", function () {
|
|
|
|
|
|
|
|
|
|
$(this).off("popupafterclose").remove();
|
2014-08-01 19:34:45 -07:00
|
|
|
|
$(card).removeClass('hasContextMenu');
|
2014-07-04 22:21:13 -07:00
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
e.preventDefault();
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2014-08-01 19:34:45 -07:00
|
|
|
|
$.fn.createCardMenus = function () {
|
2014-03-17 07:48:16 -07:00
|
|
|
|
|
2014-05-21 09:49:19 -07:00
|
|
|
|
var preventHover = false;
|
|
|
|
|
|
2014-03-17 07:48:16 -07:00
|
|
|
|
function onShowTimerExpired(elem) {
|
|
|
|
|
|
|
|
|
|
if ($(elem).hasClass('hasContextMenu')) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2014-03-18 21:59:45 -07:00
|
|
|
|
if ($('.itemSelectionPanel:visible', elem).length) {
|
2014-03-17 18:45:41 -07:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2014-08-01 19:34:45 -07:00
|
|
|
|
var innerElem = $('.cardOverlayTarget', elem);
|
2014-03-17 07:48:16 -07:00
|
|
|
|
var id = elem.getAttribute('data-itemid');
|
2014-06-30 19:29:27 -07:00
|
|
|
|
var commands = elem.getAttribute('data-commands').split(',');
|
2014-03-17 07:48:16 -07:00
|
|
|
|
|
|
|
|
|
var promise1 = ApiClient.getItem(Dashboard.getCurrentUserId(), id);
|
|
|
|
|
var promise2 = Dashboard.getCurrentUser();
|
|
|
|
|
|
|
|
|
|
$.when(promise1, promise2).done(function (response1, response2) {
|
|
|
|
|
|
|
|
|
|
var item = response1[0];
|
|
|
|
|
var user = response2[0];
|
|
|
|
|
|
2014-06-30 19:29:27 -07:00
|
|
|
|
innerElem.html(getOverlayHtml(item, user, elem, commands)).trigger('create');
|
2014-03-17 07:48:16 -07:00
|
|
|
|
|
|
|
|
|
$('.btnPlayTrailer', innerElem).on('click', onTrailerButtonClick);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
innerElem.show().each(function () {
|
|
|
|
|
|
|
|
|
|
this.style.height = 0;
|
|
|
|
|
|
|
|
|
|
}).animate({ "height": "100%" }, "fast");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function onHoverIn() {
|
|
|
|
|
|
2014-05-21 09:49:19 -07:00
|
|
|
|
if (preventHover === true) {
|
|
|
|
|
preventHover = false;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2014-03-17 07:48:16 -07:00
|
|
|
|
if (showOverlayTimeout) {
|
|
|
|
|
clearTimeout(showOverlayTimeout);
|
|
|
|
|
showOverlayTimeout = null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var elem = this;
|
|
|
|
|
|
|
|
|
|
showOverlayTimeout = setTimeout(function () {
|
|
|
|
|
|
|
|
|
|
onShowTimerExpired(elem);
|
|
|
|
|
|
|
|
|
|
}, 1000);
|
|
|
|
|
}
|
|
|
|
|
|
2014-05-21 09:49:19 -07:00
|
|
|
|
function preventTouchHover() {
|
|
|
|
|
preventHover = true;
|
2014-03-17 07:48:16 -07:00
|
|
|
|
}
|
|
|
|
|
|
2014-08-01 19:34:45 -07:00
|
|
|
|
var elems = '.card:not(.bannerCard)';
|
2014-05-21 09:49:19 -07:00
|
|
|
|
|
2014-08-01 19:34:45 -07:00
|
|
|
|
$('.card', this).on('contextmenu.cardMenu', onCardTapHold);
|
2014-07-04 22:21:13 -07:00
|
|
|
|
|
2014-07-05 14:15:25 -07:00
|
|
|
|
$('.listviewMenuButton', this).on('click', onListViewMenuButtonClick);
|
|
|
|
|
|
2014-08-01 19:34:45 -07:00
|
|
|
|
$('.groupedCard', this).on('click', onGroupedCardClick);
|
2014-06-30 19:29:27 -07:00
|
|
|
|
|
2014-08-01 19:34:45 -07:00
|
|
|
|
return this.off('.cardHoverMenu')
|
|
|
|
|
.on('mouseenter.cardHoverMenu', elems, onHoverIn)
|
|
|
|
|
.on('mouseleave.cardHoverMenu', elems, onHoverOut)
|
|
|
|
|
.on("touchstart.cardHoverMenu", elems, preventTouchHover);
|
2014-03-17 07:48:16 -07:00
|
|
|
|
};
|
|
|
|
|
|
2014-03-17 18:45:41 -07:00
|
|
|
|
function toggleSelections(page) {
|
|
|
|
|
|
|
|
|
|
Dashboard.showLoadingMsg();
|
|
|
|
|
|
|
|
|
|
var selectionCommands = $('.selectionCommands', page);
|
|
|
|
|
|
|
|
|
|
if (selectionCommands.is(':visible')) {
|
|
|
|
|
|
|
|
|
|
selectionCommands.hide();
|
|
|
|
|
$('.itemSelectionPanel', page).hide();
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
|
|
selectionCommands.show();
|
|
|
|
|
|
|
|
|
|
$('.itemSelectionPanel', page).show();
|
2014-03-18 18:35:40 -07:00
|
|
|
|
|
|
|
|
|
$('.chkItemSelect:checked', page).checked(false).checkboxradio('refresh');
|
2014-03-17 18:45:41 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Dashboard.hideLoadingMsg();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function hideSelections(page) {
|
|
|
|
|
|
|
|
|
|
$('.selectionCommands', page).hide();
|
|
|
|
|
|
|
|
|
|
$('.itemSelectionPanel', page).hide();
|
|
|
|
|
}
|
2014-03-18 18:35:40 -07:00
|
|
|
|
|
2014-03-17 18:45:41 -07:00
|
|
|
|
function getSelectedItems(page) {
|
2014-03-18 18:35:40 -07:00
|
|
|
|
|
2014-03-17 18:45:41 -07:00
|
|
|
|
var selection = $('.chkItemSelect:checked', page);
|
|
|
|
|
|
2014-08-01 19:34:45 -07:00
|
|
|
|
return selection.parents('.card')
|
2014-03-18 18:35:40 -07:00
|
|
|
|
.map(function () {
|
2014-03-17 18:45:41 -07:00
|
|
|
|
|
|
|
|
|
return this.getAttribute('data-itemid');
|
|
|
|
|
|
|
|
|
|
}).get();
|
|
|
|
|
}
|
2014-03-18 18:35:40 -07:00
|
|
|
|
|
2014-03-17 18:45:41 -07:00
|
|
|
|
function combineVersions(page) {
|
|
|
|
|
|
|
|
|
|
var selection = getSelectedItems(page);
|
2014-03-18 18:35:40 -07:00
|
|
|
|
|
2014-03-17 18:45:41 -07:00
|
|
|
|
if (selection.length < 2) {
|
2014-03-18 18:35:40 -07:00
|
|
|
|
|
2014-03-17 18:45:41 -07:00
|
|
|
|
Dashboard.alert({
|
2014-06-03 20:34:36 -07:00
|
|
|
|
message: Globalize.translate('MessagePleaseSelectTwoItems'),
|
2014-05-30 12:23:56 -07:00
|
|
|
|
title: Globalize.translate('HeaderError')
|
2014-03-17 18:45:41 -07:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2014-08-01 19:34:45 -07:00
|
|
|
|
var names = $('.chkItemSelect:checked', page).parents('.card').get().reverse().map(function (e) {
|
2014-03-18 18:35:40 -07:00
|
|
|
|
|
2014-08-01 19:34:45 -07:00
|
|
|
|
return $('.cardText', e).html();
|
2014-03-18 18:35:40 -07:00
|
|
|
|
|
|
|
|
|
}).join('<br/>');
|
|
|
|
|
|
2014-05-30 12:23:56 -07:00
|
|
|
|
var msg = Globalize.translate('MessageTheFollowingItemsWillBeGrouped') + "<br/><br/>" + names;
|
2014-03-18 18:35:40 -07:00
|
|
|
|
|
2014-05-30 12:23:56 -07:00
|
|
|
|
msg += "<br/><br/>" + Globalize.translate('MessageConfirmItemGrouping');
|
2014-03-18 18:35:40 -07:00
|
|
|
|
|
|
|
|
|
Dashboard.confirm(msg, "Group Versions", function (confirmResult) {
|
|
|
|
|
|
|
|
|
|
if (confirmResult) {
|
|
|
|
|
|
|
|
|
|
Dashboard.showLoadingMsg();
|
|
|
|
|
|
2014-07-01 22:16:59 -07:00
|
|
|
|
ApiClient.ajax({
|
2014-06-30 11:55:38 -07:00
|
|
|
|
|
2014-03-18 18:35:40 -07:00
|
|
|
|
type: "POST",
|
|
|
|
|
url: ApiClient.getUrl("Videos/MergeVersions", { Ids: selection.join(',') })
|
|
|
|
|
|
|
|
|
|
}).done(function () {
|
|
|
|
|
|
|
|
|
|
Dashboard.hideLoadingMsg();
|
|
|
|
|
|
2014-06-03 20:34:36 -07:00
|
|
|
|
hideSelections(page);
|
2014-03-18 18:35:40 -07:00
|
|
|
|
|
|
|
|
|
$('.itemsContainer', page).trigger('needsrefresh');
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
});
|
2014-03-17 18:45:41 -07:00
|
|
|
|
}
|
2014-06-30 11:55:38 -07:00
|
|
|
|
|
2014-06-03 20:34:36 -07:00
|
|
|
|
function addToCollection(page) {
|
2014-06-30 11:55:38 -07:00
|
|
|
|
|
2014-06-03 20:34:36 -07:00
|
|
|
|
var selection = getSelectedItems(page);
|
|
|
|
|
|
|
|
|
|
if (selection.length < 1) {
|
|
|
|
|
|
|
|
|
|
Dashboard.alert({
|
|
|
|
|
message: Globalize.translate('MessagePleaseSelectOneItem'),
|
|
|
|
|
title: Globalize.translate('HeaderError')
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BoxSetEditor.showPanel(page, selection);
|
|
|
|
|
}
|
2014-03-17 18:45:41 -07:00
|
|
|
|
|
|
|
|
|
$(document).on('pageinit', ".libraryPage", function () {
|
|
|
|
|
|
|
|
|
|
var page = this;
|
|
|
|
|
|
|
|
|
|
$('.btnMergeVersions', page).on('click', function () {
|
|
|
|
|
combineVersions(page);
|
|
|
|
|
});
|
|
|
|
|
|
2014-06-03 20:34:36 -07:00
|
|
|
|
$('.btnAddToCollection', page).on('click', function () {
|
|
|
|
|
addToCollection(page);
|
|
|
|
|
});
|
|
|
|
|
|
2014-07-19 21:46:29 -07:00
|
|
|
|
$('.viewTabButton', page).on('click', function () {
|
|
|
|
|
|
|
|
|
|
$('.viewTabButton', page).removeClass('ui-btn-active');
|
|
|
|
|
$(this).addClass('ui-btn-active');
|
|
|
|
|
|
|
|
|
|
$('.viewTab', page).hide();
|
|
|
|
|
$('.' + this.getAttribute('data-tab'), page).show();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
var viewPanel = $('.viewPanel', page).panel('option', 'classes.modalOpen', 'viewPanelModelOpen ui-panel-dismiss-open');
|
|
|
|
|
|
|
|
|
|
$('#selectPageSize', viewPanel).html(LibraryBrowser.getDefaultPageSizeSelections().map(function (i) {
|
|
|
|
|
|
|
|
|
|
return '<option value="' + i + '">' + i + '</option>';
|
|
|
|
|
|
|
|
|
|
}).join('')).selectmenu('refresh');
|
|
|
|
|
|
|
|
|
|
$('.itemsContainer', page).on('itemsrendered', function() {
|
|
|
|
|
|
|
|
|
|
$('.btnToggleSelections', page).off('click.toggleselections').on('click.toggleselections', function () {
|
|
|
|
|
toggleSelections(page);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
2014-06-03 20:34:36 -07:00
|
|
|
|
}).on('pagebeforeshow', ".libraryPage", function () {
|
|
|
|
|
|
|
|
|
|
var page = this;
|
|
|
|
|
|
|
|
|
|
hideSelections(page);
|
2014-07-19 21:46:29 -07:00
|
|
|
|
|
|
|
|
|
$('.viewTabButton:first', page).trigger('click');
|
2014-03-17 18:45:41 -07:00
|
|
|
|
});
|
|
|
|
|
|
2014-08-01 19:34:45 -07:00
|
|
|
|
function renderUserDataChanges(card, userData) {
|
2014-06-30 11:55:38 -07:00
|
|
|
|
|
|
|
|
|
if (userData.Played) {
|
|
|
|
|
|
2014-08-01 19:34:45 -07:00
|
|
|
|
if (!$('.playedIndicator', card).length) {
|
2014-06-30 11:55:38 -07:00
|
|
|
|
|
2014-08-01 19:34:45 -07:00
|
|
|
|
$('<div class="playedIndicator"></div>').insertAfter($('.cardOverlayTarget', card));
|
2014-07-03 19:22:57 -07:00
|
|
|
|
}
|
2014-08-01 19:34:45 -07:00
|
|
|
|
$('.playedIndicator', card).html('<div class="ui-icon-check ui-btn-icon-notext"></div>');
|
|
|
|
|
$('.cardProgress', card).remove();
|
2014-07-03 19:22:57 -07:00
|
|
|
|
}
|
|
|
|
|
else if (userData.UnplayedItemCount) {
|
2014-06-30 11:55:38 -07:00
|
|
|
|
|
2014-08-01 19:34:45 -07:00
|
|
|
|
if (!$('.playedIndicator', card).length) {
|
2014-07-03 19:22:57 -07:00
|
|
|
|
|
2014-08-01 19:34:45 -07:00
|
|
|
|
$('<div class="playedIndicator"></div>').insertAfter($('.cardOverlayTarget', card));
|
2014-06-30 11:55:38 -07:00
|
|
|
|
}
|
2014-08-01 19:34:45 -07:00
|
|
|
|
$('.playedIndicator', card).html(userData.UnplayedItemCount);
|
2014-07-03 19:22:57 -07:00
|
|
|
|
}
|
|
|
|
|
else {
|
2014-06-30 12:24:35 -07:00
|
|
|
|
|
2014-08-01 19:34:45 -07:00
|
|
|
|
$('.playedIndicator', card).remove();
|
2014-06-30 12:24:35 -07:00
|
|
|
|
|
2014-07-03 19:22:57 -07:00
|
|
|
|
var progressHtml = LibraryBrowser.getItemProgressBarHtml(userData);
|
|
|
|
|
|
2014-08-01 19:34:45 -07:00
|
|
|
|
$('.cardProgress', card).html(progressHtml);
|
2014-07-03 19:22:57 -07:00
|
|
|
|
}
|
2014-06-30 11:55:38 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function onUserDataChanged(userData) {
|
|
|
|
|
|
2014-07-26 10:30:15 -07:00
|
|
|
|
var cssClass = LibraryBrowser.getUserDataCssClass(userData.Key);
|
|
|
|
|
|
|
|
|
|
$('.' + cssClass).each(function () {
|
2014-07-19 21:46:29 -07:00
|
|
|
|
|
|
|
|
|
this.setAttribute('data-positionticks', (userData.PlaybackPositionTicks || 0));
|
|
|
|
|
|
2014-08-01 19:34:45 -07:00
|
|
|
|
if ($(this).hasClass('card')) {
|
2014-07-19 21:46:29 -07:00
|
|
|
|
renderUserDataChanges(this, userData);
|
|
|
|
|
}
|
2014-06-30 11:55:38 -07:00
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function onWebSocketMessage(e, data) {
|
|
|
|
|
|
|
|
|
|
var msg = data;
|
|
|
|
|
|
|
|
|
|
if (msg.MessageType === "UserDataChanged") {
|
|
|
|
|
|
|
|
|
|
if (msg.Data.UserId == Dashboard.getCurrentUserId()) {
|
|
|
|
|
|
|
|
|
|
for (var i = 0, length = msg.Data.UserDataList.length; i < length; i++) {
|
|
|
|
|
onUserDataChanged(msg.Data.UserDataList[i]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$(ApiClient).on('websocketmessage', onWebSocketMessage);
|
|
|
|
|
|
2014-03-17 07:48:16 -07:00
|
|
|
|
})(jQuery, document, window);
|