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"); var ASPxClientCommandConsts = { BOLD_COMMAND : "bold", ITALIC_COMMAND: "italic", UNDERLINE_COMMAND: "underline", STRIKETHROUGH_COMMAND: "strikethrough", SUPERSCRIPT_COMMAND: "superscript", SUBSCRIPT_COMMAND: "subscript", JUSTIFYCENTER_COMMAND: "justifycenter", JUSTIFYLEFT_COMMAND: "justifyleft", INDENT_COMMAND: "indent", OUTDENT_COMMAND: "outdent", JUSTIFYRIGHT_COMMAND: "justifyright", JUSTIFYFULL_COMMAND: "justifyfull", FONTSIZE_COMMAND : "fontsize", FONTNAME_COMMAND : "fontname", FONTCOLOR_COMMAND: "forecolor", BACKCOLOR_COMMAND: "backcolor", FORMATBLOCK_COMMAND: "formatblock", APPLYCSS_COMMAND: "applycss", REMOVEFORMAT_COMMAND: "removeformat", UNDO_COMMAND: "undo", REDO_COMMAND: "redo", COPY_COMMAND: "copy", KBCOPY_COMMAND: "kbcopy", PASTE_COMMAND: "paste", KBPASTE_COMMAND: "kbpaste", PASTEFROMWORD_COMMAND: "pastefromword", PASTEFROMWORDDIALOG_COMMAND: "pastefromworddialog", CUT_COMMAND: "cut", KBCUT_COMMAND: "kbcut", SELECT_ALL: "selectall", DELETE_COMMAND: "delete", KBDELETE_COMMAND: "kbdelete", TEXTTYPE_COMMAND: "texttype", NEWPARAGRAPHTYPE_COMMAND: "newparagraphtype", LINEBREAKETYPE_COMMAND: "linebreaktype", ENTER_COMMAND: "enter", PASTEHTML_COMMAND: "pastehtml", RESIZEOBJECT_COMMAND: "resizeobject", DRAGDROPOBJECT_COMMAND: "dragdropobject", DROPOBJECTFROMEXTERNAL_COMMAND: "dropobjectfromexternal", INSERTORDEREDLIST_COMMAND: "insertorderedlist", INSERTUNORDEREDLIST_COMMAND: "insertunorderedlist", UNLINK_COMMAND: "unlink", INSERTLINK_COMMAND: "insertlink", INSERTIMAGE_COMMAND: "insertimage", CHANGEIMAGE_COMMAND: "changeimage", CHECKSPELLING_COMMAND: "checkspelling", INSERTIMAGE_DIALOG_COMMAND: "insertimagedialog", CHANGEIMAGE_DIALOG_COMMAND: "changeimagedialog", INSERTLINK_DIALOG_COMMAND: "insertlinkdialog", CHANGELINK_DIALOG_COMMAND: "changelinkdialog", INSERTTABLE_DIALOG_COMMAND: "inserttabledialog", TABLEPROPERTIES_DIALOG_COMMAND: "tablepropertiesdialog", TABLECELLPROPERTIES_DIALOG_COMMAND: "tablecellpropertiesdialog", TABLECOLUMNPROPERTIES_DIALOG_COMMAND: "tablecolumnpropertiesdialog", TABLEROWPROPERTIES_DIALOG_COMMAND: "tablerowpropertiesdialog", PRINT_COMMAND: "print", FULLSCREEN_COMMAND: "fullscreen", INSERTTABLE_COMMAND: "inserttable", CHANGETABLE_COMMAND: "changetable", CHANGETABLECELL_COMMAND: "changetablecell", CHANGETABLEROW_COMMAND: "changetablerow", CHANGETABLECOLUMN_COMMAND: "changetablecolumn", DELETETABLE_COMMAND: "deletetable", DELETETABLEROW_COMMAND: "deletetablerow", DELETETABLECOLUMN_COMMAND: "deletetablecolumn", INSERTTABLECOLUMNTOLEFT_COMMAND: "inserttablecolumntoleft", INSERTTABLECOLUMNTORIGHT_COMMAND: "inserttablecolumntoright", INSERTTABLEROWBELOW_COMMAND: "inserttablerowbelow", INSERTTABLEROWABOVE_COMMAND: "inserttablerowabove", SPLITTABLECELLHORIZONTALLY_COMMAND: "splittablecellhorizontally", SPLITTABLECELLVERTICALLY_COMMAND: "splittablecellvertically", MERGETABLECELLRIGHT_COMMAND: "mergetablecellright", MERGETABLECELLDOWN_COMMAND: "mergetablecelldown", CheckSpellingCore_COMMAND: "checkspellingcore", Start_COMMAND: "start", CUSTOMDIALOG_COMMAND: "customdialog", EXPORT_COMMAND: "export", SAVESTATEUNDOREDOSTACK_COMMAND: "savestateundoredostack" }; var ASPxHtmlEditorCommands = { Browser: {} }; ASPxHtmlEditorCommands.Command = _aspxCreateClass(null, { constructor: function(cmdID) { this.commandID = cmdID; }, Execute: function(cmdValue, editor) { return true; }, GetCommandID: function() { return this.commandID; }, GetState: function(editor) { return true; }, GetValue: function(editor) { return null; }, IsDefaultAction: function(editor) { return false; }, IsImmediateExecution: function() { return false; }, IsHtmlChangeable: function() { return true; }, IsLocked: function(editor) { return false; }, IsReversable: function() { return true; }, IsClientCommand: function() { return true; } }); ASPxHtmlEditorCommands.Browser.Command = _aspxCreateClass(ASPxHtmlEditorCommands.Command, { Execute: function(cmdValue, editor) { ASPxHtmlEditorCommands.Command.prototype.Execute.apply(this, arguments); var contentAreaDoc = editor.GetDesignViewDocument(); if (!this.NeedUseCss()) contentAreaDoc.execCommand(this.GetUseCSSCommandName(), false, false); if(!editor.isSelectionRestored) editor.RestoreSelection(); var isSuccessfully = contentAreaDoc.execCommand(this.GetCommandName(), false, this.GetCorrectedValue(cmdValue)); if (!this.NeedUseCss()) contentAreaDoc.execCommand(this.GetUseCSSCommandName(), false, true); editor.SetFocus(); return isSuccessfully; }, GetCommandName: function() { return this.commandID; }, GetCorrectedValue: function(value) { return value; }, GetState: function(editor) { var ret = true; if (!this.IsAlwaysEnabledCommand(this.commandID)) { try { ret = this.TryGetState(editor); } catch(ex) { ret = false; } } return ret; }, GetValue: function(editor) { var ret = null; try { ret = this.TryGetValue(editor); } catch(e) {} return ret; }, GetUseCSSCommandName: function(doc) { return __aspxNetscapeFamily ? "styleWithCSS" : "useCSS"; }, IsLocked: function(editor) { var ret = this.TryGetIsLocked(editor); if (__aspxOpera && ret) { try { ret = !this.TryGetState(editor); } catch(ex) { ret = false; } } return ret; }, TryGetState: function(editor) { return editor.GetDesignViewDocument().queryCommandState(this.GetCommandName()); }, TryGetValue: function(editor) { return editor.GetDesignViewDocument().queryCommandValue(this.GetCommandName()); }, TryGetIsLocked: function(editor) { try { return !editor.GetDesignViewDocument().queryCommandEnabled(this.GetCommandName()); } catch(e) {} return true; }, IsAlwaysEnabledCommand: function(commandID) { return this.commandID == ASPxClientCommandConsts.FONTSIZE_COMMAND || this.commandID == ASPxClientCommandConsts.FONTNAME_COMMAND; }, NeedUseCss: function() { return true; } }); ASPxHtmlEditorCommands.Browser.FontStyle = _aspxCreateClass(ASPxHtmlEditorCommands.Browser.Command, { Execute: function(cmdValue, editor) { if(__aspxFirefox && __aspxBrowserVersion >= 4 && editor.GetSelection().GetHtml() != "") { var contentAreaDoc = editor.GetDesignViewDocument(); contentAreaDoc.execCommand("useCSS", false, true); var isSuccessfully = this.ExecuteInternal(cmdValue, editor); contentAreaDoc.execCommand("useCSS", false, false); return isSuccessfully; } else { return this.ExecuteInternal(cmdValue, editor); } }, ExecuteInternal: function(cmdValue, editor) { var selection = editor.GetSelection(); var elements = selection.GetElements(); for(var i = 0, el; el = elements[i]; i++) { if(el.nodeType == 1) this.ClearStyles(el); } return ASPxHtmlEditorCommands.Browser.Command.prototype.Execute.call(this, cmdValue, editor); }, ClearStyles: function(element) { var styles = []; if(this.commandID == ASPxClientCommandConsts.BOLD_COMMAND) styles = ["fontWeight", "bold", "normal", "light"]; else if(this.commandID == ASPxClientCommandConsts.ITALIC_COMMAND) styles = ["fontStyle", "italic", "normal"]; else if(this.commandID == ASPxClientCommandConsts.UNDERLINE_COMMAND) styles = ["textDecoration", "underline", "none"]; else if(this.commandID == ASPxClientCommandConsts.STRIKETHROUGH_COMMAND) styles = ["textDecoration", "line-through", "none"]; if(styles.length == 0) return; var styleName = styles[0]; if(element.style[styleName]) { for(var i = 1; i < styles.length; i++) { var styleValue = styles[i]; var regEx = new RegExp(styleValue, "gi"); element.style[styleName] = element.style[styleName].replace(regEx, ""); } } for(var el = element.firstChild; el; el = el.nextSibling) { if(el.nodeType == 1) this.ClearStyles(el); } } }); ASPxHtmlEditorCommands.Browser.Justify = _aspxCreateClass(ASPxHtmlEditorCommands.Browser.Command, { Execute: function(cmdValue, editor) { var selection = editor.GetSelection(); var curElement = selection.GetSelectedElement(); var setAlign = this.GetAlignByCommandID(); if(!setAlign) return false; if(this.IsImgElement(curElement)) { ASPxHtmlEditorCommands.Browser.Command.prototype.Execute.apply(this, arguments); var imageInfo = ASPxHtmlEditorCommands.ChangeImage.GetImageProperties(curElement); setAlign = setAlign == "justify" ? "left" : setAlign; curElement = ASPxHtmlEditorCommands.ChangeImage.SetImageProperties(curElement, { width: null, height: null, align: setAlign, useFloat: imageInfo.useFloat }); if(_aspxIsExistsElement(curElement)) ASPxClientHtmlEditorSelection.SelectElement(curElement, editor); return true; } else { var selection = editor.GetSelection(); var elements = selection.GetElements(); if(elements.length == 0) elements.push(curElement); for(var i = 0, el; el = elements[i]; i++) { var par = this.FindAlignParagraph(el); if(par && !this.IsTextAlignStateConform(par, setAlign)) { par.align = ""; par.style.textAlign = setAlign; } } if(__aspxIE && (curElement.tagName == "DIV" || this.IsElementContainsDivs(curElement))) { var divs = []; if(curElement.tagName == "DIV") divs.push(curElement); else { for(var child = curElement.firstChild; child; child = child.nextSibling) { if(child.tagName == "DIV") divs.push(child); } } for(var i = 0, div; div = divs[i]; i++) _aspxChangeStyleAttribute(div, "display", "inline"); var res = ASPxHtmlEditorCommands.Browser.Command.prototype.Execute.call(this, cmdValue, editor); for(var i = 0, div; div = divs[i]; i++) _aspxRestoreStyleAttribute(div, "display"); return res; } return ASPxHtmlEditorCommands.Browser.Command.prototype.Execute.call(this, cmdValue, editor); } }, FindAlignParagraph: function(element) { for(var el = element; el && el.tagName != "BODY"; el = el.parentNode) { if(el.tagName == "P" && ((el.style && el.style.textAlign) || el.align)) return el; } return null; }, TryGetState: function(editor) { var curElement = ASPxClientHtmlEditorSelection.Create(editor).GetParentElement(); var findAlign = this.GetAlignByCommandID(); if(!findAlign || !curElement) return false; var isImgElement = this.IsImgElement(curElement); if(!isImgElement && !__aspxWebKitFamily) return ASPxHtmlEditorCommands.Browser.Command.prototype.TryGetState.call(this, editor); if(isImgElement){ var imageInfo = ASPxHtmlEditorCommands.ChangeImage.GetImageProperties(curElement); return imageInfo.align == findAlign; } if(curElement.nodeType == 1 && this.IsTextAlignStateConform(curElement, findAlign)) return true; return this.IsTextAlignStateConform(curElement.parentNode, findAlign); }, IsTextAlignStateConform: function(element, findAlign) { return _aspxGetAttribute(element, "align") == findAlign || element.style.textAlign == findAlign; }, IsImgElement: function(element) { return (element && element.nodeType == 1 && element.tagName.toLowerCase() == "img"); }, IsElementContainsDivs: function(element) { for(var child = element.firstChild; child; child = child.nextSibling) { if(child.tagName == "DIV") return true; } return false; }, GetAlignByCommandID: function() { switch(this.commandID) { case "justifyleft": return "left"; break; case "justifycenter": return "center"; break; case "justifyright": return "right"; break; case "justifyfull": return "justify"; break; default: return null; } } }); ASPxHtmlEditorCommands.SelectionManipulationCommand = _aspxCreateClass(ASPxHtmlEditorCommands.Command, { Execute: function(cmdValue, editor) { this.newElements = []; if(__aspxIE && __aspxBrowserMajorVersion > 8) editor.RestoreSelection(); }, WrapElementInternal: function(target, wrapper) { var inline = this.IsInlineTextElement(wrapper); if((inline || this.IsNewElement(target.previousSibling)) && target.previousSibling && this.CanMerge(target.previousSibling, wrapper)) { target.previousSibling.appendChild(target); return target.previousSibling; } else if ((inline || this.IsNewElement(target.nextSibling)) && target.nextSibling && this.CanMerge(target.nextSibling, wrapper)) { target.nextSibling.insertBefore(target, target.nextSibling.firstChild); return target.nextSibling; } else { target.parentNode.insertBefore(wrapper, target); wrapper.appendChild(target); this.newElements.push(wrapper); return wrapper; } }, IsNewElement: function(target) { for(var i = 0, el; el = this.newElements[i]; i++) { if(target == el) return true; } return false; }, CanMerge: function(el1, el2) { return el1.tagName == el2.tagName && el1.className == el2.className; }, IsInlineTextElement: function(el) { var expr = /^(SPAN|B|STRONG|I|EM|U|SUP|SUB|FONT)$/i; return expr.test(typeof(el) == "object" ? el.tagName : el); }, SeparateParentByPredicate: function(target, predicate) { while(target && predicate(target) && this.SeparateParent(target, target.parentNode.className, false)) { target = target.parentNode; } return target; }, SeparateParent: function(target, className, tryMerge) { var parent = target.parentNode; if(!parent || parent.tagName == "BODY") return false; if(target.previousSibling) { var prevParent = parent.previousSibling; if(!prevParent || prevParent.tagName != parent.tagName || prevParent.className != parent.className) { prevParent = parent.cloneNode(false); parent.parentNode.insertBefore(prevParent, parent); } for(var child = parent.firstChild; child && child != target; child = parent.firstChild) { prevParent.appendChild(child); } } if(target.nextSibling) { var nextParent = parent.nextSibling; if(!nextParent || nextParent.tagName != parent.tagName || nextParent.className != parent.className) { nextParent = parent.cloneNode(false); _aspxInsertElementAfter(nextParent, parent); } for(var child = parent.lastChild; child && child != target; child = parent.lastChild) { nextParent.insertBefore(child, nextParent.firstChild); } } this.SetClassName(parent, className); if(tryMerge && parent.previousSibling && this.CanMerge(parent, parent.previousSibling)) { parent.previousSibling.appendChild(target); _aspxRemoveElement(parent); } else if(tryMerge && parent.nextSibling && this.CanMerge(parent, parent.nextSibling)) { parent.nextSibling.insertBefore(target, parent.nextSibling.firstChild); _aspxRemoveElement(parent); } return true; }, SetClassName: function(target, className) { if(!className) _aspxRemoveAttribute(target, !__aspxIE || __aspxBrowserVersion >= 8 ? "class" : "className"); else target.className = className; } }); ASPxHtmlEditorCommands.ApplyCss = _aspxCreateClass(ASPxHtmlEditorCommands.SelectionManipulationCommand, { Execute: function(cmdValue, editor) { ASPxHtmlEditorCommands.SelectionManipulationCommand.prototype.Execute.apply(this, arguments); cmdValue.tagName = _aspxTrim(cmdValue.tagName).toUpperCase(); cmdValue.cssClass = _aspxTrim(cmdValue.cssClass); if(this.IsExclusionTagName(cmdValue.tagName)) return false; var selection = editor.GetSelection(); var parentElement = selection.GetSelectedElement(); if(parentElement.nodeType == 3) parentElement = parentElement.parentNode; var cleanMode = !cmdValue.cssClass && !cmdValue.tagName; if(this.IsExclusionTagName(parentElement.tagName)) { this.SetClassName(parentElement, cmdValue.cssClass); } else if(selection.GetHtml()) { var elements = selection.GetElements(); for(var i = 0, el; el = elements[i]; i++) { if(cleanMode) this.CleanFormat(el); else if(!this.GetEqualParentElement(el.nodeType == 3 ? el.parentNode : el, cmdValue.tagName, cmdValue.cssClass)) this.ApplyFormat(el, cmdValue.cssClass, cmdValue.tagName); } } }, GetValue: function(editor) { var element = editor.GetSelection().GetSelectedElement(); var tagName = ""; var cssClass = ""; if (element && element.nodeType == 1 && element.tagName != "BODY") { tagName = element.tagName.toLowerCase(); cssClass = element.className; } return { tagName: tagName, cssClass: cssClass }; }, CleanFormat: function(el) { var parent = el.parentNode; if(el.nodeType == 3 && parent.className && this.IsInlineTextElement(parent)) this.SeparateParent(el, "", true); else if(el.nodeType == 1) { this.CleanFormatInDescendants(el); var prevSibling = el.previousSibling; if(el.previousSibling && prevSibling.tagName == el.tagName && !prevSibling.className) { for(var child = el.firstChild; child; child = el.firstChild) { el.previousSibling.appendChild(child); } _aspxRemoveElement(el); } } }, CleanFormatInDescendants: function(el) { if(el.nodeType == 1) { this.SetClassName(el, ""); for(var child = el.firstChild; child; child = child.nextSibling) { this.CleanFormatInDescendants(child); } } }, ApplyFormat: function(el, className, tagName) { if(el.nodeType == 1 && (!tagName || el.tagName == tagName)) this.AppendClassName(el, className); else this.ApplyWrapperFormat(el, !tagName ? "SPAN" : tagName, className); }, ApplyWrapperFormat: function(el, tagName, className) { if(this.FindNotNestedNode(el) && this.IsCantBeNested(tagName)) { var _this = this; var predicate = function(target) { return !_this.IsCantBeNested(target); }; var nnElement = this.SeparateParentByPredicate(el, predicate); var wrapper = this.WrapElement(nnElement, tagName, className); for(var child = nnElement.firstChild; child; child = nnElement.firstChild) { nnElement.parentNode.insertBefore(child, nnElement); } _aspxRemoveElement(nnElement); } else if(this.IsInlineTextElement(el.nodeType == 3 ? el.parentNode : el)) { var _this = this; var predicate = function(target) { return !_this.IsInlineTextElement(target.parentNode); }; el = this.IsInlineTextElement(tagName) ? el : this.SeparateParentByPredicate(el, predicate); this.WrapElement(el, tagName, className); } else if(el.nodeType == 3) this.WrapElement(el, tagName, className); else this.ApplyFormatToInlineChilds(el, tagName, className); }, AppendClassName: function(target, className) { if(className && target.className.indexOf(className) == -1) { if(target.className.length > 0) className = " " + className; target.className += className; } }, WrapElement: function(target, tagName, className) { var wrapper = target.ownerDocument.createElement(tagName); this.SetClassName(wrapper, className); this.WrapElementInternal(target, wrapper); }, ApplyFormatToInlineChilds: function(el, tagName, className) { var child = el.firstChild; while(child) { var next = child.nextSibling; if(child.nodeType == 3) this.WrapElement(child, tagName, className); else if(child.tagName == tagName && child.className.indexOf(className) < 0) this.AppendClassName(child, className); else if(this.IsInlineTextElement(child)) this.WrapElement(child, tagName, className); else this.ApplyFormatToInlineChilds(child, tagName, className); child = next; } }, IsCantBeNested: function(el) { var expr = /^(H[1-6]|P|ADDRESS|BLOCKQUOTE|PRE|A)$/i; return expr.test(typeof(el) == "object" ? el.tagName : el); }, IsExclusionTagName: function(tagName) { tagName = tagName.toUpperCase(); return tagName == "IMG" || tagName == "TABLE" || tagName == "OBJECT" || tagName == "EMBED"; }, GetEqualParentElement: function(elem, tagName, cssClass) { if (tagName && cssClass) return _aspxGetParentByTagNameAndAttributeValue(elem, tagName, "class", cssClass); else if (cssClass) return _aspxGetParentByPartialClassName(elem, cssClass); }, FindNotNestedNode: function(el) { if(!el || el.tagName == "BODY") return null; if(el.nodeType == 3) el = el.parentNode; if(this.IsCantBeNested(el)) return el; return this.FindNotNestedNode(el.parentNode); } }); ASPxHtmlEditorCommands.Browser.FontColor = _aspxCreateClass(ASPxHtmlEditorCommands.Browser.Command, { Execute: function(cmdValue, editor) { if (!cmdValue) cmdValue = editor.currentFontColor; else editor.currentFontColor = cmdValue; var hyperlinks; if(__aspxIE || __aspxWebKitFamily) hyperlinks = this.SaveHyperlinks(editor); if(__aspxFirefox && __aspxBrowserVersion >= 4) { var contentAreaDoc = editor.GetDesignViewDocument(); contentAreaDoc.execCommand("useCSS", false, false); var commandExecResult = ASPxHtmlEditorCommands.Browser.Command.prototype.Execute.call(this, cmdValue, editor); contentAreaDoc.execCommand("useCSS", false, true); } else var commandExecResult = ASPxHtmlEditorCommands.Browser.Command.prototype.Execute.call(this, cmdValue, editor); if(hyperlinks) this.RestoreHyperlinks(hyperlinks); return commandExecResult; }, GetValue: function(editor) { return _aspxColorToHexadecimal(ASPxHtmlEditorCommands.Browser.Command.prototype.GetValue.call(this, editor)); }, NeedUseCss: function() { return !__aspxNetscapeFamily; }, TryGetValue: function(editor) { return editor.currentFontColor; }, SaveHyperlinks: function(htmlEditor) { var hyperlinks = [ ]; var selection = ASPxClientHtmlEditorSelection.Create(htmlEditor); var selectionContainer = selection.GetParentElement(); var anchors = _aspxGetElementsByTagName(selectionContainer, "A"); for(var i = 0; i < anchors.length; i++) { var anchor = anchors[i]; if(this.IsHyperlink(anchor)) { hyperlinks.push( { element: anchor, innerHTML: anchor.innerHTML } ); } } return hyperlinks; }, RestoreHyperlinks: function(hyperlinks) { for(var i = 0; i < hyperlinks.length; i++) { var hyperlink = hyperlinks[i]; hyperlink.element.innerHTML = hyperlink.innerHTML; } }, IsHyperlink: function(anchor) { return typeof(anchor.href) == "string" && anchor.href.length > 0; } }); ASPxHtmlEditorCommands.Browser.FontSize = _aspxCreateClass(ASPxHtmlEditorCommands.Browser.Command, { GetValue: function(editor) { var value = ASPxHtmlEditorCommands.Browser.Command.prototype.GetValue.call(this, editor); if(value && typeof(value) == 'string') { if(value.indexOf("px") > -1) { var index = _aspxGetDefaultSafariFontSizesInPixelHashTable()[value]; return index > -1 ? index + 1 : null; } if(value.indexOf("pt") > -1) { var index = _aspxGetDefaultSafariFontSizesHashTable()[value]; return index > -1 ? index + 1 : null; } } return value; } }); ASPxHtmlEditorCommands.Browser.FontName = _aspxCreateClass(ASPxHtmlEditorCommands.Browser.Command, { GetValue: function(editor) { var value = ASPxHtmlEditorCommands.Browser.Command.prototype.GetValue.call(this, editor); return value ? this.TrimApostrophes(value) : ""; }, TrimApostrophes: function(str) { if(str.indexOf('\'') == 0) str = str.substr(1); if(str.indexOf('\'') == str.length - 1) str = str.substr(0, str.length - 1); return str; }, NeedUseCss: function() { return !(__aspxFirefox && __aspxBrowserVersion >= 4); } }); ASPxHtmlEditorCommands.Browser.BgColor = _aspxCreateClass(ASPxHtmlEditorCommands.Browser.FontColor, { Execute: function(cmdValue, editor) { if (!cmdValue) cmdValue = editor.currentBgColor; else editor.currentBgColor = cmdValue; return ASPxHtmlEditorCommands.Browser.Command.prototype.Execute.call(this, cmdValue, editor); }, GetCommandName: function() { return __aspxIE ? ASPxHtmlEditorCommands.Browser.Command.prototype.GetCommandName.call(this) : "HiliteColor"; }, NeedUseCss: function() { return true; }, TryGetValue: function(editor) { return editor.currentBgColor; } }); ASPxHtmlEditorCommands.Browser.InsertList = _aspxCreateClass(ASPxHtmlEditorCommands.Browser.Command, { GetState: function(editor) { var curSelection = ASPxClientHtmlEditorSelection.Create(editor); var tagName = ""; switch (this.GetCommandName()) { case ASPxClientCommandConsts.INSERTORDEREDLIST_COMMAND: tagName = "OL";break; case ASPxClientCommandConsts.INSERTUNORDEREDLIST_COMMAND: tagName = "UL";break; } return !!_aspxGetParentByTagName(curSelection.GetParentElement(), tagName); }, Execute: function(cmdValue, editor) { if(__aspxIE) { var doc = editor.GetDesignViewDocument(); var selectedElement = editor.GetSelection().selectedElement; var clientSelection = editor.GetSelection().clientSelection; var listItem = _aspxGetParentByTagName(selectedElement, "LI"); var tagName = (this.GetCommandName() == ASPxClientCommandConsts.INSERTORDEREDLIST_COMMAND) ? "OL" : "UL"; var oppositeTagName = (tagName == "OL") ? "UL" : "OL"; if(listItem != null && listItem.tagName == "LI" && listItem.parentNode.tagName == oppositeTagName) { var bookmark = clientSelection.GetExtendedBookmark(); var curList = listItem.parentNode; var newList = doc.createElement(tagName); curList.parentNode.insertBefore(newList, listItem.parentNode); if(listItem.previousSibling && listItem.previousSibling.tagName == "LI") { var newPrevList = curList.cloneNode(false); var curNode = curList.firstChild; do { var nextNode = curNode.nextSibling; newPrevList.appendChild(curNode); curNode = nextNode; } while(curNode && nextNode != listItem); newList.parentNode.insertBefore(newPrevList, newList); } newList.appendChild(listItem); if(curList.childNodes.length == 0) _aspxRemoveElement(curList); newList.appendChild(listItem); selectedElement = _aspxGetElementByIdInDocument(doc, bookmark.endMarkerID); clientSelection.SelectElement(selectedElement); clientSelection.RemoveExtendedBookmark(bookmark); ASPxHtmlEditorCommands.Command.prototype.Execute.apply(this, arguments); return true; } else if(!listItem && selectedElement.tagName != tagName) { var bookmark = clientSelection.GetExtendedBookmark(); selectedElement = this.GetBlockSelectedElement(selectedElement); var lineInfos = this.GetLineInfos(selectedElement); var selectedLineInfos = this.GetSelectedLineInfos(selectedElement, lineInfos, bookmark); var result = this.CreateBulletList(doc, tagName, lineInfos, selectedLineInfos.startLineIndex, selectedLineInfos.endLineIndex); if(__aspxBrowserMajorVersion == 9) editor.RestoreSelection(); selectedElement = _aspxGetElementByIdInDocument(doc, bookmark.endMarkerID); clientSelection.SelectElement(selectedElement); clientSelection.RemoveExtendedBookmark(bookmark); if(result) return true; } } return ASPxHtmlEditorCommands.Browser.Command.prototype.Execute.call(this, cmdValue, editor); }, CreateBulletList: function(doc, tagName, lineInfos, startLineIndex, endLineIndex) { if(startLineIndex == -1 || endLineIndex == -1) return false; var lineIndex = startLineIndex; var lineCount = lineInfos.length; while(lineIndex <= endLineIndex) { var line = lineInfos[lineIndex]; var firstLineNode = line[0]; var lastLineNode = line[line.length - 1]; var firstLineElement = this.GetLineSelectedElement(firstLineNode); var lastLineElement = this.GetLineSelectedElement(lastLineNode); var firstBlockNode = this.GetBlockSelectedElement(firstLineNode); var hasBlockSibling = _aspxGetChildNodes(firstBlockNode, function(element) { return ASPxHtmlEditorCommands.Enter.IsBlockNode(element); }).length > 0; var parent = null; var replacedElement = null; var isParentBlockLimit = this.IsBlockLimitElement(firstBlockNode); var isMoveOutTheBlock = !hasBlockSibling && !isParentBlockLimit; if(lineIndex == startLineIndex) { var isList = false; var sBlock = firstBlockNode; if(sBlock.tagName == "LI") { sBlock = sBlock.parentNode; isList = true; isMoveOutTheBlock = true; } for(var i = 0; i < lineIndex; i++) { var uBlock = this.GetBlockSelectedElement(lineInfos[i][0]); if(uBlock.tagName == "LI") uBlock = uBlock.parentNode; if(uBlock == sBlock && uBlock.tagName != tagName) { var tFirst = lineInfos[i]; var tLast = lineInfos[lineIndex - 1]; var tFirstLineNode = tFirst[0]; var tLastLineNode = tLast[tLast.length - 1]; var textNodes = ASPxClientHtmlProcessingUtils.SplitNode(uBlock, [tFirstLineNode, tLastLineNode]); if(isMoveOutTheBlock) sBlock.parentNode.insertBefore(textNodes[1].cloneNode(true), sBlock); else { var childs = textNodes[1].childNodes; var target = sBlock.firstChild; for(var j = 0; j < childs.length; j++) sBlock.insertBefore(childs[j].cloneNode(true), target); } this.RemoveLineBreakElement(uBlock, tFirstLineNode, tLastLineNode); this.RemoveLineElement(uBlock, tFirstLineNode, tLastLineNode); if(isList) { while(_aspxGetInnerText(uBlock.firstChild) == "") uBlock.removeChild(uBlock.firstChild); } break; } } } if(isParentBlockLimit && !this.IsAcceptableElement(firstBlockNode)) { lineIndex++; continue; } if(firstBlockNode.tagName == "LI") { var parentLI = _aspxGetParentByTagName(firstLineNode, "LI"); var parentList = parentLI.parentNode; var prev = parentList.previousSibling; if(parentList.tagName != tagName) { if(!prev || prev.nodeType != 1 || prev.tagName != tagName) { prev = document.createElement(tagName); parentList.parentNode.insertBefore(prev, parentList); } prev.appendChild(parentLI.cloneNode(true)); _aspxRemoveElement(parentLI); } else if(prev && prev.nodeType == 1 && prev.tagName == tagName) { prev.appendChild(parentLI.cloneNode(true)); _aspxRemoveElement(parentLI); } if(_aspxGetInnerText(parentList) == "") parentList.parentNode.removeChild(parentList); } else { var list = doc.createElement(tagName); var addInBegin = false; if(isMoveOutTheBlock) { replacedElement = firstBlockNode; parent = replacedElement.parentNode; var node = replacedElement.previousSibling; if(node && node.nodeType == 1 && node.tagName == tagName) list = node; else parent.insertBefore(list, replacedElement); parent = replacedElement; } else { parent = firstLineElement.parentNode; var prevNode = firstLineElement.previousSibling; var nextNode = lastLineElement.nextSibling; if(prevNode && prevNode.nodeType == 1 && prevNode.tagName == tagName) list = prevNode; else if(nextNode && nextNode.nodeType == 1 && nextNode.tagName == tagName) { list = nextNode; addInBegin = true; } else { parent.insertBefore(list, firstLineElement); if(this.IsBoundaryElement(list.previousSibling)) parent.removeChild(list.previousSibling); } } var li = doc.createElement("LI"); if(addInBegin) list.insertBefore(li, list.firstChild); else list.appendChild(li); var textNodes = ASPxClientHtmlProcessingUtils.SplitNode(parent, [firstLineNode, lastLineNode]); if(isMoveOutTheBlock) this.AppendLineElement(li, replacedElement, textNodes[1].cloneNode(true)); else { var childs = textNodes[1].childNodes; for(var j = 0; j < childs.length; j++) this.AppendLineElement(li, null, childs[j].cloneNode(true)); } this.RemoveLineBreakElement(parent, firstLineNode, lastLineNode); this.RemoveLineElement(parent, firstLineNode, lastLineNode); if(replacedElement && _aspxGetInnerText(replacedElement) == "") replacedElement.parentNode.removeChild(replacedElement); } lineIndex++; } return true; }, AppendLineElement: function(li, lineBlock, node) { if(lineBlock && {p:1, div:1}[node.tagName.toLowerCase()]) { _aspxCopyAllAttributes(lineBlock, li); li.innerHTML = node.innerHTML; } else li.appendChild(node); }, RemoveLineBreakElement: function(lineBlock, firstLineNode, lastLineNode) { var isRemoved = false; var first = firstLineNode; var last = lastLineNode; var parent = first.parentNode; do { if(last && this.IsBoundaryElement(last.nextSibling)) { last.parentNode.removeChild(last.nextSibling); isRemoved = true; } else if(first && this.IsBoundaryElement(first.previousSibling)) { first.parentNode.removeChild(first.previousSibling); isRemoved = true; } else { first = first ? first.previousSibling : null; last = last ? last.nextSibling : null; if(!(first || last)) { first = parent.previousSibling ? parent.previousSibling : null; last = parent.nextSibling ? parent.nextSibling : null; if(parent != lineBlock) parent = parent.parentNode; } } } while(!isRemoved && parent != lineBlock); }, RemoveLineElement: function(lineBlock, firstLineNode, lastLineNode) { if(firstLineNode == lastLineNode) { firstLineNode.parentNode.removeChild(firstLineNode); return; } var isNeedRemoveElement = (arguments[3] == true); if(lineBlock.hasChildNodes()) { var childs = lineBlock.childNodes; var index = 0; while(childs[index]) { if(childs[index].hasChildNodes()) isNeedRemoveElement = this.RemoveLineElement(childs[index], firstLineNode, lastLineNode, isNeedRemoveElement); if(childs[index] == firstLineNode) isNeedRemoveElement = true; if(isNeedRemoveElement) { if(childs[index] == lastLineNode) isNeedRemoveElement = false; lineBlock.removeChild(childs[index]); } else index++; } } return isNeedRemoveElement; }, GetBlockSelectedElement: function(element) { while(element && !(this.IsBlockLimitElement(element) || this.IsBlockElement(element))) element = element.parentNode; return element; }, GetLineSelectedElement: function(element) { var parent = element.parentNode; while(parent && !this.IsBlockLimitElement(parent) && !this.IsBlockElement(parent)) { element = parent; parent = parent.parentNode; } return element; }, GetLineInfos: function(selectedElement) { var properties = { lineInfos: [], lineElements: [] }; properties = this.SearchHtmlLines(selectedElement, properties); return properties.lineInfos; }, GetSelectedLineInfos: function(parentElement, lineInfos, bookmark) { var startLineIndex = -1, endLineIndex = -1, i = 0, lineCount = lineInfos.length; while(i < lineCount) { var line = lineInfos[i]; var markers; if(line.length == 1 && line[0].nodeType == 1) markers = this.SearchMarkers(line[0], bookmark); else if(line.length > 1) { params = [line[0], line[line.length - 1]]; parts = ASPxClientHtmlProcessingUtils.SplitNode(parentElement, params); var markers = this.SearchMarkers(parts[1], bookmark); if(startLineIndex == -1 && markers.startMarkerIsFound) startLineIndex = i; if(endLineIndex == -1 && markers.endMarkerIsFound) endLineIndex = i; } i++; } return { startLineIndex: startLineIndex, endLineIndex: endLineIndex }; }, SearchHtmlLines: function(element, properties) { var nodes = element.childNodes; for(var i = 0; i < nodes.length; i++) { var isLineBreak = this.IsBoundaryElement(nodes[i]) || this.IsBlockElement(nodes[i]) || this.IsBlockLimitElement(nodes[i]); if( !isLineBreak ) { if(nodes[i].hasChildNodes()) properties = this.SearchHtmlLines(nodes[i], properties); else properties.lineElements.push(nodes[i]); } else { if(properties.lineElements.length > 0) { properties.lineInfos.push( properties.lineElements ); properties.lineElements = []; } if(nodes[i].hasChildNodes()) properties = this.SearchHtmlLines(nodes[i], properties); } } if(this.IsBlockElement(element) || this.IsBlockLimitElement(element)) { if(properties.lineElements.length > 0) { properties.lineInfos.push( properties.lineElements ); properties.lineElements = []; } } return properties; }, SearchMarkers: function(element, bookmark) { var start = false; var end = false; if(element.nodeType == 1) { if(element.id == bookmark.startMarkerID) start = true; if(element.id == bookmark.endMarkerID) end = true; if(element.hasChildNodes()) { var childs = element.childNodes; for(var i = 0; i < childs.length; i++) { var markers = this.SearchMarkers(childs[i], bookmark); start = start || markers.startMarkerIsFound; end = end || markers.endMarkerIsFound; } } } return { startMarkerIsFound: start, endMarkerIsFound: end }; }, IsAcceptableElement: function(element) { var unacceptableElements = {colgroup: 1, table: 1, tbody: 1, thead:1, tfoot:1, tr: 1 }; if(element.nodeType == 1) return !unacceptableElements[element.tagName.toLowerCase()]; return true; }, IsBlockElement: function(element) { return ASPxHtmlEditorCommands.Enter.IsBlockNode(element); }, IsBlockLimitElement: function(element) { if(!this.limiters) { this.limiters = {}; for(var e in __aspxHEPathBlockLimitElements) { if(!{div:1}[e]) this.limiters[e] = 1; } } return element.nodeType == 1 && !!this.limiters[element.tagName.toLowerCase()]; }, IsBoundaryElement: function(element) { return element != null && element.nodeType == 1 && element.tagName.toUpperCase() == "BR"; } }); ASPxHtmlEditorCommands.Browser.Indent = _aspxCreateClass(ASPxHtmlEditorCommands.Browser.Command, { Execute: function(cmdValue, editor) { var curSelection = ASPxClientHtmlEditorSelection.Create(editor); var selectedList = ASPxHtmlEditorCommands.Browser.Indent.GetMainParentList(curSelection.GetParentElement()); if (selectedList) this.IndentList(selectedList, curSelection, editor); else ASPxHtmlEditorCommands.Browser.Command.prototype.Execute.call(this, cmdValue, editor); return true; }, GetState: function(editor) { return false; }, IsLocked: function(editor) { if (__aspxOpera) return this.TryGetIsLocked(editor); return ASPxHtmlEditorCommands.Browser.Command.prototype.IsLocked.call(this, editor); }, TryGetIsLocked: function(editor) { var isLocked = false; var curSelection = ASPxClientHtmlEditorSelection.Create(editor); var selectedList = ASPxHtmlEditorCommands.Browser.Indent.GetParentList(curSelection.GetParentElement()); if (selectedList) { selectedList = ASPxHtmlEditorCommands.Browser.Indent.GetMainParentList(curSelection.GetParentElement()); isLocked = !this.IsIndentionAllowed(selectedList, curSelection.GetStartContainer(), curSelection.GetEndContainer(), editor); } else isLocked = ASPxHtmlEditorCommands.Browser.Command.prototype.TryGetIsLocked.call(this, editor); return isLocked; }, IndentList: function(listNode, selection, editor) { var bookmark = selection.GetExtendedBookmark(); var doc = editor.GetDesignViewDocument(); selection = ASPxClientHtmlEditorSelection.Create(editor); var newlistNode = ASPxHtmlEditorCommands.Browser.Indent.IndentListCore(listNode, selection.GetStartContainer(), selection.GetEndContainer(), this.GetIndent()); listNode.parentNode.replaceChild(newlistNode, listNode); if(__aspxIE && __aspxBrowserMajorVersion > 8 && bookmark.endMarkerID) { var endBm = doc.getElementById(bookmark.endMarkerID); if(endBm.parentNode.childNodes.length == 2 && endBm.parentNode.firstChild.id == bookmark.startMarkerID) { var fakeElement = doc.createTextNode(" "); endBm.parentNode.insertBefore(fakeElement, endBm.parentNode.firstChild); } } selection.SelectExtendedBookmark(bookmark); if(fakeElement) fakeElement.parentNode.removeChild(fakeElement); if (!__aspxIE || __aspxBrowserMajorVersion > 8) editor.SetFocus(); }, IsIndentionAllowed: function(listNode, startItemNode, endItemNode, htmlEditor) { startItemNode = ASPxHtmlEditorCommands.Browser.Indent.EnsureListItemNode(startItemNode); endItemNode = ASPxHtmlEditorCommands.Browser.Indent.EnsureListItemNode(endItemNode); var indent = this.GetIndent(); var listItemArray = ASPxHtmlEditorCommands.Browser.Indent.GetListItemArray(listNode, 0, null); listItemArray = ASPxHtmlEditorCommands.Browser.Indent.IndentListItemsInItemArray(listItemArray, startItemNode, endItemNode, indent); if (listItemArray == null || listItemArray[0].level != 0) return false; for (var i = 1; i < listItemArray.length; i++) { if (indent > 0) { if (listItemArray[i].level - listItemArray[i - 1].level > indent) return false; } else if (listItemArray[i].level < 0) return false; } return true; }, GetIndent: function() { var indent = 0; switch (this.GetCommandName()) { case ASPxClientCommandConsts.INDENT_COMMAND: indent = 1; break; case ASPxClientCommandConsts.OUTDENT_COMMAND: indent = -1; break; } return indent; } }); ASPxHtmlEditorCommands.Browser.Indent.IndentListCore = function(listNode, startNode, endNode, indent) { startNode = ASPxHtmlEditorCommands.Browser.Indent.EnsureListItemNode(startNode); endNode = ASPxHtmlEditorCommands.Browser.Indent.EnsureListItemNode(endNode); var listItemArray = ASPxHtmlEditorCommands.Browser.Indent.GetListItemArray(listNode, 0, null); var itemArray = ASPxHtmlEditorCommands.Browser.Indent.IndentListItemsInItemArray(listItemArray, startNode, endNode, indent); return ASPxHtmlEditorCommands.Browser.Indent.GenerateListByItemArray(itemArray); }; ASPxHtmlEditorCommands.Browser.Indent.GetListItemArray = function(listNode, currentLevel, itemArray, parentItemIndex) { if (!itemArray) itemArray = [ ]; if (!_aspxIsExists(parentItemIndex)) parentItemIndex = -1; var curListItem = _aspxGetChildByTagName(listNode, "LI" ,0); while(curListItem) { itemArray.push({ 'level': currentLevel, 'node' : curListItem, 'parentItemIndex' : parentItemIndex }); var nestedListNode = ASPxHtmlEditorCommands.Browser.Indent.GetChildList(curListItem); if (nestedListNode) itemArray = ASPxHtmlEditorCommands.Browser.Indent.GetListItemArray(nestedListNode, currentLevel + 1, itemArray, itemArray.length - 1); curListItem = ASPxHtmlEditorCommands.Browser.Indent.GetNextListItem(curListItem); } return itemArray; }; ASPxHtmlEditorCommands.Browser.Indent.IndentListItemsInItemArray = function(itemArray, startListItem, endListItem, indent) { var startItemIndex = -1; var endItemIndex = -1; for (var i = 0; i < itemArray.length; i++) { if (itemArray[i].node == startListItem) startItemIndex = i; if (itemArray[i].node == endListItem) endItemIndex = i; if (startItemIndex != -1 && endItemIndex != -1) break; } if (startItemIndex == -1 || endItemIndex == -1) return null; for (var i = startItemIndex; i <= endItemIndex; i++) itemArray[i].level += indent; if (indent < 0) { for (var i = 0; i < itemArray.length; i++) { if (itemArray[i].parentItemIndex != -1) { var parentLevel = itemArray[itemArray[i].parentItemIndex].level; if (itemArray[i].level - parentLevel > 1) itemArray[i].level += indent; } } } return itemArray; }; ASPxHtmlEditorCommands.Browser.Indent.GenerateListByItemArray = function(itemArray) { if (itemArray.length <= 0) return null; var doc = itemArray[0].node.document || itemArray[0].node.ownerDocument; var listNodeByLevel = []; var listItemNodeArray = []; var curLevel = 0; for (var i = 0; i < itemArray.length; i++) { var curItem = itemArray[i]; if (curLevel > curItem.level) { for (var j = curItem.level + 1; j <= curLevel; j++) listNodeByLevel[j] = null; } if (!listNodeByLevel[curItem.level]) { var oldListNode = ASPxHtmlEditorCommands.Browser.Indent.GetParentList(curItem.node); var newListNode = oldListNode.cloneNode(false); listNodeByLevel[curItem.level] = newListNode; if (curItem.level - 1 >= 0) listItemNodeArray[curItem.level - 1].appendChild(newListNode); } var clonedListItem = ASPxHtmlEditorCommands.Browser.Indent.CloneListItem(curItem.node, doc); listItemNodeArray[curItem.level] = clonedListItem; listNodeByLevel[curItem.level].appendChild(clonedListItem); curLevel = curItem.level; } return listNodeByLevel[0]; }; ASPxHtmlEditorCommands.Browser.Indent.EnsureListItemNode = function(node) { while (node) { var tagName = ""; var parentNode = node.parentNode; if (parentNode && parentNode.nodeType == 1) tagName = parentNode.tagName.toUpperCase(); if (tagName == "OL" || tagName == "UL") break; node = parentNode; } return node; }; ASPxHtmlEditorCommands.Browser.Indent.CloneListItem = function(item, doc) { var newItem = item.cloneNode(true); newItem.innerHTML = ""; for (var i = 0 ; i < item.childNodes.length; i++) { var tagName = item.childNodes[i].tagName; tagName = tagName ? tagName.toUpperCase() : ""; if ((tagName != "UL") && (tagName != "OL")) newItem.appendChild(item.childNodes[i].cloneNode(true)); } return newItem; }; ASPxHtmlEditorCommands.Browser.Indent.GetChildList = function(elem) { for (var i = 0 ; i < elem.childNodes.length; i++) { var tagName = elem.childNodes[i].tagName; tagName = tagName ? tagName.toUpperCase() : ""; if ((tagName == "UL") || (tagName == "OL")) return elem.childNodes[i]; } return null; }; ASPxHtmlEditorCommands.Browser.Indent.GetNextListItem = function(listItemNode) { var nextListItemNode = listItemNode.nextSibling; while (nextListItemNode != null && nextListItemNode.nodeType != 1) nextListItemNode = nextListItemNode.nextSibling; return nextListItemNode; }; ASPxHtmlEditorCommands.Browser.Indent.GetMainParentList = function(elem) { var lastListNode = null; while (elem) { if (elem.nodeType == 1) { var tagName = elem.tagName.toUpperCase(); if (tagName == "UL" || tagName == "OL") lastListNode = elem; } elem = elem.parentNode; } return lastListNode; }; ASPxHtmlEditorCommands.Browser.Indent.GetParentList = function(elem) { var selectedList = _aspxGetParentByTagName(elem, "OL"); if (!selectedList) selectedList = _aspxGetParentByTagName(elem, "UL"); return selectedList; }; var __aspxEmptyBorderTableClassName = "dxEmptyBorderTable"; var __aspxHESizeTypeRegExp = new RegExp("([0-9]*[,.]?[0-9]*)(px|%)"); var _aspxHETableHelper = { AppendEmptyBorderClassName: function(elem) { if (elem.className.indexOf(__aspxEmptyBorderTableClassName) > -1) return; elem.className += " " + __aspxEmptyBorderTableClassName; }, IsEmptyBorder: function(table) { if (!table) return false; return table.border == "0" || !table.border; }, ReplaceTableStyleBorderByAttribute: function(table) { var tableStyle = table.style; if (tableStyle.borderLeftColor && (tableStyle.borderLeftColor == tableStyle.borderRightColor) && (tableStyle.borderRightColor == tableStyle.borderBottomColor) && (tableStyle.borderBottomColor == tableStyle.borderTopColor)) { this.SetTableBorderColor(table, tableStyle.borderBottomColor); tableStyle.borderLeftColor = ""; _aspxRemoveStyleAttribute(tableStyle, "borderLeftColor"); tableStyle.borderRightColor = ""; _aspxRemoveStyleAttribute(tableStyle, "borderRightColor"); tableStyle.borderTopColor = ""; _aspxRemoveStyleAttribute(tableStyle, "borderTopColor"); tableStyle.borderBottomColor = ""; _aspxRemoveStyleAttribute(tableStyle, "borderBottomColor"); } }, RemoveEmptyBorderClassName: function(elem) { elem.className = elem.className.replace(__aspxEmptyBorderTableClassName, ""); }, GetTable: function(element) { if(!element) return null; return element.tagName == "TABLE" ? element : _aspxGetParentByTagName(element, "TABLE"); }, GetTableRow: function(elem) { if (elem && elem.nodeType == 1 && elem.tagName.toUpperCase() == "TR") return elem; var cell = this.GetTableCell(elem); if (cell) return cell.parentNode; return null; }, GetTableCellBySelection: function(startElem, endElem) { var cell = _aspxHETableHelper.GetTableCell(startElem); if (!cell && endElem) { cell = _aspxHETableHelper.GetTableCell(endElem); if (__aspxSafari && startElem && startElem.tagName.toUpperCase() == "TR") { var index = cell.cellIndex - 1; if (index < 0) cell = startElem.cells[startElem.cells.length - 1]; else cell = startElem.cells[index]; } } return cell; }, GetTableCell: function(element) { if (!element) return null; if (element.nodeType == "1" && (element.tagName.toUpperCase() == "TD" || element.tagName.toUpperCase() == "TH")) return element; var cell = _aspxGetParentByTagName(element, "TD"); if (!cell) cell = _aspxGetParentByTagName(element, "TH"); return cell; }, GetTableProperties: function(table) { var tableInfoObject = { borderWidth: 0, borderColor: null, backgroundColor: null, width: null, height: null, cellPadding: 0, cellSpacing: 0, align: null, accessibility: null }; if (table.className.indexOf(__aspxEmptyBorderTableClassName) == -1) { if (_aspxIsExists(table.border)) tableInfoObject.borderWidth = table.border; var borderColor = this.GetTableBorderColor(table); if (_aspxIsExists(borderColor)) tableInfoObject.borderColor = borderColor; } if (table.style.backgroundColor) tableInfoObject.backgroundColor = table.style.backgroundColor; if (table.style.width) tableInfoObject.width = table.style.width; if (table.style.height) tableInfoObject.height = table.style.height; tableInfoObject.cellPadding = table.cellPadding; tableInfoObject.cellSpacing = table.cellSpacing; if (table.align) tableInfoObject.align = table.align; var accessibility = { caption: "", summary: "", headers: "" }; accessibility.headers = this.GetAccessibilityHeadersValue(table); accessibility.caption = this.GetAccessibilityCaption(table); accessibility.summary = table.summary; tableInfoObject.accessibility = accessibility; return tableInfoObject; }, SetTableProperties: function(table, properties, htmlEditor) { if (properties) { if (_aspxIsExists(properties.borderWidth)) this.SetTableBorderWidth(table, properties.borderWidth, htmlEditor); if (_aspxIsExists(properties.borderColor)) this.SetTableBorderColor(table, properties.borderColor); this.SetBackgroundColor(table, properties.backgroundColor); table.cellSpacing = properties.cellSpacing; table.cellPadding = properties.cellPadding; if (properties.width) table.style.width = properties.width; else if (_aspxIsExists(table.style.width)) { _aspxRemoveAttribute(table, "width"); _aspxRemoveStyleAttribute(table, "width"); } if (properties.height) table.style.height = properties.height; else if (_aspxIsExists(table.style.height)) { _aspxRemoveAttribute(table, "height"); table.style.height = ""; _aspxRemoveStyleAttribute(table, "height"); } if (properties.align) table.align = properties.align; else if (_aspxIsExists(table.align)) { table.align = ""; _aspxRemoveAttribute(table, "align"); } if (properties.accessibility) this.SetTableAccessibility(table, properties.accessibility); } }, SetTableBorderWidth: function(table, borderWidth, htmlEditor) { if (__aspxFirefox && table.style.borderCollapse == "collapse") { var tempTableId = ASPxClientSelection.CreateUniqueID(); _aspxChangeAttribute(table, "id", tempTableId); table.style.borderCollapse = "separate"; this.currentHtmlEditor = htmlEditor; _aspxSetTimeout("_aspxHETableHelper.SetTableBorderWidthDelay('" + tempTableId + "'," + borderWidth + ")", 100); } else { _aspxSetAttribute(table, "border", borderWidth); this.SetEmptyTableBorderClass(table); } }, SetTableBorderWidthDelay: function(tableId, borderWidth) { var table = _aspxGetElementByIdInDocument(this.currentHtmlEditor.GetDesignViewDocument(), tableId); _aspxSetAttribute(table, "border", borderWidth); table.style.borderCollapse = "collapse"; _aspxRestoreAttribute(table, "id"); this.SetEmptyTableBorderClass(table); this.currentHtmlEditor.commandManager.UpdateLastItemInRestoreHtmlArray(); this.currentHtmlEditor = null; }, SetEmptyTableBorderClass: function(table) { if (this.IsEmptyBorder(table)) this.AppendEmptyBorderClassName(table); else this.RemoveEmptyBorderClassName(table); }, GetCellProperties: function(cell) { var cellInfo = { backgroundColor: null, align: null, vAlign: null }; if (cell.style.textAlign) cellInfo.align = cell.style.textAlign; if (cell.style.verticalAlign) cellInfo.vAlign = cell.style.verticalAlign; if (cell.style.backgroundColor) cellInfo.backgroundColor = cell.style.backgroundColor; return cellInfo; }, SetCellProperties: function(cell, properties) { if (properties.vAlign) cell.style.verticalAlign = properties.vAlign.toLowerCase(); else if (_aspxIsExists(cell.vAlign)) _aspxRemoveStyleAttribute(cell, "verticalAlign"); if (properties.align) cell.style.textAlign = properties.align.toLowerCase(); else if (_aspxIsExists(cell.align)) _aspxRemoveStyleAttribute(cell, "textAlign"); this.SetBackgroundColor(cell, properties.backgroundColor); }, SetCellPropertiesForAllCell: function(table, properties) { for (var i = 0; i < table.rows.length; i++) { for (var j = 0; j < table.rows[i].cells.length; j++) this.SetCellProperties(this.GetCell(table, i, j), properties); } }, SetColumnProperties: function(cell, properties) { var table = _aspxGetParentByTagName(cell, "TABLE"); var row = cell.parentNode; var tableModel = _aspxHETableHelper.CreateTableModel(table); var columnIndex = this.GetColumnIndexByTableModel(tableModel, row.rowIndex, cell); var colSpan = this.GetColSpan(cell); for (var i = 0; i < tableModel.length; i++) { for (var j = columnIndex; j < columnIndex + colSpan; j++) { var curCell = tableModel[i][j]; if (this.GetColSpan(curCell) <= colSpan) { this.SetCellProperties(curCell, properties); if (properties.width) curCell.style.width = properties.width; else if (_aspxIsExists(curCell.style.width)) { curCell.style.width = ""; _aspxRemoveStyleAttribute(curCell, "width"); } } } } }, GetColumnProperties: function(cell) { var columnInfo = { backgroundColor: null, width: null, align: null, vAlign: null }; var table = _aspxGetParentByTagName(cell, "TABLE"); var row = cell.parentNode; var tableModel = _aspxHETableHelper.CreateTableModel(table); var columnIndex = this.GetColumnIndexByTableModel(tableModel, row.rowIndex, cell); var colSpan = this.GetColSpan(cell); var curCellInfo = this.GetCellProperties(cell); var align = columnInfo.align = curCellInfo.align; var vAlign = columnInfo.vAlign = curCellInfo.vAlign; var backgroundColor = columnInfo.backgroundColor = curCellInfo.backgroundColor; var maxCellWidth = 0; var isWidthDefined = true; for (var i = 0; i < tableModel.length; i++) { for (var j = columnIndex; j < columnIndex + colSpan; j++) { var curCell = tableModel[i][j]; if (this.GetColSpan(curCell) <= colSpan) { var curCellInfo = this.GetCellProperties(curCell); if (curCell.style.width && _aspxGetClearClientWidth(curCell) > maxCellWidth) maxCellWidth = curCell.style.width; if (align != curCellInfo.align) columnInfo.align = null; if (vAlign != curCellInfo.vAlign) columnInfo.vAlign = null; if (backgroundColor != curCellInfo.backgroundColor) columnInfo.backgroundColor = null; if (isWidthDefined) { var curCellColSpan = this.GetColSpan(curCell); if (curCellColSpan != colSpan) isWidthDefined = false; else if (columnIndex != this.GetColumnIndexByTableModel(tableModel, i, curCell)) isWidthDefined = false; } } } } if (isWidthDefined && this.ParseSizeString(maxCellWidth).value > 0) columnInfo.width = maxCellWidth; return columnInfo; }, GetRowProperties: function(cell) { var rowInfo = { backgroundColor: null, height: null, align: null, vAlign: null }; var table = _aspxGetParentByTagName(cell, "TABLE"); var row = cell.parentNode; var tableModel = _aspxHETableHelper.CreateTableModel(table); var rowSpan = this.GetRowSpan(cell); var curCellInfo = this.GetCellProperties(cell); var align = rowInfo.align = curCellInfo.align; var vAlign = rowInfo.vAlign = curCellInfo.vAlign; var backgroundColor = rowInfo.backgroundColor = curCellInfo.backgroundColor; var maxCellHeight = 0; var isHeightDefined = true; for (var i = row.rowIndex; i < row.rowIndex + rowSpan; i++) { for (var j = 0; j < tableModel[i].length; j++) { var curCell = tableModel[i][j]; if (this.GetRowSpan(curCell) <= rowSpan) { var curCellInfo = this.GetCellProperties(curCell); if (curCell.style.height && _aspxGetClearClientHeight(curCell) > maxCellHeight) maxCellHeight = curCell.style.height; if (align != curCellInfo.align) rowInfo.align = null; if (vAlign != curCellInfo.vAlign) rowInfo.vAlign = null; if (backgroundColor != curCellInfo.backgroundColor) rowInfo.backgroundColor = null; if (isHeightDefined) { var curCellRowSpan = this.GetRowSpan(curCell); if (curCellRowSpan != rowSpan) isHeightDefined = false; else if (row.rowIndex != curCell.parentNode.rowIndex) isHeightDefined = false; } } } } if (isHeightDefined && this.ParseSizeString(maxCellHeight).value > 0) rowInfo.height = maxCellHeight; return rowInfo; }, SetRowProperties: function(cell, properties) { var table = _aspxGetParentByTagName(cell, "TABLE"); var row = cell.parentNode; var tableModel = _aspxHETableHelper.CreateTableModel(table); var columnIndex = this.GetColumnIndexByTableModel(tableModel, row.rowIndex, cell); var rowSpan = this.GetRowSpan(cell); var rowIndex = row.rowIndex; for (var i = rowIndex; i < rowIndex + rowSpan; i++) { for (var j = 0; j < tableModel[i].length; j++) { if (this.GetRowSpan(tableModel[i][j]) <= rowSpan) { this.SetCellProperties(tableModel[i][j], properties); if (properties.height) tableModel[i][j].style.height = properties.height; else if (_aspxIsExists(tableModel[i][j].style.width)) { tableModel[i][j].style.height = ""; _aspxRemoveStyleAttribute(tableModel[i][j], "height"); } } } } }, SetTableAccessibility: function(table, properties) { if (properties.caption) { var caption = table.createCaption(); caption.innerHTML = properties.caption; } else table.deleteCaption(); if (properties.summary) table.summary = properties.summary; else _aspxRemoveAttribute(table, "summary"); var hasColumnHeaders = this.GetHasColumnHeaders(table); var headers = properties.headers; this.SetRowAndBothHeaders(table, headers); this.SetColumnAndBothHeaders(table, headers, hasColumnHeaders); }, SetColumnAndBothHeaders: function(table, headers, hasColumnHeaders) { if ((headers == 'column' || headers == 'both') && !this.GetHasColumnHeaders(table)) { for (var i = 0; i < table.rows.length; i++) { var newCell = _aspxReplaceTagName(table.rows[i].cells[0], 'TH'); if (newCell != null && !(headers == 'both' && newCell.scope == 'col')) newCell.scope = 'row'; } } if (hasColumnHeaders && headers != 'column' && headers != 'both') { for (var i = 0; i < table.rows.length; i++) { var row = table.rows[i]; if (row.parentNode.nodeName.toUpperCase() == 'TBODY') { var newCell = _aspxReplaceTagName(row.cells[0], 'TD'); if (newCell != null) newCell.removeAttribute('scope'); } } } }, SetRowAndBothHeaders: function(table, headers) { var hasRowHeaders = this.GetHasRowHeaders(table); if (!hasRowHeaders && (headers == 'row' || headers == 'both')) { var firstRow = table.rows[0]; for (var i = 0; i < firstRow.childNodes.length; i++) { if (firstRow.childNodes[i].nodeType == 1) { var th = _aspxReplaceTagName(firstRow.childNodes[i], 'TH'); if (th) th.scope = 'col'; } } var tHead = table.tHead; if (!tHead) tHead = table.createTHead(); if (tHead.childNodes.length == 0) tHead.appendChild(firstRow); for (var i = table.tBodies.length - 1; i >= 0; i--) { if (_aspxTrim(table.tBodies[i].innerHTML) == "") table.removeChild(table.tBodies[i]); } } if (hasRowHeaders && headers != 'row' && headers != 'both') { var firstRow = table.rows[0]; for (var i = 0; i < firstRow.cells.length; i++) { var newCell = _aspxReplaceTagName(firstRow.cells[i], "TD"); if (newCell != null) _aspxRemoveAttribute(newCell, "scope"); } if (table.tHead && table.tHead.childNodes.length > 0) { var firstRow = table.tBodies[0].firstChild; for (var i = table.tHead.childNodes.length - 1; i >= 0; i--) { if (table.tHead.childNodes[i].nodeType == 1) firstRow = table.tBodies[0].insertBefore(table.tHead.childNodes[i], firstRow); } table.removeChild(table.tHead); } } }, GetAccessibilityHeadersValue: function(table) { var hasColumnHeaders = this.GetHasColumnHeaders(table); var hasRowHeaders = this.GetHasRowHeaders(table); var ret = null; if (hasColumnHeaders && hasRowHeaders) ret = "both"; else if (hasColumnHeaders) ret = "column"; else if (hasRowHeaders) ret = "row"; return ret; }, GetAccessibilityCaption: function(table) { var caption = _aspxGetChildByTagName(table, "CAPTION", 0); if (caption) return caption.innerHTML; return ""; }, GetHasColumnHeaders: function(table) { for (var i = 0; i < table.rows.length; i++) { if (table.rows[i].cells[0].nodeName.toUpperCase() != 'TH') return false; } return true; }, GetHasRowHeaders: function(table) { if (table.rows.length == 0) return false; for (var i = 0; i < table.rows[0].cells.length; i++) { if (table.rows[0].cells[i].nodeName.toUpperCase() != 'TH') return false; } return true; }, IsTableColumnEqual: function(table) { if (table.rows.length < 0) return false; var cellWidth = table.rows[0].cells[0].style.width; if (!cellWidth) return false; for (var i = 0; i < table.rows.length; i++) { var curRow = table.rows[i]; for (var j = 0; j < curRow.cells.length; j++) if (cellWidth && cellWidth != this.GetCell(table, i, j).style.width) return false; } return true; }, AdjustColumnWidth: function(table) { var cellWidth = 100 / table.rows[0].cells.length + "%"; for (var i = 0; i < table.rows.length; i++) { var curRow = table.rows[i]; for (var j = 0; j < curRow.cells.length; j++) { _aspxRemoveAttribute(this.GetCell(table, i, j), "width"); this.GetCell(table, i, j).style.width = cellWidth; } } }, InsertColumn: function(cell, shift, htmlEditor) { if (cell.nodeName.toUpperCase() != "TD" && cell.nodeName.toUpperCase() != "TH") return ""; var table = this.GetTable(cell); var tableModel = this.CreateTableModel(table); var row = cell.parentNode; var columnIndex = this.GetColumnIndexByTableModel(tableModel, row.rowIndex, cell); var colSpan = this.GetColSpan(cell); var nextColumnIndex = -1; if (shift > 0) nextColumnIndex = columnIndex + colSpan; else nextColumnIndex = columnIndex; var isTableColumnEqual = this.IsTableColumnEqual(table); var doc = _aspxGetElementDocument(cell); for (var r = 0; r < tableModel.length; r++) { var curCell = shift > 0 ? tableModel[r][nextColumnIndex - 1] : tableModel[r][nextColumnIndex]; if(!curCell) continue; var curCellColumnIndex = this.GetColumnIndexByTableModel(tableModel, r, curCell); var curCellColSpan = this.GetColSpan(curCell); if ((shift > 0 && curCellColumnIndex + curCellColSpan == columnIndex + colSpan) || (shift == 0 && curCellColumnIndex == columnIndex)) { var curCellRowSpan = this.GetRowSpan(curCell); var newCell = this.CreateNewCellByCell(tableModel[r][columnIndex], true); for (var j = r; j < r + curCellRowSpan; j++) _aspxArrayInsert(tableModel[j], newCell, nextColumnIndex); r = j - 1; } else _aspxArrayInsert(tableModel[r], curCell, nextColumnIndex); } var rowIndex = row.rowIndex; this.GenerateTableFromModel(tableModel, table); if (isTableColumnEqual) this.AdjustColumnWidth(table); if (htmlEditor) this.SelectCellCore(tableModel[rowIndex][nextColumnIndex], htmlEditor); }, InsertRow: function(cell, shift, htmlEditor) { if (cell.nodeName.toUpperCase() != "TD" && cell.nodeName.toUpperCase() != "TH") return ""; var table = this.GetTable(cell); var tableModel = this.CreateTableModel(table); var row = cell.parentNode; var rowIndex = row.rowIndex; var columnIndex = this.GetColumnIndexByTableModel(tableModel, rowIndex, cell); var rowSpan = this.GetRowSpan(cell); var doc = _aspxGetElementDocument(cell); var newRowIndex = -1; var rowIndexInModel = -1; if (shift > 0) { rowIndexInModel = rowIndex + rowSpan - 1; newRowIndex = rowIndex + rowSpan + shift - 1; } else { newRowIndex = rowIndex; rowIndexInModel = rowIndex; } var newRowModel = [ ]; for (var i = 0; i < tableModel[rowIndexInModel].length; i++) { var curCell = tableModel[rowIndexInModel][i]; var curCellRow = curCell.parentNode; var curCellRowSpan = this.GetRowSpan(curCell); if ((shift > 0 && (curCellRow.rowIndex + curCellRowSpan == rowIndex + rowSpan)) || (shift == 0 && (curCellRow.rowIndex == rowIndex))) { var curCellColSpan = this.GetColSpan(curCell); var newCell = this.CreateNewCellByCell(curCell); for (var j = i; j < i + curCellColSpan; j++) newRowModel[j] = newCell; i = j - 1; } else newRowModel[i] = tableModel[rowIndexInModel][i]; } _aspxArrayInsert(tableModel, newRowModel, newRowIndex); var newRow = null; if (_aspxGetParentByTagName(cell, "THEAD")) newRow = table.tHead.insertRow(newRowIndex); else newRow = table.insertRow(newRowIndex); _aspxCopyAllAttributes(row, newRow); _aspxRemoveAttribute(newRow, "id"); this.GenerateTableFromModel(tableModel, table); if (htmlEditor) this.SelectCellCore(tableModel[newRowIndex][columnIndex], htmlEditor); }, RemoveRow: function(cell, htmlEditor) { var row = _aspxHETableHelper.GetTableRow(cell); if (row) { var table = this.GetTable(cell); var tableModel = this.CreateTableModel(table); var columnIndex = this.GetColumnIndexByTableModel(tableModel, row.rowIndex, cell); var rowIndex = row.rowIndex; var rowSpan = this.GetRowSpan(tableModel[rowIndex][columnIndex]); for (var r = rowSpan + rowIndex - 1; r >= rowIndex; r--) { _aspxArrayRemoveAt(tableModel, r); if (r < table.rows.length) table.deleteRow(r); } if (table.rows.length > 0) { this.GenerateTableFromModel(tableModel, table); if (htmlEditor) { rowIndex = Math.min(rowIndex, table.rows.length - 1); this.SelectCellCore(tableModel[rowIndex][columnIndex], htmlEditor); } } else _aspxRemoveElement(table); return true; } return false; }, RemoveColumn: function(cell, htmlEditor) { var row = _aspxHETableHelper.GetTableRow(cell); if (row) { var table = this.GetTable(cell); var tableModel = this.CreateTableModel(table); var columnIndex = this.GetColumnIndexByTableModel(tableModel, row.rowIndex, cell); var rowIndex = row.rowIndex; var colSpan = this.GetColSpan(tableModel[rowIndex][columnIndex]); for (var r = 0; r < tableModel.length; r++) { for (var c = columnIndex + colSpan - 1; c >= columnIndex; c--) { _aspxArrayRemoveAt(tableModel[r], c); } } if (tableModel[rowIndex].length > 0) { this.GenerateTableFromModel(tableModel, table); if (htmlEditor) { columnIndex = Math.min(columnIndex, tableModel[rowIndex].length - 1); this.SelectCellCore(tableModel[rowIndex][columnIndex], htmlEditor); } } else _aspxRemoveElement(table); return true; } return false; }, SplitCellHorizontal: function(cell, htmlEditor) { if (!cell) return false; var table = _aspxGetParentByTagName(cell, "TABLE"); var row = cell.parentNode; var rowIndex = row.rowIndex; var tableModel = _aspxHETableHelper.CreateTableModel(table); var columnIndex = this.GetColumnIndexByTableModel(tableModel, row.rowIndex, cell); var colSpan = isNaN(cell.colSpan) ? 1 : cell.colSpan; var doc = _aspxGetElementDocument(table); var newCellWidth = ""; var newCell = doc.createElement(cell.nodeName); newCell.style.cssText = cell.style.cssText; this.AddDefaultContentToCell(newCell); if (colSpan > 1) { var newColSpan = Math.ceil(colSpan / 2); var startIdx = columnIndex + newColSpan; var endIdx = columnIndex + colSpan; var rowSpan = isNaN(cell.rowSpan) ? 1 : cell.rowSpan; for (var r = rowIndex; r < rowIndex + rowSpan; r++) { for (var i = startIdx; i < endIdx; i++) tableModel[r][i] = newCell; } } else { var newTableModel = [ ]; var newRowHash = {}; for (var i = 0; i < tableModel.length; i++) { var newRow = tableModel[i].slice(0, columnIndex); if (tableModel[i].length <= columnIndex) { newTableModel.push(newRow); continue; } if (tableModel[i][columnIndex] == cell) { newRow.push(cell); newRow.push(newCell); } else { newRow.push(tableModel[i][columnIndex]); newRow.push(tableModel[i][columnIndex]); } for (var j = columnIndex + 1; j < tableModel[i].length; j++) newRow.push(tableModel[i][j]); newTableModel.push(newRow); } tableModel = newTableModel; } var cellWidthInfo = _aspxHETableHelper.ParseSizeString(tableModel[rowIndex][columnIndex].style.width); if (cellWidthInfo.valueType) { var newCellWidth = cellWidthInfo.value / 2; tableModel[rowIndex][columnIndex].style.width = newCellWidth + cellWidthInfo.valueType; newCell.style.width = newCellWidth + cellWidthInfo.valueType; } this.GenerateTableFromModel(tableModel, table); if (htmlEditor) this.SelectCellCore(tableModel[rowIndex][columnIndex], htmlEditor); }, SplitCellVertical: function(cell, htmlEditor) { if (!cell) return false; var table = _aspxGetParentByTagName(cell, "TABLE"); var row = cell.parentNode; var rowIndex = row.rowIndex; var tableModel = _aspxHETableHelper.CreateTableModel(table); var columnIndex = this.GetColumnIndexByTableModel(tableModel, rowIndex, cell); var rowSpan = this.GetRowSpan(cell); var doc = _aspxGetElementDocument(table); if (rowSpan > 1) { var newRowSpan = Math.ceil(rowSpan / 2); var newCell = doc.createElement(cell.nodeName); newCell.style.cssText = cell.style.cssText; this.AddDefaultContentToCell(newCell); var startRowIndex = rowIndex + newRowSpan; var endRowIndex = rowIndex + rowSpan; var curColumnIndex = columnIndex; while (tableModel[rowIndex][curColumnIndex] == cell) { for (var r = startRowIndex; r < endRowIndex && r < tableModel.length; r++) { if (tableModel[r][curColumnIndex] == cell) tableModel[r][curColumnIndex] = newCell; } curColumnIndex++; } } else { var newRowHash = {}; var newRowIndex = rowIndex + 1; var isThead = !!_aspxGetParentByTagName(cell, "THEAD"); var newRow = null; if (isThead) newRow = table.tHead.insertRow(newRowIndex); else newRow = table.insertRow(newRowIndex); _aspxCopyAllAttributes(row, newRow); _aspxRemoveAttribute(newRow, "id"); _aspxArrayInsert(tableModel, [ ], newRowIndex); for (var i = 0; i < tableModel[rowIndex].length; i++) { if (tableModel[rowIndex][i] == cell) { if (!newRowHash[cell]) { var newCell = doc.createElement(cell.nodeName); newCell.style.cssText = cell.style.cssText; newRowHash[cell] = newCell; this.AddDefaultContentToCell(newRowHash[cell]); } tableModel[newRowIndex][i] = newRowHash[cell]; } else tableModel[newRowIndex][i] = tableModel[rowIndex][i]; } } this.GenerateTableFromModel(tableModel, table); if (htmlEditor) this.SelectCellCore(tableModel[rowIndex][columnIndex], htmlEditor); }, MergeCellHorizontal: function(cell, htmlEditor) { var table = _aspxGetParentByTagName(cell, "TABLE"); var row = cell.parentNode; var rowIndex = row.rowIndex; var tableModel = _aspxHETableHelper.CreateTableModel(table); var columnIndex = this.GetColumnIndexByTableModel(tableModel, rowIndex, cell); var nextCellColumnIndex = this.GetNextCellColumnIndexByTableModel(tableModel, rowIndex, columnIndex); var nextCell = tableModel[rowIndex][nextCellColumnIndex]; var rowSpan = isNaN(cell.rowSpan) ? 1 : cell.rowSpan; var newCell = this.MergeCell(cell, nextCell); var cellWidthInfo = _aspxHETableHelper.ParseSizeString(tableModel[rowIndex][columnIndex].style.width); var mergedCellWidthInfo = _aspxHETableHelper.ParseSizeString(tableModel[rowIndex][nextCellColumnIndex].style.width); if (cellWidthInfo.valueType && cellWidthInfo.valueType == mergedCellWidthInfo.valueType) newCell.style.width = cellWidthInfo.value + mergedCellWidthInfo.value + cellWidthInfo.valueType; for (var i = rowIndex; i < rowIndex + rowSpan; i++) { var curColumnIndex = columnIndex; while (tableModel[i] && (tableModel[i][curColumnIndex] == cell || tableModel[i][curColumnIndex] == nextCell)) { tableModel[i][curColumnIndex] = newCell; curColumnIndex++; } } this.GenerateTableFromModel(tableModel, table); if (htmlEditor) this.SelectCellCore(tableModel[rowIndex][columnIndex], htmlEditor); }, MergeCellVertical: function(cell, htmlEditor) { var table = _aspxGetParentByTagName(cell, "TABLE"); var row = cell.parentNode; var rowIndex = row.rowIndex; var tableModel = _aspxHETableHelper.CreateTableModel(table); var columnIndex = this.GetColumnIndexByTableModel(tableModel, rowIndex, cell); var nextCellRowIndex = this.GetNextCellRowIndexByTableModel(tableModel, rowIndex, columnIndex); var colSpan = this.GetColSpan(cell); var nextCell = tableModel[nextCellRowIndex][columnIndex]; var newCell = this.MergeCell(cell, nextCell); for (var i = columnIndex; i < columnIndex + colSpan; i++) { var curRowIndex = rowIndex; while (tableModel[curRowIndex] && (tableModel[curRowIndex][i] == cell || tableModel[curRowIndex][i] == nextCell)) { tableModel[curRowIndex][i] = newCell; curRowIndex++; } } this.GenerateTableFromModel(tableModel, table); if (htmlEditor) this.SelectCellCore(tableModel[rowIndex][columnIndex], htmlEditor); }, IsMergeCellHorizontalAllow: function(cell, htmlEditor) { var isAllow = false; var tableModel = _aspxHETableHelper.CreateTableModel(_aspxGetParentByTagName(cell, "TABLE")); var row = cell.parentNode; var colIndx = this.GetColumnIndexByTableModel(tableModel, row.rowIndex, cell); var nextCellColIndx = colIndx + this.GetColSpan(cell); var nextCell = tableModel[row.rowIndex][nextCellColIndx]; if (nextCell) { if (this.GetRowSpan(cell) == this.GetRowSpan(nextCell)) { var realNextCellRow = nextCell.parentNode; isAllow = realNextCellRow.rowIndex == row.rowIndex; } } return isAllow; }, IsMergeCellVerticalAllow: function(cell, htmlEditor) { var isAllow = false; var table = _aspxGetParentByTagName(cell, "TABLE"); var nextCell = this.GetNextCellVertical(cell); if (nextCell) { var colSpan = isNaN(cell.colSpan) ? 1 : cell.colSpan; var nextCellColSpan = isNaN(nextCell.colSpan) ? 1 : nextCell.colSpan; isAllow = colSpan == nextCellColSpan; } return isAllow; }, MergeCell: function(firstCell, secondCell) { var doc = _aspxGetElementDocument(firstCell); var newCell = doc.createElement(firstCell.nodeName); newCell.innerHTML = firstCell.innerHTML; var emptyHtmlRegExp = new RegExp(__aspxHEEmptyHtmlRegExpPattern, "ig"); if (!emptyHtmlRegExp.test(secondCell.innerHTML)) newCell.innerHTML += "
" + secondCell.innerHTML; _aspxCopyAllAttributes(firstCell, newCell); return newCell; }, CreateTableModel: function(table) { var rows = table.rows; var rowCount = 0; var model = [ ]; for (var i = 0; i < rows.length; i++) { if (!model[rowCount]) model[rowCount] = [ ]; var colCount = 0; for (var j = 0, cl = rows[i].cells.length; j < cl; j++) { var curCell = rows[i].cells[j]; while (model[rowCount][colCount]) colCount++; var colSpan = this.GetColSpan(curCell); var rowSpan = this.GetRowSpan(curCell); for (var rs = 0; rs < rowSpan; rs++) { var rowInd = rowCount + rs; if (rowInd >= rows.length) break; if (!model[rowInd]) model[rowInd] = [ ]; for (var cs = 0; cs < colSpan; cs++) model[rowInd][colCount + cs] = curCell; } colCount += colSpan - 1; } rowCount++; } return model; }, GenerateTableFromModel: function(model, sourceTable) { var rowSpanAttr = __aspxIE ? "_dxrowspan" : "rowSpan"; for (var i = 0; i < model.length; i++) { for (var j = 0; j < model[i].length; j++) { if (model[i][j].parentNode) model[i][j].parentNode.removeChild(model[i][j]); model[i][j].colSpan = model[i][j][rowSpanAttr] = 1; model[i][j].rowSpan = 1; model[i][j].rowIsNotSpanned = false; model[i][j].colIsNotSpanned = false; } } var maxColumnCount = 0; for (var i = 0; i < model.length; i++) { for (var j = 0; j < model[i].length; j++) { if (model[i][j]) { var cell = model[i][j]; if (j > maxColumnCount) maxColumnCount = j; if (!cell.colIsNotSpanned) { if (model[i][j - 1] == cell) cell.colSpan++; if (model[i][j + 1] != cell) cell.colIsNotSpanned = true; } } } } var sourceRows = new Array(); for (var i = 0; i <= maxColumnCount; i++) { for (var j = 0; j < model.length; j++) { if (model[j] && model[j][i] && !model[j][i].rowIsNotSpanned) { var cell = model[j][i]; if (model[j - 1] && model[j - 1][i] == cell) cell[rowSpanAttr]++; if (!model[j + 1] || model[j + 1][i] != cell) cell.rowIsNotSpanned = true; } } } var doc = _aspxGetElementDocument(sourceTable); for (var i = 0; i < model.length; i++) { var rowObj = doc.createElement(sourceTable.rows[i].tagName); _aspxCopyAllAttributes(sourceTable.rows[i], rowObj); for (var j = 0; j < model[i].length; ) { var cell = model[i][j]; _aspxRemoveAttribute(cell, "rowIsNotSpanned"); _aspxRemoveAttribute(cell, "colIsNotSpanned"); if (model[i - 1] && model[i - 1][j] == cell) { j += cell.colSpan; continue; } rowObj.appendChild(cell); var isEmptyRowSpan = cell.rowSpan == 1; if (rowSpanAttr != 'rowSpan' && _aspxIsExists(cell[rowSpanAttr])) { if (cell[rowSpanAttr] > 1) isEmptyRowSpan = false; cell.rowSpan = cell[rowSpanAttr]; cell.removeAttribute(rowSpanAttr); } if (cell.colSpan == 1) cell.removeAttribute('colspan'); if (isEmptyRowSpan) cell.removeAttribute('rowspan'); j += cell.colSpan; } sourceTable.rows[i].parentNode.replaceChild(rowObj, sourceTable.rows[i]); } }, AddDefaultContentToCell: function(cell) { cell.innerHTML = " "; }, CreateNewCellByCell: function(cell, resetWidth) { var newCell = _aspxGetElementDocument(cell).createElement(cell.nodeName); if (cell.style.cssText !== '') { newCell.style.cssText = cell.style.cssText; if (resetWidth && _aspxHETableHelper.ParseSizeString(newCell.style.width).valueType == "%") newCell.style.width = ""; } this.AddDefaultContentToCell(newCell); return newCell; }, ParseSizeString: function(sizeString) { var ret = { value: null, valueType: null }; var res = __aspxHESizeTypeRegExp.exec(sizeString); if (res && res.length > 2) { ret.value = parseFloat(res[1]); ret.valueType = res[2]; } return ret; }, SetBackgroundColor: function(element, color) { if (color) element.style.backgroundColor = color; else { element.style.backgroundColor = ""; _aspxRemoveStyleAttribute(element.style, "backgroundColor"); } }, SetTableBorderColor: function(table, color) { table.setAttribute(__aspxIE ? "borderColor" : "bordercolor", color); }, GetTableBorderColor: function(table, color) { return _aspxGetAttribute(table, __aspxIE ? "borderColor" : "bordercolor"); }, GetRowIndex: function(cell) { var row = cell.parentNode; return row.rowIndex; }, GetCell: function(table, rowIndex, colIndex) { return table.rows[rowIndex].cells[colIndex]; }, GetNextCellVertical: function(cell) { var nextCell = null; var row = cell.parentNode; var table = _aspxGetParentByTagName(cell, "TABLE"); var rowSpan = this.GetRowSpan(cell); if (table.rows.length > row.rowIndex + rowSpan) { var nextRow = table.rows[row.rowIndex + rowSpan]; var prevSumSpan = 0; for(var i = 0, prevInd = cell.cellIndex; i <= prevInd; i++) prevSumSpan += this.GetColSpan(row.cells[i]); var nextSumSpan = 0; for(var i = 0, rowLen = nextRow.cells.length; i < rowLen; i++) { var nextSpan = this.GetColSpan(nextRow.cells[i]); nextSumSpan += nextSpan; if((this.GetColSpan(cell) == nextSpan) && (nextSumSpan == prevSumSpan)) { nextCell = nextRow.cells[i]; break; } } } return nextCell; }, GetColumnIndexByTableModel: function(model, rowIndex, cell) { if (model.length < rowIndex + 1) return -1; var row = model[rowIndex]; for (var i = 0; i < row.length; i++) { if (row[i] == cell) return i; } return -1; }, GetNextCellColumnIndexByTableModel: function(model, rowIndex, columnIndex) { if (model.length < rowIndex + 1) return -1; var cell = model[rowIndex][columnIndex]; for (var i = columnIndex; i < model[rowIndex].length; i++) { if (model[rowIndex][i] != cell) return i; } return -1; }, GetNextCellRowIndexByTableModel: function(model, rowIndex, columnIndex) { if (model.length < rowIndex + 1) return -1; var cell = model[rowIndex][columnIndex]; for (var i = rowIndex; i < model.length; i++) { if (model[i][columnIndex] != cell) return i; } return -1; }, GetNextRow: function(row) { var table = _aspxGetParentByTagName(row, "TABLE"); var i = 0; for (i = 0; i < table.rows.length; i++) if (table.rows[i] == row) break; return i + 1 < table.rows.length ? table.rows[i + 1] : null; }, GetColSpan: function(cell) { return isNaN(cell.colSpan) ? 1 : cell.colSpan; }, GetRowSpan: function(cell) { return isNaN(cell.rowSpan) ? 1 : cell.rowSpan; }, SelectCell: function(table, rowIndex, colIndex, htmlEditor) { var cell = this.GetCell(table, rowIndex, colIndex); if (cell) this.SelectCellCore(cell, htmlEditor); }, SelectCellCore: function(cell, htmlEditor) { var elem = cell; if (cell.childNodes.length > 0 && !__aspxIE) elem = cell.childNodes[0]; if (!__aspxIE) htmlEditor.SetFocus(); ASPxClientHtmlEditorSelection.SelectElement(elem, htmlEditor, __aspxOpera); }, DeleteRows: function(table) { for (var i = 0; i < table.rows.length; i++) { var rIndex = table.rows[i].sectionRowIndex; table.deleteRow(rIndex); } } }; ASPxHtmlEditorCommands.Tables = {}; ASPxHtmlEditorCommands.Tables.Table = { IsSelected: function(htmlEditor) { var curSelection = ASPxClientHtmlEditorSelection.Create(htmlEditor); return !!_aspxHETableHelper.GetTable(curSelection.GetParentElement()); }, SetRowAndColumnCount: function(table, rowCount, columnCount, isColumnEqualWidth) { _aspxHETableHelper.DeleteRows(table); var cellWidth = 100 / columnCount + "%"; for (var i = 0; i < rowCount; i++) { var newRow = table.insertRow(i); for (var j = 0; j < columnCount; j++) { var cell = newRow.insertCell(j); if (isColumnEqualWidth) cell.style.width = cellWidth; } } }, Insert: _aspxCreateClass(ASPxHtmlEditorCommands.Command, { Execute: function(cmdValue, htmlEditor) { ASPxHtmlEditorCommands.Command.prototype.Execute.apply(this, arguments); var doc = htmlEditor.GetDesignViewDocument(); var tableId = ASPxClientSelection.CreateUniqueID(); var emptyTableHtml = "
"; ASPxHtmlEditorCommandList[ASPxClientCommandConsts.PASTEHTML_COMMAND].Execute(emptyTableHtml, htmlEditor); var emptyTable = _aspxGetElementByIdInDocument(doc, tableId); emptyTable.id = ""; _aspxRemoveAttribute(emptyTable, "id"); ASPxHtmlEditorCommands.Tables.Table.SetRowAndColumnCount(emptyTable, cmdValue.rows, cmdValue.columns, cmdValue.isColumnEqualWidth); this.InitializeTable(emptyTable); _aspxHETableHelper.SetTableProperties(emptyTable, cmdValue.tableProperties, htmlEditor); _aspxHETableHelper.SelectCell(emptyTable, 0, 0, htmlEditor); return true; }, InitializeTable: function(table) { table.style.borderCollapse = "collapse"; for (var i = 0; i < table.rows.length; i++) { var row = table.rows[i]; for (var j = 0; j < row.cells.length; j++) _aspxHETableHelper.AddDefaultContentToCell(row.cells[j]); } } }), Change: _aspxCreateClass(ASPxHtmlEditorCommands.Command, { Execute: function(cmdValue, htmlEditor) { ASPxHtmlEditorCommands.Command.prototype.Execute.apply(this, arguments); _aspxHETableHelper.SetTableProperties(cmdValue.tableElement, cmdValue.tableProperties, htmlEditor); _aspxHETableHelper.SelectCell(cmdValue.tableElement, 0, 0, htmlEditor); return true; } }), Delete: _aspxCreateClass(ASPxHtmlEditorCommands.Command, { Execute: function(cmdValue, htmlEditor) { ASPxHtmlEditorCommands.Command.prototype.Execute.apply(this, arguments); var curSelection = ASPxClientHtmlEditorSelection.Create(htmlEditor); var table = _aspxHETableHelper.GetTable(curSelection.GetParentElement()); if (table) { ASPxClientHtmlEditorSelection.SelectElement(table, htmlEditor); ASPxHtmlEditorCommandList[ASPxClientCommandConsts.DELETE_COMMAND].Execute(null, htmlEditor); if (__aspxOpera) _aspxRemoveElement(table); htmlEditor.SetFocus(); return true; } return false; }, IsLocked: function(editor) { return !ASPxHtmlEditorCommands.Tables.Table.IsSelected(editor); } }) }; ASPxHtmlEditorCommands.Tables.InsertColumnAndRowBase = _aspxCreateClass(ASPxHtmlEditorCommands.Command, { IsLocked: function(editor) { return !ASPxHtmlEditorCommands.Tables.Cell.Get(editor); } }); ASPxHtmlEditorCommands.Tables.DeleteColumnAndRowBase = _aspxCreateClass(ASPxHtmlEditorCommands.Command, { IsLocked: function(editor) { if (editor.NeedGetElementFromSelection("tableRow")) { var curSelection = ASPxClientHtmlEditorSelection.Create(editor); editor.SetSelectedElement("tableRow", _aspxHETableHelper.GetTableRow(curSelection.GetParentElement())); } return !editor.GetSelectedElement("tableRow"); } }); ASPxHtmlEditorCommands.Tables.Row = { Insert: _aspxCreateClass(ASPxHtmlEditorCommands.Tables.InsertColumnAndRowBase, { Execute: function(cmdValue, htmlEditor) { ASPxHtmlEditorCommands.Tables.InsertColumnAndRowBase.prototype.Execute.apply(this, arguments); var cell = ASPxHtmlEditorCommands.Tables.Cell.Get(htmlEditor); if (cell) { _aspxHETableHelper.InsertRow(cell, this.GetShift(), htmlEditor); htmlEditor.SetFocus(); return true; } return false; }, GetShift: function() { var ret = 0; if (this.commandID == ASPxClientCommandConsts.INSERTTABLEROWBELOW_COMMAND) ret = 1; return ret; } }), Change: _aspxCreateClass(ASPxHtmlEditorCommands.Command, { Execute: function(cmdValue, htmlEditor) { ASPxHtmlEditorCommands.Command.prototype.Execute.apply(this, arguments); _aspxHETableHelper.SetRowProperties(cmdValue.cell, cmdValue.properties); return true; } }), Delete: _aspxCreateClass(ASPxHtmlEditorCommands.Tables.DeleteColumnAndRowBase, { Execute: function(cmdValue, htmlEditor) { ASPxHtmlEditorCommands.Tables.DeleteColumnAndRowBase.prototype.Execute.apply(this, arguments); var cell = ASPxHtmlEditorCommands.Tables.Cell.Get(htmlEditor); return _aspxHETableHelper.RemoveRow(cell, htmlEditor); } }) }; ASPxHtmlEditorCommands.Tables.Column = { Insert: _aspxCreateClass(ASPxHtmlEditorCommands.Tables.InsertColumnAndRowBase, { Execute: function(cmdValue, htmlEditor) { ASPxHtmlEditorCommands.Tables.InsertColumnAndRowBase.prototype.Execute.apply(this, arguments); var cell = ASPxHtmlEditorCommands.Tables.Cell.Get(htmlEditor); if (cell) { _aspxHETableHelper.InsertColumn(cell, this.GetShift(htmlEditor.rtl), htmlEditor); htmlEditor.SetFocus(); return true; } return false; }, GetShift: function(rtl) { if(rtl) return this.commandID == ASPxClientCommandConsts.INSERTTABLECOLUMNTORIGHT_COMMAND ? 0 : 1; else return this.commandID == ASPxClientCommandConsts.INSERTTABLECOLUMNTORIGHT_COMMAND ? 1 : 0; } }), Change: _aspxCreateClass(ASPxHtmlEditorCommands.Command, { Execute: function(cmdValue, htmlEditor) { ASPxHtmlEditorCommands.Command.prototype.Execute.apply(this, arguments); _aspxHETableHelper.SetColumnProperties(cmdValue.cell, cmdValue.properties); return true; } }), Delete: _aspxCreateClass(ASPxHtmlEditorCommands.Tables.DeleteColumnAndRowBase, { Execute: function(cmdValue, htmlEditor) { ASPxHtmlEditorCommands.Tables.DeleteColumnAndRowBase.prototype.Execute.apply(this, arguments); var curSelection = ASPxClientHtmlEditorSelection.Create(htmlEditor); var selElem = curSelection.GetParentElement(); var table = _aspxHETableHelper.GetTable(selElem); var row = _aspxHETableHelper.GetTableRow(selElem); var cell = ASPxHtmlEditorCommands.Tables.Cell.Get(htmlEditor); return _aspxHETableHelper.RemoveColumn(cell, htmlEditor); } }) }; ASPxHtmlEditorCommands.Tables.Cell = { Get: function(htmlEditor) { if (htmlEditor.NeedGetElementFromSelection("tableCell")) { var curSelection = ASPxClientHtmlEditorSelection.Create(htmlEditor); var parentElem = curSelection.GetParentElement(); var endElem = null; if (!__aspxIE) endElem = curSelection.GetEndContainer(); htmlEditor.SetSelectedElement("tableCell", _aspxHETableHelper.GetTableCellBySelection(parentElem, endElem)); } return htmlEditor.GetSelectedElement("tableCell"); }, IsSelected: function(editor) { return !!ASPxHtmlEditorCommands.Tables.Cell.Get(editor); }, Change: _aspxCreateClass(ASPxHtmlEditorCommands.Command, { Execute: function(cmdValue, htmlEditor) { ASPxHtmlEditorCommands.Command.prototype.Execute.apply(this, arguments); if (cmdValue.properties.applyForAll) _aspxHETableHelper.SetCellPropertiesForAllCell(_aspxGetParentByTagName(cmdValue.cellElement, "TABLE"), cmdValue.properties); else _aspxHETableHelper.SetCellProperties(cmdValue.cellElement, cmdValue.properties); return true; } }), SplitHorizontally: _aspxCreateClass(ASPxHtmlEditorCommands.Tables.InsertColumnAndRowBase, { Execute: function(cmdValue, htmlEditor) { ASPxHtmlEditorCommands.Tables.InsertColumnAndRowBase.prototype.Execute.apply(this, arguments); _aspxHETableHelper.SplitCellHorizontal(ASPxHtmlEditorCommands.Tables.Cell.Get(htmlEditor), htmlEditor); return true; } }), SplitVertically: _aspxCreateClass(ASPxHtmlEditorCommands.Tables.InsertColumnAndRowBase, { Execute: function(cmdValue, htmlEditor) { ASPxHtmlEditorCommands.Tables.InsertColumnAndRowBase.prototype.Execute.apply(this, arguments); _aspxHETableHelper.SplitCellVertical(ASPxHtmlEditorCommands.Tables.Cell.Get(htmlEditor), htmlEditor); return true; } }), MergeRight: _aspxCreateClass(ASPxHtmlEditorCommands.Tables.InsertColumnAndRowBase, { Execute: function(cmdValue, htmlEditor) { ASPxHtmlEditorCommands.Tables.InsertColumnAndRowBase.prototype.Execute.apply(this, arguments); _aspxHETableHelper.MergeCellHorizontal(ASPxHtmlEditorCommands.Tables.Cell.Get(htmlEditor), htmlEditor); return true; }, IsLocked: function(editor) { var cell = ASPxHtmlEditorCommands.Tables.Cell.Get(editor); if (cell) return !_aspxHETableHelper.IsMergeCellHorizontalAllow(cell, editor); return true; } }), MergeDown: _aspxCreateClass(ASPxHtmlEditorCommands.Tables.InsertColumnAndRowBase, { Execute: function(cmdValue, htmlEditor) { ASPxHtmlEditorCommands.Tables.InsertColumnAndRowBase.prototype.Execute.apply(this, arguments); _aspxHETableHelper.MergeCellVertical(ASPxHtmlEditorCommands.Tables.Cell.Get(htmlEditor), htmlEditor); return true; }, IsLocked: function(editor) { var cell = ASPxHtmlEditorCommands.Tables.Cell.Get(editor); if (cell) return !_aspxHETableHelper.IsMergeCellVerticalAllow(cell, editor); return true; } }) }; ASPxHtmlEditorCommands.Browser.FormatBlock = _aspxCreateClass(ASPxHtmlEditorCommands.Browser.Command, { GetCorrectedValue: function(value) { return __aspxIE ? "<" + value + ">" : value; }, GetValue: function(editor) { value = (__aspxIE) ? this.GetValueIE(editor) : this.GetValueMoz(editor); return (value == "font") ? "span" : value; }, GetValueIE : function(editor) { var contentAreaDoc = editor.GetDesignViewDocument(); var curSelection = contentAreaDoc.selection; if (!curSelection) return ""; var selRange = curSelection.createRange(); var parentElement = (selRange.length > 0 ? selRange(0) : selRange.parentElement()); return this.GetValueByElement(parentElement); }, GetValueMoz: function(editor) { var contentWindow = editor.GetDesignViewIFrameWindow(); var curSelection = contentWindow.getSelection(); if (!curSelection || curSelection.rangeCount != 1) return ""; var startNode = (curSelection.anchorNode.nodeType != 3 ? curSelection.anchorNode : curSelection.anchorNode.parentNode); var endNode = (curSelection.focusNode.nodeType != 3 ? curSelection.focusNode : curSelection.focusNode.parentNode); if (startNode != endNode) return ""; var restoreSelection = ASPxClientHtmlEditorSelection.Create(editor); return this.GetValueByElement(restoreSelection.GetParentElement()); }, GetValueByElement: function(element) { return (element) && (element.nodeType == 1) ? element.tagName.toLowerCase() : ""; } }); ASPxHtmlEditorCommands.Browser.RemoveFormat = _aspxCreateClass(ASPxHtmlEditorCommands.Browser.Command, { Execute: function(cmdValue, editor) { ASPxHtmlEditorCommands.Browser.Command.prototype.Execute.call(this, cmdValue, editor); var sel = editor.GetSelection(); if(!sel.clientSelection.IsTextOnly() && !sel.clientSelection.IsControl() && sel.GetSelectedElement()) { var elements = sel.GetElements(); for(var i = 0, el; el = elements[i]; i++) { if(el.nodeType == 1) this.CleanElement(el); } } return true; }, CleanElement: function(element) { for (var i = 0; i < element.childNodes.length ; i++) this.CleanElement(element.childNodes[i]); if (element.nodeType == 1 && element.tagName.toUpperCase() != "BODY") { _aspxRemoveAllAttributes(element, ["href", "src", "alt", "target", "id", "title", "value"]); _aspxRemoveAllStyles(element); } } }); ASPxHtmlEditorCommands.PasteFromWord = _aspxCreateClass(ASPxHtmlEditorCommands.Command, { Execute: function(cmdValue, htmlEditor) { if(!__aspxTouchUI) { ASPxHtmlEditorCommands.Command.prototype.Execute.apply(this, arguments); return ASPxHtmlEditorCommandList[ASPxClientCommandConsts.PASTEHTML_COMMAND].Execute( ASPxHtmlEditorCommands.PasteFromWord.ClearWordFormatting(cmdValue.html, cmdValue.stripFontFamily), htmlEditor); } else alert(ASPxHtmlEditorCommands.Browser.Clipboard.NotAllowedMessage[ASPxClientCommandConsts.PASTE_COMMAND]); } }); ASPxHtmlEditorCommands.PasteFromWord.ClearWordFormatting = function(html, stripFontFamily) { html = ASPxHtmlEditorCommands.PasteFromWord.ClearWordAttributes(html); html = html.replace(/<\/?\w+:[^>]*>/gi, ''); html = html.replace(/]*>[\s\S]*?<\/STYLE[^>]*>/gi, ''); html = html.replace(/<(?:META|LINK)[^>]*>\s*/gi, ''); html = html.replace(/<\\?\?xml[^>]*>/gi, ''); html = html.replace(/]*>\s*<\/o:[pP]>/gi, ''); html = html.replace(/]*>.*?<\/o:[pP]>/gi, ' '); html = html.replace(//gi, ''); html = html.replace(/<\!--[\s\S]*?-->/g, ''); html = html.replace(/<(\w[^>]*) class=([^ |>]*)([^>]*)/gi, "<$1$3") ; html = html.replace(/\s*style="\s*"/gi, ''); html = html.replace(/style=""/ig, ""); html = html.replace(/style=''/ig, ""); var stRegExp = new RegExp('(?:style=\\")([^\\"]*)(?:\\")', 'gi'); html = html.replace(stRegExp, function(str) { str = str.replace(/"/gi, "'") str = str.replace(/ /gi, " ") return str; }); html = html.replace(/^\s/i, ''); html = html.replace(/\s$/i, ''); html = html.replace(/

 <\/p>/gi, '

'); html = html.replace(/([^<>]+)<\/font>/gi, '$1'); html = html.replace(/([^<>]+)<\/span><\/span>/ig, '$1'); html = html.replace(/([^<>]+)<\/span>/gi, '$1'); if (stripFontFamily) { html = html.replace(/\s*face="[^"]*"/gi, ''); html = html.replace(/\s*face=[^ >]*/gi, ''); html = html.replace(/\s*FONT-FAMILY:[^;"]*;?/gi, ''); } var replacePwithDIV = new RegExp('(]*>[\\s\\S]*?)(<\/P>)', 'gi'); html = html.replace(replacePwithDIV, ''); html = html.replace( /]*)>\s*<\/td>/gi, ' ' ); html = html.replace( /<([^\s>]+)(\s[^>]*)?>\s*<\/\1>/g, '' ); html = html.replace( /<([^\s>]+)(\s[^>]*)?>\s*<\/\1>/g, '' ); html = html.replace( /<([^\s>]+)(\s[^>]*)?>\s*<\/\1>/g, '' ); return html; }; ASPxHtmlEditorCommands.PasteFromWord.ClearWordAttributes = function(html) { html = html.replace(/<(\w[^>]*) lang=([^ |>]*)([^>]*)/gi, "<$1$3"); html = html.replace(/\s*mso-bidi-font-family/gi, "font-family"); html = html.replace(/\s*mso-[^:]+:[^;"]+;?/gi, ''); html = html.replace(/\s*MARGIN: 0cm 0cm 0pt\s*;/gi, ''); html = html.replace(/\s*MARGIN: 0cm 0cm 0pt\s*"/gi, "\""); html = html.replace(/\s*TEXT-INDENT: 0cm\s*;/gi, ''); html = html.replace(/\s*TEXT-INDENT: 0cm\s*"/gi, "\""); html = html.replace(/\s*PAGE-BREAK-BEFORE: [^\s;]+;?"/gi, "\""); html = html.replace(/\s*FONT-VARIANT: [^\s;]+;?"/gi, "\"") ; html = html.replace(/\s*tab-stops:[^;"]*;?/gi, '') ; html = html.replace(/\s*tab-stops:[^"]*/gi, '') ; return html; }; ASPxHtmlEditorCommands.PasteHtml = _aspxCreateClass(ASPxHtmlEditorCommands.Command, { Execute: function(htmlText, htmlEditor) { ASPxHtmlEditorCommands.Command.prototype.Execute.apply(this, arguments); if(__aspxIE) { htmlText = htmlText.replace(/(\r\n|\n|\r)/gm, " "); htmlText = htmlText.replace(/>[\s]*<"); } htmlEditor.GetSelection().SetHtmlInternal(htmlText); return true; } }); ASPxHtmlEditorCommands.Browser.Clipboard = _aspxCreateClass(ASPxHtmlEditorCommands.Browser.Command, { Execute: function(cmdValue, editor) { if(__aspxIE && __aspxBrowserMajorVersion < 8 && !editor.isInFocus) editor.SetFocus(); var result = false; if(ASPxHtmlEditorCommands.Browser.Clipboard.IsAllowed[this.commandID]) result = this.ExecuteInternal(editor); else alert(ASPxHtmlEditorCommands.Browser.Clipboard.NotAllowedMessage[this.commandID]); if(__aspxIE && __aspxBrowserMajorVersion > 8) editor.SaveSelection(); editor.SetFocus(); return result; }, ExecuteInternal: function(editor) { var isEnabled = true; if(__aspxIE) { try { editor.GetDesignViewDocument().queryCommandEnabled(this.commandID); } catch (e) { isEnabled = false; } } if(isEnabled) return editor.GetDesignViewDocument().execCommand(this.commandID, false, null); return false; }, TryGetIsLocked: function(editor) { if(__aspxSafari) return false; if(__aspxChrome && this.commandID == ASPxClientCommandConsts.PASTE_COMMAND) return false; return ASPxHtmlEditorCommands.Browser.Command.prototype.TryGetIsLocked.call(this, editor); }, IsHtmlChangeable: function() { return this.GetCommandID() != ASPxClientCommandConsts.COPY_COMMAND; } }); ASPxHtmlEditorCommands.Browser.Clipboard.NotAllowedMessage = {}; ASPxHtmlEditorCommands.Browser.Clipboard.NotAllowedMessage[ASPxClientCommandConsts.CUT_COMMAND] = "This command cannot be executed. Please use Ctrl+X to Cut to the clipboard."; ASPxHtmlEditorCommands.Browser.Clipboard.NotAllowedMessage[ASPxClientCommandConsts.PASTE_COMMAND] = "This command cannot be executed. Please use Ctrl+V to Paste from the clipboard."; ASPxHtmlEditorCommands.Browser.Clipboard.NotAllowedMessage[ASPxClientCommandConsts.COPY_COMMAND] = "This command cannot be executed. Please use Ctrl+C to Copy to the clipboard."; ASPxHtmlEditorCommands.Browser.Clipboard.IsAllowed = {}; ASPxHtmlEditorCommands.Browser.Clipboard.IsAllowed[ASPxClientCommandConsts.CUT_COMMAND] = __aspxIE || __aspxChrome; ASPxHtmlEditorCommands.Browser.Clipboard.IsAllowed[ASPxClientCommandConsts.PASTE_COMMAND] = __aspxIE; ASPxHtmlEditorCommands.Browser.Clipboard.IsAllowed[ASPxClientCommandConsts.COPY_COMMAND] = __aspxIE || __aspxChrome; ASPxHtmlEditorCommands.Browser.SelectAll = _aspxCreateClass(ASPxHtmlEditorCommands.Browser.Command, { IsHtmlChangeable: function() { return false; } }); ASPxHtmlEditorCommands.TextType = _aspxCreateClass(ASPxHtmlEditorCommands.Command, { IsDefaultAction: function(editor) { return true; }, IsImmediateExecution: function() { return true; } }); ASPxHtmlEditorCommands.KbCopy = _aspxCreateClass(ASPxHtmlEditorCommands.TextType, { IsHtmlChangeable: function() { return false; } }); ASPxHtmlEditorCommands.KbCut = _aspxCreateClass(ASPxHtmlEditorCommands.TextType, { }); ASPxHtmlEditorCommands.KbPaste = _aspxCreateClass(ASPxHtmlEditorCommands.TextType, { }); ASPxHtmlEditorCommands.LineBreakType = _aspxCreateClass(ASPxHtmlEditorCommands.TextType, { }); ASPxHtmlEditorCommands.NewParagraphType = _aspxCreateClass(ASPxHtmlEditorCommands.Command, { Execute: function(cmdValue, editor) { return editor.GetDesignViewDocument().execCommand("InsertParagraph", false, null); } }); var __aspxHEBlockElements = { div:1, address:1, blockquote:1, center:1, table:1, h1:1, h2:1, h3:1, h4:1, h5:1, h6:1, p:1, pre:1, ol:1, ul:1, dl:1 }; var __aspxHEPathBlockElements = { address:1, blockquote:1, dl:1, h1:1, h2:1, h3:1, h4:1, h5:1, h6:1, p:1, pre:1, li:1, dt:1, de:1 }; var __aspxHEPathBlockLimitElements = { html:1, body: 1, form: 1, div:1, table:1, tbody:1, tr:1, td:1, th:1, li:1, caption:1 }; var __aspxHEBogusSymbol = "\u200B"; ASPxHtmlEditorCommands.Enter = _aspxCreateClass(ASPxHtmlEditorCommands.Command, { constructor: function(cmdID) { ASPxHtmlEditorCommands.Command.prototype.constructor.call(this, cmdID); this.passCommandToBrowser; }, IsDefaultAction: function(htmlEditor) { return Boolean(this.passCommandToBrowser); }, ReplaceWithNewLine: function(controlElement, lineFeedNodeTagName) { var newLineElement = controlElement.document.createElement(lineFeedNodeTagName); if(newLineElement.tagName != "BR") { newLineElement = this.EnsureEmptySymbolIs(newLineElement); } controlElement.parentNode.replaceChild(newLineElement, controlElement); }, Execute: function(cmdValue, htmlEditor) { this.passCommandToBrowser = false; if(htmlEditor.enterMode == ASPxHtmlEditorEnterMode.Default) { this.passCommandToBrowser = true; return false; } var selection = ASPxClientHtmlEditorSelection.Create(htmlEditor); var startContainer = selection.GetStartContainer(); if(_aspxGetParentByTagName(startContainer, "LI")) { this.passCommandToBrowser = true; return false; } var enterMode = htmlEditor.enterMode; if(this.NodeOrOneOfItsParentsIsPre(selection.GetParentElement())) enterMode = ASPxHtmlEditorEnterMode.BR; var doc = htmlEditor.GetDesignViewDocument(); var win = htmlEditor.GetDesignViewIFrameWindow(); if(enterMode == ASPxHtmlEditorEnterMode.BR) { var lineFeedNode; var lineFeedNodeTagName = "br"; var range = selection.GetRange(); if(__aspxIE) { if(selection.IsControl()) { var controlElement = range.item(0); this.ReplaceWithNewLine(controlElement, lineFeedNodeTagName); return true; } var uniqueID = ASPxClientSelection.CreateUniqueID(); range.pasteHTML("<" + lineFeedNodeTagName + " id=\"" + uniqueID + "\" />"); lineFeedNode = _aspxGetElementByIdInDocument(doc, uniqueID); _aspxRemoveAttribute(lineFeedNode, "id"); if(ASPxHtmlEditorCommands.Enter.IsNeedBogusNode(lineFeedNode)) { range.collapse(false); ASPxHtmlEditorCommands.Enter.AppendBogusNode(lineFeedNode); } range.collapse(true); range.select(); } else if(__aspxNetscapeFamily) { range.deleteContents(); lineFeedNode = doc.createElement(lineFeedNodeTagName); range.insertNode(lineFeedNode); var emptyNode = doc.createTextNode(""); lineFeedNode.parentNode.insertBefore(emptyNode, lineFeedNode.nextSibling); range.selectNode(emptyNode); range.collapse(false); if(ASPxHtmlEditorCommands.Enter.IsNeedBogusNode(lineFeedNode)) ASPxHtmlEditorCommands.Enter.AppendBogusNode(lineFeedNode); var nativeSelection = win.getSelection(); if(nativeSelection.rangeCount > 0) nativeSelection.removeAllRanges(); nativeSelection.addRange(range); } else if(__aspxOpera) { range.deleteContents(); lineFeedNode = doc.createElement(lineFeedNodeTagName); range.insertNode(lineFeedNode); var parentElement = selection.GetParentElement(); if(!ASPxHtmlEditorCommands.Enter.IsBlockNode(parentElement) && ASPxHtmlEditorCommands.Enter.NextNode(lineFeedNode) == null) { var savedDisplayStyle = parentElement.style.display; parentElement.style.display = "block"; } range = doc.createRange(); range.selectNode(lineFeedNode); range.collapse(false); win.getSelection().addRange(range); if(_aspxIsExists(savedDisplayStyle)) parentElement.style.display = savedDisplayStyle; } else if(__aspxWebKitFamily) { range.deleteContents(); lineFeedNode = doc.createElement(lineFeedNodeTagName); range.insertNode(lineFeedNode); range.collapse(false); if(ASPxHtmlEditorCommands.Enter.IsNeedBogusNode(lineFeedNode)) ASPxHtmlEditorCommands.Enter.AppendBogusNode(lineFeedNode); selection = win.getSelection(); selection.setBaseAndExtent(range.startContainer, range.startOffset, range.endContainer, range.endOffset); } ASPxHtmlEditorCommands.Enter.RemoveBogusNodes(doc.body); if(!__aspxIE) { var elementToView = lineFeedNode.nextSibling ? lineFeedNode.nextSibling : lineFeedNode; this.ScrollToElement(elementToView, doc); } } else if(htmlEditor.enterMode == ASPxHtmlEditorEnterMode.P) { var bookmark = selection.GetExtendedBookmark(); if(__aspxIE && selection.IsControl()) { this.ReplaceWithNewLine(doc.getElementById(bookmark.controlElementID), "P"); return true; } var startMarkerNode = doc.getElementById(bookmark.startMarkerID); var endMarkerNode = doc.getElementById(bookmark.endMarkerID); this.TryMoveBookmarkFromParent(startMarkerNode); var firstSplitBlockItem = this.GetSplitBlockItem("P", startMarkerNode, true); var lastSplitBlockItem = this.GetSplitBlockItem("P", endMarkerNode, false); var firstContainer = firstSplitBlockItem.block, firstLimitContainer = firstSplitBlockItem.blockLimit, lastContainer = lastSplitBlockItem.block, lastLimitContainer = lastSplitBlockItem.blockLimit; var elements = firstSplitBlockItem.elements.concat(lastSplitBlockItem.elements); if(firstContainer && firstContainer == lastContainer) { var container = firstContainer; for(var i = 0; i < elements.length; i++) { if(i == 0) container.parentNode.replaceChild(elements[i], container); else container.parentNode.insertBefore(elements[i], container.nextSibling); container = elements[i]; } } else if(firstLimitContainer && firstLimitContainer == lastLimitContainer) { _aspxSetInnerHtml(firstLimitContainer, ""); for(var i = 0; i < elements.length; i++) firstLimitContainer.appendChild(elements[i]); } else { selection.RemoveExtendedBookmark(bookmark); this.passCommandToBrowser = true; return false; } var startSplitNode = doc.getElementById(bookmark.startMarkerID).parentNode; var endSplitNode = doc.getElementById(bookmark.endMarkerID).parentNode; selection.RemoveExtendedBookmark(bookmark); startSplitNode = this.EnsureEmptySymbolIs(startSplitNode); endSplitNode = this.EnsureEmptySymbolIs(endSplitNode); var selectElem = endSplitNode; var range = selection.GetRange(); if(__aspxIE) { if(__aspxBrowserVersion == 9) { var fakeElem = doc.createElement("P"); selectElem.insertBefore(fakeElem, selectElem.firstChild); selectElem = fakeElem; } range.moveToElementText(selectElem); } else { if(selectElem.hasChildNodes()) selectElem = selectElem.firstChild; selection.SelectElement(selectElem, htmlEditor); range = selection.GetRange(); } var isStartSelection = !(__aspxIE && __aspxBrowserVersion == 9); range.collapse(isStartSelection); if(__aspxIE) { range.select(); if (__aspxBrowserVersion == 9) selectElem.parentNode.removeChild(selectElem); var endSplitNodeFirstChild = endSplitNode.firstChild; if(endSplitNodeFirstChild && endSplitNodeFirstChild.nodeType == 3 && _aspxTrim(endSplitNodeFirstChild.nodeValue) == "") endSplitNode.removeChild(endSplitNodeFirstChild); } else if(__aspxNetscapeFamily) { var emptyNode = doc.createTextNode(""); selectElem.parentNode.insertBefore(emptyNode, selectElem); range.selectNode(emptyNode); range.collapse(false); var nativeSelection = win.getSelection(); if(nativeSelection.rangeCount > 0) nativeSelection.removeAllRanges(); nativeSelection.addRange(range); } else if(__aspxOpera) { doc.body.focus(); range = doc.createRange(); range.selectNode(selectElem); range.collapse(true); var nativeSelection = win.getSelection(); if(__aspxBrowserVersion >= 10.5 && nativeSelection.rangeCount > 0) nativeSelection.removeAllRanges(); nativeSelection.addRange(range); } else if(__aspxWebKitFamily) { selection = win.getSelection(); selection.setBaseAndExtent(range.startContainer, range.startOffset, range.endContainer, range.endOffset); } if(!__aspxIE) this.ScrollToElement(endSplitNode.firstChild, doc); } return true; }, TryMoveBookmarkFromParent: function (bm) { var parent = bm.parentNode; parent.normalize(); if (parent.tagName == "A" && parent.firstChild == bm) { parent.parentNode.insertBefore(bm, parent); this.TryMoveBookmarkFromParent(bm); } }, NodeOrOneOfItsParentsIsPre: function(node) { while(node && node.tagName != "BODY") { if(node.tagName == "PRE") return true; else node = node.parentNode; } return false; }, EnsureEmptySymbolIs: function(node) { if(node) { if(node.nodeType == 1 && _aspxTrim(node.innerHTML) == "") node.innerHTML = " "; else if(node.nodeType == 3 && _aspxTrim(node.nodeValue) == "") node.nodeValue = "\xA0"; } return node; }, GetSplitInfo: function(splitNode) { var block = null; var blockLimit = null; var elements = []; var node = splitNode; while(node && node.tagName != "BODY") { elements.push(node); node = node.parentNode; if(this.IsPathBlockElement(node)) { block = node; break; } if(this.IsPathBlockLimitElement(node)) { blockLimit = node; break; } } elements = elements.reverse(); return { block: block, blockLimit: blockLimit, elements: elements }; }, GetSplitBlockItem: function(blockTag, splitNode, isFirst) { var doc = _aspxGetElementDocument(splitNode); var splitInfo = this.GetSplitInfo(splitNode); var elements = splitInfo.elements; if(splitInfo.blockLimit && splitInfo.blockLimit.tagName == "DIV") { blockTag = "DIV"; splitInfo.block = splitInfo.blockLimit; } var srcNode = null; var destNode = splitInfo.block ? splitInfo.block.cloneNode(false) : doc.createElement(blockTag); var splitBlock = destNode; for(var i = 0; i < elements.length; i++) { srcNode = elements[i]; destNode = destNode.appendChild(srcNode.cloneNode(false)); while(srcNode = isFirst ? srcNode.previousSibling : srcNode.nextSibling) { var parent = destNode.parentNode; if(isFirst) parent.insertBefore(srcNode.cloneNode(true), parent.firstChild); else parent.appendChild(srcNode.cloneNode(true)); } } return { block: splitInfo.block, blockLimit: splitInfo.blockLimit, elements: this.ValidateElements(splitBlock, isFirst) }; }, IsPathBlockElement: function(element) { return element.nodeType == 1 && __aspxHEPathBlockElements[element.tagName.toLowerCase()]; }, IsPathBlockLimitElement: function(element) { return element.nodeType == 1 && __aspxHEPathBlockLimitElements[element.tagName.toLowerCase()]; }, IsValidBlock: function(parentBlock, childBlock) { if(this.IsPathBlockElement(parentBlock) && (this.IsPathBlockElement(childBlock) || this.IsPathBlockLimitElement(childBlock))) { return false; } return true; }, ValidateElements: function(splitBlock, isFirst) { var elements = []; var isNeedToWrap = true; if(splitBlock.hasChildNodes()) { var count = splitBlock.childNodes.length; for(var i = isFirst ? count-1 : 0; isFirst ? i >= 0 : i < count; isFirst ? i-- : i++ ) { var node = splitBlock.childNodes[i].cloneNode(true); if(!this.IsValidBlock(splitBlock, node) || !isNeedToWrap) { isNeedToWrap = false; elements.push(node); } else { if(elements.length == 0) elements.push(splitBlock.cloneNode(false)); if(isFirst) elements[0].insertBefore(node, elements[0].firstChild); else elements[0].appendChild(node); } } } if(isFirst) elements = elements.reverse(); return elements; }, ScrollToElement: function(element, doc) { var elementPosY = 0; var elementHeight = 0; var parentNode = element.parentNode; var fakeElem = doc.createElement("DIV"); fakeElem.innerHTML = " "; parentNode.insertBefore(fakeElem, element); elementPosY = fakeElem.offsetTop; elementHeight = fakeElem.offsetHeight; parentNode.removeChild(fakeElem); var newScrollTop = (elementPosY + elementHeight) - doc.body.clientHeight; if(newScrollTop > doc.body.scrollTop) doc.body.scrollTop = Math.max(newScrollTop, 0); } }); ASPxHtmlEditorCommands.Enter.NextNode = function(node) { var next = node.nextSibling; if(next && next.nodeType == 3 && next.nodeValue == "") next = ASPxHtmlEditorCommands.Enter.NextNode(next); return next; }; ASPxHtmlEditorCommands.Enter.PreviousNode = function(node) { var prev = node.previousSibling; if(prev && prev.nodeType == 3 && prev.nodeValue == "") prev = ASPxHtmlEditorCommands.Enter.PreviousNode(prev); return prev; }; ASPxHtmlEditorCommands.Enter.IsBogusNode = function(node) { if(node && node.nodeType == 3) { if(__aspxIE && node.nodeValue == __aspxHEBogusSymbol) return true; else if(__aspxNetscapeFamily || __aspxWebKitFamily) { if(node.nodeValue == __aspxHEBogusSymbol) return true; } } return false; }; ASPxHtmlEditorCommands.Enter.IsBlockNode = function(node) { if(node && node.nodeType == 1) { if(__aspxHEBlockElements[node.nodeName.toLowerCase()]) { if(node.style.display != "inline") return true; } else if(node.style.display == "block") return true; } return false; }; ASPxHtmlEditorCommands.Enter.IsNeedBogusNode = function(node) { if(__aspxIE && __aspxBrowserVersion == 6) return false; var prev = ASPxHtmlEditorCommands.Enter.PreviousNode(node); var next = ASPxHtmlEditorCommands.Enter.NextNode(node); if(__aspxNetscapeFamily && prev && prev.nodeName == "BR") { if(_aspxGetAttribute(prev, "type") == "_moz") return false; } if(!ASPxHtmlEditorCommands.Enter.IsBlockNode(prev) && (ASPxHtmlEditorCommands.Enter.IsBlockNode(next) || next == null)) return true; return false; }; ASPxHtmlEditorCommands.Enter.AppendBogusNode = function(node) { var doc = _aspxGetElementDocument(node); return node.parentNode.insertBefore(doc.createTextNode(__aspxHEBogusSymbol), node.nextSibling); }; ASPxHtmlEditorCommands.Enter.RemoveBogusNodes = function(node) { var textNodes = [ ]; _aspxGetChildTextNodeCollection(node, textNodes); for(var i = textNodes.length - 1; i > 0; i--) if(ASPxHtmlEditorCommands.Enter.IsBogusNode(textNodes[i]) && !ASPxHtmlEditorCommands.Enter.IsNeedBogusNode(textNodes[i])) textNodes[i].parentNode.removeChild(textNodes[i]); }; ASPxHtmlEditorCommands.Delete = _aspxCreateClass(ASPxHtmlEditorCommands.Command, { Execute: function(cmdValue, editor) { ASPxHtmlEditorCommands.CorrectSelectionForDeleteCommand(editor); var isSuccessfully = true; var designViewIFrameDocument = editor.GetDesignViewDocument(); isSuccessfully = designViewIFrameDocument.execCommand(this.commandID, false, null); if (__aspxOpera) { designViewIFrameDocument.contentEditable = true; designViewIFrameDocument.body.focus(); } return isSuccessfully; } }); ASPxHtmlEditorCommands.DeleteWithoutSelection = _aspxCreateClass(ASPxHtmlEditorCommands.Command, { Execute: function(cmdValue, editor) { ASPxHtmlEditorCommands.CorrectSelectionForDeleteCommand(editor); if(__aspxNetscapeFamily) { var IFrameBody = editor.GetDesignViewDocument().body; window.setTimeout(function() { ASPxHtmlEditorCommands.Enter.RemoveBogusNodes(IFrameBody); }, 0); } return true; }, IsImmediateExecution: function() { return true; } }); ASPxHtmlEditorCommands.CorrectSelectionForDeleteCommand = function(editor) { if(__aspxNetscapeFamily) { var clientSelection = ASPxClientHtmlEditorSelection.Create(editor); var parent = clientSelection.GetParentElement(); if(parent.tagName != "A") return; var isNeedDeleteParentNode = false; var selectionText = clientSelection.GetText(); if(selectionText != "") { var parentInnerText = _aspxGetInnerText(parent); isNeedDeleteParentNode = selectionText == parentInnerText; } else { var doc = editor.GetDesignViewDocument(); var range = clientSelection.GetRange(); var markerID = ASPxClientSelection.CreateUniqueID(); var marker = doc.createElement("SPAN"); marker.id = markerID; range.insertNode(marker); var parts = ASPxClientHtmlProcessingUtils.SplitNode(parent, [marker]); var prevSymbolsCount = _aspxGetInnerText(parts[0]).length, nextSymbolsCount = _aspxGetInnerText(parts[1]).length; var isBackSpaceKey = editor.keyDownInfo.isBackSpaceKey; if(isBackSpaceKey) isNeedDeleteParentNode = prevSymbolsCount < 2 && nextSymbolsCount == 0; else isNeedDeleteParentNode = nextSymbolsCount < 2 && prevSymbolsCount == 0; _aspxRemoveElement(marker); } if(isNeedDeleteParentNode && parent.tagName != "BODY") clientSelection.SelectElement(parent); } }; ASPxHtmlEditorCommands.Undo = _aspxCreateClass(ASPxHtmlEditorCommands.Command, { Execute: function(cmdValue, editor) { editor.SetFocus(); var ret = editor.Undo(); return ret; }, IsReversable: function() { return false; }, IsLocked: function(editor) { return !editor.IsUndoAvailable(); } }); ASPxHtmlEditorCommands.Redo = _aspxCreateClass(ASPxHtmlEditorCommands.Command, { Execute: function(cmdValue, editor) { editor.SetFocus(); var ret = editor.Redo(); return ret; }, IsReversable: function() { return false; }, IsLocked: function(editor) { return !editor.IsRedoAvailable(); } }); ASPxHtmlEditorCommands.CheckSpelling = _aspxCreateClass(ASPxHtmlEditorCommands.Command, { Execute: function(cmdValue, editor) { return editor.CheckSpelling(); }, IsLocked: function(editor) { return aspxIsEmptyHtml(editor.GetHtmlInternal()); } }); ASPxHtmlEditorCommands.CheckSpellingCore = _aspxCreateClass(ASPxHtmlEditorCommands.Command, { Execute: function(cmdValue, editor) { editor.SetHtmlInternal(cmdValue); return true; } }); ASPxHtmlEditorCommands.Print = _aspxCreateClass(ASPxHtmlEditorCommands.Command, { Execute: function(cmdValue, editor) { return editor.Print(); }, IsLocked: function(editor) { return aspxIsEmptyHtml(editor.GetHtmlInternal()); }, IsReversable: function() { return false; } }); ASPxHtmlEditorCommands.Fullscreen = _aspxCreateClass(ASPxHtmlEditorCommands.Command, { Execute: function(cmdValue, editor) { editor.SetFullscreenMode(); return true; }, IsLocked: function(editor) { return false; }, IsReversable: function() { return false; }, GetState: function(editor) { return editor.isFullscreenMode; } }); function aspxIsEmptyHtml(html){ var html = _aspxTrim(html); return html == "" || html == " " || html == "

 

"; } ASPxHtmlEditorCommands.Browser.InsertImage = _aspxCreateClass(ASPxHtmlEditorCommands.Browser.Command, { Execute: function(cmdValue, editor) { var newImageElement = this.InsertImage(cmdValue.src, editor); ASPxHtmlEditorCommands.ChangeImage.SetImageProperties(newImageElement, cmdValue); if(__aspxIE) ASPxClientHtmlEditor.RestoreUrlsInDOM(editor.GetDesignViewDocument()); return true; }, InsertImage: function(source, editor) { var markerID = ASPxClientSelection.CreateUniqueID(); var htmlText = ''; ASPxHtmlEditorCommandList[ASPxClientCommandConsts.PASTEHTML_COMMAND].Execute(htmlText, editor); var imageElement = _aspxGetElementByIdInDocument(editor.GetDesignViewDocument(), markerID); _aspxRemoveAttribute(imageElement, "id"); return imageElement; } }); ASPxHtmlEditorCommands.ChangeImage = _aspxCreateClass(ASPxHtmlEditorCommands.Command, { Execute: function(cmdValue, editor) { ASPxHtmlEditorCommands.ChangeImage.SetImageProperties(cmdValue.imageElement, cmdValue); return true; } }); ASPxHtmlEditorCommands.ChangeImage.GetImageProperties = function(imageElement) { var imageInfoObject = { isCustomSize: false, src: __aspxIE ? imageElement.getAttribute("src", 2) : _aspxGetAttribute(imageElement, "src"), width: imageElement.width, height: imageElement.height, align: "", alt: "", useFloat: false }; imageInfoObject.isCustomSize = ASPxHtmlEditorCommands.ChangeImage.IsExistImageAttribute(imageElement, "width") || ASPxHtmlEditorCommands.ChangeImage.IsExistImageAttribute(imageElement, "height"); var parentNode = imageElement.parentNode; if (parentNode.childNodes.length == 1 && parentNode.tagName != "BODY") { imageInfoObject.align = parentNode.style.textAlign; if (!imageInfoObject.align) imageInfoObject.align = parentNode.align; } if (!imageInfoObject.align) { if (_aspxIsExistsAttribute(imageElement, "align")) imageInfoObject.align = _aspxGetAttribute(imageElement, "align"); else { if (__aspxIE && _aspxIsExists(imageElement.style.styleFloat)) { imageInfoObject.align = imageElement.style.styleFloat; imageInfoObject.useFloat = true; } if (!__aspxIE && _aspxIsExists(imageElement.style.cssFloat)) { imageInfoObject.align = imageElement.style.cssFloat; imageInfoObject.useFloat = true; } } } imageInfoObject.alt = _aspxGetAttribute(imageElement, "alt"); return imageInfoObject; }; ASPxHtmlEditorCommands.ChangeImage.IsExistImageAttribute = function(image, attrName) { var styleAttr = _aspxGetAttribute(image.style, attrName); return ((styleAttr != "") && (styleAttr != null)) || (!__aspxNetscapeFamily && (image.outerHTML.toLowerCase().indexOf(attrName + "=") > -1)); }; ASPxHtmlEditorCommands.ChangeImage.SetImageProperties = function(imageElement, params) { var src = params.src, cssClass = params.cssClass, width = params.width, height = params.height, align = params.align, alt = params.alt, useFloat = params.useFloat; if (src && src != "") _aspxSetAttribute(imageElement, "src", src); if (cssClass) _aspxSetAttribute(imageElement, "class", cssClass); if (width && width != "") _aspxSetAttribute(imageElement.style, "width", width); else if(width != null) { _aspxRemoveAttribute(imageElement, "width"); _aspxRemoveAttribute(imageElement.style, "width"); } if (height && height != "") _aspxSetAttribute(imageElement.style, "height", height); else if(height != null) { _aspxRemoveAttribute(imageElement, "height"); _aspxRemoveAttribute(imageElement.style, "height"); } if (alt && alt != "") _aspxSetAttribute(imageElement, "alt", alt); if (align) { var documentObj = _aspxGetElementDocument(imageElement); var sourceId = imageElement.id; imageElement.id = __aspxHEMarkID; var parentNode = imageElement.parentNode; var wrapElem = null; if (parentNode.childNodes.length == 1 && parentNode.tagName == "DIV") wrapElem = parentNode; _aspxRemoveAttribute(imageElement, "align"); _aspxSetElementFloat(imageElement, ""); if (align.toLowerCase() == "left" || align.toLowerCase() == "right") { if (wrapElem != null) _aspxRemoveOuterTags(wrapElem); imageElement = _aspxGetElementByIdInDocument(documentObj, __aspxHEMarkID); if (useFloat) { if (__aspxIE) imageElement.style.styleFloat = align; else imageElement.style.cssFloat = align; } else _aspxSetAttribute(imageElement, "align", align); } else { if (wrapElem == null) wrapElem = _aspxWrapElementInNewElement(imageElement, "DIV"); wrapElem.style.textAlign = "center"; imageElement = _aspxGetElementByIdInDocument(documentObj, __aspxHEMarkID); } sourceId != "" ? imageElement.id = sourceId : _aspxRemoveAttribute(imageElement, "id"); } if(imageElement) return imageElement; }; ASPxHtmlEditorCommands.InsertLink = _aspxCreateClass(ASPxHtmlEditorCommands.SelectionManipulationCommand, { Execute: function(cmdValue, editor) { ASPxHtmlEditorCommands.SelectionManipulationCommand.prototype.Execute.apply(this, arguments); this.ValidateCommandValue(cmdValue); var selection = editor.GetSelection(); this.parentElement = selection.GetSelectedElement(); this.text = ASPxHtmlEditorCommands.InsertLink.PrepareLinkText(cmdValue.text); this.url = cmdValue.url; this.target = cmdValue.target; this.title = cmdValue.title; var link = _aspxGetParentByTagName(this.parentElement, "A"); if(link) this.SetLinkProperties(link, this.url, this.target, this.title, this.text); else if(this.parentElement.tagName == "IMG") this.WrapElementInternal(this.parentElement, this.CreateLink()); else if(selection.GetHtml()) { var elements = selection.GetElements(); if(elements.length) { var link = this.ApplyLinkFormat(elements, this.CreateLink()); selection.clientSelection.SelectElement(link, false); if (__aspxOpera) editor.GetDesignViewDocument().body.focus(); } else return this.InsertLinkAtCursor(editor); } else return this.InsertLinkAtCursor(editor); return true; }, InsertLinkAtCursor: function(editor) { var htmlText = ""; return ASPxHtmlEditorCommandList[ASPxClientCommandConsts.PASTEHTML_COMMAND].Execute(htmlText, editor); }, CreateLink: function() { var link = this.parentElement.ownerDocument.createElement('A'); if (__aspxWebKitFamily) link.href = "#"; return link; }, ApplyLinkFormat: function(elements, link) { var lastLink; for(var i = 0, el; el = elements[i]; i++) { if(el.tagName == "A" && el.href != this.url) { this.SetLinkProperties(el, this.url, this.target, this.title); this.newElements.push(el); lastLink = el; } else if(_aspxGetParentByTagName(el, "A")) { var predicate = function(target) { return target.tagName != "A"; }; var nnElement = this.SeparateParentByPredicate(el, predicate); this.SetLinkProperties(nnElement, this.url, this.target, this.title); this.newElements.push(nnElement); lastLink = nnElement; } else if(el.nodeType == 3 || el.tagName == "IMG") lastLink = this.WrapElementInternal(el, link.cloneNode(false)); else lastLink = this.ApplyLinkFormat(el.childNodes, link); } return lastLink; }, WrapElementInternal: function(el, wrapper) { this.SetLinkProperties(wrapper, this.url, this.target, this.title); var link = ASPxHtmlEditorCommands.SelectionManipulationCommand.prototype.WrapElementInternal.apply(this, arguments); if(this.text) link.innerHTML = this.text; return link; }, CanMerge: function(el1, el2) { return el1.tagName == el2.tagName && el1.className == el2.className && el1.href == el2.href; }, ValidateCommandValue: function(cmdValue) { cmdValue.url = this.ReplaceDoubleQuotesWithSingleQuotes(cmdValue.url); cmdValue.title = this.ReplaceDoubleQuotesWithSingleQuotes(cmdValue.title); }, ReplaceDoubleQuotesWithSingleQuotes: function(str) { return str ? str.replace(new RegExp("\"", "g"), "'") : str; }, AddAttributeStringToHtml: function(html, attrName, attrValue) { return html + " " + attrName + "=\"" + attrValue + "\""; }, SetLinkProperties: function(linkElement, url, target, title, text) { _aspxSetOrRemoveAttribute(linkElement, "href", url); _aspxSetOrRemoveAttribute(linkElement, "target", target); _aspxSetOrRemoveAttribute(linkElement, "title", title); if(text) linkElement.innerHTML = text; } }); ASPxHtmlEditorCommands.InsertLink.PrepareLinkText = function(text) { return text.replace("<", "<").replace(">", ">"); }; ASPxHtmlEditorCommands.DialogCommand = _aspxCreateClass(ASPxHtmlEditorCommands.Command, { Execute: function(cmdValue, editor) { var dialog = ASPxHtmlEditorDialogList[this.commandID]; if (dialog != null) dialog.Execute(editor); else alert('Dialog is not found'); return true; }, IsHtmlChangeable: function() { return false; }, GetState: function(editor) { return false; }, IsLocked: function(editor) { return false; } }); ASPxHtmlEditorCommands.Dialogs = { PasteFromWord: _aspxCreateClass(ASPxHtmlEditorCommands.DialogCommand, { Execute: function(cmdValue, editor) { if(!__aspxTouchUI) ASPxHtmlEditorCommands.DialogCommand.prototype.Execute.call(this, cmdValue, editor); else alert(ASPxHtmlEditorCommands.Browser.Clipboard.NotAllowedMessage[ASPxClientCommandConsts.PASTE_COMMAND]); }, IsLocked: function(editor) { if (__aspxWebKitFamily) return false; try { return !editor.GetDesignViewDocument().queryCommandEnabled(ASPxClientCommandConsts.PASTE_COMMAND); } catch(e) {} return true; } }), ChangeImage: _aspxCreateClass(ASPxHtmlEditorCommands.DialogCommand, { IsLocked: function(editor) { return !InsertImageDialog.prototype.GetSelectedImage(editor); } }), ChangeLink: _aspxCreateClass(ASPxHtmlEditorCommands.DialogCommand, { IsLocked: function(editor) { return !InsertLinkDialog.prototype.IsLinkSelected(editor); } }), TableCellProperties: _aspxCreateClass(ASPxHtmlEditorCommands.DialogCommand, { IsLocked: function(editor) { return !ASPxHtmlEditorCommands.Tables.Cell.IsSelected(editor); } }), ChangeTable: _aspxCreateClass(ASPxHtmlEditorCommands.DialogCommand, { IsLocked: function(editor) { return !ASPxHtmlEditorCommands.Tables.Table.IsSelected(editor); } }), CustomDialog: _aspxCreateClass(ASPxHtmlEditorCommands.DialogCommand, { constructor: function(cmdID) { this.constructor.prototype.constructor.call(this, cmdID); this.dialogs = {}; }, Execute: function(cmdValue, editor) { var customDialogName = "cd_" + cmdValue; if(!this.dialogs[customDialogName]) this.dialogs[customDialogName] = new ASPxCustomDialog(customDialogName, cmdValue); var dialog = this.dialogs[customDialogName]; dialog.Execute(editor); return true; }, DialogNotFound: function(dialogName) { delete this.dialogs[dialogName]; } }) }; ASPxHtmlEditorCommands.SaveAs = _aspxCreateClass(ASPxHtmlEditorCommands.Command, { Execute: function(cmdValue, editor) { editor.Export(cmdValue); }, IsDefaultAction: function(editor) { return true; }, IsImmediateExecution: function() { return true; }, IsHtmlChangeable: function() { return false; }, IsLocked: function(editor) { return false; }, IsReversable: function() { return false; }, IsClientCommand: function() { return false; } }); var ASPxHtmlEditorCommandList = {}; ASPxHtmlEditorCommandList[ASPxClientCommandConsts.BOLD_COMMAND] = new ASPxHtmlEditorCommands.Browser.FontStyle(ASPxClientCommandConsts.BOLD_COMMAND); ASPxHtmlEditorCommandList[ASPxClientCommandConsts.ITALIC_COMMAND] = new ASPxHtmlEditorCommands.Browser.FontStyle(ASPxClientCommandConsts.ITALIC_COMMAND); ASPxHtmlEditorCommandList[ASPxClientCommandConsts.UNDERLINE_COMMAND] = new ASPxHtmlEditorCommands.Browser.FontStyle(ASPxClientCommandConsts.UNDERLINE_COMMAND); ASPxHtmlEditorCommandList[ASPxClientCommandConsts.STRIKETHROUGH_COMMAND] = new ASPxHtmlEditorCommands.Browser.FontStyle(ASPxClientCommandConsts.STRIKETHROUGH_COMMAND); ASPxHtmlEditorCommandList[ASPxClientCommandConsts.JUSTIFYCENTER_COMMAND] = new ASPxHtmlEditorCommands.Browser.Justify(ASPxClientCommandConsts.JUSTIFYCENTER_COMMAND); ASPxHtmlEditorCommandList[ASPxClientCommandConsts.JUSTIFYLEFT_COMMAND] = new ASPxHtmlEditorCommands.Browser.Justify(ASPxClientCommandConsts.JUSTIFYLEFT_COMMAND); ASPxHtmlEditorCommandList[ASPxClientCommandConsts.JUSTIFYRIGHT_COMMAND] = new ASPxHtmlEditorCommands.Browser.Justify(ASPxClientCommandConsts.JUSTIFYRIGHT_COMMAND); ASPxHtmlEditorCommandList[ASPxClientCommandConsts.JUSTIFYFULL_COMMAND] = new ASPxHtmlEditorCommands.Browser.Justify(ASPxClientCommandConsts.JUSTIFYFULL_COMMAND); ASPxHtmlEditorCommandList[ASPxClientCommandConsts.SUPERSCRIPT_COMMAND] = new ASPxHtmlEditorCommands.Browser.Command(ASPxClientCommandConsts.SUPERSCRIPT_COMMAND); ASPxHtmlEditorCommandList[ASPxClientCommandConsts.SUBSCRIPT_COMMAND] = new ASPxHtmlEditorCommands.Browser.Command(ASPxClientCommandConsts.SUBSCRIPT_COMMAND); ASPxHtmlEditorCommandList[ASPxClientCommandConsts.INDENT_COMMAND] = new ASPxHtmlEditorCommands.Browser.Indent(ASPxClientCommandConsts.INDENT_COMMAND); ASPxHtmlEditorCommandList[ASPxClientCommandConsts.OUTDENT_COMMAND] = new ASPxHtmlEditorCommands.Browser.Indent(ASPxClientCommandConsts.OUTDENT_COMMAND); ASPxHtmlEditorCommandList[ASPxClientCommandConsts.INSERTORDEREDLIST_COMMAND] = new ASPxHtmlEditorCommands.Browser.InsertList(ASPxClientCommandConsts.INSERTORDEREDLIST_COMMAND); ASPxHtmlEditorCommandList[ASPxClientCommandConsts.INSERTUNORDEREDLIST_COMMAND] = new ASPxHtmlEditorCommands.Browser.InsertList(ASPxClientCommandConsts.INSERTUNORDEREDLIST_COMMAND); ASPxHtmlEditorCommandList[ASPxClientCommandConsts.SELECT_ALL] = new ASPxHtmlEditorCommands.Browser.SelectAll(ASPxClientCommandConsts.SELECT_ALL); ASPxHtmlEditorCommandList[ASPxClientCommandConsts.PASTE_COMMAND] = new ASPxHtmlEditorCommands.Browser.Clipboard(ASPxClientCommandConsts.PASTE_COMMAND); ASPxHtmlEditorCommandList[ASPxClientCommandConsts.PASTEFROMWORD_COMMAND] = new ASPxHtmlEditorCommands.PasteFromWord(ASPxClientCommandConsts.PASTEFROMWORD_COMMAND); ASPxHtmlEditorCommandList[ASPxClientCommandConsts.CUT_COMMAND] = new ASPxHtmlEditorCommands.Browser.Clipboard(ASPxClientCommandConsts.CUT_COMMAND); ASPxHtmlEditorCommandList[ASPxClientCommandConsts.COPY_COMMAND] = new ASPxHtmlEditorCommands.Browser.Clipboard(ASPxClientCommandConsts.COPY_COMMAND); ASPxHtmlEditorCommandList[ASPxClientCommandConsts.KBPASTE_COMMAND] = new ASPxHtmlEditorCommands.KbPaste(ASPxClientCommandConsts.KBPASTE_COMMAND); ASPxHtmlEditorCommandList[ASPxClientCommandConsts.KBCUT_COMMAND] = new ASPxHtmlEditorCommands.KbCut(ASPxClientCommandConsts.KBCUT_COMMAND); ASPxHtmlEditorCommandList[ASPxClientCommandConsts.KBCOPY_COMMAND] = new ASPxHtmlEditorCommands.KbCopy(ASPxClientCommandConsts.KBCOPY_COMMAND); ASPxHtmlEditorCommandList[ASPxClientCommandConsts.FONTSIZE_COMMAND] = new ASPxHtmlEditorCommands.Browser.FontSize(ASPxClientCommandConsts.FONTSIZE_COMMAND); ASPxHtmlEditorCommandList[ASPxClientCommandConsts.FONTNAME_COMMAND] = new ASPxHtmlEditorCommands.Browser.FontName(ASPxClientCommandConsts.FONTNAME_COMMAND); ASPxHtmlEditorCommandList[ASPxClientCommandConsts.FONTCOLOR_COMMAND] = new ASPxHtmlEditorCommands.Browser.FontColor(ASPxClientCommandConsts.FONTCOLOR_COMMAND); ASPxHtmlEditorCommandList[ASPxClientCommandConsts.BACKCOLOR_COMMAND] = new ASPxHtmlEditorCommands.Browser.BgColor(ASPxClientCommandConsts.BACKCOLOR_COMMAND); ASPxHtmlEditorCommandList[ASPxClientCommandConsts.APPLYCSS_COMMAND] = new ASPxHtmlEditorCommands.ApplyCss(ASPxClientCommandConsts.APPLYCSS_COMMAND); ASPxHtmlEditorCommandList[ASPxClientCommandConsts.FORMATBLOCK_COMMAND] = new ASPxHtmlEditorCommands.Browser.FormatBlock(ASPxClientCommandConsts.FORMATBLOCK_COMMAND); ASPxHtmlEditorCommandList[ASPxClientCommandConsts.REMOVEFORMAT_COMMAND] = new ASPxHtmlEditorCommands.Browser.RemoveFormat(ASPxClientCommandConsts.REMOVEFORMAT_COMMAND); ASPxHtmlEditorCommandList[ASPxClientCommandConsts.UNDO_COMMAND] = new ASPxHtmlEditorCommands.Undo(ASPxClientCommandConsts.UNDO_COMMAND); ASPxHtmlEditorCommandList[ASPxClientCommandConsts.REDO_COMMAND] = new ASPxHtmlEditorCommands.Redo(ASPxClientCommandConsts.REDO_COMMAND); ASPxHtmlEditorCommandList[ASPxClientCommandConsts.LINEBREAKETYPE_COMMAND] = new ASPxHtmlEditorCommands.LineBreakType(ASPxClientCommandConsts.LINEBREAKETYPE_COMMAND); ASPxHtmlEditorCommandList[ASPxClientCommandConsts.NEWPARAGRAPHTYPE_COMMAND] = new ASPxHtmlEditorCommands.NewParagraphType(ASPxClientCommandConsts.NEWPARAGRAPHTYPE_COMMAND); ASPxHtmlEditorCommandList[ASPxClientCommandConsts.TEXTTYPE_COMMAND] = new ASPxHtmlEditorCommands.TextType(ASPxClientCommandConsts.TextType_COMMAND); ASPxHtmlEditorCommandList[ASPxClientCommandConsts.RESIZEOBJECT_COMMAND] = new ASPxHtmlEditorCommands.TextType(ASPxClientCommandConsts.RESIZEOBJECT_COMMAND); ASPxHtmlEditorCommandList[ASPxClientCommandConsts.DRAGDROPOBJECT_COMMAND] = new ASPxHtmlEditorCommands.TextType(ASPxClientCommandConsts.DRAGDROPOBJECT_COMMAND); ASPxHtmlEditorCommandList[ASPxClientCommandConsts.DROPOBJECTFROMEXTERNAL_COMMAND] = new ASPxHtmlEditorCommands.TextType(ASPxClientCommandConsts.DROPOBJECTFROMEXTERNAL_COMMAND); ASPxHtmlEditorCommandList[ASPxClientCommandConsts.DELETE_COMMAND] = new ASPxHtmlEditorCommands.Delete(ASPxClientCommandConsts.DELETE_COMMAND); ASPxHtmlEditorCommandList[ASPxClientCommandConsts.KBDELETE_COMMAND] = new ASPxHtmlEditorCommands.DeleteWithoutSelection(ASPxClientCommandConsts.KBDELETE_COMMAND); ASPxHtmlEditorCommandList[ASPxClientCommandConsts.ENTER_COMMAND] = new ASPxHtmlEditorCommands.Enter(ASPxClientCommandConsts.ENTER_COMMAND); ASPxHtmlEditorCommandList[ASPxClientCommandConsts.PASTEHTML_COMMAND] = new ASPxHtmlEditorCommands.PasteHtml(ASPxClientCommandConsts.PASTEHTML_COMMAND); ASPxHtmlEditorCommandList[ASPxClientCommandConsts.INSERTLINK_COMMAND] = new ASPxHtmlEditorCommands.InsertLink(ASPxClientCommandConsts.INSERTLINK_COMMAND); ASPxHtmlEditorCommandList[ASPxClientCommandConsts.UNLINK_COMMAND] = new ASPxHtmlEditorCommands.Browser.Command(ASPxClientCommandConsts.UNLINK_COMMAND); ASPxHtmlEditorCommandList[ASPxClientCommandConsts.CHANGEIMAGE_COMMAND] = new ASPxHtmlEditorCommands.ChangeImage(ASPxClientCommandConsts.CHANGEIMAGE_COMMAND); ASPxHtmlEditorCommandList[ASPxClientCommandConsts.INSERTIMAGE_COMMAND] = new ASPxHtmlEditorCommands.Browser.InsertImage(ASPxClientCommandConsts.INSERTIMAGE_COMMAND); ASPxHtmlEditorCommandList[ASPxClientCommandConsts.CHECKSPELLING_COMMAND] = new ASPxHtmlEditorCommands.CheckSpelling(ASPxClientCommandConsts.CHECKSPELLING_COMMAND); ASPxHtmlEditorCommandList[ASPxClientCommandConsts.CheckSpellingCore_COMMAND] = new ASPxHtmlEditorCommands.CheckSpellingCore(ASPxClientCommandConsts.CHECKSPELLING_COMMAND); ASPxHtmlEditorCommandList[ASPxClientCommandConsts.PRINT_COMMAND] = new ASPxHtmlEditorCommands.Print(ASPxClientCommandConsts.PRINT_COMMAND); ASPxHtmlEditorCommandList[ASPxClientCommandConsts.FULLSCREEN_COMMAND] = new ASPxHtmlEditorCommands.Fullscreen(ASPxClientCommandConsts.FULLSCREEN_COMMAND); ASPxHtmlEditorCommandList[ASPxClientCommandConsts.INSERTTABLE_COMMAND] = new ASPxHtmlEditorCommands.Tables.Table.Insert(ASPxClientCommandConsts.INSERTTABLE_COMMAND); ASPxHtmlEditorCommandList[ASPxClientCommandConsts.CHANGETABLE_COMMAND] = new ASPxHtmlEditorCommands.Tables.Table.Change(ASPxClientCommandConsts.CHANGETABLE_COMMAND); ASPxHtmlEditorCommandList[ASPxClientCommandConsts.DELETETABLE_COMMAND] = new ASPxHtmlEditorCommands.Tables.Table.Delete(ASPxClientCommandConsts.DELETETABLE_COMMAND); ASPxHtmlEditorCommandList[ASPxClientCommandConsts.INSERTTABLECOLUMNTOLEFT_COMMAND] = new ASPxHtmlEditorCommands.Tables.Column.Insert(ASPxClientCommandConsts.INSERTTABLECOLUMNTOLEFT_COMMAND); ASPxHtmlEditorCommandList[ASPxClientCommandConsts.INSERTTABLECOLUMNTORIGHT_COMMAND] = new ASPxHtmlEditorCommands.Tables.Column.Insert(ASPxClientCommandConsts.INSERTTABLECOLUMNTORIGHT_COMMAND); ASPxHtmlEditorCommandList[ASPxClientCommandConsts.CHANGETABLECOLUMN_COMMAND] = new ASPxHtmlEditorCommands.Tables.Column.Change(ASPxClientCommandConsts.CHANGETABLECOLUMN_COMMAND); ASPxHtmlEditorCommandList[ASPxClientCommandConsts.DELETETABLECOLUMN_COMMAND] = new ASPxHtmlEditorCommands.Tables.Column.Delete(ASPxClientCommandConsts.DELETETABLECOLUMN_COMMAND); ASPxHtmlEditorCommandList[ASPxClientCommandConsts.INSERTTABLEROWBELOW_COMMAND] = new ASPxHtmlEditorCommands.Tables.Row.Insert(ASPxClientCommandConsts.INSERTTABLEROWBELOW_COMMAND); ASPxHtmlEditorCommandList[ASPxClientCommandConsts.INSERTTABLEROWABOVE_COMMAND] = new ASPxHtmlEditorCommands.Tables.Row.Insert(ASPxClientCommandConsts.INSERTTABLEROWABOVE_COMMAND); ASPxHtmlEditorCommandList[ASPxClientCommandConsts.CHANGETABLEROW_COMMAND] = new ASPxHtmlEditorCommands.Tables.Row.Change(ASPxClientCommandConsts.CHANGETABLEROW_COMMAND); ASPxHtmlEditorCommandList[ASPxClientCommandConsts.DELETETABLEROW_COMMAND] = new ASPxHtmlEditorCommands.Tables.Row.Delete(ASPxClientCommandConsts.DELETETABLEROW_COMMAND); ASPxHtmlEditorCommandList[ASPxClientCommandConsts.CHANGETABLECELL_COMMAND] = new ASPxHtmlEditorCommands.Tables.Cell.Change(ASPxClientCommandConsts.CHANGETABLECELL_COMMAND); ASPxHtmlEditorCommandList[ASPxClientCommandConsts.SPLITTABLECELLHORIZONTALLY_COMMAND] = new ASPxHtmlEditorCommands.Tables.Cell.SplitHorizontally(ASPxClientCommandConsts.SPLITTABLECELLHORIZONTALLY_COMMAND); ASPxHtmlEditorCommandList[ASPxClientCommandConsts.SPLITTABLECELLVERTICALLY_COMMAND] = new ASPxHtmlEditorCommands.Tables.Cell.SplitVertically(ASPxClientCommandConsts.SPLITTABLECELLVERTICALLY_COMMAND); ASPxHtmlEditorCommandList[ASPxClientCommandConsts.MERGETABLECELLRIGHT_COMMAND] = new ASPxHtmlEditorCommands.Tables.Cell.MergeRight(ASPxClientCommandConsts.MERGETABLECELLRIGHT_COMMAND); ASPxHtmlEditorCommandList[ASPxClientCommandConsts.MERGETABLECELLDOWN_COMMAND] = new ASPxHtmlEditorCommands.Tables.Cell.MergeDown(ASPxClientCommandConsts.MERGETABLECELLDOWN_COMMAND); ASPxHtmlEditorCommandList[ASPxClientCommandConsts.PASTEFROMWORDDIALOG_COMMAND] = new ASPxHtmlEditorCommands.Dialogs.PasteFromWord(ASPxClientCommandConsts.PASTEFROMWORDDIALOG_COMMAND); ASPxHtmlEditorCommandList[ASPxClientCommandConsts.CHANGEIMAGE_DIALOG_COMMAND] = new ASPxHtmlEditorCommands.Dialogs.ChangeImage(ASPxClientCommandConsts.CHANGEIMAGE_DIALOG_COMMAND); ASPxHtmlEditorCommandList[ASPxClientCommandConsts.INSERTIMAGE_DIALOG_COMMAND] = new ASPxHtmlEditorCommands.DialogCommand(ASPxClientCommandConsts.INSERTIMAGE_DIALOG_COMMAND); ASPxHtmlEditorCommandList[ASPxClientCommandConsts.INSERTLINK_DIALOG_COMMAND] = new ASPxHtmlEditorCommands.DialogCommand(ASPxClientCommandConsts.INSERTLINK_DIALOG_COMMAND); ASPxHtmlEditorCommandList[ASPxClientCommandConsts.CHANGELINK_DIALOG_COMMAND] = new ASPxHtmlEditorCommands.Dialogs.ChangeLink(ASPxClientCommandConsts.CHANGELINK_DIALOG_COMMAND); ASPxHtmlEditorCommandList[ASPxClientCommandConsts.TABLEPROPERTIES_DIALOG_COMMAND] = new ASPxHtmlEditorCommands.Dialogs.ChangeTable(ASPxClientCommandConsts.TABLEPROPERTIES_DIALOG_COMMAND); ASPxHtmlEditorCommandList[ASPxClientCommandConsts.INSERTTABLE_DIALOG_COMMAND] = new ASPxHtmlEditorCommands.DialogCommand(ASPxClientCommandConsts.INSERTTABLE_DIALOG_COMMAND); ASPxHtmlEditorCommandList[ASPxClientCommandConsts.TABLECELLPROPERTIES_DIALOG_COMMAND] = new ASPxHtmlEditorCommands.Dialogs.TableCellProperties(ASPxClientCommandConsts.TABLECELLPROPERTIES_DIALOG_COMMAND); ASPxHtmlEditorCommandList[ASPxClientCommandConsts.TABLECOLUMNPROPERTIES_DIALOG_COMMAND] = new ASPxHtmlEditorCommands.Dialogs.TableCellProperties(ASPxClientCommandConsts.TABLECOLUMNPROPERTIES_DIALOG_COMMAND); ASPxHtmlEditorCommandList[ASPxClientCommandConsts.TABLEROWPROPERTIES_DIALOG_COMMAND] = new ASPxHtmlEditorCommands.Dialogs.TableCellProperties(ASPxClientCommandConsts.TABLEROWPROPERTIES_DIALOG_COMMAND); ASPxHtmlEditorCommandList[ASPxClientCommandConsts.CUSTOMDIALOG_COMMAND] = new ASPxHtmlEditorCommands.Dialogs.CustomDialog(ASPxClientCommandConsts.CUSTOMDIALOG_COMMAND); ASPxHtmlEditorCommandList[ASPxClientCommandConsts.Start_COMMAND] = new ASPxHtmlEditorCommands.Command(ASPxClientCommandConsts.TEXTTYPE_COMMAND); ASPxHtmlEditorCommandList[ASPxClientCommandConsts.SAVESTATEUNDOREDOSTACK_COMMAND] = new ASPxHtmlEditorCommands.Command(ASPxClientCommandConsts.SAVESTATEUNDOREDOSTACK_COMMAND); ASPxHtmlEditorCommandList[ASPxClientCommandConsts.EXPORT_COMMAND] = new ASPxHtmlEditorCommands.SaveAs(ASPxClientCommandConsts.EXPORT_COMMAND); var __aspxEmptySelection = "empty"; CommandManager = _aspxCreateClass(null, { constructor: function(htmlEditor) { this.htmlEditor = htmlEditor; this.commandIdArray = [ ]; this.currentCmdIDIndex = -1; this.lastRestoreSelection = null; this.restoreHtmlArray = [ ]; this.undoSelectionArray = [ ]; this.redoSelectionArray = [ ]; this.ExecuteCommand(ASPxClientCommandConsts.Start_COMMAND, "null", true); }, ExecuteCommand: function(cmdID, cmdValue, addToUndoHistory) { var isSuccessfully = false; if (!ASPxHtmlEditorCommandList[cmdID].IsHtmlChangeable() || !addToUndoHistory) isSuccessfully = ASPxHtmlEditorCommandList[cmdID].Execute(cmdValue, this.htmlEditor); else { this.OnCommandExecuting(cmdID); isSuccessfully = ASPxHtmlEditorCommandList[cmdID].Execute(cmdValue, this.htmlEditor); var needAddToStack = isSuccessfully && ASPxHtmlEditorCommandList[cmdID].IsReversable(); if (needAddToStack) { this.ClearActionsToRedo(); this.currentCmdIDIndex = this.commandIdArray.length; this.commandIdArray.push(cmdID); } this.OnCommandExecuted(needAddToStack); } return isSuccessfully; }, Undo: function(depth) { depth = Math.min(depth, this.commandIdArray.length); var actionCount = this.commandIdArray.length; depth = Math.min(depth, this.commandIdArray.length); while ((depth > 0) && (this.currentCmdIDIndex > 0) && (this.currentCmdIDIndex < actionCount)) { this.htmlEditor.SetInnerHtmlToBody(this.htmlEditor.GetDesignViewIFrameDocumentBody(), this.GetRestoreText(this.currentCmdIDIndex - 1)); this.GetUndoSelection(this.currentCmdIDIndex - 1).Restore(); this.currentCmdIDIndex--; depth--; } return true; }, Redo: function(depth) { depth = Math.min(depth, this.commandIdArray.length); var actionIndex = this.currentCmdIDIndex + 1; while (depth > 0 && this.commandIdArray.length >= actionIndex) { this.htmlEditor.SetInnerHtmlToBody(this.htmlEditor.GetDesignViewIFrameDocumentBody(), this.GetRestoreText(actionIndex)); this.GetRedoSelection(actionIndex).Restore(); this.currentCmdIDIndex = actionIndex; actionIndex++; depth--; } return true; }, OnCommandExecuting: function(cmdID) { if (this.IsUndoRedoCommand(cmdID) && _aspxIsExists(this.commandIdArray[this.currentCmdIDIndex + 1])) return; if (_aspxIsExists(this.commandIdArray[this.currentCmdIDIndex])) { var prevActionUndoSelection = this.htmlEditor.SaveLastSelection(); if (this.IsLastCommandImmediateExecute()) { this.AddNewItemToArray(this.restoreHtmlArray, this.currentCmdIDIndex, this.lastHTML); this.UpdateOrAddNewItemToArray(this.undoSelectionArray, this.currentCmdIDIndex, prevActionUndoSelection); this.AddNewItemToArray(this.redoSelectionArray, this.currentCmdIDIndex, _aspxCloneObject(this.lastRestoreSelection)); } else this.undoSelectionArray[this.currentCmdIDIndex] = prevActionUndoSelection; } }, OnCommandExecuted: function(needAddToStack) { var lastCmdID = this.GetLastCommandID(); if (needAddToStack && !ASPxHtmlEditorCommandList[lastCmdID].IsImmediateExecution()) { this.AddNewItemToArray(this.restoreHtmlArray, this.currentCmdIDIndex, this.GetEditorHtml()); this.AddNewItemToArray(this.undoSelectionArray, this.currentCmdIDIndex, __aspxEmptySelection); try { var selection = lastCmdID == ASPxClientCommandConsts.Start_COMMAND ? __aspxEmptySelection : this.htmlEditor.SaveLastSelection(); } catch(e) { var selection = __aspxEmptySelection; } this.AddNewItemToArray(this.redoSelectionArray, this.currentCmdIDIndex, selection); } }, ClearActionsToRedo: function() { if (this.IsRedoAvailable()) { this.lastRestoreSelection = null; var startIndex = this.currentCmdIDIndex + 1; var length = this.commandIdArray.length - this.currentCmdIDIndex; this.commandIdArray.splice(startIndex, length); this.restoreHtmlArray.splice(startIndex, length); this.undoSelectionArray.splice(startIndex, length); this.redoSelectionArray.splice(startIndex, length); } }, ClearUndoHistory: function() { this.lastRestoreSelection = null; this.currentCmdIDIndex = -1; this.commandIdArray.length = 0; this.commandIdArray.length = 0; this.restoreHtmlArray.length = 0; this.undoSelectionArray.length = 0; this.redoSelectionArray.length = 0; this.ExecuteCommand(ASPxClientCommandConsts.Start_COMMAND, "null", true); }, CleanEmptyRestoreHtml: function() { if (this.GetEditorHtml() == this.lastHTML) { _aspxArrayRemoveAt(this.commandIdArray, this.currentCmdIDIndex); this.currentCmdIDIndex = this.commandIdArray.length - 1; return true; } return false; }, GetEditorHtml: function() { return this.htmlEditor.GetHtmlInternal(); }, GetRestoreText: function(index) { return this.restoreHtmlArray[index]; }, GetRedoSelection: function(index) { return this.redoSelectionArray[index]; }, GetUndoSelection: function(index) { return this.undoSelectionArray[index]; }, IsRedoAvailable: function() { return (this.commandIdArray.length - 1 > this.currentCmdIDIndex); }, IsUndoAvailable: function() { return this.currentCmdIDIndex > 0; }, UpdateLastRestoreSelectionAndHTML: function() { if (this.lastRestoreSelection == null) this.lastRestoreSelection = ASPxClientHtmlEditorSelection.Create(this.htmlEditor); this.lastRestoreSelection.Save(); this.UpdateLastRestoreHtml(); }, UpdateLastRestoreHtml: function() { this.lastHTML = this.GetEditorHtml(); }, UpdateLastItemInRestoreHtmlArray: function() { this.restoreHtmlArray[this.restoreHtmlArray.length - 1] = this.GetEditorHtml(); }, IsLastCommandImmediateExecute: function() { var lastCmdID = this.GetLastCommandID(); var isImmediateExecution = ASPxHtmlEditorCommandList[lastCmdID].IsImmediateExecution(); return (lastCmdID != null) && isImmediateExecution && (this.currentCmdIDIndex == this.commandIdArray.length - 1); }, IsDeleting: function() { var lastCmdID = this.GetLastCommandID(); return (lastCmdID != null) && (lastCmdID == ASPxClientCommandConsts.KBDELETE_COMMAND) && (this.currentCmdIDIndex == this.commandIdArray.length - 1); }, IsUndoRedoCommand: function(cmdID) { return (cmdID == ASPxClientCommandConsts.REDO_COMMAND) || (cmdID == ASPxClientCommandConsts.UNDO_COMMAND); }, GetLastCommandID: function() { var curAction = this.commandIdArray[this.currentCmdIDIndex]; return _aspxIsExists(curAction) ? curAction : null; }, AddNewItemToArray: function(array, index, value) { if (!_aspxIsExists(array[index])) array.push(value); }, UpdateOrAddNewItemToArray: function(array, index, value) { if (!_aspxIsExists(array[index])) array.push(value); else if (array[index] == __aspxEmptySelection) array[index] = value; } }); ASPxHtmlEditorKeyboardManager = _aspxCreateClass(null, { constructor: function() { this.shortcutCommands = [ ]; }, AddShortcut: function(shortcutString, commandID) { var shortcutCode = _aspxParseShortcutString(shortcutString); this.shortcutCommands[shortcutCode] = commandID; }, GetShortcutCommand: function(evt) { var shortcutCode = _aspxGetShortcutCode(evt.keyCode, evt.ctrlKey, evt.shiftKey, evt.altKey); return this.shortcutCommands[shortcutCode]; }, IsBrowserShortcut: function(evt) { if(__aspxWebKitFamily || __aspxIE) { var shortcutCode = _aspxGetShortcutCode(evt.keyCode, evt.ctrlKey, evt.shiftKey, evt.altKey); return _aspxArrayIndexOf(ASPxHtmlEditorKeyboardManager.BrowserShortcuts, shortcutCode) > -1; } }, GetKeyDownInfo: function(evt) { return { isSystemKey: ASPxHtmlEditorKeyboardManager.IsSystemKey(evt.keyCode), isDeleteOrBackSpaceKey: ASPxHtmlEditorKeyboardManager.IsDeleteOrBackSpaceKey(evt.keyCode), isBackSpaceKey: ASPxHtmlEditorKeyboardManager.IsBackSpaceKey(evt.keyCode), isSpaceKey: ASPxHtmlEditorKeyboardManager.IsSpaceKey(evt.keyCode), isCursorMovingKey: ASPxHtmlEditorKeyboardManager.IsCursorMovingKey(evt.keyCode) }; } }); ASPxHtmlEditorKeyboardManager.Shortcuts = [ [ASPxClientCommandConsts.BOLD_COMMAND, "CTRL+B"], [ASPxClientCommandConsts.ITALIC_COMMAND, "CTRL+I"], [ASPxClientCommandConsts.UNDERLINE_COMMAND, "CTRL+U"], [ASPxClientCommandConsts.JUSTIFYLEFT_COMMAND, "CTRL+L"], [ASPxClientCommandConsts.JUSTIFYCENTER_COMMAND, "CTRL+E"], [ASPxClientCommandConsts.JUSTIFYRIGHT_COMMAND, "CTRL+R"], [ASPxClientCommandConsts.JUSTIFYFULL_COMMAND, "CTRL+J"], [ASPxClientCommandConsts.UNDO_COMMAND, "CTRL+Z"], [ASPxClientCommandConsts.REDO_COMMAND, "CTRL+Y"], [ASPxClientCommandConsts.INSERTLINK_DIALOG_COMMAND, "CTRL+K"], [ASPxClientCommandConsts.INSERTIMAGE_DIALOG_COMMAND, "CTRL+G"], [ASPxClientCommandConsts.UNLINK_COMMAND, "CTRL+SHIFT+K"], [ASPxClientCommandConsts.PRINT_COMMAND, "CTRL+P"], [ASPxClientCommandConsts.FULLSCREEN_COMMAND, "F11"], [ASPxClientCommandConsts.NEWPARAGRAPHTYPE_COMMAND, "CTRL+ENTER"], [ASPxClientCommandConsts.LINEBREAKETYPE_COMMAND, "SHIFT+ENTER"], [ASPxClientCommandConsts.ENTER_COMMAND, "ENTER"], [ASPxClientCommandConsts.SELECT_ALL, "CTRL+A"], [ASPxClientCommandConsts.KBCUT_COMMAND, "CTRL+X"], [ASPxClientCommandConsts.KBCUT_COMMAND, "SHIFT+DELETE"], [ASPxClientCommandConsts.KBCOPY_COMMAND, "CTRL+C"], [ASPxClientCommandConsts.KBCOPY_COMMAND, "CTRL+INSERT"], [ASPxClientCommandConsts.KBPASTE_COMMAND, "CTRL+V"], [ASPxClientCommandConsts.KBPASTE_COMMAND, "SHIFT+INSERT"] ]; ASPxHtmlEditorKeyboardManager.BrowserShortcuts = [ _aspxParseShortcutString("CTRL+B"), _aspxParseShortcutString("CTRL+I"), _aspxParseShortcutString("CTRL+U"), _aspxParseShortcutString("CTRL+Z"), _aspxParseShortcutString("CTRL+Y") ]; ASPxHtmlEditorKeyboardManager.IsSystemKey = function(keyCode) { return keyCode == 0 || keyCode >= ASPxKey.F1 && keyCode <= ASPxKey.F12 || keyCode >= ASPxKey.Backspace && keyCode <= ASPxKey.Esc || keyCode >= ASPxKey.Space && keyCode <= ASPxKey.Delete || keyCode == ASPxKey.ContextMenu; }; ASPxHtmlEditorKeyboardManager.IsDeleteOrBackSpaceKey = function(keyCode) { return keyCode == ASPxKey.Delete || keyCode == ASPxKey.Backspace; }; ASPxHtmlEditorKeyboardManager.IsBackSpaceKey = function(keyCode) { return keyCode == ASPxKey.Backspace; }; ASPxHtmlEditorKeyboardManager.IsSpaceKey = function(keyCode) { return keyCode == ASPxKey.Space; }; ASPxHtmlEditorKeyboardManager.IsCursorMovingKey = function(keyCode) { return keyCode >= ASPxKey.PageUp && keyCode <= ASPxKey.Down; }; } /* playback timings (ms): captures_list: 148.807 exclusion.robots: 0.092 exclusion.robots.policy: 0.085 RedisCDXSource: 2.7 esindex: 0.008 LoadShardBlock: 127.461 (3) PetaboxLoader3.datanode: 140.0 (4) CDXLines.iter: 16.415 (3) load_resource: 161.922 PetaboxLoader3.resolve: 59.159 */