2016-08-29 23:06:24 -07:00
|
|
|
|
define(['dialogHelper', 'connectionManager', 'loading', 'dom', 'layoutManager', 'globalize', 'scrollHelper', 'require', 'cardStyle', 'formDialogStyle', 'emby-button', 'paper-icon-button-light'], function (dialogHelper, connectionManager, loading, dom, layoutManager, globalize, scrollHelper, require) {
|
2013-05-04 14:20:27 -07:00
|
|
|
|
|
|
|
|
|
var currentItem;
|
2015-10-15 22:36:16 -07:00
|
|
|
|
var hasChanges = false;
|
2013-05-04 14:20:27 -07:00
|
|
|
|
|
2013-10-31 18:48:14 -07:00
|
|
|
|
function getBaseRemoteOptions() {
|
2014-11-14 19:31:03 -07:00
|
|
|
|
|
2013-10-31 18:48:14 -07:00
|
|
|
|
var options = {};
|
|
|
|
|
|
2014-11-14 19:31:03 -07:00
|
|
|
|
options.itemId = currentItem.Id;
|
2013-10-31 18:48:14 -07:00
|
|
|
|
|
|
|
|
|
return options;
|
|
|
|
|
}
|
|
|
|
|
|
2015-09-17 09:04:04 -07:00
|
|
|
|
function reload(page, item) {
|
2013-05-04 14:20:27 -07:00
|
|
|
|
|
2016-08-29 21:33:24 -07:00
|
|
|
|
loading.show();
|
2013-05-04 14:20:27 -07:00
|
|
|
|
|
2016-08-29 23:06:24 -07:00
|
|
|
|
var apiClient;
|
|
|
|
|
|
2015-09-17 09:04:04 -07:00
|
|
|
|
if (item) {
|
2016-08-29 23:06:24 -07:00
|
|
|
|
apiClient = connectionManager.getApiClient(item.ServerId);
|
|
|
|
|
reloadItem(page, item, apiClient);
|
2015-09-17 09:04:04 -07:00
|
|
|
|
}
|
|
|
|
|
else {
|
2016-08-29 23:06:24 -07:00
|
|
|
|
|
|
|
|
|
apiClient = connectionManager.getApiClient(currentItem.ServerId);
|
|
|
|
|
apiClient.getItem(apiClient.getCurrentUserId(), currentItem.Id).then(function (item) {
|
|
|
|
|
reloadItem(page, item, apiClient);
|
2015-09-17 09:04:04 -07:00
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
2013-05-04 14:20:27 -07:00
|
|
|
|
|
2016-06-15 11:56:37 -07:00
|
|
|
|
function addListeners(elems, eventName, fn) {
|
|
|
|
|
|
|
|
|
|
for (var i = 0, length = elems.length; i < length; i++) {
|
|
|
|
|
|
|
|
|
|
elems[i].addEventListener(eventName, fn);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-08-29 23:06:24 -07:00
|
|
|
|
function reloadItem(page, item, apiClient) {
|
2013-05-04 14:20:27 -07:00
|
|
|
|
|
2015-09-17 09:04:04 -07:00
|
|
|
|
currentItem = item;
|
2013-11-27 12:04:19 -07:00
|
|
|
|
|
2016-08-29 23:06:24 -07:00
|
|
|
|
apiClient.getRemoteImageProviders(getBaseRemoteOptions()).then(function (providers) {
|
2013-11-27 12:04:19 -07:00
|
|
|
|
|
2016-06-15 11:56:37 -07:00
|
|
|
|
var btnBrowseAllImages = page.querySelectorAll('.btnBrowseAllImages');
|
|
|
|
|
for (var i = 0, length = btnBrowseAllImages.length; i < length; i++) {
|
|
|
|
|
|
|
|
|
|
if (providers.length) {
|
|
|
|
|
btnBrowseAllImages[i].classList.remove('hide');
|
|
|
|
|
} else {
|
|
|
|
|
btnBrowseAllImages[i].classList.add('hide');
|
|
|
|
|
}
|
2015-09-17 09:04:04 -07:00
|
|
|
|
}
|
2013-11-27 12:04:19 -07:00
|
|
|
|
|
2016-06-15 11:56:37 -07:00
|
|
|
|
|
2016-08-29 23:06:24 -07:00
|
|
|
|
apiClient.getItemImageInfos(currentItem.Id).then(function (imageInfos) {
|
2013-11-05 08:38:59 -07:00
|
|
|
|
|
2016-08-29 23:06:24 -07:00
|
|
|
|
renderStandardImages(page, apiClient, item, imageInfos, providers);
|
|
|
|
|
renderBackdrops(page, apiClient, item, imageInfos, providers);
|
|
|
|
|
renderScreenshots(page, apiClient, item, imageInfos, providers);
|
2016-08-29 21:33:24 -07:00
|
|
|
|
loading.hide();
|
2013-11-05 08:38:59 -07:00
|
|
|
|
});
|
2013-05-04 21:49:49 -07:00
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2016-08-29 23:06:24 -07:00
|
|
|
|
function getImageUrl(item, apiClient, type, index, options) {
|
2016-07-30 11:37:38 -07:00
|
|
|
|
|
|
|
|
|
options = options || {};
|
|
|
|
|
options.type = type;
|
|
|
|
|
options.index = index;
|
|
|
|
|
|
|
|
|
|
if (type == 'Backdrop') {
|
|
|
|
|
options.tag = item.BackdropImageTags[index];
|
|
|
|
|
} else if (type == 'Screenshot') {
|
|
|
|
|
options.tag = item.ScreenshotImageTags[index];
|
|
|
|
|
} else if (type == 'Primary') {
|
|
|
|
|
options.tag = item.PrimaryImageTag || item.ImageTags[type];
|
|
|
|
|
} else {
|
|
|
|
|
options.tag = item.ImageTags[type];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// For search hints
|
2016-08-29 23:06:24 -07:00
|
|
|
|
return apiClient.getScaledImageUrl(item.Id || item.ItemId, options);
|
2016-07-30 11:37:38 -07:00
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2016-08-29 23:06:24 -07:00
|
|
|
|
|
|
|
|
|
function getCardHtml(image, index, apiClient, imageProviders, imageSize, tagName, enableFooterButtons) {
|
2013-05-04 21:49:49 -07:00
|
|
|
|
|
|
|
|
|
var html = '';
|
|
|
|
|
|
2016-08-29 23:06:24 -07:00
|
|
|
|
var cssClass = "card scalableCard";
|
|
|
|
|
cssClass += " midBackdropCard midBackdropCard-scalable";
|
2013-05-04 21:49:49 -07:00
|
|
|
|
|
2016-08-29 23:06:24 -07:00
|
|
|
|
if (tagName == 'button') {
|
|
|
|
|
html += '<button type="button" class="' + cssClass + '">';
|
|
|
|
|
} else {
|
|
|
|
|
html += '<div class="' + cssClass + '">';
|
|
|
|
|
}
|
2013-05-04 21:49:49 -07:00
|
|
|
|
|
2016-08-29 23:06:24 -07:00
|
|
|
|
html += '<div class="cardBox visualCardBox">';
|
|
|
|
|
html += '<div class="cardScalable visualCardBox-cardScalable" style="background-color:transparent;">';
|
|
|
|
|
html += '<div class="cardPadder-backdrop"></div>';
|
2015-07-15 04:26:47 -07:00
|
|
|
|
|
2016-08-29 23:06:24 -07:00
|
|
|
|
html += '<div class="cardContent">';
|
2015-07-14 12:04:16 -07:00
|
|
|
|
|
2016-08-29 23:06:24 -07:00
|
|
|
|
var imageUrl = getImageUrl(currentItem, apiClient, image.ImageType, image.ImageIndex, { maxWidth: imageSize });
|
2013-05-04 21:49:49 -07:00
|
|
|
|
|
2016-08-29 23:06:24 -07:00
|
|
|
|
html += '<div class="cardImageContainer" style="background-image:url(\'' + imageUrl + '\');background-position:center bottom;"></div>';
|
2015-09-17 18:51:22 -07:00
|
|
|
|
|
2016-08-29 23:06:24 -07:00
|
|
|
|
html += '</div>';
|
|
|
|
|
html += '</div>';
|
2013-05-04 21:49:49 -07:00
|
|
|
|
|
2016-08-29 23:06:24 -07:00
|
|
|
|
html += '<div class="cardFooter visualCardBox-cardFooter">';
|
|
|
|
|
|
|
|
|
|
html += '<h3 class="cardText cardTextCentered" style="margin:0;">' + image.ImageType + '</h3>';
|
|
|
|
|
|
|
|
|
|
html += '<div class="cardText cardText-secondary cardTextCentered">';
|
|
|
|
|
if (image.Width && image.Height) {
|
|
|
|
|
html += image.Width + ' X ' + image.Height;
|
|
|
|
|
} else {
|
|
|
|
|
html += ' ';
|
|
|
|
|
}
|
|
|
|
|
html += '</div>';
|
2013-05-04 21:49:49 -07:00
|
|
|
|
|
2016-08-29 23:06:24 -07:00
|
|
|
|
if (enableFooterButtons) {
|
|
|
|
|
html += '<div class="cardText cardTextCentered">';
|
2013-05-04 21:49:49 -07:00
|
|
|
|
|
|
|
|
|
if (image.ImageType == "Backdrop" || image.ImageType == "Screenshot") {
|
|
|
|
|
|
2016-08-29 23:06:24 -07:00
|
|
|
|
if (index > 0) {
|
|
|
|
|
html += '<button is="paper-icon-button-light" class="btnMoveImage autoSize" data-imagetype="' + image.ImageType + '" data-index="' + image.ImageIndex + '" data-newindex="' + (image.ImageIndex - 1) + '" title="' + globalize.translate('sharedcomponents#MoveLeft') + '"><i class="md-icon">chevron_left</i></button>';
|
2013-05-04 21:49:49 -07:00
|
|
|
|
} else {
|
2016-08-29 23:06:24 -07:00
|
|
|
|
html += '<button is="paper-icon-button-light" class="autoSize" disabled title="' + globalize.translate('sharedcomponents#MoveLeft') + '"><i class="md-icon">chevron_left</i></button>';
|
2013-05-04 21:49:49 -07:00
|
|
|
|
}
|
|
|
|
|
|
2016-08-29 23:06:24 -07:00
|
|
|
|
if (index < length - 1) {
|
|
|
|
|
html += '<button is="paper-icon-button-light" class="btnMoveImage autoSize" data-imagetype="' + image.ImageType + '" data-index="' + image.ImageIndex + '" data-newindex="' + (image.ImageIndex + 1) + '" title="' + globalize.translate('sharedcomponents#MoveRight') + '"><i class="md-icon">chevron_right</i></button>';
|
2013-05-04 21:49:49 -07:00
|
|
|
|
} else {
|
2016-08-29 23:06:24 -07:00
|
|
|
|
html += '<button is="paper-icon-button-light" class="autoSize" disabled title="' + globalize.translate('sharedcomponents#MoveRight') + '"><i class="md-icon">chevron_right</i></button>';
|
2013-05-04 21:49:49 -07:00
|
|
|
|
}
|
|
|
|
|
}
|
2015-09-17 18:51:22 -07:00
|
|
|
|
else {
|
|
|
|
|
if (imageProviders.length) {
|
2016-08-29 23:06:24 -07:00
|
|
|
|
html += '<button is="paper-icon-button-light" data-imagetype="' + image.ImageType + '" class="btnSearchImages autoSize" title="' + globalize.translate('sharedcomponents#Search') + '"><i class="md-icon">search</i></button>';
|
2015-09-17 18:51:22 -07:00
|
|
|
|
}
|
2013-11-05 08:38:59 -07:00
|
|
|
|
}
|
2013-10-31 18:55:38 -07:00
|
|
|
|
|
2016-08-29 23:06:24 -07:00
|
|
|
|
html += '<button is="paper-icon-button-light" data-imagetype="' + image.ImageType + '" data-index="' + (image.ImageIndex != null ? image.ImageIndex : "null") + '" class="btnDeleteImage autoSize" title="' + globalize.translate('sharedcomponents#Delete') + '"><i class="md-icon">delete</i></button>';
|
2015-09-17 09:04:04 -07:00
|
|
|
|
html += '</div>';
|
2016-08-29 23:06:24 -07:00
|
|
|
|
}
|
2013-05-04 21:49:49 -07:00
|
|
|
|
|
2016-08-29 23:06:24 -07:00
|
|
|
|
html += '</div>';
|
|
|
|
|
html += '</div>';
|
|
|
|
|
html += '</div>';
|
|
|
|
|
html += '</' + tagName + '>';
|
|
|
|
|
|
|
|
|
|
return html;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function renderImages(page, item, apiClient, images, imageProviders, elem) {
|
|
|
|
|
|
|
|
|
|
var html = '';
|
|
|
|
|
|
|
|
|
|
var imageSize = 300;
|
|
|
|
|
var windowSize = dom.getWindowSize();
|
|
|
|
|
if (windowSize.innerWidth >= 1280) {
|
|
|
|
|
imageSize = Math.round(windowSize.innerWidth / 4);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var tagName = layoutManager.tv ? 'button' : 'div';
|
|
|
|
|
var enableFooterButtons = !layoutManager.tv;
|
|
|
|
|
|
|
|
|
|
for (var i = 0, length = images.length; i < length; i++) {
|
|
|
|
|
|
|
|
|
|
var image = images[i];
|
|
|
|
|
|
|
|
|
|
html += getCardHtml(image, i, apiClient, imageProviders, imageSize, tagName, enableFooterButtons);
|
2013-05-04 21:49:49 -07:00
|
|
|
|
}
|
|
|
|
|
|
2015-09-17 10:24:23 -07:00
|
|
|
|
elem.innerHTML = html;
|
2015-09-24 22:15:29 -07:00
|
|
|
|
ImageLoader.lazyChildren(elem);
|
2015-09-17 10:24:23 -07:00
|
|
|
|
|
2016-06-15 11:56:37 -07:00
|
|
|
|
addListeners(elem.querySelectorAll('.btnSearchImages'), 'click', function () {
|
2015-09-17 10:24:23 -07:00
|
|
|
|
showImageDownloader(page, this.getAttribute('data-imagetype'));
|
|
|
|
|
});
|
|
|
|
|
|
2016-06-15 11:56:37 -07:00
|
|
|
|
addListeners(elem.querySelectorAll('.btnDeleteImage'), 'click', function () {
|
2015-09-17 10:24:23 -07:00
|
|
|
|
var type = this.getAttribute('data-imagetype');
|
|
|
|
|
var index = this.getAttribute('data-index');
|
|
|
|
|
index = index == "null" ? null : parseInt(index);
|
|
|
|
|
|
2016-02-22 12:12:06 -07:00
|
|
|
|
require(['confirm'], function (confirm) {
|
|
|
|
|
|
2016-08-29 23:06:24 -07:00
|
|
|
|
confirm(globalize.translate('sharedcomponents#ConfirmDeleteImage')).then(function () {
|
2016-02-22 12:12:06 -07:00
|
|
|
|
|
2015-12-14 08:43:03 -07:00
|
|
|
|
ApiClient.deleteItemImage(currentItem.Id, type, index).then(function () {
|
2015-09-17 10:24:23 -07:00
|
|
|
|
|
2015-10-15 22:36:16 -07:00
|
|
|
|
hasChanges = true;
|
2015-09-17 10:24:23 -07:00
|
|
|
|
reload(page);
|
|
|
|
|
|
|
|
|
|
});
|
2016-02-22 12:12:06 -07:00
|
|
|
|
});
|
2015-09-17 10:24:23 -07:00
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
2016-06-15 11:56:37 -07:00
|
|
|
|
addListeners(elem.querySelectorAll('.btnMoveImage'), 'click', function () {
|
2015-09-17 10:24:23 -07:00
|
|
|
|
var type = this.getAttribute('data-imagetype');
|
|
|
|
|
var index = parseInt(this.getAttribute('data-index'));
|
|
|
|
|
var newIndex = parseInt(this.getAttribute('data-newindex'));
|
2015-12-14 08:43:03 -07:00
|
|
|
|
ApiClient.updateItemImageIndex(currentItem.Id, type, index, newIndex).then(function () {
|
2015-09-17 10:24:23 -07:00
|
|
|
|
|
2015-10-15 22:36:16 -07:00
|
|
|
|
hasChanges = true;
|
2015-09-17 10:24:23 -07:00
|
|
|
|
reload(page);
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
});
|
2013-05-04 21:49:49 -07:00
|
|
|
|
}
|
|
|
|
|
|
2016-08-29 23:06:24 -07:00
|
|
|
|
function renderStandardImages(page, apiClient, item, imageInfos, imageProviders) {
|
2013-05-04 21:49:49 -07:00
|
|
|
|
|
|
|
|
|
var images = imageInfos.filter(function (i) {
|
|
|
|
|
return i.ImageType != "Screenshot" && i.ImageType != "Backdrop" && i.ImageType != "Chapter";
|
2013-05-04 14:20:27 -07:00
|
|
|
|
});
|
2013-05-04 21:49:49 -07:00
|
|
|
|
|
2016-08-29 23:06:24 -07:00
|
|
|
|
renderImages(page, item, apiClient, images, imageProviders, page.querySelector('#images'));
|
2013-05-04 21:49:49 -07:00
|
|
|
|
}
|
|
|
|
|
|
2016-08-29 23:06:24 -07:00
|
|
|
|
function renderBackdrops(page, apiClient, item, imageInfos, imageProviders) {
|
2013-05-04 21:49:49 -07:00
|
|
|
|
|
|
|
|
|
var images = imageInfos.filter(function (i) {
|
|
|
|
|
return i.ImageType == "Backdrop";
|
|
|
|
|
|
|
|
|
|
}).sort(function (a, b) {
|
|
|
|
|
return a.ImageIndex - b.ImageIndex;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
if (images.length) {
|
2016-06-15 09:45:45 -07:00
|
|
|
|
page.querySelector('#backdropsContainer', page).classList.remove('hide');
|
2016-08-29 23:06:24 -07:00
|
|
|
|
renderImages(page, item, apiClient, images, imageProviders, page.querySelector('#backdrops'));
|
2013-05-04 21:49:49 -07:00
|
|
|
|
} else {
|
2016-06-15 09:45:45 -07:00
|
|
|
|
page.querySelector('#backdropsContainer', page).classList.add('hide');
|
2013-05-04 21:49:49 -07:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-08-29 23:06:24 -07:00
|
|
|
|
function renderScreenshots(page, apiClient, item, imageInfos, imageProviders) {
|
2013-05-04 21:49:49 -07:00
|
|
|
|
|
|
|
|
|
var images = imageInfos.filter(function (i) {
|
|
|
|
|
return i.ImageType == "Screenshot";
|
|
|
|
|
|
|
|
|
|
}).sort(function (a, b) {
|
|
|
|
|
return a.ImageIndex - b.ImageIndex;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
if (images.length) {
|
2016-06-15 09:45:45 -07:00
|
|
|
|
page.querySelector('#screenshotsContainer', page).classList.remove('hide');
|
2016-08-29 23:06:24 -07:00
|
|
|
|
renderImages(page, item, apiClient, images, imageProviders, page.querySelector('#screenshots'));
|
2013-05-04 21:49:49 -07:00
|
|
|
|
} else {
|
2016-06-15 09:45:45 -07:00
|
|
|
|
page.querySelector('#screenshotsContainer', page).classList.add('hide');
|
2013-05-04 21:49:49 -07:00
|
|
|
|
}
|
2013-05-04 14:20:27 -07:00
|
|
|
|
}
|
|
|
|
|
|
2015-09-17 10:24:23 -07:00
|
|
|
|
function showImageDownloader(page, imageType) {
|
2015-12-14 08:43:03 -07:00
|
|
|
|
require(['components/imagedownloader/imagedownloader'], function (ImageDownloader) {
|
2013-05-04 21:49:49 -07:00
|
|
|
|
|
2016-06-24 21:22:11 -07:00
|
|
|
|
ImageDownloader.show(currentItem.Id, currentItem.Type, imageType).then(function () {
|
2013-05-04 21:49:49 -07:00
|
|
|
|
|
2016-06-24 21:22:11 -07:00
|
|
|
|
hasChanges = true;
|
|
|
|
|
reload(page);
|
2013-05-04 21:49:49 -07:00
|
|
|
|
});
|
2015-09-17 10:24:23 -07:00
|
|
|
|
});
|
2013-05-04 14:20:27 -07:00
|
|
|
|
}
|
|
|
|
|
|
2015-10-15 22:36:16 -07:00
|
|
|
|
function initEditor(page, options) {
|
2013-05-04 14:20:27 -07:00
|
|
|
|
|
2016-06-15 11:56:37 -07:00
|
|
|
|
addListeners(page.querySelectorAll('.btnOpenUploadMenu'), 'click', function () {
|
2016-02-06 13:32:14 -07:00
|
|
|
|
var imageType = this.getAttribute('data-imagetype');
|
|
|
|
|
|
2015-12-14 08:43:03 -07:00
|
|
|
|
require(['components/imageuploader/imageuploader'], function (imageUploader) {
|
|
|
|
|
|
|
|
|
|
imageUploader.show(currentItem.Id, {
|
2015-09-17 09:04:04 -07:00
|
|
|
|
|
2016-02-06 13:32:14 -07:00
|
|
|
|
theme: options.theme,
|
|
|
|
|
imageType: imageType
|
2015-10-15 22:36:16 -07:00
|
|
|
|
|
2015-12-14 08:43:03 -07:00
|
|
|
|
}).then(function (hasChanged) {
|
2015-09-17 09:04:04 -07:00
|
|
|
|
|
2015-10-15 22:36:16 -07:00
|
|
|
|
if (hasChanged) {
|
|
|
|
|
hasChanges = true;
|
2015-09-17 09:04:04 -07:00
|
|
|
|
reload(page);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
});
|
2015-07-14 12:04:16 -07:00
|
|
|
|
});
|
|
|
|
|
|
2016-06-15 11:56:37 -07:00
|
|
|
|
addListeners(page.querySelectorAll('.btnBrowseAllImages'), 'click', function () {
|
2015-09-17 18:51:22 -07:00
|
|
|
|
showImageDownloader(page, this.getAttribute('data-imagetype') || 'Primary');
|
2015-07-14 12:04:16 -07:00
|
|
|
|
});
|
2015-09-17 09:04:04 -07:00
|
|
|
|
}
|
2015-05-18 18:46:31 -07:00
|
|
|
|
|
2016-08-29 23:06:24 -07:00
|
|
|
|
function showEditor(options, resolve, reject) {
|
2015-10-15 22:36:16 -07:00
|
|
|
|
|
2016-08-29 23:06:24 -07:00
|
|
|
|
var itemId = options.itemId;
|
|
|
|
|
var serverId = options.serverId;
|
2013-05-04 21:49:49 -07:00
|
|
|
|
|
2016-08-29 21:33:24 -07:00
|
|
|
|
loading.show();
|
2013-05-04 14:20:27 -07:00
|
|
|
|
|
2016-08-29 23:06:24 -07:00
|
|
|
|
require(['text!./imageeditor.template.html'], function (template) {
|
|
|
|
|
var apiClient = connectionManager.getApiClient(serverId);
|
|
|
|
|
apiClient.getItem(apiClient.getCurrentUserId(), itemId).then(function (item) {
|
2013-05-04 14:20:27 -07:00
|
|
|
|
|
2016-08-29 23:06:24 -07:00
|
|
|
|
var dialogOptions = {
|
2016-06-15 09:45:45 -07:00
|
|
|
|
removeOnClose: true
|
2016-08-29 23:06:24 -07:00
|
|
|
|
};
|
2013-05-04 14:20:27 -07:00
|
|
|
|
|
2016-08-29 23:06:24 -07:00
|
|
|
|
if (layoutManager.tv) {
|
|
|
|
|
dialogOptions.size = 'fullscreen';
|
|
|
|
|
} else {
|
|
|
|
|
dialogOptions.size = 'fullscreen-border';
|
|
|
|
|
}
|
2016-01-30 13:59:09 -07:00
|
|
|
|
|
2016-08-29 23:06:24 -07:00
|
|
|
|
var dlg = dialogHelper.createDialog(dialogOptions);
|
2016-01-30 13:59:09 -07:00
|
|
|
|
|
2016-08-29 23:06:24 -07:00
|
|
|
|
dlg.classList.add('formDialog');
|
2013-05-04 14:20:27 -07:00
|
|
|
|
|
2016-08-29 23:06:24 -07:00
|
|
|
|
dlg.innerHTML = globalize.translateDocument(template, 'sharedcomponents');
|
|
|
|
|
dlg.querySelector('.formDialogHeaderTitle').innerHTML = item.Name;
|
2013-05-04 14:20:27 -07:00
|
|
|
|
|
2015-09-17 09:04:04 -07:00
|
|
|
|
document.body.appendChild(dlg);
|
2013-05-04 14:20:27 -07:00
|
|
|
|
|
2016-08-29 23:06:24 -07:00
|
|
|
|
if (layoutManager.tv) {
|
|
|
|
|
scrollHelper.centerFocus.on(dlg, false);
|
|
|
|
|
}
|
|
|
|
|
|
2015-10-15 22:36:16 -07:00
|
|
|
|
initEditor(dlg, options);
|
2015-09-17 09:04:04 -07:00
|
|
|
|
|
|
|
|
|
// Has to be assigned a z-index after the call to .open()
|
2016-06-28 21:05:16 -07:00
|
|
|
|
dlg.addEventListener('close', function () {
|
|
|
|
|
|
2016-08-29 23:06:24 -07:00
|
|
|
|
if (layoutManager.tv) {
|
|
|
|
|
scrollHelper.centerFocus.off(dlg, false);
|
|
|
|
|
}
|
|
|
|
|
|
2016-08-29 21:33:24 -07:00
|
|
|
|
loading.hide();
|
2016-06-28 21:05:16 -07:00
|
|
|
|
|
|
|
|
|
if (hasChanges) {
|
|
|
|
|
resolve();
|
|
|
|
|
} else {
|
|
|
|
|
reject();
|
|
|
|
|
}
|
|
|
|
|
});
|
2015-09-17 09:04:04 -07:00
|
|
|
|
|
2016-03-23 12:03:17 -07:00
|
|
|
|
dialogHelper.open(dlg);
|
2015-09-17 09:04:04 -07:00
|
|
|
|
|
2016-08-29 23:06:24 -07:00
|
|
|
|
reload(dlg, item);
|
2015-09-17 09:04:04 -07:00
|
|
|
|
|
2016-08-29 23:06:24 -07:00
|
|
|
|
dlg.querySelector('.btnCancel').addEventListener('click', function () {
|
2015-12-14 08:43:03 -07:00
|
|
|
|
|
2016-03-23 12:03:17 -07:00
|
|
|
|
dialogHelper.close(dlg);
|
2015-09-29 09:29:06 -07:00
|
|
|
|
});
|
2015-09-17 09:04:04 -07:00
|
|
|
|
});
|
2016-08-29 23:06:24 -07:00
|
|
|
|
});
|
2015-09-17 09:04:04 -07:00
|
|
|
|
}
|
|
|
|
|
|
2015-12-14 08:43:03 -07:00
|
|
|
|
return {
|
2016-08-29 23:06:24 -07:00
|
|
|
|
show: function (options) {
|
2015-10-15 22:36:16 -07:00
|
|
|
|
|
2016-06-24 09:51:13 -07:00
|
|
|
|
return new Promise(function (resolve, reject) {
|
2015-10-15 22:36:16 -07:00
|
|
|
|
|
2016-06-24 09:51:13 -07:00
|
|
|
|
hasChanges = false;
|
2015-09-17 09:04:04 -07:00
|
|
|
|
|
2016-08-29 23:06:24 -07:00
|
|
|
|
showEditor(options, resolve, reject);
|
2016-06-24 09:51:13 -07:00
|
|
|
|
});
|
2015-09-17 09:04:04 -07:00
|
|
|
|
}
|
|
|
|
|
};
|
2015-12-14 08:43:03 -07:00
|
|
|
|
});
|