1(function() { 2 ASPx.HtmlEditorClasses.Commands.Browser = { }; 3 ASPx.HEBlockElements = { 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, hr:1 }; 4 ASPx.HEPathBlockElements = { 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 }; 5 ASPx.HEPathBlockLimitElements = { html:1, body: 1, form: 1, div:1, table:1, tbody:1, tr:1, td:1, th:1, li:1, caption:1 }; 6 ASPx.HEBogusSymbol = "\u200B"; 7 ASPx.HESafariBogusSymbol = "\u200D"; 8 ASPx.IsEmptyHtml = function(html){ 9 var html = ASPx.Str.Trim(html); 10 return html == "" || html == " " || html == "<P> </P>"; 11 }; 12 ASPx.HtmlEditorClasses.Commands.Browser.Command = ASPx.CreateClass(ASPx.HtmlEditorClasses.Commands.Command, { 13 Execute: function(cmdValue, wrapper) { 14 ASPx.HtmlEditorClasses.Commands.Command.prototype.Execute.apply(this, arguments); 15 var contentAreaDoc = wrapper.getDocument(); 16 if (!this.NeedUseCss()) 17 contentAreaDoc.execCommand(this.GetUseCSSCommandName(), false, false); 18 if(!wrapper.isSelectionRestored()) { 19 if(ASPx.Browser.Opera) 20 wrapper.focus(); 21 else 22 wrapper.restoreSelection(); 23 } 24 var isSuccessfully = contentAreaDoc.execCommand(this.GetCommandName(), false, this.GetCorrectedValue(cmdValue)); 25 if (!this.NeedUseCss()) 26 contentAreaDoc.execCommand(this.GetUseCSSCommandName(), false, true); 27 if(isSuccessfully) { 28 wrapper.saveSelection(); 29 if((ASPx.Browser.WebKitTouchUI || ASPx.Browser.MSTouchUI) && !wrapper.isInFocus) 30 wrapper.eventManager.setLockUpdate(true); 31 setTimeout(function() { 32 if(!wrapper.isSelectionRestored()) 33 wrapper.restoreSelection(); 34 }.aspxBind(this), 300); 35 } 36 return isSuccessfully; 37 }, 38 afterExecute: function (cmdValue, wrapper, isSuccessfull) { 39 if (isSuccessfull && this.IsHtmlChangeable()) { 40 var selection = wrapper.getSelection(); 41 if (!selection.IsCollapsed()) { 42 selection.Change(function (doc, start, end) { 43 var helper = ASPx.HtmlEditorClasses.Utils.ElementsSelectionHelper; 44 var parent = helper.FindCommonAncestor(helper.GetAncestorsChain(start), helper.GetAncestorsChain(end)); 45 if(!helper.isRelativeContainer(parent) && helper.IsContentStartsWithElement(parent, start) && helper.IsContentEndsWithElement(parent, end)) { 46 parent = helper.FindParentWithSameSelectionBounds(parent); 47 var container = doc.createElement(parent.tagName); 48 ASPx.InsertElementAfter(container, parent); 49 container.appendChild(start); 50 container.appendChild(parent); 51 container.appendChild(end); 52 ASPx.HtmlEditorClasses.HtmlProcessor.clearExcessStyleToElement(container, true); 53 ASPx.HtmlEditorClasses.unwrapContent(container); 54 } 55 }); 56 } 57 } 58 }, 59 GetCommandName: function() { 60 return this.commandID; 61 }, 62 GetCorrectedValue: function(value) { 63 return value; 64 }, 65 GetState: function(wrapper, selection, selectedElements) { 66 var ret = true; 67 if (!this.IsAlwaysEnabledCommand(this.commandID)) { 68 try { 69 ret = this.TryGetState(wrapper); 70 } 71 catch(ex) { ret = false; } 72 } 73 return ret; 74 }, 75 GetValue: function(wrapper, selection, selectedElements) { 76 var ret = null; 77 try { 78 ret = this.TryGetValue(wrapper); 79 } 80 catch(e) {} 81 return !ret ? null : ret; 82 }, 83 GetUseCSSCommandName: function(doc) { 84 return ASPx.Browser.NetscapeFamily ? "styleWithCSS" : "useCSS"; 85 }, 86 IsLocked: function(wrapper) { 87 var ret = this.TryGetIsLocked(wrapper); 88 if (ASPx.Browser.Opera && ret) { 89 try { 90 ret = !this.TryGetState(wrapper); 91 } 92 catch(ex) { ret = false; } 93 } 94 return ret; 95 }, 96 TryGetState: function(wrapper) { 97 return wrapper.getDocument().queryCommandState(this.GetCommandName()); 98 }, 99 TryGetValue: function(wrapper) { 100 return wrapper.getDocument().queryCommandValue(this.GetCommandName()); 101 }, 102 TryGetIsLocked: function(wrapper) { 103 try { 104 return !wrapper.getDocument().queryCommandEnabled(this.GetCommandName()); 105 } catch(e) {} 106 return true; 107 }, 108 IsAlwaysEnabledCommand: function(commandID) { 109 return this.commandID == ASPxClientCommandConsts.FONTSIZE_COMMAND || this.commandID == ASPxClientCommandConsts.FONTNAME_COMMAND; 110 }, 111 NeedUseCss: function() { 112 return true; 113 } 114 }); 115 ASPx.HtmlEditorClasses.Commands.SelectionManipulationCommand = ASPx.CreateClass(ASPx.HtmlEditorClasses.Commands.Command, { 116 Execute: function(cmdValue, wrapper) { 117 this.newElements = []; 118 if(ASPx.Browser.IE && ASPx.Browser.MajorVersion > 8) 119 wrapper.restoreSelection(); 120 }, 121 WrapElementInternal: function(target, wrapper) { 122 var inline = ASPx.HtmlEditorClasses.Commands.Utils.IsInlineTextElement(wrapper); 123 if((inline || this.IsNewElement(target.previousSibling)) && target.previousSibling && this.CanMerge(target.previousSibling, wrapper)) {
124 target.previousSibling.appendChild(target); 125 return target.previousSibling; 126 } 127 else if ((inline || this.IsNewElement(target.nextSibling)) && target.nextSibling && this.CanMerge(target.nextSibling, wrapper)) { 128 target.nextSibling.insertBefore(target, target.nextSibling.firstChild); 129 return target.nextSibling; 130 } 131 else { 132 target.parentNode.insertBefore(wrapper, target); 133 wrapper.appendChild(target); 134 this.newElements.push(wrapper); 135 return wrapper; 136 } 137 }, 138 IsNewElement: function(target) { 139 for(var i = 0, el; el = this.newElements[i]; i++) { 140 if(target == el) 141 return true; 142 } 143 return false; 144 }, 145 CanMerge: function(el1, el2) { 146 return el1.tagName == el2.tagName && el1.className == el2.className && !this.isBlockElement(el1) && !this.isBlockElement(el2); 147 }, 148 SeparateParentByPredicate: function(target, predicate) { 149 while(target && predicate(target) && this.SeparateParent(target, target.parentNode.className, false)) { 150 target = target.parentNode; 151 } 152 return target; 153 }, 154 SeparateParent: function(target, className, tryMerge) { 155 var parent = target.parentNode; 156 if(!parent || parent.tagName == "BODY") 157 return false; 158 if(target.previousSibling) { 159 var prevParent = parent.previousSibling; 160 if(!prevParent || prevParent.tagName != parent.tagName || prevParent.className != parent.className || this.isBlockElement(prevParent)) { 161 prevParent = parent.cloneNode(false); 162 parent.parentNode.insertBefore(prevParent, parent); 163 } 164 for(var child = parent.firstChild; child && child != target; child = parent.firstChild) { 165 prevParent.appendChild(child); 166 } 167 } 168 if(target.nextSibling) { 169 var nextParent = parent.nextSibling; 170 if(!nextParent || nextParent.tagName != parent.tagName || nextParent.className != parent.className || this.isBlockElement(nextParent)) { 171 nextParent = parent.cloneNode(false); 172 ASPx.InsertElementAfter(nextParent, parent); 173 } 174 for(var child = parent.lastChild; child && child != target; child = parent.lastChild) { 175 nextParent.insertBefore(child, nextParent.firstChild); 176 } 177 } 178 this.SetClassName(parent, className); 179 if(tryMerge && parent.previousSibling && this.CanMerge(parent, parent.previousSibling)) { 180 parent.previousSibling.appendChild(target); 181 ASPx.RemoveElement(parent); 182 } 183 else if(tryMerge && parent.nextSibling && this.CanMerge(parent, parent.nextSibling)) { 184 parent.nextSibling.insertBefore(target, parent.nextSibling.firstChild); 185 ASPx.RemoveElement(parent); 186 } 187 return true; 188 }, 189 SetClassName: function(target, className) { 190 if(!className) 191 ASPx.Attr.RemoveAttribute(target, !ASPx.Browser.IE || ASPx.Browser.Version >= 8 ? "class" : "className"); 192 else 193 target.className = className; 194 }, 195 isBlockElement: function(element) { 196 return element.nodeType == 1 && element.innerHTML && ASPx.GetCurrentStyle(element)["display"] == "block"; 197 } 198 }); 199})(); 200
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.