2 lines
58 KiB
JavaScript
2 lines
58 KiB
JavaScript
Type.registerNamespace("Sys.Extended.UI.HtmlEditor"),Sys.Extended.UI.HtmlEditor.DesignPanel=function(e){Sys.Extended.UI.HtmlEditor.DesignPanel.initializeBase(this,[e]),this._doc=null,this._updated_now=!1,this._updateTimer=null,this._popup=null,this._contextElement=null,this._a_prize=!1,this.__stack=null,this._StyleForTyping=null,this.isWord=!1,this.isPlainText=!1,this.dfltBlockElement="P",this._FontNotSet=!0,this._design_timer1=null,this._events$delegate=Function.createDelegate(this,Sys.Extended.UI.HtmlEditor.DesignPanelEventHandler),this._blur$delegate=Function.createDelegate(this,this._blur),this._focus$delegate=Function.createDelegate(this,this._focus_event)},Sys.Extended.UI.HtmlEditor.DesignPanel.prototype={initialize:function(){Sys.Extended.UI.HtmlEditor.DesignPanel.callBaseMethod(this,"initialize")},dispose:function(){Sys.Extended.UI.HtmlEditor.DesignPanel.callBaseMethod(this,"dispose")},_activate:function(e){Sys.Extended.UI.HtmlEditor.DesignPanel.callBaseMethod(this,"_activate"),this._wasFocused=!1,this._initIframe(e),this._onDocumentLoaded()},_deactivate:function(){this._deactivateCommon(),Sys.Extended.UI.HtmlEditor.isIE&&(this._doc.open(),this._doc.write(""),this._doc.close(),this.get_element().src="javascript:false;"),this._doc=null,Sys.Extended.UI.HtmlEditor.DesignPanel.callBaseMethod(this,"_deactivate")},_deactivateCommon:function(){this._editPanel.__blured=!1;for(var e=this._doc.body.getElementsByTagName("IMG"),t=0;t<e.length;t++)if(e[t].getAttribute(Sys.Extended.UI.HtmlEditor.attachedIdAttribute)&&e[t].getAttribute(Sys.Extended.UI.HtmlEditor.attachedIdAttribute).length>0)try{Sys.Extended.UI.HtmlEditor.isIE?$removeHandler(e[t],"dragstart",Sys.Extended.UI.HtmlEditor.stopDrag):$removeHandler(e[t],"draggesture",Sys.Extended.UI.HtmlEditor.stopDrag)}catch(e){}Sys.Extended.UI.HtmlEditor._removeEvents(this._doc,["keydown","keypress","mousedown","mouseup","dblclick"],this._events$delegate),Sys.Extended.UI.HtmlEditor._removeEvents(this.get_element().contentWindow,["blur"],this._blur$delegate),Sys.Extended.UI.HtmlEditor._removeEvents(this.get_element().contentWindow,["focus"],this._focus$delegate)},_initIframe:function(e){Sys.Extended.UI.HtmlEditor.isIE||(this._savedValue=e,this._absAndFixedParents=this._getAbsAndFixedParents());var t=Sys.Extended.UI.HtmlEditor.Trim(this._prepareContent(e));this._doc=this.get_element().contentWindow.document,Sys.Extended.UI.HtmlEditor.isIE||(this._doc.designMode="on"),this._doc.open(),this._doc.write('<html><head><link rel="stylesheet" href="'+this._editPanel.get_documentCssPath()+'" media="all" /><link rel="stylesheet" href="'+this._editPanel.get_designPanelCssPath()+'" media="all" /></head><body>'+t+"</body></html>"),this._doc.close(),this._doc.id="EditorDocument",Sys.Extended.UI.HtmlEditor.isIE&&(this._doc.body.contentEditable=!0,this._tryForward=!0)},_blur:function(e){return this._editPanel.__blured=!0,Sys.Extended.UI.HtmlEditor.isIE||null==this._design_timer1||(clearTimeout(this._design_timer1),this._design_timer1=null),this.isPopup||this._editPanel._validate(e,null),!0},_focus_event:function(){if(this._editPanel.__blured=!1,Sys.Extended.UI.HtmlEditor.isIE)this._really_focused();else{var e=this;Sys.Extended.UI.HtmlEditor.LastFocusedEditPanel=this._editPanel,null==this._design_timer1&&(this._design_timer1=setTimeout(function(){e._really_focused(),e._design_timer1=null},0))}return!0},_getAbsAndFixedParents:function(){for(var e=this.get_element(),t="";null!=e&&e.tagName&&"body"!=e.tagName.toLowerCase();)t+=e.tagName,"absolute"!=e.style.position&&"fixed"!=e.style.position||(t+=": "+e.style.position),t+="\n",e=e.parentNode;return t},_onDocumentLoaded:function(){var e=this;if(!Sys.Extended.UI.HtmlEditor.isIE){var t=this._getAbsAndFixedParents();if(t!=this._absAndFixedParents)return this._initIframe(this._savedValue),void setTimeout(function(){e._onDocumentLoaded()},10)}try{if(!Sys.Extended.UI.HtmlEditor.isIE&&(this._doc.queryCommandValue("forecolor"),(Sys.Extended.UI.HtmlEditor.isSafari||Sys.Extended.UI.HtmlEditor.isOpera)&&!Sys.Extended.UI.HtmlEditor.isReallyVisible(this.get_element())))return void setTimeout(function(){e._onDocumentLoaded()},10);e._doc.body.innerHTML}catch(t){return void setTimeout(function(){e._onDocumentLoaded()},10)}this._afterBodyIsFormed(),setTimeout(function(){e._activateFinished(),Sys.Extended.UI.HtmlEditor.isIE&&!e._editPanel.get_autofocus()&&e._getSelection().empty()},0)},_afterBodyIsFormed:function(){var e=this;Sys.Extended.UI.HtmlEditor._addEvents(this._doc,["keydown","keypress","mousedown","mouseup","dblclick"],this._events$delegate),Sys.Extended.UI.HtmlEditor._addEvents(this.get_element().contentWindow,["blur"],this._blur$delegate),Sys.Extended.UI.HtmlEditor._addEvents(this.get_element().contentWindow,["focus"],this._focus$delegate),Sys.Extended.UI.HtmlEditor.inspectForShadows(e._doc.body);var t=this._doc.body;if(1==t.childNodes.length&&t.firstChild.tagName&&"DIV"==t.firstChild.tagName.toUpperCase()&&t.firstChild.style.cssText.length>0&&t.firstChild.style.direction.length>0&&"absolute"!=Sys.Extended.UI.HtmlEditor.getStyle(t.firstChild,"position")){t.style.cssText=t.firstChild.style.cssText;for(var i=t.firstChild;i.firstChild;)t.insertBefore(i.firstChild,i);t.removeChild(i)}e._clearP()},_getContent:function(){if(null!=this._popup&&"function"==typeof this._popup._forceImClose){var e=this._popup._forceImClose;e(this._popup._iframe.contentWindow)}this._clearP();var t;if(Sys.Extended.UI.HtmlEditor.isIE){Sys.Extended.UI.HtmlEditor.spanJoiner(this._doc.body,this._doc),t=Sys.Extended.UI.HtmlEditor.getHTML(this._doc.body,!1,!0),t=t.replace(/(<td[^>]*?>)([\s ]*?)(<\/td[^>]*?>)/gi,"$1 $3").replace(/(<td[^>]*?>)\s*( )\s*(<\/td[^>]*?>)/gi,"$1<br/>$3").replace(/(<p[^>]*?>)\s*( )\s*(<\/p[^>]*?>)/gi,"$1<br/>$3"),t=(this._doc.body.style.cssText.length>0?'<div style="'+this._doc.body.style.cssText.replace('"',"'")+'">':"")+t+(this._doc.body.style.cssText.length>0?"</div>":""),this._editPanel.get_noScript()&&(t=t.replace(/(<script(?:[^>]*?)>(?:[^<]*?)<\/script(?:[^>]*?)>)/gi,"")),/<embed/gi.test(t)&&(t=t.replace(/(<embed(?:.*?))(\sloop=\"true\")((?:.*?)>)/gi,"$1$3").replace(/(<embed(?:.*?))(\splay=\"true\")((?:.*?)>)/gi,"$1$3").replace(/(<embed(?:.*?))(\sbgcolor=\"\")((?:.*?)>)/gi,"$1$3").replace(/(<embed(?:.*?))(\sscale=\"\")((?:.*?)>)/gi,"$1$3").replace(/(<embed(?:.*?))(\shspace=\"0\")((?:.*?)>)/gi,"$1$3").replace(/(<embed(?:.*?))(\svspace=\"0\")((?:.*?)>)/gi,"$1$3").replace(/(<embed(?:.*?))(\swmode=\"[^\"]+\")((?:.*?)>)/gi,"$1$3").replace(/(<embed(?:.*?))(pseudomode=)(\"[^\"]*\")((?:.*?)>)/gi,"$1wmode=$3$4").replace(/(<embed(?:.*?))(\swmode=\"\")((?:.*?)>)/gi,"$1$3"));var i=new RegExp("(<[/]?)(teo"+Sys.Extended.UI.HtmlEditor.smartClassName+":)","ig");t=t.replace(i,"$1")}else{var n=this._doc.createElement("DIV"),r=new Sys.Extended.UI.HtmlEditor.DesignPanel.ScriptRecover;n.style.cssText=this._doc.body.style.cssText,this._editPanel.get_noScript()||this._doc.body.innerHTML.replace(/<script(?:[^>]*?)>(.*?)<\/script(?:[^>]*?>)/gi,function(e,t){return r.regReplScript1(e,t)}),n.innerHTML=Sys.Extended.UI.HtmlEditor.Trim(this._doc.body.innerHTML);for(var s=n.getElementsByTagName("IMG"),d=[],o=0;o<s.length;o++)d.push(s[o]);for(var a=0;a<d.length;a++){var l,c=d[a];if(l=c.getAttribute("dummytag"),l&&l.length>0&&"embed"==l.toLowerCase()){var h=c.getAttribute("dummysrc"),m=c.getAttribute("dummybgcolor"),g=c.getAttribute("pseudomode"),_=c.attributes,p=this._doc.createElement("EMBED");p.src=h,p.width=c.width,p.height=c.height,m&&m.length>0&&(m=Sys.Extended.UI.HtmlEditor.tryReplaceRgb(m),p.setAttribute("bgcolor",m)),g&&g.length>0&&p.setAttribute("wmode",g);for(var o=0;o<_.length;++o){var E=_.item(o);if(E.specified){var u=E.name.toLowerCase(),f=E.value;"dummytag"!=u&&"dummysrc"!=u&&"dummybgcolor"!=u&&"style"!=u&&"wmode"!=u&&"pseudomode"!=u&&"src"!=u&&("loop"==u&&"true"==f||"play"==u&&"true"==f||"hspace"==u&&"0"==f||"vspace"==u&&"0"==f||"scale"==u&&0==f.length||"align"==u&&0==f.length||p.setAttribute(u,f))}}c.style.width&&c.style.width.length>0&&(p.style.width=c.style.width),c.style.height&&c.style.height.length>0&&(p.style.height=c.style.height),c.parentNode.insertBefore(p,c),c.parentNode.removeChild(c)}}Sys.Extended.UI.HtmlEditor.spanJoiner(n,this._doc),t=Sys.Extended.UI.HtmlEditor.getHTML(n,n.style.cssText.length>0,!0),t=this._editPanel.get_noScript()?t.replace(/(<script(?:[^>]*?)>(?:[^<]*?)<\/script(?:[^>]*?)>)/gi,""):t.replace(/(<script(?:[^>]*?)>)(.*?)(<\/script(?:[^>]*?)>)/gi,function(e,t,i,n){return r.regReplFromScript1(e,t,i,n)}),delete n}return t=Sys.Extended.UI.HtmlEditor.brXHTML(t.replace(/^([\n|\r]+)/,"")),this._editPanel.get_noUnicode()&&(t=t.replace(/([\u0080-\uFFFF])/g,function(e,t){return"&#"+t.charCodeAt(0).toString(10)+";"})),"<br />"==Sys.Extended.UI.HtmlEditor.Trim(t)&&(t=""),t},_setContent:function(e){this._deactivateCommon();var t=Sys.Extended.UI.HtmlEditor.Trim(this._prepareContent(e));this._doc.open(),this._doc.write('<html><head><link rel="stylesheet" href="'+this._editPanel.get_documentCssPath()+'" media="all" /><link rel="stylesheet" href="'+this._editPanel.get_designPanelCssPath()+'" media="all" /></head><body>'+t+"</body></html>"),this._doc.close(),Sys.Extended.UI.HtmlEditor.isIE&&(this._doc.body.contentEditable=!0,this._tryForward=!0),this._afterBodyIsFormed(),this._editPanel.get_autofocus()&&this._focus(),Sys.Extended.UI.HtmlEditor.isIE&&!this._editPanel.get_autofocus()&&this._getSelection().empty()},_focus:function(e){this.focusEditor(),this._focused(e)},focusEditor:function(){try{this.get_element().contentWindow.focus()}catch(e){}this._wasFocused||(this._wasFocused=!0,this._editPanel.get_startEnd()||this._setToEnd())},_prepareContent:function(e){var t=e;if(t=t.replace(/<object(?:[^>]*?)>(?:[^\u0000]*?)(<embed(?:[^>]*?)>)(?:[^\u0000]*?)<\/object(?:[^>]*?)>/gi,"$1"),Sys.Extended.UI.HtmlEditor.isIE)return t=Sys.Extended.UI.HtmlEditor.Trim(t.replace(/([\n\r]+<)/g,"<").replace(/([^>])([\n\r]+)([^<])/g,"$1 $3")).replace(/(&)/g,"&amp;").replace(/<br\s*[\/]*>\s*<\/td>/gi,"</td>").replace(/(<td[^>]*?>)([\s ]*?)(<\/td[^>]*?>)/gi,"$1 $3").replace(/(<p[^>]*?>)\s*(<br[^>]*?>)\s*(<\/p[^>]*?>)/gi,"$1 $3"),/<embed/gi.test(t)&&(t=t.replace(/(<embed(?:.*?))(wmode=)(\"[^\"]*\")((?:.*?)>)/gi,"$1pseudomode=$3$4").replace(/(<embed)([^>]*?>)/gi,'$1 wmode="transparent"$2')),t=t.replace(/&/gi,"&");var i=new Sys.Extended.UI.HtmlEditor.DesignPanel.ScriptRecover,n=document.createElement("DIV");this._editPanel.get_noScript()||t.replace(/<script(?:[^>]*?)>(.*?)<\/script(?:[^>]*?>)/gi,function(e,t){return i.regReplScript1(e,t)}),n.innerHTML=Sys.Extended.UI.HtmlEditor.Trim(t.replace(/([^>])([\n\r]+)([^<])/g,"$1 $3"));for(var r=n.getElementsByTagName("EMBED"),s=[],d=0;d<r.length;d++)s.push(r[d]);for(var o=0;o<s.length;o++){var a=s[o],l=document.createElement("IMG"),c=a.attributes;l.src=this._editPanel.get_imagePath_1x1(),l.setAttribute("dummytag","embed");for(var d=0;d<c.length;++d){var h=c.item(d);if(h.specified){var m=h.name.toLowerCase(),e=h.value;"src"==m?m="dummysrc":"bgcolor"==m?m="dummybgcolor":"wmode"==m&&(m="pseudomode"),l.setAttribute(m,e)}}l.style.cssText="border: 1px dotted #000000; background-image: url('"+("application/x-mplayer2"==l.getAttribute("type").toLowerCase()?this._editPanel.get_imagePath_media():tthis._editPanel.get_imagePath_flash())+"'); background-position: center; background-repeat: no-repeat; background-color: #c0c0c0;",a.style.width&&a.style.width.length>0&&(l.style.width=a.style.width),a.style.height&&a.style.height.length>0&&(l.style.height=a.style.height),a.parentNode.insertBefore(l,a),a.parentNode.removeChild(a)}return Sys.Extended.UI.HtmlEditor.spanJoiner(n,document),t=Sys.Extended.UI.HtmlEditor.Trim(Sys.Extended.UI.HtmlEditor.getHTML(n,!1,!0)),this._editPanel.get_noScript()||(t=t.replace(/(<script(?:[^>]*?)>)(.*?)(<\/script(?:[^>]*?)>)/gi,function(e,t,n,r){return i.regReplFromScript1(e,t,n,r)})),delete n,delete i,t=Sys.Extended.UI.HtmlEditor.brXHTML(t),0==t.length&&(t="<br/>"),t},_clearP:function(){function e(t){var i=!1;if(1==t.nodeType){var n=t.tagName.toUpperCase();if((!s||"LI"!=n)&&(Sys.Extended.UI.HtmlEditor.isRestricted(t)||"IMG"==n||"IFRAME"==n||"EMBED"==n||"SCRIPT"==n))return!0;if(t.childNodes.length>1)return!0;if(0==t.childNodes.length)return!1;i|=e(t.firstChild)}else 3==t.nodeType&&(i|=!0);return i}try{var t=this._doc.body;if(t.firstChild&&3==t.firstChild.nodeType){var i=Sys.Extended.UI.HtmlEditor.Trim(""+t.firstChild.data);0==i.length?t.removeChild(t.firstChild):i!=""+t.firstChild.data&&(t.firstChild.data=i)}if(Sys.Extended.UI.HtmlEditor.isIE&&1==t.childNodes.length&&(t=t.firstChild,1==t.nodeType)){var n=t.tagName.toLowerCase();if("p"==n||"ul"==n||"ol"==n){var r=!1,s="ul"==n||"ol"==n;1==t.childNodes.length&&(e(t.firstChild)||t.removeChild(t.firstChild)),r=!0,(r||"<p> </p>"==t.parentNode.innerHTML.toLowerCase())&&this._doc.body.removeChild(t)}}}catch(e){}},isControl:function(){try{var e=this._getSelection();if(Sys.Extended.UI.HtmlEditor.isIE)return"control"==e.type.toLowerCase();var t=this._createRange(e),i=this._getParent(t);return 3!=i.nodeType&&t.startContainer==t.endContainer&&(!!i.tagName&&(null!=t.startContainer.childNodes.item(t.startOffset)&&((t.startOffset!=t.endOffset||!t.startContainer.childNodes.item(t.startOffset).tagName||"BR"!=t.startContainer.childNodes.item(t.startOffset).tagName.toUpperCase()&&!Sys.Extended.UI.HtmlEditor.isStyleTag(t.startContainer.childNodes.item(t.startOffset).tagName))&&(!("BODY"==i.tagName.toUpperCase()&&0==t.startOffset&&t.endOffset>0&&t.endOffset==i.childNodes.length)&&(t.startOffset!=t.endOffset||3!=t.startContainer.childNodes.item(t.startOffset).nodeType)))))}catch(e){return!0}},isPopup:function(){return null!=this._popup},_getSelection:function(){if(Sys.Extended.UI.HtmlEditor.isIE){var e=this._doc.selection;return e}this.focusEditor();var e,t,i,n=this.get_element().contentWindow;e=n.getSelection(),t=this._createRange(e),i=t.startContainer;try{for(;i&&i.nodeType;)i=i.parentNode}catch(i){this._removeAllRanges(e),t=this._createRange(e),t.setStart(this._saved_startContainer,this._saved_startOffset),t.setEnd(this._saved_startContainer,this._saved_startOffset),this._selectRange(e,t),e=n.getSelection()}return e},_createRange:function(e){if(Sys.Extended.UI.HtmlEditor.isIE)return"undefined"==typeof e?this._doc.body.createTextRange():e.createRange();if(this.focusEditor(),"undefined"==typeof e)return this._doc.createRange();try{var t=e.getRangeAt(0);return t}catch(e){return this._doc.createRange()}},toEndOfProtected:function(){var e,t=this,i=this._getSelection();try{e=this._createRange(i)}catch(e){return!1}var n;if(Sys.Extended.UI.HtmlEditor.isIE?n=Sys.Extended.UI.HtmlEditor.contentEditable(Sys.Extended.UI.HtmlEditor.getSelParent(t)):(n=Sys.Extended.UI.HtmlEditor.contentEditable(e.startContainer),null==n&&(n=Sys.Extended.UI.HtmlEditor.contentEditable(e.endContainer))),Sys.Extended.UI.HtmlEditor.isIE&&null!=n){try{e.remove(n)}catch(e){}e=t._doc.body.createControlRange(),e.add(n),e.select()}else if(!Sys.Extended.UI.HtmlEditor.isIE&&null!=n){var r,s=t._getSelection();null!=n.nextSibling&&3==n.nextSibling.nodeType?r=n.nextSibling:(r=t._doc.createTextNode(""),null!=n.nextSibling?n.parentNode.insertBefore(r,n.nextSibling):n.parentNode.appendChild(r)),t._removeAllRanges(s);var e=t._createRange(s);e.setStart(r,0),e.setEnd(r,0),t._selectRange(s,e)}return!0},_commonPaste:function(e){var t=this;if(this._saveContent(),Sys.Extended.UI.HtmlEditor.isIE)this.openWait(),setTimeout(function(){t._paste(!t._editPanel.get_noPaste()),t.closeWait()},0),Sys.Extended.UI.HtmlEditor._stopEvent(e);else if(this.isPlainText||this.isWord||this._editPanel.get_noPaste()){var i=t._getSafePlace();if(null!=i){var n=t._doc.createElement("div");n.style.display="inline",n.style.borderStyle="none",i.parentNode.insertBefore(n,i),n.appendChild(i),n.removeChild(i),n.innerHTML="xx";var r=t._getSelection(),s=t._createRange();t._removeAllRanges(r),s.setStart(n.firstChild,0),s.setEnd(n.firstChild,1),t._selectRange(r,s),t.openWait(),setTimeout(function(){var e=n.parentNode;if(n.lastChild.deleteData(n.lastChild.length-1,1),t.isWord)n.innerHTML=Sys.Extended.UI.HtmlEditor.cleanUp(n.innerHTML),Sys.Extended.UI.HtmlEditor.replaceOldTags(n,t),Sys.Extended.UI.HtmlEditor.spanJoiner(n,t._doc);else{var i=document.createElement("div");i.innerHTML=Sys.Extended.UI.HtmlEditor.cleanUp(n.innerHTML);var r=new Sys.Extended.UI.HtmlEditor.jsDocument((!0));Sys.Extended.UI.HtmlEditor.__MozillaGetInnerText(i,r),n.innerHTML=r.toString().replace(/</g,"<").replace(/>/g,">").replace(/\r/g,"").replace(/\n/g,"<br/>").replace(/\t/g," "),delete i}for(;n.firstChild;)e.insertBefore(n.firstChild,n);var s=null,d=null;n.nextSibling&&3==n.nextSibling.nodeType&&n.previousSibling&&3==n.previousSibling.nodeType&&(s=n.nextSibling,d=n.previousSibling),e.removeChild(n);var o=null;if(null!=s&&null!=d&&(o=d.data.length,d.data=""+d.data+s.data,s.parentNode.removeChild(s)),t.isWord=!1,t.isPlainText=!1,t.closeWait(),null!=o){var a=t._getSelection(),l=t._createRange();t._removeAllRanges(a),l.setStart(d,o),l.setEnd(d,o),t._selectRange(a,l)}t.onContentChanged()},0)}else Sys.Extended.UI.HtmlEditor._stopEvent(e)}else setTimeout(function(){Sys.Extended.UI.HtmlEditor.operateAnchors(t,t._doc,!t._editPanel.get_showAnchors()),Sys.Extended.UI.HtmlEditor.operatePlaceHolders(t,t._doc,!t._editPanel.get_showPlaceHolders()),Sys.Extended.UI.HtmlEditor.inspectForShadows(t._doc.body),t._checkImages(t._doc.body),t.onContentChanged()},0)},_selectRange:function(e,t){e.addRange(t),this.focusEditor()},_selectRng:function(e){var t=this._getSelection();if(Sys.Extended.UI.HtmlEditor.isIE){var i=this._createRange(t),n=this._createRange(t),r=this._doc.createElement("span"),s=this._doc.createElement("span");e[0].parentNode.insertBefore(r,e[0]),e[e.length-1].nextSibling?e[e.length-1].parentNode.insertBefore(s,e[e.length-1].nextSibling):e[e.length-1].parentNode.appendChild(s);try{i.moveToElementText(r);var d=i.moveStart("character",1);i.moveStart("character",-d),n.moveToElementText(s),d=n.moveEnd("character",-1),n.moveEnd("character",-d),i.setEndPoint("EndToEnd",n),i.select()}catch(e){}e[0].parentNode.removeChild(r),e[e.length-1].parentNode.removeChild(s)}else{var o=this._doc.createRange();o.setStart(e[0],0),o.setEnd(e[e.length-1],(""+e[e.length-1].data).length),this._removeAllRanges(t),this._selectRange(t,o)}},_removeAllRanges:function(e){e.removeAllRanges()},_setToEnd:function(){var e=this;setTimeout(function(){e._setToEnd_(),e._editPanel.updateToolbar()},0)},_setToEnd_:function(){var e=this;if(Sys.Extended.UI.HtmlEditor.isIE){var t=e._getSelection(),i=e._createRange(t);return"control"!=t.type.toLowerCase()&&(i.moveEnd("textedit",1),i.collapse(!1)),i.select(),void e.focusEditor()}var n=0,r=e._doc.body,s=null;if(r.lastChild&&3==r.lastChild.nodeType)r=r.lastChild,n=(""+r.data).length;else{var d=e._doc.createTextNode("");r.lastChild&&1==r.lastChild.nodeType&&"BR"==r.lastChild.tagName.toUpperCase()?r.insertBefore(d,r.lastChild):r.appendChild(d),r=d,n=0}var t=e._getSelection();e._removeAllRanges(t);var i=e._createRange();if(i.setStart(r,n),i.setEnd(r,n),e._selectRange(t,i),null!=s&&e._doc.body.removeChild(s),e.focusEditor(),!Sys.Extended.UI.HtmlEditor.isSafari&&!Sys.Extended.UI.HtmlEditor.isOpera)try{var s=e._doc.createElement("button");s.style.width="0px",s.style.height="20px",e._doc.body.appendChild(s),s.focus(),s.blur(),e.focusEditor(),e._doc.body.removeChild(s)}catch(e){}},isShadowed:function(){if(!this.isControl())return!1;var e,t=this._getSelection(),i=this._createRange(t);if(e=Sys.Extended.UI.HtmlEditor.isIE?i.item(0):i.startContainer.childNodes.item(i.startOffset),e.tagName&&"IMG"==e.tagName.toUpperCase()&&e.getAttribute(Sys.Extended.UI.HtmlEditor.attachedIdAttribute)&&e.getAttribute(Sys.Extended.UI.HtmlEditor.attachedIdAttribute).length>0){var n=this.getAttachedElement(e);if(null!=n){if(Sys.Extended.UI.HtmlEditor.isIE)i=this._doc.body.createControlRange(),i.add(n),i.select();else try{var r=Sys.Extended.UI.HtmlEditor.__getIndex(n);t.collapseToEnd(),this._removeAllRanges(t),i=this._createRange(t),i.setStart(n.parentNode,r),i.setEnd(n.parentNode,r+1),this._selectRange(t,i)}catch(e){return!0}return!1}return!0}return!1},_ifShadow:function(){if(Sys.Extended.UI.HtmlEditor.isIE)try{this._doc.selection}catch(e){return!1}for(var e=this,t=null,i=Sys.Extended.UI.HtmlEditor.getSelParent(e);i&&(3==i.nodeType||i.tagName&&"BODY"!=i.tagName.toUpperCase());)if(3!=i.nodeType&&i.tagName){var n=i.tagName.toUpperCase();if("TABLE"==n&&i.getAttribute(Sys.Extended.UI.HtmlEditor.noContextMenuAttribute)&&"yes"==i.getAttribute(Sys.Extended.UI.HtmlEditor.noContextMenuAttribute)){t=i.rows.item(0).cells.item(0).firstChild,Sys.Extended.UI.HtmlEditor.isIE&&"P"==n&&(t=t.firstChild);break}i=i.parentNode}else i=i.parentNode;if(null!=t){var r=e._getSelection(),s=e._createRange(r);if(Sys.Extended.UI.HtmlEditor.isIE)s=e._doc.body.createControlRange(),s.add(t),s.select();else try{r.collapseToEnd(),e._removeAllRanges(r),s=e._createRange(r),s.setStart(t.parentNode,0),s.setEnd(t.parentNode,1),e._selectRange(r,s)}catch(e){}}},_saveContent:function(){var e,t,i;try{try{e=this._getSelection(),t=this._createRange(e)}catch(e){}i=new Sys.Extended.UI.HtmlEditor._Marker(this,t,e)}catch(e){return}for(this.__stack||(this.__stack=[],this.__stackPos=0);this.__stackPos<this.__stack.length;)this.__stack.pop();this.__stack.length==Sys.Extended.UI.HtmlEditor.__stackMaxSize&&(this.__stack.reverse(),this.__stack.pop(),this.__stack.reverse()),this.__stack.push(i),this.__stackPos=this.__stack.length},_restoreContent:function(){function e(e,t,i,n,r){return t.replace(/\salign=[^\s>]*/gi,"")+('"X"'==n?"":"align="+n)+r.replace(/\salign=[^\s>]*/gi,"")}if(this.__stack&&this.__stackPos>=0&&this.__stackPos<this.__stack.length){var t,i,n=this.__stack[this.__stackPos];if(Sys.Extended.UI.HtmlEditor.isIE){for(var r=this._doc.body.getElementsByTagName("EMBED"),s=[],d=0;d<r.length;d++)s.push(r[d]);for(var o=0;o<s.length;o++)s[o].parentNode.removeChild(s[o]);var a=n._save.replace(/&/gi,"&");a=a.replace(/(<embed(?:.*?))(teoalign=)(\"[^\"]*\")((?:.*?)>)/gi,e),this._doc.body.innerHTML="!!!<span></span>"+Sys.Extended.UI.HtmlEditor.Trim(a),this._doc.body.firstChild&&this._doc.body.removeChild(this._doc.body.firstChild),this._doc.body.firstChild&&this._doc.body.removeChild(this._doc.body.firstChild);var l=Sys.Extended.UI.HtmlEditor.getHrefsText(a);if(Sys.Extended.UI.HtmlEditor.setHrefsText(this._doc.body,l),this._editPanel.get_relativeImages()&&(l=Sys.Extended.UI.HtmlEditor.getImagesText(a),Sys.Extended.UI.HtmlEditor.setImagesText(this._doc.body,l)),Sys.Extended.UI.HtmlEditor.setNames(this._doc.body,n._nArr),Sys.Extended.UI.HtmlEditor.operateAnchors(this,this._doc,!this._editPanel.get_showAnchors()),Sys.Extended.UI.HtmlEditor.operatePlaceHolders(this,this._doc,!this._editPanel.get_showPlaceHolders()),null!=n._tree){var d,c=this._doc.body;try{for(d=n._tree.length-1;d>=0;d--)c=c.childNodes.item(n._tree[d])}catch(e){return void(this.__stackPos>0&&(this.__stackPos--,this._restoreContent(),this.__stackPos++))}try{var h=this._doc.body.createControlRange();h.add(c),h.select()}catch(e){}}else{var m=this;setTimeout(function(){try{if(m._editPanel==Sys.Extended.UI.HtmlEditor.LastFocusedEditPanel){if(t=m._getSelection(),i=m._createRange(t),"control"!=t.type.toLowerCase())try{i.moveToPoint(n._offsetLeft,n._offsetTop)}catch(e){}i.select()}}catch(e){}},0)}}else{if(Sys.Extended.UI.HtmlEditor.isOpera)this._doc.body.innerHTML=Sys.Extended.UI.HtmlEditor.Trim(n._save);else{this._doc.body.innerHTML="";for(var d=0;d<n._save.childNodes.length;d++)this._doc.body.appendChild(n._save.childNodes.item(d).cloneNode(!0))}Sys.Extended.UI.HtmlEditor.operateAnchors(this,this._doc,!this._editPanel.get_showAnchors()),Sys.Extended.UI.HtmlEditor.operatePlaceHolders(this,this._doc,!this._editPanel.get_showPlaceHolders());try{t=this._getSelection(),i=this._createRange(),this._removeAllRanges(t)}catch(e){}for(var g="",c=this._doc.body,d=n._tree.length-1;d>=0;d--)g+=" "+n._tree[d],c=c.childNodes.item(n._tree[d]);var _=n._offset;try{i.setStart(c,_),i.setEnd(c,_)}catch(e){return void Sys.Extended.UI.HtmlEditor.inspectForShadows(this._doc.body)}try{this._selectRange(t,i)}catch(e){}}try{Sys.Extended.UI.HtmlEditor.inspectForShadows(this._doc.body)}catch(e){}}},SaveContent:function(){this._saveContent()},RestoreContent:function(){this._undo(!1)},_undo:function(e){if(this.__stack&&this.__stackPos>0){this.__stackPos==this.__stack.length&&e&&this._saveContent();do{var t=Sys.Extended.UI.HtmlEditor.Trim(this._doc.body.innerHTML);this.__stackPos--,this._restoreContent()}while(Sys.Extended.UI.HtmlEditor.Trim(this._doc.body.innerHTML)==t&&this.__stackPos>0&&e);var i=this;setTimeout(function(){try{i._ifShadow()}catch(e){}if(i._editPanel==Sys.Extended.UI.HtmlEditor.LastFocusedEditPanel)try{i._editPanel.updateToolbar()}catch(e){}e||i.onContentChanged()},0)}},_redo:function(){if(this.__stack&&this.__stackPos<this.__stack.length-1){this.__stackPos++;var e,t=this;if(Sys.Extended.UI.HtmlEditor.isIE&&(e=t._doc.body.getElementsByTagName("EMBED").length,e>0)){var i=t._body.ownerDocument.createElement("div");t._body.appendChild(i),setTimeout(function(){t._body.removeChild(i)},0)}this._restoreContent();var t=this;setTimeout(function(){t._ifShadow(),t._editPanel.updateToolbar()},0)}},undo:function(){this._undo(!0),this.onContentChanged()},redo:function(){this._redo(),this.onContentChanged()},_contextMenuCallP:function(){},onContentChanged:function(){},_copyCut:function(e,t){var i=this;if(Sys.Extended.UI.HtmlEditor.isIE){var n=this._getSelection(),r=this._createRange(n),s=!1,d="";if("x"==e&&this._saveContent(),"control"==n.type.toLowerCase())s=!0,d=Sys.Extended.UI.HtmlEditor.getHTML(r.item(0),!0);else if(""!=r.text){s=!0,d=r.htmlText;var o=r.duplicate(),a=this._getTextNodeCollection();if(a.length<1)return;var l=Sys.Extended.UI.HtmlEditor._commonParent(a[0],a[a.length-1]);if(null!=l&&a[0].previousSibling&&3==a[0].previousSibling.nodeType)for(var c=l.parent;c&&"BODY"!=c.tagName.toUpperCase()&&Sys.Extended.UI.HtmlEditor.isStyleTag(c.tagName);){var h=c.cloneNode(!1);h.innerHTML=d,d=h.outerHTML,c=c.parentNode}n=this._getSelection(),n.empty(),r=this._createRange(n),r.setEndPoint("EndToEnd",o),r.setEndPoint("StartToStart",o),r.select()}else""!=r.htmlText&&(s=!0,d=r.htmlText);if(s){var m=this._doc.createElement("DIV");m.innerHTML="!!!<span></span>"+d,m.removeChild(m.firstChild),m.removeChild(m.firstChild);var g=Sys.Extended.UI.HtmlEditor.getHTML(m,!1,!0),_=new RegExp("(<[/]?)(teo"+Sys.Extended.UI.HtmlEditor.smartClassName+":)","ig");g=g.replace(_,"$1"),delete m,this._contentCopy(g,!0),r.select(),"x"==e&&(n.clear(),this._clearP())}else"x"==e&&(n.clear(),this._clearP());t&&setTimeout(function(){i._editPanel.updateToolbar()},0)}else if("x"==e){this._saveContent();var n=this._getSelection(),r=this._createRange(n);this._removeAllRanges(n),r.deleteContents(),""==this._doc.body.innerHTML&&(this._doc.body.innerHTML="<br/>",r.setStart(this._doc.body,0),r.setEnd(this._doc.body,0)),i.onContentChanged(),this._selectRange(n,r)}else{var n=this._getSelection(),r=this._createRange(n);this._removeAllRanges(n),alert(String.format(Sys.Extended.UI.Resources.HTMLEditor_toolbar_button_Use_verb,Sys.Extended.UI.HtmlEditor.isSafari&&navigator.userAgent.indexOf("mac")!=-1?"Apple-C":"Ctrl-C")),this._selectRange(n,r)}},_paste:function(e,t){var i,n,r=this,s=this._getSelection(),d=this._createRange(s);if(!e)return i=d.offsetLeft,n=d.offsetTop,this.insertHTML(this._getPlain()),void r.onContentChanged();if(!this._editPanel.get_noPaste()){i=d.offsetLeft,n=d.offsetTop;var o,a=this._doc.createElement("span"),l=this._contentCopy("",!1,t);if(/<[\/]*p[\s>]+/i.test(l)||/<[\/]*h/i.test(l))o=this._getSafePlace();else{if(o=this._doc.createElement("SPAN"),o.id=Sys.Extended.UI.HtmlEditor.smartClassName,!this.insertHTML(Sys.Extended.UI.HtmlEditor.getHTML(o,!0)))return;o=this._doc.getElementById(Sys.Extended.UI.HtmlEditor.smartClassName),o&&(o.id=null,o.removeAttribute("id"),o.setAttribute("para","no"))}if(a.innerHTML=l,o){this._checkImages(a);var c=o.parentNode,h=o.getAttribute("para");if("no"!=h){if(h.indexOf("left")>=0&&a.firstChild&&a.firstChild.tagName&&"P"==a.firstChild.tagName.toUpperCase()){for(;a.firstChild.firstChild;)o.previousSibling.appendChild(a.firstChild.firstChild);a.removeChild(a.firstChild)}if(h.indexOf("right")>=0&&a.lastChild&&a.lastChild.tagName&&"P"==a.lastChild.tagName.toUpperCase()){for(;a.lastChild.lastChild;)o.nextSibling.insertBefore(a.lastChild.lastChild,o.nextSibling.firstChild);a.removeChild(a.lastChild)}}var m=o,g=null;if(0==a.childNodes.length&&h.indexOf("left")>=0&&h.indexOf("right")>=0){for(o.nextSibling.firstChild&&(g=this._doc.createElement("span"),m=g,g.innerHTML="111",o.previousSibling.appendChild(g));o.nextSibling.firstChild;)o.previousSibling.appendChild(o.nextSibling.firstChild);c.removeChild(o.nextSibling)}else for(;a.firstChild;)c.insertBefore(a.firstChild,o);setTimeout(function(){var e=r._getSelection(),t=r._createRange(e);if("control"==e.type.toLowerCase())for(;t.length>0;)t.remove(0);try{t.collapse(!1)}catch(e){}r.focusEditor(),Sys.Extended.UI.HtmlEditor._setCursor(m,r),g&&g.parentNode.removeChild(g),c.removeChild(o),Sys.Extended.UI.HtmlEditor.inspectForShadows(r._doc.body),r.onContentChanged(),t.select()},0)}}},_contentCopy:function(e,t,i){""!=e&&(e=e.replace(/(<td[^>]*?>)([\s ]*?)(<\/td[^>]*?>)/gi,"$1 $3").replace(/(<td[^>]*?>)\s*( )\s*(<\/td[^>]*?>)/gi,"$1<br/>$3").replace(/(<p[^>]*?>)\s*( )\s*(<\/p[^>]*?>)/gi,"$1<br/>$3"));var n=this._doc.createElement("iframe");n.width="0",n.height="0",Sys.Extended.UI.HtmlEditor.isIE&&(n.src="javascript:false;"),this._doc.appendChild(n);var r=n.contentWindow.document;r.write("<html><head></head><body>"+e+"</body></html>"),r.close(),r.body.contentEditable=!0;var s=r.body.createTextRange(),d=!1;if(""==e){s.execCommand("paste");for(var o=r.createElement("DIV"),a=0;a<r.body.childNodes.length;a++){var l=r.body.childNodes.item(a);if(8==l.nodeType){var c=""+l.data;if(c.search(/StartFragment/i)>=0&&l.nextSibling&&3==l.nextSibling.nodeType){var c=""+l.nextSibling.data;if(c.length&&160==c.charCodeAt(0)){c=c.substr(1),l.nextSibling.data=c,d=!0;break}}}}"undefined"!=typeof i&&i&&(r.body.innerHTML=Sys.Extended.UI.HtmlEditor.cleanUp(r.body.innerHTML));var c=Sys.Extended.UI.HtmlEditor.Trim(Sys.Extended.UI.HtmlEditor.getHTML(r.body,!1,!0));if(c=c.replace(/(<script(?:[^>]*?)>(?:[^<]*?)<\/script(?:[^>]*?)>)/gi,""),r.body.innerHTML=c,!t){Sys.Extended.UI.HtmlEditor.operateAnchors(this,r,!this.showAnchors),Sys.Extended.UI.HtmlEditor.operatePlaceHolders(this,r,!this.showPlaceHolders);for(var h=r.body.getElementsByTagName("EMBED"),m=[],a=0;a<h.length;a++)m.push(h[a]);for(var g=0;g<m.length;g++)m[g].parentNode.removeChild(m[g])}delete s,delete o,t&&Sys.Extended.UI.HtmlEditor.isIE&&(s=r.body.createTextRange())}t&&Sys.Extended.UI.HtmlEditor.isIE&&(""!=e&&(Sys.Extended.UI.HtmlEditor.operateAnchors(this,r,!0),Sys.Extended.UI.HtmlEditor.operatePlaceHolders(this,r,!0)),s.select(),s.execCommand("copy"));for(var _=Sys.Extended.UI.HtmlEditor.Trim(r.body.innerHTML).replace(/<br\s*[\/]*>\s*<\/td>/gi,"</td>").replace(/(<td[^>]*?>)([\s ]*?)(<\/td[^>]*?>)/gi,"$1 $3").replace(/(<p[^>]*?>)\s*(<br[^>]*?>)\s*(<\/p[^>]*?>)/gi,"$1 $3").replace(/(<embed(?:.*?))(wmode=)(\"[^\"]*\")((?:.*?)>)/gi,"$1pseudomode=$3$4").replace(/(<embed)([^>]*?>)/gi,'$1 wmode="transparent"$2'),h=r.body.getElementsByTagName("EMBED"),m=[],a=0;a<h.length;a++)m.push(h[a]);for(var g=0;g<m.length;g++)m[g].parentNode.removeChild(m[g]);n.src="";var p=this;return p._doc.removeChild(n),delete n,_},insertHTML:function(e,t){function i(e,t){return'<span class="'+Sys.Extended.UI.HtmlEditor.smartClassName+"_script\" style='display:none;visibility:hidden;'>"+t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")+"</span>"}function n(e,t,i,n){return t.replace(/>/g,">").replace(/</g,"<").replace(/&/g,"&");
|
|
}this.focusEditor();var r=this._getSelection();if("undefined"==typeof t&&(t=this._createRange(r)),Sys.Extended.UI.HtmlEditor.isIE){var s='<span id="'+Sys.Extended.UI.HtmlEditor.smartClassName+'">111<span></span>'+e+"</span>",d=Sys.Extended.UI.HtmlEditor.getHrefsText(s),o=Sys.Extended.UI.HtmlEditor.getImagesText(s);s=this._editPanel.get_noScript()?s.replace(/(<script(?:[^>]*?)>.*?<\/script(?:[^>]*?)>)/gi,""):s.replace(/(<script(?:[^>]*?)>.*?<\/script(?:[^>]*?)>)/gi,i);try{if(t.pasteHTML)t.pasteHTML(s);else{var a=this._doc.createElement("DIV");for(a.innerHTML=s;a.firstChild;)t(0).parentNode.insertBefore(a.firstChild,t(0));t(0).parentNode.removeChild(t(0)),t.remove(0),delete a}}catch(e){return!1}var l=this._doc.getElementById(Sys.Extended.UI.HtmlEditor.smartClassName);for(l.innerHTML="<span>qqq</span>"+Sys.Extended.UI.HtmlEditor.getHTML(l,!1,!0).replace(new RegExp("<span(?:[^>]*?)class="+Sys.Extended.UI.HtmlEditor.smartClassName+"_script(?:[^>]*?)>(.*?)</span(?:[^>]*?)>","gi"),n)+"<span>qqq</span>",l.removeChild(l.firstChild),l.removeChild(l.lastChild),Sys.Extended.UI.HtmlEditor.setHrefsText(l,d),Sys.Extended.UI.HtmlEditor.setImagesText(l,o),l.firstChild&&l.removeChild(l.firstChild),l.firstChild&&l.removeChild(l.firstChild);l.firstChild;)l.parentNode.insertBefore(l.firstChild,l);return l.parentNode.removeChild(l),delete l,!0}var a=this._doc.createElement("div");a.innerHTML=e;for(var c=a.getElementsByTagName("EMBED"),h=[],m=0;m<c.length;m++)h.push(c[m]);for(var g=0;g<h.length;g++){var _=h[g],p=document.createElement("IMG"),E=_.attributes;p.src=this._images_list[1],p.setAttribute("dummytag","embed");for(var m=0;m<E.length;++m){var u=E.item(m);if(u.specified){var f=u.name.toLowerCase(),y=u.value;"src"==f?f="dummysrc":"bgcolor"==f?f="dummybgcolor":"wmode"==f&&(f="pseudomode"),p.setAttribute(f,y)}}p.getAttribute("type"),p.style.cssText="border: 1px dotted #000000; background-image: url('"+("application/x-mplayer2"==p.getAttribute("type").toLowerCase()?this._images_list[3]:this._images_list[2])+"'); background-position: center; background-repeat: no-repeat; background-color: #c0c0c0;",_.parentNode.insertBefore(p,_),_.parentNode.removeChild(_)}var S=this.insertNodeAtSelection(a,t);return S},insertNodeAtSelection:function(e,t){if(Sys.Extended.UI.HtmlEditor.isIE)return!1;var i=this._getSelection();if("undefined"==typeof t)try{t=this._createRange(i)}catch(e){return this._removeAllRanges(i),!1}var n=t.startContainer,r=t.startOffset;if("EditorDocument"!=n.ownerDocument.id&&"ms__id"!=n.ownerDocument.uniqueID.substring(0,6))return!1;if(1==t.startContainer.nodeType&&"TR"==t.startContainer.tagName.toUpperCase()||1==t.endContainer.nodeType&&"TR"==t.endContainer.tagName.toUpperCase())return!1;this._removeAllRanges(i),t.deleteContents();try{t=this._createRange()}catch(e){return this._removeAllRanges(i),!1}switch(n.nodeType){case 3:for(r>0&&(n=n.splitText(r));e.firstChild;)n.parentNode.insertBefore(e.firstChild,n);t.setStart(n,0),t.setEnd(n,0);break;case 1:case 11:try{if(this._removeAllRanges(i),n.childNodes.length>=r+1){for(n=n.childNodes.item(r);e.firstChild;)n.parentNode.insertBefore(e.firstChild,n);var s=this._doc.createTextNode("");n.parentNode.insertBefore(s,n),n=s}else{var s=this._doc.createTextNode("");if(Sys.Extended.UI.HtmlEditor.canHaveChildren(n)){for(;e.firstChild;)n.appendChild(e.firstChild);n.appendChild(s)}else{for(;e.firstChild;)n.parentNode.insertBefore(e.firstChild,n);n.parentNode.insertBefore(s,n)}n=s}if(1==n.nodeType){for(var d=n.parentNode,o=0;o<d.childNodes.length&&n!=d.childNodes.item(o);o++);t.setStart(d,o),t.setEnd(d,o)}else t.setStart(n,0),t.setEnd(n,0)}catch(e){return this._removeAllRanges(i),!1}}return this._selectRange(i,t),!0},trickWithStyles:function(e){var t=this,i=t._doc.getElementById(e);if(null!=i)if(i.nextSibling&&3==i.nextSibling.nodeType){var n=i.nextSibling;i.parentNode.removeChild(i);var r=(""+n.data).indexOf(" ");if(r>0?n.splitText(r):0==r&&n.splitText(1),null!=t.n_arr)for(var s=0;s<t.n_arr.length;s++)t.MSIE_applyCssStyle(t.n_arr[s],[n],!1);t.n_arr=null;var d=t._getSelection();if(Sys.Extended.UI.HtmlEditor.isIE){var o=t._createRange(d),a=t._doc.createElement("span");n.nextSibling?n.parentNode.insertBefore(a,n.nextSibling):n.parentNode.appendChild(a);try{o.moveToElementText(a),o.select()}catch(e){}a.parentNode.removeChild(a)}else{var l=t._doc.createRange();l.setStart(n,n.length),l.setEnd(n,n.length),t._removeAllRanges(d),t._selectRange(d,l)}}else i.parentNode.removeChild(i)},_getParent:function(e){return Sys.Extended.UI.HtmlEditor.isIE?e.parentElement():e.startContainer},_checkImages:function(e){if(this._editPanel.get_relativeImages())for(var t=e.getElementsByTagName("IMG"),i=0;i<t.length;i++){var n=t[i];if(n.src.indexOf("http://")>=0){var r=n.src;n.src="qwerty.gif";var s=n.src.indexOf("qwerty.gif");r.substr(0,s)==n.src.substr(0,s)&&(r=r.substr(s,r.length-s)),n.src=r}}},_getSafePlace:function(e){function t(e,i,s,d){var o=Sys.Extended.UI.HtmlEditor.myClone(s,n._doc,!1);for(e&&o.appendChild(e);i;){if(1==i.nodeType||3==i.nodeType&&Sys.Extended.UI.HtmlEditor.Trim(""+i.data).length>0){var a=null;i.tagName&&"SCRIPT"==i.tagName.toUpperCase()&&(a=i.text);var l=Sys.Extended.UI.HtmlEditor.myClone(i,n._doc,!0);0!=o.childNodes.length&&d?o.insertBefore(l,o.firstChild):o.appendChild(l),null!=a&&(l.text=a)}i=d?i.previousSibling:i.nextSibling}return 0==o.childNodes.length&&(delete o,o=null),s==r?o:t(o,d?s.previousSibling:s.nextSibling,s.parentNode,d)}var i=this._doc.createElement("SPAN"),n=this;if(i.id=Sys.Extended.UI.HtmlEditor.smartClassName,"undefined"==typeof e){if(!this.insertHTML(Sys.Extended.UI.HtmlEditor.getHTML(i,!0)))return null}else null==e.nextSibling?e.parentNode.appendChild(i):e.parentNode.insertBefore(i,e.nextSibling),e.parentNode.removeChild(e);i=this._doc.getElementById(Sys.Extended.UI.HtmlEditor.smartClassName),i.id=null,i.removeAttribute("id"),i.setAttribute("para","no");for(var r=i.parentNode,s=r.tagName.toUpperCase();"BODY"!=s&&"TD"!=s&&"P"!=s&&"DIV"!=s&&Sys.Extended.UI.HtmlEditor.isStyleTag(r.tagName);)r=r.parentNode,s=r.tagName.toUpperCase();if("P"==s){i.setAttribute("para","");var d=t(null,i.previousSibling,i.parentNode,!0),o=t(null,i.nextSibling,i.parentNode,!1),a=r.parentNode;d&&(a.insertBefore(d,r),i.setAttribute("para",i.getAttribute("para")+" left")),a.insertBefore(i,r),o&&(a.insertBefore(o,r),i.setAttribute("para",i.getAttribute("para")+" right")),a.removeChild(r)}return i},noContextMenuAttributeName:function(){return Sys.Extended.UI.HtmlEditor.noContextMenuAttribute},_getTextNodeCollection:function(e){function t(e,n){for(;e;){if(e.id&&e.id==d)return void(E=!0);if(3==e.nodeType){for(;e.nextSibling&&(3==e.nextSibling.nodeType||!Sys.Extended.UI.HtmlEditor.isIE&&"undefined"!=typeof u.__saveBM__&&null!=u.__saveBM__&&u.__saveBM__[0]==e.nextSibling);)3==e.nextSibling.nodeType?e.data=""+e.data+e.nextSibling.data:(u.__saveBM__[0]=e,u.__saveBM__[1]=(""+e.data).length),e.parentNode.removeChild(e.nextSibling);Sys.Extended.UI.HtmlEditor.Trim(""+e.data).length>0&&i.push(e)}else{var r=e.tagName;e.tagName&&(r=r.toUpperCase(),"MAP"!=r&&"AREA"!=r&&"SCRIPT"!=r&&"NOSCRIPT"!=r&&(!e.style||"none"!=Sys.Extended.UI.HtmlEditor.getStyle(e,"display")&&"hidden"!=Sys.Extended.UI.HtmlEditor.getStyle(e,"visibility"))&&t(e.firstChild,!1))}if(E)return;e.parentNode;if(n)for(;null==e.nextSibling;)e=e.parentNode;e=e.nextSibling}}var i=[];if(this.isControl())return i;var n,r=this._getSelection(),s=this._createRange(r),d=Sys.Extended.UI.HtmlEditor.smartClassName+"_right",o=Sys.Extended.UI.HtmlEditor.smartClassName+"_left",a=null,l=null;if("undefined"==typeof e){if(Sys.Extended.UI.HtmlEditor.isIE?(a=s.duplicate(),l=s.duplicate(),a.setEndPoint("EndToStart",s),l.setEndPoint("StartToEnd",s)):(a=s.cloneRange(),l=s.cloneRange(),a.setEnd(a.startContainer,a.startOffset),l.setStart(l.endContainer,l.endOffset),n=a.endOffset),!this.insertHTML("<span id='"+d+"'/>",l))return i;if(Sys.Extended.UI.HtmlEditor.isOpera&&(a.setEnd(a.startContainer,n),a.setStart(a.startContainer,n)),!this.insertHTML("<span id='"+o+"'/>",a)){var c=this._doc.getElementById(d);null!=c&&(p=c.parentNode,p.removeChild(c));var h=this._doc.getElementById(rl);return null!=h&&(p=h.parentNode,p.removeChild(h)),i}}else{var m;m=this._doc.createElement("SPAN"),m.id=d,this._doc.body.appendChild(m),m=this._doc.createElement("SPAN"),m.id=o,this._doc.body.insertBefore(m,this._doc.body.firstChild)}var g=this._doc.getElementById(o),_=this._doc.getElementById(d);if(null==g||null==_){var p;return null!=g&&(p=g.parentNode,p.removeChild(g)),null!=_&&(p=_.parentNode,p.removeChild(_)),[]}for(;g.firstChild;)g.removeChild(g.firstChild);for(;_.firstChild;)_.removeChild(_.firstChild);for(;g.previousSibling&&3==g.previousSibling.nodeType&&0==Sys.Extended.UI.HtmlEditor.Trim(""+g.previousSibling.data).length;)g.parentNode.removeChild(g.previousSibling);for(;g.nextSibling&&3==g.nextSibling.nodeType&&0==Sys.Extended.UI.HtmlEditor.Trim(""+g.nextSibling.data).length;)g.parentNode.removeChild(g.nextSibling);for(;_.previousSibling&&3==_.previousSibling.nodeType&&0==Sys.Extended.UI.HtmlEditor.Trim(""+_.previousSibling.data).length;)_.parentNode.removeChild(_.previousSibling);for(;_.nextSibling&&3==_.nextSibling.nodeType&&0==Sys.Extended.UI.HtmlEditor.Trim(""+_.nextSibling.data).length;)_.parentNode.removeChild(_.nextSibling);var E=!1,u=this;t(g,!0);var p;if(p=g.parentNode,p.removeChild(g),p=_.parentNode,p.removeChild(_),"undefined"==typeof e)if(Sys.Extended.UI.HtmlEditor.isIE)r.empty(),l.select();else if(i.length>0){this._removeAllRanges(r);var f=this._createRange();f.setEnd(i[i.length-1],i[i.length-1].length),f.setStart(i[i.length-1],i[i.length-1].length),this._selectRange(r,f)}return i},_getPlain:function(){var e=this._doc.createElement("textarea");e.width="0",e.height="0",this._doc.appendChild(e);var t=e.createTextRange();t.execCommand("paste");var i=e.value;return i=i.replace(/</g,"<").replace(/>/g,">").replace(/\r/g,"").replace(/\n/g,"<br/>"),this._doc.removeChild(e),i},_execCommand:function(e,t,i){var n,r,s=this;if(Sys.Extended.UI.HtmlEditor.isIE&&!this.isControl()){n=this._getSelection(),r=this._createRange(n);var d=r.parentElement();if("TEXTAREA"==d.tagName.toUpperCase())return}switch("createlink"!=e.toLowerCase()&&this._saveContent(),e.toLowerCase()){case"createlink":if(Sys.Extended.UI.HtmlEditor.isIE||!t)this._doc.execCommand(e,t,i);else{var i;(i=prompt("Enter URL"))&&this._doc.execCommand(e,!1,i)}break;case"backcolor":case"forecolor":case"fontname":case"fontsize":this.MSIE_applyCommand(e.toLowerCase(),i);break;case"indent":this.MSIE_indent(!0);break;case"outdent":this.MSIE_indent(!1);break;case"justifyleft":this.MSIE_justify("left");break;case"justifyfull":this.MSIE_justify("justify");break;case"justifycenter":this.MSIE_justify("center");break;case"justifyright":this.MSIE_justify("right");break;case"paragraph":this.MSIE_justify("remain",!1,"P");break;case"formatblock":if(null!=i&&"string"==typeof i&&2==i.length&&"H"==i.substr(0,1).toUpperCase()&&parseInt(i.substr(1,1))>0){this.MSIE_justify("remain",!1,i);break}this._doc.execCommand(e,t,i);break;case"insertunorderedlist":this.MSIE_list("UL");break;case"insertorderedlist":this.MSIE_list("OL");break;case"bold":case"italic":case"underline":case"strikethrough":case"superscript":case"subscript":this.MSIE_applyCommand(e.toLowerCase());break;default:this._doc.execCommand(e,t,i)}this.onContentChanged(),Sys.Extended.UI.HtmlEditor.isIE||(n=this._getSelection(),r=this._createRange(n),this._removeAllRanges(n),this._selectRange(n,r),this.focusEditor());var s=this;setTimeout(function(){s._editPanel.updateToolbar()},0)},MSIE_indent:function(e){return Function.createDelegate(this,Sys.Extended.UI.HtmlEditor.MSIE_indent)(e)},MSIE_justify:function(e,t,i){return Function.createDelegate(this,Sys.Extended.UI.HtmlEditor.MSIE_justify)(e,t,i)},MSIE_list:function(e){return Function.createDelegate(this,Sys.Extended.UI.HtmlEditor.MSIE_list)(e)},getSelectionAfterOperation:function(e){return Function.createDelegate(this,Sys.Extended.UI.HtmlEditor.getSelectionAfterOperation)(e)},setSelectionAfterOperation:function(e,t){return Function.createDelegate(this,Sys.Extended.UI.HtmlEditor.setSelectionAfterOperation)(e,t)},get_paragraphs:function(){return Function.createDelegate(this,Sys.Extended.UI.HtmlEditor.get_paragraphs)()},getPseudoP:function(){return Function.createDelegate(this,Sys.Extended.UI.HtmlEditor.getPseudoP)()},getPseudoP_Recur:function(e,t,i){return Function.createDelegate(this,Sys.Extended.UI.HtmlEditor.getPseudoP_Recur)(e,t,i)},unWrap:function(e,t){return Function.createDelegate(this,Sys.Extended.UI.HtmlEditor.unWrap)(e,t)},tryUnWrap:function(e,t,i){return Function.createDelegate(this,Sys.Extended.UI.HtmlEditor.tryUnWrap)(e,t,i)},MSIE_applyCommand:function(e,t){var i=Sys.Extended.UI.HtmlEditor.isIE?"":Sys.Extended.UI.HtmlEditor.Trim(this.getSelectedHTML());if(!this.isControl()){var n=this._getSelection(),r=this._createRange(n),s=(Sys.Extended.UI.HtmlEditor.isIE?[r.boundingLeft,r.boundingTop]:[r.startContainer,r.startOffset],Sys.Extended.UI.HtmlEditor.isIE&&r.text.length>0||!Sys.Extended.UI.HtmlEditor.isIE&&i.length>0),d={name:"none",value:"none"};switch(e.toLowerCase()){case"bold":d={name:"font-weight",value:"bold",repl:!1};break;case"italic":d={name:"font-style",value:"italic",repl:!1};break;case"underline":d={name:"text-decoration",value:"underline",repl:!1};break;case"strikethrough":d={name:"text-decoration",value:"line-through",repl:!1};break;case"superscript":d={name:"vertical-align",value:"super",repl:!1};break;case"subscript":d={name:"vertical-align",value:"sub",repl:!1};break;case"forecolor":d={name:"color",value:t,repl:!1};break;case"backcolor":d={name:"background-color",value:t,repl:!1};break;case"fontname":d={name:"font-family",value:t,repl:!1};break;case"fontsize":d={name:"font-size",value:t,repl:!1}}if(s){var o=this._getTextNodeCollection();this.MSIE_applyCssStyle(d,o,!0)}else{if(this.isControl())return;var o=this._tryExpand();o.length>0?(this.MSIE_applyCssStyle(d,o,!1),Sys.Extended.UI.HtmlEditor.isIE&&null!=this.__saveBM__?(n=this._getSelection(),r=this._createRange(n),r.moveToBookmark(this.__saveBM__),r.select(),this.__saveBM__=null):null!=this.__saveBM__&&(3==this.__saveBM__[0].nodeType?(n=this._getSelection(),r=this._doc.createRange(),r.setStart(this.__saveBM__[0],this.__saveBM__[1]),r.setEnd(this.__saveBM__[0],this.__saveBM__[1]),this._removeAllRanges(n),this._selectRange(n,r)):(this._trySelect(this.__saveBM__[0],this.__saveBM__[0]),this.__saveBM__[0].parentNode.removeChild(this.__saveBM__[0])),this.__saveBM__=null)):this._setStyleForTyping(d)}}},MSIE_applyCssStyle:function(e,t,i){var n=e.name.replace(/\-(\w)/g,function(e,t){return t.toUpperCase()}),r=e.value,s=e.repl,d=!1,o=!1;this._saveContent();var a=Sys.Extended.UI.HtmlEditor.smartClassName+"_right",l=Sys.Extended.UI.HtmlEditor.smartClassName+"_left",c=this._doc.createElement("SPAN");c.id=l;var h=this._doc.createElement("SPAN");h.id=a,t[0].parentNode.insertBefore(c,t[0]),null!=t[t.length-1].nextSibling?t[t.length-1].parentNode.insertBefore(h,t[t.length-1].nextSibling):t[t.length-1].parentNode.appendChild(h),Sys.Extended.UI.HtmlEditor.unStyle(c),Sys.Extended.UI.HtmlEditor.unStyle(h);for(var m=[],g=0;g<t.length;g++){var _,p=t[g],E=p.parentNode;for(_=0;_<m.length;_++){var u=m[_];if(u.parent==E){u.textNodes.push(p);break}}_==m.length&&m.push({parent:E,textNodes:[p]})}for(var g=0;g<m.length;g++){var u=m[g];if(u.textNodes.length>1){var f=u.textNodes,y=this._doc.createElement("SPAN"),S=this._doc.createElement("SPAN");f[0].parentNode.insertBefore(y,f[0]),null!=f[f.length-1].nextSibling?f[f.length-1].parentNode.insertBefore(S,f[f.length-1].nextSibling):f[f.length-1].parentNode.appendChild(S),Sys.Extended.UI.HtmlEditor._moveTagsUp(y,S),y.parentNode.removeChild(y),S.parentNode.removeChild(S)}}for(var g=0;g<t.length;g++){for(var p=t[g],E=p.parentNode,v=!1;E&&E.tagName&&1==E.childNodes.length&&Sys.Extended.UI.HtmlEditor.isStyleTag(E.tagName);){var x=E.tagName.toUpperCase();if(("I"==x||"EM"==x)&&"font-style"==e.name||("B"==x||"STRONG"==x)&&"font-weight"==e.name||("S"==x||"STRIKE"==x)&&"text-decoration"==e.name||"U"==x&&"text-decoration"==e.name||("SUB"==x||"SUP"==x)&&"vertical-align"==e.name){var C=E;for(E=E.parentNode;C.firstChild;)E.insertBefore(C.firstChild,C);E.removeChild(C),v=!0}else{if(E.style&&E.style[n]&&E.style[n].length>0){var I=E.style[n];if(n.toLowerCase().indexOf("color")>=0||"fontFamily"==n||"fontSize"==n)E.style[n]=r;else if(s)try{E.style[n]=E.style[n]+" "+r,I==E.style[n]&&(E.style[n]=r)}catch(e){E.style[n]=r}else if(d)if(o)E.style[n]=I.replace(r,"").replace(/,/,"");else try{E.style[n]=E.style[n]+" "+r,I==E.style[n]&&(E.style[n]=r)}catch(e){E.style[n]=r}else{var b=I.replace(r,"");if("fontWeight"==n&&"700"==I.toString()&&(b=""),b==I)try{E.style[n]=E.style[n]+" "+r,I==E.style[n]&&(E.style[n]=r)}catch(e){E.style[n]=r}else E.style[n]=b.replace(/,/,""),o=!0;d=!0}v=!0}E=E.parentNode}}if(!v&&!o){var H;H=this._doc.createElement("SPAN"),H.style[n]=r;var U=p.parentNode;U.insertBefore(H,p),H.appendChild(p),d=!0}}var T=Sys.Extended.UI.HtmlEditor._commonTotalParent(c,h),N=T.parent.childNodes.item(T.indexFirst).previousSibling,P=T.parent.childNodes.item(T.indexLast).nextSibling;c.parentNode.removeChild(c),h.parentNode.removeChild(h);var R=0,M=T.parent.childNodes.length;if(null!=N&&(R=Sys.Extended.UI.HtmlEditor.__getIndex(N)),null!=P&&(M=Sys.Extended.UI.HtmlEditor.__getIndex(P)+1,M<T.parent.childNodes.length))if(3==P.nodeType)M++;else if(1==P.nodeType){var A=P.tagName.toUpperCase();"TR"!=A&&"TD"!=A&&"LI"!=A&&M++}Sys.Extended.UI.HtmlEditor.spanJoiner(T.parent,this._doc,R,M);var w=this;i&&w._selectRng(t),setTimeout(function(){Sys.Extended.UI.HtmlEditor.isIE||w.focusEditor(),w._editPanel.updateToolbar()},0)},_tryExpand:function(e){function t(e){var t=/[\d\w]/;return!t.test(e)&&(t=/[\u0080-\u024F]/,!t.test(e)&&(t=/[\u0370-\u2000]/,!t.test(e)))}var i,n,r,s,d=[],o=this._getSelection(),a=this._createRange(o),l=Sys.Extended.UI.HtmlEditor.smartClassName+"_right_add",c=Sys.Extended.UI.HtmlEditor.smartClassName+"_left_add",h=Sys.Extended.UI.HtmlEditor.smartClassName+"_middle_add";if(Sys.Extended.UI.HtmlEditor.isIE&&"undefined"==typeof e&&(a.execCommand("bold"),this.__saveBM__=a.getBookmark(),a.execCommand("bold")),Sys.Extended.UI.HtmlEditor.isIE){var m=null,g="<span id="+h+"></span>",_=a.duplicate();try{a.pasteHTML(g)}catch(e){}if(m=this._doc.getElementById(h),null==m)return[];if("undefined"!=typeof e&&(this.__saveBM__=m),null!=m.nextSibling&&!Sys.Extended.UI.HtmlEditor.isInlineElement(m.nextSibling))return m.parentNode.removeChild(m),[];if(a.expand("word"),a.select(),0==a.text.length)return m.parentNode.removeChild(m),_.select(),[];var p=new RegExp(g,"ig");if(!p.test(a.htmlText.replace(/[\n\r]/g,"")))return m.parentNode.removeChild(m),_.select(),[];if(p=new RegExp(g+"(</span>| |[\\s])*$","ig"),p.test(a.htmlText.replace(/[\n\r]/g,"")))return m.parentNode.removeChild(m),_.select(),[];for(;a.text.length>0&&" "==a.text.substr(a.text.length-1,1);)if(a.moveEnd("character",-1),a.select(),0==a.text.length)return m.parentNode.removeChild(m),_.select(),[];return"undefined"==typeof e&&m.parentNode.removeChild(m),this._getTextNodeCollection()}if(!this.insertHTML("<span id='"+c+"'></span><span id='"+h+"'></span><span id='"+l+"'></span>"))return[];var E=this._doc.getElementById(c),u=this._doc.getElementById(l),f=this._doc.getElementById(h);Sys.Extended.UI.HtmlEditor.positionInParagraph(E,E.previousSibling,!0,E.parentNode,t);try{this._trySelect(E,u)}catch(e){}if(r=this._getSelection(),s=this._createRange(r),i=Sys.Extended.UI.HtmlEditor.isIE?"":Sys.Extended.UI.HtmlEditor.Trim(this.getSelectedHTML()),n=Sys.Extended.UI.HtmlEditor.isIE&&s.text.length>0||!Sys.Extended.UI.HtmlEditor.isIE&&i.length>0,!n||0==this._getTextNodeCollection().length){var y=this._doc.createTextNode("");E.parentNode.insertBefore(y,E),E.parentNode.removeChild(E),u.parentNode.removeChild(u),f.parentNode.removeChild(f);var a=this._doc.createRange();return a.setStart(y,0),a.setEnd(y,0),a.setStart(y,0),a.setEnd(y,0),this._removeAllRanges(o),this._selectRange(o,a),[]}if(u.parentNode.insertBefore(E,f),Sys.Extended.UI.HtmlEditor.positionInParagraph(u,u.nextSibling,!1,u.parentNode,t),this._trySelect(E,u),r=this._getSelection(),s=this._createRange(r),i=Sys.Extended.UI.HtmlEditor.isIE?"":Sys.Extended.UI.HtmlEditor.Trim(this.getSelectedHTML()),n=Sys.Extended.UI.HtmlEditor.isIE&&s.text.length>0||!Sys.Extended.UI.HtmlEditor.isIE&&i.length>0,!n||0==this._getTextNodeCollection().length){var y=this._doc.createTextNode("");E.parentNode.insertBefore(y,E),E.parentNode.removeChild(E),u.parentNode.removeChild(u),f.parentNode.removeChild(f);var a=this._doc.createRange();return a.setStart(y,0),a.setEnd(y,0),a.setStart(y,0),a.setEnd(y,0),this._removeAllRanges(o),this._selectRange(o,a),[]}return Sys.Extended.UI.HtmlEditor.positionInParagraph(E,E.previousSibling,!0,E.parentNode,t),this._trySelect(E,u),r=this._getSelection(),s=this._createRange(r),i=Sys.Extended.UI.HtmlEditor.isIE?"":Sys.Extended.UI.HtmlEditor.Trim(this.getSelectedHTML()),n=Sys.Extended.UI.HtmlEditor.isIE&&s.text.length>0||!Sys.Extended.UI.HtmlEditor.isIE&&i.length>0,Sys.Extended.UI.HtmlEditor.isIE?"undefined"!=typeof e?this.__saveBM__=f:f.parentNode.removeChild(f):this.__saveBM__=[f,0],n&&(d=this._getTextNodeCollection()),E.parentNode.removeChild(E),u.parentNode.removeChild(u),d},_setStyleForTyping:function(e){var t=e.name.replace(/\-(\w)/g,function(e,t){return t.toUpperCase()}),i=e.value,n=e.repl;null==this._StyleForTyping&&(this._StyleForTyping=[]);for(var r=[],s=!0,d=0;d<this._StyleForTyping.length;d++){var o=this._StyleForTyping[d].name.replace(/\-(\w)/g,function(e,t){return t.toUpperCase()}),a=this._StyleForTyping[d].value;o!=t||a!=i&&!n?r.push(this._StyleForTyping[d]):s=!1}this._StyleForTyping=r,s&&this._StyleForTyping.push(e)},_trySelect:function(e,t){var i=this._getSelection(),n=null,r=null;if(Sys.Extended.UI.HtmlEditor.isIE){i.empty(),i=this._getSelection();var s=this._createRange(i),d=this._createRange(i);try{null!=e&&s.moveToElementText(e),null!=t&&d.moveToElementText(t),null!=e&&null!=t?(s.setEndPoint("EndToEnd",d),s.select()):null!=e?s.select():null!=t&&d.select()}catch(e){}}else try{n=this._doc.createTextNode(""),r=this._doc.createTextNode(""),e.parentNode.insertBefore(n,e),t.parentNode.insertBefore(r,t);var o=this._doc.createRange();o.setStart(n,0),o.setEnd(r,0),this._removeAllRanges(i),this._selectRange(i,o)}catch(e){}},getSelectedHTML:function(){var e=this._getSelection(),t=this._createRange(e),i=null;if(Sys.Extended.UI.HtmlEditor.isIE)i=t.htmlText;else if(!Sys.Extended.UI.HtmlEditor.isSafari||"Caret"!=e.type&&"None"!=e.type){if(Sys.Extended.UI.HtmlEditor.isSafari&&null==t.cloneContents())return"";i=Sys.Extended.UI.HtmlEditor.getHTML(t.cloneContents(),!1)}else i="";return i},_queryCommandState:function(e){var t=this._rangeStartEnd();if(null==t)return!1;try{var i={name:"none",value:"none"};switch(e.toLowerCase()){case"bold":i={name:"font-weight",value:"bold"};break;case"italic":i={name:"font-style",value:"italic"};break;case"underline":i={name:"text-decoration",value:"underline"};break;case"strikethrough":i={name:"text-decoration",value:"line-through"};break;case"superscript":i={name:"vertical-align",value:"super"};break;case"subscript":i={name:"vertical-align",value:"sub"}}var n=t.start,r=t.end,s=Sys.Extended.UI.HtmlEditor.getStyle(n,i.name).toString().toLowerCase(),d=Sys.Extended.UI.HtmlEditor.getStyle(r,i.name).toString().toLowerCase();if("font-weight"==i.name&&"700"==s&&(s="bold"),"font-weight"==i.name&&"700"==d&&(d="bold"),/MSIE (5|6)/.test(navigator.userAgent)&&"strikethrough"==e.toLowerCase()&&("underline"==s||"underline"==d)){for(;n&&Sys.Extended.UI.HtmlEditor.isStyleTag(n.tagName);){if(n.style.textDecoration.indexOf("line-through")>=0){s=n.style.textDecoration;break}n=n.parentNode}for(;r&&Sys.Extended.UI.HtmlEditor.isStyleTag(r.tagName);){if(r.style.textDecoration.indexOf("line-through")>=0){d=r.style.textDecoration;break}r=r.parentNode}}if(Sys.Extended.UI.HtmlEditor.isSafari&&("strikethrough"==e.toLowerCase()||"underline"==e.toLowerCase())){var o=e.toLowerCase();for("strikethrough"==o&&(o="line-through");n&&Sys.Extended.UI.HtmlEditor.isStyleTag(n.tagName);){if(n.style.textDecoration.indexOf(o)>=0){s=n.style.textDecoration;break}n=n.parentNode}for(;r&&Sys.Extended.UI.HtmlEditor.isStyleTag(r.tagName);){if(r.style.textDecoration.indexOf(o)>=0){d=r.style.textDecoration;break}r=r.parentNode}}var a=s.indexOf(i.value)>=0&&d.indexOf(i.value)>=0;if(null!=this._StyleForTyping&&this._StyleForTyping.length>0)for(var l=0;l<this._StyleForTyping.length;l++){var c=this._StyleForTyping[l];if(c.name==i.name&&c.value==i.value){a=!a;break}}return a}catch(e){return!1}},_textAlignState:function(e){var t=this._rangeStartEnd();if(null==t)return!1;try{var i=this._textAlignStateSingle(t.start),n=this._textAlignStateSingle(t.end);return i==e&&n==e}catch(e){return!1}},_textAlignStateSingle:function(e){for(;e&&Sys.Extended.UI.HtmlEditor.isStyleTag(e.tagName);)e=e.parentNode;if(null!=e){var t=e.tagName.toUpperCase();if("P"==t||"DIV"==t)return e.style.textAlign.toLowerCase()}return null},_rangeStartEnd:function(){function e(t,n){for(var r=null;null==r;){if(r=3==t.nodeType?n&&i.startContainer!=i.endContainer&&i.startOffset==t.length&&t.nextSibling?e(t.nextSibling,n):!n&&i.startContainer!=i.endContainer&&0==i.endOffset&&t.previousSibling?e(t.previousSibling,n):t:null==(n?t.firstChild:t.lastChild)?null:e(n?t.firstChild:t.lastChild,n),null!=r)return r;if(t=n?t.nextSibling:t.previousSibling,null==t)return null}}if(this.isControl())return null;try{var t=this._getSelection(),i=this._createRange(t),n=null,r=null;if(Sys.Extended.UI.HtmlEditor.isIE)if(0==i.text.length)n=r=this._getParent(i);else{var s=Sys.Extended.UI.HtmlEditor.smartClassName+"_right_marker",d=Sys.Extended.UI.HtmlEditor.smartClassName+"_left_marker",o=i.duplicate(),a=i.duplicate();o.setEndPoint("EndToStart",i),a.setEndPoint("StartToEnd",i),a.pasteHTML("<span id='"+s+"'/>"),o.pasteHTML("<span id='"+d+"'/>");var l=this._doc.getElementById(d),c=this._doc.getElementById(s);n=l.parentNode,r=c.parentNode,l.parentNode.removeChild(l),c.parentNode.removeChild(c)}else{var h=this._getParent(i);if(3!=h.nodeType&&i.startContainer==i.endContainer&&i.startOffset==i.endOffset&&i.startContainer.childNodes.item(i.startOffset).tagName&&Sys.Extended.UI.HtmlEditor.isStyleTag(i.startContainer.childNodes.item(i.startOffset).tagName))return{start:i.startContainer.childNodes.item(i.startOffset),end:i.startContainer.childNodes.item(i.startOffset)};n=e(i.startContainer,!0),null!=n&&null!=n.parentNode&&(n=n.parentNode),null==n&&(n=i.startContainer),r=e(i.endContainer,!1),null!=r&&null!=r.parentNode&&(r=r.parentNode),null==r&&(r=i.endContainer)}return{start:n,end:r}}catch(e){return null}},rtlState:function(){return!(!this._doc.body.style.direction||"rtl"!=this._doc.body.style.direction)},openWait:function(){this._editPanel.openWait()},closeWait:function(){this._editPanel.closeWait()}},Sys.Extended.UI.HtmlEditor.DesignPanel.ScriptRecover=function(){this.scriptsArray=[],this.scriptsArray_index=-1,this.regReplScript1=function(e,t){return this.scriptsArray.push(t),""},this.regReplFromScript=function(e,t,i,n){return t.replace(/>/g,">").replace(/</g,"<").replace(/&/g,"&")},this.regReplFromScript1=function(e,t,i,n){this.scriptsArray_index++;var r;return r=Sys.Extended.UI.HtmlEditor.isIE?this.scriptsArray[this.scriptsArray_index]:this.scriptsArray[this.scriptsArray_index].replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,'"'),t+r+n}},Sys.Extended.UI.HtmlEditor.DesignPanel.registerClass("Sys.Extended.UI.HtmlEditor.DesignPanel",Sys.Extended.UI.HtmlEditor.ModePanel); |