var _____WB$wombat$assign$function_____ = function(name) {return (self._wb_wombat && self._wb_wombat.local_init && self._wb_wombat.local_init(name)) || self[name]; };
if (!self.__WB_pmw) { self.__WB_pmw = function(obj) { this.__WB_source = obj; return this; } }
{
let window = _____WB$wombat$assign$function_____("window");
let self = _____WB$wombat$assign$function_____("self");
let document = _____WB$wombat$assign$function_____("document");
let location = _____WB$wombat$assign$function_____("location");
let top = _____WB$wombat$assign$function_____("top");
let parent = _____WB$wombat$assign$function_____("parent");
let frames = _____WB$wombat$assign$function_____("frames");
let opener = _____WB$wombat$assign$function_____("opener");
ASPxHtmlEditorDialogSR = { };
ASPxHtmlEditorDialog = _aspxCreateClass(ASPxDialog, {
Execute: function(ownerControl) {
this.htmlEditor = ownerControl;
this.SaveDocumentScrollPosition();
this.CreateSelectionInfo();
if (__aspxIE)
this.SaveScrollPosition();
this.htmlEditor.RemoveFocus();
if (__aspxOpera || __aspxChrome)
this.RestoreDocumentScrollPosition();
this.SetDialogNameInput();
this.isOnCallbackError = false;
this.isPreventKeyPress = false;
ASPxDialog.prototype.Execute.call(this, ownerControl);
},
ExecuteInternal: function(result) {
ASPxDialog.prototype.ExecuteInternal.call(this, result);
var nonEmptyTextPattern = /\S/;
var contentContainer = this.GetDialogPopup().GetContentContainer(-1);
if(contentContainer.lastChild && contentContainer.lastChild.nodeType == 3 && !nonEmptyTextPattern.test(contentContainer.lastChild.nodeValue))
contentContainer.removeChild(contentContainer.lastChild);
},
OnCallbackError: function(result, data) {
this.isOnCallbackError = true;
this.ClearDialogNameInput();
this.HideDialog(null, true);
ASPxDialog.prototype.OnCallbackError.call(this, result);
},
OnClose: function() {
ASPxDialog.prototype.OnClose.call(this);
this.ClearDialogNameInput();
if (!this.isOnCallbackError)
this.SaveEditorsState();
},
OnCloseButtonClick: function() {
this.htmlEditor.RestoreLastSelection(this.selectionInfo.selection);
this.htmlEditor.UpdateToolbar();
},
OnComplete: function(result, params) {
this.HideDialogPopup();
this.htmlEditor.RestoreLastSelection(this.selectionInfo.selection);
if(__aspxIE && __aspxBrowserMajorVersion > 8)
this.htmlEditor.RestoreSelection();
this.DoCustomAction(result, params);
this.ClearEditorValue();
if (!result)
this.htmlEditor.UpdateToolbar();
},
OnInitComplete: function() {
ASPxDialog.prototype.OnInitComplete.call(this);
this.GetDialogPopup().UpdatePosition();
if (__aspxIE)
this.RestoreScrollPositionAndSelection();
var htmlEditor = this.htmlEditor;
htmlEditor.ClearFocusInput();
this.RestoreEditorsState();
},
OnDocumentKeyPress: function(evt) {
if(!this.isPreventKeyPress)
ASPxDialog.prototype.OnDocumentKeyPress.call(this, evt);
},
SaveEditorsState: function() {
},
RestoreEditorsState: function() {
},
ClearEditorValue: function() {
},
CreateSelectionInfo: function() {
var curSelection = this.htmlEditor.CreateRestoreSelectionForDialog();
this.selectionInfo = {
selection: curSelection,
isControl: curSelection.IsControl(),
text: curSelection.GetText(),
htmlText: curSelection.GetHtmlText(),
selectedElement: curSelection.GetParentElement(),
endSelectedElement: curSelection.GetEndContainer()
};
},
ClearDialogNameInput: function() {
this.htmlEditor.GetCurrentDialogHiddenField().value = "";
},
SendCallback: function(callbackArgs) {
this.ownerControl.callbackOwner = this;
this.ownerControl.CreateCallback(callbackArgs, "", false);
this.ShowLoadingPanelOverDialogPopup();
},
SetDialogNameInput: function() {
this.htmlEditor.GetCurrentDialogHiddenField().value = this.name;
},
RestoreScrollPositionAndSelection: function() {
this.htmlEditor.RestoreLastSelection(this.selectionInfo.selection);
if (this.savedScrollLeft > 0)
this.htmlEditor.GetDesignViewDocument().body.scrollLeft = this.savedScrollLeft;
if (this.savedScrollTop > 0)
this.htmlEditor.GetDesignViewDocument().body.scrollTop = this.savedScrollTop;
},
RestoreDocumentScrollPosition: function() {
var scrollElement = __aspxIE || __aspxFirefox ? document.documentElement : document.body;
if(this.savedDocumentScrollLeft)
scrollElement.scrollLeft = this.savedDocumentScrollLeft;
if(this.savedDocumentScrollTop)
scrollElement.scrollTop = this.savedDocumentScrollTop;
},
SaveScrollPosition: function() {
this.savedScrollLeft = this.htmlEditor.GetDesignViewDocument().body.scrollLeft;
this.savedScrollTop = this.htmlEditor.GetDesignViewDocument().body.scrollTop;
},
SaveDocumentScrollPosition: function() {
this.savedDocumentScrollLeft = _aspxGetDocumentScrollLeft();
this.savedDocumentScrollTop = _aspxGetDocumentScrollTop();
},
IsEnabledEditor: function(editor) {
return _aspxGetElementVisibility(editor.GetMainElement());
}
});
ASPxCustomDialog = _aspxCreateClass(ASPxHtmlEditorDialog, {
constructor: function(customDialogName, customDialogPublicName) {
this.constructor.prototype.constructor.call(this, customDialogName);
this.publicName = customDialogPublicName;
},
OnCallbackError: function(result, data) {
ASPxHtmlEditorDialog.prototype.OnCallbackError.call(this, result, data);
ASPxHtmlEditorCommandList[ASPxClientCommandConsts.CUSTOMDIALOG_COMMAND].DialogNotFound(this.name);
},
GetDialogCaptionText: function() {
return this.htmlEditor.customDialogsCaptions[this.name] || "";
},
OnInitComplete: function() {
this.RestoreDocumentScrollPosition();
ASPxHtmlEditorDialog.prototype.OnInitComplete.call(this);
var _this = this;
setTimeout(function() {
_this.SetFakeFocus();
_this.htmlEditor.RaiseCustomDialogOpened(_this.publicName);
}, 0);
},
SetFakeFocus: function() {
if(!this.fakeFocusElement) {
this.fakeFocusElement = document.createElement("A");
this.fakeFocusElement.setAttribute("href", "#");
}
this.GetDialogPopup().GetContentContainer(-1).appendChild(this.fakeFocusElement);
this.fakeFocusElement.focus();
},
OnClosing: function(args) {
ASPxHtmlEditorDialog.prototype.OnClosing.call(this);
if(args)
args.cancel = true;
var canceled = this.htmlEditor.RaiseCustomDialogClosing(this.publicName, "cancel");
if(!canceled)
ASPxClientHtmlEditor.CustomDialogComplete("cancel", null);
return canceled;
},
DoCustomAction: function(result, data) {
ASPxHtmlEditorDialog.prototype.DoCustomAction.call(this);
this.htmlEditor.RaiseCustomDialogClosed(this.publicName, result, data);
}
});
__aspxDefaultLinkHref = "http://";
__aspxMailtToPrefix = "mailto:";
__aspxMailtToSubjectPrefix = "?subject=";
__aspxOpenInNewWindowTarget = "_blank";
InsertLinkDialog = _aspxCreateClass(ASPxHtmlEditorDialog , {
OnInitComplete: function() {
ASPxHtmlEditorDialog.prototype.OnInitComplete.apply(this, arguments);
if(typeof(ASPxClientHtmlEditorFileManager) != "undefined")
ASPxClientHtmlEditorFileManager.SetOwner(this.GetDialogPopup().GetContentContainer(-1), this.htmlEditor);
},
DoCustomAction: function(result, params) {
if (result) {
var target = "";
var title = "";
var text = "";
var url = "";
title = params.title;
text = params.text;
switch (_dxeRblLinkType.GetValue()) {
case "Email":
url = __aspxMailtToPrefix + params.url;
if (params.subject)
url += __aspxMailtToSubjectPrefix + params.subject;
break;
case "URL":
url = params.url;
target = params.isCheckedOpenInNewWindow ? __aspxOpenInNewWindowTarget : "";
break;
}
if (params.isTextOnlySelected && (text == ""))
text = params.url;
this.htmlEditor.InsertLink(url, text, target, title);
}
},
GetDialogCaptionText: function() {
return InsertLinkDialog.prototype.IsLink(this.selectionInfo.selectedElement)
? ASPxHtmlEditorDialogSR.ChangeLink
: ASPxHtmlEditorDialogSR.InsertLink;
},
GetInitInfoObject: function() {
var linkInfoObject = {
href: "",
text: "",
title: "",
target: ""
};
var link = this.selectionInfo.selectedElement.tagName == "A" ? this.selectionInfo.selectedElement : _aspxGetParentByTagName(this.selectionInfo.selectedElement, "A");
var isTextEditorVisible =true;
if (link) {
if (!InsertLinkDialog.prototype.ContaintTextNodeOnly(link) || this.selectionInfo.isControl)
isTextEditorVisible = false;
}
else {
var img = _aspxGetParentByTagName(this.selectionInfo.selectedElement, "img");
if (img)
isTextEditorVisible = false;
else {
var text = this.selectionInfo.text;
if (text) text = this.selectionInfo.htmlText;
isTextEditorVisible = !ASPxClientSelection.IsHtml(_aspxTrim(text));
}
}
linkInfoObject.isTextEditorVisible = isTextEditorVisible;
linkInfoObject.text = this.selectionInfo.text;
if (link) {
linkInfoObject.href = _aspxGetAttribute(link, "href");
linkInfoObject.text = link.innerHTML;
linkInfoObject.title = _aspxGetAttribute(link, "title");
linkInfoObject.target = _aspxGetAttribute(link, "target");
}
if (linkInfoObject.href == "")
linkInfoObject.href = __aspxDefaultLinkHref;
return linkInfoObject;
},
InitializeDialogFields: function(linkInfo) {
var isLinkSelected = InsertLinkDialog.prototype.IsLink(this.selectionInfo.selectedElement);
this.GetChangeButton().SetVisible(isLinkSelected);
this.GetInsertButton().SetVisible(!isLinkSelected);
if(!linkInfo.href) {
this.GetLinkTypeRadioButtonList().SetValue("URL");
this.GetUrlTextBox().SetValue("");
this.GetOpenInNewWindowCheckBox().SetValue(false);
}
else if ((linkInfo.href != "") && (linkInfo.href.indexOf(__aspxMailtToPrefix) > -1)) {
var mailtoIndex = linkInfo.href.indexOf(__aspxMailtToPrefix);
var subjectIndex = linkInfo.href.indexOf(__aspxMailtToSubjectPrefix);
var index = subjectIndex > -1 ? subjectIndex : linkInfo.href.length;
this.GetEmailToTextBox().SetValue(linkInfo.href.substring(mailtoIndex + __aspxMailtToPrefix.length, index));
var subject = "";
if (subjectIndex > -1)
subject = linkInfo.href.substring(subjectIndex + __aspxMailtToSubjectPrefix.length);
this.GetSubjectTextBox().SetValue(subject);
this.GetLinkTypeRadioButtonList().SetValue("Email");
}
else {
this.GetLinkTypeRadioButtonList().SetValue("URL");
this.GetUrlTextBox().SetValue(linkInfo.href);
if(linkInfo.href != __aspxDefaultLinkHref || linkInfo.target != "")
this.GetOpenInNewWindowCheckBox().SetValue(linkInfo.target == __aspxOpenInNewWindowTarget);
}
this.GetToolTipTextBox().SetValue(linkInfo.title);
if (linkInfo.isTextEditorVisible)
this.GetTextTextBox().SetValue(linkInfo.text);
else {
this.GetTextTextBox().SetEnabled(false);
this.GetLabelText().SetEnabled(false);
}
this.GetLinkTypeRadioButtonList().RaiseSelectedIndexChanged();
},
ClearEditorValue: function() {
this.GetEmailToTextBox().SetValue(null);
this.GetSubjectTextBox().SetValue(null);
this.GetUrlTextBox().SetValue(null);
this.GetToolTipTextBox().SetValue(null);
this.GetTextTextBox().SetValue(null);
},
SetFocusInField: function() {
if (this.GetLinkTypeRadioButtonList().GetValue() == "URL")
_aspxSetFocusToTextEditWithDelay(_dxeTxbURL.name);
else
_aspxSetFocusToTextEditWithDelay(_dxeTxbEmailTo.name);
},
GetChangeButton: function() {
return window._dxeBtnChange || null;
},
GetEmailToTextBox: function() {
return _dxeTxbEmailTo;
},
GetInsertButton: function() {
return _dxeBtnOk;
},
GetLabelText: function() {
return _dxeLblText;
},
GetLinkTypeRadioButtonList: function() {
return _dxeRblLinkType;
},
GetOpenInNewWindowCheckBox: function() {
return _dxeCkbOpenInNewWindow;
},
GetTextTextBox: function() {
return _dxeTxbText;
},
GetToolTipTextBox: function() {
return _dxeTxbToolTip;
},
GetSubjectTextBox: function() {
return _dxeTxbSubject;
},
GetUrlTextBox: function() {
return _dxeTxbURL;
}
});
InsertLinkDialog.prototype.ContaintTextNodeOnly = function(linkElement) {
if (linkElement.childNodes.length > 0) {
for (var i = 0; i < linkElement.childNodes.length; i++) {
if (linkElement.childNodes[i].nodeType != 3)
return false;
}
}
return true;
};
InsertLinkDialog.prototype.IsLinkSelected = function(htmlEditor) {
var curSelection = ASPxClientHtmlEditorSelection.Create(htmlEditor);
return InsertLinkDialog.prototype.IsLink(curSelection.GetParentElement());
};
InsertLinkDialog.prototype.IsLink = function(element) {
return !!_aspxGetParentByTagName(element, "A");
};
var __aspxPreviewTextElementID = "_dxInsertImagePreviewText";
var __aspxPreviewImageElementID = "_dxInsertImagePreviewImage";
InsertImageDialog = _aspxCreateClass(ASPxHtmlEditorDialog, {
OnInitComplete: function() {
ASPxHtmlEditorDialog.prototype.OnInitComplete.apply(this, arguments);
if(typeof(ASPxClientHtmlEditorFileManager) != "undefined")
ASPxClientHtmlEditorFileManager.SetOwner(this.GetDialogPopup().GetContentContainer(-1), this.htmlEditor);
},
DoCustomAction: function(result, params) {
if (result) {
if (this.selectedImageElement)
this.htmlEditor.ChangeImage(this.selectedImageElement, params);
else
this.htmlEditor.InsertImage(params);
}
},
GetDialogCaptionText: function() {
var img = InsertImageDialog.prototype.GetImage(this.selectionInfo.selectedElement);
return img
? ASPxHtmlEditorDialogSR.ChangeImage
: ASPxHtmlEditorDialogSR.InsertImage;
},
GetInitInfoObject: function() {
var imageInfoObject = {
isCustomSize: false,
src: "",
width: "",
height: "",
align: "",
alt: "",
useFloat: false
};
this.constrainProportions = true;
this.selectedImageElement = InsertImageDialog.prototype.GetImage(this.selectionInfo.selectedElement);
if (this.selectedImageElement)
imageInfoObject = ASPxHtmlEditorCommands.ChangeImage.GetImageProperties(this.selectedImageElement);
return imageInfoObject;
},
InitializeDialogFields: function(imageInfo) {
var isImage = !!this.selectedImageElement;
this.GetChangeButton().SetVisible(isImage);
this.GetInsertButton().SetVisible(!isImage);
if (imageInfo.src) {
this.fieldInitializing = true;
_dxeTbxInsertImageUrl.SetValue(imageInfo.src);
this.OnImageSrcChanged(imageInfo.src);
}
this.UpdateSizeFields(imageInfo.width ? imageInfo.width : 0, imageInfo.height ? imageInfo.height : 0);
if (imageInfo.isCustomSize) {
_dxeCmbSize.SetValue("custom");
_dxeCmbSize.OnSelectChanged();
}
if (imageInfo.align)
_dxeCmbImagePosition.SetValue(imageInfo.align);
if (imageInfo.alt)
_dxeTxbDescription.SetValue(imageInfo.alt);
if (imageInfo.useFloat)
_dxeCkbWrapTextArroundImage.SetChecked(imageInfo.useFloat);
},
ClearEditorValue: function() {
_dxeTbxInsertImageUrl.SetValue(null);
_dxeTxbDescription.SetValue(null);
_dxeCkbWrapTextArroundImage.SetChecked(false);
this.GetThumbnailFileNameTextBox().SetValue(null);
},
SaveEditorsState: function() {
var checkBox = this.GetCheckBoxMoreImageOptions();
if (checkBox) {
this.htmlEditor.moreImageOptions = checkBox.GetChecked();
}
},
RestoreEditorsState: function() {
if (_aspxIsExists(this.htmlEditor.moreImageOptions)) {
this.GetCheckBoxMoreImageOptions().SetChecked(this.htmlEditor.moreImageOptions);
this.GetCheckBoxMoreImageOptions().RaiseCheckedChanged();
}
},
GetPreviewTextElement: function() {
return _aspxGetElementById(this.htmlEditor.name + __aspxPreviewTextElementID);
},
GetPreviewImageElement: function() {
return _aspxGetElementById(this.htmlEditor.name + __aspxPreviewImageElementID);
},
GetPreviewAreaCell: function() {
return _aspxGetParentByTagName(this.GetPreviewImageElement(), "td");
},
GetChangeButton: function() {
return _dxeBtnChangeImage;
},
GetCheckBoxMoreImageOptions: function() {
return window._dxeCkbMoreImageOptions || null;
},
GetClientUploadDirectory: function() {
return this.htmlEditor.uploadImageFileDirectoryPath;
},
GetThumbnailCheckBox: function() {
return _dxeCkbCreateThumbnail;
},
GetErrorLabel: function() {
return _dxeLblError;
},
GetInsertButton: function() {
return _dxeBtnInsertImage;
},
GetImageUploader: function() {
return _dxeUplImage;
},
GetThumbnailFileNameTextBox: function() {
return _dxeThumbnailFileName;
},
GetInsertImageUrlTextBox: function() {
return _dxeTbxInsertImageUrl;
},
IsFieldInitializing: function() {
if (_aspxIsExists(this.fieldInitializing))
return this.fieldInitializing;
return false;
},
SetFocusInField: function() {
_aspxSetFocusToTextEditWithDelay(_dxeTbxInsertImageUrl.name);
},
OnCallback: function(result) {
if (result.indexOf(__aspxHESaveImageToServerCallbackPrefix) == 0) {
this.OnImageSavedToServer(result.substring(__aspxHESaveImageToServerCallbackPrefix.length + 1, result.length));
this.ownerControl.callbackOwner = null;
}
else
ASPxDialog.prototype.OnCallback.call(this, result);
},
OnComplete: function(result, params) {
this.insertImageParams = params;
if (result) {
if(_dxeRblImageFromThisComputer.GetChecked())
return this.GetImageUploader().UploadFile();
else if (this.IsCreateThumbnail())
return this.SaveThumbnailImageToServerViaCallback(this.GetInsertImageUrlTextBox().GetText(),
this.GetThumbnailFileNameTextBox().GetText(),
params.width, params.height);
else if (this.IsSaveImageToServer() && _dxeRblImageFromTheWeb.GetChecked())
return this.SaveImageToServerViaCallback(this.GetInsertImageUrlTextBox().GetText());
}
ASPxHtmlEditorDialog.prototype.OnComplete.call(this, result, params);
},
OnImageSavedToServer: function(result) {
if (result.indexOf(__aspxSaveImageToServerErrorCallbackPrefix) > -1)
this.ShowErrorMessage(result.substring(__aspxSaveImageToServerErrorCallbackPrefix.length + 1, result.length));
else {
this.insertImageParams.src = result.substr(__aspxSaveImageToServerNewUrlCallbackPrefix.length + 1, result.length);
ASPxHtmlEditorDialog.prototype.OnComplete.call(this, 1, this.insertImageParams);
}
},
OnConstrainProportionsSwitchClick: function(evt, invisibleSwitchImgID) {
var visibleSwitchImg = _aspxGetEventSource(evt);
var invisibleSwitchImg = _aspxGetElementById(invisibleSwitchImgID);
_aspxSetElementDisplay(visibleSwitchImg, false);
_aspxSetElementDisplay(invisibleSwitchImg, true);
this.constrainProportions = !this.constrainProportions;
if (this.constrainProportions)
this.UpdateSizeFields(this.initialWidth, this.initialHeight);
},
OnImageUploadStart: function() {
this.ShowLoadingPanelOverDialogPopup();
},
OnImageUploadComplete: function(args) {
this.HideLoadingPanelOverDialogPopup();
if (args.isValid) {
var fileName = args.callbackData;
var isDataUriImage = (fileName.toLowerCase().indexOf("data:image") == 0);
if(!isDataUriImage)
fileName = this.GetClientUploadDirectory() + fileName;
this.insertImageParams.src = fileName;
if(!isDataUriImage && this.IsCreateThumbnail()) {
this.SaveThumbnailImageToServerViaCallback(
ASPxClientPath.GetBaseUrlPath() + fileName,
this.GetThumbnailFileNameTextBox().GetText(),
this.insertImageParams.width,
this.insertImageParams.height
);
}
else
ASPxHtmlEditorDialog.prototype.OnComplete.call(this, 1, this.insertImageParams);
}
},
OnImageUploadTextChanged: function() {
this.UpdateThumbnailFileName(this.GetImageUploader().GetText());
},
OnImageSrcChanged: function(src) {
this.CheckImageExisting(src);
this.UpdateThumbnailFileName(src);
},
OnImageFromTypeChanged: function() {
var src = _dxeRblImageFromTheWeb.GetChecked() ? this.GetInsertImageUrlTextBox().GetText() :
this.GetImageUploader().GetText();
this.UpdateThumbnailFileName(src);
},
OnLoadTestExistingImage: function() {
this.GetPreviewImageElement().src = this.testImage.src;
var previewAreaTD = this.GetPreviewAreaCell();
var maxWidth = previewAreaTD.clientWidth;
var maxHeight = __aspxWebKitFamily ? previewAreaTD.offsetHeight : previewAreaTD.clientHeight;
this.SetPreviewImageSize(this.testImage.width, this.testImage.height, maxWidth, maxHeight);
_aspxSetElementDisplay(this.GetPreviewTextElement(), false);
_aspxSetElementDisplay(this.GetPreviewImageElement(), true);
previewAreaTD.style.borderStyle = "none";
this.UpdateSizeFieldsAfterLoad(this.testImage.width, this.testImage.height);
},
OnErrorTestExistingImage: function() {
_aspxSetElementDisplay(this.GetPreviewTextElement(), true);
_aspxSetElementDisplay(this.GetPreviewImageElement(), false);
var previewAreaTD = this.GetPreviewAreaCell();
previewAreaTD.style.borderStyle = "";
this.UpdateSizeFieldsAfterLoad();
},
OnSizeSpinNumberChanged: function(sizeType) {
if (this.constrainProportions)
this.UpdateSizeSpinEditsWithConstrainProportions(sizeType);
},
OnSizeSpinKeyUp: function(sizeType, htmlEvent) {
if (this.constrainProportions) {
var keyCode = _aspxGetKeyCode(htmlEvent);
if (keyCode != ASPxKey.Tab && keyCode != ASPxKey.Shift)
this.UpdateSizeSpinEditsWithConstrainProportions(sizeType);
}
},
CheckImageExisting: function (checkingSrc) {
if (document.images) {
this.testImage = new Image();
_aspxAttachEventToElement(this.testImage, "load", new Function("aspxTestExistingImageOnLoad" + "('" + this.htmlEditor.name + "');"));
_aspxAttachEventToElement(this.testImage, "error", new Function("aspxTestExistingImageOnError" + "('" + this.htmlEditor.name + "');"));
this.testImage.src = checkingSrc;
}
},
IsCreateThumbnail: function() {
return this.GetThumbnailCheckBox().GetChecked() && _dxeCmbSize.GetValue() == "custom";
},
IsSaveImageToServer: function() {
return _dxeCkbSaveToServer.GetValue() || !this.htmlEditor.allowInsertDirectImageUrls;
},
SetPreviewImageSize: function(sourceWidth, sourceHeight, maxWidth, maxHeight) {
var newWidth = sourceWidth;
var newHeight = sourceHeight;
if ((sourceWidth > maxWidth) ||
(sourceHeight > maxHeight)) {
var cw = sourceWidth/maxWidth;
var ch = sourceHeight/maxHeight;
if (cw > ch) {
var cw = sourceWidth/maxWidth;
newWidth = Math.floor(sourceWidth/cw);
newHeight = Math.floor(sourceHeight/cw);
}
else {
newWidth = Math.floor(sourceWidth/ch);
newHeight = Math.floor(sourceHeight/ch);
}
}
var previewImage = this.GetPreviewImageElement();
previewImage.style.width = newWidth + "px";
previewImage.style.height = newHeight + "px";
},
SaveImageToServerViaCallback: function(src) {
this.SendCallback(_aspxFormatCallbackArg(__aspxHESaveImageToServerCallbackPrefix, src));
},
SaveThumbnailImageToServerViaCallback: function(src, newImageFileName, thumbnailWidth, thumbnailHeight) {
this.SendCallback(_aspxFormatCallbackArgs([
[ __aspxHESaveImageToServerCallbackPrefix, src ],
[ __aspxHEThumbnailImageWidthCallbackPrefix, thumbnailWidth ],
[ __aspxHEThumbnailImageHeightCallbackPrefix, thumbnailHeight ],
[ __aspxHEThumbnailImageFileNameCallbackPrefix, newImageFileName ]
]));
},
HideErrorMessage: function() {
this.GetErrorLabel().SetVisible(false);
},
ShowErrorMessage: function(message) {
var textBox = this.GetInsertImageUrlTextBox();
textBox.isValid = false;
textBox.errorText = message;
textBox.UpdateErrorFrameAndFocus(false, true);
},
UpdateConstrainProportionsCoef: function(width, height) {
if ((width == height) || (height == 0))
this.constrainProportionsCoef_WH = 1;
else
this.constrainProportionsCoef_WH = width/height;
this.initialWidth = width;
this.initialHeight = height;
},
UpdateSizeSpinEditsWithConstrainProportions: function(sizeType) {
var widthVal = _dxeSpnWidth.GetText();
var heightVal = _dxeSpnHeight.GetText();
if(widthVal === "" || heightVal === "") {
if(widthVal == heightVal)
this.UpdateSizeFields(this.initialWidth, this.initialHeight);
return;
}
var newWidth = _dxeSpnWidth.GetNumber();
var newHeight = _dxeSpnHeight.GetNumber();
switch(sizeType) {
case "width":
_dxeSpnWidth.SaveSelectionStartAndEndPosition();
newHeight = _dxeSpnWidth.GetParsedNumber()/this.constrainProportionsCoef_WH;
_dxeSpnHeight.SetValue(Math.floor(newHeight));
_dxeSpnWidth.RestoreSelectionStartAndEndPosition();
break;
case "height":
_dxeSpnHeight.SaveSelectionStartAndEndPosition();
newWidth = _dxeSpnHeight.GetParsedNumber()*this.constrainProportionsCoef_WH;
_dxeSpnWidth.SetValue(Math.floor(newWidth));
_dxeSpnHeight.RestoreSelectionStartAndEndPosition();
break;
}
},
UpdateSizeFields: function(imageWidth, imageHeight) {
_dxeSpnWidth.SetValue(imageWidth >= 0 ? imageWidth : 0);
_dxeSpnHeight.SetValue(imageHeight >=0 ? imageHeight: 0);
this.UpdateConstrainProportionsCoef(_dxeSpnWidth.GetNumber(), _dxeSpnHeight.GetNumber());
},
UpdateSizeFieldsAfterLoad: function(imageWidth, imageHeight) {
if (!this.IsFieldInitializing())
this.UpdateSizeFields(imageWidth, imageHeight);
else
this.fieldInitializing = false;
},
UpdateThumbnailFileName: function(src) {
var fileName = ASPxClientPath.GetFileNameWithoutExtension(src);
if (fileName)
fileName += "Thumbnail.jpg";
this.GetThumbnailFileNameTextBox().SetText(fileName);
}
});
InsertImageDialog.prototype.GetSelectedImage = function(htmlEditor) {
var curSelection = ASPxClientHtmlEditorSelection.Create(htmlEditor);
var containerElement = curSelection.GetParentElement();
return InsertImageDialog.prototype.GetImage(containerElement);
}
InsertImageDialog.prototype.GetImage = function(element) {
return element.tagName == "IMG" ? element : _aspxGetParentByTagName(element, "img");
}
function aspxInsertImageSrcValueChanged(src) {
var htmlEdit = aspxGetControlCollection().Get(__aspxCurrentControlNameInDialog);
var curDialog = htmlEdit != null ? ASPxDialog.GetLastDialog(htmlEdit) : null;
if (curDialog != null) curDialog.OnImageSrcChanged(src);
}
function aspxConstrainProportionsSwitchClick(evt, invisibleSwitchImgID) {
var htmlEdit = aspxGetControlCollection().Get(__aspxCurrentControlNameInDialog);
var curDialog = htmlEdit != null ? ASPxDialog.GetLastDialog(htmlEdit) : null;
if (curDialog != null)
return curDialog.OnConstrainProportionsSwitchClick(evt, invisibleSwitchImgID);
}
function aspxImageUploadStart() {
var htmlEdit = aspxGetControlCollection().Get(__aspxCurrentControlNameInDialog);
var curDialog = htmlEdit != null ? ASPxDialog.GetLastDialog(htmlEdit) : null;
if (curDialog != null)
return curDialog.OnImageUploadStart();
}
function aspxImageUploadComplete(args) {
var htmlEdit = aspxGetControlCollection().Get(__aspxCurrentControlNameInDialog);
var curDialog = htmlEdit != null ? ASPxDialog.GetLastDialog(htmlEdit) : null;
if (curDialog != null)
return curDialog.OnImageUploadComplete(args);
}
function aspxImageUploadTextChanged() {
var htmlEdit = aspxGetControlCollection().Get(__aspxCurrentControlNameInDialog);
var curDialog = htmlEdit != null ? ASPxDialog.GetLastDialog(htmlEdit) : null;
if (curDialog != null)
return curDialog.OnImageUploadTextChanged();
}
function aspxOnImageFromTypeChanged() {
var htmlEdit = aspxGetControlCollection().Get(__aspxCurrentControlNameInDialog);
var curDialog = htmlEdit != null ? ASPxDialog.GetLastDialog(htmlEdit) : null;
if (curDialog != null)
return curDialog.OnImageFromTypeChanged();
}
function aspxTestExistingImageOnLoad(name) {
var htmlEdit = aspxGetControlCollection().Get(name);
var curDialog = htmlEdit != null ? ASPxDialog.GetLastDialog(htmlEdit) : null;
if (curDialog != null) curDialog.OnLoadTestExistingImage();
}
function aspxTestExistingImageOnError(name) {
var htmlEdit = aspxGetControlCollection().Get(name);
var curDialog = htmlEdit != null ? ASPxDialog.GetLastDialog(htmlEdit) : null;
if (curDialog != null) curDialog.OnErrorTestExistingImage();
}
function aspxSizeSpinNumberChanged(sizeType) {
var htmlEdit = aspxGetControlCollection().Get(__aspxCurrentControlNameInDialog);
var curDialog = htmlEdit != null ? ASPxDialog.GetLastDialog(htmlEdit) : null;
if (curDialog != null)
return curDialog.OnSizeSpinNumberChanged(sizeType);
}
function aspxSizeSpinKeyUp(sizeType, htmlEvent) {
var htmlEdit = aspxGetControlCollection().Get(__aspxCurrentControlNameInDialog);
var curDialog = htmlEdit != null ? ASPxDialog.GetLastDialog(htmlEdit) : null;
if (curDialog != null)
return curDialog.OnSizeSpinKeyUp(sizeType, htmlEvent);
}
InsertTableDialog = _aspxCreateClass(ASPxHtmlEditorDialog, {
DoCustomAction: function(result, cmdValue) {
if (result)
this.htmlEditor.ExecuteCommand(ASPxClientCommandConsts.INSERTTABLE_COMMAND, cmdValue, true);
},
GetDialogCaptionText: function() {
return ASPxHtmlEditorDialogSR.InsertTable;
},
InitializeDialogFields: function(tableInfo) {
this.SetDisplayColumnsAndRowsEditors(true);
},
SetFocusInField: function() {
_aspxSetFocusToTextEditWithDelay(_dxeSpnTableColumns.name);
},
SetDisplayColumnsAndRowsEditors: function(display) {
_dxeCkbColumnsEqualWidth.SetClientVisible(display);
var row = this.GetRowsAndColumnsRowElement();
_aspxSetElementDisplay(row, display);
_aspxSetElementDisplay(_aspxHETableHelper.GetNextRow(row), display);
},
GetRowsAndColumnsRowElement: function() {
return _aspxGetParentByTagName(_dxeSpnTableColumns.GetMainElement(), "TR");
}
});
TablePropertiesDialog = _aspxCreateClass(InsertTableDialog, {
DoCustomAction: function(result, cmdValue) {
if (result) {
cmdValue = { tableElement: this.selectedTable, tableProperties: cmdValue.tableProperties };
this.htmlEditor.ExecuteCommand(ASPxClientCommandConsts.CHANGETABLE_COMMAND, cmdValue, true);
}
},
GetInitInfoObject: function() {
var tableInfoObject = {
borderWidth: null,
borderColor: "",
backgroundColor: "",
width: "",
height: "",
cellPadding: "",
cellSpacing: "",
align: null,
accessibility: null
};
this.selectedTable = _aspxHETableHelper.GetTable(this.selectionInfo.selectedElement);
if (this.selectedTable)
tableInfoObject = _aspxHETableHelper.GetTableProperties(this.selectedTable);
return tableInfoObject;
},
InitializeDialogFields: function(tableInfo) {
this.SetDisplayColumnsAndRowsEditors(false);
TablePropertiesDialog.SetSizeEditors(_dxeCmbTableWidth, _dxeCmbTableWidthType, _dxeTxbTableWidth, tableInfo.width);
TablePropertiesDialog.SetSizeEditors(_dxeCmbTableHeight, _dxeCmbTableHeightType, _dxeTxbTableHeight, tableInfo.height);
_dxeSpnCellPadding.SetText(tableInfo.cellPadding);
_dxeSpnCellSpacing.SetText(tableInfo.cellSpacing);
_dxeCmbTableAlign.SetValue(tableInfo.align);
if (tableInfo.align)
_dxeCmbTableAlign.SetValue(tableInfo.align.toLowerCase());
_dxeSpnTableBorderSize.SetText(tableInfo.borderWidth);
_dxeTxbTableBorderColor.SetText(tableInfo.borderColor);
_dxeTxbTableBackgroundColor.SetText(tableInfo.backgroundColor);
var accessibility = tableInfo.accessibility;
_dxeTxbTableSummary.SetText(accessibility.summary);
_dxeTxbTableCaption.SetText(accessibility.caption);
_dxeCmbTableHeaders.SetValue(accessibility.headers);
},
GetDialogCaptionText: function() {
return ASPxHtmlEditorDialogSR.ChangeTable;
},
SetFocusInField: function() {
_aspxSetFocusToTextEditWithDelay(_dxeCmbTableWidth.name);
}
});
TablePropertiesDialog.SetSizeEditors = function(cmb, cmbType, spinEdit, value) {
cmb.SetValue(value);
var selectedItem = cmb.GetSelectedItem();
if (selectedItem == null) {
cmb.SetValue("custom");
var res = _aspxHETableHelper.ParseSizeString(value);
if (res.valueType) {
value = res.value;
cmbType.SetValue(res.valueType);
cmbType.RaiseValueChangedEvent();
}
spinEdit.SetText(value);
}
cmb.RaiseValueChangedEvent();
}
TableCellPropertiesDialog = _aspxCreateClass(ASPxHtmlEditorDialog, {
DoCustomAction: function(result, cmdValue) {
if (result) {
cmdValue = { cellElement: this.selectedCell, properties: cmdValue };
this.htmlEditor.ExecuteCommand(ASPxClientCommandConsts.CHANGETABLECELL_COMMAND, cmdValue, true);
}
},
GetDialogCaptionText: function() {
return ASPxHtmlEditorDialogSR.ChangeTableCell;
},
InitializeDialogFields: function(cellInfo) {
this.SetSizeEditorsDisplay(false);
_dxeCkbApplyForAllElements.SetVisible(true);
_dxeTxbTableColumnBackgroundColor.SetText(cellInfo.backgroundColor);
_dxeCmbTableColumnAlign.SetValue(cellInfo.align);
if (cellInfo.align)
_dxeCmbTableColumnAlign.SetValue(cellInfo.align.toLowerCase());
_dxeCmbTableColumnVAlign.SetValue(cellInfo.vAlign);
if (cellInfo.vAlign)
_dxeCmbTableColumnVAlign.SetValue(cellInfo.vAlign.toLowerCase());
},
GetInitInfoObject: function() {
var cellInfoObject = {
backgroundColor: "",
align: null,
vAlign: null
};
this.selectedCell = _aspxHETableHelper.GetTableCellBySelection(this.selectionInfo.selectedElement,
this.selectionInfo.endSelectedElement);
if (this.selectedCell)
cellInfoObject = _aspxHETableHelper.GetCellProperties(this.selectedCell);
return cellInfoObject;
},
SetFocusInField: function() {
_aspxSetFocusToTextEditWithDelay(_dxeCmbTableColumnAlign.name);
},
SetSizeEditorsDisplay: function(display) {
_dxeRPTableColumnSize.SetVisible(display);
var firstMainElem = _dxeRPTableColumnSize.GetMainElement();
var secondMainElem = _dxeRPTableLayout.GetMainElement();
if (firstMainElem && secondMainElem) {
var curElem = firstMainElem.nextSibling;
while (curElem != secondMainElem) {
if (curElem.nodeType == 1)
_aspxSetElementDisplay(curElem, display);
curElem = curElem.nextSibling;
}
}
},
OnComplete: function(result, params) {
ASPxHtmlEditorDialog.prototype.OnComplete.call(this, result, params);
_dxeCkbApplyForAllElements.SetChecked(false);
},
SetWidthEditorsDisplay: function(display) {
_aspxSetElementDisplay(_aspxGetElementById(this.GetWidthEditorsTRID()), display);
},
SetHeightEditorsDisplay: function(display) {
_aspxSetElementDisplay(_aspxGetElementById(this.GetHeightEditorsTRID()), display);
},
GetWidthEditorsTRID: function() {
return this.htmlEditor.name + "_dxeColumnWidthCell";
},
GetHeightEditorsTRID: function() {
return this.htmlEditor.name + "_dxeColumnHeightCell";
}
});
TableColumnPropertiesDialog = _aspxCreateClass(TableCellPropertiesDialog, {
DoCustomAction: function(result, cmdValue) {
if (result) {
cmdValue = { cell: this.selectedCell, properties: cmdValue };
this.htmlEditor.ExecuteCommand(ASPxClientCommandConsts.CHANGETABLECOLUMN_COMMAND, cmdValue, true);
}
},
SetFocusInField: function() {
_aspxSetFocusToTextEditWithDelay(_dxeCmbTableColumnAlign.name);
},
GetInitInfoObject: function() {
var columnInfoObject = {
backgroundColor: "",
width: "",
align: null,
vAlign: null
};
var table = _aspxHETableHelper.GetTable(this.selectionInfo.selectedElement);
this.selectedCell = _aspxHETableHelper.GetTableCellBySelection(this.selectionInfo.selectedElement,
this.selectionInfo.endSelectedElement);
if (table)
columnInfoObject = _aspxHETableHelper.GetColumnProperties(this.selectedCell);
return columnInfoObject;
},
InitializeDialogFields: function(columnInfo) {
_dxeTxbTableColumnBackgroundColor.SetText(columnInfo.backgroundColor);
_dxeCkbApplyForAllElements.SetVisible(false);
this.SetWidthEditorsDisplay(true);
this.SetHeightEditorsDisplay(false);
this.SetSizeEditorsDisplay(true);
_dxeCmbTableColumnAlign.SetValue(columnInfo.align);
if (columnInfo.align)
_dxeCmbTableColumnAlign.SetValue(columnInfo.align.toLowerCase());
_dxeCmbTableColumnVAlign.SetValue(columnInfo.vAlign);
if (columnInfo.vAlign)
_dxeCmbTableColumnVAlign.SetValue(columnInfo.vAlign.toLowerCase());
TablePropertiesDialog.SetSizeEditors(_dxeCmbTableColumnWidth, _dxeCmbTableColumnWidthType,
_dxeTxbTableColumnWidth, columnInfo.width);
},
GetDialogCaptionText: function() {
return ASPxHtmlEditorDialogSR.ChangeTableColumn;
}
});
TableRowPropertiesDialog = _aspxCreateClass(TableCellPropertiesDialog, {
DoCustomAction: function(result, cmdValue) {
if (result) {
cmdValue = { cell: this.selectedCell, properties: cmdValue };
this.htmlEditor.ExecuteCommand(ASPxClientCommandConsts.CHANGETABLEROW_COMMAND, cmdValue, true);
}
},
SetFocusInField: function() {
_aspxSetFocusToTextEditWithDelay(_dxeCmbTableColumnAlign.name);
},
GetInitInfoObject: function() {
var rowInfoObject = {
backgroundColor: "",
height: "",
align: null,
vAlign: null
};
var table = _aspxHETableHelper.GetTable(this.selectionInfo.selectedElement);
this.selectedCell = _aspxHETableHelper.GetTableCellBySelection(this.selectionInfo.selectedElement,
this.selectionInfo.endSelectedElement);
if (this.selectedCell)
rowInfoObject = _aspxHETableHelper.GetRowProperties(this.selectedCell);
return rowInfoObject;
},
GetDialogCaptionText: function() {
return ASPxHtmlEditorDialogSR.ChangeTableRow;
},
InitializeDialogFields: function(rowInfo) {
_dxeTxbTableColumnBackgroundColor.SetText(rowInfo.backgroundColor);
_dxeCkbApplyForAllElements.SetVisible(false);
this.SetWidthEditorsDisplay(false);
this.SetHeightEditorsDisplay(true);
this.SetSizeEditorsDisplay(true);
_dxeCmbTableColumnAlign.SetValue(rowInfo.align);
if (rowInfo.align)
_dxeCmbTableColumnAlign.SetValue(rowInfo.align.toLowerCase());
_dxeCmbTableColumnVAlign.SetValue(rowInfo.vAlign);
if (rowInfo.vAlign)
_dxeCmbTableColumnVAlign.SetValue(rowInfo.vAlign.toLowerCase());
TablePropertiesDialog.SetSizeEditors(_dxeCmbTableRowHeight, _dxeCmbTableRowHeightType, _dxeTxbTableRowHeight, rowInfo.height);
}
});
PasteFromWordDialog = _aspxCreateClass(ASPxHtmlEditorDialog, {
DoCustomAction: function(result, cmdValue) {
_aspxRemoveElement(this.GetPasteContainerIFrame());
if (result && cmdValue.html)
this.htmlEditor.ExecuteCommand(ASPxClientCommandConsts.PASTEFROMWORD_COMMAND, cmdValue, true);
},
InitializeDialogFields: function() {
var iframe = this.GetPasteContainerIFrame();
if(!iframe.contentWindow) {
var src = iframe.src;
iframe.src = src;
}
var contentDocument = this.GetPasteContainerIFrame().contentWindow.document;
contentDocument.open();
contentDocument.write("");
contentDocument.close();
if (__aspxIE)
contentDocument.body.contentEditable = true;
else {
contentDocument.body.spellcheck = false;
contentDocument["designMode"] = "on";
}
_aspxAttachEventToElement(contentDocument, "keypress", aspxHEPasteFromWordContainerKeyPress);
contentDocument.body.style.margin = "0px";
contentDocument.body.style.padding = "2px";
contentDocument.body.style.border = "Solid 0px";
},
SetFocusInField: function() {
_aspxSetTimeout("ASPxIFrame.GetWindow('" + this.GetPasteContainerIFrameName() + "').focus();", 500);
},
GetDialogCaptionText: function() {
return ASPxHtmlEditorDialogSR.PasteFromWord;
},
OnPasteContainerKeyPress: function(evt) {
if (evt.keyCode == ASPxKey.Esc)
this.HideDialog(evt);
},
GetPasteContainerIFrame: function() {
return _aspxGetElementById(this.GetPasteContainerIFrameName());
},
GetPasteContainerIFrameName: function() {
return this.htmlEditor.name + "_dxePasteFromWordContainer";
}
});
function aspxHEPasteFromWordContainerKeyPress(evt) {
var htmlEdit = aspxGetControlCollection().Get(__aspxCurrentControlNameInDialog);
var curDialog = htmlEdit != null ? ASPxDialog.GetLastDialog(htmlEdit) : null;
if (curDialog != null)
return curDialog.OnPasteContainerKeyPress(evt);
}
var ASPxHtmlEditorDialogList = {};
ASPxHtmlEditorDialogList[ASPxClientCommandConsts.INSERTLINK_DIALOG_COMMAND] = new InsertLinkDialog(ASPxClientCommandConsts.INSERTLINK_DIALOG_COMMAND);
ASPxHtmlEditorDialogList[ASPxClientCommandConsts.CHANGELINK_DIALOG_COMMAND] = new InsertLinkDialog(ASPxClientCommandConsts.INSERTLINK_DIALOG_COMMAND);
ASPxHtmlEditorDialogList[ASPxClientCommandConsts.INSERTIMAGE_DIALOG_COMMAND] = new InsertImageDialog(ASPxClientCommandConsts.INSERTIMAGE_DIALOG_COMMAND);
ASPxHtmlEditorDialogList[ASPxClientCommandConsts.CHANGEIMAGE_DIALOG_COMMAND] = new InsertImageDialog(ASPxClientCommandConsts.INSERTIMAGE_DIALOG_COMMAND);
ASPxHtmlEditorDialogList[ASPxClientCommandConsts.INSERTTABLE_DIALOG_COMMAND] = new InsertTableDialog(ASPxClientCommandConsts.INSERTTABLE_DIALOG_COMMAND);
ASPxHtmlEditorDialogList[ASPxClientCommandConsts.TABLEPROPERTIES_DIALOG_COMMAND] = new TablePropertiesDialog(ASPxClientCommandConsts.INSERTTABLE_DIALOG_COMMAND);
ASPxHtmlEditorDialogList[ASPxClientCommandConsts.TABLECELLPROPERTIES_DIALOG_COMMAND] = new TableCellPropertiesDialog(ASPxClientCommandConsts.TABLECOLUMNPROPERTIES_DIALOG_COMMAND);
ASPxHtmlEditorDialogList[ASPxClientCommandConsts.TABLECOLUMNPROPERTIES_DIALOG_COMMAND] = new TableColumnPropertiesDialog(ASPxClientCommandConsts.TABLECOLUMNPROPERTIES_DIALOG_COMMAND);
ASPxHtmlEditorDialogList[ASPxClientCommandConsts.TABLEROWPROPERTIES_DIALOG_COMMAND] = new TableRowPropertiesDialog(ASPxClientCommandConsts.TABLECOLUMNPROPERTIES_DIALOG_COMMAND);
ASPxHtmlEditorDialogList[ASPxClientCommandConsts.PASTEFROMWORDDIALOG_COMMAND] = new PasteFromWordDialog(ASPxClientCommandConsts.PASTEFROMWORDDIALOG_COMMAND);
}
/*
playback timings (ms):
CDXLines.iter: 16.683 (3)
exclusion.robots: 0.291
captures_list: 64.689
RedisCDXSource: 1.123
esindex: 0.012
load_resource: 120.472
PetaboxLoader3.datanode: 84.471 (4)
PetaboxLoader3.resolve: 54.18
LoadShardBlock: 43.798 (3)
exclusion.robots.policy: 0.273
*/