var xq={majorVersion:"0.2",minorVersion:"20071205"}; xq.Class=function(){var D=null,C=xq.$A(arguments); if(typeof C[0]=="function"){D=C.shift() }function A(){this.initialize.apply(this,arguments) }if(D){for(var B in D.prototype){A.prototype[B]=D.prototype[B] }}for(var B in C[0]){A.prototype[B]=C[0][B] }if(!A.prototype.initialize){A.prototype.initialize=function(){} }A.prototype.constructor=A; return A }; xq.observe=function(B,A,C){if(B.addEventListener){B.addEventListener(A,C,false) }else{B.attachEvent("on"+A,C) }B=null }; xq.stopObserving=function(B,A,C){if(B.removeEventListener){B.removeEventListener(A,C,false) }else{B.detachEvent("on"+A,C) }B=null }; xq.cancelHandler=function(A){xq.stopEvent(A); return false }; xq.stopEvent=function(A){if(A.preventDefault){A.preventDefault() }if(A.stopPropagation){A.stopPropagation() }A.returnValue=false; A.cancelBubble=true; A.stopped=true }; xq.isButton=function(B,A){return B.which?(B.which===A+1):(B.button===A) }; xq.isLeftClick=function(A){return isButton(A,0) }; xq.isMiddleClick=function(A){return isButton(A,1) }; xq.isRightClick=function(A){return isButton(A,2) }; xq.getEventPoint=function(A){return{x:A.pageX||(A.clientX+(document.documentElement.scrollLeft||document.body.scrollLeft)),y:A.pageY||(A.clientY+(document.documentElement.scrollTop||document.body.scrollTop))} }; xq.getCumulativeOffset=function(A){var C=0,B=0; do{C+=A.offsetTop||0; B+=A.offsetLeft||0; A=A.offsetParent }while(A); return{top:C,left:B} }; xq.$=function(A){return document.getElementById(A) }; xq.isEmptyHash=function(B){for(var A in B){return false }return true }; xq.$A=function(C){var A=C.length,B=new Array(A); while(A--){B[A]=C[A] }return B }; xq.hasClassName=function(A,B){var C=A.className; return(C.length>0&&(C==B||new RegExp("(^|\\s)"+B+"(\\s|$)").test(C))) }; xq.serializeForm=function(F){try{var J={hash:true}; var C={}; var A=F.getElementsByTagName("*"); for(var D=0; D]+>/gi,"") }; String.prototype.escapeHTML=function(){xq._text.data=this; return xq._div.innerHTML }; xq._text=document.createTextNode(""); xq._div=document.createElement("div"); xq._div.appendChild(xq._text); String.prototype.strip=function(){return this.replace(/^\s+/,"").replace(/\s+$/,"") }; Array.prototype.indexOf=function(B){for(var A=0; A=A }; String.prototype.merge=function(B){var A=this; for(k in B){A=A.replace("{"+k+"}",B[k]) }return A }; String.prototype.parseURL=function(){var E=this.match(/((((\w+):\/\/(((([^@:]+)(:([^@]+))?)@)?([^:\/\?#]+)?(:(\d+))?))?([^\?#]+)?)(\?([^#]+))?)(#(.+))?/); var D=E[0]; var B=E[1]||undefined; var M=E[2]||undefined; var L=E[3]||undefined; var A=null; var N=E[4]||undefined; var G=E[8]||undefined; var K=E[10]||undefined; var F=E[11]||undefined; var C=E[13]||undefined; var O=E[14]||undefined; var J=E[16]||undefined; var H=E[18]||undefined; if(!O||O=="/"){A=L+"/" }else{var I=O.lastIndexOf("/"); A=L+O.substring(0,I+1) }return{includeAnchor:D,includeQuery:B,includePath:M,includeBase:A,includeHost:L,protocol:N,user:G,password:K,domain:F,port:C,path:O,query:J,anchor:H} }; xq.autoFinalizeQueue=[]; xq.addToFinalizeQueue=function(A){xq.autoFinalizeQueue.push(A) }; xq.finalize=function(B){if(typeof B.finalize=="function"){try{B.finalize() }catch(A){}}for(key in B){B[key]=null }}; xq.observe(window,"unload",function(){for(var A=0; A") }; xq.loadOthers=function(){var A=xq.findXquaredScript(); var D=A.src.match(/(.*\/)xquared\.js.*/i)[1]; var C=["Editor.js","Browser.js","Shortcut.js","DomTree.js","RichDom.js","RichDomW3.js","RichDomGecko.js","RichDomWebkit.js","RichDomTrident.js","RichTable.js","Validator.js","ValidatorW3.js","ValidatorGecko.js","ValidatorWebkit.js","ValidatorTrident.js","EditHistory.js","Controls.js","_ui_templates.js"]; for(var B=0; B0?E[0]:null; if(A){this.toolbarButtons[G[B]]=A }}}var D=this.toolbarButtons; var F=this.rdom.collectStructureAndStyle(C); this._updateToolbarButtonStatus("emphasis",F.em); this._updateToolbarButtonStatus("strongEmphasis",F.strong); this._updateToolbarButtonStatus("underline",F.underline); this._updateToolbarButtonStatus("strike",F.strike); this._updateToolbarButtonStatus("superscription",F.superscription); this._updateToolbarButtonStatus("subscription",F.subscription); this._updateToolbarButtonStatus("justifyLeft",F.justification=="left"); this._updateToolbarButtonStatus("justifyCenter",F.justification=="center"); this._updateToolbarButtonStatus("justifyRight",F.justification=="right"); this._updateToolbarButtonStatus("justifyBoth",F.justification=="justify"); this._updateToolbarButtonStatus("orderedList",F.list=="OL"); this._updateToolbarButtonStatus("unorderedList",F.list=="UL"); this._updateToolbarButtonStatus("code",F.list=="CODE"); this._updateToolbarButtonStatus("paragraph",F.block=="P"); this._updateToolbarButtonStatus("heading1",F.block=="H1"); this._updateToolbarButtonStatus("heading2",F.block=="H2"); this._updateToolbarButtonStatus("heading3",F.block=="H3"); this._updateToolbarButtonStatus("heading4",F.block=="H4"); this._updateToolbarButtonStatus("heading5",F.block=="H5"); this._updateToolbarButtonStatus("heading6",F.block=="H6") },removeUnnecessarySpaces:function(A){var C=this.rdom.tree.getBlockTags().join("|"); var B=new RegExp("\\s*<(/?)("+C+")>\\s*","img"); return A.replace(B,"<$1$2>") },getCurrentContent:function(A){if(this.getCurrentEditMode()=="source"){return this.getSourceContent(A) }else{return this.getWysiwygContent(A) }},getWysiwygContent:function(A,B){if(B||!A){return this.validator.validate(this.rdom.getRoot(),A) }var C=this.editHistory.getLastModifiedDate(); if(this._lastModified!=C){this._validContentCache=this.validator.validate(this.rdom.getRoot(),A); this._lastModified=C }return this._validContentCache },getSourceContent:function(C){var B=this.sourceEditorTextarea[xq.Browser.isWebkit?"innerHTML":"value"]; var A=document.createElement("div"); A.innerHTML=this.removeUnnecessarySpaces(B); var D=xq.RichDom.createInstance(); D.setRoot(document.body); D.wrapAllInlineOrTextNodesAs("P",A,true); return this.validator.validate(A,C) },setStaticContent:function(A){if(this.contentElement.nodeName=="TEXTAREA"){this.contentElement.value=A; if(xq.Browser.isWebkit){this.contentElement.innerHTML=A }}else{this.contentElement.innerHTML=A }this._fireOnStaticContentChanged(this,A) },getStaticContent:function(){var A; if(this.contentElement.nodeName=="TEXTAREA"){A=this.contentElement[xq.Browser.isWebkit?"innerHTML":"value"] }else{A=this.contentElement.innerHTML }return A },getStaticContentAsDOM:function(){if(this.contentElement.nodeName=="TEXTAREA"){var A=this.doc.createElement("DIV"); A.innerHTML=this.contentElement[xq.Browser.isWebkit?"innerHTML":"value"]; return A }else{return this.contentElement }},focus:function(){if(this.getCurrentEditMode()=="wysiwyg"){this.rdom.focus(); window.setTimeout(function(){this.updateAllToolbarButtonsStatus(this.rdom.getCurrentElement()) }.bind(this),0) }else{if(this.getCurrentEditMode()=="source"){this.sourceEditorTextarea.focus() }}},getFrame:function(){return this.editorFrame },getWin:function(){return this.editorWin },getDoc:function(){return this.editorDoc },getOutmostWrapper:function(){return this.outmostWrapper },getBody:function(){return this.editorBody },_createEditorFrame:function(){this.outmostWrapper=this.doc.createElement("div"); this.outmostWrapper.className="xquared"; this.contentElement.parentNode.insertBefore(this.outmostWrapper,this.contentElement); if(!this.toolbarContainer&&this.config.generateDefaultToolbar){this.toolbarContainer=this._generateDefaultToolbar(); this.outmostWrapper.appendChild(this.toolbarContainer) }this.sourceEditorDiv=this.doc.createElement("div"); this.sourceEditorDiv.className="editor source_editor"; this.sourceEditorDiv.style.display="none"; this.outmostWrapper.appendChild(this.sourceEditorDiv); this.sourceEditorTextarea=this.doc.createElement("textarea"); this.sourceEditorDiv.appendChild(this.sourceEditorTextarea); this.wysiwygEditorDiv=this.doc.createElement("div"); this.wysiwygEditorDiv.className="editor wysiwyg_editor"; this.wysiwygEditorDiv.style.display="none"; this.outmostWrapper.appendChild(this.wysiwygEditorDiv); this.editorFrame=this.doc.createElement("iframe"); this.rdom.setAttributes(this.editorFrame,{"frameBorder":"0","marginWidth":"0","marginHeight":"0","leftMargin":"0","topMargin":"0","allowTransparency":"true"}); this.wysiwygEditorDiv.appendChild(this.editorFrame); var B=this.editorFrame.contentWindow.document; if(xq.Browser.isTrident){B.designMode="On" }B.open(); B.write(""); B.write(""); B.write(""); if(!xq.Browser.isTrident){B.write("") }B.write(""); B.write("XQuared"); if(this.config.changeCursorOnLink){B.write("") }B.write(""); B.write("

"+this.rdom.makePlaceHolderString()+"

"); B.write(""); B.close(); this.editorWin=this.editorFrame.contentWindow; this.editorDoc=this.editorWin.document; this.editorBody=this.editorDoc.body; this.editorBody.className="xed"; if(xq.Browser.isIE6){this.editorDoc.documentElement.style.overflowY="auto"; this.editorDoc.documentElement.style.overflowX="hidden" }if(this.config.generateDefaultToolbar){this._addStyleRules([{selector:".xquared div.toolbar",rule:"background-image: url("+this.config.imagePathForDefaultToobar+"toolbarBg.gif)"},{selector:".xquared ul.buttons li",rule:"background-image: url("+this.config.imagePathForDefaultToobar+"toolbarButtonBg.gif)"},{selector:".xquared ul.buttons li.xq_separator",rule:"background-image: url("+this.config.imagePathForDefaultToobar+"toolbarSeparator.gif)"}]) }this.rdom.setWin(this.editorWin); this.rdom.setRoot(this.editorBody); this.validator=xq.Validator.createInstance(this.doc.location.href,this.config.urlValidationMode,this.config.allowedTags,this.config.allowedAttributes); if(this.config.automaticallyHookSubmitEvent&&this.contentElement.nodeName=="TEXTAREA"&&this.contentElement.form){var A=this.contentElement.form.onsubmit; this.contentElement.form.onsubmit=function(){this.contentElement.value=this.getCurrentContent(true); if(A){return A() }else{return true }}.bind(this) }},_addStyleRules:function(D){if(!this.dynamicStyle){if(xq.Browser.isTrident){this.dynamicStyle=this.doc.createStyleSheet() }else{var B=this.doc.createElement("style"); this.doc.body.appendChild(B); this.dynamicStyle=xq.$A(this.doc.styleSheets).last() }}for(var A=0; A0){this._contextMenuContainer.removeChild(this._contextMenuContainer.childNodes[0]) }}for(var B=0; B"+(B.title.toString().escapeHTML())+"" }else{A.innerHTML=(B.title.toString().escapeHTML()) }}if(B.className){A.className=B.className }this._contextMenuContainer.appendChild(A); return A },_contextMenuClicked:function(e){this.hideContextMenu(); if(!this._contextMenuContainer){return }var node=e.srcElement||e.target; while(node&&node.nodeName!="LI"){node=node.parentNode }if(!node||!this.rdom.tree.isDescendantOf(this._contextMenuContainer,node)){return }for(var i=0; i-1,isGecko:navigator.userAgent.indexOf("Gecko")>-1&&navigator.userAgent.indexOf("KHTML")==-1,isKHTML:navigator.userAgent.indexOf("KHTML")!=-1,isPresto:navigator.appName=="Opera",isMac:navigator.userAgent.indexOf("Macintosh")!=-1,isUbuntu:navigator.userAgent.indexOf("Ubuntu")!=-1,isIE:navigator.appName=="Microsoft Internet Explorer",isIE6:navigator.userAgent.indexOf("MSIE 6")!=-1,isIE7:navigator.userAgent.indexOf("MSIE 7")!=-1}; xq.Shortcut=xq.Class({initialize:function(A){xq.addToFinalizeQueue(this); this.keymap=(typeof A=="string")?xq.Shortcut.interprete(A).keymap:A },matches:function(A){var B=xq.Browser.isGecko&&xq.Browser.isMac?(A.keyCode+"_"+A.charCode):A.keyCode; var D=(this.keymap.which==B)||(this.keymap.which==32&&B==25); if(typeof A.metaKey=="undefined"){A.metaKey=false }var C=(typeof this.keymap.shiftKey=="undefined"||this.keymap.shiftKey==A.shiftKey)&&(typeof this.keymap.altKey=="undefined"||this.keymap.altKey==A.altKey)&&(typeof this.keymap.ctrlKey=="undefined"||this.keymap.ctrlKey==A.ctrlKey)&&(typeof this.keymap.metaKey=="undefined"||this.keymap.metaKey==A.metaKey); return C&&D }}); xq.Shortcut.interprete=function(G){G=G.toUpperCase(); var F=xq.Shortcut._interpreteWhich(G.split("+").pop()); var E=xq.Shortcut._interpreteModifier(G,"CTRL"); var C=xq.Shortcut._interpreteModifier(G,"ALT"); var B=xq.Shortcut._interpreteModifier(G,"SHIFT"); var D=xq.Shortcut._interpreteModifier(G,"META"); var A={}; A.which=F; if(typeof E!="undefined"){A.ctrlKey=E }if(typeof C!="undefined"){A.altKey=C }if(typeof B!="undefined"){A.shiftKey=B }if(typeof D!="undefined"){A.metaKey=D }return new xq.Shortcut(A) }; xq.Shortcut._interpreteModifier=function(A,B){return A.match("\\("+B+"\\)")?undefined:A.match(B)?true:false }; xq.Shortcut._interpreteWhich=function(A){var B=A.length==1?((xq.Browser.isMac&&xq.Browser.isGecko)?"0_"+A.toLowerCase().charCodeAt(0):A.charCodeAt(0)):xq.Shortcut._keyNames[A]; if(typeof B=="undefined"){throw"Unknown special key name: ["+A+"]" }return B }; xq.Shortcut._keyNames=xq.Browser.isMac&&xq.Browser.isGecko?{BACKSPACE:"8_0",TAB:"9_0",RETURN:"13_0",ENTER:"13_0",ESC:"27_0",SPACE:"0_32",LEFT:"37_0",UP:"38_0",RIGHT:"39_0",DOWN:"40_0",DELETE:"46_0",HOME:"36_0",END:"35_0",PAGEUP:"33_0",PAGEDOWN:"34_0",COMMA:"0_44",HYPHEN:"0_45",EQUAL:"0_61",PERIOD:"0_46",SLASH:"0_47",F1:"112_0",F2:"113_0",F3:"114_0",F4:"115_0",F5:"116_0",F6:"117_0",F7:"118_0",F8:"119_0"}:{BACKSPACE:8,TAB:9,RETURN:13,ENTER:13,ESC:27,SPACE:32,LEFT:37,UP:38,RIGHT:39,DOWN:40,DELETE:46,HOME:36,END:35,PAGEUP:33,PAGEDOWN:34,COMMA:188,HYPHEN:xq.Browser.isTrident?189:109,EQUAL:xq.Browser.isTrident?187:61,PERIOD:190,SLASH:191,F1:112,F2:113,F3:114,F4:115,F5:116,F6:117,F7:118,F8:119,F9:120,F10:121,F11:122,F12:123}; xq.DomTree=xq.Class({initialize:function(){xq.addToFinalizeQueue(this); this._blockTags=["DIV","DD","LI","ADDRESS","CAPTION","DT","H1","H2","H3","H4","H5","H6","HR","P","BODY","BLOCKQUOTE","PRE","PARAM","DL","OL","UL","TABLE","THEAD","TBODY","TR","TH","TD"]; this._blockContainerTags=["DIV","DD","LI","BODY","BLOCKQUOTE","UL","OL","DL","TABLE","THEAD","TBODY","TR","TH","TD"]; this._listContainerTags=["OL","UL","DL"]; this._tableCellTags=["TH","TD"]; this._blockOnlyContainerTags=["BODY","BLOCKQUOTE","UL","OL","DL","TABLE","THEAD","TBODY","TR"]; this._atomicTags=["IMG","OBJECT","BR","HR"] },getBlockTags:function(){return this._blockTags },findCommonAncestorAndImmediateChildrenOf:function(E,C){if(E.parentNode==C.parentNode){return{left:E,right:C,parent:E.parentNode} }else{var D=this.collectParentsOf(E,true); var G=this.collectParentsOf(C,true); var B=this.getCommonAncestor(D,G); var F=D.find(function(H){return H.parentNode==B }); var A=G.find(function(H){return H.parentNode==B }); return{left:F,right:A,parent:B} }},getLeavesAtEdge:function(C){if(!C.hasChildNodes()){return[null,null] }var D=function(G){for(var F=0; F0){for(var A=0; AQ[L].length){C-=Q[L].length }else{M=L; break }}if(R){return{text:P,textIndex:N,nodeIndex:M,breakPoint:C} }if(C!=0){var I=B[M].splitText(C); M++; B.splice(M,0,I) }var A=B[M]||H.firstChild; var O=this.tree.findCommonAncestorAndImmediateChildrenOf(A,G); var K=O.parent; if(K){if(A.parentNode!=K){A=this.splitElementUpto(A,K,true) }if(G.parentNode!=K){G=this.splitElementUpto(G,K,true) }var D=A.previousSibling; var J=G.nextSibling; if(D&&D.nodeType==1&&this.isEmptyBlock(D)){this.deleteNode(D) }if(J&&J.nodeType==1&&this.isEmptyBlock(J)){this.deleteNode(J) }var E=this.insertNodeAt(this.createElement(S),A,"before"); while(E.nextSibling!=G){E.appendChild(E.nextSibling) }return E }else{var E=this.insertNodeAt(this.createElement(S),G,"before"); return E }},wrapAllInlineOrTextNodesAs:function(A,B,E){var D=[]; if(!E&&!this.tree.hasMixedContents(B)){return D }var C=B.firstChild; while(C){if(this.tree.isTextOrInlineNode(C)){var F=this.wrapInlineOrTextNodesAs(A,C); D.push(F); C=F.nextSibling }else{C=C.nextSibling }}return D },wrapInlineOrTextNodesAs:function(A,B){var D=this.createElement(A); var C=B; C.parentNode.replaceChild(D,C); D.appendChild(C); while(D.nextSibling&&this.tree.isTextOrInlineNode(D.nextSibling)){D.appendChild(D.nextSibling) }return D },turnElementIntoListItem:function(C,D){D=D.toUpperCase(); var B=this.createElement(D=="UL"?"UL":"OL"); if(D=="CODE"){B.className="code" }if(this.tree.isTableCell(C)){var E=this.wrapAllInlineOrTextNodesAs("P",C,true)[0]; B=this.insertNodeAt(B,C,"start"); var A=this.insertNodeAt(this.createElement("LI"),B,"start"); A.appendChild(E) }else{B=this.insertNodeAt(B,C,"after"); var A=this.insertNodeAt(this.createElement("LI"),B,"start"); A.appendChild(C) }this.unwrapUnnecessaryParagraph(A); this.mergeAdjustLists(B); return A },extractOutElementFromParent:function(B){if(B==this.root||this.root==B.parentNode||!B.offsetParent){return null }if(B.nodeName=="LI"){this.wrapAllInlineOrTextNodesAs("P",B,true); B=B.firstChild }var A=B.parentNode; var D=null; if(A.nodeName=="LI"&&A.parentNode.parentNode.nodeName=="LI"){if(B.previousSibling){this.splitContainerOf(B,true); this.correctEmptyElement(B) }this.outdentListItem(B); D=B }else{if(A.nodeName=="LI"){if(this.tree.isListContainer(B.nextSibling)){var E=A.parentNode; this.splitContainerOf(A,true); this.correctEmptyElement(B); D=A.firstChild; while(A.firstChild){this.insertNodeAt(A.firstChild,E,"before") }var C=E.previousSibling; this.deleteNode(E); if(C&&this.tree.isListContainer(C)){this.mergeAdjustLists(C) }}else{this.splitContainerOf(B,true); this.correctEmptyElement(B); var E=this.splitContainerOf(A); this.insertNodeAt(B,E.parentNode,"before"); this.deleteNode(E.parentNode); D=B }}else{if(this.tree.isTableCell(A)||this.tree.isTableCell(B)){}else{this.splitContainerOf(B,true); this.correctEmptyElement(B); D=this.insertNodeAt(B,A,"before"); this.deleteNode(A) }}}return D },insertNewBlockAround:function(E,D,B){var C=E.nodeName=="LI"||E.parentNode.nodeName=="LI"; this.removeTrailingWhitespace(E); if(this.isFirstLiWithNestedList(E)&&!B&&D){var A=this.getParentElementOf(E,["LI"]); var F=this._insertNewBlockAround(A,D); return F }else{if(C&&!B){var A=this.getParentElementOf(E,["LI"]); var F=this._insertNewBlockAround(E,D); if(A!=E){F=this.splitContainerOf(F,false,"prev") }return F }else{if(this.tree.isBlockContainer(E)){this.wrapAllInlineOrTextNodesAs("P",E,true); return this._insertNewBlockAround(E.firstChild,D,B) }else{return this._insertNewBlockAround(E,D,this.tree.isHeading(E)?"P":B) }}}},_insertNewBlockAround:function(B,C,A){var D=this.createElement(A||B.nodeName); this.copyAttributes(B,D,false); this.correctEmptyElement(D); D=this.insertNodeAt(D,B,C?"before":"after"); return D },applyTagIntoElement:function(A,B){if(this.tree.isBlockOnlyContainer(A)){return this.wrapBlock(A,B) }else{if(this.tree.isBlockContainer(B)){var C=this.createElement(A); this.moveChildNodes(B,C); return this.insertNodeAt(C,B,"start") }else{if(this.tree.isBlockContainer(A)&&this.hasImportantAttributes(B)){return this.wrapBlock(A,B) }else{return this.replaceTag(A,B) }}}throw"IllegalArgumentException - ["+A+", "+B+"]" },applyTagIntoElements:function(C,K,L){var F=[]; if(this.tree.isBlockContainer(C)){var H=this.tree.findCommonAncestorAndImmediateChildrenOf(K,L); var D=H.left; var B=this.insertNodeAt(this.createElement(C),D,"before"); var M=H.parent.nodeName=="LI"&&H.parent.parentNode.childNodes.length==1&&!H.left.previousSilbing&&!H.right.nextSibling; if(M){var I=D.parentNode.parentNode; this.insertNodeAt(B,I,"before"); B.appendChild(I) }else{while(D!=H.right){next=D.nextSibling; B.appendChild(D); D=next }B.appendChild(H.right) }F.push(B) }else{var A=this.getBlockElementsBetween(K,L); for(var G=0; G=2&&this.isMarker(D.lastChild.previousSibling)&&D.lastChild.nodeType==3&&D.lastChild.nodeValue.length==1&&D.lastChild.nodeValue.charCodeAt(0)==160){this.deleteNode(D.lastChild) }this.removePlaceHoldersAndEmptyNodes(D); if(this.isEmptyBlock(D)){if(this.tree.isAtomic(D)){D=this.replaceTag("P",D) }D=this.replaceTag(F.nodeName,D)||D; D.innerHTML="" }else{if(D.firstChild==D.lastChild&&this.isMarker(D.firstChild)){D=this.replaceTag(F.nodeName,D)||D }}if(this.isEmptyBlock(F)){if(this.tree.isAtomic(F)){F=this.replaceTag("P",F) }F.innerHTML="" }this.moveChildNodes(F,D); this.deleteNode(F); return D }finally{if(H&&this.isEmptyBlock(H)){this.deleteNode(H,true) }if(G&&this.isEmptyBlock(G)){this.deleteNode(G,true) }if(H){this.unwrapUnnecessaryParagraph(H) }if(G){this.unwrapUnnecessaryParagraph(G) }}},mergeAdjustLists:function(A,G,D){var F=A.previousSibling; var C=F&&(F.nodeName==A.nodeName&&F.className==A.className); if((!D||D.toLowerCase()=="prev")&&(C||(G&&this.tree.isListContainer(F)))){while(F.lastChild){this.insertNodeAt(F.lastChild,A,"start") }this.deleteNode(F) }var E=A.nextSibling; var B=E&&(E.nodeName==A.nodeName&&E.className==A.className); if((!D||D.toLowerCase()=="next")&&(B||(G&&this.tree.isListContainer(E)))){while(E.firstChild){this.insertNodeAt(E.firstChild,A,"end") }this.deleteNode(E) }},moveChildNodes:function(B,A){if(this.tree.isDescendantOf(B,A)||["HTML","HEAD"].indexOf(A.nodeName)!=-1){throw"Illegal argument. Cannot move children of element["+B.nodeName+"] to element["+A.nodeName+"]" }if(B==A){return }while(B.firstChild){A.appendChild(B.firstChild) }},copyAttributes:function(E,D,B){var A=E.attributes; if(!A){return }for(var C=0; C0?D:E },outdentElementsCode:function(A){if(A.tagName=="LI"){A=A.parentNode }if(A.tagName=="OL"&&A.className=="code"){return true }return false },_outdentElements:function(C,F,E){for(var B=0; B0; var D=O.length>0; var L=null; if(E){L=H }else{if(D){L=O }else{L=B }}for(var F=0; F" },makeEmptyParagraph:function(){return this.createElementFromHtml("


") },isPlaceHolder:function(B){if(B.nodeType!=1){return false }var A=B.nodeName=="BR"&&B.getAttribute("type")=="_moz"; if(A){return true }var C=B.nodeName=="BR"&&!this.getNextSibling(B); if(C){return true }return false },selectElement:function(B,C){if(!B){throw"[element] is null" }if(B.nodeType!=1){throw"[element] is not an element" }try{if(!xq.Browser.isMac){this.doc.execCommand("SelectAll",false,null) }}catch(A){}if(C){this.rng().selectNode(B) }else{this.rng().selectNodeContents(B) }}}); xq.RichDomWebkit=xq.Class(xq.RichDomW3,{makePlaceHolder:function(){var A=this.createElement("BR"); A.className="webkit-block-placeholder"; return A },makePlaceHolderString:function(){return"
" },makeEmptyParagraph:function(){return this.createElementFromHtml("


") },isPlaceHolder:function(A){return A.nodeName=="BR"&&A.className=="webkit-block-placeholder" },rng:function(){var B=this.sel(); var A=this.doc.createRange(); if(!this._rng||this._anchorNode!=B.anchorNode||this._anchorOffset!=B.anchorOffset||this._focusNode!=B.focusNode||this._focusOffset!=B.focusOffset){if(B.type!="None"){A.setStart(B.anchorNode,B.anchorOffset); A.setEnd(B.focusNode,B.focusOffset) }this._anchorNode=B.anchorNode; this._anchorOffset=B.anchorOffset; this._focusNode=B.focusNode; this._focusOffset=B.focusOffset; this._rng=A }return this._rng },selectElement:function(B,C){if(!B){throw"[element] is null" }if(B.nodeType!=1){throw"[element] is not an element" }var A=this.rng(); if(C){A.selectNode(B) }else{A.selectNodeContents(B) }this._setSelectionByRange(A) },deleteSelection:function(){this.rng().deleteContents() },collapseSelection:function(B){var A=this.rng(); A.collapse(B); this._setSelectionByRange(A) },getSelectionAsHtml:function(){var B=this.createElement("div"); var A=this.rng(); var C=this.rng().cloneContents(); if(C){B.appendChild(C) }return B.innerHTML },_setSelectionByRange:function(A){var B=this.sel(); B.setBaseAndExtent(A.startContainer,A.startOffset,A.endContainer,A.endOffset); this._anchorNode=B.anchorNode; this._anchorOffset=B.anchorOffset; this._focusNode=B.focusNode; this._focusOffset=B.focusOffset }}); xq.RichDomTrident=xq.Class(xq.RichDom,{makePlaceHolder:function(){return this.createTextNode(" ") },makePlaceHolderString:function(){return" " },makeEmptyParagraph:function(){return this.createElementFromHtml("

 

") },isPlaceHolder:function(A){return false },getOuterHTML:function(A){return A.outerHTML },insertNode:function(B){if(this.hasSelection()){this.collapseSelection(true) }this.rng().pasteHTML(""); var A=this.$("xquared_temp"); if(B.id=="xquared_temp"){return A }A.replaceNode(B); return B },removeTrailingWhitespace:function(E){if(!E){return }if(this.tree.isBlockContainer(E)){return }if(this.isEmptyBlock(E)){return }var D=E.innerText; var B=D.charCodeAt(D.length-1); if(D.length<=1||[32,160].indexOf(B)==-1){return }var C=E; while(C&&C.nodeType!=3){C=C.lastChild }if(!C){return }var A=C.nodeValue; if(A.length<=1){this.deleteNode(C,true) }else{C.nodeValue=A.substring(0,A.length-1) }},correctEmptyElement:function(A){if(!A||A.nodeType!=1||this.tree.isAtomic(A)){return }if(A.firstChild){this.correctEmptyElement(A.firstChild) }else{A.innerHTML=" " }},copyAttributes:function(C,B,A){B.mergeAttributes(C,!A) },correctParagraph:function(){if(!this.hasFocus()){return false }if(this.hasSelection()){return false }var D=this.getCurrentElement(); if(D.nodeName=="BODY"){D=this.insertNode(this.makeEmptyParagraph()); var B=D.nextSibling; if(this.tree.isAtomic(B)){D=this.insertNodeAt(D,B,"after"); this.placeCaretAtStartOf(D); var C=this.tree.findForward(D,function(E){return this.tree.isBlock(E)&&!this.tree.isBlockOnlyContainer(E) }.bind(this)); if(C){this.deleteNode(D); this.placeCaretAtStartOf(C) }return true }else{var C=this.tree.findForward(D,function(E){return this.tree.isBlock(E)&&!this.tree.isBlockOnlyContainer(E) }.bind(this)); if(C){this.deleteNode(D); this.placeCaretAtStartOf(C) }else{this.placeCaretAtStartOf(D) }return true }}else{D=this.getCurrentBlockElement(); if(D.nodeType==3){D=D.parentNode }if(this.tree.hasMixedContents(D)){var A=this.pushMarker(); this.wrapAllInlineOrTextNodesAs("P",D,true); this.popMarker(true); return true }else{if((this.tree.isTextOrInlineNode(D.previousSibling)||this.tree.isTextOrInlineNode(D.nextSibling))&&this.tree.hasMixedContents(D.parentNode)){this.wrapAllInlineOrTextNodesAs("P",D.parentNode,true); return true }else{return false }}}},execCommand:function(A,B){return this.doc.execCommand(A,false,B) },applyBackgroundColor:function(A){this.execCommand("BackColor",A) },applyEmphasis:function(){this.execCommand("Italic") },applyStrongEmphasis:function(){this.execCommand("Bold") },applyStrike:function(){this.execCommand("strikethrough") },applyUnderline:function(){this.execCommand("underline") },applyRemoveFormat:function(){this.execCommand("RemoveFormat"); this.execCommand("Unlink") },execHeading:function(A){this.execCommand("FormatBlock","") },focus:function(){this.win.focus(); if(!this._focusedBefore){this.correctParagraph(); this.placeCaretAtStartOf(this.getCurrentBlockElement()); this._focusedBefore=true }},sel:function(){return this.doc.selection },rng:function(){try{var B=this.sel(); return(B==null)?null:B.createRange() }catch(A){return null }},hasSelection:function(){var A=this.sel().type.toLowerCase(); if("none"==A){return false }if("text"==A&&this.getSelectionAsHtml().length==0){return false }return true },deleteSelection:function(){if(this.getSelectionAsText()!=""){this.sel().clear() }},placeCaretAtStartOf:function(A){var B=this.insertNodeAt(this.createElement("SPAN"),A,"start"); this.selectElement(B); this.collapseSelection(false); this.deleteNode(B) },selectElement:function(B,C){if(!B){throw"[element] is null" }if(B.nodeType!=1){throw"[element] is not an element" }var A=this.rng(); A.moveToElementText(B); A.select() },selectBlocksBetween:function(D,B){var A=this.rng(); var C=this.rng(); C.moveToElementText(D); A.setEndPoint("StartToStart",C); C.moveToElementText(B); A.setEndPoint("EndToEnd",C); A.select() },collapseSelection:function(B){var A=this.rng(); A.collapse(B); A.select() },getSelectionAsHtml:function(){var A=this.rng(); return A&&A.htmlText?A.htmlText:"" },getSelectionAsText:function(){var A=this.rng(); return A&&A.text?A.text:"" },hasImportantAttributes:function(A){return !!(A.id||A.className||A.style.cssText) },isEmptyBlock:function(A){if(!A.hasChildNodes()){return true }if(A.nodeType==3&&!A.nodeValue){return true }if([" "," ",""].indexOf(A.innerHTML)!=-1){return true }return false },getLastChild:function(C){if(!C||!C.hasChildNodes()){return null }var A=xq.$A(C.childNodes).reverse(); for(var B=0; BA)?B.cells[A]:null },getRowAt:function(A){if(this.hasHeadingAtTop()){return A==0?this.table.tHead.rows[0]:this.table.tBodies[0].rows[A-1] }else{var B=this.table.tBodies[0].rows; return(B.length>A)?B[A]:null }},getDom:function(){return this.table },hasHeadingAtTop:function(){return !!(this.table.tHead&&this.table.tHead.rows[0]) },hasHeadingAtLeft:function(){return this.table.tBodies[0].rows[0].cells[0].nodeName=="TH" },correctEmptyCells:function(){var A=xq.$A(this.table.getElementsByTagName("TH")); var C=xq.$A(this.table.getElementsByTagName("TD")); for(var B=0; B"); if(I){F.push(""); for(var D=0; D") }F.push(""); J-=1 }F.push(""); for(var D=0; D"); for(var B=0; B") }else{F.push("") }}F.push("") }F.push(""); F.push(""); var A=E.createElement("div"); A.innerHTML=F.join(""); var H=new xq.RichTable(E,A.firstChild); H.correctEmptyCells(); return H }; xq.Validator=xq.Class({initialize:function(C,A,D,B){xq.addToFinalizeQueue(this); this.allowedTags=(D||["a","abbr","acronym","address","blockquote","br","caption","cite","code","dd","dfn","div","dl","dt","em","h1","h2","h3","h4","h5","h6","hr","img","kbd","li","ol","p","pre","q","samp","span","sup","sub","strong","table","thead","tbody","td","th","tr","ul","var"]).join(" ")+" "; this.allowedAttrs=(B||["alt","cite","class","datetime","height","href","id","rel","rev","src","style","title","width"]).join(" ")+" "; this.curUrl=C; this.curUrlParts=C?C.parseURL():null; this.urlValidationMode=A },validate:function(B,A){throw"Not implemented" },invalidate:function(A){throw"Not implemented" },validateStrike:function(A){A=A.replace(/|\s+[^>]*>)/ig,"/ig,""); return A },validateUnderline:function(A){A=A.replace(/|\s+[^>]*>)/ig,"/ig,""); return A },replaceTag:function(A,C,B){return A.replace(new RegExp("(|\\s+[^>]*>)","ig"),"$1"+B+"$2") },validateSelfClosingTags:function(A){return A.replace(/<(br|hr|img)([^>]*?)>/img,function(D,B,C){return"<"+B+C+" />" }) },removeComments:function(A){return A.replace(//img,"") },removeDangerousElements:function(C){var A=xq.$A(C.getElementsByTagName("SCRIPT")).reverse(); for(var B=0; B]+?)(>|\\s+([^>]*?)(\\s?/?)>)","g"),function(H,K,M,G,L,I){if(C.indexOf(M)==-1){return"" }if(L){L=L.replace(/(^|\s")([^"=]+)(\s|$)/g,"$1$2=\"$2\"$3"); var J=[]; var E=L.match(/([^=]+)="[^"]*?"/g); for(var F=0; F" }else{return H }}) },makeUrlsRelative:function(A){var B=this.curUrl; var C=this.curUrlParts; return A.replace(/(<\w+\s+)(\/|([^>]+?)(\/?))>/g,function(H,G,D,F,E){if(F){F=F.replace(/(href|src)="([^"]+)"/g,function(M,L,K){var J=null; if(K.charAt(0)=="#"){J=C.includeQuery+K }else{if(K.charAt(0)=="?"){J=C.includePath+K }else{if(K.charAt(0)=="/"){J=C.includeHost+K }else{if(K.match(/^\w+:\/\//)){J=K }else{J=C.includeBase+K }}}}var I=J; if(J.indexOf(C.includeQuery)==0){I=J.substring(C.includeQuery.length) }else{if(J.indexOf(C.includePath)==0){I=J.substring(C.includePath.length) }else{if(J.indexOf(C.includeBase)==0){I=J.substring(C.includeBase.length) }else{if(J.indexOf(C.includeHost)==0){I=J.substring(C.includeHost.length) }}}}if(I==""){I="#" }return L+"=\""+I+"\"" }); return G+F+E+">" }else{return H }}); return A },makeUrlsHostRelative:function(A){var B=this.curUrl; var C=this.curUrlParts; return A.replace(/(<\w+\s+)(\/|([^>]+?)(\/?))>/g,function(H,G,D,F,E){if(F){F=F.replace(/(href|src)="([^"]+)"/g,function(M,L,K){var J=null; if(K.charAt(0)=="#"){J=C.includeQuery+K }else{if(K.charAt(0)=="?"){J=C.includePath+K }else{if(K.charAt(0)=="/"){J=C.includeHost+K }else{if(K.match(/^\w+:\/\//)){J=K }else{J=C.includeBase+K }}}}var I=J; if(J.indexOf(C.includeHost)==0){I=J.substring(C.includeHost.length) }if(I==""){I="#" }return L+"=\""+I+"\"" }); return G+F+E+">" }else{return H }}); return A },makeUrlsAbsolute:function(A){var B=this.curUrl; var C=this.curUrlParts; return A.replace(/(<\w+\s+)(\/|([^>]+?)(\/?))>/g,function(H,G,D,F,E){if(F){F=F.replace(/(href|src)="([^"]+)"/g,function(L,K,J){var I=null; if(J.charAt(0)=="#"){I=C.includeQuery+J }else{if(J.charAt(0)=="?"){I=C.includePath+J }else{if(J.charAt(0)=="/"){I=C.includeHost+J }else{if(J.match(/^\w+:\/\//)){I=J }else{I=C.includeBase+J }}}}return K+"=\""+I+"\"" }); return G+F+E+">" }else{return H }}) }}); xq.Validator.createInstance=function(C,A,D,B){if(xq.Browser.isTrident){return new xq.ValidatorTrident(C,A,D,B) }else{if(xq.Browser.isWebkit){return new xq.ValidatorWebkit(C,A,D,B) }else{return new xq.ValidatorGecko(C,A,D,B) }}}; xq.ValidatorW3=xq.Class(xq.Validator,{validate:function(C,B){C=C.cloneNode(true); var F=xq.RichDom.createInstance(); F.setRoot(C); F.removePlaceHoldersAndEmptyNodes(C); this.removeDangerousElements(C); this.validateFontColor(C); var E=C.innerHTML; try{E=this.replaceTag(E,"b","strong"); E=this.replaceTag(E,"i","em"); E=this.validateStrike(E); E=this.validateUnderline(E); E=this.addNbspToEmptyBlocks(E); if(B){E=this.performFullValidation(E) }}catch(A){}var G=F.tree.getBlockTags().join("|"); var D=new RegExp("([^\n])","img"); E=E.replace(D,"\n$2"); return E },invalidate:function(C){var F=xq.RichDom.createInstance(); F.setRoot(C); var E=xq.getElementsByClassName(F.getRoot(),"strike"); for(var B=0; B\\s*?","img"); return B.replace(A,"<$1> ") },replaceNbspToBr:function(B){var D=new xq.DomTree().getBlockTags().join("|"); var A=new RegExp("<("+D+")>( )?","img"); var C=xq.RichDom.createInstance(); return B.replace(A,"<$1>"+C.makePlaceHolderString()+"") }}); xq.ValidatorGecko=xq.Class(xq.ValidatorW3,{}); xq.ValidatorWebkit=xq.Class(xq.ValidatorW3,{}); xq.ValidatorTrident=xq.Class(xq.Validator,{validate:function(C,B){C=C.cloneNode(true); this.removeDangerousElements(C); this.validateFontColor(C); this.validateBackgroundColor(C); var D=C.innerHTML; try{D=this.validateStrike(D); D=this.validateUnderline(D); if(B){D=this.performFullValidation(D) }}catch(A){}return D },invalidate:function(C){var F=xq.RichDom.createInstance(); F.setRoot(C); this.invalidateFontColor(C); this.invalidateBackgroundColor(C); var E=xq.getElementsByClassName(F.getRoot(),"strike"); for(var B=0; B]*?)>/img,function(E,B,D,C){return"<"+B+D.toLowerCase()+this.correctHtmlAttrQuotation(C)+">" }.bind(this)); return A },correctHtmlAttrQuotation:function(A){A=A.replace(/\s(\w+?)=\s+"([^"]+)"/mg,function(D,B,C){return" "+B.toLowerCase()+"=\""+C+"\"" }); A=A.replace(/\s(\w+?)=([^ "]+)/mg,function(D,B,C){return" "+B.toLowerCase()+"=\""+C+"\"" }); return A }}); xq.EditHistory=xq.Class({initialize:function(B,A){xq.addToFinalizeQueue(this); if(!B){throw"IllegalArgumentException" }this.disabled=false; this.max=A||100; this.rdom=B; this.root=B.getRoot(); this.clear(); this.lastModified=Date.get() },getLastModifiedDate:function(){return this.lastModified },isUndoable:function(){return this.queue.length>0&&this.index>0 },isRedoable:function(){return this.queue.length>0&&this.index0){var A=B.html.substring(0,B.caret)+""+B.html.substring(B.caret); this.root.innerHTML=A }else{this.root.innerHTML=B.html }this.restoreCaret() },pushContent:function(B){if(xq.Browser.isTrident&&!B&&!this.rdom.hasFocus()){return false }if(!this.rdom.getCurrentElement()){return false }var A=this.root.innerHTML; if(A==(this.queue[this.index]?this.queue[this.index].html:null)){return false }var C=B?-1:this.saveCaret(); if(this.queue.length>=this.max){this.queue.shift() }else{this.index++ }this.queue.splice(this.index,this.queue.length-this.index,{html:A,caret:C}); return true },clear:function(){this.index=-1; this.queue=[]; this.pushContent(true) },saveCaret:function(){if(this.rdom.hasSelection()){return null }var A=this.rdom.pushMarker(); var C=xq.Browser.isTrident?"0){D[0].focus() }if(C.cancelOnEsc){xq.observe(this.form,"keydown",function(F){if(F.keyCode==27){this.onCloseHandler(); this.close() }return false }.bind(this)) }this.onLoadHandler(this) },close:function(){this.form.parentNode.removeChild(this.form) },setPosition:function(E){var F=null; var B=0; var H=0; if(E=="centerOfWindow"){F=document.documentElement }else{if(E=="centerOfEditor"){F=this.xed.getFrame(); var A=F; do{B+=A.offsetLeft; H+=A.offsetTop }while(A=A.offsetParent) }else{if(E=="nearbyCaret"){throw"Not implemented yet" }else{throw"Invalid argument: "+E }}}var I=F.clientWidth; var D=F.clientHeight; var C=this.form.clientWidth; var G=this.form.clientHeight; B+=parseInt((I-C)/2); H+=parseInt((D-G)/2); this.form.style.left=B+"px"; this.form.style.top=H+"px" }}); xq.controls.QuickSearchDialog=xq.Class({initialize:function(A,B){xq.addToFinalizeQueue(this); this.xed=A; this.rdom=xq.RichDom.createInstance(); this.rdom.setRoot(document.body); this.param=B; if(!this.param.renderItem){this.param.renderItem=function(C){return this.rdom.getInnerText(C) }.bind(this) }this.container=null },getQuery:function(){if(!this.container){return"" }return this._getInputField().value },onSubmit:function(A){if(this.matchCount()>0){this.param.onSelect(this.xed,this.list[this._getSelectedIndex()]) }this.close(); xq.stopEvent(A); return false },onCancel:function(A){if(this.param.onCancel){this.param.onCancel(this.xed) }this.close() },onBlur:function(A){setTimeout(function(){this.onCancel(A) }.bind(this),400) },onKey:function(C){var B=new xq.Shortcut("ESC"); var D=new xq.Shortcut("ENTER"); var A=new xq.Shortcut("UP"); var E=new xq.Shortcut("DOWN"); if(B.matches(C)){this.onCancel(C) }else{if(D.matches(C)){this.onSubmit(C) }else{if(A.matches(C)){this._moveSelectionUp() }else{if(E.matches(C)){this._moveSelectionDown() }else{this.updateList() }}}}},onClick:function(C){var B=C.srcElement||C.target; if(B.nodeName=="LI"){var A=this._getIndexOfLI(B); this.param.onSelect(this.xed,this.list[A]) }},onList:function(A){this.list=A; this.renderList(A) },updateList:function(){window.setTimeout(function(){this.param.listProvider(this.getQuery(),this.xed,this.onList.bind(this)) }.bind(this),0) },renderList:function(D){var B=this._getListContainer(); B.innerHTML=""; for(var C=0; C=C){B=0 }A.childNodes[B].className="selected" }}); if(!xq){xq={} }if(!xq.ui_templates){xq.ui_templates={} }xq.ui_templates.basicColorPickerDialog="
\n\t\t
\n\t\t\t\n\t\t\t\n\t\t\t\t\n\t\t\t\tYellow\n\t\t\t\n\t\t\t\n\t\t\t\t\n\t\t\t\tPink\n\t\t\t\n\t\t\t\n\t\t\t\n\t\t\t\n\t\t\t\n\t\t\t\n\t\t
\n\t
"; if(!xq){xq={} }if(!xq.ui_templates){xq.ui_templates={} }xq.ui_templates.basicLinkDialog="
\n\t\t

Link

\n\t\t
\n\t\t\t\n\t\t\t\n\t\t\t\n\t\t\t\n\t\t\t\n\t\t
\n\t
"