1// Name: HTMLEditor.Toolbar_buttons.RemoveStyles.debug.js 2// Assembly: AjaxControlToolkit 3// Version: 3.5.7.1213 4// FileVersion: 3.5.7.1213 5Type.registerNamespace("Sys.Extended.UI.HTMLEditor.ToolbarButton"); 6 7Sys.Extended.UI.HTMLEditor.ToolbarButton.RemoveStyles = function(element) { 8 Sys.Extended.UI.HTMLEditor.ToolbarButton.RemoveStyles.initializeBase(this, [element]); 9} 10 11Sys.Extended.UI.HTMLEditor.ToolbarButton.RemoveStyles.prototype = { 12 callMethod : function() { 13 if(!Sys.Extended.UI.HTMLEditor.ToolbarButton.RemoveStyles.callBaseMethod(this, "callMethod")) return false; 14 var editor = this._designPanel; 15 16 setTimeout(function() { 17 var selectedHTML = (!Sys.Extended.UI.HTMLEditor.isIE)?Sys.Extended.UI.HTMLEditor.Trim(editor.getSelectedHTML()):""; 18 var sel = editor._getSelection(); 19 var range = editor._createRange(sel); 20 var rng = null; 21 var expanded = false; 22 23 if(!editor.isControl() && ((Sys.Extended.UI.HTMLEditor.isIE && range.text.length>0) || (!Sys.Extended.UI.HTMLEditor.isIE && selectedHTML.length > 0))) { 24 rng=editor._getTextNodeCollection(); 25 } else { 26 rng = editor._tryExpand(); 27 expanded = true; 28 } 29 30 if(rng != null && rng.length > 0) { 31 var changed=false; // document tree changing indicator 32 var _found =true; // style tag deleting indicator 33 var _text=null; 34 35 editor._saveContent(); // for undo 36 37 var span1 = editor._doc.createElement("span"); 38 span1.id = "_left_"; 39 var span2 = editor._doc.createElement("span"); 40 span2.id = "_right_"; 41 42 var par1 = rng[0].parentNode; 43 var par2 = rng[rng.length-1].parentNode; 44 45 par1.insertBefore(span1,rng[0]); 46 47 if(rng[rng.length-1].nextSibling) 48 par2.insertBefore(span2,rng[rng.length-1].nextSibling); 49 else 50 par2.appendChild(span2); 51 52 while(_found) { // while there were tags' deletings 53 _found =false; // reset the indicator 54 for(var i=0; i< rng.length; i++) { // inspect all TextNodes 55 var par = rng[i].parentNode; 56 57 if(par) { 58 if(rng[i].previousSibling == null && rng[i].nextSibling == null) { 59 var tag = par.tagName.toUpperCase(); 60 61 if( Sys.Extended.UI.HTMLEditor.isStyleTag(tag) && (tag != "A") && (par.className != Sys.Extended.UI.HTMLEditor.smartClassName || tag.substr(0,1) == "H") ) { 62 var _attrs = Sys.Extended.UI.HTMLEditor.differAttr(par,["class","color","face","size"]); 63 64 changed=true; 65 66 if(_attrs.length==0) { 67 var parent=par.parentNode; 68 var el = (par.firstChild)?par.firstChild:null; 69 var P = null; 70 71 if(tag.toUpperCase().substr(0,1) == "H" && (Sys.Extended.UI.HTMLEditor.isIE)) { 72 P = editor._doc.createElement("p"); 73 P.className = Sys.Extended.UI.HTMLEditor.smartClassName; 74 75 parent.insertBefore(P,par); 76 77 while(par.firstChild) { // chieldren moving 78 P.appendChild(par.firstChild); 79 } 80 } else { 81 while(par.firstChild){ // chieldren moving 82 parent.insertBefore(par.firstChild,par); 83 } 84 85 if(tag.toUpperCase().substr(0,1) == "H") { 86 var br = editor._doc.createElement("br"); 87 parent.insertBefore(br,par); 88 } 89 } 90 91 parent.removeChild(par); 92 _found=true; // set indicator 93 } else { // we can't remove the tag - cleaning only 94 var parent=par.parentNode; 95 96 var nel =editor._doc.createElement(tag); 97 for(var j=0; j<_attrs.length; j++) { 98 nel.setAttribute(_attrs[j][0], _attrs[j][1]); 99 } 100 101 102 parent.insertBefore(nel,par); 103 while(par.firstChild) { 104 nel.appendChild(par.firstChild); 105 } 106 parent.removeChild(par); 107 } 108 } 109 } 110 } 111 } 112 } 113 114 for(var i=0; i< rng.length; i++) { // inspect all TextNodes 115 var el = rng[i]; 116 var _prn = (rng[i].parentNode != null && typeof rng[i].parentNode != "undefined")?rng[i].parentNode:null; 117 118 if(_prn) { 119 120 var _fnd = null; 121 122 while (_prn && _prn.tagName && _prn.tagName.toUpperCase() != "BODY" && Sys.Extended.UI.HTMLEditor.isStyleTag(_prn.tagName) && (_prn.tagName.toUpperCase() != "A") 123 && Sys.Extended.UI.HTMLEditor.differAttr(_prn,["class","color","face","size"]).length == 0 124 ) { 125 _fnd = _prn; 126 _prn = _prn.parentNode; 127 } 128 129 130 if(_fnd) { 131 changed=true; 132 133 function diver(add,el, rpr, before) { 134 var par=rpr.cloneNode(false); 135 136 if(add) { 137 if(add.push && typeof add.push == "function") { 138 for(var iii=0; iii < add.length; iii++) { 139 par.appendChild(add[iii]); 140 } 141 } else 142 par.appendChild(add); 143 } 144 145 while(el) { 146 var elSibling=before?el.previousSibling:el.nextSibling;
147 if(el.nodeType==1 || (el.nodeType==3 && Sys.Extended.UI.HTMLEditor.Trim(""+el.data+"").length>0)) { 148 if(el.nodeType==1) { 149 if(Sys.Extended.UI.HTMLEditor.isStyleTag(el.tagName) && (el.tagName.toUpperCase() != "A") && (!el.id || (el.id != "_left_" && el.id != "_right_"))) { 150 Sys.Extended.UI.HTMLEditor.spanJoiner(el); 151 } 152 153 if(Sys.Extended.UI.HTMLEditor.isStyleTag(el.tagName) && el.childNodes.length==0 && (!el.id || (el.id != "_left_" && el.id != "_right_"))) { 154 el=null; 155 } 156 } 157 if(el) { 158 if(par.childNodes.length == 0 || !before) 159 par.appendChild(el); 160 else 161 par.insertBefore(el,par.firstChild); 162 } 163 } 164 el=elSibling; 165 } 166 167 if(par.childNodes.length==0) { 168 delete par; 169 par=null; 170 } else if(par.childNodes.length==1 && par.firstChild.nodeType==3 && (""+par.firstChild.data+"").length==0) { 171 delete par; 172 par=null; 173 } else { 174 if(Sys.Extended.UI.HTMLEditor.isStyleTag(par.tagName)) { 175 var elNumber = par.childNodes.length; 176 for(var cnt=0; cnt< par.childNodes.length; cnt++) { 177 var inn = par.childNodes.item(cnt); 178 if(inn.nodeType==1 && !Sys.Extended.UI.HTMLEditor.isStyleTag(inn.tagName)) elNumber--; 179 } 180 181 if(elNumber == 0) { 182 var parr = []; 183 while(par.firstChild) { 184 var inn = par.removeChild(par.firstChild); 185 parr.push(inn); 186 } 187 par = parr; 188 } 189 } 190 } 191 192 if(rpr==_fnd) 193 return par; 194 else 195 return diver(par,before?rpr.previousSibling:rpr.nextSibling,rpr.parentNode,before); 196 }; 197 198 _prn = el.parentNode; 199 200 if ( el.previousSibling == null && el.nextSibling == null && 201 _prn && _prn.tagName && _prn.tagName.toUpperCase() != "BODY" && Sys.Extended.UI.HTMLEditor.isStyleTag(_prn.tagName) && 202 Sys.Extended.UI.HTMLEditor.differAttr(_prn,["class","color","face","size"]).length > 0 203 ) 204 el = _prn; 205 206 207 var p1 = diver(null,el.previousSibling,el.parentNode,true ); 208 var p2 = diver(null,el.nextSibling ,el.parentNode,false); 209 210 var par = _fnd.parentNode; 211 if(p1) { 212 if(p1.push && typeof p1.push == "function") { 213 for(var iii=0; iii < p1.length; iii++) { 214 par.insertBefore(p1[iii],_fnd); 215 } 216 } else { 217 par.insertBefore(p1,_fnd); 218 } 219 220 if(Sys.Extended.UI.HTMLEditor.isIE) { 221 span1 = editor._doc.getElementById("_left_"); 222 span2 = editor._doc.getElementById("_right_"); 223 } 224 } 225 par.insertBefore(el,_fnd); 226 if(p2) { 227 if(p2.push && typeof p2.push == "function") { 228 for(var iii=0; iii < p2.length; iii++) { 229 par.insertBefore(p2[iii],_fnd); 230 } 231 } else { 232 par.insertBefore(p2,_fnd); 233 } 234 235 if(Sys.Extended.UI.HTMLEditor.isIE) { 236 span1 = editor._doc.getElementById("_left_"); 237 span2 = editor._doc.getElementById("_right_"); 238 } 239 } 240 par.removeChild (_fnd); 241 } 242 } 243 } 244 245 if(expanded) { 246 if(Sys.Extended.UI.HTMLEditor.isIE && editor.__saveBM__ != null) { 247 try { 248 var ppp = span1.parentNode; 249 ppp.removeChild(span1); 250 while(ppp && ppp.childNodes.length==0) { 251 ppp.parentNode.removeChild(ppp); 252 ppp = ppp.parentNode; 253 } 254 255 ppp = span2.parentNode; 256 ppp.removeChild(span2); 257 while(ppp && ppp.childNodes.length==0) { 258 ppp.parentNode.removeChild(ppp); 259 ppp = ppp.parentNode; 260 } 261 span1 = null; 262 span2 = null; 263 } catch(e){} 264 265 var sel = editor._getSelection(); 266 var range = editor._createRange(sel); 267 range.moveToBookmark(editor.__saveBM__); 268 range.select(); 269 editor.__saveBM__ = null; 270 } else if(editor.__saveBM__ != null) { 271 if(editor.__saveBM__[0].nodeType==3) { 272 var sel = editor._getSelection(); 273 var range = editor._doc.createRange(); 274 range.setStart(editor.__saveBM__[0],editor.__saveBM__[1]); 275 range.setEnd (editor.__saveBM__[0],editor.__saveBM__[1]); 276 editor._removeAllRanges(sel); 277 editor._selectRange(sel,range); 278 } else { 279 editor._trySelect(editor.__saveBM__[0],editor.__saveBM__[0]); 280 editor.__saveBM__[0].parentNode.removeChild(editor.__saveBM__[0]); 281 } 282 editor.__saveBM__ = null; 283 } 284 } else if(!Sys.Extended.UI.HTMLEditor.isIE) { 285 rng = []; 286 var _found = false; 287 288 function _diver(_point,prize) { 289 while(_point) { 290 if(_point == span2) { 291 _found=true; 292 return; 293 } 294 295 if(_point.nodeType==3) { 296 while(_point.nextSibling && _point.nextSibling.nodeType==3) { 297 _point.data= ""+_point.data+""+_point.nextSibling.data+""; 298 _point.parentNode.removeChild(_point.nextSibling); 299 } 300 if(Sys.Extended.UI.HTMLEditor.Trim(""+_point.data+"").length>0) rng.push(_point); 301 } else 302 _diver(_point.firstChild,false); 303 304 if(_found) return; 305 306 var _save= _point.parentNode; 307 308 if(prize) { 309 while(_point && _point.nextSibling==null) { 310 _point=_point.parentNode; 311 } 312 } 313 314 _point = _point.nextSibling; 315 } 316 } 317 318 _diver(span1,true); 319 320 range = editor._doc.createRange(); 321 range.setStart(rng[0],0); 322 range.setEnd (rng[rng.length-1],(""+rng[rng.length-1].data+"").length); 323 324 editor._removeAllRanges(sel); 325 editor._selectRange(sel,range); 326 } else { 327 try { 328 sel = editor._getSelection(); 329 var range1= editor._createRange(sel); 330 var range2= editor._createRange(sel); 331 332 range1.moveToElementText(span1); 333 range2.moveToElementText(span2); 334 335 range1.setEndPoint("EndToEnd", range2); 336 range1.select(); 337 } catch(e){} 338 } 339 340 try { 341 var ppp; 342 if(span1 != null) { 343 ppp = span1.parentNode; 344 ppp.removeChild(span1); 345 while(ppp && ppp.childNodes.length==0) { 346 ppp.parentNode.removeChild(ppp); 347 ppp = ppp.parentNode; 348 } 349 } 350 if(span2 != null) { 351 ppp = span2.parentNode; 352 ppp.removeChild(span2); 353 while(ppp && ppp.childNodes.length==0) { 354 ppp.parentNode.removeChild(ppp); 355 ppp = ppp.parentNode; 356 } 357 } 358 } 359 catch(e){} 360 editor.onContentChanged(); 361 editor._editPanel.updateToolbar(); 362 } 363 },0); 364 } 365} 366 367Sys.Extended.UI.HTMLEditor.ToolbarButton.RemoveStyles.registerClass("Sys.Extended.UI.HTMLEditor.ToolbarButton.RemoveStyles", Sys.Extended.UI.HTMLEditor.ToolbarButton.MethodButton); 368
369if(typeof(Sys)!=='undefined')Sys.Application.notifyScriptLoaded();
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.