Files
SIG/Scripts/AjaxControlToolkit/Release/HtmlEditor.DesignPanelEventHandler.js
2024-11-05 10:47:20 -07:00

1 line
22 KiB
JavaScript

Type.registerNamespace("Sys.Extended.UI.HtmlEditor"),Sys.Extended.UI.HtmlEditor.DesignPanelEventHandler=function(e){function t(){var e=i._createRange(i._getSelection()),t=e.parentElement();if(t&&1==t.nodeType&&"P"==t.tagName.toUpperCase()){for(;t.firstChild;)t.parentNode.insertBefore(t.firstChild,t);t.parentNode.removeChild(t)}}function n(){R=i._createRange(i._getSelection());for(var e=R.parentElement();e&&e.tagName&&"BODY"!=e.tagName.toUpperCase()&&Sys.Extended.UI.HtmlEditor.isStyleTag(e.tagName);)e=e.parentNode;if(e&&1==e.nodeType&&"P"==e.tagName.toUpperCase()){for(var t=i._doc.createElement("span"),n=i._doc.createTextNode(" "),d=e;null!=d.firstChild&&1==d.firstChild.nodeType;)d=d.firstChild;if(1==d.nodeType)for(d.appendChild(n),d.appendChild(t);e.firstChild;)e.parentNode.insertBefore(e.firstChild,e);else e.parentNode.insertBefore(n,e),e.parentNode.insertBefore(t,e);e.parentNode.removeChild(e),R.moveToElementText(t),R.select(),t.parentNode.removeChild(t),i.onContentChanged()}}function d(){var e=i._getSelection(),t=i._createRange(e);null!=V&&(V.innerHTML="&nbsp;",t.moveToElementText(V),t.select(),V.parentNode.insertBefore(V.firstChild,V),V.parentNode.removeChild(V),i.onContentChanged())}function o(){if(i._editPanel==Sys.Extended.UI.HtmlEditor.LastFocusedEditPanel)try{if(Sys.Extended.UI.HtmlEditor.isIE){try{i._doc.selection}catch(e){return!1}if("None"==i._getSelection().type&&0==i._doc.queryCommandValue("backcolor")&&0==i._doc.queryCommandValue("forecolor")&&(i._updateTimerLimit--,i._updateTimerLimit>0))return void(i._updateTimer=setTimeout(o,100))}i._updated_now=!0,i._editPanel.updateToolbar(),i._updated_now=!1,i._updateTimer=null,Sys.Extended.UI.HtmlEditor.isIE||i.focusEditor()}catch(e){}}try{var i=this;if(i._editPanel!=Sys.Extended.UI.HtmlEditor.LastFocusedEditPanel)return!0;if(Sys.Extended.UI.HtmlEditor.isIE)try{var r=this._doc.selection,s=this._createRange(r)}catch(t){return Sys.Extended.UI.HtmlEditor._stopEvent(e),!1}if("mousedown"!=e.type&&"dblclick"!=e.type||this._focus(!0),!Sys.Extended.UI.HtmlEditor.isIE&&"keydown"==e.type&&e.keyCode==Sys.UI.Key.tab&&this._editPanel.get_suppressTabInDesignMode())return Sys.Extended.UI.HtmlEditor.LastFocusedEditPanel=null,!0;if(this.isPopup())return Sys.Extended.UI.HtmlEditor._stopEvent(e),!1;var a=!1;if(i._contextElement&&null!=i._contextElement){if(Function.createDelegate(this,Sys.Extended.UI.HtmlEditor.RemoveContextMenu)(),"keydown"==e.type||"keypress"==e.type)return void Sys.Extended.UI.HtmlEditor._stopEvent(e);a=!0}if("function"==typeof i.captureInDesign&&i.captureInDesign(e)===!1)return void Sys.Extended.UI.HtmlEditor._stopEvent(e);if(Sys.Extended.UI.HtmlEditor.isIE&&"mousedown"==e.type&&e.ctrlKey){var l=i._getSelection(),E=e.clientX,y=e.clientY;return setTimeout(function(){var e=i._getSelection();if("control"!=e.type.toLowerCase()){var t=i._doc.body.createTextRange();t.moveToPoint(E,y),t.select()}e=i._getSelection();for(var t=i._createRange(e),n=Sys.Extended.UI.HtmlEditor.getSelParent(i);null!=n&&"BODY"!=n.tagName.toUpperCase();){if("A"==n.tagName.toUpperCase()&&null!=n.href&&"undefined"!=typeof n.href&&n.href.length>0){window.open(n.href,"LinkViewWindow");break}n=n.parentNode}},0),Sys.Extended.UI.HtmlEditor._stopEvent(e),!1}var p=Sys.Extended.UI.HtmlEditor.isIE?e.srcElement:e.target;if(null==p.tagName||"undefined"==typeof p.tagName||"HTML"!=p.tagName.toUpperCase()&&"BODY"!=p.tagName.toUpperCase()?null!=Sys.Extended.UI.HtmlEditor.contentEditable(p)&&setTimeout(function(){i._editPanel==Sys.Extended.UI.HtmlEditor.LastFocusedEditPanel&&i.toEndOfProtected()},0):1!=i.__kkoka&&(i.__kkoka=!0,setTimeout(function(){if(i._editPanel==Sys.Extended.UI.HtmlEditor.LastFocusedEditPanel&&!i.toEndOfProtected())try{i.focusEditor()}catch(e){}i.__kkoka=!1},0)),a&&Sys.Extended.UI.HtmlEditor.isIE){var s,m=this._getSelection();try{if(s=this._createRange(m),"control"==m.type.toLowerCase())return Sys.Extended.UI.HtmlEditor._stopEvent(e),!1}catch(t){return Sys.Extended.UI.HtmlEditor._stopEvent(e),!1}}var f=Sys.Extended.UI.HtmlEditor.isIE&&"keydown"==e.type||"keypress"==e.type;e.type+"--"+f;if(f&&!this._editPanel.get_keyboardEnabled())return Sys.Extended.UI.HtmlEditor._stopEvent(e),!1;var c=String.fromCharCode(Sys.Extended.UI.HtmlEditor.isIE?e.keyCode:e.charCode).toLowerCase();if(f&&null!=i._editPanel.get_hotkeys()&&i._editPanel.get_hotkeys().length>0){var S=i._editPanel.get_hotkeys().length,_=c;18!=e.keyCode&&17!=e.keyCode&&16!=e.keyCode||(_=null);for(var g=0;g<S;g++){var u=i._editPanel.get_hotkeys()[g];if(u[1]==_&&u[2]==e.altKey&&u[3]==e.shiftKey&&u[4]==e.ctrlKey)return"function"==typeof u[0]&&setTimeout(function(){u[0](i),i.onContentChanged(),i.focusEditor()},0),Sys.Extended.UI.HtmlEditor._stopEvent(e),!1}}if(f&&e.shiftKey&&45==e.keyCode)this._commonPaste(e);else if(f&&e.ctrlKey&&e.altKey&&e.keyCode==Sys.UI.Key.home){for(var I=null,p=Sys.Extended.UI.HtmlEditor.getSelParent(i);p&&(3==p.nodeType||p.tagName&&"BODY"!=p.tagName.toUpperCase());)if(3!=p.nodeType&&p.tagName){var C=p.tagName.toUpperCase();if(!Sys.Extended.UI.HtmlEditor.canBeInsideP(p)&&"P"!=C){if("TD"==C)for(;"TABLE"!=C;)p=p.parentNode,C=p.tagName.toUpperCase();else if("LI"==C)for(;"OL"!=C&&"UL"!=C;)p=p.parentNode,C=p.tagName.toUpperCase();I=p;break}p=p.parentNode}else p=p.parentNode;if(null!=I){var l=i._getSelection(),h=i._createRange(l),x=i._doc.createTextNode("");if(I.parentNode.insertBefore(x,I),Sys.Extended.UI.HtmlEditor.isIE){var v=i._createRange(l),U=i._createRange(l),H=i._doc.createElement("span"),T=i._doc.createElement("span");x.parentNode.insertBefore(H,x),x.nextSibling?x.parentNode.insertBefore(T,x.nextSibling):x.parentNode.appendChild(T);try{v.moveToElementText(H),U.moveToElementText(T),v.setEndPoint("EndToEnd",U),v.select()}catch(e){}x.parentNode.removeChild(H),x.parentNode.removeChild(T)}else i._removeAllRanges(l),h.setStart(x,0),h.setEnd(x,0),i._selectRange(l,h)}}else if(Sys.Extended.UI.HtmlEditor.isIE&&e.keyCode>=33&&e.keyCode<=40&&!e.shiftKey){var N=e.keyCode==Sys.UI.Key.pageDown||e.keyCode==Sys.UI.Key.end||e.keyCode==Sys.UI.Key.right||e.keyCode==Sys.UI.Key.down;setTimeout(function(){var e=i._getSelection(),t=i._createRange(e);if("control"==e.type.toLowerCase()){var n=t.item(0);if(!n.contentEditable||"false"==n.contentEditable){t.remove(0),e.empty(),t=i._createRange(e);var d=i._doc.createElement("SPAN");d.appendChild(i._doc.createTextNode("")),N?null==n.nextSibling?n.parentNode.appendChild(d):n.parentNode.insertBefore(d,n.nextSibling):n.parentNode.insertBefore(d,n),t.moveToElementText(d),t.select(),setTimeout(function(){i.focusEditor(),d.parentNode.removeChild(d)},0)}}},0)}else if((f&&!Sys.Extended.UI.HtmlEditor.isSafari||Sys.Extended.UI.HtmlEditor.isSafari&&"keydown"==e.type)&&e.ctrlKey&&!e.altKey){i._a_prize=!1;var l=null,h=null,c=String.fromCharCode(Sys.Extended.UI.HtmlEditor.isIE||Sys.Extended.UI.HtmlEditor.isOpera||Sys.Extended.UI.HtmlEditor.isSafari?e.keyCode:e.charCode).toLowerCase(),k=null,b=null;if((Sys.Extended.UI.HtmlEditor.isIE||Sys.Extended.UI.HtmlEditor.isSafari)&&17==e.keyCode)return!1;if(Sys.Extended.UI.HtmlEditor.isIE||e.keyCode!=Sys.UI.Key.end||e.shiftKey){if(46==e.keyCode&&this.isShadowed())return Sys.Extended.UI.HtmlEditor._stopEvent(e),!1;if(46==e.keyCode||e.keyCode==Sys.UI.Key.backspace)(Sys.Extended.UI.HtmlEditor.isIE&&"keydown"==e.type||!Sys.Extended.UI.HtmlEditor.isIE&&"keypress"==e.type)&&this._saveContent();else switch(c){case"a":if(!Sys.Extended.UI.HtmlEditor.isIE)return l=this._getSelection(),this._removeAllRanges(l),h=this._createRange(),h.selectNodeContents(this._doc.body),this._selectRange(l,h),Sys.Extended.UI.HtmlEditor._stopEvent(e),!1;i._a_prize=!0;break;case"z":return this.undo(),Sys.Extended.UI.HtmlEditor._stopEvent(e),!1;case"p":if(!Sys.Extended.UI.HtmlEditor.isIE)return setTimeout(function(){i._contextMenuCallP()},0),Sys.Extended.UI.HtmlEditor._stopEvent(e),!1;break;case"y":return this.redo(),Sys.Extended.UI.HtmlEditor._stopEvent(e),!1;case"x":if(this.isShadowed())return Sys.Extended.UI.HtmlEditor._stopEvent(e),!1;if(this._saveContent(),Sys.Extended.UI.HtmlEditor.isIE&&"keydown"==e.type)return i.openWait(),setTimeout(function(){i._copyCut(c,!1),i.closeWait()},0),Sys.Extended.UI.HtmlEditor._stopEvent(e),!1;break;case"c":if(this.isShadowed())return Sys.Extended.UI.HtmlEditor._stopEvent(e),!1;if(Sys.Extended.UI.HtmlEditor.isIE&&"keydown"==e.type)return i.openWait(),setTimeout(function(){i._copyCut(c,!1),i.closeWait(),setTimeout(function(){i._ifShadow()},0)},0),Sys.Extended.UI.HtmlEditor._stopEvent(e),!1;break;case"v":if(this.isShadowed())return Sys.Extended.UI.HtmlEditor._stopEvent(e),!1;if(Sys.Extended.UI.HtmlEditor.isIE)return this._saveContent(),!0;this._commonPaste(e);break;case"b":return this._execCommand("bold",!1,b),Sys.Extended.UI.HtmlEditor._stopEvent(e),!1;case"i":return this._execCommand("italic",!1,b),Sys.Extended.UI.HtmlEditor._stopEvent(e),!1;case"u":return this._execCommand("underline",!1,b),Sys.Extended.UI.HtmlEditor._stopEvent(e),!1;case"s":return this._execCommand("strikethrough",!1,b),Sys.Extended.UI.HtmlEditor._stopEvent(e),!1;case"l":k="justifyleft";break;case"e":k="justifycenter";break;case"r":k="justifyright";break;case"j":k="justifyfull";break;case"q":return alert(this._doc.body.innerHTML),Sys.Extended.UI.HtmlEditor._stopEvent(e),!1;case"0":var O="Your browser:\n\n"+navigator.userAgent;return alert(O),Sys.Extended.UI.HtmlEditor._stopEvent(e),!1;case"9":if(Sys.Extended.UI.HtmlEditor.isIE){var l=i._getSelection(),h=i._createRange(l);alert("boundingLeft: "+h.boundingLeft+" boundingTop: "+h.boundingTop+"\nboundingWidth: "+h.boundingWidth+" boundingHeight: "+h.boundingHeight)}else{var l=i._getSelection(),h=i._createRange(l),w=h.startContainer,P=h.endContainer,L="";L+="startContainer: "+(1==w.nodeType?w.tagName:"text")+"\n",L+="endContainer : "+(1==P.nodeType?P.tagName:"text")+"\n",w==P&&(L+="startOffset: "+h.startOffset+"\n",L+="endOffset : "+h.endOffset+"\n",1==w.nodeType&&(w=w.childNodes.item(h.startOffset),w&&w.nodeType?(L+="startOffset node: "+(1==w.nodeType?w.tagName:"text")+"\n",h.startOffset!=h.endOffset&&(w=P.childNodes.item(h.endOffset),w&&w.nodeType&&(L+="endOffset node: "+(1==w.nodeType?w.tagName:"text")+"\n"))):L+=w)),alert(L)}return Sys.Extended.UI.HtmlEditor._stopEvent(e),!1}}else i._setToEnd();k&&(this._execCommand(k,!1,b),"formatblock"!=k||Sys.Extended.UI.HtmlEditor.isIE||(this._saveContent(),this._undo(!1)),Sys.Extended.UI.HtmlEditor._stopEvent(e),"delete"!=k&&"paste"!=k||this._clearP())}else if(f||(Sys.Extended.UI.HtmlEditor.isSafari||Sys.Extended.UI.HtmlEditor.isOpera)&&"keydown"==e.type){if(Sys.Extended.UI.HtmlEditor.isIE&&this._tryForward){var h=this._createRange(this._getSelection());h.select(),this._tryForward=!1}var c=String.fromCharCode(Sys.Extended.UI.HtmlEditor.isIE?e.keyCode:e.charCode).toLowerCase();if(i._a_prize&&(i._a_prize=!1,setTimeout(t,0)),this.isShadowed())return Sys.Extended.UI.HtmlEditor._stopEvent(e),!1;switch(e.keyCode){case Sys.UI.Key.tab:if((Sys.Extended.UI.HtmlEditor.isSafari||Sys.Extended.UI.HtmlEditor.isOpera)&&"keydown"!=e.type)break;if(this._editPanel.get_suppressTabInDesignMode())return Sys.Extended.UI.HtmlEditor.isSafari&&Sys.Extended.UI.HtmlEditor._stopEvent(e),Sys.Extended.UI.HtmlEditor.LastFocusedEditPanel=null,!0;this.isControl()||this.insertHTML("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"),Sys.Extended.UI.HtmlEditor._stopEvent(e);break;case 46:case Sys.UI.Key.backspace:if((Sys.Extended.UI.HtmlEditor.isSafari||Sys.Extended.UI.HtmlEditor.isOpera)&&"keydown"!=e.type)break;if(((Sys.Extended.UI.HtmlEditor.isIE||Sys.Extended.UI.HtmlEditor.isSafari)&&"keydown"==e.type||!Sys.Extended.UI.HtmlEditor.isIE&&"keypress"==e.type)&&this._saveContent(),Sys.Extended.UI.HtmlEditor.isIE){var l=i._getSelection();if("control"==l.type.toLowerCase()){if(8==e.keyCode)return setTimeout(function(){i._ifShadow(),i.onContentChanged()},0),void Sys.Extended.UI.HtmlEditor._stopEvent(e);var R=i._createRange(l),B=R.item(0);if("EMBED"==B.tagName.toUpperCase()){for(B.src="",B.parentNode.removeChild(B);R.length>0;)R.remove(0);try{R.collapse(!1)}catch(e){}return Sys.Extended.UI.HtmlEditor._stopEvent(e),i._saveContent(),void setTimeout(function(){i._undo(!1),i.onContentChanged()},0)}}var K=i._doc.body.getElementsByTagName("EMBED").length;if(K>0){var D=i._body.ownerDocument.createElement("div");i._body.appendChild(D);e.keyCode;setTimeout(function(){i._body.removeChild(D);var e=i._doc.body.getElementsByTagName("EMBED");K!=e.length&&(i._saveContent(),setTimeout(function(){i._undo(!1),i.onContentChanged()},0))},0)}setTimeout(function(){i._clearP()},0)}else{var h=this._createRange(this._getSelection()),w=h.startContainer,P=h.endContainer;if("keypress"==e.type&&(null!=Sys.Extended.UI.HtmlEditor.contentEditable(w)||null!=Sys.Extended.UI.HtmlEditor.contentEditable(P)))return Sys.Extended.UI.HtmlEditor._stopEvent(e),!1;if(w==P&&1==w.nodeType&&"TD"==w.tagName.toUpperCase()&&h.startOffset==h.startOffset&&w.childNodes.item(h.startOffset)&&w.childNodes.item(h.startOffset).tagName&&"BR"==w.childNodes.item(h.startOffset).tagName.toUpperCase()){var F,M=w.childNodes.item(h.startOffset),A=0,W=0;for(F=M.previousSibling;F;)A++,F=F.previousSibling;for(F=M.nextSibling;F;)W++,F=F.nextSibling;if(46==e.keyCode&&0==W||e.keyCode==Sys.UI.Key.backspace&&0==A)return Sys.Extended.UI.HtmlEditor._stopEvent(e),!1;if(46==e.keyCode&&w.firstChild==w.lastChild&&1==w.firstChild.nodeType)return Sys.Extended.UI.HtmlEditor._stopEvent(e),!1}if(w==P&&3==w.nodeType&&h.startOffset==h.endOffset&&!Sys.Extended.UI.HtmlEditor.isOpera){var Y=w.data+"";if(46==e.keyCode&&h.startOffset==Y.length&&(!w.nextSibling||3!=w.nextSibling.nodeType))return w.nextSibling&&(w.parentNode.removeChild(w.nextSibling),i.onContentChanged()),Sys.Extended.UI.HtmlEditor._stopEvent(e),!1;if(e.keyCode==Sys.UI.Key.backspace&&0==h.startOffset&&(!w.previousSibling||3!=w.previousSibling.nodeType))return w.previousSibling&&(w.parentNode.removeChild(w.previousSibling),i.onContentChanged()),Sys.Extended.UI.HtmlEditor._stopEvent(e),!1}if(e.keyCode==Sys.UI.Key.backspace&&1==w.nodeType&&w==P&&h.startOffset==h.endOffset){var z=w.childNodes.item(h.startOffset);if(null!=z&&1==z.nodeType&&"BR"==z.tagName.toUpperCase()&&(z=z.previousSibling,null!=z&&3!=z.nodeType))return z.parentNode.removeChild(z),i.onContentChanged(),Sys.Extended.UI.HtmlEditor._stopEvent(e),!1}setTimeout(function(){var e=i._getSelection(),t=i._createRange(e),n=t.startContainer,d=t.endContainer;if(null!=Sys.Extended.UI.HtmlEditor.contentEditable(n)||null!=Sys.Extended.UI.HtmlEditor.contentEditable(d))return void i._undo(!1);if(Sys.Extended.UI.HtmlEditor.isOpera&&n==d&&3==n.nodeType&&0==n.data.length)n.parentNode.removeChild(n);else if(n==d&&1==n.nodeType&&Sys.Extended.UI.HtmlEditor.isStyleTag(n.tagName)&&t.startOffset==t.endOffset&&0==n.childNodes.length){for(;1==n.parentNode.nodeType&&Sys.Extended.UI.HtmlEditor.isStyleTag(n.parentNode.tagName)&&1==n.parentNode.childNodes.length;)n=n.parentNode;var o=n.nextSibling,r=n.previousSibling,s=n.parentNode;if(s.removeChild(n),i.onContentChanged(),null==o&&null==r)t.setStart(s,0),t.setEnd(s,0);else if(null!=o&&null!=r)if(3==o.nodeType&&3==r.nodeType){var a=(""+r.data).length;r.appendData(o.data),s.removeChild(o),t.setStart(r,a),t.setEnd(r,a)}else if(3==r.nodeType){var a=(""+r.data).length;t.setStart(r,a),t.setEnd(r,a)}else if(3==o.nodeType)t.setStart(o,0),t.setEnd(o,0);else if(o.childNodes.length>0)t.setStart(o,0),t.setEnd(o,0);else{var a=Sys.Extended.UI.HtmlEditor.__getIndex(o);t.setStart(s,a),t.setEnd(s,a)}else if(null!=r)if(3==r.nodeType){var a=(""+r.data).length;t.setStart(r,a),t.setEnd(r,a)}else{var a=r.childNodes.length;a>0?(t.setStart(r,a),t.setEnd(r,a)):(a=Sys.Extended.UI.HtmlEditor.__getIndex(r),t.setStart(s,a),t.setEnd(s,a))}else if(null!=o)if(3==o.nodeType)t.setStart(o,0),t.setEnd(o,0);else{var a=o.childNodes.length;a>0?(t.setStart(o,a),t.setEnd(o,a)):(a=Sys.Extended.UI.HtmlEditor.__getIndex(o),t.setStart(s,a),t.setEnd(s,a))}i._removeAllRanges(e),i._selectRange(e,t)}},0)}break;case Sys.UI.Key.enter:if((Sys.Extended.UI.HtmlEditor.isSafari||Sys.Extended.UI.HtmlEditor.isOpera)&&"keydown"==e.type)break;if((!Sys.Extended.UI.HtmlEditor.isIE&&"keypress"==e.type||Sys.Extended.UI.HtmlEditor.isIE&&"keydown"==e.type)&&this._saveContent(),Sys.Extended.UI.HtmlEditor.isIE&&"keydown"==e.type){var l=i._getSelection();if("control"==l.type.toLowerCase())break;var R=i._createRange(l);if(e.shiftKey)break;var j=R.parentElement();if("TEXTAREA"==j.tagName.toUpperCase())break;for(;j&&j.tagName&&"BODY"!=j.tagName.toUpperCase()&&Sys.Extended.UI.HtmlEditor.isStyleTag(j.tagName);)j=j.parentNode;if(j&&j.tagName){var C=j.tagName.toUpperCase();if("P"==C||"LI"==C){"LI"==C&&setTimeout(n,0);break}}try{var q=Sys.Extended.UI.HtmlEditor.smartClassName+"_middle_add",V=null,X="<span id="+q+"></span>";R.pasteHTML(X);var G=!1;if(V=i._doc.getElementById(q),null!=V){for(var J=V.nextSibling,Q=V.parentNode;null==J&&null!=Q&&Sys.Extended.UI.HtmlEditor.isStyleTag(Q.tagName);)J=Q.nextSibling,Q=Q.parentNode;if(null!=J&&!Sys.Extended.UI.HtmlEditor.isInlineElement(J)&&null!=J.tagName&&"undefined"!=typeof J.tagName){var Z=J.tagName.toUpperCase();"BR"!=Z&&"UL"!=Z&&"OL"!=Z&&"P"!=Z&&(G=!0)}V.parentNode.removeChild(V)}if(R.pasteHTML("<br/>"+(G?X:"")),G&&(V=i._doc.getElementById(q)),R.select(),G)return setTimeout(d,0),Sys.Extended.UI.HtmlEditor._stopEvent(e),!1}catch(e){}Sys.Extended.UI.HtmlEditor._stopEvent(e)}else if(e.shiftKey||!Sys.Extended.UI.HtmlEditor.isSafari&&!Sys.Extended.UI.HtmlEditor.isOpera)Sys.Extended.UI.HtmlEditor.isSafari&&(this.insertHTML("<br/>"),Sys.Extended.UI.HtmlEditor._stopEvent(e),i.onContentChanged());else{var j=Sys.Extended.UI.HtmlEditor.getSelParent(this);for(3==j.nodeType&&(j=j.parentNode);j&&j.tagName&&"BODY"!=j.tagName.toUpperCase()&&Sys.Extended.UI.HtmlEditor.isStyleTag(j.tagName);)j=j.parentNode;if(j&&j.tagName&&("P"==j.tagName.toUpperCase()||"LI"==j.tagName.toUpperCase()))break;var X="<br />";if(Sys.Extended.UI.HtmlEditor.isOpera){var l=i._getSelection(),h=i._createRange(l);if(h.startContainer==h.endContainer)if(1==h.startContainer.nodeType){var $=h.startContainer.childNodes.item(h.startOffset);1==$.nodeType&&"BR"==$.tagName.toUpperCase()&&(X+="<br />")}else 3!=h.startContainer.nodeType||h.startOffset!=h.endOffset||h.startContainer.data.length!=h.endOffset||h.startContainer.nextSibling&&3==h.startContainer.nextSibling.nodeType||(X+="&nbsp;")}if(this.insertHTML(X),Sys.Extended.UI.HtmlEditor._stopEvent(e),Sys.Extended.UI.HtmlEditor.isOpera){var l=i._getSelection(),h=i._createRange(l);if(h.startContainer==h.endContainer&&3==h.startContainer.nodeType&&h.startOffset==h.endOffset&&0==h.startContainer.data.length){var ee=h.startContainer.previousSibling;h.startContainer.parentNode.removeChild(h.startContainer),i._removeAllRanges(l),h=i._createRange(),h.setStart(ee,0),h.setEnd(ee,1),i._selectRange(l,h)}}i.onContentChanged()}}}else i._a_prize=!1;if(Sys.Extended.UI.HtmlEditor.isIE&&"keypress"==e.type&&!e.ctrlKey){var c=e.keyCode,te=i._getSelection(),ne=i._createRange(te);if(ne.text.length>0){var de=String.fromCharCode(c),oe=Sys.Extended.UI.HtmlEditor.capLock(e),ie=e.shiftKey&&!oe||oe;ie||(de=de.toLowerCase());var re=Sys.Extended.UI.HtmlEditor.smartClassName+"StyleForTyping",se=i._doc.getElementById(re);return null!=se&&(de="<span id='"+re+"'></span>"+de+"<span id='"+re+re+"'></span>",se.parentNode.removeChild(se)),ne.pasteHTML(de),null!=se&&(i.trickWithStyles(re),se=i._doc.getElementById(re+re),se.parentNode.removeChild(se)),Sys.Extended.UI.HtmlEditor._stopEvent(e),i.onContentChanged(),!1}}if("mouseup"==e.type||"mousedown"==e.type||"keydown"==e.type){var ae=!0;if("keydown"==e.type&&!e.ctrlKey){var c=e.keyCode;if((c>=48&&c<=90||32==c||13==c||c>=186&&c<=222||c>=96&&c<=111)&&null!=i._StyleForTyping){i.n_arr=[];for(var le=0;le<i._StyleForTyping.length;le++)i.n_arr.push(i._StyleForTyping[le]);var re=Sys.Extended.UI.HtmlEditor.smartClassName+"StyleForTyping",Ee=!0;if(Sys.Extended.UI.HtmlEditor.isIE){i.insertHTML("<span id='"+re+"'>&nbsp;</span>");var se=i._doc.getElementById(re);if(se&&se.nextSibling&&3==se.nextSibling.nodeType){Ee=!1;var te=i._getSelection(),ne=i._createRange(te);ne.moveToElementText(i._doc.getElementById(re)),ne.select()}else se&&se.removeChild(se.firstChild)}else i.insertHTML("<span id='"+re+"'></span>");Ee&&setTimeout(function(){i.trickWithStyles(re),i.onContentChanged()},0)}}!ae&&Sys.Extended.UI.HtmlEditor.isIE||i._updated_now||(i._updateTimer&&(clearTimeout(i._updateTimer),i._updateTimer=null),i._updateTimerLimit=3,i._updateTimer=setTimeout(o,300))}if((Sys.Extended.UI.HtmlEditor.isIE||"keydown"!=e.type&&"keyup"!=e.type)&&(!Sys.Extended.UI.HtmlEditor.isIE||"keydown"!=e.type&&"keyup"!=e.type||16!=e.keyCode&&20!=e.keyCode)&&(i._StyleForTyping=null),Sys.Extended.UI.HtmlEditor.isSafari&&setTimeout(function(){i._createRange(i._getSelection())},0),Sys.Extended.UI.HtmlEditor.isIE||setTimeout(function(){if(i._editPanel==Sys.Extended.UI.HtmlEditor.LastFocusedEditPanel){var e=i._getSelection(),t=i._createRange(e);if(3!=t.startContainer.nodeType&&t.startContainer==t.endContainer&&t.startOffset==t.endOffset&&t.startContainer.childNodes.item(t.startOffset)&&3==t.startContainer.childNodes.item(t.startOffset).nodeType){var n=t.startContainer.childNodes.item(t.startOffset);e.collapseToEnd(),i._removeAllRanges(e),e=i._getSelection(),t=i._createRange(e),t.setStart(n,0),t.setEnd(n,0),i._selectRange(e,t)}}},0),!Sys.Extended.UI.HtmlEditor.isIE){var l=i._getSelection(),h=i._createRange(l);i._saved_startContainer=h.startContainer,i._saved_startOffset=h.startOffset}return setTimeout(function(){try{i._editPanel==Sys.Extended.UI.HtmlEditor.LastFocusedEditPanel&&i._ifShadow()}catch(e){}},0),"keydown"==e.type&&(null!=i._AfterOnContentChanged&&"undefined"!=typeof i._AfterOnContentChanged&&i._AfterOnContentChanged||(i._AfterOnContentChanged=!0,setTimeout(function(){i._editPanel==Sys.Extended.UI.HtmlEditor.LastFocusedEditPanel&&(i.onContentChanged(),i._AfterOnContentChanged=!1)},0))),!0}catch(t){return Sys.Extended.UI.HtmlEditor._stopEvent(e),!1}};