2013-05-04 17:20:27 -04:00
|
|
|
|
(function ($, document, window, FileReader, escape) {
|
|
|
|
|
|
|
|
|
|
var currentItem;
|
|
|
|
|
|
2013-10-31 17:03:24 -04:00
|
|
|
|
var browsableImagePageSize = 10;
|
|
|
|
|
var browsableImageStartIndex = 0;
|
|
|
|
|
var browsableImageType = 'Primary';
|
2014-02-09 16:11:11 -05:00
|
|
|
|
var selectedProvider;
|
2013-10-31 17:03:24 -04:00
|
|
|
|
|
2013-10-31 21:48:14 -04:00
|
|
|
|
function getBaseRemoteOptions() {
|
2014-11-14 21:31:03 -05:00
|
|
|
|
|
2013-10-31 21:48:14 -04:00
|
|
|
|
var options = {};
|
|
|
|
|
|
2014-11-14 21:31:03 -05:00
|
|
|
|
options.itemId = currentItem.Id;
|
2013-10-31 21:48:14 -04:00
|
|
|
|
|
|
|
|
|
return options;
|
|
|
|
|
}
|
|
|
|
|
|
2013-10-31 17:03:24 -04:00
|
|
|
|
function reloadBrowsableImages(page) {
|
|
|
|
|
|
2013-10-31 21:48:14 -04:00
|
|
|
|
Dashboard.showLoadingMsg();
|
|
|
|
|
|
|
|
|
|
var options = getBaseRemoteOptions();
|
|
|
|
|
|
|
|
|
|
options.type = browsableImageType;
|
|
|
|
|
options.startIndex = browsableImageStartIndex;
|
|
|
|
|
options.limit = browsableImagePageSize;
|
2014-02-25 10:40:16 -05:00
|
|
|
|
options.IncludeAllLanguages = $('#chkAllLanguages', page).checked();
|
2013-10-31 21:48:14 -04:00
|
|
|
|
|
2014-02-09 16:11:11 -05:00
|
|
|
|
var provider = selectedProvider || '';
|
2013-10-31 21:48:14 -04:00
|
|
|
|
|
|
|
|
|
if (provider) {
|
|
|
|
|
options.ProviderName = provider;
|
|
|
|
|
}
|
2013-10-31 17:03:24 -04:00
|
|
|
|
|
|
|
|
|
ApiClient.getAvailableRemoteImages(options).done(function (result) {
|
|
|
|
|
|
|
|
|
|
renderRemoteImages(page, currentItem, result, browsableImageType, options.startIndex, options.limit);
|
2013-10-31 21:48:14 -04:00
|
|
|
|
|
2015-09-03 13:01:51 -04:00
|
|
|
|
$('#selectBrowsableImageType', page).val(browsableImageType);
|
2013-10-31 21:48:14 -04:00
|
|
|
|
|
|
|
|
|
var providersHtml = result.Providers.map(function (p) {
|
|
|
|
|
return '<option value="' + p + '">' + p + '</option>';
|
|
|
|
|
});
|
|
|
|
|
|
2015-09-03 13:01:51 -04:00
|
|
|
|
$('#selectImageProvider', page).html('<option value="">' + Globalize.translate('LabelAll') + '</option>' + providersHtml).val(provider);
|
2013-10-31 21:48:14 -04:00
|
|
|
|
|
|
|
|
|
Dashboard.hideLoadingMsg();
|
2013-10-31 17:03:24 -04:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function renderRemoteImages(page, item, imagesResult, imageType, startIndex, limit) {
|
|
|
|
|
$('.availableImagesPaging', page).html(getPagingHtml(startIndex, limit, imagesResult.TotalRecordCount)).trigger('create');
|
|
|
|
|
|
|
|
|
|
var html = '';
|
|
|
|
|
|
|
|
|
|
for (var i = 0, length = imagesResult.Images.length; i < length; i++) {
|
|
|
|
|
|
|
|
|
|
html += getRemoteImageHtml(imagesResult.Images[i], imageType);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$('.availableImagesList', page).html(html).trigger('create');
|
|
|
|
|
|
|
|
|
|
$('.btnNextPage', page).on('click', function () {
|
|
|
|
|
browsableImageStartIndex += browsableImagePageSize;
|
|
|
|
|
reloadBrowsableImages(page);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
$('.btnPreviousPage', page).on('click', function () {
|
|
|
|
|
browsableImageStartIndex -= browsableImagePageSize;
|
|
|
|
|
reloadBrowsableImages(page);
|
|
|
|
|
});
|
|
|
|
|
|
2013-10-31 21:48:14 -04:00
|
|
|
|
$('.btnDownloadRemoteImage', page).on('click', function () {
|
|
|
|
|
|
|
|
|
|
downloadRemoteImage(page, this.getAttribute('data-imageurl'), this.getAttribute('data-imagetype'), this.getAttribute('data-imageprovider'));
|
|
|
|
|
});
|
|
|
|
|
|
2013-10-31 17:03:24 -04:00
|
|
|
|
}
|
|
|
|
|
|
2013-10-31 21:48:14 -04:00
|
|
|
|
function downloadRemoteImage(page, url, type, provider) {
|
|
|
|
|
|
|
|
|
|
var options = getBaseRemoteOptions();
|
|
|
|
|
|
|
|
|
|
options.Type = type;
|
|
|
|
|
options.ImageUrl = url;
|
|
|
|
|
options.ProviderName = provider;
|
|
|
|
|
|
|
|
|
|
Dashboard.showLoadingMsg();
|
2013-11-01 11:55:25 -04:00
|
|
|
|
|
2013-10-31 21:48:14 -04:00
|
|
|
|
ApiClient.downloadRemoteImage(options).done(function () {
|
|
|
|
|
|
2014-02-25 10:40:16 -05:00
|
|
|
|
$('.popupDownload', page).popup("close");
|
2013-10-31 21:48:14 -04:00
|
|
|
|
reload(page);
|
|
|
|
|
});
|
|
|
|
|
}
|
2013-10-31 17:03:24 -04:00
|
|
|
|
|
2013-11-04 16:50:37 -05:00
|
|
|
|
function getDisplayUrl(url) {
|
2014-02-09 01:08:10 -05:00
|
|
|
|
return ApiClient.getUrl("Images/Remote", { imageUrl: url });
|
2013-11-04 16:50:37 -05:00
|
|
|
|
}
|
|
|
|
|
|
2013-10-31 17:03:24 -04:00
|
|
|
|
function getRemoteImageHtml(image, imageType) {
|
|
|
|
|
|
|
|
|
|
var html = '';
|
|
|
|
|
|
|
|
|
|
html += '<div class="remoteImageContainer">';
|
|
|
|
|
|
|
|
|
|
var cssClass = "remoteImage";
|
|
|
|
|
|
2013-10-31 21:48:14 -04:00
|
|
|
|
if (imageType == "Backdrop" || imageType == "Art" || imageType == "Thumb" || imageType == "Logo") {
|
2013-10-31 17:03:24 -04:00
|
|
|
|
cssClass += " remoteBackdropImage";
|
|
|
|
|
}
|
2013-10-31 21:48:14 -04:00
|
|
|
|
else if (imageType == "Banner") {
|
|
|
|
|
cssClass += " remoteBannerImage";
|
|
|
|
|
}
|
|
|
|
|
else if (imageType == "Disc") {
|
|
|
|
|
cssClass += " remoteDiscImage";
|
|
|
|
|
}
|
2013-10-31 17:03:24 -04:00
|
|
|
|
else {
|
2013-11-27 14:04:19 -05:00
|
|
|
|
|
2013-11-05 17:29:07 -05:00
|
|
|
|
if (currentItem.Type == "Episode") {
|
|
|
|
|
cssClass += " remoteBackdropImage";
|
|
|
|
|
}
|
2013-11-21 15:48:26 -05:00
|
|
|
|
else if (currentItem.Type == "MusicAlbum" || currentItem.Type == "MusicArtist") {
|
2013-11-05 17:29:07 -05:00
|
|
|
|
cssClass += " remoteDiscImage";
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
cssClass += " remotePosterImage";
|
|
|
|
|
}
|
2013-10-31 17:03:24 -04:00
|
|
|
|
}
|
|
|
|
|
|
2013-11-04 16:50:37 -05:00
|
|
|
|
var displayUrl = getDisplayUrl(image.ThumbnailUrl || image.Url);
|
|
|
|
|
|
|
|
|
|
html += '<a target="_blank" href="' + getDisplayUrl(image.Url) + '" class="' + cssClass + '" style="background-image:url(\'' + displayUrl + '\');">';
|
2013-10-31 21:48:14 -04:00
|
|
|
|
html += '</a>';
|
2013-10-31 17:03:24 -04:00
|
|
|
|
|
|
|
|
|
html += '<div class="remoteImageDetails">';
|
|
|
|
|
html += image.ProviderName;
|
|
|
|
|
html += '</div>';
|
|
|
|
|
|
2013-11-04 14:04:23 -05:00
|
|
|
|
if (image.Width || image.Height || image.Language) {
|
2013-10-31 17:03:24 -04:00
|
|
|
|
|
|
|
|
|
html += '<div class="remoteImageDetails">';
|
2013-10-31 21:48:14 -04:00
|
|
|
|
|
2015-07-23 19:40:54 -04:00
|
|
|
|
if (image.Width && image.Height) {
|
2013-11-04 14:04:23 -05:00
|
|
|
|
html += image.Width + ' x ' + image.Height;
|
2013-10-31 17:03:24 -04:00
|
|
|
|
|
2013-11-04 14:04:23 -05:00
|
|
|
|
if (image.Language) {
|
|
|
|
|
|
|
|
|
|
html += ' • ' + image.Language;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
if (image.Language) {
|
|
|
|
|
|
|
|
|
|
html += image.Language;
|
|
|
|
|
}
|
2013-10-31 17:03:24 -04:00
|
|
|
|
}
|
2013-11-04 14:04:23 -05:00
|
|
|
|
|
2013-10-31 17:03:24 -04:00
|
|
|
|
html += '</div>';
|
|
|
|
|
}
|
|
|
|
|
|
2013-10-31 21:48:14 -04:00
|
|
|
|
if (image.CommunityRating != null) {
|
|
|
|
|
|
2013-10-31 17:03:24 -04:00
|
|
|
|
html += '<div class="remoteImageDetails">';
|
|
|
|
|
|
2013-10-31 21:48:14 -04:00
|
|
|
|
if (image.RatingType == "Likes") {
|
|
|
|
|
html += image.CommunityRating + (image.CommunityRating == 1 ? " like" : " likes");
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
|
|
if (image.CommunityRating) {
|
|
|
|
|
html += image.CommunityRating.toFixed(1);
|
|
|
|
|
|
|
|
|
|
if (image.VoteCount) {
|
2013-11-05 10:12:13 -05:00
|
|
|
|
html += ' • ' + image.VoteCount + (image.VoteCount == 1 ? " vote" : " votes");
|
2013-10-31 21:48:14 -04:00
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
html += "Unrated";
|
|
|
|
|
}
|
2013-10-31 17:03:24 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
html += '</div>';
|
|
|
|
|
}
|
|
|
|
|
|
2014-07-16 23:17:14 -04:00
|
|
|
|
html += '<div><button class="btnDownloadRemoteImage" data-imageprovider="' + image.ProviderName + '" data-imageurl="' + image.Url + '" data-imagetype="' + image.Type + '" type="button" data-icon="arrow-d" data-mini="true">' + Globalize.translate('ButtonDownload') + '</button></div>';
|
2013-10-31 21:48:14 -04:00
|
|
|
|
|
2013-10-31 17:03:24 -04:00
|
|
|
|
html += '</div>';
|
|
|
|
|
|
|
|
|
|
return html;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function getPagingHtml(startIndex, limit, totalRecordCount) {
|
|
|
|
|
|
|
|
|
|
var html = '';
|
|
|
|
|
|
|
|
|
|
var recordsEnd = Math.min(startIndex + limit, totalRecordCount);
|
|
|
|
|
|
|
|
|
|
// 20 is the minimum page size
|
2013-10-31 21:48:14 -04:00
|
|
|
|
var showControls = totalRecordCount > limit;
|
2013-10-31 17:03:24 -04:00
|
|
|
|
|
|
|
|
|
html += '<div class="listPaging">';
|
|
|
|
|
|
|
|
|
|
html += '<span style="margin-right: 10px;">';
|
|
|
|
|
|
|
|
|
|
var startAtDisplay = totalRecordCount ? startIndex + 1 : 0;
|
|
|
|
|
html += startAtDisplay + '-' + recordsEnd + ' of ' + totalRecordCount;
|
|
|
|
|
|
|
|
|
|
html += '</span>';
|
|
|
|
|
|
|
|
|
|
if (showControls) {
|
2014-01-22 15:46:01 -05:00
|
|
|
|
html += '<div data-role="controlgroup" data-type="horizontal" style="display:inline-block;">';
|
2013-10-31 17:03:24 -04:00
|
|
|
|
|
2015-09-06 15:09:36 -04:00
|
|
|
|
html += '<paper-icon-button icon="arrow-back" title="' + Globalize.translate('ButtonPreviousPage') + '" class="btnPreviousPage" ' + (startIndex ? '' : 'disabled') + '></paper-icon-button>';
|
|
|
|
|
html += '<paper-icon-button icon="arrow-forward" title="' + Globalize.translate('ButtonNextPage') + '" class="btnNextPage" ' + (startIndex + limit > totalRecordCount ? 'disabled' : '') + '></paper-icon-button>';
|
2014-01-22 15:46:01 -05:00
|
|
|
|
html += '</div>';
|
2013-10-31 17:03:24 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
html += '</div>';
|
|
|
|
|
|
|
|
|
|
return html;
|
|
|
|
|
}
|
2013-11-27 14:04:19 -05:00
|
|
|
|
|
2015-09-17 12:04:04 -04:00
|
|
|
|
function reload(page, item) {
|
2013-05-04 17:20:27 -04:00
|
|
|
|
|
|
|
|
|
Dashboard.showLoadingMsg();
|
|
|
|
|
|
2014-02-09 16:11:11 -05:00
|
|
|
|
browsableImageStartIndex = 0;
|
|
|
|
|
browsableImageType = 'Primary';
|
|
|
|
|
selectedProvider = null;
|
|
|
|
|
|
2015-09-17 12:04:04 -04:00
|
|
|
|
if (item) {
|
|
|
|
|
reloadItem(page, item);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
ApiClient.getItem(Dashboard.getCurrentUserId(), currentItem.Id).done(function (item) {
|
|
|
|
|
reloadItem(page, item);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
2013-05-04 17:20:27 -04:00
|
|
|
|
|
2015-09-17 12:04:04 -04:00
|
|
|
|
function reloadItem(page, item) {
|
2013-05-04 17:20:27 -04:00
|
|
|
|
|
2015-09-17 12:04:04 -04:00
|
|
|
|
currentItem = item;
|
2013-11-27 14:04:19 -05:00
|
|
|
|
|
2015-09-17 12:04:04 -04:00
|
|
|
|
ApiClient.getRemoteImageProviders(getBaseRemoteOptions()).done(function (providers) {
|
2013-11-27 14:04:19 -05:00
|
|
|
|
|
2015-09-17 12:04:04 -04:00
|
|
|
|
if (providers.length) {
|
|
|
|
|
$('.lnkBrowseAllImages', page).removeClass('hide');
|
|
|
|
|
} else {
|
|
|
|
|
$('.lnkBrowseAllImages', page).addClass('hide');
|
|
|
|
|
}
|
2013-11-27 14:04:19 -05:00
|
|
|
|
|
2015-09-17 12:04:04 -04:00
|
|
|
|
ApiClient.getItemImageInfos(currentItem.Id).done(function (imageInfos) {
|
2013-11-05 10:38:59 -05:00
|
|
|
|
|
2015-09-17 12:04:04 -04:00
|
|
|
|
renderStandardImages(page, item, imageInfos, providers);
|
|
|
|
|
renderBackdrops(page, item, imageInfos, providers);
|
|
|
|
|
renderScreenshots(page, item, imageInfos, providers);
|
|
|
|
|
Dashboard.hideLoadingMsg();
|
2013-11-05 10:38:59 -05:00
|
|
|
|
});
|
2013-05-05 00:49:49 -04:00
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2013-11-05 10:38:59 -05:00
|
|
|
|
function renderImages(page, item, images, imageProviders, elem) {
|
2013-05-05 00:49:49 -04:00
|
|
|
|
|
|
|
|
|
var html = '';
|
|
|
|
|
|
|
|
|
|
for (var i = 0, length = images.length; i < length; i++) {
|
|
|
|
|
|
|
|
|
|
var image = images[i];
|
|
|
|
|
|
2013-11-27 14:04:19 -05:00
|
|
|
|
html += '<div class="editorTile imageEditorTile">';
|
2013-05-05 00:49:49 -04:00
|
|
|
|
|
2015-07-15 07:26:47 -04:00
|
|
|
|
if (image.ImageType !== "Backdrop" && image.ImageType !== "Screenshot") {
|
|
|
|
|
html += '<h3>' + image.ImageType + '</h3>';
|
|
|
|
|
}
|
|
|
|
|
|
2015-07-14 15:04:16 -04:00
|
|
|
|
var height = 150;
|
|
|
|
|
|
|
|
|
|
html += '<div style="height:' + height + 'px;vertical-align:top;background-repeat:no-repeat;background-position:center center;background-size:contain;background-image:url(\'' + LibraryBrowser.getImageUrl(currentItem, image.ImageType, image.ImageIndex, { height: height }) + '\');"></div>';
|
2013-05-05 00:49:49 -04:00
|
|
|
|
|
2015-07-15 07:26:47 -04:00
|
|
|
|
html += '<div class="editorTileInner">';
|
2013-05-05 00:49:49 -04:00
|
|
|
|
|
2015-08-02 19:47:31 -04:00
|
|
|
|
if (image.Width && image.Height) {
|
|
|
|
|
html += '<p>' + image.Width + ' X ' + image.Height + '</p>';
|
|
|
|
|
} else {
|
|
|
|
|
html += '<p> </p>';
|
|
|
|
|
}
|
2013-05-05 00:49:49 -04:00
|
|
|
|
|
2015-09-17 12:04:04 -04:00
|
|
|
|
html += '<div>';
|
2013-05-05 00:49:49 -04:00
|
|
|
|
|
|
|
|
|
if (image.ImageType == "Backdrop" || image.ImageType == "Screenshot") {
|
|
|
|
|
|
|
|
|
|
if (i > 0) {
|
2015-07-14 15:04:16 -04:00
|
|
|
|
html += '<paper-icon-button icon="chevron-left" onclick="EditItemImagesPage.moveImage(\'' + image.ImageType + '\', ' + image.ImageIndex + ', ' + (i - 1) + ');" title="' + Globalize.translate('ButtonMoveLeft') + '"></paper-icon-button>';
|
2013-05-05 00:49:49 -04:00
|
|
|
|
} else {
|
2015-07-14 15:04:16 -04:00
|
|
|
|
html += '<paper-icon-button icon="chevron-left" disabled title="' + Globalize.translate('ButtonMoveLeft') + '"></paper-icon-button>';
|
2013-05-05 00:49:49 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (i < length - 1) {
|
2015-07-14 15:04:16 -04:00
|
|
|
|
html += '<paper-icon-button icon="chevron-right" onclick="EditItemImagesPage.moveImage(\'' + image.ImageType + '\', ' + image.ImageIndex + ', ' + (i + 1) + ');" title="' + Globalize.translate('ButtonMoveRight') + '"></paper-icon-button>';
|
2013-05-05 00:49:49 -04:00
|
|
|
|
} else {
|
2015-07-14 15:04:16 -04:00
|
|
|
|
html += '<paper-icon-button icon="chevron-right" disabled title="' + Globalize.translate('ButtonMoveRight') + '"></paper-icon-button>';
|
2013-05-05 00:49:49 -04:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-11-05 10:38:59 -05:00
|
|
|
|
if (imageProviders.length) {
|
2015-07-14 15:04:16 -04:00
|
|
|
|
html += '<paper-icon-button icon="cloud" onclick="EditItemImagesPage.showDownloadMenu(\'' + image.ImageType + '\');" title="' + Globalize.translate('ButtonBrowseOnlineImages') + '"></paper-icon-button>';
|
2013-11-05 10:38:59 -05:00
|
|
|
|
}
|
2013-10-31 21:55:38 -04:00
|
|
|
|
|
2015-07-15 07:26:47 -04:00
|
|
|
|
html += '<paper-icon-button icon="delete" onclick="EditItemImagesPage.deleteImage(\'' + image.ImageType + '\', ' + (image.ImageIndex != null ? image.ImageIndex : "null") + ');" title="' + Globalize.translate('Delete') + '"></paper-icon-button>';
|
|
|
|
|
|
2015-09-17 12:04:04 -04:00
|
|
|
|
html += '</div>';
|
2013-05-05 00:49:49 -04:00
|
|
|
|
|
|
|
|
|
html += '</div>';
|
|
|
|
|
|
|
|
|
|
html += '</div>';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
elem.html(html).trigger('create');
|
|
|
|
|
}
|
|
|
|
|
|
2013-11-05 10:38:59 -05:00
|
|
|
|
function renderStandardImages(page, item, imageInfos, imageProviders) {
|
2013-05-05 00:49:49 -04:00
|
|
|
|
|
|
|
|
|
var images = imageInfos.filter(function (i) {
|
|
|
|
|
return i.ImageType != "Screenshot" && i.ImageType != "Backdrop" && i.ImageType != "Chapter";
|
2013-05-04 17:20:27 -04:00
|
|
|
|
});
|
2013-05-05 00:49:49 -04:00
|
|
|
|
|
2015-09-17 12:04:04 -04:00
|
|
|
|
renderImages(page, item, images, imageProviders, $('#images', page));
|
2013-05-05 00:49:49 -04:00
|
|
|
|
}
|
|
|
|
|
|
2013-11-05 10:38:59 -05:00
|
|
|
|
function renderBackdrops(page, item, imageInfos, imageProviders) {
|
2013-05-05 00:49:49 -04:00
|
|
|
|
|
|
|
|
|
var images = imageInfos.filter(function (i) {
|
|
|
|
|
return i.ImageType == "Backdrop";
|
|
|
|
|
|
|
|
|
|
}).sort(function (a, b) {
|
|
|
|
|
return a.ImageIndex - b.ImageIndex;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
if (images.length) {
|
|
|
|
|
$('#backdropsContainer', page).show();
|
2013-11-05 10:38:59 -05:00
|
|
|
|
renderImages(page, item, images, imageProviders, $('#backdrops', page));
|
2013-05-05 00:49:49 -04:00
|
|
|
|
} else {
|
|
|
|
|
$('#backdropsContainer', page).hide();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-11-05 10:38:59 -05:00
|
|
|
|
function renderScreenshots(page, item, imageInfos, imageProviders) {
|
2013-05-05 00:49:49 -04:00
|
|
|
|
|
|
|
|
|
var images = imageInfos.filter(function (i) {
|
|
|
|
|
return i.ImageType == "Screenshot";
|
|
|
|
|
|
|
|
|
|
}).sort(function (a, b) {
|
|
|
|
|
return a.ImageIndex - b.ImageIndex;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
if (images.length) {
|
|
|
|
|
$('#screenshotsContainer', page).show();
|
2013-11-05 10:38:59 -05:00
|
|
|
|
renderImages(page, item, images, imageProviders, $('#screenshots', page));
|
2013-05-05 00:49:49 -04:00
|
|
|
|
} else {
|
|
|
|
|
$('#screenshotsContainer', page).hide();
|
|
|
|
|
}
|
2013-05-04 17:20:27 -04:00
|
|
|
|
}
|
|
|
|
|
|
2015-05-18 21:46:31 -04:00
|
|
|
|
function editItemImages() {
|
2013-05-04 17:20:27 -04:00
|
|
|
|
|
2015-05-18 21:46:31 -04:00
|
|
|
|
var self = this;
|
2013-05-05 00:49:49 -04:00
|
|
|
|
|
|
|
|
|
self.deleteImage = function (type, index) {
|
|
|
|
|
|
|
|
|
|
var page = $.mobile.activePage;
|
|
|
|
|
|
2014-07-16 23:17:14 -04:00
|
|
|
|
Dashboard.confirm(Globalize.translate('DeleteImageConfirmation'), Globalize.translate('HeaderDeleteImage'), function (result) {
|
2013-05-05 00:49:49 -04:00
|
|
|
|
|
|
|
|
|
if (result) {
|
2014-04-26 23:42:05 -04:00
|
|
|
|
ApiClient.deleteItemImage(currentItem.Id, type, index).done(function () {
|
2013-05-05 00:49:49 -04:00
|
|
|
|
|
2015-09-17 12:04:04 -04:00
|
|
|
|
reload(page);
|
2013-05-05 00:49:49 -04:00
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
self.moveImage = function (type, index, newIndex) {
|
|
|
|
|
|
|
|
|
|
var page = $.mobile.activePage;
|
|
|
|
|
|
2014-04-26 23:42:05 -04:00
|
|
|
|
ApiClient.updateItemImageIndex(currentItem.Id, type, index, newIndex).done(function () {
|
2013-05-05 00:49:49 -04:00
|
|
|
|
|
2015-09-17 12:04:04 -04:00
|
|
|
|
reload(page);
|
2013-05-05 00:49:49 -04:00
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
};
|
2013-10-31 21:55:38 -04:00
|
|
|
|
|
2013-11-01 11:55:25 -04:00
|
|
|
|
self.showDownloadMenu = function (type) {
|
2013-11-04 10:25:06 -05:00
|
|
|
|
browsableImageStartIndex = 0;
|
2013-10-31 21:55:38 -04:00
|
|
|
|
browsableImageType = type;
|
2014-02-25 10:40:16 -05:00
|
|
|
|
|
2015-07-14 15:04:16 -04:00
|
|
|
|
var page = $.mobile.activePage;
|
|
|
|
|
|
|
|
|
|
selectedProvider = null;
|
|
|
|
|
$('.popupDownload', page).popup('open');
|
|
|
|
|
reloadBrowsableImages(page);
|
2013-10-31 21:55:38 -04:00
|
|
|
|
};
|
2013-05-04 17:20:27 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
window.EditItemImagesPage = new editItemImages();
|
|
|
|
|
|
2015-09-17 12:04:04 -04:00
|
|
|
|
function initEditor(page) {
|
2013-05-04 17:20:27 -04:00
|
|
|
|
|
2013-10-31 17:03:24 -04:00
|
|
|
|
$('#selectBrowsableImageType', page).on('change', function () {
|
|
|
|
|
|
|
|
|
|
browsableImageType = this.value;
|
|
|
|
|
browsableImageStartIndex = 0;
|
2014-02-09 16:11:11 -05:00
|
|
|
|
selectedProvider = null;
|
2013-10-31 17:03:24 -04:00
|
|
|
|
|
|
|
|
|
reloadBrowsableImages(page);
|
|
|
|
|
});
|
|
|
|
|
|
2013-10-31 21:48:14 -04:00
|
|
|
|
$('#selectImageProvider', page).on('change', function () {
|
|
|
|
|
|
|
|
|
|
browsableImageStartIndex = 0;
|
2014-02-09 16:11:11 -05:00
|
|
|
|
selectedProvider = this.value;
|
2013-10-31 21:48:14 -04:00
|
|
|
|
|
|
|
|
|
reloadBrowsableImages(page);
|
|
|
|
|
});
|
|
|
|
|
|
2014-02-11 22:46:27 -05:00
|
|
|
|
$('#chkAllLanguages', page).on('change', function () {
|
|
|
|
|
|
|
|
|
|
browsableImageStartIndex = 0;
|
|
|
|
|
|
|
|
|
|
reloadBrowsableImages(page);
|
|
|
|
|
});
|
|
|
|
|
|
2015-08-02 19:47:31 -04:00
|
|
|
|
$('.btnOpenUploadMenu', page).on('click', function () {
|
2015-07-14 15:04:16 -04:00
|
|
|
|
|
2015-09-17 12:04:04 -04:00
|
|
|
|
require(['components/imageuploader/imageuploader'], function () {
|
|
|
|
|
|
|
|
|
|
ImageUploader.show(currentItem.Id).done(function (hasChanges) {
|
|
|
|
|
|
|
|
|
|
if (hasChanges) {
|
|
|
|
|
reload(page);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
});
|
2015-07-14 15:04:16 -04:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
$('.btnBrowseAllImages', page).on('click', function () {
|
|
|
|
|
|
|
|
|
|
selectedProvider = null;
|
|
|
|
|
browsableImageType = 'Primary';
|
|
|
|
|
$('.popupDownload', page).popup('open');
|
|
|
|
|
reloadBrowsableImages(page);
|
|
|
|
|
});
|
2015-09-17 12:04:04 -04:00
|
|
|
|
}
|
2015-05-18 21:46:31 -04:00
|
|
|
|
|
2015-09-17 12:04:04 -04:00
|
|
|
|
function showEditor(itemId) {
|
2013-05-05 00:49:49 -04:00
|
|
|
|
|
2015-09-17 12:04:04 -04:00
|
|
|
|
Dashboard.showLoadingMsg();
|
2013-05-04 17:20:27 -04:00
|
|
|
|
|
2015-09-17 12:04:04 -04:00
|
|
|
|
ApiClient.ajax({
|
2013-05-04 17:20:27 -04:00
|
|
|
|
|
2015-09-17 12:04:04 -04:00
|
|
|
|
type: 'GET',
|
|
|
|
|
url: 'components/imageeditor/imageeditor.template.html'
|
2013-05-04 17:20:27 -04:00
|
|
|
|
|
2015-09-17 12:04:04 -04:00
|
|
|
|
}).done(function (template) {
|
2013-05-04 17:20:27 -04:00
|
|
|
|
|
2015-09-17 12:04:04 -04:00
|
|
|
|
ApiClient.getItem(Dashboard.getCurrentUserId(), itemId).done(function (item) {
|
2013-05-04 17:20:27 -04:00
|
|
|
|
|
2015-09-17 12:04:04 -04:00
|
|
|
|
var dlg = document.createElement('paper-dialog');
|
2013-05-04 17:20:27 -04:00
|
|
|
|
|
2015-09-17 12:04:04 -04:00
|
|
|
|
dlg.setAttribute('with-backdrop', 'with-backdrop');
|
|
|
|
|
dlg.setAttribute('role', 'alertdialog');
|
|
|
|
|
dlg.entryAnimation = 'scale-up-animation';
|
|
|
|
|
dlg.exitAnimation = 'fade-out-animation';
|
|
|
|
|
dlg.classList.add('fullscreen-editor-paper-dialog');
|
|
|
|
|
dlg.classList.add('ui-body-b');
|
2013-05-04 17:20:27 -04:00
|
|
|
|
|
2015-09-17 12:04:04 -04:00
|
|
|
|
var html = '';
|
|
|
|
|
html += '<h2 class="dialogHeader">';
|
|
|
|
|
html += '<paper-fab icon="arrow-back" class="mini btnCloseDialog"></paper-fab>';
|
|
|
|
|
html += '<div style="display:inline-block;margin-left:.6em;vertical-align:middle;">' + item.Name + '</div>';
|
|
|
|
|
html += '</h2>';
|
2013-05-04 17:20:27 -04:00
|
|
|
|
|
2015-09-17 12:04:04 -04:00
|
|
|
|
html += '<div class="editorContent">';
|
|
|
|
|
html += Globalize.translateDocument(template);
|
|
|
|
|
html += '</div>';
|
2013-05-04 17:20:27 -04:00
|
|
|
|
|
2015-09-17 12:04:04 -04:00
|
|
|
|
dlg.innerHTML = html;
|
|
|
|
|
document.body.appendChild(dlg);
|
2013-05-04 17:20:27 -04:00
|
|
|
|
|
2015-09-17 12:04:04 -04:00
|
|
|
|
initEditor(dlg);
|
|
|
|
|
|
|
|
|
|
// Has to be assigned a z-index after the call to .open()
|
|
|
|
|
$(dlg).on('iron-overlay-closed', onDialogClosed);
|
|
|
|
|
|
|
|
|
|
document.body.classList.add('bodyWithPopupOpen');
|
|
|
|
|
PaperDialogHelper.openWithHash(dlg, 'imageeditor');
|
|
|
|
|
|
|
|
|
|
var editorContent = dlg.querySelector('.editorContent');
|
|
|
|
|
reload(editorContent, item);
|
|
|
|
|
|
|
|
|
|
$('.btnCloseDialog', dlg).on('click', closeDialog);
|
|
|
|
|
});
|
2015-07-14 16:29:51 -04:00
|
|
|
|
});
|
2015-09-17 12:04:04 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function closeDialog() {
|
|
|
|
|
|
|
|
|
|
history.back();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function onDialogClosed() {
|
|
|
|
|
|
|
|
|
|
document.body.classList.remove('bodyWithPopupOpen');
|
|
|
|
|
$(this).remove();
|
|
|
|
|
Dashboard.hideLoadingMsg();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
window.ImageEditor = {
|
|
|
|
|
show: function (itemId) {
|
|
|
|
|
|
|
|
|
|
require(['components/paperdialoghelper', 'jqmpopup'], function () {
|
|
|
|
|
|
|
|
|
|
Dashboard.importCss('css/metadataeditor.css');
|
|
|
|
|
showEditor(itemId);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
};
|
2013-05-04 17:20:27 -04:00
|
|
|
|
|
2013-11-27 14:04:19 -05:00
|
|
|
|
})(jQuery, document, window, window.FileReader, escape);
|