/*
 Constructor for kissy editor,dependency moved to independent module
 thanks to CKSource's intelligent work on CKEditor
 @author: yiminghe@gmail.com, lifesinger@gmail.com
 @version: 2.1.5
 @buildtime: 2011-04-18 21:45:33
*/
KISSY.add("editor",function(l){function v(q,s){var j=this;if(!(j instanceof v))return new v(q,s);if(l.isString(q))q=l.one(q);q=D._4e_wrap(q);s=s||{};s.pluginConfig=s.pluginConfig||{};j.cfg=s;s.pluginConfig=s.pluginConfig;j.cfg=s;l.app(j,l.EventTarget);var d=["htmldataprocessor","enterkey","clipboard"],e=r;j.use=function(f,h){f=f.split(",");if(!e)for(var p=0;p<d.length;p++){var k=d[p];l.inArray(k,f)||f.unshift(k)}j.ready(function(){l.use.call(j,f.join(","),function(){for(var a=0;a<f.length;a++)j.usePlugin(f[a]);
h&&h.call(j);if(!e){j.setData(q.val());if(s.focus)j.focus();else(a=j.getSelection())&&a.removeAllRanges();e=C}},{global:v})});return j};j.use=j.use;j.Config.base=v.Config.base;j.Config.debug=v.Config.debug;j.Config.componentJsName=y;j.init(q);return j}var D=l.DOM,C=true,r=false,y;y=parseFloat(l.version)<1.2?function(){return"plugin-min.js?t=2011-04-18 21:45:33"}:function(q,s){return q+"/plugin-min.js"+(s?s:"?t=2011-04-18 21:45:33")};l.app(v,l.EventTarget);v.Config.base=l.Config.base+"editor/plugins/";v.Config.debug=
l.Config.debug;v.Config.componentJsName=y;l.Editor=v;l.Editor=v});
KISSY.Editor.add("utils",function(l){var v=null,D=KISSY,C=D.Node,r=D.DOM,y=D.UA,q=D.Event,s;s=y.ie?document.documentMode||y.ie:void 0;var j={debugUrl:function(d){d=d.replace(/-min\.(js|css)/i,".$1");l.Config.debug||(d=d.replace(/\.(js|css)/i,"-min.$1"));if(d.indexOf("?t")==-1){d+=d.indexOf("?")!=-1?"&":"?";d+="t="+encodeURIComponent("2011-02-14 14:32:25")}return l.Config.base+d},lazyRun:function(d,e,f){var h=d[e],p=d[f];d[e]=function(){h.apply(this,arguments);d[e]=d[f];return p.apply(this,arguments)}},
getXY:function(d,e,f,h){f=f.defaultView||f.parentWindow;d-=r.scrollLeft(f);e-=r.scrollTop(f);if(h)if(f!=(h.defaultView||h.parentWindow)&&f.frameElement){h=r._4e_getOffset(f.frameElement,h);d+=h.left;e+=h.top}return{left:d,top:e}},tryThese:function(){for(var d,e=0,f=arguments.length;e<f;e++){var h=arguments[e];try{d=h();break}catch(p){}}return d},arrayCompare:function(d,e){if(!d&&!e)return true;if(!d||!e||d.length!=e.length)return false;for(var f=0;f<d.length;f++)if(d[f]!==e[f])return false;return true},
getByAddress:function(d,e,f){d=d.documentElement;for(var h=0;d&&h<e.length;h++){var p=e[h];if(f)for(var k=-1,a=0;a<d.childNodes.length;a++){var b=d.childNodes[a];if(!(f===true&&b.nodeType==3&&b.previousSibling&&b.previousSibling.nodeType==3)){k++;if(k==p){d=b;break}}}else d=d.childNodes[p]}return d?new C(d):v},clearAllMarkers:function(d){for(var e in d)d[e]._4e_clearMarkers(d,true)},htmlEncodeAttr:function(d){return d.replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/,"&gt;")},ltrim:function(d){return d.replace(/^\s+/,
"")},rtrim:function(d){return d.replace(/\s+$/,"")},trim:function(d){return this.ltrim(this.rtrim(d))},mix:function(){for(var d={},e=0;e<arguments.length;e++)d=D.mix(d,arguments[e]);return d},isCustomDomain:function(){if(!y.ie)return false;var d=document.domain,e=window.location.hostname;return d!=e&&d!="["+e+"]"},duplicateStr:function(d,e){return Array(e+1).join(d)},throttle:function(d,e,f){f=f||150;if(f===-1)return function(){d.apply(e,arguments)};var h=(new Date).getTime();return function(){var p=
(new Date).getTime();if(p-h>f){h=p;d.apply(e,arguments)}}},buffer:function(d,e,f){f=f||0;var h=v;return function(){h&&clearTimeout(h);var p=arguments;h=setTimeout(function(){return d.apply(e,p)},f)}},isNumber:function(d){return/^\d+(.\d+)?$/.test(D.trim(d))},verifyInputs:function(d){for(var e=0;e<d.length;e++){var f=r._4e_wrap(d[e]),h=D.trim(f.val()),p=f.attr("data-verify");f=f.attr("data-warning");if(p&&!RegExp(p).test(h)){alert(f);return false}}return true},sourceDisable:function(d,e){d.on("sourcemode",
e.disable,e);d.on("wysiwygmode",e.enable,e)},resetInput:function(d){var e=d.attr("placeholder");if(e&&!y.webkit){d.addClass("ke-input-tip");d.val(e)}else y.webkit&&d.val("")},valInput:function(d,e){d.removeClass("ke-input-tip");d.val(e)},placeholder:function(d,e){d.attr("placeholder",e);if(!y.webkit){d.on("blur",function(){if(!D.trim(d.val())){d.addClass("ke-input-tip");d.val(e)}});d.on("focus",function(){d.removeClass("ke-input-tip");D.trim(d.val())==e&&d.val("")})}},clean:function(d){d=d[0]||d;
for(var e=D.makeArray(d.childNodes),f=0;f<e.length;f++){var h=e[f];h.nodeType==l.NODE.NODE_TEXT&&!D.trim(h.nodeValue)&&d.removeChild(h)}},htmlEncode:function(d){return!d?d:String(d).replace(/&/g,"&amp;").replace(/>/g,"&gt;").replace(/</g,"&lt;").replace(/"/g,"&quot;")},htmlDecode:function(d){return!d?d:String(d).replace(/&gt;/g,">").replace(/&lt;/g,"<").replace(/&quot;/g,'"').replace(/&amp;/g,"&")},equalsIgnoreCase:function(d,e){return d.toLowerCase()==e.toLowerCase()},normParams:function(d){d=D.clone(d);
for(var e in d)if(d.hasOwnProperty(e)){var f=d[e];if(D.isFunction(f))d[e]=f()}return d},doFormUpload:function(d,e,f){function h(){var z={responseText:"",responseXML:v};z.argument=d?d.argument:v;try{var A;if((A=y.ie?k.contentWindow.document:k.contentDocument||window.frames[p].document)&&A.body)z.responseText=A.body.innerHTML;z.responseXML=A&&A.XMLDocument?A.XMLDocument:A}catch(w){D.log(w)}q.remove(k,"load",h);d.callback&&d.callback(z);setTimeout(function(){r._4e_remove(k)},100)}var p=D.guid("form-upload-"),
k=document.createElement("iframe");k.id=p;k.name=p;k.className="ke-hidden";var a="document.open();"+(j.isCustomDomain()?'document.domain="'+document.domain+'";':"")+"document.close();";if(y.ie)k.src=y.ie?"javascript:void(function(){"+encodeURIComponent(a)+"}())":"";D.log("doFormUpload : "+k.src);document.body.appendChild(k);if(y.ie)document.frames[p].name=p;a=r._4e_unwrap(d.form);var b={target:a.target,method:a.method,encoding:a.encoding,enctype:a.enctype,action:a.action};a.target=p;a.method="POST";
a.enctype=a.encoding="multipart/form-data";if(f)a.action=f;var g;if(e){g=[];e=l.Utils.normParams(e);for(var n in e)if(e.hasOwnProperty(n)){f=document.createElement("input");f.type="hidden";f.name=n;f.value=e[n];a.appendChild(f);g.push(f)}}q.on(k,"load",h);a.submit();a.target=b.target;a.method=b.method;a.enctype=b.enctype;a.encoding=b.encoding;a.action=b.action;if(g){e=0;for(n=g.length;e<n;e++)r._4e_remove(g[e])}return k},extern:function(d,e){for(var f in e)d[f]=e[f]},map:function(d,e){for(var f=0;f<
d.length;f++)d[f]=e(d[f]);return d},ieEngine:s,preventFocus:function(d){y.ie?d._4e_unselectable():d.attr("onmousedown","return false;")},isFlashEmbed:function(d){d=d.attributes;return d.type=="application/x-shockwave-flash"||/\.swf(?:$|\?)/i.test(d.src||"")},addRes:function(){var d=this.__res=this.__res||[];d.push.apply(d,D.makeArray(arguments))},destroyRes:function(){for(var d=this.__res||[],e=0;e<d.length;e++){var f=d[e];if(D.isFunction(f))f();else{f.detach&&f.detach();f.destroy&&f.destroy();f.nodeType&&
f.remove&&f.remove()}}this.__res=[]}};l.Utils=j;l.Utils=j;y.ieEngine=j.ieEngine;j.extern(j,{debugUrl:j.debugUrl,lazyRun:j.lazyRun,getXY:j.getXY,tryThese:j.tryThese,arrayCompare:j.arrayCompare,getByAddress:j.getByAddress,clearAllMarkers:j.clearAllMarkers,htmlEncodeAttr:j.htmlEncodeAttr,ltrim:j.ltrim,rtrim:j.rtrim,trim:j.trim,mix:j.mix,isCustomDomain:j.isCustomDomain,duplicateStr:j.duplicateStr,buffer:j.buffer,isNumber:j.isNumber,verifyInputs:j.verifyInputs,sourceDisable:j.sourceDisable,resetInput:j.resetInput,
placeholder:j.placeholder,clean:j.clean,htmlEncode:j.htmlEncode,htmlDecode:j.htmlDecode,equalsIgnoreCase:j.equalsIgnoreCase,normParams:j.normParams,throttle:j.throttle,doFormUpload:j.doFormUpload,map:j.map})});
KISSY.Editor.add("dom",function(l){function v(a){return a.replace(/-(\w)/g,function(b,g){return g.toUpperCase()})}var D=KISSY,C=D.DOM,r=D.UA,y=D.Node,q=l.Utils,s={abbr:1,acronym:1,address:1,b:1,bdo:1,big:1,cite:1,code:1,del:1,dfn:1,em:1,font:1,i:1,ins:1,label:1,kbd:1,q:1,s:1,samp:1,small:1,span:1,strike:1,strong:1,sub:1,sup:1,tt:1,u:1,"var":1};l.NODE={NODE_ELEMENT:1,NODE_TEXT:3,NODE_COMMENT:8,NODE_DOCUMENT_FRAGMENT:11};l.NODE=l.NODE;l.POSITION={POSITION_IDENTICAL:0,POSITION_DISCONNECTED:1,POSITION_FOLLOWING:2,
POSITION_PRECEDING:4,POSITION_IS_CONTAINED:8,POSITION_CONTAINS:16};l.POSITION=l.POSITION;var j=l.NODE,d=l.POSITION,e={block:1,"list-item":1,table:1,"table-row-group":1,"table-header-group":1,"table-footer-group":1,"table-row":1,"table-column-group":1,"table-column":1,"table-cell":1,"table-caption":1},f={hr:1},h=function(a){return a[0]||a},p=function(a){if(a&&!a[0])return new y(a);return a},k={_4e_wrap:p,_4e_unwrap:h,_4e_equals:function(a,b){if(!a&&!b)return true;if(!a||!b)return false;a=h(a);b=h(b);
return a===b},_4e_isBlockBoundary:function(a,b){a=p(a);var g=D.mix(D.mix({},f),b||{});return e[a.css("display")]||g[a._4e_name()]},_4e_getWin:function(a){return a&&"scrollTo"in a&&a.document?a:a&&a.nodeType===9?a.defaultView||a.parentWindow:false},_4e_index:function(a){a=h(a);for(var b=a.parentNode.childNodes,g=0;g<b.length;g++)if(b[g]===a)return g;return-1},_4e_first:function(a,b){a=h(a);var g=a.firstChild;if((g=g&&new y(g))&&b&&!b(g))g=g._4e_next(b);return g},_4e_move:function(a,b,g){a=h(a);C._4e_remove(a);
b=h(b);g?b.insertBefore(a,b.firstChild):b.appendChild(a)},_4e_name:function(a){a=h(a);var b=a.nodeName.toLowerCase();if(r.ie)if((a=a.scopeName)&&a!="HTML")b=a.toLowerCase()+":"+b;return b},_4e_isIdentical:function(a,b){if(a._4e_name()!=b._4e_name())return false;var g=a[0].attributes,n=b[0].attributes,z=g.length,A=n.length;if(z!=A)return false;for(var w=0;w<z;w++){var u=g[w],x=u.name;if(u.specified&&a.attr(x)!=b.attr(x))return false}if(q.ieEngine<8)for(w=0;w<A;w++){u=n[w];x=u.name;if(u.specified&&
a.attr(x)!=b.attr(x))return false}return true},_4e_isEmptyInlineRemoveable:function(a){a=h(a).childNodes;for(var b=0,g=a.length;b<g;b++){var n=a[b],z=n.nodeType;if(!(z==j.NODE_ELEMENT&&n.getAttribute("_ke_bookmark")))if(z==j.NODE_ELEMENT&&!k._4e_isEmptyInlineRemoveable(n)||z==j.NODE_TEXT&&D.trim(n.nodeValue))return false}return true},_4e_moveChildren:function(a,b,g){a=h(a);b=b[0]||b;if(a!=b)if(g)for(;g=a.lastChild;)b.insertBefore(a.removeChild(g),b.firstChild);else for(;g=a.firstChild;)b.appendChild(a.removeChild(g))},
_4e_mergeSiblings:function(){function a(b,g,n){if(g[0]&&g[0].nodeType==j.NODE_ELEMENT){for(var z=[];g.attr("_ke_bookmark")||g._4e_isEmptyInlineRemoveable();){z.push(g);g=n?new y(g[0].nextSibling):new y(g[0].previousSibling);if(!g[0]||g[0].nodeType!=j.NODE_ELEMENT)return}if(b._4e_isIdentical(g)){for(var A=n?b[0].lastChild:b[0].firstChild;z.length;)z.shift()._4e_move(b,!n);g._4e_moveChildren(b,!n);g._4e_remove();A[0]&&A[0].nodeType==j.NODE_ELEMENT&&A._4e_mergeSiblings()}}}return function(b){if(b[0])if(s[b._4e_name()]||
b._4e_name()=="a"){a(b,new y(b[0].nextSibling),true);a(b,new y(b[0].previousSibling))}}}(),_4e_unselectable:r.gecko?function(a){a=h(a);a.style.MozUserSelect="none"}:r.webkit?function(a){a=h(a);a.style.KhtmlUserSelect="none"}:function(a){a=h(a);if(r.ie||r.opera){var b=0;a.setAttribute("unselectable","on");for(var g=a.getElementsByTagName("*");a=g[b++];)switch(a.tagName.toLowerCase()){case "iframe":case "textarea":case "input":case "select":break;default:a.setAttribute("unselectable","on")}}},_4e_getOffset:function(a,
b){a=h(a);var g,n=0;g=0;var z=a.ownerDocument.defaultView||a.ownerDocument.parentWindow,A=a.ownerDocument,w=A.documentElement;b=b||A;if(a.getBoundingClientRect){if(a!==A.body&&w!==a){g=a.getBoundingClientRect();n=g.left+(b===A?C.scrollLeft(z):0);g=g.top+(b===A?C.scrollTop(z):0)}if(b)if(z!=(b.defaultView||b.parentWindow)&&z.frameElement){z=k._4e_getOffset(z.frameElement,b);n+=z.left;g+=z.top}}return{left:n,top:g}},_4e_getFrameDocument:function(a){return(a=h(a))&&a.contentWindow.document},_4e_splitText:function(a,
b){a=h(a);var g=a.ownerDocument;if(!(!a||a.nodeType!=j.NODE_TEXT)){if(r.ie&&b==a.nodeValue.length){var n=g.createTextNode("");C.insertAfter(n,a);return new y(n)}n=new y(a.splitText(b));if(g.documentMode){g=g.createTextNode("");C.insertAfter(g,n[0]);C._4e_remove(g)}return n}},_4e_parents:function(a,b){a=p(a);var g=[];do g[b?"push":"unshift"](a);while(a=a.parent());return g},_4e_clone:function(a,b,g){a=h(a);a=a.cloneNode(b);if(!g){var n=function(z){if(z.nodeType==j.NODE_ELEMENT){z.removeAttribute("id");
z=z.childNodes;for(var A=0;A<z.length;A++)n(z[A])}};n(a)}return new y(a)},_4e_nextSourceNode:function(a,b,g,n){a=h(a);if(n&&!n.call){var z=n[0]||n;n=function(w){w=w[0]||w;return w!==z}}b=!b&&a.firstChild;var A=new y(a);if(!b){if(a.nodeType==j.NODE_ELEMENT&&n&&n(a,true)===false)return null;b=a.nextSibling}for(;!b&&(A=A.parent());){if(n&&n(A,true)===false)return null;b=A[0].nextSibling}if(!b)return null;b=C._4e_wrap(b);if(n&&n(b)===false)return null;if(g&&g!=b[0].nodeType)return b._4e_nextSourceNode(false,
g,n);return b},_4e_previousSourceNode:function(a,b,g,n){a=h(a);if(n&&!n.call){var z=n[0]||n;n=function(w){w=w[0]||w;return w!==z}}b=!b&&a.lastChild;var A=new y(a);if(!b){if(a.nodeType==j.NODE_ELEMENT&&n&&n(a,true)===false)return null;b=a.previousSibling}for(;!b&&(A=A.parent());){if(n&&n(A,true)===false)return null;b=A[0].previousSibling}if(!b)return null;b=C._4e_wrap(b);if(n&&n(b)===false)return null;if(g&&b[0].nodeType!=g)return b._4e_previousSourceNode(false,g,n);return b},_4e_commonAncestor:function(a,
b){if(a._4e_equals(b))return a;if(b[0].nodeType!=j.NODE_TEXT&&b.contains(a))return b;var g=a[0].nodeType==j.NODE_TEXT?a.parent():a;do if(g[0].nodeType!=j.NODE_TEXT&&g.contains(b))return g;while(g=g.parent());return null},_4e_ascendant:function(a,b,g){a=h(a);if(!g)a=a.parentNode;if(b&&!D.isFunction(b)){var n=b;b=function(z){return z._4e_name()==n}}for(;a&&a.nodeType!=9;){if(!b||b(new y(a))===true)return new y(a);a=a.parentNode}return null},_4e_hasAttribute:q.ieEngine<9?function(a,b){a=h(a);var g=a.getAttributeNode(b);
return!!(g&&g.specified)}:function(a,b){a=h(a);return a.hasAttribute(b)},_4e_hasAttributes:q.ieEngine<9?function(a){a=h(a);for(var b=a.attributes,g=0;g<b.length;g++){var n=b[g];switch(n.name){case "class":if(a.getAttribute("class"))return true;break;default:if(n.specified)return true}}return false}:function(a){a=h(a);r.gecko&&a.removeAttribute("_moz_dirty");return a.hasAttributes()},_4e_position:function(a,b){var g=h(a),n=h(b);if(g.compareDocumentPosition)return g.compareDocumentPosition(n);if(g==
n)return d.POSITION_IDENTICAL;if(g.nodeType==j.NODE_ELEMENT&&n.nodeType==j.NODE_ELEMENT){if(g.contains){if(g.contains(n))return d.POSITION_CONTAINS+d.POSITION_PRECEDING;if(n.contains(g))return d.POSITION_IS_CONTAINED+d.POSITION_FOLLOWING}if("sourceIndex"in g)return g.sourceIndex<0||n.sourceIndex<0?d.POSITION_DISCONNECTED:g.sourceIndex<n.sourceIndex?d.POSITION_PRECEDING:d.POSITION_FOLLOWING}g=a._4e_address();n=b._4e_address();for(var z=Math.min(g.length,n.length),A=0;A<=z-1;A++)if(g[A]!=n[A]){if(A<
z)return g[A]<n[A]?d.POSITION_PRECEDING:d.POSITION_FOLLOWING;break}return g.length<n.length?d.POSITION_CONTAINS+d.POSITION_PRECEDING:d.POSITION_IS_CONTAINED+d.POSITION_FOLLOWING},_4e_address:function(a,b){a=h(a);for(var g=[],n=a.ownerDocument.documentElement,z=a;z&&z!=n;){var A=z.parentNode,w=-1;if(A){for(var u=0;u<A.childNodes.length;u++){var x=A.childNodes[u];if(!(b&&x.nodeType==3&&x.previousSibling&&x.previousSibling.nodeType==3)){w++;if(x==z)break}}g.unshift(w)}z=A}return g},_4e_breakParent:function(a,
b){var g=new l.Range(a[0].ownerDocument);g.setStartAfter(a);g.setEndAfter(b);var n=g.extractContents();g.insertNode(a._4e_remove());a[0].parentNode.insertBefore(n,a[0].nextSibling)},_4e_style:function(a,b,g){a=p(a);if(g!==undefined)return a.css(b,g);a=h(a);return a.style[v(b)]},_4e_remove:function(a,b){var g=h(a),n=g.parentNode;if(n){if(b)for(var z;z=g.firstChild;)n.insertBefore(g.removeChild(z),g);n.removeChild(g)}return a},_4e_trim:function(a){C._4e_ltrim(a);C._4e_rtrim(a)},_4e_ltrim:function(a){a=
h(a);for(var b;b=a.firstChild;){if(b.nodeType==j.NODE_TEXT){var g=q.ltrim(b.nodeValue),n=b.nodeValue.length;if(g){if(g.length<n){(new y(b))._4e_splitText(n-g.length);a.removeChild(a.firstChild)}}else{a.removeChild(b);continue}}break}},_4e_rtrim:function(a){a=h(a);for(var b;b=a.lastChild;){if(b.type==j.NODE_TEXT){var g=q.rtrim(b.nodeValue),n=b.nodeValue.length;if(g){if(g.length<n){(new y(b))._4e_splitText(g.length);a.removeChild(a.lastChild)}}else{a.removeChild(b);continue}}break}if(!r.ie&&!r.opera)(b=
a.lastChild)&&b.nodeType==1&&b.nodeName.toLowerCase()=="br"&&b.parentNode.removeChild(b)},_4e_appendBogus:function(a){a=h(a);for(var b=a.lastChild;b&&b.nodeType==j.NODE_TEXT&&!D.trim(b.nodeValue);)b=b.previousSibling;if(!b||b.nodeType==j.NODE_TEXT||C._4e_name(b)!=="br"){b=r.opera?a.ownerDocument.createTextNode(""):a.ownerDocument.createElement("br");r.gecko&&b.setAttribute("type","_moz");a.appendChild(b)}},_4e_previous:function(a,b){var g=h(a),n;do n=(g=g.previousSibling)&&new y(g);while(n&&b&&!b(n));
return n},_4e_last:function(a,b){a=C._4e_wrap(a);var g=a[0].lastChild;if((g=g&&new y(g))&&b&&!b(g))g=g._4e_previous(b);return g},_4e_next:function(a,b){var g=h(a),n;do n=(g=g.nextSibling)&&new y(g);while(n&&b&&!b(n));return n},_4e_outerHtml:function(a){a=h(a);if(a.outerHTML)return a.outerHTML.replace(/<\?[^>]*>/,"");var b=a.ownerDocument.createElement("div");b.appendChild(a.cloneNode(true));return b.innerHTML},_4e_setMarker:function(a,b,g,n){a=C._4e_wrap(a);var z=a.data("list_marker_id")||a.data("list_marker_id",
D.guid()).data("list_marker_id"),A=a.data("list_marker_names")||a.data("list_marker_names",{}).data("list_marker_names");b[z]=a;A[g]=1;return a.data(g,n)},_4e_clearMarkers:function(a,b,g){a=p(a);var n=a.data("list_marker_names"),z=a.data("list_marker_id"),A;for(A in n)a.removeData(A);a.removeData("list_marker_names");if(g){a.removeData("list_marker_id");delete b[z]}},_4e_copyAttributes:function(a,b,g){a=h(a);b=p(b);var n=a.attributes;g=g||{};for(var z=0;z<n.length;z++){var A=n[z],w=A.name.toLowerCase(),
u;if(!(w in g))if(w=="checked"&&(u=C.attr(a,w)))b.attr(w,u);else if(A.specified||r.ie&&A.value&&w=="value"){u=C.attr(a,w);if(u===null)u=A.nodeValue;b.attr(w,u)}}if(a.style.cssText!=="")b[0].style.cssText=a.style.cssText},_4e_isEditable:function(a){a=C._4e_name(a);var b=l.XHTML_DTD;return(a=!b.$nonEditable[a]&&(b[a]||b.span))&&a["#"]},_4e_scrollIntoView:function(a){a=p(a);var b=a[0].ownerDocument,g=C.scrollLeft(b),n=C.scrollTop(b),z=a.offset(),A=z.left;z=z.top;if(C.viewportHeight(b)+n<z||z<n||C.viewportWidth(b)+
g<A||A<g)a.scrollIntoView(b)},_4e_getElementsByTagName:function(a,b,g){a=h(a);if(!r.ie&&g)b=g+":"+b;g=[];a=a.getElementsByTagName(b);for(b=0;b<a.length;b++)g.push(new y(a[b]));return g}};D.DOM._4e_inject=function(a){D.mix(C,a);for(var b in a)a.hasOwnProperty(b)&&function(g){y.prototype[g]=function(){var n=[].slice.call(arguments,0);n.unshift(this);return a[g].apply(null,n)}}(b)};q.extern(k,{_4e_wrap:k._4e_wrap,_4e_unwrap:k._4e_unwrap,_4e_equals:k._4e_equals,_4e_isBlockBoundary:k._4e_isBlockBoundary,
_4e_getWin:k._4e_getWin,_4e_index:k._4e_index,_4e_first:k._4e_first,_4e_move:k._4e_move,_4e_name:k._4e_name,_4e_isIdentical:k._4e_isIdentical,_4e_isEmptyInlineRemoveable:k._4e_isEmptyInlineRemoveable,_4e_moveChildren:k._4e_moveChildren,_4e_mergeSiblings:k._4e_mergeSiblings,_4e_unselectable:k._4e_unselectable,_4e_getOffset:k._4e_getOffset,_4e_getFrameDocument:k._4e_getFrameDocument,_4e_splitText:k._4e_splitText,_4e_parents:k._4e_parents,_4e_clone:k._4e_clone,_4e_nextSourceNode:k._4e_nextSourceNode,
_4e_previousSourceNode:k._4e_previousSourceNode,_4e_commonAncestor:k._4e_commonAncestor,_4e_ascendant:k._4e_ascendant,_4e_hasAttribute:k._4e_hasAttribute,_4e_hasAttributes:k._4e_hasAttributes,_4e_position:k._4e_position,_4e_address:k._4e_address,_4e_breakParent:k._4e_breakParent,_4e_style:k._4e_style,_4e_remove:k._4e_remove,_4e_trim:k._4e_trim,_4e_ltrim:k._4e_ltrim,_4e_rtrim:k._4e_rtrim,_4e_appendBogus:k._4e_appendBogus,_4e_last:k._4e_last,_4e_previous:k._4e_previous,_4e_next:k._4e_next,_4e_outerHtml:k._4e_outerHtml,
_4e_setMarker:k._4e_setMarker,_4e_clearMarkers:k._4e_clearMarkers,_4e_getUniqueId:k._4e_getUniqueId,_4e_copyAttributes:k._4e_copyAttributes,_4e_isEditable:k._4e_isEditable,_4e_scrollIntoView:k._4e_scrollIntoView,_4e_getElementsByTagName:k._4e_getElementsByTagName});C._4e_inject(k)});
KISSY.Editor.add("focusmanager",function(l){function v(){var h=this;h.iframeFocus=d;j=h;s&&clearTimeout(s);s=setTimeout(function(){h.fire("focus")},100)}function D(){var h=this;h.iframeFocus=e;j=f;s&&clearTimeout(s);s=setTimeout(function(){h.fire("blur")},100)}var C=KISSY,r=C.DOM,y=C.Event,q={},s,j;C={refreshAll:function(){for(var h in q){var p=q[h];p.document.designMode="off";p.document.designMode="on"}},currentInstance:function(){return j},getInstance:function(h){return q[h]},add:function(h){var p=
r._4e_getWin(h.document);y.on(p,"focus",v,h);y.on(p,"blur",D,h)},register:function(h){q[h._UUID]=h},remove:function(h){delete q[h._UUID];var p=r._4e_getWin(h.document);y.remove(p,"focus",v,h);y.remove(p,"blur",D,h)}};var d=true,e=false,f=null;l.focusManager=C;l.focusManager=C;l.getInstances=function(){return q};l.getInstances=l.getInstances});
KISSY.Editor.add("definition",function(l){var v=true,D=false,C=l.Utils,r=document,y=KISSY,q=y.UA,s=y.DOM,j=y.Node,d=y.Event,e=l.focusManager,f=C.tryThese,h=1,p="document.open();"+(C.isCustomDomain()?'document.domain="'+r.domain+'";':"")+"document.close();",k="<div  class='ke-editor-wrap'  > <div class='"+".ke-editor-tools".substring(1)+"' ></div><div class='"+".ke-textarea-wrap".substring(1)+'\'><iframe  style="width:100%;height:100%;border:none;"  width="100%"  height="100%"  frameborder="0"  title="kissy-editor"  src="'+
(q.ie?"javascript:void(function(){"+encodeURIComponent(p)+"}())":"")+'"  allowTransparency="true" ></iframe></div><div class=\''+".ke-editor-status".substring(1)+"'></div></div>";l.SOURCE_MODE=0;l.WYSIWYG_MODE=1;l.SOURCE_MODE=l.SOURCE_MODE;l.WYSIWYG_MODE=l.WYSIWYG_MODE;y.augment(l,{init:function(a){var b=this;b.__commands={};b.__dialogs={};b.__plugins={};q.ie&&s.addClass(r.body,"ke-ie"+q.ie);if(q.trident)s.addClass(r.body,"ke-trident"+q.trident);else if(q.gecko)s.addClass(r.body,"ke-gecko");else q.webkit&&
s.addClass(r.body,"ke-webkit");var g=new j(k);b.editorWrap=g;b._UUID=h++;e.register(b);b.wrap=g.one(".ke-textarea-wrap");b.wrap=b.wrap;b.iframe=b.wrap.one("iframe");b.iframe=b.iframe;b.toolBarDiv=g.one(".ke-editor-tools");b.toolBarDiv=b.toolBarDiv;b.textarea=a;b.textarea=b.textarea;b.statusDiv=g.one(".ke-editor-status");b.statusDiv=b.statusDiv;C.preventFocus(b.toolBarDiv);var n=a._4e_style("width"),z=a._4e_style("height");if(n){g.css("width",n);a.css("width","100%")}b.textarea.css("display","none");
g.insertAfter(a);b.wrap[0].appendChild(a[0]);if(z){b.wrap.css("height",z);a.css("height","100%")}g=b.iframe;if(a._4e_hasAttribute("tabindex"))g[0].tabIndex=q.webkit?-1:a[0].tabIndex;b.on("dataReady",function(){b._ready=v;l.fire("instanceCreated",{editor:b})});q.gecko?g.on("load",b._setUpIFrame,b):b._setUpIFrame();b.cfg.attachForm&&a[0].form&&b._attachForm()},destroy:function(){if(!this.__destroyed){var a=this.editorWrap,b=this.textarea,g=this.document,n=this.iframe[0].contentWindow;this.sync();l.focusManager.remove(this);
d.remove(g);d.remove(g.documentElement);d.remove(g.body);d.remove(n);this.iframe.detach();g=this.__plugins;for(var z in g)if(g.hasOwnProperty(z)){n=g[z];n.destroy&&n.destroy()}this.fire("destroy");b.insertBefore(a);a.remove();b.css({width:a.css("width"),height:this.wrap.css("height")});b.show();this.__commands=this.__dialogs=this.__plugins=null;this.detach();this.__destroyed=true}},_attachForm:function(){var a=this,b=new j(a.textarea[0].form);b.on("submit",a.sync,a);a.on("destroy",function(){b.detach("submit",
a.sync,a)})},useDialog:function(a,b){var g=this,n=l.Overlay;n&&n.loading();g.use(a,function(){var z=g.getDialog(a);if(z){b(z);n&&n.unloading()}else y.later(arguments.callee,50,false,g)})},addDialog:function(a,b){this.__dialogs[a]=b},getDialog:function(a){return this.__dialogs[a]},destroyDialog:function(a){var b=this.__dialogs[a];b&&b.destroy();this.__dialogs[a]=null},addCommand:function(a,b){this.__commands[a]=b},hasCommand:function(a){return this.__commands[a]},execCommand:function(a){var b=this.__commands[a],
g=y.makeArray(arguments);g.shift();g.unshift(this);return b.exec.apply(b,g)},getMode:function(){return this.textarea.css("display")=="none"?l.WYSIWYG_MODE:l.SOURCE_MODE},getData:function(a){var b;b=this.getMode()==l.WYSIWYG_MODE?this.document&&this.document.body?this.document.body.innerHTML:"":this.textarea.val();if(this.htmlDataProcessor)b=a?this.htmlDataProcessor.toHtml(b,"p"):this.htmlDataProcessor.toServer(b,"p");b=y.trim(b);if(/^<p>((&nbsp;)|\s)*<\/p>$/.test(b))b="";return b},setData:function(a){var b=
a;if(this.htmlDataProcessor)b=this.htmlDataProcessor.toDataFormat(a,"p");this.document.body.innerHTML=b;if(!b)this.document.body.innerHTML=b;this.getMode()!=l.WYSIWYG_MODE&&this.textarea.val(a)},sync:function(){this.textarea.val(this.getData())},_getRawData:function(){return this.document.body.innerHTML},_setRawData:function(a){this.document.body.innerHTML=a},_prepareIFrameHtml:function(a){var b=this.cfg,g=b.customStyle;b=b.customLink;var n="",z=l.Utils.debugUrl("../theme/editor-iframe.css");if(b)for(var A=
0;A<b.length;A++)n+='<link href="'+b[A]+'" rel="stylesheet"/>';return"<!doctype html><html><head><title>${title}</title><link href='"+z+"' rel='stylesheet'/><style>"+(g||"")+"</style>"+n+"</head><body class='ke-editor'>&nbsp;"+(a?'<script id="ke_actscript" type="text/javascript">'+(C.isCustomDomain()?'document.domain="'+r.domain+'";':"")+'window.parent.KISSY.Editor._initIFrame("'+a+'");<\/script>':"")+"</body></html>"},getSelection:function(){return l.Selection.getSelection(this.document)},focus:function(){var a=
this.document,b=s._4e_getWin(a);q.webkit&&b&&b.parent&&b.parent.focus();q.webkit&&b&&b.focus();a&&a.body.focus();this.notifySelectionChange()},blur:function(){s._4e_getWin(this.document).blur();this.document&&this.document.body.blur()},addCustomStyle:function(a){var b=this.cfg,g=this.document;b.customStyle=b.customStyle||"";b.customStyle+="\n"+a;b=g.createElement("style");g.getElementsByTagName("head")[0].appendChild(b);if(b.styleSheet)b.styleSheet.cssText=a;else b.appendChild(g.createTextNode(a))},
addCustomLink:function(a){var b=this.cfg,g=this.document;b.customLink=b.customLink||[];b.customLink.push(a);b=g.createElement("link");b.rel="stylesheet";g.getElementsByTagName("head")[0].appendChild(b);b.href=a},removeCustomLink:function(a){for(var b=this.cfg,g=y.makeArray(this.document.getElementsByTagName("link")),n=0;n<g.length;n++)g[n].href==a&&s._4e_remove(g[n]);b.customLink=b.customLink||[];b=b.customLink;a=y.indexOf(a,b);a!=-1&&b.splice(a,1)},_setUpIFrame:function(){function a(){A=z.document;
b.document=A;g.detach();A.open("text/html","replace");A.write(n);A.close()}var b=this,g=b.iframe,n=b._prepareIFrameHtml(b._UUID),z=g[0].contentWindow,A;try{A=z.document}catch(w){g[0].src=g[0].src;if(q.ie<7){setTimeout(a,10);return}}a()},ready:function(a){this._ready?a():this.on("dataReady",a)},addPlugin:function(a,b,g){this.__plugins=this.__plugins;g=g||{};g.func=b;this.__plugins[a]=g},usePlugin:function(a){var b=this.__plugins[a];if(b)if(!(b.status&&!b.duplicate)){a=this.Env.mods[a].requires||[];
for(var g=0;g<a.length;g++)this.usePlugin(a[g]);b.func.call(b);b.status=1}},_monitor:function(){var a=this;a._monitorId&&clearTimeout(a._monitorId);a._monitorId=setTimeout(function(){var b=a.getSelection();if(b&&!b.isInvalid){var g=b.getStartElement(),n=new l.ElementPath(g);if(!a.previousPath||!a.previousPath.compare(n)){a.previousPath=n;a.fire("selectionChange",{selection:b,path:n,element:g})}}},100)},notifySelectionChange:function(){this.previousPath=null;this._monitor()},insertElement:function(a,
b,g){var n=this;n.focus();setTimeout(function(){var z,A=a._4e_name(),w=l.XHTML_DTD,u=l.RANGE,x=l.NODE,J=w.$block[A],B=n.getSelection(),c=B&&B.getRanges(),i,o,t,m;if(!c||c.length==0){var E=arguments,P=E.callee;setTimeout(function(){P.apply(n,E)},30)}else{n.fire("save");for(var O=c.length-1;O>=0;O--){i=c[O];i.deleteContents();z=!O&&a||a._4e_clone(v);b&&b(z);if(J)for(;(t=i.getCommonAncestor(D,v))&&(m=w[t._4e_name()])&&!(m&&m[A]);)if(t._4e_name()in w.span)i.splitElement(t);else if(i.checkStartOfBlock()&&
i.checkEndOfBlock()){i.setStartBefore(t);i.collapse(v);t._4e_remove()}else i.splitBlock();i.insertNode(z);o||(o=z)}if(o){A=o._4e_nextSourceNode(v);w=n.document;m=l.XHTML_DTD;if(m.$inline[z._4e_name()]){A=new j(w.createTextNode(" "));A.insertAfter(o)}else if(A){if(A._4e_name()=="br"&&m[A.parent()._4e_name()].p){m=new j("<p>&nbsp;</p>",null,w);A[0].parentNode.replaceChild(m[0],A[0]);A=m}}else{m=new j("<p>&nbsp;</p>",null,w);m.insertAfter(o);A=m}i.moveToPosition(o,u.POSITION_AFTER_END);A&&A[0].nodeType==
x.NODE_ELEMENT&&i.moveToElementEditablePosition(A);B.selectRanges([i]);n.focus();z&&z._4e_scrollIntoView();setTimeout(function(){n.fire("save")},10);g&&g(z)}}},0)},insertHtml:function(a,b){var g=this;if(g.htmlDataProcessor)a=g.htmlDataProcessor.toDataFormat(a,null,b);g.focus();setTimeout(function(){var n=g.getSelection(),z=n&&n.getRanges();if(!z||z.length==0){var A=arguments,w=A.callee;setTimeout(function(){w.apply(g,A)},30)}else{g.fire("save");if(document.selection){z=document.selection;if(z.type==
"Control")z.clear();else if(n.getType()==l.SELECTION.SELECTION_TEXT){n=n.getRanges()[0];n.deleteContents();n.select()}z.createRange().pasteHTML(a)}else g.document.execCommand("inserthtml",D,a);setTimeout(function(){g.fire("save")},10)}},0)}});l._initIFrame=function(a){function b(c){f(function(){z.designMode="on";setTimeout(function(){z.designMode="off";u.focus();if(!arguments.callee.retry)arguments.callee.retry=v},50)},function(){z.designMode="off";s.attr(u,"contentEditable",D);s.attr(u,"contentEditable",
v);!c&&b(1)})}var g=e.getInstance(a);a=g.textarea[0];var n=g.iframe[0].contentWindow,z=g.document,A=g.cfg,w=z.getElementById("ke_actscript");s._4e_remove(w);var u=z.body;if(q.ie){u.hideFocus=v;u.disabled=v;u.contentEditable=v;u.removeAttribute("disabled")}else setTimeout(function(){if(q.gecko||q.opera)u.contentEditable=v;else if(q.webkit)u.parentNode.contentEditable=v;else z.designMode="on"},0);if(q.webkit){d.on(z,"click",function(c){var i=new j(c.target);y.inArray(i._4e_name(),["input","select"])&&
c.preventDefault()});d.on(z,"mouseup",function(c){var i=new j(c.target);y.inArray(i._4e_name(),["input","textarea"])&&c.preventDefault()})}if(q.gecko||q.ie||q.opera){var x;x=new j(s.insertAfter((new j('<span tabindex="-1" style="position:absolute; left:-10000" role="presentation"></span>'))[0],a));x.on("focus",function(){g.focus()});g.activateGecko=function(){q.gecko&&g.iframeFocus&&x[0].focus()};g.on("destroy",function(){x.detach();x.remove()})}if(z.documentMode||q.gecko||q.opera){var J=z.documentElement;
d.on(J,"mousedown",function(c){if((new j(c.target))[0]==J){q.gecko&&b(D);x[0].focus()}})}d.on(n,"focus",function(){if(q.gecko)b(D);else q.opera&&u.focus();g.notifySelectionChange()});q.gecko&&d.on(g.document,"mousedown",function(){g.iframeFocus||b(D)});if(q.ie){d.on(z,"keydown",function(c){if(c.keyCode in{8:1,46:1}){var i=g.getSelection(),o=i.getSelectedElement();if(o){g.fire("save");var t=i.getRanges()[0].createBookmark();o._4e_remove();i.selectBookmarks([t]);g.fire("save");c.preventDefault()}}});
if(z.compatMode=="CSS1Compat"){var B={33:1,34:1};d.on(z,"keydown",function(c){c.keyCode in B&&setTimeout(function(){g.getSelection().scrollIntoView()},0)})}}setTimeout(function(){q.ie&&setTimeout(function(){if(z){u.runtimeStyle.marginBottom="0px";u.runtimeStyle.marginBottom=""}},1E3)},0);setTimeout(function(){g.fire("dataReady");var c=A.disableObjectResizing,i=A.disableInlineTableEditing;if(c||i)try{z.execCommand("enableObjectResizing",D,!c);z.execCommand("enableInlineTableEditing",D,!i)}catch(o){d.on(u,
q.ie?"resizestart":"resize",function(t){var m=new j(t.target);if(c||m._4e_name()==="table"&&i)t.preventDefault()})}},10);q.webkit&&d.on(z,"mousedown",function(c){c=new j(c.target);y.inArray(c._4e_name(),["img","hr","input","textarea","select"])&&g.getSelection().selectElement(c)});q.gecko&&d.on(z,"dragstart",function(c){var i=new j(c.target);i._4e_name()==="img"&&/ke_/.test(i[0].className)&&c.preventDefault()});e.add(g)};document.documentMode>7&&function(){for(var a=y.all("link"),b=0;b<a.length;b++){var g=
new j(a[b]),n=g.attr("href");n.indexOf("editor-pkg-min-mhtml.css")!=-1&&g.attr("href",n.replace(/editor-pkg-min-mhtml\.css/g,"editor-pkg-min-datauri.css"))}}();p=l.prototype;C.extern(p,{setData:p.setData,getData:p.getData,insertElement:p.insertElement,insertHtml:p.insertHtml,ready:p.ready,addCustomStyle:p.addCustomStyle,addCommand:p.addCommand,hasCommand:p.hasCommand,execCommand:p.execCommand,useDialog:p.useDialog,addDialog:p.addDialog,getDialog:p.getDialog,getMode:p.getMode,sync:p.sync,getSelection:p.getSelection,
focus:p.focus,blur:p.blur,notifySelectionChange:p.notifySelectionChange})});KISSY.Editor.add("zindex",function(){var l=KISSY.Editor;if(!l.zIndexManager){l.zIndexManager={BUBBLE_VIEW:1100,POPUP_MENU:1200,DD_PG:99999,MAXIMIZE:900,OVERLAY:9999,LOADING:11E3,LOADING_CANCEL:12E3,SELECT:1200};l.baseZIndex=function(v){return(l.Config.baseZIndex||1E4)+v};l.baseZIndex=l.baseZIndex;l.zIndexManager=l.zIndexManager}});
KISSY.Editor.add("dtd",function(l){l.XHTML_DTD=function(){function v(w){for(var u=arguments.length-1;u>0;)KISSY.mix(w,arguments[u--]);return w}var D={isindex:1,fieldset:1},C={input:1,button:1,select:1,textarea:1,label:1},r=v({a:1},C),y=v({iframe:1},r),q={hr:1,ul:1,menu:1,div:1,blockquote:1,noscript:1,table:1,center:1,address:1,dir:1,pre:1,h5:1,dl:1,h4:1,noframes:1,h6:1,ol:1,h1:1,h3:1,h2:1},s={ins:1,del:1,script:1,style:1},j=v({b:1,acronym:1,bdo:1,"var":1,"#":1,abbr:1,code:1,br:1,i:1,cite:1,kbd:1,
u:1,strike:1,s:1,tt:1,strong:1,q:1,samp:1,em:1,dfn:1,span:1},s),d=v({sub:1,img:1,object:1,sup:1,basefont:1,map:1,applet:1,font:1,big:1,small:1},j),e=v({p:1},d);C=v({iframe:1},d,C);d={img:1,noscript:1,br:1,kbd:1,center:1,button:1,basefont:1,h5:1,h4:1,samp:1,h6:1,ol:1,h1:1,h3:1,h2:1,form:1,font:1,"#":1,select:1,menu:1,ins:1,abbr:1,label:1,code:1,table:1,script:1,cite:1,input:1,iframe:1,strong:1,textarea:1,noframes:1,big:1,small:1,span:1,hr:1,sub:1,bdo:1,"var":1,div:1,object:1,sup:1,strike:1,dir:1,map:1,
dl:1,applet:1,del:1,isindex:1,fieldset:1,ul:1,b:1,acronym:1,a:1,blockquote:1,i:1,u:1,s:1,tt:1,address:1,q:1,pre:1,p:1,em:1,dfn:1};var f=v({a:1},C),h={tr:1},p={"#":1},k=v({param:1},d),a=v({form:1},D,y,q,e),b={li:1},g={base:1,link:1,meta:1,title:1},n=v(g,{style:1,script:1}),z={head:1,body:1},A={address:1,blockquote:1,center:1,dir:1,div:1,dl:1,fieldset:1,form:1,h1:1,h2:1,h3:1,h4:1,h5:1,h6:1,hr:1,isindex:1,menu:1,noframes:1,ol:1,p:1,pre:1,table:1,ul:1};return{$nonBodyContent:v({html:1},z,g),$block:A,
$blockLimit:{body:1,div:1,td:1,th:1,caption:1,form:1},$inline:f,$body:v({script:1,style:1},A),$cdata:{script:1,style:1},$empty:{area:1,base:1,br:1,col:1,hr:1,img:1,input:1,link:1,meta:1,param:1},$listItem:{dd:1,dt:1,li:1},$list:{ul:1,ol:1,dl:1},$nonEditable:{applet:1,button:1,embed:1,iframe:1,map:1,object:1,option:1,script:1,textarea:1,param:1},$removeEmpty:{abbr:1,acronym:1,address:1,b:1,bdo:1,big:1,cite:1,code:1,del:1,dfn:1,em:1,font:1,i:1,ins:1,label:1,kbd:1,q:1,s:1,samp:1,small:1,span:1,strike:1,
strong:1,sub:1,sup:1,tt:1,u:1,"var":1},$tabIndex:{a:1,area:1,button:1,input:1,object:1,select:1,textarea:1},$tableContent:{caption:1,col:1,colgroup:1,tbody:1,td:1,tfoot:1,th:1,thead:1,tr:1},html:z,head:n,style:p,body:a,base:{},link:{},meta:{},title:p,col:{},tr:{td:1,th:1},img:{},colgroup:{col:1},noscript:a,td:a,br:{},th:a,center:a,kbd:f,button:v(e,q),basefont:{},h5:f,h4:f,samp:f,h6:f,ol:b,h1:f,h3:f,option:p,h2:f,form:v(D,y,q,e),select:{optgroup:1,option:1},font:f,ins:f,menu:b,abbr:f,label:f,table:{thead:1,
col:1,tbody:1,tr:1,colgroup:1,caption:1,tfoot:1},code:f,script:p,tfoot:h,cite:f,li:a,input:{},iframe:a,strong:f,textarea:p,noframes:a,big:f,small:f,span:f,hr:{},dt:f,sub:f,optgroup:{option:1},param:{},bdo:f,"var":f,div:a,object:k,sup:f,dd:a,strike:f,area:{},dir:b,map:v({area:1,form:1,p:1},D,s,q),applet:k,dl:{dt:1,dd:1},del:f,isindex:{},fieldset:v({legend:1},d),thead:h,ul:b,acronym:f,b:f,a:C,blockquote:a,caption:f,i:f,u:f,tbody:h,s:f,address:v(y,e),tt:f,legend:f,q:f,pre:v(j,r),p:f,em:f,dfn:f}}();l.XHTML_DTD=
l.XHTML_DTD});
KISSY.Editor.add("elementpath",function(l){function v(d){var e=y,f=y,h=[];for(d=d;d&&d[0];){if(d[0].nodeType==r.NODE_ELEMENT){if(!this.lastElement)this.lastElement=d;var p=d._4e_name();if(!f){if(!e&&q[p])e=d;if(s[p]){var k;if(k=!e){if(k=p=="div"){a:{k=d;k=k[0]||k;k=k.childNodes;for(var a=0,b=k.length;a<b;a++){var g=k[a];if(g.nodeType==r.NODE_ELEMENT&&C.$block[g.nodeName.toLowerCase()]){k=true;break a}}k=false}k=!k}k=k}if(k)e=d;else f=d}}h.push(d);if(p=="body")break}d=d.parent()}this.block=this.block=
e;this.blockLimit=this.blockLimit=f;this.elements=this.elements=h}var D=KISSY.DOM,C=l.XHTML_DTD,r=l.NODE,y=null,q={address:1,blockquote:1,dl:1,h1:1,h2:1,h3:1,h4:1,h5:1,h6:1,p:1,pre:1,li:1,dt:1,dd:1},s={body:1,div:1,table:1,tbody:1,tr:1,td:1,th:1,caption:1,form:1};v.prototype={compare:function(d){var e=this.elements;d=d&&d.elements;if(!d||e.length!=d.length)return false;for(var f=0;f<e.length;f++)if(!D._4e_equals(e[f],d[f]))return false;return true},contains:function(d){for(var e=this.elements,f=0;f<
e.length;f++)if(e[f]._4e_name()in d)return e[f];return y}};l.ElementPath=l.ElementPath=v;var j=v.prototype;l.Utils.extern(j,{compare:j.compare,contains:j.contains})});
KISSY.Editor.add("walker",function(l){function v(h,p){if(this._.end)return q;var k,a=this.range,b,g=this.guard,n=this.type,z=h?"_4e_previousSourceNode":"_4e_nextSourceNode";if(!this._.start){this._.start=1;a.trim();if(a.collapsed){this.end();return q}}if(!h&&!this._.guardLTR){var A=a.endContainer,w=new e(A[0].childNodes[a.endOffset]);this._.guardLTR=function(B,c){return(B=d._4e_wrap(B))&&B[0]&&(!c||!d._4e_equals(A,B))&&(!w[0]||!B._4e_equals(w))&&(B[0].nodeType!=j.NODE_ELEMENT||!c||B._4e_name()!="body")}}if(h&&
!this._.guardRTL){var u=a.startContainer,x=a.startOffset>0&&new e(u[0].childNodes[a.startOffset-1]);this._.guardRTL=function(B,c){return(B=d._4e_wrap(B))&&B[0]&&(!c||!B._4e_equals(u))&&(!x[0]||!B._4e_equals(x))&&(B[0].nodeType!=j.NODE_ELEMENT||!c||B._4e_name()!="body")}}var J=h?this._.guardRTL:this._.guardLTR;b=g?function(B,c){if(J(B,c)===y)return y;return g(B,c)}:J;if(this.current)k=this.current[z](y,n,b);else if(h){k=a.endContainer;if(a.endOffset>0){k=new e(k[0].childNodes[a.endOffset-1]);if(b(k)===
y)k=q}else k=b(k,r)===y?q:k._4e_previousSourceNode(r,n,b)}else{k=a.startContainer;if((k=new e(k[0].childNodes[a.startOffset]))&&k[0]){if(b(k)===y)k=q}else k=b(a.startContainer,r)===y?q:a.startContainer._4e_nextSourceNode(r,n,b)}for(;k&&k[0]&&!this._.end;){this.current=k;if(!this.evaluator||this.evaluator(k)!==y){if(!p)return k}else if(p&&this.evaluator)return y;k=k[z](y,n,b)}this.end();return this.current=q}function D(h){for(var p,k=q;p=v.call(this,h);)k=p;return k}function C(h){this.range=h;this._=
{}}var r=true,y=false,q=null,s=KISSY,j=l.NODE,d=s.DOM,e=s.Node;s.augment(C,{end:function(){this._.end=1},next:function(){return v.call(this)},previous:function(){return v.call(this,r)},checkForward:function(){return v.call(this,y,r)!==y},checkBackward:function(){return v.call(this,r,r)!==y},lastForward:function(){return D.call(this)},lastBackward:function(){return D.call(this,r)},reset:function(){delete this.current;this._={}}});C.blockBoundary=function(h){return function(p){p=d._4e_wrap(p);return!(p&&
p[0].nodeType==j.NODE_ELEMENT&&p._4e_isBlockBoundary(h))}};C.listItemBoundary=function(){return this.blockBoundary({br:1})};C.bookmark=function(h,p){function k(a){return a&&a[0]&&a._4e_name()=="span"&&a.attr("_ke_bookmark")}return function(a){var b,g;b=a&&a[0]&&a[0].nodeType==j.NODE_TEXT&&(g=a.parent())&&k(g);b=h?b:b||k(a);return p^b}};C.whitespaces=function(h){return function(p){p=(p=p[0]||p)&&p.nodeType==j.NODE_TEXT&&!s.trim(p.nodeValue);return h^p}};C.invisible=function(h){var p=C.whitespaces();
return function(k){k=p(k)||k[0].nodeType==j.NODE_ELEMENT&&!k[0].offsetHeight;return h^k}};l.Walker=C;l.Walker=C;var f=C.prototype;l.Utils.extern(f,{end:f.end,next:f.next,previous:f.previous,checkForward:f.checkForward,checkBackward:f.checkBackward,lastForward:f.lastForward,lastBackward:f.lastBackward,reset:f.reset});l.Utils.extern(C,{blockBoundary:C.blockBoundary,listItemBoundary:C.listItemBoundary,bookmark:C.bookmark,whitespaces:C.whitespaces,invisible:C.invisible})});
KISSY.Editor.add("range",function(l){function v(c){this.endOffset=this.endContainer=this.startOffset=this.startContainer=d;this.collapsed=s;this.document=c}function D(c){var i=c[0].nodeType!=f.NODE_TEXT&&c._4e_name()in n.$removeEmpty,o=!e.trim(c[0].nodeValue);c=!!c.parent().attr("_ke_bookmark");return i||o||c}function C(c){return!x(c)&&!J(c)}function r(c){var i=j,o=k.bookmark(s);return function(t){if(o(t))return s;if(t[0].nodeType==f.NODE_TEXT){if(e.trim(t[0].nodeValue).length)return j}else if(t[0].nodeType==
f.NODE_ELEMENT)if(!u[t._4e_name()])if(!c&&!g.ie&&t._4e_name()=="br"&&!i)i=s;else return j;return s}}function y(c,i){function o(t){return t&&t.nodeName=="span"&&t.getAttribute("_ke_bookmark")}return function(t){var m,E;m=t&&!t.nodeName&&(E=t.parentNode)&&o(E);m=c?m:m||o(t);return i^m}}function q(c){return function(i){i=(i=i[0]||i)&&i.nodeType==f.NODE_TEXT&&!e.trim(i.nodeValue);return c^i}}l.RANGE={POSITION_AFTER_START:1,POSITION_BEFORE_END:2,POSITION_BEFORE_START:3,POSITION_AFTER_END:4,ENLARGE_ELEMENT:1,
ENLARGE_BLOCK_CONTENTS:2,ENLARGE_LIST_ITEM_CONTENTS:3,START:1,END:2,STARTEND:3,SHRINK_ELEMENT:1,SHRINK_TEXT:2};l.RANGE=l.RANGE;var s=true,j=false,d=null,e=KISSY,f=l.NODE,h=l.RANGE,p=l.POSITION,k=l.Walker,a=e.DOM,b=l.Utils.getByAddress,g=e.UA,n=l.XHTML_DTD,z=l.ElementPath,A=e.Node,w={area:1,base:1,br:1,col:1,hr:1,img:1,input:1,link:1,meta:1,param:1};v.prototype.toString=function(){var c=[];c.push((this.startContainer[0].id||this.startContainer[0].nodeName)+":"+this.startOffset);c.push((this.endContainer[0].id||
this.endContainer[0].nodeName)+":"+this.endOffset);return c.join("<br/>")};e.augment(v,{updateCollapsed:function(){this.collapsed=this.startContainer&&this.endContainer&&a._4e_equals(this.startContainer,this.endContainer)&&this.startOffset==this.endOffset},optimize:function(){var c=this.startContainer,i=this.startOffset;if(c[0].nodeType!=f.NODE_ELEMENT)if(i)i>=c[0].nodeValue.length&&this.setStartAfter(c);else this.setStartBefore(c);c=this.endContainer;i=this.endOffset;if(c[0].nodeType!=f.NODE_ELEMENT)if(i)i>=
c[0].nodeValue.length&&this.setEndAfter(c);else this.setEndBefore(c)},setStartAfter:function(c){this.setStart(c.parent(),c._4e_index()+1)},setStartBefore:function(c){this.setStart(c.parent(),c._4e_index())},setEndAfter:function(c){this.setEnd(c.parent(),c._4e_index()+1)},setEndBefore:function(c){this.setEnd(c.parent(),c._4e_index())},optimizeBookmark:function(){var c=this.startContainer,i=this.endContainer;c&&c._4e_name()=="span"&&c.attr("_ke_bookmark")&&this.setStartAt(c,h.POSITION_BEFORE_START);
i&&i._4e_name()=="span"&&i.attr("_ke_bookmark")&&this.setEndAt(i,h.POSITION_AFTER_END)},setStart:function(c,i){if(c[0].nodeType==f.NODE_ELEMENT&&w[c._4e_name()]){c=c.parent();i=c._4e_index()}this.startContainer=c;this.startOffset=i;if(!this.endContainer){this.endContainer=c;this.endOffset=i}this.updateCollapsed()},setEnd:function(c,i){if(c[0].nodeType==f.NODE_ELEMENT&&w[c._4e_name()]){c=c.parent();i=c._4e_index()+1}this.endContainer=c;this.endOffset=i;if(!this.startContainer){this.startContainer=
c;this.startOffset=i}this.updateCollapsed()},setStartAt:function(c,i){switch(i){case h.POSITION_AFTER_START:this.setStart(c,0);break;case h.POSITION_BEFORE_END:c[0].nodeType==f.NODE_TEXT?this.setStart(c,c[0].nodeValue.length):this.setStart(c,c[0].childNodes.length);break;case h.POSITION_BEFORE_START:this.setStartBefore(c);break;case h.POSITION_AFTER_END:this.setStartAfter(c)}this.updateCollapsed()},setEndAt:function(c,i){switch(i){case h.POSITION_AFTER_START:this.setEnd(c,0);break;case h.POSITION_BEFORE_END:c[0].nodeType==
f.NODE_TEXT?this.setEnd(c,c[0].nodeValue.length):this.setEnd(c,c[0].childNodes.length);break;case h.POSITION_BEFORE_START:this.setEndBefore(c);break;case h.POSITION_AFTER_END:this.setEndAfter(c)}this.updateCollapsed()},execContentsAction:function(c,i){var o=this.startContainer,t=this.endContainer,m=this.startOffset,E=this.endOffset,P,O=this.document,Q;this.optimizeBookmark();if(t[0].nodeType==f.NODE_TEXT)t=t._4e_splitText(E);else if(t[0].childNodes.length>0)if(E>=t[0].childNodes.length){t=new A(t[0].appendChild(O.createTextNode("")));
Q=s}else t=new A(t[0].childNodes[E]);if(o[0].nodeType==f.NODE_TEXT){o._4e_splitText(m);if(o._4e_equals(t))t=new A(o[0].nextSibling)}else if(m)if(m>=o[0].childNodes.length){P=new A(O.createTextNode(""));o.append(P);o=P;P=s}else o=new A(o[0].childNodes[m].previousSibling);else{P=new A(O.createTextNode(""));o.prepend(P);o=P;P=s}m=o._4e_parents();E=t._4e_parents();var N,U,R;for(N=0;N<m.length;N++){U=m[N];R=E[N];if(!U._4e_equals(R))break}O=i;for(var V,Y,$,G=N;G<m.length;G++){V=m[G];Y=O&&!V._4e_equals(o)?
O.appendChild(V._4e_clone()[0]):null;for(V=V[0].nextSibling;V;){if(a._4e_equals(E[G],V)||a._4e_equals(t,V))break;$=V.nextSibling;if(c==2)O.appendChild(V.cloneNode(s));else{a._4e_remove(V);c==1&&O.appendChild(V)}V=$}if(Y)O=Y}O=i;for(N=N;N<E.length;N++){V=E[N];Y=O&&c>0&&!V._4e_equals(t)?O.appendChild(V._4e_clone()[0]):null;if(!m[N]||!V.parent()._4e_equals(m[N].parent()))for(V=V[0].previousSibling;V;){if(a._4e_equals(m[N],V)||a._4e_equals(o,V))break;$=V.previousSibling;if(c==2)O.insertBefore(V.cloneNode(s),
O.firstChild);else{a._4e_remove(V);c==1&&O.insertBefore(V,O.firstChild)}V=$}if(Y)O=Y}if(c==2){R=this.startContainer[0];if(R.nodeType==f.NODE_TEXT&&R.nextSibling&&R.nextSibling.nodeType==f.NODE_TEXT){R.data+=R.nextSibling.data;R.parentNode.removeChild(R.nextSibling)}R=this.endContainer[0];if(R.nodeType==f.NODE_TEXT&&R.nextSibling&&R.nextSibling.nodeType==f.NODE_TEXT){R.data+=R.nextSibling.data;R.parentNode.removeChild(R.nextSibling)}}else{if(U&&R&&(!o.parent()._4e_equals(U.parent())||!t.parent()._4e_equals(R.parent()))){U=
R._4e_index();P&&R.parent()._4e_equals(o.parent())&&U--;this.setStart(R.parent(),U)}this.collapse(s)}P&&o._4e_remove();Q&&t[0].parentNode&&t._4e_remove()},collapse:function(c){if(c){this.endContainer=this.startContainer;this.endOffset=this.startOffset}else{this.startContainer=this.endContainer;this.startOffset=this.endOffset}this.collapsed=s},clone:function(){var c=new v(this.document);c.startContainer=this.startContainer;c.startOffset=this.startOffset;c.endContainer=this.endContainer;c.endOffset=
this.endOffset;c.collapsed=this.collapsed;return c},getEnclosedNode:function(){var c=this.clone();c.optimize();if(c.startContainer[0].nodeType!=f.NODE_ELEMENT||c.endContainer[0].nodeType!=f.NODE_ELEMENT)return d;var i=new l.Walker(c),o=y(s,undefined),t=q(s);c.evaluator=function(m){return t(m)&&o(m)};c=i.next();i.reset();i=i.previous();return c&&c._4e_equals(i)?c:d},shrink:function(c,i){if(!this.collapsed){c=c||h.SHRINK_TEXT;var o=this.clone(),t=this.startContainer,m=this.endContainer,E=this.startOffset,
P=this.endOffset,O=1,Q=1;if(t&&t[0].nodeType==f.NODE_TEXT)if(E)if(E>=t[0].nodeValue.length)o.setStartAfter(t);else{o.setStartBefore(t);O=0}else o.setStartBefore(t);if(m&&m[0].nodeType==f.NODE_TEXT)if(P)if(P>=m[0].nodeValue.length)o.setEndAfter(m);else{o.setEndAfter(m);Q=0}else o.setEndBefore(m);o=new k(o);o.evaluator=function(U){U=U[0]||U;return U.nodeType==(c==h.SHRINK_ELEMENT?f.NODE_ELEMENT:f.NODE_TEXT)};var N;o.guard=function(U,R){U=U[0]||U;if(c==h.SHRINK_ELEMENT&&U.nodeType==f.NODE_TEXT)return j;
if(R&&U==N)return j;if(!R&&U.nodeType==f.NODE_ELEMENT)N=U;return s};if(O)(t=o[c==h.SHRINK_ELEMENT?"lastForward":"next"]())&&this.setStartAt(t,i?h.POSITION_AFTER_START:h.POSITION_BEFORE_START);if(Q){o.reset();(o=o[c==h.SHRINK_ELEMENT?"lastBackward":"previous"]())&&this.setEndAt(o,i?h.POSITION_BEFORE_END:h.POSITION_AFTER_END)}return!!(O||Q)}},getTouchedStartNode:function(){var c=this.startContainer;if(this.collapsed||c[0].nodeType!=f.NODE_ELEMENT)return c;return c.childNodes[this.startOffset]||c},createBookmark2:function(c){var i=
this.startContainer,o=this.endContainer,t=this.startOffset,m=this.endOffset,E,P;if(!i||!o)return{start:0,end:0};if(c){if(i[0].nodeType==f.NODE_ELEMENT)if((E=new A(i[0].childNodes[t]))&&E[0]&&E[0].nodeType==f.NODE_TEXT&&t>0&&E[0].previousSibling.nodeType==f.NODE_TEXT){i=E;t=0}for(;i[0].nodeType==f.NODE_TEXT&&(P=i._4e_previous())&&P[0].nodeType==f.NODE_TEXT;){i=P;t+=P[0].nodeValue.length}if(!this.collapsed){if(o[0].nodeType==f.NODE_ELEMENT)if((E=new A(o[0].childNodes[m]))&&E[0]&&E[0].nodeType==f.NODE_TEXT&&
m>0&&E[0].previousSibling.nodeType==f.NODE_TEXT){o=E;m=0}for(;o[0].nodeType==f.NODE_TEXT&&(P=o._4e_previous())&&P[0].nodeType==f.NODE_TEXT;){o=P;m+=P[0].nodeValue.length}}}return{start:i._4e_address(c),end:this.collapsed?d:o._4e_address(c),startOffset:t,endOffset:m,normalized:c,is2:s}},createBookmark:function(c){var i,o,t,m,E=this.collapsed;i=new A("<span>",d,this.document);i.attr("_ke_bookmark",1);i.css("display","none");i.html("&nbsp;");if(c){t=e.guid("ke_bm_");i.attr("id",t+"S")}if(!E){o=i._4e_clone();
o.html("&nbsp;");c&&o.attr("id",t+"E");m=this.clone();m.collapse();m.insertNode(o)}m=this.clone();m.collapse(s);m.insertNode(i);if(o){this.setStartAfter(i);this.setEndBefore(o)}else this.moveToPosition(i,h.POSITION_AFTER_END);return{startNode:c?t+"S":i,endNode:c?t+"E":o,serializable:c,collapsed:E}},moveToPosition:function(c,i){this.setStartAt(c,i);this.collapse(s)},trim:function(c,i){var o=this.startContainer,t=this.startOffset,m=this.collapsed;if((!c||m)&&o[0]&&o[0].nodeType==f.NODE_TEXT){if(t)if(t>=
o[0].nodeValue.length){t=o._4e_index()+1;o=o.parent()}else{var E=o._4e_splitText(t);t=o._4e_index()+1;o=o.parent();if(a._4e_equals(this.startContainer,this.endContainer))this.setEnd(E,this.endOffset-this.startOffset);else if(a._4e_equals(o,this.endContainer))this.endOffset+=1}else{t=o._4e_index();o=o.parent()}this.setStart(o,t);if(m){this.collapse(s);return}}o=this.endContainer;t=this.endOffset;if(!(i||m)&&o[0]&&o[0].nodeType==f.NODE_TEXT){if(t){t>=o.nodeValue.length||o._4e_splitText(t);t=o._4e_index()+
1}else t=o._4e_index();o=o.parent();this.setEnd(o,t)}},insertNode:function(c){this.optimizeBookmark();this.trim(j,s);var i=this.startContainer;i[0].insertBefore(c[0]||c,i[0].childNodes[this.startOffset]||null);a._4e_equals(c.parent(),this.endContainer)&&this.endOffset++;this.setStartBefore(c)},moveToBookmark:function(c){if(c.is2){var i=b(this.document,c.start,c.normalized),o=c.startOffset,t=c.end&&b(this.document,c.end,c.normalized);c=c.endOffset;this.setStart(i,o);t?this.setEnd(t,c):this.collapse(s)}else{i=
(o=c.serializable)?e.one("#"+c.startNode,this.document):c.startNode;c=o?e.one("#"+c.endNode,this.document):c.endNode;this.setStartBefore(i);i._4e_remove();if(c&&c[0]){this.setEndBefore(c);c._4e_remove()}else this.collapse(s)}},getCommonAncestor:function(c,i){var o=this.startContainer,t=this.endContainer;o=a._4e_equals(o,t)?c&&o[0].nodeType==f.NODE_ELEMENT&&this.startOffset==this.endOffset-1?new A(o[0].childNodes[this.startOffset]):o:o._4e_commonAncestor(t);return i&&o[0].nodeType==f.NODE_TEXT?o.parent():
o},enlarge:function(c){switch(c){case h.ENLARGE_ELEMENT:if(this.collapsed)break;c=this.getCommonAncestor();var i=new A(this.document.body),o,t,m,E,P,O=j,Q,N;Q=this.startContainer;N=this.startOffset;if(Q[0].nodeType==f.NODE_TEXT){if(N){Q=!e.trim(Q[0].nodeValue.substring(0,N)).length&&Q;O=!!Q}if(Q)if(!(E=Q[0].previousSibling))m=Q.parent()}else{if(N)E=Q[0].childNodes[N-1]||Q[0].lastChild;E||(m=Q)}for(;m||E;){if(m&&!E){if(!P&&a._4e_equals(m,c))P=s;if(!i.contains(m))break;if(!O||m.css("display")!="inline"){O=
j;if(P)o=m;else this.setStartBefore(m)}E=m[0].previousSibling}for(;E;){Q=j;if(E.nodeType==f.NODE_TEXT){N=E.nodeValue;if(/[^\s\ufeff]/.test(N))E=d;Q=/[\s\ufeff]$/.test(N)}else if(E.offsetWidth>0&&!E.getAttribute("_ke_bookmark"))if(O&&n.$removeEmpty[E.nodeName.toLowerCase()]){N=a.text(E);if(/[^\s\ufeff]/.test(N))E=d;else for(var U=E.all||E.getElementsByTagName("*"),R=0,V;V=U[R++];)if(!n.$removeEmpty[V.nodeName.toLowerCase()]){E=d;break}if(E)Q=!!N.length}else E=d;if(Q)if(O)if(P)o=m;else m&&this.setStartBefore(m);
else O=s;if(E){Q=E.previousSibling;if(!m&&!Q){m=new A(E);E=d;break}E=Q}else m=d}if(m)m=m.parent()}Q=this.endContainer;N=this.endOffset;m=E=d;P=O=j;if(Q[0].nodeType==f.NODE_TEXT){Q=!e.trim(Q[0].nodeValue.substring(N)).length&&Q;O=!(Q&&Q[0].nodeValue.length);if(Q)if(!(E=Q[0].nextSibling))m=Q.parent()}else(E=Q[0].childNodes[N])||(m=Q);for(;m||E;){if(m&&!E){if(!P&&a._4e_equals(m,c))P=s;if(!i.contains(m))break;if(!O||m.css("display")!="inline"){O=j;if(P)t=m;else m&&this.setEndAfter(m)}E=m[0].nextSibling}for(;E;){Q=
j;if(E.nodeType==f.NODE_TEXT){N=E.nodeValue;if(/[^\s\ufeff]/.test(N))E=d;Q=/^[\s\ufeff]/.test(N)}else if(E.offsetWidth>0&&!E.getAttribute("_ke_bookmark"))if(O&&n.$removeEmpty[E.nodeName.toLowerCase()]){N=a.text(E);if(/[^\s\ufeff]/.test(N))E=d;else{U=E.all||E.getElementsByTagName("*");for(R=0;V=U[R++];)if(!n.$removeEmpty[V.nodeName.toLowerCase()]){E=d;break}}if(E)Q=!!N.length}else E=d;if(Q)if(O)if(P)t=m;else this.setEndAfter(m);if(E){Q=E.nextSibling;if(!m&&!Q){m=new A(E);E=d;break}E=Q}else m=d}if(m)m=
m.parent()}if(o&&t){c=o.contains(t)?t:o;this.setStartBefore(c);this.setEndAfter(c)}break;case h.ENLARGE_BLOCK_CONTENTS:case h.ENLARGE_LIST_ITEM_CONTENTS:m=new v(this.document);i=new A(this.document.body);m.setStartAt(i,h.POSITION_AFTER_START);m.setEnd(this.startContainer,this.startOffset);m=new k(m);var Y,$,G=k.blockBoundary(c==h.ENLARGE_LIST_ITEM_CONTENTS?{br:1}:d),K=function(F){var I=G(F);I||(Y=F);return I};o=function(F){var I=K(F);if(!I&&F[0]&&F._4e_name()=="br")$=F;return I};m.guard=K;m=m.lastBackward();
Y=Y||i;this.setStartAt(Y,Y._4e_name()!="br"&&(!m&&this.checkStartOfBlock()||m&&Y.contains(m))?h.POSITION_AFTER_START:h.POSITION_AFTER_END);m=this.clone();m.collapse();m.setEndAt(i,h.POSITION_BEFORE_END);m=new k(m);m.guard=c==h.ENLARGE_LIST_ITEM_CONTENTS?o:K;Y=d;m=m.lastForward();Y=Y||i;this.setEndAt(Y,!m&&this.checkEndOfBlock()||m&&Y.contains(m)?h.POSITION_BEFORE_END:h.POSITION_BEFORE_START);$&&this.setEndAfter($)}},checkStartOfBlock:function(){var c=this.startContainer,i=this.startOffset;if(i&&c[0].nodeType==
f.NODE_TEXT)if(e.trim(c[0].nodeValue.substring(0,i)).length)return j;this.trim();c=new z(this.startContainer);i=this.clone();i.collapse(s);i.setStartAt(c.block||c.blockLimit,h.POSITION_AFTER_START);c=new k(i);c.evaluator=r(s);return c.checkBackward()},checkEndOfBlock:function(){var c=this.endContainer,i=this.endOffset;if(c[0].nodeType==f.NODE_TEXT)if(e.trim(c[0].nodeValue.substring(i)).length)return j;this.trim();c=new z(this.endContainer);i=this.clone();i.collapse(j);i.setEndAt(c.block||c.blockLimit,
h.POSITION_BEFORE_END);c=new k(i);c.evaluator=r(j);return c.checkForward()},deleteContents:function(){this.collapsed||this.execContentsAction(0)},extractContents:function(){var c=this.document.createDocumentFragment();this.collapsed||this.execContentsAction(1,c);return c},checkBoundaryOfElement:function(c,i){var o=this.clone();o[i==h.START?"setStartAt":"setEndAt"](c,i==h.START?h.POSITION_AFTER_START:h.POSITION_BEFORE_END);o=new k(o);o.evaluator=D;return o[i==h.START?"checkBackward":"checkForward"]()},
getBoundaryNodes:function(){var c=this.startContainer,i=this.endContainer,o=this.startOffset,t=this.endOffset,m;if(c[0].nodeType==f.NODE_ELEMENT){m=c[0].childNodes.length;if(m>o)c=new A(c[0].childNodes[o]);else if(m<1)c=c._4e_previousSourceNode();else{for(c=c[0];c.lastChild;)c=c.lastChild;c=new A(c);c=c._4e_nextSourceNode()||c}}if(i[0].nodeType==f.NODE_ELEMENT){m=i[0].childNodes.length;if(m>t)i=(new A(i[0].childNodes[t]))._4e_previousSourceNode(s);else if(m<1)i=i._4e_previousSourceNode();else{for(i=
i[0];i.lastChild;)i=i.lastChild;i=new A(i)}}if(c._4e_position(i)&p.POSITION_FOLLOWING)c=i;return{startNode:c,endNode:i}},fixBlock:function(c,i){var o=this.createBookmark(),t=new A(this.document.createElement(i));this.collapse(c);this.enlarge(h.ENLARGE_BLOCK_CONTENTS);t[0].appendChild(this.extractContents());t._4e_trim();g.ie||t._4e_appendBogus();for(var m=t[0].childNodes,E=0;E<m.length;E++){var P=m[E];P.nodeType==8&&this.insertNode(new A(P))}this.insertNode(t);this.moveToBookmark(o);return t},splitBlock:function(c){var i=
new z(this.startContainer),o=new z(this.endContainer),t=i.block,m=o.block,E=d;if(!i.blockLimit._4e_equals(o.blockLimit))return d;if(c!="br"){if(!t){t=this.fixBlock(s,c);m=(new z(this.endContainer)).block}m||(m=this.fixBlock(j,c))}c=t&&this.checkStartOfBlock();i=m&&this.checkEndOfBlock();this.deleteContents();if(t&&a._4e_equals(t,m))if(i){E=new z(this.startContainer);this.moveToPosition(m,h.POSITION_AFTER_END);m=d}else if(c){E=new z(this.startContainer);this.moveToPosition(t,h.POSITION_BEFORE_START);
t=d}else{m=this.splitElement(t);!g.ie&&!e.inArray(t._4e_name(),["ul","ol"])&&t._4e_appendBogus()}return{previousBlock:t,nextBlock:m,wasStartOfBlock:c,wasEndOfBlock:i,elementPath:E}},splitElement:function(c){if(!this.collapsed)return d;this.setEndAt(c,h.POSITION_BEFORE_END);var i=this.extractContents(),o=c._4e_clone(j);o[0].appendChild(i);o.insertAfter(c);this.moveToPosition(c,h.POSITION_AFTER_END);return o},moveToElementEditablePosition:function(c,i){var o,t=l.XHTML_DTD;if(t.$empty[c._4e_name()])return j;
for(;c&&c[0].nodeType==f.NODE_ELEMENT;){if(o=c._4e_isEditable())this.moveToPosition(c,i?h.POSITION_BEFORE_END:h.POSITION_AFTER_START);else if(t.$inline[c._4e_name()]){this.moveToPosition(c,i?h.POSITION_AFTER_END:h.POSITION_BEFORE_START);return s}if((c=t.$empty[c._4e_name()]?c[i?"_4e_previous":"_4e_next"](C):c[i?"_4e_last":"_4e_first"](C))&&c[0].nodeType==f.NODE_TEXT){this.moveToPosition(c,i?h.POSITION_AFTER_END:h.POSITION_BEFORE_START);return s}}return o},selectNodeContents:function(c){this.setStart(c,
0);this.setEnd(c,c[0].nodeType==f.NODE_TEXT?c[0].nodeValue.length:c[0].childNodes.length)}});var u={abbr:1,acronym:1,b:1,bdo:1,big:1,cite:1,code:1,del:1,dfn:1,em:1,font:1,i:1,ins:1,label:1,kbd:1,q:1,samp:1,small:1,span:1,strike:1,strong:1,sub:1,sup:1,tt:1,u:1,"var":1},x=new k.whitespaces,J=new k.bookmark;l.Range=v;l.Range=v;var B=v.prototype;l.Utils.extern(B,{updateCollapsed:B.updateCollapsed,optimize:B.optimize,setStartAfter:B.setStartAfter,setEndAfter:B.setEndAfter,setStartBefore:B.setStartBefore,
setEndBefore:B.setEndBefore,optimizeBookmark:B.optimizeBookmark,setStart:B.setStart,setEnd:B.setEnd,setStartAt:B.setStartAt,setEndAt:B.setEndAt,execContentsAction:B.execContentsAction,collapse:B.collapse,clone:B.clone,getEnclosedNode:B.getEnclosedNode,shrink:B.shrink,getTouchedStartNode:B.getTouchedStartNode,createBookmark2:B.createBookmark2,createBookmark:B.createBookmark,moveToPosition:B.moveToPosition,trim:B.trim,insertNode:B.insertNode,moveToBookmark:B.moveToBookmark,getCommonAncestor:B.getCommonAncestor,
enlarge:B.enlarge,checkStartOfBlock:B.checkStartOfBlock,checkEndOfBlock:B.checkEndOfBlock,deleteContents:B.deleteContents,extractContents:B.extractContents,checkBoundaryOfElement:B.checkBoundaryOfElement,getBoundaryNodes:B.getBoundaryNodes,fixBlock:B.fixBlock,splitBlock:B.splitBlock,splitElement:B.splitElement,moveToElementEditablePosition:B.moveToElementEditablePosition,selectNodeContents:B.selectNodeContents})});
KISSY.Editor.add("domiterator",function(l){function v(k){if(!(arguments.length<1)){this.range=k;this.forceBrBreak=C;this.enlargeBr=D;this.enforceRealBlocks=C;this._||(this._={})}}var D=true,C=false,r=KISSY,y=r.UA,q=l.Walker,s=l.Range,j=l.RANGE,d=l.NODE,e=l.ElementPath,f=r.Node,h=r.DOM,p=/^[\r\n\t ]*$/;r.augment(v,{getNextParagraph:function(k){var a,b,g,n,z;if(!this._.lastNode){b=this.range.clone();b.shrink(j.SHRINK_ELEMENT,D);b.enlarge(this.forceBrBreak||!this.enlargeBr?j.ENLARGE_LIST_ITEM_CONTENTS:
j.ENLARGE_BLOCK_CONTENTS);var A=new q(b),w=q.bookmark(D,D);A.evaluator=w;this._.nextNode=A.next();A=new q(b);A.evaluator=w;A=A.previous();this._.lastNode=A._4e_nextSourceNode(D);if(this._.lastNode&&this._.lastNode[0].nodeType==d.NODE_TEXT&&!r.trim(this._.lastNode[0].nodeValue)&&this._.lastNode.parent()._4e_isBlockBoundary()){w=new s(b.document);w.moveToPosition(this._.lastNode,j.POSITION_AFTER_END);if(w.checkEndOfBlock()){w=new e(w.endContainer);this._.lastNode=(w.block||w.blockLimit)._4e_nextSourceNode(D)}}if(!this._.lastNode){this._.lastNode=
this._.docEndMarker=new f(b.document.createTextNode(""));h.insertAfter(this._.lastNode[0],A[0])}b=null}w=this._.nextNode;A=this._.lastNode;for(this._.nextNode=null;w;){var u=C,x=w[0].nodeType!=d.NODE_ELEMENT,J=C;if(x){if(w[0].nodeType==d.NODE_TEXT)if(p.test(w[0].nodeValue))x=C}else{var B=w._4e_name();if(w._4e_isBlockBoundary(this.forceBrBreak&&{br:1})){if(B=="br")x=D;else if(!b&&!w[0].childNodes.length&&B!="hr"){a=w;g=w._4e_equals(A);break}if(b){b.setEndAt(w,j.POSITION_BEFORE_START);if(B!="br")this._.nextNode=
w}u=D}else{if(w[0].firstChild){if(!b){b=new s(this.range.document);b.setStartAt(w,j.POSITION_BEFORE_START)}w=new f(w[0].firstChild);continue}x=D}}if(x&&!b){b=new s(this.range.document);b.setStartAt(w,j.POSITION_BEFORE_START)}g=(!u||x)&&w._4e_equals(A);if(b&&!u)for(;!w[0].nextSibling&&!g;){B=w.parent();if(B._4e_isBlockBoundary(this.forceBrBreak&&{br:1})){u=D;g||B._4e_equals(A);break}w=B;x=D;g=w._4e_equals(A);J=D}x&&b.setEndAt(w,j.POSITION_AFTER_END);w=w._4e_nextSourceNode(J,null,A);if((g=!w)||u&&b)break}if(!a){if(!b){this._.docEndMarker&&
this._.docEndMarker._4e_remove();return this._.nextNode=null}a=new e(b.startContainer);w=a.blockLimit;u={div:1,th:1,td:1};a=a.block;if((!a||!a[0])&&!this.enforceRealBlocks&&u[w._4e_name()]&&b.checkStartOfBlock()&&b.checkEndOfBlock())a=w;else if(!a||this.enforceRealBlocks&&a._4e_name()=="li"){a=new f(this.range.document.createElement(k||"p"));a[0].appendChild(b.extractContents());a._4e_trim();b.insertNode(a);n=z=D}else if(a._4e_name()!="li"){if(!b.checkStartOfBlock()||!b.checkEndOfBlock()){a=a._4e_clone(C);
a[0].appendChild(b.extractContents());a._4e_trim();z=b.splitBlock();n=!z.wasStartOfBlock;z=!z.wasEndOfBlock;b.insertNode(a)}}else if(!g)this._.nextNode=a._4e_equals(A)?null:b.getBoundaryNodes().endNode._4e_nextSourceNode(D,null,A)}if(n){b=new f(a[0].previousSibling);if(b[0]&&b[0].nodeType==d.NODE_ELEMENT)if(b._4e_name()=="br")b._4e_remove();else b[0].lastChild&&h._4e_name(b[0].lastChild)=="br"&&h._4e_remove(b[0].lastChild)}if(z){b=q.bookmark(C,D);n=new f(a[0].lastChild);if(n[0]&&n[0].nodeType==d.NODE_ELEMENT&&
n._4e_name()=="br")if(y.ie||n._4e_previous(b)||n._4e_next(b))n._4e_remove()}if(!this._.nextNode)this._.nextNode=g||a._4e_equals(A)?null:a._4e_nextSourceNode(D,null,A);return a}});s.prototype.createIterator=function(){return new v(this)}});
KISSY.Editor.add("selection",function(l){function v(u){this.document=this.document=u;this._={cache:{}};if(a){var x=this.getNative().createRange();if(!x||x.item&&x.item(0).ownerDocument!=u||x.parentElement&&x.parentElement().ownerDocument!=u)this.isInvalid=r}}function D(u){u=new v(u);return!u||u.isInvalid?q:u}function C(u){var x=u.document,J=new f(x.body),B=new f(x.documentElement);if(j.ie){j.ieEngine<8&&B.on("click",function(N){(new f(N.target))._4e_name()==="html"&&u.getSelection().getNative().createRange().select()});
var c,i,o=1;B.on("mousedown",function(){o=0});B.on("mouseup",function(){o=1});J.on("focusin",function(N){if((new f(N.target))._4e_name()=="body")if(c){try{o&&c.select()}catch(U){}c=q}});J.on("focus",function(){i=r;m()});J.on("beforedeactivate",function(N){if(!N.relatedTarget){t();o=1}});u.on("blur",function(){try{var N=document.documentElement||document.body,U=N.scrollTop,R=N.scrollLeft;x&&x.selection.empty();N.scrollTop=U;N.scrollLeft=R}catch(V){}});J.on("mousedown",function(){t()});J.on("mouseup",
function(){i=r;setTimeout(function(){m(r)},0)});var t=function(){i=y},m=function(N){if(i){var U=u.document,R=u.getSelection(),V=R&&R.getType(),Y=R&&U.selection;if(N&&Y&&V==h.SELECTION_NONE)if(!U.queryCommandEnabled("InsertImage")){setTimeout(function(){m(r)},50);return}var $;if(!(Y&&V==h.SELECTION_TEXT&&($=d._4e_name(R.getStartElement()))&&$ in{input:1,textarea:1})){c=Y&&Y.createRange();u._monitor()}}};J.on("keydown",t);J.on("keyup",function(){i=r;m()});e.on(x,"selectionchange",m)}else{e.on(x,"mouseup",
u._monitor,u);e.on(x,"keyup",u._monitor,u)}var E={table:1,pre:1},P=/\s*<(p|div|address|h\d|center)[^>]*>\s*(?:<br[^>]*>|&nbsp;|\u00A0|&#160;|(<!--[\s\S]*?--\>))?\s*(:?<\/\1>)?(?=\s*$|<\/body>)/gi,O=l.Walker.whitespaces(r),Q=function(N){return O(N)&&N&&N[0].nodeType!=8};u.on("selectionChange",function(N){var U=N.path;N=(N=N.selection)&&N.getRanges()[0];if(!(!N||!N.collapsed||U.block))if(U.blockLimit._4e_name()=="body")if(U=N.fixBlock(r,"p")){if(U._4e_outerHtml().match(P)){var R=U._4e_next(Q);if(R&&
R[0].nodeType==k.NODE_ELEMENT&&!E[R._4e_name()]){N.moveToElementEditablePosition(R);U._4e_remove()}else if((R=U._4e_previous(Q))&&R[0].nodeType==k.NODE_ELEMENT&&!E[R._4e_name()]){N.moveToElementEditablePosition(R,R._4e_outerHtml().match(P)?y:r);U._4e_remove()}}N.select();a||u.notifySelectionChange()}})}l.SELECTION={SELECTION_NONE:1,SELECTION_TEXT:2,SELECTION_ELEMENT:3};var r=true,y=false,q=null,s=KISSY,j=s.UA,d=s.DOM,e=s.Event,f=s.Node,h=l.SELECTION,p=l.RANGE,k=l.NODE,a=!window.getSelection,b=l.Walker,
g=l.Range,n={img:1,hr:1,li:1,table:1,tr:1,td:1,th:1,embed:1,object:1,ol:1,ul:1,a:1,input:1,form:1,select:1,textarea:1,button:1,fieldset:1,thead:1,tfoot:1};s.augment(v,{getNative:!a?function(){var u=this._.cache;return u.nativeSel||(u.nativeSel=d._4e_getWin(this.document).getSelection())}:function(){var u=this._.cache;return u.nativeSel||(u.nativeSel=this.document.selection)},getType:!a?function(){var u=this._.cache;if(u.type)return u.type;var x=h.SELECTION_TEXT,J=this.getNative();if(J){if(J.rangeCount==
1){J=J.getRangeAt(0);var B=J.startContainer;if(B==J.endContainer&&B.nodeType==k.NODE_ELEMENT&&J.endOffset-J.startOffset===1&&n[B.childNodes[J.startOffset].nodeName.toLowerCase()])x=h.SELECTION_ELEMENT}}else x=h.SELECTION_NONE;return u.type=x}:function(){var u=this._.cache;if(u.type)return u.type;var x=h.SELECTION_NONE;try{var J=this.getNative(),B=J.type;if(B=="Text")x=h.SELECTION_TEXT;if(B=="Control")x=h.SELECTION_ELEMENT;if(J.createRange().parentElement)x=h.SELECTION_TEXT}catch(c){}return u.type=
x},getRanges:a?function(){var u=function(x,J){x=x.duplicate();x.collapse(J);for(var B=x.parentElement(),c=B.childNodes,i,o=0;o<c.length;o++){var t=c[o];if(t.nodeType==k.NODE_ELEMENT){i=x.duplicate();i.moveToElementText(t);t=i.compareEndPoints("StartToStart",x);var m=i.compareEndPoints("EndToStart",x);i.collapse();if(t>0)break;else if(!t||m==1&&t==-1)return{container:B,offset:o};else if(!m)return{container:B,offset:o+1};i=q}}if(!i){i=x.duplicate();i.moveToElementText(B);i.collapse(y)}i.setEndPoint("StartToStart",
x);i=String(i.text).replace(/\r\n|\r/g,"\n").length;try{for(;i>0;)i-=c[--o].nodeValue.length}catch(E){i=0}return i===0?{container:B,offset:o}:{container:c[o],offset:-i}};return function(){var x=this._.cache;if(x.ranges)return x.ranges;var J=this.getNative(),B=J&&J.createRange(),c=this.getType();if(!J)return[];if(c==h.SELECTION_TEXT){J=new g(this.document);c=u(B,r);J.setStart(new f(c.container),c.offset);c=u(B);J.setEnd(new f(c.container),c.offset);return x.ranges=[J]}else if(c==h.SELECTION_ELEMENT){x=
x.ranges=[];for(c=0;c<B.length;c++){var i=B.item(c),o=i.parentNode,t=0;for(J=new g(this.document);t<o.childNodes.length&&o.childNodes[t]!=i;t++);J.setStart(new f(o),t);J.setEnd(new f(o),t+1);x.push(J)}return x}return x.ranges=[]}}():function(){var u=this._.cache;if(u.ranges)return u.ranges;var x=[],J=this.getNative();if(!J)return[];for(var B=0;B<J.rangeCount;B++){var c=J.getRangeAt(B),i=new g(this.document);i.setStart(new f(c.startContainer),c.startOffset);i.setEnd(new f(c.endContainer),c.endOffset);
x.push(i)}return u.ranges=x},getStartElement:function(){var u=this._.cache;if(u.startElement!==undefined)return u.startElement;var x,J=this.getNative();switch(this.getType()){case h.SELECTION_ELEMENT:return this.getSelectedElement();case h.SELECTION_TEXT:var B=this.getRanges()[0];if(B)if(!B.collapsed){for(B.optimize();r;){x=B.startContainer;if(B.startOffset==(x[0].nodeType===k.NODE_ELEMENT?x[0].childNodes.length:x[0].nodeValue.length)&&!x._4e_isBlockBoundary())B.setStartAfter(x);else break}x=B.startContainer;
if(x[0].nodeType!=k.NODE_ELEMENT)return x.parent();x=new f(x[0].childNodes[B.startOffset]);if(!x[0]||x[0].nodeType!=k.NODE_ELEMENT)return B.startContainer;for(B=x[0].firstChild;B&&B.nodeType==k.NODE_ELEMENT;){x=new f(B);B=B.firstChild}return x}if(a){B=J.createRange();B.collapse(r);x=B.parentElement()}else if((x=J.anchorNode)&&x.nodeType!=k.NODE_ELEMENT)x=x.parentNode}return u.startElement=x?d._4e_wrap(x):q},getSelectedElement:function(){var u=this,x,J=u._.cache;if(J.selectedElement!==undefined)return J.selectedElement;
if(a){x=u.getNative().createRange();x=x.item&&x.item(0)}x||(x=function(){for(var B=u.getRanges()[0],c,i,o=2;o&&!((c=B.getEnclosedNode())&&c[0].nodeType==k.NODE_ELEMENT&&n[c._4e_name()]&&(i=c));o--)B.shrink(p.SHRINK_ELEMENT);return i&&i[0]}());return J.selectedElement=d._4e_wrap(x)},reset:function(){this._.cache={}},selectElement:function(u){var x,J=this.document;if(a)try{x=J.body.createControlRange();x.addElement(u[0]);x.select()}catch(B){x=J.body.createTextRange();x.moveToElementText(u[0]);x.select()}finally{}else{x=
J.createRange();x.selectNode(u[0]);u=this.getNative();u.removeAllRanges();u.addRange(x)}this.reset()},selectRanges:function(u){if(a){if(u.length>1){var x=u[u.length-1];u[0].setEnd(x.endContainer,x.endOffset);u.length=1}u[0]&&u[0].select()}else{x=this.getNative();if(!x)return;x.removeAllRanges();for(var J=0;J<u.length;J++){var B=u[J],c=this.document.createRange(),i=B.startContainer;B.collapsed&&j.gecko&&j.gecko<1.09&&i[0].nodeType==k.NODE_ELEMENT&&!i[0].childNodes.length&&i[0].appendChild(this.document.createTextNode(""));
c.setStart(i[0],B.startOffset);c.setEnd(B.endContainer[0],B.endOffset);x.addRange(c)}}this.reset()},createBookmarks2:function(u){for(var x=[],J=this.getRanges(),B=0;B<J.length;B++)x.push(J[B].createBookmark2(u));return x},createBookmarks:function(u,x){var J=[],B=this.document,c;x=x||this.getRanges();for(var i=x.length,o=0;o<i;o++){J.push(c=x[o].createBookmark(u,r));var t=(u=c.serializable)?s.one("#"+c.startNode,B):c.startNode;c=u?s.one("#"+c.endNode,B):c.endNode;for(var m=o+1;m<i;m++){var E=x[m],
P=E.startContainer,O=E.endContainer;d._4e_equals(P,t.parent())&&E.startOffset++;d._4e_equals(P,c.parent())&&E.startOffset++;d._4e_equals(O,t.parent())&&E.endOffset++;d._4e_equals(O,c.parent())&&E.endOffset++}}return J},selectBookmarks:function(u){for(var x=[],J=0;J<u.length;J++){var B=new g(this.document);B.moveToBookmark(u[J]);x.push(B)}this.selectRanges(x);return this},getCommonAncestor:function(){var u=this.getRanges();return u[0].startContainer._4e_commonAncestor(u[u.length-1].endContainer)},
scrollIntoView:function(){var u=this.getStartElement();u&&u._4e_scrollIntoView()},removeAllRanges:function(){var u=this.getNative();if(a)u&&u.clear();else u&&u.removeAllRanges()}});var z={table:1,tbody:1,tr:1},A=b.whitespaces(r),w=/\ufeff|\u00a0/;g.prototype.select=g.prototype.select=!a?function(){var u=this.startContainer;this.collapsed&&u[0].nodeType==k.NODE_ELEMENT&&!u[0].childNodes.length&&u[0].appendChild(this.document.createTextNode(""));var x=this.document.createRange();x.setStart(u[0],this.startOffset);
try{x.setEnd(this.endContainer[0],this.endOffset)}catch(J){if(J.toString().indexOf("NS_ERROR_ILLEGAL_VALUE")>=0){this.collapse(r);x.setEnd(this.endContainer[0],this.endOffset)}else throw J;}u=D(this.document).getNative();u.removeAllRanges();u.addRange(x)}:function(u){var x=this.collapsed,J,B;if(this.startContainer[0]===this.endContainer[0]&&this.endOffset-this.startOffset==1){var c=this.startContainer[0].childNodes[this.startOffset];if(c.nodeType==k.NODE_ELEMENT){(new v(this.document)).selectElement(new f(c));
return}}if(this.startContainer[0].nodeType==k.NODE_ELEMENT&&this.startContainer._4e_name()in z||this.endContainer[0].nodeType==k.NODE_ELEMENT&&this.endContainer._4e_name()in z)this.shrink(p.SHRINK_ELEMENT,r);var i=this.createBookmark();c=i.startNode;var o;if(!x)o=i.endNode;i=this.document.body.createTextRange();i.moveToElementText(c[0]);i.moveStart("character",1);if(o){u=this.document.body.createTextRange();u.moveToElementText(o[0]);i.setEndPoint("EndToEnd",u);i.moveEnd("character",-1)}else{for(J=
c[0].nextSibling;J&&!A(J);)J=J.nextSibling;J=!(J&&J.nodeValue&&J.nodeValue.match(w))&&(u||!c[0].previousSibling||c[0].previousSibling&&d._4e_name(c[0].previousSibling)=="br");B=new f(this.document.createElement("span"));B.html("&#65279;");B.insertBefore(c);J&&d.insertBefore(this.document.createTextNode("\ufeff"),c)}this.setStartBefore(c);c._4e_remove();if(x){if(J){i.moveStart("character",-1);i.select();this.document.selection.clear()}else i.select();if(B){this.moveToPosition(B,p.POSITION_BEFORE_START);
B._4e_remove()}}else{this.setEndBefore(o);o._4e_remove();i.select()}};v.getSelection=D;l.Selection=v;l.Selection=v;b=v.prototype;l.Utils.extern(b,{getNative:b.getNative,getType:b.getType,getRanges:b.getRanges,getStartElement:b.getStartElement,getSelectedElement:b.getSelectedElement,reset:b.reset,selectElement:b.selectElement,selectRanges:b.selectRanges,createBookmarks2:b.createBookmarks2,createBookmarks:b.createBookmarks,getCommonAncestor:b.getCommonAncestor,scrollIntoView:b.scrollIntoView,selectBookmarks:b.selectBookmarks,
removeAllRanges:b.removeAllRanges});l.on("instanceCreated",function(u){C(u.editor)})});
KISSY.Editor.add("styles",function(l){function v(G){return!G.attr("_ke_bookmark")}function D(G,K){for(var F in G)if(G.hasOwnProperty(F))if(J.isString(G[F]))G[F]=G[F].replace(Y,function(I,H){return K[H]});else D(G[F],K)}function C(G,K){if(K){G=J.clone(G);D(G,K)}var F=this.element=this.element=(G.element||"*").toLowerCase();this.type=this.type=F=="#"||U[F]?i.STYLE_BLOCK:R[F]?i.STYLE_OBJECT:i.STYLE_INLINE;this._={definition:G}}function r(G,K){var F=K?this.removeFromRange:this.applyToRange;G.body.focus();
for(var I=new t(G),H=I.getRanges(),M=0;M<H.length;M++)F.call(this,H[M]);I.selectRanges(H)}function y(G,K,F){var I=G.element;if(I=="*")I="span";K=new O(K.createElement(I));F&&F._4e_copyAttributes(K);return q(K,G)}function q(G,K){var F=K._.definition,I=F.attributes;F=C.getStyleText(F);if(I)for(var H in I)G.attr(H,I[H]);if(F)G[0].style.cssText=F;return G}function s(G){var K=G.createBookmark(w),F=G.createIterator();F.enforceRealBlocks=w;F.enlargeBr=w;for(var I,H=G.document;I=F.getNextParagraph();){var M=
y(this,H,I);I=I;var L=M;M=L._4e_name=="pre";var S=I._4e_name=="pre",T=!M&&S;if(M&&!S){S=I;L=L;T=S.html();T=j(T,/(?:^[ \t\n\r]+)|(?:[ \t\n\r]+$)/g,"");T=T.replace(/[ \t\r\n]*(<br[^>]*>)[ \t\r\n]*/gi,"$1");T=T.replace(/([ \t\n\r]+|&nbsp;)/g," ");T=T.replace(/<br\b[^>]*>/gi,"\n");if(Q.ie){S=S[0].ownerDocument.createElement("div");S.appendChild(L[0]);L[0].outerHTML="<pre>"+T+"</pre>";L=new O(S.firstChild);L._4e_remove()}else L.html(T);L=L}else if(T)L=e(d(I),L);else I._4e_moveChildren(L);I[0].parentNode.replaceChild(L[0],
I[0]);if(M){I=L;M=void 0;if((M=I._4e_previousSourceNode(w,m.NODE_ELEMENT))&&M._4e_name()=="pre"){L=j(M.html(),/\n$/,"")+"\n\n"+j(I.html(),/^\n/,"");if(Q.ie)I[0].outerHTML="<pre>"+L+"</pre>";else I.html(L);M._4e_remove()}}}G.moveToBookmark(K)}function j(G,K,F){var I="",H="";G=G.replace(/(^<span[^>]+_ke_bookmark.*?\/span>)|(<span[^>]+_ke_bookmark.*?\/span>$)/gi,function(M,L,S){L&&(I=L);S&&(H=S);return""});return I+G.replace(K,F)+H}function d(G){var K=[];j(G._4e_outerHtml(),/(\S\s*)\n(?:\s|(<span[^>]+_ck_bookmark.*?\/span>))*\n(?!$)/gi,
function(F,I,H){return I+"</pre>"+H+"<pre>"}).replace(/<pre\b.*?>([\s\S]*?)<\/pre>/gi,function(F,I){K.push(I)});return K}function e(G,K){for(var F=K[0].ownerDocument.createDocumentFragment(),I=0;I<G.length;I++){var H=G[I];H=H.replace(/(\r\n|\r)/g,"\n");H=j(H,/^[ \t]*\n/,"");H=j(H,/\n$/,"");H=j(H,/^[ \t]+|[ \t]+$/g,function(L,S){return L.length==1?"&nbsp;":S?" "+Array(L.length).join("&nbsp;"):Array(L.length).join("&nbsp;")+" "});H=H.replace(/\n/g,"<br>");H=H.replace(/[ \t]{2,}/g,function(L){return Array(L.length).join("&nbsp;")+
" "});var M=K._4e_clone();M.html(H);F.appendChild(M[0])}return F}function f(G){var K=G.document;if(G.collapsed){K=y(this,K,undefined);G.insertNode(K);G.moveToPosition(K,o.POSITION_BEFORE_END)}else{var F=this.element,I=this._.definition,H,M=l.XHTML_DTD[F]||(H=w,l.XHTML_DTD.span),L=G.createBookmark();G.enlarge(o.ENLARGE_ELEMENT);G.trim();var S=G.createBookmark(),T=S.startNode;S=S.endNode;for(var X=T,aa;X&&X[0];){var W=u;if(c._4e_equals(X,S)){X=x;W=w}else{var Z=X[0].nodeType,ca=Z==m.NODE_ELEMENT?X._4e_name():
x;if(ca&&X.attr("_ke_bookmark")){X=X._4e_nextSourceNode(w);continue}if(!ca||M[ca]&&(X._4e_position(S)|E.POSITION_PRECEDING|E.POSITION_IDENTICAL|E.POSITION_IS_CONTAINED)==E.POSITION_PRECEDING+E.POSITION_IDENTICAL+E.POSITION_IS_CONTAINED&&(!I.childRule||I.childRule(X))){var ea=X.parent();if(ea&&ea[0]&&((l.XHTML_DTD[ea._4e_name()]||l.XHTML_DTD.span)[F]||H)&&(!I.parentRule||I.parentRule(ea))){if(!aa&&(!ca||!l.XHTML_DTD.$removeEmpty[ca]||(X._4e_position(S)|E.POSITION_PRECEDING|E.POSITION_IDENTICAL|E.POSITION_IS_CONTAINED)==
E.POSITION_PRECEDING+E.POSITION_IDENTICAL+E.POSITION_IS_CONTAINED)){aa=new P(K);aa.setStartBefore(X)}if(Z==m.NODE_TEXT||Z==m.NODE_ELEMENT&&!X[0].childNodes.length){Z=X;for(var da;(W=!Z._4e_next(v))&&(da=Z.parent(),M[da._4e_name()])&&(da._4e_position(T)|E.POSITION_FOLLOWING|E.POSITION_IDENTICAL|E.POSITION_IS_CONTAINED)==E.POSITION_FOLLOWING+E.POSITION_IDENTICAL+E.POSITION_IS_CONTAINED&&(!I.childRule||I.childRule(da));)Z=da;aa.setEndAfter(Z)}}else W=w}else W=w;X=X._4e_nextSourceNode()}if(W&&aa&&!aa.collapsed){W=
y(this,K,undefined);Z=aa.getCommonAncestor();ca={styles:{},attrs:{},blockedStyles:{},blockedAttrs:{}};for(var ba,fa,ga;W&&Z&&W[0]&&Z[0];){if(Z._4e_name()==F){for(ba in I.attributes)if(!(ca.blockedAttrs[ba]||!(ga=Z.attr(fa))))if(W.attr(ba)==ga)W.removeAttr(ba);else ca.blockedAttrs[ba]=1;for(fa in I.styles)if(!(ca.blockedStyles[fa]||!(ga=Z._4e_style(fa))))if(W._4e_style(fa)==ga)W._4e_style(fa,"");else ca.blockedStyles[fa]=1;if(!W._4e_hasAttributes()){W=x;break}}Z=Z.parent()}if(W){W[0].appendChild(aa.extractContents());
n(this,W);aa.insertNode(W);W._4e_mergeSiblings();Q.ie||W[0].normalize()}else{W=new O(K.createElement("span"));W[0].appendChild(aa.extractContents());aa.insertNode(W);n(this,W);W._4e_remove(true)}aa=x}}T._4e_remove();S._4e_remove();G.moveToBookmark(L);G.shrink(o.SHRINK_TEXT)}}function h(G){G.enlarge(o.ENLARGE_ELEMENT);var K=G.createBookmark(),F=K.startNode;if(G.collapsed){for(var I=new N(F.parent()),H,M=0,L;M<I.elements.length&&(L=I.elements[M]);M++){if(L==I.block||L==I.blockLimit)break;if(this.checkElementRemovable(L)){var S=
G.checkBoundaryOfElement(L,o.END),T=!S&&G.checkBoundaryOfElement(L,o.START);if(T||S){H=L;H.match=T?"start":"end"}else{L._4e_mergeSiblings();if(L._4e_name()!=this.element){S=a(this);z(L,S[L._4e_name()]||S["*"])}else b(this,L)}}}if(H&&H[0]){L=F;for(M=0;;M++){S=I.elements[M];if(c._4e_equals(S,H))break;else if(S.match)continue;else S=S._4e_clone();S[0].appendChild(L[0]);L=S}c[H.match=="start"?"insertBefore":"insertAfter"](L,H)}}else{var X=K.endNode,aa=this;I=function(){for(var W=new N(F.parent()),Z=new N(X.parent()),
ca=x,ea=x,da=0;da<W.elements.length;da++){var ba=W.elements[da];if(ba==W.block||ba==W.blockLimit)break;if(aa.checkElementRemovable(ba))ca=ba}for(da=0;da<Z.elements.length;da++){ba=Z.elements[da];if(ba==Z.block||ba==Z.blockLimit)break;if(aa.checkElementRemovable(ba))ea=ba}ea&&X._4e_breakParent(ea);ca&&F._4e_breakParent(ca)};I();for(H=new O(F[0].nextSibling);H[0]!==X[0];){M=H._4e_nextSourceNode();if(H[0]&&H[0].nodeType==m.NODE_ELEMENT&&this.checkElementRemovable(H)){if(H._4e_name()==this.element)b(this,
H);else{L=a(this);z(H,L[H._4e_name()]||L["*"])}if(M[0].nodeType==m.NODE_ELEMENT&&M.contains(F)){I();M=new O(F[0].nextSibling)}}H=M}}G.moveToBookmark(K)}function p(G){G=String(G);var K={};G.replace(/&quot;/g,'"').replace(/\s*([^ :;]+)\s*:\s*([^;]+)\s*(?=;|$)/g,function(F,I,H){K[I]=H});return K}function k(G,K){var F="";if(K!==u){F=document.createElement("span");F.style.cssText=G;F=F.style.cssText||""}else F=G;return F.replace(/\s*([;:])\s*/,"$1").replace(/([^\s;])$/,"$1;").replace(/,\s+/g,",").toLowerCase()}
function a(G){if(G._.overrides)return G._.overrides;var K=G._.overrides={},F=G._.definition.overrides;if(F){J.isArray(F)||(F=[F]);for(var I=0;I<F.length;I++){var H=F[I],M,L,S;if(typeof H=="string")M=H.toLowerCase();else{M=H.element?H.element.toLowerCase():G.element;L=H.attributes;S=H.styles}H=K[M]||(K[M]={});if(L){M=H.attributes=H.attributes||[];for(var T in L)L.hasOwnProperty(T)&&M.push([T.toLowerCase(),L[T]])}if(S){H=H.styles=H.styles||[];for(var X in S)S.hasOwnProperty(X)&&H.push([X.toLowerCase(),
S[X]])}}}return K}function b(G,K){var F=G._.definition,I=a(G),H=B.mix(F.attributes,(I[K._4e_name()]||I["*"]||{}).attributes);F=B.mix(F.styles,(I[K._4e_name()]||I["*"]||{}).styles);I=J.isEmptyObject(H)&&J.isEmptyObject(F);for(var M in H)if(H.hasOwnProperty(M))if(!((M=="class"||G._.definition.fullMatch)&&K.attr(M)!=g(M,H[M]))){I=I||!!K._4e_hasAttribute(M);K.removeAttr(M)}for(var L in F)if(F.hasOwnProperty(L))if(!(G._.definition.fullMatch&&K._4e_style(L)!=g(L,F[L],w))){I=I||!!K._4e_style(L);K._4e_style(L,
"")}A(K)}function g(G,K,F){var I=new O("<span>");I[F?"_4e_style":"attr"](G,K);return I[F?"_4e_style":"attr"](G)}function n(G,K){for(var F=a(G),I=K.all(G.element),H=I.length;--H>=0;)b(G,new O(I[H]));for(var M in F)if(M!=G.element){I=K.all(M);for(H=I.length-1;H>=0;H--){var L=new O(I[H]);z(L,F[M])}}}function z(G,K){var F,I=K&&K.attributes;if(I)for(F=0;F<I.length;F++){var H=I[F][0],M;if(M=G.attr(H)){var L=I[F][1];if(L===x||L.test&&L.test(M)||typeof L=="string"&&M==L)G[0].removeAttribute(H)}}if(I=K&&K.styles)for(F=
0;F<I.length;F++){H=I[F][0];if(L=G.css(H)){var S=I[F][1];if(S===x||S.test&&S.test(M)||typeof S=="string"&&L==S)G.css(H,"")}}A(G)}function A(G){if(!G._4e_hasAttributes()){var K=G[0].firstChild,F=G[0].lastChild;G._4e_remove(w);if(K){K.nodeType==m.NODE_ELEMENT&&c._4e_mergeSiblings(K);F&&K!=F&&F.nodeType==m.NODE_ELEMENT&&c._4e_mergeSiblings(F)}}}var w=true,u=false,x=null,J=KISSY,B=l.Utils,c=J.DOM,i={STYLE_BLOCK:1,STYLE_INLINE:2,STYLE_OBJECT:3},o=l.RANGE,t=l.Selection,m=l.NODE,E=l.POSITION,P=l.Range,O=
J.Node,Q=J.UA,N=l.ElementPath,U={address:1,div:1,h1:1,h2:1,h3:1,h4:1,h5:1,h6:1,p:1,pre:1},R={embed:1,hr:1,img:1,li:1,object:1,ol:1,table:1,td:1,tr:1,th:1,ul:1,dl:1,dt:1,dd:1,form:1},V=/\s*(?:;\s*|$)/g,Y=/#\((.+?)\)/g;l.STYLE=i;C.prototype={apply:function(G){r.call(this,G,u)},remove:function(G){r.call(this,G,w)},applyToRange:function(G){return(this.applyToRange=this.type==i.STYLE_INLINE?f:this.type==i.STYLE_BLOCK?s:this.type==i.STYLE_OBJECT?x:x).call(this,G)},removeFromRange:function(G){return(this.removeFromRange=
this.type==i.STYLE_INLINE?h:x).call(this,G)},applyToObject:function(G){q(G,this)},checkElementRemovable:function(G,K){if(!G)return u;var F=this._.definition,I;if(G._4e_name()==this.element){if(!K&&!G._4e_hasAttributes())return w;var H=F._AC;if(H)F=H;else{H={};var M=0,L=F.attributes;if(L)for(var S in L){M++;H[S]=L[S]}if(L=C.getStyleText(F)){H.style||M++;H.style=L}H._length=M;F=F._AC=H}if(F._length){for(var T in F)if(T!="_length"){M=G.attr(T)||"";if(T=="style")a:{H=F[T];M=k(M,u);typeof H=="string"&&
(H=p(H));typeof M=="string"&&(M=p(M));L=void 0;for(L in H)if(!(L in M&&(M[L]==H[L]||H[L]=="inherit"||M[L]=="inherit"))){H=u;break a}H=w}else H=F[T]==M;if(H){if(!K)return w}else if(K)return u}if(K)return w}else return w}T=a(this);if(T=T[G._4e_name()]||T["*"]){if(!(F=T.attributes)&&!(I=T.styles))return w;if(F)for(H=0;H<F.length;H++){T=F[H][0];if(T=G.attr(T)){M=F[H][1];if(M===x||typeof M=="string"&&T==M||M.test&&M.test(T))return w}}if(I)for(H=0;H<I.length;H++)if(T=G.css(I[H][0])){F=I[H][1];if(F===x||
typeof F=="string"&&T==F||F.test&&F.test(T))return w}}return u},checkActive:function(G){switch(this.type){case i.STYLE_BLOCK:return this.checkElementRemovable(G.block||G.blockLimit,w);case i.STYLE_OBJECT:case i.STYLE_INLINE:for(var K=G.elements,F=0,I;F<K.length;F++){I=K[F];if(!(this.type==i.STYLE_INLINE&&(c._4e_equals(I,G.block)||c._4e_equals(I,G.blockLimit))))if(!(this.type==i.STYLE_OBJECT&&!(I._4e_name()in R)))if(this.checkElementRemovable(I,w))return w}}return u}};C.getStyleText=function(G){var K=
G._ST;if(K)return K;K=G.styles;var F=G.attributes&&G.attributes.style||"",I="";if(F.length)F=F.replace(V,";");for(var H in K){var M=K[H],L=(H+":"+M).replace(V,";");if(M=="inherit")I+=L;else F+=L}if(F.length)F=k(F);F+=I;return G._ST=F};l.Style=C;l.Style=C;var $=C.prototype;l.Utils.extern($,{apply:$.apply,remove:$.remove,applyToRange:$.applyToRange,removeFromRange:$.removeFromRange,applyToObject:$.applyToObject,checkElementRemovable:$.checkElementRemovable,checkActive:$.checkActive})});
KISSY.Editor.add("htmlparser",function(){function l(){this._={htmlPartsRegex:RegExp("<(?:(?:\\/([^>]+)>)|(?:!--([\\S|\\s]*?)--\>)|(?:([^\\s>]+)\\s*((?:(?:[^\"'>]+)|(?:\"[^\"]*\")|(?:'[^']*'))*)\\/?>))","g")}}var v=KISSY,D=function(){},C=v.Editor,r=/([\w\-:.]+)(?:(?:\s*=\s*(?:(?:"([^"]*)")|(?:'([^']*)')|([^\s>]+)))|(?=\s|$))/g,y={checked:1,compact:1,declare:1,defer:1,disabled:1,ismap:1,multiple:1,nohref:1,noresize:1,noshade:1,nowrap:1,readonly:1,selected:1},q=C.XHTML_DTD;v.augment(l,{onTagOpen:D,onTagClose:D,
onText:D,onCDATA:D,onComment:D,parse:function(s){for(var j,d,e=0,f;j=this._.htmlPartsRegex.exec(s);){d=j.index;if(d>e){e=s.substring(e,d);f?f.push(e):this.onText(e)}e=this._.htmlPartsRegex.lastIndex;if(d=j[1]){d=d.toLowerCase();if(f&&q.$cdata[d]){this.onCDATA(f.join(""));f=null}if(!f){this.onTagClose(d);continue}}if(f)f.push(j[0]);else if(d=j[3]){d=d.toLowerCase();if(!/="/.test(d)){var h={},p;j=j[4];var k=!!(j&&j.charAt(j.length-1)=="/");if(j)for(;p=r.exec(j);){var a=p[1].toLowerCase();p=p[2]||p[3]||
p[4]||"";h[a]=!p&&y[a]?a:p}this.onTagOpen(d,h,k);if(!f&&q.$cdata[d])f=[]}}else if(d=j[2])this.onComment(d)}s.length>e&&this.onText(s.substring(e,s.length))}});C.HtmlParser=l;C.HtmlParser=l});
KISSY.Editor.add("htmlparser-basicwriter",function(){function l(){this._={output:[]}}var v=KISSY,D=v.Editor,C=D.Utils;v.augment(l,{openTag:function(r){this._.output.push("<",r)},openTagClose:function(r,y){y?this._.output.push(" />"):this._.output.push(">")},attribute:function(r,y){if(typeof y=="string")y=C.htmlEncodeAttr(y);this._.output.push(" ",r,'="',y,'"')},closeTag:function(r){this._.output.push("</",r,">")},text:function(r){this._.output.push(r)},comment:function(r){this._.output.push("<!--",
r,"--\>")},write:function(r){this._.output.push(r)},reset:function(){this._.output=[];this._.indent=false},getHtml:function(r){var y=this._.output.join("");r&&this.reset();return y}});D.HtmlParser.BasicWriter=l;D.HtmlParser.BasicWriter=l;v=l.prototype;D.Utils.extern(v,{openTag:v.openTag,openTagClose:v.openTagClose,attribute:v.attribute,closeTag:v.closeTag,text:v.text,comment:v.comment,write:v.write,reset:v.reset,getHtml:v.getHtml})});
KISSY.Editor.add("htmlparser-htmlwriter",function(){function l(){l.superclass.constructor.call(this);this.indentationChars="\t";this.selfClosingEnd=" />";this.lineBreakChars="\n";this.forceSimpleAmpersand=y;this.sortAttributes=r;this._.indent=y;this._.indentation="";this._.rules={};var q=D.XHTML_DTD,s;for(s in C.mix({},q.$nonBodyContent,q.$block,q.$listItem,q.$tableContent))this.setRules(s,{indent:r,breakBeforeOpen:r,breakAfterOpen:r,breakBeforeClose:!q[s]["#"],breakAfterClose:r});this.setRules("br",
{breakAfterOpen:r});this.setRules("title",{indent:y,breakAfterOpen:y});this.setRules("style",{indent:y,breakBeforeClose:r});this.setRules("pre",{indent:y})}var v=KISSY,D=v.Editor,C=D.Utils,r=true,y=false;v.extend(l,D.HtmlParser.BasicWriter,{openTag:function(q){var s=this._.rules[q];if(this._.indent)this.indentation();else if(s&&s.breakBeforeOpen){this.lineBreak();this.indentation()}this._.output.push("<",q)},openTagClose:function(q,s){var j=this._.rules[q];if(s)this._.output.push(this.selfClosingEnd);
else{this._.output.push(">");if(j&&j.indent)this._.indentation+=this.indentationChars}j&&j.breakAfterOpen&&this.lineBreak()},attribute:function(q,s){if(typeof s=="string"){this.forceSimpleAmpersand&&(s=s.replace(/&amp;/g,"&"));s=C.htmlEncodeAttr(s)}this._.output.push(" ",q,'="',s,'"')},closeTag:function(q){var s=this._.rules[q];if(s&&s.indent)this._.indentation=this._.indentation.substr(this.indentationChars.length);if(this._.indent)this.indentation();else if(s&&s.breakBeforeClose){this.lineBreak();
this.indentation()}this._.output.push("</",q,">");s&&s.breakAfterClose&&this.lineBreak()},text:function(q){if(this._.indent){this.indentation();q=C.ltrim(q)}this._.output.push(q)},comment:function(q){this._.indent&&this.indentation();this._.output.push("<!--",q,"--\>")},lineBreak:function(){this._.output.length>0&&this._.output.push(this.lineBreakChars);this._.indent=r},indentation:function(){this._.output.push(this._.indentation);this._.indent=y},setRules:function(q,s){var j=this._.rules[q];if(j)C.mix(j,
s);else this._.rules[q]=s}});D.HtmlParser.HtmlWriter=l;D.HtmlParser.HtmlWriter=l;v=l.prototype;D.Utils.extern(v,{openTag:v.openTag,openTagClose:v.openTagClose,attribute:v.attribute,closeTag:v.closeTag,text:v.text,comment:v.comment,lineBreak:v.lineBreak,indentation:v.indentation,setRules:v.setRules})});
KISSY.Editor.add("htmlparser-fragment",function(){function l(){this.children=[];this.parent=C;this._={isBlockLike:v,hasInlineStarted:D}}var v=true,D=false,C=null,r=KISSY.Editor,y={colgroup:1,dd:1,dt:1,li:1,option:1,p:1,td:1,tfoot:1,th:1,thead:1,tr:1},q=KISSY,s=r.Utils,j=r.NODE,d=r.XHTML_DTD;s.mix({table:1,ul:1,ol:1,dl:1},d.table,d.ul,d.ol,d.dl);var e=d.$list,f=d.$listItem;l.FromHtml=function(h,p){function k(c){var i;if(z.length>0)for(var o=0;o<z.length;o++){var t=z[o],m=t.name,E=d[m],P=w.name&&d[w.name];
if((!P||P[m])&&(!c||!E||E[c]||!d[c])){if(!i){a();i=1}t=t.clone();t.parent=w;w=t;z.splice(o,1);o--}}}function a(){for(;A.length;)w.add(A.shift())}function b(c,i,o){i=i||w||n;if(p&&!i.type){var t,m;if((t=c.attributes&&(m=c.attributes._ke_real_element_type)?m:c.name)&&!(t in d.$body)&&!(t in d.$nonBodyContent)){m=w;w=i;g.onTagOpen({li:"ul",dt:"dl",dd:"dl"}[t]||p,{});i=w;if(o)w=m}}if(c._.isBlockLike&&c.name!="pre"){o=c.children.length;if((t=c.children[o-1])&&t.type==j.NODE_TEXT)if(m=s.rtrim(t.value))t.value=
m;else c.children.length=o-1}i.add(c);if(c.returnPoint){w=c.returnPoint;delete c.returnPoint}}var g=new r.HtmlParser,n=new l,z=[],A=[],w=n,u=D,x;g.onTagOpen=function(c,i,o){var t=new r.HtmlParser.Element(c,i);if(t.isUnknown&&o)t.isEmpty=v;if(d.$removeEmpty[c])z.push(t);else{if(c==="pre")u=v;else if(c==="br"&&u){w.add(new r.HtmlParser.Text("\n"));return}if(c==="br")A.push(t);else{var m=w.name,E=m&&(d[m]||(w._.isBlockLike?d.div:d.span));if(E&&!t.isUnknown&&!w.isUnknown&&!E[c]){E=D;var P;if(c in e&&
m in e){m=w.children;(m=m[m.length-1])&&m.name in f||b(m=new r.HtmlParser.Element("li"),w);x=w;P=m}else if(c==m)b(w,w.parent);else{b(w,w.parent,v);!y[m]&&m in d.$inline&&z.unshift(w);E=v}w=P?P:w.returnPoint||w.parent;if(E){g.onTagOpen.apply(this,arguments);return}}k(c);a();t.parent=w;t.returnPoint=x;x=0;if(t.isEmpty)b(t);else w=t}}};g.onTagClose=function(c){for(var i=z.length-1;i>=0;i--)if(c==z[i].name){z.splice(i,1);return}for(var o=[],t=[],m=w;m.type&&m.name!=c;){m._.isBlockLike||t.unshift(m);o.push(m);
m=m.parent}if(m.type){for(i=0;i<o.length;i++){var E=o[i];b(E,E.parent)}w=m;if(w.name=="pre")u=D;m._.isBlockLike&&a();b(m,m.parent);if(m==w)w=w.parent;z=z.concat(t)}if(c=="body")p=D};g.onText=function(c){if(!w._.hasInlineStarted&&!u){c=s.ltrim(c);if(c.length===0)return}a();k();if(p&&(!w.type||w.name=="body")&&s.trim(c))this.onTagOpen(p,{});u||(c=c.replace(/[\t\r\n ]{2,}|[\t\r\n]/g," "));w.add(new r.HtmlParser.Text(c))};g.onCDATA=function(c){w.add(new r.HtmlParser.cdata(c))};g.onComment=function(c){w.add(new r.HtmlParser.Comment(c))};
g.parse(h);for(a();w.type;){var J=w.parent,B=w;if(p&&(!J.type||J.name=="body")&&!d.$body[B.name]){w=J;g.onTagOpen(p,{});J=w}J.add(B);w=J}return n};q.augment(l,{add:function(h){var p=this.children.length;if(p=p>0&&this.children[p-1]||C){if(h._.isBlockLike&&p.type==j.NODE_TEXT){p.value=s.rtrim(p.value);if(p.value.length===0){this.children.pop();this.add(h);return}}p.next=h}h.previous=p;h.parent=this;this.children.push(h);this._.hasInlineStarted=h.type==j.NODE_TEXT||h.type==j.NODE_ELEMENT&&!h._.isBlockLike},
writeHtml:function(h,p){var k;this.filterChildren=this.filterChildren=function(){var a=new r.HtmlParser.BasicWriter;this.writeChildrenHtml.call(this,a,p,v);a=a.getHtml();this.children=(new l.FromHtml(a)).children;k=1};!this.name&&p&&p.onFragment(this);this.writeChildrenHtml(h,k?C:p)},writeChildrenHtml:function(h,p){for(var k=0;k<this.children.length;k++)this.children[k].writeHtml(h,p)}});r.HtmlParser.Fragment=l;r.HtmlParser.Fragment=l;l.FromHtml=l.FromHtml;q=l.prototype;r.Utils.extern(q,{add:q.add,
writeHtml:q.writeHtml,writeChildrenHtml:q.writeChildrenHtml})});
KISSY.Editor.add("htmlparser-element",function(){function l(y,q){this.name=y;this.attributes=q||(q={});this.children=[];var s=q._ke_real_element_type||y,j=v.XHTML_DTD;s=!!(j.$nonBodyContent[s]||j.$block[s]||j.$listItem[s]||j.$tableContent[s]||j.$nonEditable[s]||s=="br");var d=!!j.$empty[y];this.isEmpty=d;this.isUnknown=!j[y];this._={isBlockLike:s,hasInlineStarted:d||!s}}var v=KISSY.Editor,D=v.NODE,C=function(y,q){y=y[0];q=q[0];return y<q?-1:y>q?1:0};KISSY.augment(l,{type:D.NODE_ELEMENT,add:v.HtmlParser.Fragment.prototype.add,
clone:function(){return new l(this.name,this.attributes)},writeHtml:function(y,q){var s=this.attributes,j=this,d=j.name,e,f,h,p;j.filterChildren=function(){if(!p){var b=new v.HtmlParser.BasicWriter;v.HtmlParser.Fragment.prototype.writeChildrenHtml.call(j,b,q);j.children=(new v.HtmlParser.Fragment.FromHtml(b.getHtml())).children;p=1}};j.filterChildren=j.filterChildren;if(q){for(;;){if(!(d=q.onElementName(d)))return;j.name=d;if(!(j=q.onElement(j)))return;j.parent=this.parent;if(j.name==d)break;if(j.type!=
D.NODE_ELEMENT){j.writeHtml(y,q);return}d=j.name;if(!d){this.writeChildrenHtml.call(j,y,p?null:q);return}}s=j.attributes}y.openTag(d,s);for(var k=[],a=0;a<2;a++)for(e in s){f=e;h=s[e];if(a==1)k.push([e,h]);else if(q){for(;;)if(f=q.onAttributeName(e))if(f!=e){delete s[e];e=f}else break;else{delete s[e];break}if(f)if((h=q.onAttribute(j,f,h))===false)delete s[f];else s[f]=h}}y.sortAttributes&&k.sort(C);s=k.length;for(a=0;a<s;a++){e=k[a];y.attribute(e[0],e[1])}y.openTagClose(d,j.isEmpty);if(!j.isEmpty){this.writeChildrenHtml.call(j,
y,p?null:q);y.closeTag(d)}},writeChildrenHtml:function(){v.HtmlParser.Fragment.prototype.writeChildrenHtml.apply(this,arguments)}});v.HtmlParser.Element=l;v.HtmlParser.Element=l;var r=l.prototype;v.Utils.extern(r,{type:r.type,add:r.add,clone:r.clone,writeHtml:r.writeHtml,writeChildrenHtml:r.writeChildrenHtml})});
KISSY.Editor.add("htmlparser-filter",function(){function l(e){this._={elementNames:[],attributeNames:[],elements:{$length:0},attributes:{$length:0}};e&&this.addRules(e,10)}function v(e,f){for(var h=0;e&&h<f.length;h++){var p=f[h];e=e.replace(p[0],p[1])}return e}function D(e,f,h){if(typeof f=="function")f=[f];var p,k;k=e.length;var a=f&&f.length;if(a){for(p=0;p<k&&e[p].pri<h;p++);for(k=a-1;k>=0;k--)if(a=f[k]){a.pri=h;e.splice(p,0,a)}}}function C(e,f,h){if(f)for(var p in f){var k=e[p];e[p]=r(k,f[p],
h);k||e.$length++}}function r(e,f,h){if(f){f.pri=h;if(e){if(e.splice)D(e,f,h);else{e=e.pri>h?[f,e]:[e,f];e.filter=y}return e}else return f.filter=f}}function y(e){for(var f=e.type||e instanceof s.HtmlParser.Fragment,h=0;h<this.length;h++){if(f)var p=e.type,k=e.name;var a=this[h].apply(window,arguments);if(a===d)return a;if(f){if(a&&(a.name!=k||a.type!=p))return a}else if(typeof a!="string")return a;a!=undefined&&(e=a)}return e}var q=KISSY,s=q.Editor,j=s.NODE,d=false;q.augment(l,{addRules:function(e,
f){if(typeof f!="number")f=10;D(this._.elementNames,e.elementNames,f);D(this._.attributeNames,e.attributeNames,f);C(this._.elements,e.elements,f);C(this._.attributes,e.attributes,f);this._.text=r(this._.text,e.text,f)||this._.text;this._.comment=r(this._.comment,e.comment,f)||this._.comment;this._.root=r(this._.root,e.root,f)||this._.root},onElementName:function(e){return v(e,this._.elementNames)},onAttributeName:function(e){return v(e,this._.attributeNames)},onText:function(e){var f=this._.text;
return f?f.filter(e):e},onComment:function(e,f){var h=this._.comment;return h?h.filter(e,f):e},onFragment:function(e){var f=this._.root;return f?f.filter(e):e},onElement:function(e){for(var f=[this._.elements["^"],this._.elements[e.name],this._.elements.$],h,p=0;p<3;p++)if(h=f[p]){h=h.filter(e,this);if(h===d)return null;if(h&&h!=e)return this.onNode(h);if(e.parent&&!e.name)break}return e},onNode:function(e){var f=e.type;return f==j.NODE_ELEMENT?this.onElement(e):f==j.NODE_TEXT?new s.HtmlParser.Text(this.onText(e.value)):
null},onAttribute:function(e,f,h){if(f=this._.attributes[f]){e=f.filter(h,e,this);if(e===d)return d;if(typeof e!="undefined")return e}return h}});s.HtmlParser.Filter=l;q=l.prototype;s.Utils.extern(q,{addRules:q.addRules,onElementName:q.onElementName,onAttributeName:q.onAttributeName,onText:q.onText,onComment:q.onComment,onFragment:q.onFragment,onElement:q.onElement,onNode:q.onNode,onAttribute:q.onAttribute});s.HtmlParser.Filter=l});
KISSY.Editor.add("htmlparser-text",function(){function l(r){this.value=r;this._={isBlockLike:C}}var v=KISSY,D=v.Editor,C=false;v.augment(l,{type:D.NODE.NODE_TEXT,writeHtml:function(r,y){var q=this.value;y&&!(q=y.onText(q,this))||r.text(q)}});D.HtmlParser.Text=l;D.HtmlParser.Text=l});KISSY.Editor.add("htmlparser-cdata",function(l){l.HtmlParser.cdata=function(v){this.value=v};l.HtmlParser.cdata.prototype={type:l.NODE.NODE_TEXT,writeHtml:function(v){v.write(this.value)}}});
KISSY.Editor.add("htmlparser-comment",function(){function l(C){this.value=C;this._={isBlockLike:false}}var v=KISSY.Editor,D=v.NODE;v.HtmlParser.Comment=l;v.HtmlParser.Comment=l;l.prototype={constructor:l,type:D.NODE_COMMENT,writeHtml:function(C,r){var y=this.value;if(r){if(!(y=r.onComment(y,this)))return;if(typeof y!="string"){y.parent=this.parent;y.writeHtml(C,r);return}}C.comment(y)}}});
KISSY.Editor.add("button",function(){var l=KISSY,v=l.Editor;if(v.TripleButton)l.log("TripleButton attach twice","warn");else{var D=l.UIBase.create([l.UIBase.Box.Render||l.UIBase.Box],{bindUI:function(){var C=this,r=C.get("el");r.on("click",C._action,C);r.on("mousedown",function(){C.get("state")=="off"&&r.addClass("ke-triplebutton-active")});r.on("mouseup mouseleave",function(){C.get("state")=="off"&&r.hasClass("ke-triplebutton-active")&&setTimeout(function(){r.removeClass("ke-triplebutton-active")},
300)})},_uiSetTitle:function(){this.get("el").attr("title",this.get("title"))},_uiSetContentCls:function(C){var r=this.get("el");if(C!==undefined){r.html("<span class='ke-toolbar-item "+C+"'>");r._4e_unselectable()}},_uiSetText:function(C){var r=this.get("el");C!==undefined&&r.html(C)},_uiSetState:function(C){this["_"+C]()},disable:function(){this._savedState=this.get("state");this.set("state","disabled")},enable:function(){this.get("state")=="disabled"&&this.set("state",this._savedState)},_action:function(C){this.fire(this.get("state")+
"Click",{TripleEvent:C});this.fire("click",{TripleClickType:this.get("state")+"Click"});C&&C.preventDefault()},bon:function(){this.set("state","on")},boff:function(){this.set("state","off")},_on:function(){var C=this.get("el");C.removeClass("ke-triplebutton-off ke-triplebutton-disabled");C.addClass("ke-triplebutton-on")},_off:function(){var C=this.get("el");C.removeClass("ke-triplebutton-on ke-triplebutton-disabled");C.addClass("ke-triplebutton-off")},_disabled:function(){var C=this.get("el");C.removeClass("ke-triplebutton-off ke-triplebutton-on");
C.addClass("ke-triplebutton-disabled")}},{ATTRS:{state:{value:"off"},elCls:{value:"ke-triplebutton ke-triplebutton-off"},elAttrs:{value:{hideFocus:true,tabIndex:0}},elTagName:{value:"a"},title:{},contentCls:{},text:{}}});D.ON="on";D.OFF="off";D.DISABLED="disabled";D.ON_CLASS="ke-triplebutton-on";D.OFF_CLASS="ke-triplebutton-off";D.DISABLED_CLASS="ke-triplebutton-disabled";v.TripleButton=D;v.prototype.addButton=function(C,r){var y=this,q=new D({render:y.toolBarDiv,autoRender:true,title:r.title,text:r.text,
contentCls:r.contentCls}),s={btn:q,editor:y,cfg:r,call:function(){var j=l.makeArray(arguments),d=j.shift();return r[d].apply(s,j)},reload:function(j){l.mix(r,j);q.enable();y.on("selectionChange",function(){y.getMode()!=v.SOURCE_MODE&&r.selectionChange&&r.selectionChange.apply(s,arguments)});q.on("click",function(d){var e=d.TripleClickType;r[e]&&r[e].apply(s,arguments);d&&d.halt()});if(r.mode==v.WYSIWYG_MODE){y.on("wysiwygmode",q.enable,q);y.on("sourcemode",q.disable,q)}r.init&&r.init.call(s)},destroy:function(){r.destroy&&
r.destroy.call(s);q.destroy()}};r.loading?q.disable():s.reload(undefined);return s}}});
KISSY.Editor.add("select",function(){function l(d){l.superclass.constructor.call(this,d);this._init()}var v=KISSY,D=v.Node,C=v.Event,r=v.DOM,y=v.Editor;if(y.Select)v.log("ke select attach more");else{l.DISABLED=0;l.ENABLED=1;var q=y.XHTML_DTD;l.ATTRS={showValue:{},el:{},cls:{},container:{},doc:{},value:{},width:{},title:{},items:{},emptyText:{},align:{value:["l","b"]},menuContainer:{valueFn:function(){for(var d=this.el.parent();d;){var e=d._4e_name();if(q[e]&&q[e].div)return d;d=d.parent()}return new D(document.body)}},
state:{value:1}};l.decorate=function(d){for(var e=d.width(),f=[],h=d.all("option"),p=0;p<h.length;p++){var k=h[p];f.push({name:r.html(k),value:r.attr(k,"value")})}return new l({width:e+"px",el:d,items:f,cls:"ke-combox",value:d.val()})};var s=y.Utils.addRes,j=y.Utils.destroyRes;v.extend(l,v.Base,{_init:function(){var d=this.get("container"),e=this.get("el"),f=new D("<span class='ke-select-wrap'><a onclick='return false;' class='ke-select'><span class='ke-select-text'><span class='ke-select-text-inner'></span></span><span class='ke-select-drop-wrap'><span class='ke-select-drop'></span></span></a></span>"),
h=this.get("title")||"",p=this.get("cls"),k=f.one(".ke-select-text"),a=f.one(".ke-select-text-inner");f.one(".ke-select-drop");this.get("value")!==undefined?a.html(this._findNameByV(this.get("value"))):a.html(h);k.css("width",this.get("width"));f._4e_unselectable();h&&f.attr("title",h);p&&f.addClass(p);if(e)e[0].parentNode.replaceChild(f[0],e[0]);else d&&f.appendTo(d);f.on("click",this._click,this);this.el=f;this.title=a;this._focusA=f.one("a.ke-select");y.Utils.lazyRun(this,"_prepare","_real");this.on("afterValueChange",
this._valueChange,this);this.on("afterStateChange",this._stateChange,this)},_findNameByV:function(d){var e=this.get("title")||"",f=this.get("items");if(this.get("showValue"))return d||e;for(var h=0;h<f.length;h++){var p=f[h];if(p.value==d){e=p.name;break}}return e},_valueChange:function(d){this.title.html(this._findNameByV(d.newVal))},_itemsChange:function(d){var e;e=d.newVal;d=this._selectList;d.html("");if(e&&e.length)for(var f=0;f<e.length;f++){var h=e[f];(new D("<a class='ke-select-menu-item' href='#' data-value='"+
h.value+"'>"+h.name+"</a>",h.attrs)).appendTo(d)._4e_unselectable()}else if(e=this.get("emptyText"))(new D("<a class='ke-select-menu-item' href='#'>"+e+"</a>")).appendTo(d)._4e_unselectable();this.as=d.all("a")},val:function(d){if(d!==undefined){this.set("value",d);return this}else return this.get("value")},_resize:function(){this.menu.get("visible")&&this._real()},_prepare:function(){function d(b){b=new D(b.target);f.contains(b)||f._4e_equals(b)||k.hide()}var e=this,f=e.el,h=e.get("popUpWidth"),
p=e._focusA,k=new y.Overlay({autoRender:true,render:e.get("menuContainer"),content:"<div>",focus4e:false,elCls:"ke-menu",width:h?h:f.width(),zIndex:y.baseZIndex(y.zIndexManager.SELECT),focusMgr:false}),a=e.get("items");s.call(e,k);h=k.get("contentEl").one("div");e.menu=k;C.on(window,"resize",e._resize,e);s.call(e,function(){C.remove(window,"resize",e._resize,e)});e.get("title")&&(new D("<div class='ke-menu-title ke-select-menu-item' style='margin-top:-6px;' >"+e.get("title")+"</div>")).appendTo(h);
e._selectList=(new D("<div>")).appendTo(h);e._itemsChange({newVal:a});k.on("show",function(){p.addClass("ke-select-active")});k.on("hide",function(){p.removeClass("ke-select-active")});C.on(document,"click",d);s.call(e,function(){C.remove(document,"click",d)});e.get("doc")&&C.on(e.get("doc"),"click",d);h.on("click",e._select,e);e.as=e._selectList.all("a");C.on(h[0],"mouseenter",function(){e.as.removeClass("ke-menu-selected")});s.call(e,h);e.on("afterItemsChange",e._itemsChange,e);e.menuNode=h},_stateChange:function(d){var e=
this.el;d.newVal==1?e.removeClass("ke-select-disabled"):e.addClass("ke-select-disabled")},enable:function(){this.set("state",1)},disable:function(){this.set("state",0)},_select:function(d){d&&d.halt();var e=this.menu,f=this.menuNode;if((d=(new D(d.target))._4e_ascendant(function(k){return f.contains(k)&&k._4e_name()=="a"},true))&&d._4e_hasAttribute("data-value")){var h=this.get("value"),p=d.attr("data-value");this.set("value",p);this.fire("click",{newVal:p,prevVal:h,name:d.html()});e.hide()}},_real:function(){var d=
this.el,e=d.offset(),f=v.clone(e),h=this.menu.get("el").height(),p=this.menu.get("el").width(),k=r.scrollTop(),a=r.scrollLeft(),b=r.viewportHeight(),g=r.viewportWidth();g=a+g-60;b=k+b;var n=e.top+(d.height()-2);d=e.left+d.width()-2;var z=this.get("align"),A=z[0];if(z[1]=="b"){e.top=n;if(e.top+h>b&&f.top-k>b-n)e.top=f.top-h}else{e.top=f.top-h;if(e.top<k&&f.top-k<b-n)e.top=n}if(A=="l"){if(e.left+p>g&&d-a>g-f.left)e.left=d-p}else{e.left=d-p;if(e.left<a&&d-a<g-f.left)e.left=f.left}this.menu.set("xy",
[e.left,e.top]);this.menu.show()},_click:function(d){if(!this.loading){d&&d.preventDefault();var e=this;d=e.el;var f=e.get("value");if(!d.hasClass("ke-select-disabled"))if(e._focusA.hasClass("ke-select-active"))e.menu&&e.menu.hide();else{e.loading=true;y.use("overlay",function(){e.loading=false;e.fire("select");e._prepare();f&&e.menu&&e.as.each(function(h){h.attr("data-value")==f?h.addClass("ke-menu-selected"):h.removeClass("ke-menu-selected")})})}}},destroy:function(){j.call(this);this.el.detach();
this.el.remove()}});y.Select=l;y.prototype.addSelect=function(d,e){var f=this;e=v.mix({container:f.toolBarDiv,doc:f.document,menuContainer:new D(document.body)},e);var h=new l(e),p={btn:h,editor:f,cfg:e,call:function(){var k=v.makeArray(arguments),a=k.shift();return e[a].apply(p,k)},reload:function(k){v.mix(e,k);h.enable();f.on("selectionChange",function(){f.getMode()!=y.SOURCE_MODE&&e.selectionChange&&e.selectionChange.apply(p,arguments)});h.on("click",function(a){var b=a.type;e[b]&&e[b].apply(p,
arguments);a&&a.halt()});if(e.mode==y.WYSIWYG_MODE){f.on("wysiwygmode",h.enable,h);f.on("sourcemode",h.disable,h)}e.init&&e.init.call(p)},destroy:function(){e.destroy&&e.destroy.call(p);h.destroy()}};e.loading?h.disable():p.reload(undefined);return p}}});
