/*
 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(k){function q(n,l){var g=this;if(!(g instanceof q))return new q(n,l);if(k.isString(n))n=k.one(n);n=r._4e_wrap(n);l=l||{};l.pluginConfig=l.pluginConfig||{};g.cfg=l;l.pluginConfig=l.pluginConfig;g.cfg=l;k.app(g,k.EventTarget);var e=["htmldataprocessor","enterkey","clipboard"],d=s;g.use=function(c,f){c=c.split(",");if(!d)for(var o=0;o<e.length;o++){var h=e[o];k.inArray(h,c)||c.unshift(h)}g.ready(function(){k.use.call(g,c.join(","),function(){for(var a=0;a<c.length;a++)g.usePlugin(c[a]);
f&&f.call(g);if(!d){g.setData(n.val());if(l.focus)g.focus();else(a=g.getSelection())&&a.removeAllRanges();d=t}},{global:q})});return g};g.use=g.use;g.Config.base=q.Config.base;g.Config.debug=q.Config.debug;g.Config.componentJsName=u;g.init(n);return g}var r=k.DOM,t=true,s=false,u;u=parseFloat(k.version)<1.2?function(){return"plugin-min.js?t=2011-04-18 21:45:33"}:function(n,l){return n+"/plugin-min.js"+(l?l:"?t=2011-04-18 21:45:33")};k.app(q,k.EventTarget);q.Config.base=k.Config.base+"editor/plugins/";q.Config.debug=
k.Config.debug;q.Config.componentJsName=u;k.Editor=q;k.Editor=q});
KISSY.Editor.add("utils",function(k){var q=null,r=KISSY,t=r.Node,s=r.DOM,u=r.UA,n=r.Event,l;l=u.ie?document.documentMode||u.ie:void 0;var g={debugUrl:function(e){e=e.replace(/-min\.(js|css)/i,".$1");k.Config.debug||(e=e.replace(/\.(js|css)/i,"-min.$1"));if(e.indexOf("?t")==-1){e+=e.indexOf("?")!=-1?"&":"?";e+="t="+encodeURIComponent("2011-02-14 14:32:25")}return k.Config.base+e},lazyRun:function(e,d,c){var f=e[d],o=e[c];e[d]=function(){f.apply(this,arguments);e[d]=e[c];return o.apply(this,arguments)}},
getXY:function(e,d,c,f){c=c.defaultView||c.parentWindow;e-=s.scrollLeft(c);d-=s.scrollTop(c);if(f)if(c!=(f.defaultView||f.parentWindow)&&c.frameElement){f=s._4e_getOffset(c.frameElement,f);e+=f.left;d+=f.top}return{left:e,top:d}},tryThese:function(){for(var e,d=0,c=arguments.length;d<c;d++){var f=arguments[d];try{e=f();break}catch(o){}}return e},arrayCompare:function(e,d){if(!e&&!d)return true;if(!e||!d||e.length!=d.length)return false;for(var c=0;c<e.length;c++)if(e[c]!==d[c])return false;return true},
getByAddress:function(e,d,c){e=e.documentElement;for(var f=0;e&&f<d.length;f++){var o=d[f];if(c)for(var h=-1,a=0;a<e.childNodes.length;a++){var b=e.childNodes[a];if(!(c===true&&b.nodeType==3&&b.previousSibling&&b.previousSibling.nodeType==3)){h++;if(h==o){e=b;break}}}else e=e.childNodes[o]}return e?new t(e):q},clearAllMarkers:function(e){for(var d in e)e[d]._4e_clearMarkers(e,true)},htmlEncodeAttr:function(e){return e.replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/,"&gt;")},ltrim:function(e){return e.replace(/^\s+/,
"")},rtrim:function(e){return e.replace(/\s+$/,"")},trim:function(e){return this.ltrim(this.rtrim(e))},mix:function(){for(var e={},d=0;d<arguments.length;d++)e=r.mix(e,arguments[d]);return e},isCustomDomain:function(){if(!u.ie)return false;var e=document.domain,d=window.location.hostname;return e!=d&&e!="["+d+"]"},duplicateStr:function(e,d){return Array(d+1).join(e)},throttle:function(e,d,c){c=c||150;if(c===-1)return function(){e.apply(d,arguments)};var f=(new Date).getTime();return function(){var o=
(new Date).getTime();if(o-f>c){f=o;e.apply(d,arguments)}}},buffer:function(e,d,c){c=c||0;var f=q;return function(){f&&clearTimeout(f);var o=arguments;f=setTimeout(function(){return e.apply(d,o)},c)}},isNumber:function(e){return/^\d+(.\d+)?$/.test(r.trim(e))},verifyInputs:function(e){for(var d=0;d<e.length;d++){var c=s._4e_wrap(e[d]),f=r.trim(c.val()),o=c.attr("data-verify");c=c.attr("data-warning");if(o&&!RegExp(o).test(f)){alert(c);return false}}return true},sourceDisable:function(e,d){e.on("sourcemode",
d.disable,d);e.on("wysiwygmode",d.enable,d)},resetInput:function(e){var d=e.attr("placeholder");if(d&&!u.webkit){e.addClass("ke-input-tip");e.val(d)}else u.webkit&&e.val("")},valInput:function(e,d){e.removeClass("ke-input-tip");e.val(d)},placeholder:function(e,d){e.attr("placeholder",d);if(!u.webkit){e.on("blur",function(){if(!r.trim(e.val())){e.addClass("ke-input-tip");e.val(d)}});e.on("focus",function(){e.removeClass("ke-input-tip");r.trim(e.val())==d&&e.val("")})}},clean:function(e){e=e[0]||e;
for(var d=r.makeArray(e.childNodes),c=0;c<d.length;c++){var f=d[c];f.nodeType==k.NODE.NODE_TEXT&&!r.trim(f.nodeValue)&&e.removeChild(f)}},htmlEncode:function(e){return!e?e:String(e).replace(/&/g,"&amp;").replace(/>/g,"&gt;").replace(/</g,"&lt;").replace(/"/g,"&quot;")},htmlDecode:function(e){return!e?e:String(e).replace(/&gt;/g,">").replace(/&lt;/g,"<").replace(/&quot;/g,'"').replace(/&amp;/g,"&")},equalsIgnoreCase:function(e,d){return e.toLowerCase()==d.toLowerCase()},normParams:function(e){e=r.clone(e);
for(var d in e)if(e.hasOwnProperty(d)){var c=e[d];if(r.isFunction(c))e[d]=c()}return e},doFormUpload:function(e,d,c){function f(){var v={responseText:"",responseXML:q};v.argument=e?e.argument:q;try{var x;if((x=u.ie?h.contentWindow.document:h.contentDocument||window.frames[o].document)&&x.body)v.responseText=x.body.innerHTML;v.responseXML=x&&x.XMLDocument?x.XMLDocument:x}catch(p){r.log(p)}n.remove(h,"load",f);e.callback&&e.callback(v);setTimeout(function(){s._4e_remove(h)},100)}var o=r.guid("form-upload-"),
h=document.createElement("iframe");h.id=o;h.name=o;h.className="ke-hidden";var a="document.open();"+(g.isCustomDomain()?'document.domain="'+document.domain+'";':"")+"document.close();";if(u.ie)h.src=u.ie?"javascript:void(function(){"+encodeURIComponent(a)+"}())":"";r.log("doFormUpload : "+h.src);document.body.appendChild(h);if(u.ie)document.frames[o].name=o;a=s._4e_unwrap(e.form);var b={target:a.target,method:a.method,encoding:a.encoding,enctype:a.enctype,action:a.action};a.target=o;a.method="POST";
a.enctype=a.encoding="multipart/form-data";if(c)a.action=c;var i;if(d){i=[];d=k.Utils.normParams(d);for(var m in d)if(d.hasOwnProperty(m)){c=document.createElement("input");c.type="hidden";c.name=m;c.value=d[m];a.appendChild(c);i.push(c)}}n.on(h,"load",f);a.submit();a.target=b.target;a.method=b.method;a.enctype=b.enctype;a.encoding=b.encoding;a.action=b.action;if(i){d=0;for(m=i.length;d<m;d++)s._4e_remove(i[d])}return h},extern:function(e,d){for(var c in d)e[c]=d[c]},map:function(e,d){for(var c=0;c<
e.length;c++)e[c]=d(e[c]);return e},ieEngine:l,preventFocus:function(e){u.ie?e._4e_unselectable():e.attr("onmousedown","return false;")},isFlashEmbed:function(e){e=e.attributes;return e.type=="application/x-shockwave-flash"||/\.swf(?:$|\?)/i.test(e.src||"")},addRes:function(){var e=this.__res=this.__res||[];e.push.apply(e,r.makeArray(arguments))},destroyRes:function(){for(var e=this.__res||[],d=0;d<e.length;d++){var c=e[d];if(r.isFunction(c))c();else{c.detach&&c.detach();c.destroy&&c.destroy();c.nodeType&&
c.remove&&c.remove()}}this.__res=[]}};k.Utils=g;k.Utils=g;u.ieEngine=g.ieEngine;g.extern(g,{debugUrl:g.debugUrl,lazyRun:g.lazyRun,getXY:g.getXY,tryThese:g.tryThese,arrayCompare:g.arrayCompare,getByAddress:g.getByAddress,clearAllMarkers:g.clearAllMarkers,htmlEncodeAttr:g.htmlEncodeAttr,ltrim:g.ltrim,rtrim:g.rtrim,trim:g.trim,mix:g.mix,isCustomDomain:g.isCustomDomain,duplicateStr:g.duplicateStr,buffer:g.buffer,isNumber:g.isNumber,verifyInputs:g.verifyInputs,sourceDisable:g.sourceDisable,resetInput:g.resetInput,
placeholder:g.placeholder,clean:g.clean,htmlEncode:g.htmlEncode,htmlDecode:g.htmlDecode,equalsIgnoreCase:g.equalsIgnoreCase,normParams:g.normParams,throttle:g.throttle,doFormUpload:g.doFormUpload,map:g.map})});
KISSY.Editor.add("dom",function(k){function q(a){return a.replace(/-(\w)/g,function(b,i){return i.toUpperCase()})}var r=KISSY,t=r.DOM,s=r.UA,u=r.Node,n=k.Utils,l={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};k.NODE={NODE_ELEMENT:1,NODE_TEXT:3,NODE_COMMENT:8,NODE_DOCUMENT_FRAGMENT:11};k.NODE=k.NODE;k.POSITION={POSITION_IDENTICAL:0,POSITION_DISCONNECTED:1,POSITION_FOLLOWING:2,
POSITION_PRECEDING:4,POSITION_IS_CONTAINED:8,POSITION_CONTAINS:16};k.POSITION=k.POSITION;var g=k.NODE,e=k.POSITION,d={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},c={hr:1},f=function(a){return a[0]||a},o=function(a){if(a&&!a[0])return new u(a);return a},h={_4e_wrap:o,_4e_unwrap:f,_4e_equals:function(a,b){if(!a&&!b)return true;if(!a||!b)return false;a=f(a);b=f(b);
return a===b},_4e_isBlockBoundary:function(a,b){a=o(a);var i=r.mix(r.mix({},c),b||{});return d[a.css("display")]||i[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=f(a);for(var b=a.parentNode.childNodes,i=0;i<b.length;i++)if(b[i]===a)return i;return-1},_4e_first:function(a,b){a=f(a);var i=a.firstChild;if((i=i&&new u(i))&&b&&!b(i))i=i._4e_next(b);return i},_4e_move:function(a,b,i){a=f(a);t._4e_remove(a);
b=f(b);i?b.insertBefore(a,b.firstChild):b.appendChild(a)},_4e_name:function(a){a=f(a);var b=a.nodeName.toLowerCase();if(s.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 i=a[0].attributes,m=b[0].attributes,v=i.length,x=m.length;if(v!=x)return false;for(var p=0;p<v;p++){var z=i[p],y=z.name;if(z.specified&&a.attr(y)!=b.attr(y))return false}if(n.ieEngine<8)for(p=0;p<x;p++){z=m[p];y=z.name;if(z.specified&&
a.attr(y)!=b.attr(y))return false}return true},_4e_isEmptyInlineRemoveable:function(a){a=f(a).childNodes;for(var b=0,i=a.length;b<i;b++){var m=a[b],v=m.nodeType;if(!(v==g.NODE_ELEMENT&&m.getAttribute("_ke_bookmark")))if(v==g.NODE_ELEMENT&&!h._4e_isEmptyInlineRemoveable(m)||v==g.NODE_TEXT&&r.trim(m.nodeValue))return false}return true},_4e_moveChildren:function(a,b,i){a=f(a);b=b[0]||b;if(a!=b)if(i)for(;i=a.lastChild;)b.insertBefore(a.removeChild(i),b.firstChild);else for(;i=a.firstChild;)b.appendChild(a.removeChild(i))},
_4e_mergeSiblings:function(){function a(b,i,m){if(i[0]&&i[0].nodeType==g.NODE_ELEMENT){for(var v=[];i.attr("_ke_bookmark")||i._4e_isEmptyInlineRemoveable();){v.push(i);i=m?new u(i[0].nextSibling):new u(i[0].previousSibling);if(!i[0]||i[0].nodeType!=g.NODE_ELEMENT)return}if(b._4e_isIdentical(i)){for(var x=m?b[0].lastChild:b[0].firstChild;v.length;)v.shift()._4e_move(b,!m);i._4e_moveChildren(b,!m);i._4e_remove();x[0]&&x[0].nodeType==g.NODE_ELEMENT&&x._4e_mergeSiblings()}}}return function(b){if(b[0])if(l[b._4e_name()]||
b._4e_name()=="a"){a(b,new u(b[0].nextSibling),true);a(b,new u(b[0].previousSibling))}}}(),_4e_unselectable:s.gecko?function(a){a=f(a);a.style.MozUserSelect="none"}:s.webkit?function(a){a=f(a);a.style.KhtmlUserSelect="none"}:function(a){a=f(a);if(s.ie||s.opera){var b=0;a.setAttribute("unselectable","on");for(var i=a.getElementsByTagName("*");a=i[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=f(a);var i,m=0;i=0;var v=a.ownerDocument.defaultView||a.ownerDocument.parentWindow,x=a.ownerDocument,p=x.documentElement;b=b||x;if(a.getBoundingClientRect){if(a!==x.body&&p!==a){i=a.getBoundingClientRect();m=i.left+(b===x?t.scrollLeft(v):0);i=i.top+(b===x?t.scrollTop(v):0)}if(b)if(v!=(b.defaultView||b.parentWindow)&&v.frameElement){v=h._4e_getOffset(v.frameElement,b);m+=v.left;i+=v.top}}return{left:m,top:i}},_4e_getFrameDocument:function(a){return(a=f(a))&&a.contentWindow.document},_4e_splitText:function(a,
b){a=f(a);var i=a.ownerDocument;if(!(!a||a.nodeType!=g.NODE_TEXT)){if(s.ie&&b==a.nodeValue.length){var m=i.createTextNode("");t.insertAfter(m,a);return new u(m)}m=new u(a.splitText(b));if(i.documentMode){i=i.createTextNode("");t.insertAfter(i,m[0]);t._4e_remove(i)}return m}},_4e_parents:function(a,b){a=o(a);var i=[];do i[b?"push":"unshift"](a);while(a=a.parent());return i},_4e_clone:function(a,b,i){a=f(a);a=a.cloneNode(b);if(!i){var m=function(v){if(v.nodeType==g.NODE_ELEMENT){v.removeAttribute("id");
v=v.childNodes;for(var x=0;x<v.length;x++)m(v[x])}};m(a)}return new u(a)},_4e_nextSourceNode:function(a,b,i,m){a=f(a);if(m&&!m.call){var v=m[0]||m;m=function(p){p=p[0]||p;return p!==v}}b=!b&&a.firstChild;var x=new u(a);if(!b){if(a.nodeType==g.NODE_ELEMENT&&m&&m(a,true)===false)return null;b=a.nextSibling}for(;!b&&(x=x.parent());){if(m&&m(x,true)===false)return null;b=x[0].nextSibling}if(!b)return null;b=t._4e_wrap(b);if(m&&m(b)===false)return null;if(i&&i!=b[0].nodeType)return b._4e_nextSourceNode(false,
i,m);return b},_4e_previousSourceNode:function(a,b,i,m){a=f(a);if(m&&!m.call){var v=m[0]||m;m=function(p){p=p[0]||p;return p!==v}}b=!b&&a.lastChild;var x=new u(a);if(!b){if(a.nodeType==g.NODE_ELEMENT&&m&&m(a,true)===false)return null;b=a.previousSibling}for(;!b&&(x=x.parent());){if(m&&m(x,true)===false)return null;b=x[0].previousSibling}if(!b)return null;b=t._4e_wrap(b);if(m&&m(b)===false)return null;if(i&&b[0].nodeType!=i)return b._4e_previousSourceNode(false,i,m);return b},_4e_commonAncestor:function(a,
b){if(a._4e_equals(b))return a;if(b[0].nodeType!=g.NODE_TEXT&&b.contains(a))return b;var i=a[0].nodeType==g.NODE_TEXT?a.parent():a;do if(i[0].nodeType!=g.NODE_TEXT&&i.contains(b))return i;while(i=i.parent());return null},_4e_ascendant:function(a,b,i){a=f(a);if(!i)a=a.parentNode;if(b&&!r.isFunction(b)){var m=b;b=function(v){return v._4e_name()==m}}for(;a&&a.nodeType!=9;){if(!b||b(new u(a))===true)return new u(a);a=a.parentNode}return null},_4e_hasAttribute:n.ieEngine<9?function(a,b){a=f(a);var i=a.getAttributeNode(b);
return!!(i&&i.specified)}:function(a,b){a=f(a);return a.hasAttribute(b)},_4e_hasAttributes:n.ieEngine<9?function(a){a=f(a);for(var b=a.attributes,i=0;i<b.length;i++){var m=b[i];switch(m.name){case "class":if(a.getAttribute("class"))return true;break;default:if(m.specified)return true}}return false}:function(a){a=f(a);s.gecko&&a.removeAttribute("_moz_dirty");return a.hasAttributes()},_4e_position:function(a,b){var i=f(a),m=f(b);if(i.compareDocumentPosition)return i.compareDocumentPosition(m);if(i==
m)return e.POSITION_IDENTICAL;if(i.nodeType==g.NODE_ELEMENT&&m.nodeType==g.NODE_ELEMENT){if(i.contains){if(i.contains(m))return e.POSITION_CONTAINS+e.POSITION_PRECEDING;if(m.contains(i))return e.POSITION_IS_CONTAINED+e.POSITION_FOLLOWING}if("sourceIndex"in i)return i.sourceIndex<0||m.sourceIndex<0?e.POSITION_DISCONNECTED:i.sourceIndex<m.sourceIndex?e.POSITION_PRECEDING:e.POSITION_FOLLOWING}i=a._4e_address();m=b._4e_address();for(var v=Math.min(i.length,m.length),x=0;x<=v-1;x++)if(i[x]!=m[x]){if(x<
v)return i[x]<m[x]?e.POSITION_PRECEDING:e.POSITION_FOLLOWING;break}return i.length<m.length?e.POSITION_CONTAINS+e.POSITION_PRECEDING:e.POSITION_IS_CONTAINED+e.POSITION_FOLLOWING},_4e_address:function(a,b){a=f(a);for(var i=[],m=a.ownerDocument.documentElement,v=a;v&&v!=m;){var x=v.parentNode,p=-1;if(x){for(var z=0;z<x.childNodes.length;z++){var y=x.childNodes[z];if(!(b&&y.nodeType==3&&y.previousSibling&&y.previousSibling.nodeType==3)){p++;if(y==v)break}}i.unshift(p)}v=x}return i},_4e_breakParent:function(a,
b){var i=new k.Range(a[0].ownerDocument);i.setStartAfter(a);i.setEndAfter(b);var m=i.extractContents();i.insertNode(a._4e_remove());a[0].parentNode.insertBefore(m,a[0].nextSibling)},_4e_style:function(a,b,i){a=o(a);if(i!==undefined)return a.css(b,i);a=f(a);return a.style[q(b)]},_4e_remove:function(a,b){var i=f(a),m=i.parentNode;if(m){if(b)for(var v;v=i.firstChild;)m.insertBefore(i.removeChild(v),i);m.removeChild(i)}return a},_4e_trim:function(a){t._4e_ltrim(a);t._4e_rtrim(a)},_4e_ltrim:function(a){a=
f(a);for(var b;b=a.firstChild;){if(b.nodeType==g.NODE_TEXT){var i=n.ltrim(b.nodeValue),m=b.nodeValue.length;if(i){if(i.length<m){(new u(b))._4e_splitText(m-i.length);a.removeChild(a.firstChild)}}else{a.removeChild(b);continue}}break}},_4e_rtrim:function(a){a=f(a);for(var b;b=a.lastChild;){if(b.type==g.NODE_TEXT){var i=n.rtrim(b.nodeValue),m=b.nodeValue.length;if(i){if(i.length<m){(new u(b))._4e_splitText(i.length);a.removeChild(a.lastChild)}}else{a.removeChild(b);continue}}break}if(!s.ie&&!s.opera)(b=
a.lastChild)&&b.nodeType==1&&b.nodeName.toLowerCase()=="br"&&b.parentNode.removeChild(b)},_4e_appendBogus:function(a){a=f(a);for(var b=a.lastChild;b&&b.nodeType==g.NODE_TEXT&&!r.trim(b.nodeValue);)b=b.previousSibling;if(!b||b.nodeType==g.NODE_TEXT||t._4e_name(b)!=="br"){b=s.opera?a.ownerDocument.createTextNode(""):a.ownerDocument.createElement("br");s.gecko&&b.setAttribute("type","_moz");a.appendChild(b)}},_4e_previous:function(a,b){var i=f(a),m;do m=(i=i.previousSibling)&&new u(i);while(m&&b&&!b(m));
return m},_4e_last:function(a,b){a=t._4e_wrap(a);var i=a[0].lastChild;if((i=i&&new u(i))&&b&&!b(i))i=i._4e_previous(b);return i},_4e_next:function(a,b){var i=f(a),m;do m=(i=i.nextSibling)&&new u(i);while(m&&b&&!b(m));return m},_4e_outerHtml:function(a){a=f(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,i,m){a=t._4e_wrap(a);var v=a.data("list_marker_id")||a.data("list_marker_id",
r.guid()).data("list_marker_id"),x=a.data("list_marker_names")||a.data("list_marker_names",{}).data("list_marker_names");b[v]=a;x[i]=1;return a.data(i,m)},_4e_clearMarkers:function(a,b,i){a=o(a);var m=a.data("list_marker_names"),v=a.data("list_marker_id"),x;for(x in m)a.removeData(x);a.removeData("list_marker_names");if(i){a.removeData("list_marker_id");delete b[v]}},_4e_copyAttributes:function(a,b,i){a=f(a);b=o(b);var m=a.attributes;i=i||{};for(var v=0;v<m.length;v++){var x=m[v],p=x.name.toLowerCase(),
z;if(!(p in i))if(p=="checked"&&(z=t.attr(a,p)))b.attr(p,z);else if(x.specified||s.ie&&x.value&&p=="value"){z=t.attr(a,p);if(z===null)z=x.nodeValue;b.attr(p,z)}}if(a.style.cssText!=="")b[0].style.cssText=a.style.cssText},_4e_isEditable:function(a){a=t._4e_name(a);var b=k.XHTML_DTD;return(a=!b.$nonEditable[a]&&(b[a]||b.span))&&a["#"]},_4e_scrollIntoView:function(a){a=o(a);var b=a[0].ownerDocument,i=t.scrollLeft(b),m=t.scrollTop(b),v=a.offset(),x=v.left;v=v.top;if(t.viewportHeight(b)+m<v||v<m||t.viewportWidth(b)+
i<x||x<i)a.scrollIntoView(b)},_4e_getElementsByTagName:function(a,b,i){a=f(a);if(!s.ie&&i)b=i+":"+b;i=[];a=a.getElementsByTagName(b);for(b=0;b<a.length;b++)i.push(new u(a[b]));return i}};r.DOM._4e_inject=function(a){r.mix(t,a);for(var b in a)a.hasOwnProperty(b)&&function(i){u.prototype[i]=function(){var m=[].slice.call(arguments,0);m.unshift(this);return a[i].apply(null,m)}}(b)};n.extern(h,{_4e_wrap:h._4e_wrap,_4e_unwrap:h._4e_unwrap,_4e_equals:h._4e_equals,_4e_isBlockBoundary:h._4e_isBlockBoundary,
_4e_getWin:h._4e_getWin,_4e_index:h._4e_index,_4e_first:h._4e_first,_4e_move:h._4e_move,_4e_name:h._4e_name,_4e_isIdentical:h._4e_isIdentical,_4e_isEmptyInlineRemoveable:h._4e_isEmptyInlineRemoveable,_4e_moveChildren:h._4e_moveChildren,_4e_mergeSiblings:h._4e_mergeSiblings,_4e_unselectable:h._4e_unselectable,_4e_getOffset:h._4e_getOffset,_4e_getFrameDocument:h._4e_getFrameDocument,_4e_splitText:h._4e_splitText,_4e_parents:h._4e_parents,_4e_clone:h._4e_clone,_4e_nextSourceNode:h._4e_nextSourceNode,
_4e_previousSourceNode:h._4e_previousSourceNode,_4e_commonAncestor:h._4e_commonAncestor,_4e_ascendant:h._4e_ascendant,_4e_hasAttribute:h._4e_hasAttribute,_4e_hasAttributes:h._4e_hasAttributes,_4e_position:h._4e_position,_4e_address:h._4e_address,_4e_breakParent:h._4e_breakParent,_4e_style:h._4e_style,_4e_remove:h._4e_remove,_4e_trim:h._4e_trim,_4e_ltrim:h._4e_ltrim,_4e_rtrim:h._4e_rtrim,_4e_appendBogus:h._4e_appendBogus,_4e_last:h._4e_last,_4e_previous:h._4e_previous,_4e_next:h._4e_next,_4e_outerHtml:h._4e_outerHtml,
_4e_setMarker:h._4e_setMarker,_4e_clearMarkers:h._4e_clearMarkers,_4e_getUniqueId:h._4e_getUniqueId,_4e_copyAttributes:h._4e_copyAttributes,_4e_isEditable:h._4e_isEditable,_4e_scrollIntoView:h._4e_scrollIntoView,_4e_getElementsByTagName:h._4e_getElementsByTagName});t._4e_inject(h)});
KISSY.Editor.add("focusmanager",function(k){function q(){var f=this;f.iframeFocus=e;g=f;l&&clearTimeout(l);l=setTimeout(function(){f.fire("focus")},100)}function r(){var f=this;f.iframeFocus=d;g=c;l&&clearTimeout(l);l=setTimeout(function(){f.fire("blur")},100)}var t=KISSY,s=t.DOM,u=t.Event,n={},l,g;t={refreshAll:function(){for(var f in n){var o=n[f];o.document.designMode="off";o.document.designMode="on"}},currentInstance:function(){return g},getInstance:function(f){return n[f]},add:function(f){var o=
s._4e_getWin(f.document);u.on(o,"focus",q,f);u.on(o,"blur",r,f)},register:function(f){n[f._UUID]=f},remove:function(f){delete n[f._UUID];var o=s._4e_getWin(f.document);u.remove(o,"focus",q,f);u.remove(o,"blur",r,f)}};var e=true,d=false,c=null;k.focusManager=t;k.focusManager=t;k.getInstances=function(){return n};k.getInstances=k.getInstances});
KISSY.Editor.add("definition",function(k){var q=true,r=false,t=k.Utils,s=document,u=KISSY,n=u.UA,l=u.DOM,g=u.Node,e=u.Event,d=k.focusManager,c=t.tryThese,f=1,o="document.open();"+(t.isCustomDomain()?'document.domain="'+s.domain+'";':"")+"document.close();",h="<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="'+
(n.ie?"javascript:void(function(){"+encodeURIComponent(o)+"}())":"")+'"  allowTransparency="true" ></iframe></div><div class=\''+".ke-editor-status".substring(1)+"'></div></div>";k.SOURCE_MODE=0;k.WYSIWYG_MODE=1;k.SOURCE_MODE=k.SOURCE_MODE;k.WYSIWYG_MODE=k.WYSIWYG_MODE;u.augment(k,{init:function(a){var b=this;b.__commands={};b.__dialogs={};b.__plugins={};n.ie&&l.addClass(s.body,"ke-ie"+n.ie);if(n.trident)l.addClass(s.body,"ke-trident"+n.trident);else if(n.gecko)l.addClass(s.body,"ke-gecko");else n.webkit&&
l.addClass(s.body,"ke-webkit");var i=new g(h);b.editorWrap=i;b._UUID=f++;d.register(b);b.wrap=i.one(".ke-textarea-wrap");b.wrap=b.wrap;b.iframe=b.wrap.one("iframe");b.iframe=b.iframe;b.toolBarDiv=i.one(".ke-editor-tools");b.toolBarDiv=b.toolBarDiv;b.textarea=a;b.textarea=b.textarea;b.statusDiv=i.one(".ke-editor-status");b.statusDiv=b.statusDiv;t.preventFocus(b.toolBarDiv);var m=a._4e_style("width"),v=a._4e_style("height");if(m){i.css("width",m);a.css("width","100%")}b.textarea.css("display","none");
i.insertAfter(a);b.wrap[0].appendChild(a[0]);if(v){b.wrap.css("height",v);a.css("height","100%")}i=b.iframe;if(a._4e_hasAttribute("tabindex"))i[0].tabIndex=n.webkit?-1:a[0].tabIndex;b.on("dataReady",function(){b._ready=q;k.fire("instanceCreated",{editor:b})});n.gecko?i.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,i=this.document,m=this.iframe[0].contentWindow;this.sync();k.focusManager.remove(this);
e.remove(i);e.remove(i.documentElement);e.remove(i.body);e.remove(m);this.iframe.detach();i=this.__plugins;for(var v in i)if(i.hasOwnProperty(v)){m=i[v];m.destroy&&m.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 g(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 i=this,m=k.Overlay;m&&m.loading();i.use(a,function(){var v=i.getDialog(a);if(v){b(v);m&&m.unloading()}else u.later(arguments.callee,50,false,i)})},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],
i=u.makeArray(arguments);i.shift();i.unshift(this);return b.exec.apply(b,i)},getMode:function(){return this.textarea.css("display")=="none"?k.WYSIWYG_MODE:k.SOURCE_MODE},getData:function(a){var b;b=this.getMode()==k.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=u.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()!=k.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,i=b.customStyle;b=b.customLink;var m="",v=k.Utils.debugUrl("../theme/editor-iframe.css");if(b)for(var x=
0;x<b.length;x++)m+='<link href="'+b[x]+'" rel="stylesheet"/>';return"<!doctype html><html><head><title>${title}</title><link href='"+v+"' rel='stylesheet'/><style>"+(i||"")+"</style>"+m+"</head><body class='ke-editor'>&nbsp;"+(a?'<script id="ke_actscript" type="text/javascript">'+(t.isCustomDomain()?'document.domain="'+s.domain+'";':"")+'window.parent.KISSY.Editor._initIFrame("'+a+'");<\/script>':"")+"</body></html>"},getSelection:function(){return k.Selection.getSelection(this.document)},focus:function(){var a=
this.document,b=l._4e_getWin(a);n.webkit&&b&&b.parent&&b.parent.focus();n.webkit&&b&&b.focus();a&&a.body.focus();this.notifySelectionChange()},blur:function(){l._4e_getWin(this.document).blur();this.document&&this.document.body.blur()},addCustomStyle:function(a){var b=this.cfg,i=this.document;b.customStyle=b.customStyle||"";b.customStyle+="\n"+a;b=i.createElement("style");i.getElementsByTagName("head")[0].appendChild(b);if(b.styleSheet)b.styleSheet.cssText=a;else b.appendChild(i.createTextNode(a))},
addCustomLink:function(a){var b=this.cfg,i=this.document;b.customLink=b.customLink||[];b.customLink.push(a);b=i.createElement("link");b.rel="stylesheet";i.getElementsByTagName("head")[0].appendChild(b);b.href=a},removeCustomLink:function(a){for(var b=this.cfg,i=u.makeArray(this.document.getElementsByTagName("link")),m=0;m<i.length;m++)i[m].href==a&&l._4e_remove(i[m]);b.customLink=b.customLink||[];b=b.customLink;a=u.indexOf(a,b);a!=-1&&b.splice(a,1)},_setUpIFrame:function(){function a(){x=v.document;
b.document=x;i.detach();x.open("text/html","replace");x.write(m);x.close()}var b=this,i=b.iframe,m=b._prepareIFrameHtml(b._UUID),v=i[0].contentWindow,x;try{x=v.document}catch(p){i[0].src=i[0].src;if(n.ie<7){setTimeout(a,10);return}}a()},ready:function(a){this._ready?a():this.on("dataReady",a)},addPlugin:function(a,b,i){this.__plugins=this.__plugins;i=i||{};i.func=b;this.__plugins[a]=i},usePlugin:function(a){var b=this.__plugins[a];if(b)if(!(b.status&&!b.duplicate)){a=this.Env.mods[a].requires||[];
for(var i=0;i<a.length;i++)this.usePlugin(a[i]);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 i=b.getStartElement(),m=new k.ElementPath(i);if(!a.previousPath||!a.previousPath.compare(m)){a.previousPath=m;a.fire("selectionChange",{selection:b,path:m,element:i})}}},100)},notifySelectionChange:function(){this.previousPath=null;this._monitor()},insertElement:function(a,
b,i){var m=this;m.focus();setTimeout(function(){var v,x=a._4e_name(),p=k.XHTML_DTD,z=k.RANGE,y=k.NODE,E=p.$block[x],D=m.getSelection(),j=D&&D.getRanges(),A,w,C,B;if(!j||j.length==0){var F=arguments,O=F.callee;setTimeout(function(){O.apply(m,F)},30)}else{m.fire("save");for(var Q=j.length-1;Q>=0;Q--){A=j[Q];A.deleteContents();v=!Q&&a||a._4e_clone(q);b&&b(v);if(E)for(;(C=A.getCommonAncestor(r,q))&&(B=p[C._4e_name()])&&!(B&&B[x]);)if(C._4e_name()in p.span)A.splitElement(C);else if(A.checkStartOfBlock()&&
A.checkEndOfBlock()){A.setStartBefore(C);A.collapse(q);C._4e_remove()}else A.splitBlock();A.insertNode(v);w||(w=v)}if(w){x=w._4e_nextSourceNode(q);p=m.document;B=k.XHTML_DTD;if(B.$inline[v._4e_name()]){x=new g(p.createTextNode(" "));x.insertAfter(w)}else if(x){if(x._4e_name()=="br"&&B[x.parent()._4e_name()].p){B=new g("<p>&nbsp;</p>",null,p);x[0].parentNode.replaceChild(B[0],x[0]);x=B}}else{B=new g("<p>&nbsp;</p>",null,p);B.insertAfter(w);x=B}A.moveToPosition(w,z.POSITION_AFTER_END);x&&x[0].nodeType==
y.NODE_ELEMENT&&A.moveToElementEditablePosition(x);D.selectRanges([A]);m.focus();v&&v._4e_scrollIntoView();setTimeout(function(){m.fire("save")},10);i&&i(v)}}},0)},insertHtml:function(a,b){var i=this;if(i.htmlDataProcessor)a=i.htmlDataProcessor.toDataFormat(a,null,b);i.focus();setTimeout(function(){var m=i.getSelection(),v=m&&m.getRanges();if(!v||v.length==0){var x=arguments,p=x.callee;setTimeout(function(){p.apply(i,x)},30)}else{i.fire("save");if(document.selection){v=document.selection;if(v.type==
"Control")v.clear();else if(m.getType()==k.SELECTION.SELECTION_TEXT){m=m.getRanges()[0];m.deleteContents();m.select()}v.createRange().pasteHTML(a)}else i.document.execCommand("inserthtml",r,a);setTimeout(function(){i.fire("save")},10)}},0)}});k._initIFrame=function(a){function b(j){c(function(){v.designMode="on";setTimeout(function(){v.designMode="off";z.focus();if(!arguments.callee.retry)arguments.callee.retry=q},50)},function(){v.designMode="off";l.attr(z,"contentEditable",r);l.attr(z,"contentEditable",
q);!j&&b(1)})}var i=d.getInstance(a);a=i.textarea[0];var m=i.iframe[0].contentWindow,v=i.document,x=i.cfg,p=v.getElementById("ke_actscript");l._4e_remove(p);var z=v.body;if(n.ie){z.hideFocus=q;z.disabled=q;z.contentEditable=q;z.removeAttribute("disabled")}else setTimeout(function(){if(n.gecko||n.opera)z.contentEditable=q;else if(n.webkit)z.parentNode.contentEditable=q;else v.designMode="on"},0);if(n.webkit){e.on(v,"click",function(j){var A=new g(j.target);u.inArray(A._4e_name(),["input","select"])&&
j.preventDefault()});e.on(v,"mouseup",function(j){var A=new g(j.target);u.inArray(A._4e_name(),["input","textarea"])&&j.preventDefault()})}if(n.gecko||n.ie||n.opera){var y;y=new g(l.insertAfter((new g('<span tabindex="-1" style="position:absolute; left:-10000" role="presentation"></span>'))[0],a));y.on("focus",function(){i.focus()});i.activateGecko=function(){n.gecko&&i.iframeFocus&&y[0].focus()};i.on("destroy",function(){y.detach();y.remove()})}if(v.documentMode||n.gecko||n.opera){var E=v.documentElement;
e.on(E,"mousedown",function(j){if((new g(j.target))[0]==E){n.gecko&&b(r);y[0].focus()}})}e.on(m,"focus",function(){if(n.gecko)b(r);else n.opera&&z.focus();i.notifySelectionChange()});n.gecko&&e.on(i.document,"mousedown",function(){i.iframeFocus||b(r)});if(n.ie){e.on(v,"keydown",function(j){if(j.keyCode in{8:1,46:1}){var A=i.getSelection(),w=A.getSelectedElement();if(w){i.fire("save");var C=A.getRanges()[0].createBookmark();w._4e_remove();A.selectBookmarks([C]);i.fire("save");j.preventDefault()}}});
if(v.compatMode=="CSS1Compat"){var D={33:1,34:1};e.on(v,"keydown",function(j){j.keyCode in D&&setTimeout(function(){i.getSelection().scrollIntoView()},0)})}}setTimeout(function(){n.ie&&setTimeout(function(){if(v){z.runtimeStyle.marginBottom="0px";z.runtimeStyle.marginBottom=""}},1E3)},0);setTimeout(function(){i.fire("dataReady");var j=x.disableObjectResizing,A=x.disableInlineTableEditing;if(j||A)try{v.execCommand("enableObjectResizing",r,!j);v.execCommand("enableInlineTableEditing",r,!A)}catch(w){e.on(z,
n.ie?"resizestart":"resize",function(C){var B=new g(C.target);if(j||B._4e_name()==="table"&&A)C.preventDefault()})}},10);n.webkit&&e.on(v,"mousedown",function(j){j=new g(j.target);u.inArray(j._4e_name(),["img","hr","input","textarea","select"])&&i.getSelection().selectElement(j)});n.gecko&&e.on(v,"dragstart",function(j){var A=new g(j.target);A._4e_name()==="img"&&/ke_/.test(A[0].className)&&j.preventDefault()});d.add(i)};document.documentMode>7&&function(){for(var a=u.all("link"),b=0;b<a.length;b++){var i=
new g(a[b]),m=i.attr("href");m.indexOf("editor-pkg-min-mhtml.css")!=-1&&i.attr("href",m.replace(/editor-pkg-min-mhtml\.css/g,"editor-pkg-min-datauri.css"))}}();o=k.prototype;t.extern(o,{setData:o.setData,getData:o.getData,insertElement:o.insertElement,insertHtml:o.insertHtml,ready:o.ready,addCustomStyle:o.addCustomStyle,addCommand:o.addCommand,hasCommand:o.hasCommand,execCommand:o.execCommand,useDialog:o.useDialog,addDialog:o.addDialog,getDialog:o.getDialog,getMode:o.getMode,sync:o.sync,getSelection:o.getSelection,
focus:o.focus,blur:o.blur,notifySelectionChange:o.notifySelectionChange})});KISSY.Editor.add("zindex",function(){var k=KISSY.Editor;if(!k.zIndexManager){k.zIndexManager={BUBBLE_VIEW:1100,POPUP_MENU:1200,DD_PG:99999,MAXIMIZE:900,OVERLAY:999999,LOADING:11E3,LOADING_CANCEL:12E3,SELECT:1200};k.baseZIndex=function(q){return(k.Config.baseZIndex||1E4)+q};k.baseZIndex=k.baseZIndex;k.zIndexManager=k.zIndexManager}});
KISSY.Editor.add("dtd",function(k){k.XHTML_DTD=function(){function q(p){for(var z=arguments.length-1;z>0;)KISSY.mix(p,arguments[z--]);return p}var r={isindex:1,fieldset:1},t={input:1,button:1,select:1,textarea:1,label:1},s=q({a:1},t),u=q({iframe:1},s),n={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},l={ins:1,del:1,script:1,style:1},g=q({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},l),e=q({sub:1,img:1,object:1,sup:1,basefont:1,map:1,applet:1,font:1,big:1,small:1},g),d=q({p:1},e);t=q({iframe:1},e,t);e={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 c=q({a:1},t),f={tr:1},o={"#":1},h=q({param:1},e),a=q({form:1},r,u,n,d),b={li:1},i={base:1,link:1,meta:1,title:1},m=q(i,{style:1,script:1}),v={head:1,body:1},x={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:q({html:1},v,i),$block:x,
$blockLimit:{body:1,div:1,td:1,th:1,caption:1,form:1},$inline:c,$body:q({script:1,style:1},x),$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:v,head:m,style:o,body:a,base:{},link:{},meta:{},title:o,col:{},tr:{td:1,th:1},img:{},colgroup:{col:1},noscript:a,td:a,br:{},th:a,center:a,kbd:c,button:q(d,n),basefont:{},h5:c,h4:c,samp:c,h6:c,ol:b,h1:c,h3:c,option:o,h2:c,form:q(r,u,n,d),select:{optgroup:1,option:1},font:c,ins:c,menu:b,abbr:c,label:c,table:{thead:1,
col:1,tbody:1,tr:1,colgroup:1,caption:1,tfoot:1},code:c,script:o,tfoot:f,cite:c,li:a,input:{},iframe:a,strong:c,textarea:o,noframes:a,big:c,small:c,span:c,hr:{},dt:c,sub:c,optgroup:{option:1},param:{},bdo:c,"var":c,div:a,object:h,sup:c,dd:a,strike:c,area:{},dir:b,map:q({area:1,form:1,p:1},r,l,n),applet:h,dl:{dt:1,dd:1},del:c,isindex:{},fieldset:q({legend:1},e),thead:f,ul:b,acronym:c,b:c,a:t,blockquote:a,caption:c,i:c,u:c,tbody:f,s:c,address:q(u,d),tt:c,legend:c,q:c,pre:q(g,s),p:c,em:c,dfn:c}}();k.XHTML_DTD=
k.XHTML_DTD});
KISSY.Editor.add("elementpath",function(k){function q(e){var d=u,c=u,f=[];for(e=e;e&&e[0];){if(e[0].nodeType==s.NODE_ELEMENT){if(!this.lastElement)this.lastElement=e;var o=e._4e_name();if(!c){if(!d&&n[o])d=e;if(l[o]){var h;if(h=!d){if(h=o=="div"){a:{h=e;h=h[0]||h;h=h.childNodes;for(var a=0,b=h.length;a<b;a++){var i=h[a];if(i.nodeType==s.NODE_ELEMENT&&t.$block[i.nodeName.toLowerCase()]){h=true;break a}}h=false}h=!h}h=h}if(h)d=e;else c=e}}f.push(e);if(o=="body")break}e=e.parent()}this.block=this.block=
d;this.blockLimit=this.blockLimit=c;this.elements=this.elements=f}var r=KISSY.DOM,t=k.XHTML_DTD,s=k.NODE,u=null,n={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},l={body:1,div:1,table:1,tbody:1,tr:1,td:1,th:1,caption:1,form:1};q.prototype={compare:function(e){var d=this.elements;e=e&&e.elements;if(!e||d.length!=e.length)return false;for(var c=0;c<d.length;c++)if(!r._4e_equals(d[c],e[c]))return false;return true},contains:function(e){for(var d=this.elements,c=0;c<
d.length;c++)if(d[c]._4e_name()in e)return d[c];return u}};k.ElementPath=k.ElementPath=q;var g=q.prototype;k.Utils.extern(g,{compare:g.compare,contains:g.contains})});
KISSY.Editor.add("walker",function(k){function q(f,o){if(this._.end)return n;var h,a=this.range,b,i=this.guard,m=this.type,v=f?"_4e_previousSourceNode":"_4e_nextSourceNode";if(!this._.start){this._.start=1;a.trim();if(a.collapsed){this.end();return n}}if(!f&&!this._.guardLTR){var x=a.endContainer,p=new d(x[0].childNodes[a.endOffset]);this._.guardLTR=function(D,j){return(D=e._4e_wrap(D))&&D[0]&&(!j||!e._4e_equals(x,D))&&(!p[0]||!D._4e_equals(p))&&(D[0].nodeType!=g.NODE_ELEMENT||!j||D._4e_name()!="body")}}if(f&&
!this._.guardRTL){var z=a.startContainer,y=a.startOffset>0&&new d(z[0].childNodes[a.startOffset-1]);this._.guardRTL=function(D,j){return(D=e._4e_wrap(D))&&D[0]&&(!j||!D._4e_equals(z))&&(!y[0]||!D._4e_equals(y))&&(D[0].nodeType!=g.NODE_ELEMENT||!j||D._4e_name()!="body")}}var E=f?this._.guardRTL:this._.guardLTR;b=i?function(D,j){if(E(D,j)===u)return u;return i(D,j)}:E;if(this.current)h=this.current[v](u,m,b);else if(f){h=a.endContainer;if(a.endOffset>0){h=new d(h[0].childNodes[a.endOffset-1]);if(b(h)===
u)h=n}else h=b(h,s)===u?n:h._4e_previousSourceNode(s,m,b)}else{h=a.startContainer;if((h=new d(h[0].childNodes[a.startOffset]))&&h[0]){if(b(h)===u)h=n}else h=b(a.startContainer,s)===u?n:a.startContainer._4e_nextSourceNode(s,m,b)}for(;h&&h[0]&&!this._.end;){this.current=h;if(!this.evaluator||this.evaluator(h)!==u){if(!o)return h}else if(o&&this.evaluator)return u;h=h[v](u,m,b)}this.end();return this.current=n}function r(f){for(var o,h=n;o=q.call(this,f);)h=o;return h}function t(f){this.range=f;this._=
{}}var s=true,u=false,n=null,l=KISSY,g=k.NODE,e=l.DOM,d=l.Node;l.augment(t,{end:function(){this._.end=1},next:function(){return q.call(this)},previous:function(){return q.call(this,s)},checkForward:function(){return q.call(this,u,s)!==u},checkBackward:function(){return q.call(this,s,s)!==u},lastForward:function(){return r.call(this)},lastBackward:function(){return r.call(this,s)},reset:function(){delete this.current;this._={}}});t.blockBoundary=function(f){return function(o){o=e._4e_wrap(o);return!(o&&
o[0].nodeType==g.NODE_ELEMENT&&o._4e_isBlockBoundary(f))}};t.listItemBoundary=function(){return this.blockBoundary({br:1})};t.bookmark=function(f,o){function h(a){return a&&a[0]&&a._4e_name()=="span"&&a.attr("_ke_bookmark")}return function(a){var b,i;b=a&&a[0]&&a[0].nodeType==g.NODE_TEXT&&(i=a.parent())&&h(i);b=f?b:b||h(a);return o^b}};t.whitespaces=function(f){return function(o){o=(o=o[0]||o)&&o.nodeType==g.NODE_TEXT&&!l.trim(o.nodeValue);return f^o}};t.invisible=function(f){var o=t.whitespaces();
return function(h){h=o(h)||h[0].nodeType==g.NODE_ELEMENT&&!h[0].offsetHeight;return f^h}};k.Walker=t;k.Walker=t;var c=t.prototype;k.Utils.extern(c,{end:c.end,next:c.next,previous:c.previous,checkForward:c.checkForward,checkBackward:c.checkBackward,lastForward:c.lastForward,lastBackward:c.lastBackward,reset:c.reset});k.Utils.extern(t,{blockBoundary:t.blockBoundary,listItemBoundary:t.listItemBoundary,bookmark:t.bookmark,whitespaces:t.whitespaces,invisible:t.invisible})});
KISSY.Editor.add("range",function(k){function q(j){this.endOffset=this.endContainer=this.startOffset=this.startContainer=e;this.collapsed=l;this.document=j}function r(j){var A=j[0].nodeType!=c.NODE_TEXT&&j._4e_name()in m.$removeEmpty,w=!d.trim(j[0].nodeValue);j=!!j.parent().attr("_ke_bookmark");return A||w||j}function t(j){return!y(j)&&!E(j)}function s(j){var A=g,w=h.bookmark(l);return function(C){if(w(C))return l;if(C[0].nodeType==c.NODE_TEXT){if(d.trim(C[0].nodeValue).length)return g}else if(C[0].nodeType==
c.NODE_ELEMENT)if(!z[C._4e_name()])if(!j&&!i.ie&&C._4e_name()=="br"&&!A)A=l;else return g;return l}}function u(j,A){function w(C){return C&&C.nodeName=="span"&&C.getAttribute("_ke_bookmark")}return function(C){var B,F;B=C&&!C.nodeName&&(F=C.parentNode)&&w(F);B=j?B:B||w(C);return A^B}}function n(j){return function(A){A=(A=A[0]||A)&&A.nodeType==c.NODE_TEXT&&!d.trim(A.nodeValue);return j^A}}k.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};k.RANGE=k.RANGE;var l=true,g=false,e=null,d=KISSY,c=k.NODE,f=k.RANGE,o=k.POSITION,h=k.Walker,a=d.DOM,b=k.Utils.getByAddress,i=d.UA,m=k.XHTML_DTD,v=k.ElementPath,x=d.Node,p={area:1,base:1,br:1,col:1,hr:1,img:1,input:1,link:1,meta:1,param:1};q.prototype.toString=function(){var j=[];j.push((this.startContainer[0].id||this.startContainer[0].nodeName)+":"+this.startOffset);j.push((this.endContainer[0].id||
this.endContainer[0].nodeName)+":"+this.endOffset);return j.join("<br/>")};d.augment(q,{updateCollapsed:function(){this.collapsed=this.startContainer&&this.endContainer&&a._4e_equals(this.startContainer,this.endContainer)&&this.startOffset==this.endOffset},optimize:function(){var j=this.startContainer,A=this.startOffset;if(j[0].nodeType!=c.NODE_ELEMENT)if(A)A>=j[0].nodeValue.length&&this.setStartAfter(j);else this.setStartBefore(j);j=this.endContainer;A=this.endOffset;if(j[0].nodeType!=c.NODE_ELEMENT)if(A)A>=
j[0].nodeValue.length&&this.setEndAfter(j);else this.setEndBefore(j)},setStartAfter:function(j){this.setStart(j.parent(),j._4e_index()+1)},setStartBefore:function(j){this.setStart(j.parent(),j._4e_index())},setEndAfter:function(j){this.setEnd(j.parent(),j._4e_index()+1)},setEndBefore:function(j){this.setEnd(j.parent(),j._4e_index())},optimizeBookmark:function(){var j=this.startContainer,A=this.endContainer;j&&j._4e_name()=="span"&&j.attr("_ke_bookmark")&&this.setStartAt(j,f.POSITION_BEFORE_START);
A&&A._4e_name()=="span"&&A.attr("_ke_bookmark")&&this.setEndAt(A,f.POSITION_AFTER_END)},setStart:function(j,A){if(j[0].nodeType==c.NODE_ELEMENT&&p[j._4e_name()]){j=j.parent();A=j._4e_index()}this.startContainer=j;this.startOffset=A;if(!this.endContainer){this.endContainer=j;this.endOffset=A}this.updateCollapsed()},setEnd:function(j,A){if(j[0].nodeType==c.NODE_ELEMENT&&p[j._4e_name()]){j=j.parent();A=j._4e_index()+1}this.endContainer=j;this.endOffset=A;if(!this.startContainer){this.startContainer=
j;this.startOffset=A}this.updateCollapsed()},setStartAt:function(j,A){switch(A){case f.POSITION_AFTER_START:this.setStart(j,0);break;case f.POSITION_BEFORE_END:j[0].nodeType==c.NODE_TEXT?this.setStart(j,j[0].nodeValue.length):this.setStart(j,j[0].childNodes.length);break;case f.POSITION_BEFORE_START:this.setStartBefore(j);break;case f.POSITION_AFTER_END:this.setStartAfter(j)}this.updateCollapsed()},setEndAt:function(j,A){switch(A){case f.POSITION_AFTER_START:this.setEnd(j,0);break;case f.POSITION_BEFORE_END:j[0].nodeType==
c.NODE_TEXT?this.setEnd(j,j[0].nodeValue.length):this.setEnd(j,j[0].childNodes.length);break;case f.POSITION_BEFORE_START:this.setEndBefore(j);break;case f.POSITION_AFTER_END:this.setEndAfter(j)}this.updateCollapsed()},execContentsAction:function(j,A){var w=this.startContainer,C=this.endContainer,B=this.startOffset,F=this.endOffset,O,Q=this.document,P;this.optimizeBookmark();if(C[0].nodeType==c.NODE_TEXT)C=C._4e_splitText(F);else if(C[0].childNodes.length>0)if(F>=C[0].childNodes.length){C=new x(C[0].appendChild(Q.createTextNode("")));
P=l}else C=new x(C[0].childNodes[F]);if(w[0].nodeType==c.NODE_TEXT){w._4e_splitText(B);if(w._4e_equals(C))C=new x(w[0].nextSibling)}else if(B)if(B>=w[0].childNodes.length){O=new x(Q.createTextNode(""));w.append(O);w=O;O=l}else w=new x(w[0].childNodes[B].previousSibling);else{O=new x(Q.createTextNode(""));w.prepend(O);w=O;O=l}B=w._4e_parents();F=C._4e_parents();var M,S,R;for(M=0;M<B.length;M++){S=B[M];R=F[M];if(!S._4e_equals(R))break}Q=A;for(var T,X,Y,H=M;H<B.length;H++){T=B[H];X=Q&&!T._4e_equals(w)?
Q.appendChild(T._4e_clone()[0]):null;for(T=T[0].nextSibling;T;){if(a._4e_equals(F[H],T)||a._4e_equals(C,T))break;Y=T.nextSibling;if(j==2)Q.appendChild(T.cloneNode(l));else{a._4e_remove(T);j==1&&Q.appendChild(T)}T=Y}if(X)Q=X}Q=A;for(M=M;M<F.length;M++){T=F[M];X=Q&&j>0&&!T._4e_equals(C)?Q.appendChild(T._4e_clone()[0]):null;if(!B[M]||!T.parent()._4e_equals(B[M].parent()))for(T=T[0].previousSibling;T;){if(a._4e_equals(B[M],T)||a._4e_equals(w,T))break;Y=T.previousSibling;if(j==2)Q.insertBefore(T.cloneNode(l),
Q.firstChild);else{a._4e_remove(T);j==1&&Q.insertBefore(T,Q.firstChild)}T=Y}if(X)Q=X}if(j==2){R=this.startContainer[0];if(R.nodeType==c.NODE_TEXT&&R.nextSibling&&R.nextSibling.nodeType==c.NODE_TEXT){R.data+=R.nextSibling.data;R.parentNode.removeChild(R.nextSibling)}R=this.endContainer[0];if(R.nodeType==c.NODE_TEXT&&R.nextSibling&&R.nextSibling.nodeType==c.NODE_TEXT){R.data+=R.nextSibling.data;R.parentNode.removeChild(R.nextSibling)}}else{if(S&&R&&(!w.parent()._4e_equals(S.parent())||!C.parent()._4e_equals(R.parent()))){S=
R._4e_index();O&&R.parent()._4e_equals(w.parent())&&S--;this.setStart(R.parent(),S)}this.collapse(l)}O&&w._4e_remove();P&&C[0].parentNode&&C._4e_remove()},collapse:function(j){if(j){this.endContainer=this.startContainer;this.endOffset=this.startOffset}else{this.startContainer=this.endContainer;this.startOffset=this.endOffset}this.collapsed=l},clone:function(){var j=new q(this.document);j.startContainer=this.startContainer;j.startOffset=this.startOffset;j.endContainer=this.endContainer;j.endOffset=
this.endOffset;j.collapsed=this.collapsed;return j},getEnclosedNode:function(){var j=this.clone();j.optimize();if(j.startContainer[0].nodeType!=c.NODE_ELEMENT||j.endContainer[0].nodeType!=c.NODE_ELEMENT)return e;var A=new k.Walker(j),w=u(l,undefined),C=n(l);j.evaluator=function(B){return C(B)&&w(B)};j=A.next();A.reset();A=A.previous();return j&&j._4e_equals(A)?j:e},shrink:function(j,A){if(!this.collapsed){j=j||f.SHRINK_TEXT;var w=this.clone(),C=this.startContainer,B=this.endContainer,F=this.startOffset,
O=this.endOffset,Q=1,P=1;if(C&&C[0].nodeType==c.NODE_TEXT)if(F)if(F>=C[0].nodeValue.length)w.setStartAfter(C);else{w.setStartBefore(C);Q=0}else w.setStartBefore(C);if(B&&B[0].nodeType==c.NODE_TEXT)if(O)if(O>=B[0].nodeValue.length)w.setEndAfter(B);else{w.setEndAfter(B);P=0}else w.setEndBefore(B);w=new h(w);w.evaluator=function(S){S=S[0]||S;return S.nodeType==(j==f.SHRINK_ELEMENT?c.NODE_ELEMENT:c.NODE_TEXT)};var M;w.guard=function(S,R){S=S[0]||S;if(j==f.SHRINK_ELEMENT&&S.nodeType==c.NODE_TEXT)return g;
if(R&&S==M)return g;if(!R&&S.nodeType==c.NODE_ELEMENT)M=S;return l};if(Q)(C=w[j==f.SHRINK_ELEMENT?"lastForward":"next"]())&&this.setStartAt(C,A?f.POSITION_AFTER_START:f.POSITION_BEFORE_START);if(P){w.reset();(w=w[j==f.SHRINK_ELEMENT?"lastBackward":"previous"]())&&this.setEndAt(w,A?f.POSITION_BEFORE_END:f.POSITION_AFTER_END)}return!!(Q||P)}},getTouchedStartNode:function(){var j=this.startContainer;if(this.collapsed||j[0].nodeType!=c.NODE_ELEMENT)return j;return j.childNodes[this.startOffset]||j},createBookmark2:function(j){var A=
this.startContainer,w=this.endContainer,C=this.startOffset,B=this.endOffset,F,O;if(!A||!w)return{start:0,end:0};if(j){if(A[0].nodeType==c.NODE_ELEMENT)if((F=new x(A[0].childNodes[C]))&&F[0]&&F[0].nodeType==c.NODE_TEXT&&C>0&&F[0].previousSibling.nodeType==c.NODE_TEXT){A=F;C=0}for(;A[0].nodeType==c.NODE_TEXT&&(O=A._4e_previous())&&O[0].nodeType==c.NODE_TEXT;){A=O;C+=O[0].nodeValue.length}if(!this.collapsed){if(w[0].nodeType==c.NODE_ELEMENT)if((F=new x(w[0].childNodes[B]))&&F[0]&&F[0].nodeType==c.NODE_TEXT&&
B>0&&F[0].previousSibling.nodeType==c.NODE_TEXT){w=F;B=0}for(;w[0].nodeType==c.NODE_TEXT&&(O=w._4e_previous())&&O[0].nodeType==c.NODE_TEXT;){w=O;B+=O[0].nodeValue.length}}}return{start:A._4e_address(j),end:this.collapsed?e:w._4e_address(j),startOffset:C,endOffset:B,normalized:j,is2:l}},createBookmark:function(j){var A,w,C,B,F=this.collapsed;A=new x("<span>",e,this.document);A.attr("_ke_bookmark",1);A.css("display","none");A.html("&nbsp;");if(j){C=d.guid("ke_bm_");A.attr("id",C+"S")}if(!F){w=A._4e_clone();
w.html("&nbsp;");j&&w.attr("id",C+"E");B=this.clone();B.collapse();B.insertNode(w)}B=this.clone();B.collapse(l);B.insertNode(A);if(w){this.setStartAfter(A);this.setEndBefore(w)}else this.moveToPosition(A,f.POSITION_AFTER_END);return{startNode:j?C+"S":A,endNode:j?C+"E":w,serializable:j,collapsed:F}},moveToPosition:function(j,A){this.setStartAt(j,A);this.collapse(l)},trim:function(j,A){var w=this.startContainer,C=this.startOffset,B=this.collapsed;if((!j||B)&&w[0]&&w[0].nodeType==c.NODE_TEXT){if(C)if(C>=
w[0].nodeValue.length){C=w._4e_index()+1;w=w.parent()}else{var F=w._4e_splitText(C);C=w._4e_index()+1;w=w.parent();if(a._4e_equals(this.startContainer,this.endContainer))this.setEnd(F,this.endOffset-this.startOffset);else if(a._4e_equals(w,this.endContainer))this.endOffset+=1}else{C=w._4e_index();w=w.parent()}this.setStart(w,C);if(B){this.collapse(l);return}}w=this.endContainer;C=this.endOffset;if(!(A||B)&&w[0]&&w[0].nodeType==c.NODE_TEXT){if(C){C>=w.nodeValue.length||w._4e_splitText(C);C=w._4e_index()+
1}else C=w._4e_index();w=w.parent();this.setEnd(w,C)}},insertNode:function(j){this.optimizeBookmark();this.trim(g,l);var A=this.startContainer;A[0].insertBefore(j[0]||j,A[0].childNodes[this.startOffset]||null);a._4e_equals(j.parent(),this.endContainer)&&this.endOffset++;this.setStartBefore(j)},moveToBookmark:function(j){if(j.is2){var A=b(this.document,j.start,j.normalized),w=j.startOffset,C=j.end&&b(this.document,j.end,j.normalized);j=j.endOffset;this.setStart(A,w);C?this.setEnd(C,j):this.collapse(l)}else{A=
(w=j.serializable)?d.one("#"+j.startNode,this.document):j.startNode;j=w?d.one("#"+j.endNode,this.document):j.endNode;this.setStartBefore(A);A._4e_remove();if(j&&j[0]){this.setEndBefore(j);j._4e_remove()}else this.collapse(l)}},getCommonAncestor:function(j,A){var w=this.startContainer,C=this.endContainer;w=a._4e_equals(w,C)?j&&w[0].nodeType==c.NODE_ELEMENT&&this.startOffset==this.endOffset-1?new x(w[0].childNodes[this.startOffset]):w:w._4e_commonAncestor(C);return A&&w[0].nodeType==c.NODE_TEXT?w.parent():
w},enlarge:function(j){switch(j){case f.ENLARGE_ELEMENT:if(this.collapsed)break;j=this.getCommonAncestor();var A=new x(this.document.body),w,C,B,F,O,Q=g,P,M;P=this.startContainer;M=this.startOffset;if(P[0].nodeType==c.NODE_TEXT){if(M){P=!d.trim(P[0].nodeValue.substring(0,M)).length&&P;Q=!!P}if(P)if(!(F=P[0].previousSibling))B=P.parent()}else{if(M)F=P[0].childNodes[M-1]||P[0].lastChild;F||(B=P)}for(;B||F;){if(B&&!F){if(!O&&a._4e_equals(B,j))O=l;if(!A.contains(B))break;if(!Q||B.css("display")!="inline"){Q=
g;if(O)w=B;else this.setStartBefore(B)}F=B[0].previousSibling}for(;F;){P=g;if(F.nodeType==c.NODE_TEXT){M=F.nodeValue;if(/[^\s\ufeff]/.test(M))F=e;P=/[\s\ufeff]$/.test(M)}else if(F.offsetWidth>0&&!F.getAttribute("_ke_bookmark"))if(Q&&m.$removeEmpty[F.nodeName.toLowerCase()]){M=a.text(F);if(/[^\s\ufeff]/.test(M))F=e;else for(var S=F.all||F.getElementsByTagName("*"),R=0,T;T=S[R++];)if(!m.$removeEmpty[T.nodeName.toLowerCase()]){F=e;break}if(F)P=!!M.length}else F=e;if(P)if(Q)if(O)w=B;else B&&this.setStartBefore(B);
else Q=l;if(F){P=F.previousSibling;if(!B&&!P){B=new x(F);F=e;break}F=P}else B=e}if(B)B=B.parent()}P=this.endContainer;M=this.endOffset;B=F=e;O=Q=g;if(P[0].nodeType==c.NODE_TEXT){P=!d.trim(P[0].nodeValue.substring(M)).length&&P;Q=!(P&&P[0].nodeValue.length);if(P)if(!(F=P[0].nextSibling))B=P.parent()}else(F=P[0].childNodes[M])||(B=P);for(;B||F;){if(B&&!F){if(!O&&a._4e_equals(B,j))O=l;if(!A.contains(B))break;if(!Q||B.css("display")!="inline"){Q=g;if(O)C=B;else B&&this.setEndAfter(B)}F=B[0].nextSibling}for(;F;){P=
g;if(F.nodeType==c.NODE_TEXT){M=F.nodeValue;if(/[^\s\ufeff]/.test(M))F=e;P=/^[\s\ufeff]/.test(M)}else if(F.offsetWidth>0&&!F.getAttribute("_ke_bookmark"))if(Q&&m.$removeEmpty[F.nodeName.toLowerCase()]){M=a.text(F);if(/[^\s\ufeff]/.test(M))F=e;else{S=F.all||F.getElementsByTagName("*");for(R=0;T=S[R++];)if(!m.$removeEmpty[T.nodeName.toLowerCase()]){F=e;break}}if(F)P=!!M.length}else F=e;if(P)if(Q)if(O)C=B;else this.setEndAfter(B);if(F){P=F.nextSibling;if(!B&&!P){B=new x(F);F=e;break}F=P}else B=e}if(B)B=
B.parent()}if(w&&C){j=w.contains(C)?C:w;this.setStartBefore(j);this.setEndAfter(j)}break;case f.ENLARGE_BLOCK_CONTENTS:case f.ENLARGE_LIST_ITEM_CONTENTS:B=new q(this.document);A=new x(this.document.body);B.setStartAt(A,f.POSITION_AFTER_START);B.setEnd(this.startContainer,this.startOffset);B=new h(B);var X,Y,H=h.blockBoundary(j==f.ENLARGE_LIST_ITEM_CONTENTS?{br:1}:e),K=function(G){var J=H(G);J||(X=G);return J};w=function(G){var J=K(G);if(!J&&G[0]&&G._4e_name()=="br")Y=G;return J};B.guard=K;B=B.lastBackward();
X=X||A;this.setStartAt(X,X._4e_name()!="br"&&(!B&&this.checkStartOfBlock()||B&&X.contains(B))?f.POSITION_AFTER_START:f.POSITION_AFTER_END);B=this.clone();B.collapse();B.setEndAt(A,f.POSITION_BEFORE_END);B=new h(B);B.guard=j==f.ENLARGE_LIST_ITEM_CONTENTS?w:K;X=e;B=B.lastForward();X=X||A;this.setEndAt(X,!B&&this.checkEndOfBlock()||B&&X.contains(B)?f.POSITION_BEFORE_END:f.POSITION_BEFORE_START);Y&&this.setEndAfter(Y)}},checkStartOfBlock:function(){var j=this.startContainer,A=this.startOffset;if(A&&j[0].nodeType==
c.NODE_TEXT)if(d.trim(j[0].nodeValue.substring(0,A)).length)return g;this.trim();j=new v(this.startContainer);A=this.clone();A.collapse(l);A.setStartAt(j.block||j.blockLimit,f.POSITION_AFTER_START);j=new h(A);j.evaluator=s(l);return j.checkBackward()},checkEndOfBlock:function(){var j=this.endContainer,A=this.endOffset;if(j[0].nodeType==c.NODE_TEXT)if(d.trim(j[0].nodeValue.substring(A)).length)return g;this.trim();j=new v(this.endContainer);A=this.clone();A.collapse(g);A.setEndAt(j.block||j.blockLimit,
f.POSITION_BEFORE_END);j=new h(A);j.evaluator=s(g);return j.checkForward()},deleteContents:function(){this.collapsed||this.execContentsAction(0)},extractContents:function(){var j=this.document.createDocumentFragment();this.collapsed||this.execContentsAction(1,j);return j},checkBoundaryOfElement:function(j,A){var w=this.clone();w[A==f.START?"setStartAt":"setEndAt"](j,A==f.START?f.POSITION_AFTER_START:f.POSITION_BEFORE_END);w=new h(w);w.evaluator=r;return w[A==f.START?"checkBackward":"checkForward"]()},
getBoundaryNodes:function(){var j=this.startContainer,A=this.endContainer,w=this.startOffset,C=this.endOffset,B;if(j[0].nodeType==c.NODE_ELEMENT){B=j[0].childNodes.length;if(B>w)j=new x(j[0].childNodes[w]);else if(B<1)j=j._4e_previousSourceNode();else{for(j=j[0];j.lastChild;)j=j.lastChild;j=new x(j);j=j._4e_nextSourceNode()||j}}if(A[0].nodeType==c.NODE_ELEMENT){B=A[0].childNodes.length;if(B>C)A=(new x(A[0].childNodes[C]))._4e_previousSourceNode(l);else if(B<1)A=A._4e_previousSourceNode();else{for(A=
A[0];A.lastChild;)A=A.lastChild;A=new x(A)}}if(j._4e_position(A)&o.POSITION_FOLLOWING)j=A;return{startNode:j,endNode:A}},fixBlock:function(j,A){var w=this.createBookmark(),C=new x(this.document.createElement(A));this.collapse(j);this.enlarge(f.ENLARGE_BLOCK_CONTENTS);C[0].appendChild(this.extractContents());C._4e_trim();i.ie||C._4e_appendBogus();for(var B=C[0].childNodes,F=0;F<B.length;F++){var O=B[F];O.nodeType==8&&this.insertNode(new x(O))}this.insertNode(C);this.moveToBookmark(w);return C},splitBlock:function(j){var A=
new v(this.startContainer),w=new v(this.endContainer),C=A.block,B=w.block,F=e;if(!A.blockLimit._4e_equals(w.blockLimit))return e;if(j!="br"){if(!C){C=this.fixBlock(l,j);B=(new v(this.endContainer)).block}B||(B=this.fixBlock(g,j))}j=C&&this.checkStartOfBlock();A=B&&this.checkEndOfBlock();this.deleteContents();if(C&&a._4e_equals(C,B))if(A){F=new v(this.startContainer);this.moveToPosition(B,f.POSITION_AFTER_END);B=e}else if(j){F=new v(this.startContainer);this.moveToPosition(C,f.POSITION_BEFORE_START);
C=e}else{B=this.splitElement(C);!i.ie&&!d.inArray(C._4e_name(),["ul","ol"])&&C._4e_appendBogus()}return{previousBlock:C,nextBlock:B,wasStartOfBlock:j,wasEndOfBlock:A,elementPath:F}},splitElement:function(j){if(!this.collapsed)return e;this.setEndAt(j,f.POSITION_BEFORE_END);var A=this.extractContents(),w=j._4e_clone(g);w[0].appendChild(A);w.insertAfter(j);this.moveToPosition(j,f.POSITION_AFTER_END);return w},moveToElementEditablePosition:function(j,A){var w,C=k.XHTML_DTD;if(C.$empty[j._4e_name()])return g;
for(;j&&j[0].nodeType==c.NODE_ELEMENT;){if(w=j._4e_isEditable())this.moveToPosition(j,A?f.POSITION_BEFORE_END:f.POSITION_AFTER_START);else if(C.$inline[j._4e_name()]){this.moveToPosition(j,A?f.POSITION_AFTER_END:f.POSITION_BEFORE_START);return l}if((j=C.$empty[j._4e_name()]?j[A?"_4e_previous":"_4e_next"](t):j[A?"_4e_last":"_4e_first"](t))&&j[0].nodeType==c.NODE_TEXT){this.moveToPosition(j,A?f.POSITION_AFTER_END:f.POSITION_BEFORE_START);return l}}return w},selectNodeContents:function(j){this.setStart(j,
0);this.setEnd(j,j[0].nodeType==c.NODE_TEXT?j[0].nodeValue.length:j[0].childNodes.length)}});var z={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},y=new h.whitespaces,E=new h.bookmark;k.Range=q;k.Range=q;var D=q.prototype;k.Utils.extern(D,{updateCollapsed:D.updateCollapsed,optimize:D.optimize,setStartAfter:D.setStartAfter,setEndAfter:D.setEndAfter,setStartBefore:D.setStartBefore,
setEndBefore:D.setEndBefore,optimizeBookmark:D.optimizeBookmark,setStart:D.setStart,setEnd:D.setEnd,setStartAt:D.setStartAt,setEndAt:D.setEndAt,execContentsAction:D.execContentsAction,collapse:D.collapse,clone:D.clone,getEnclosedNode:D.getEnclosedNode,shrink:D.shrink,getTouchedStartNode:D.getTouchedStartNode,createBookmark2:D.createBookmark2,createBookmark:D.createBookmark,moveToPosition:D.moveToPosition,trim:D.trim,insertNode:D.insertNode,moveToBookmark:D.moveToBookmark,getCommonAncestor:D.getCommonAncestor,
enlarge:D.enlarge,checkStartOfBlock:D.checkStartOfBlock,checkEndOfBlock:D.checkEndOfBlock,deleteContents:D.deleteContents,extractContents:D.extractContents,checkBoundaryOfElement:D.checkBoundaryOfElement,getBoundaryNodes:D.getBoundaryNodes,fixBlock:D.fixBlock,splitBlock:D.splitBlock,splitElement:D.splitElement,moveToElementEditablePosition:D.moveToElementEditablePosition,selectNodeContents:D.selectNodeContents})});
KISSY.Editor.add("domiterator",function(k){function q(h){if(!(arguments.length<1)){this.range=h;this.forceBrBreak=t;this.enlargeBr=r;this.enforceRealBlocks=t;this._||(this._={})}}var r=true,t=false,s=KISSY,u=s.UA,n=k.Walker,l=k.Range,g=k.RANGE,e=k.NODE,d=k.ElementPath,c=s.Node,f=s.DOM,o=/^[\r\n\t ]*$/;s.augment(q,{getNextParagraph:function(h){var a,b,i,m,v;if(!this._.lastNode){b=this.range.clone();b.shrink(g.SHRINK_ELEMENT,r);b.enlarge(this.forceBrBreak||!this.enlargeBr?g.ENLARGE_LIST_ITEM_CONTENTS:
g.ENLARGE_BLOCK_CONTENTS);var x=new n(b),p=n.bookmark(r,r);x.evaluator=p;this._.nextNode=x.next();x=new n(b);x.evaluator=p;x=x.previous();this._.lastNode=x._4e_nextSourceNode(r);if(this._.lastNode&&this._.lastNode[0].nodeType==e.NODE_TEXT&&!s.trim(this._.lastNode[0].nodeValue)&&this._.lastNode.parent()._4e_isBlockBoundary()){p=new l(b.document);p.moveToPosition(this._.lastNode,g.POSITION_AFTER_END);if(p.checkEndOfBlock()){p=new d(p.endContainer);this._.lastNode=(p.block||p.blockLimit)._4e_nextSourceNode(r)}}if(!this._.lastNode){this._.lastNode=
this._.docEndMarker=new c(b.document.createTextNode(""));f.insertAfter(this._.lastNode[0],x[0])}b=null}p=this._.nextNode;x=this._.lastNode;for(this._.nextNode=null;p;){var z=t,y=p[0].nodeType!=e.NODE_ELEMENT,E=t;if(y){if(p[0].nodeType==e.NODE_TEXT)if(o.test(p[0].nodeValue))y=t}else{var D=p._4e_name();if(p._4e_isBlockBoundary(this.forceBrBreak&&{br:1})){if(D=="br")y=r;else if(!b&&!p[0].childNodes.length&&D!="hr"){a=p;i=p._4e_equals(x);break}if(b){b.setEndAt(p,g.POSITION_BEFORE_START);if(D!="br")this._.nextNode=
p}z=r}else{if(p[0].firstChild){if(!b){b=new l(this.range.document);b.setStartAt(p,g.POSITION_BEFORE_START)}p=new c(p[0].firstChild);continue}y=r}}if(y&&!b){b=new l(this.range.document);b.setStartAt(p,g.POSITION_BEFORE_START)}i=(!z||y)&&p._4e_equals(x);if(b&&!z)for(;!p[0].nextSibling&&!i;){D=p.parent();if(D._4e_isBlockBoundary(this.forceBrBreak&&{br:1})){z=r;i||D._4e_equals(x);break}p=D;y=r;i=p._4e_equals(x);E=r}y&&b.setEndAt(p,g.POSITION_AFTER_END);p=p._4e_nextSourceNode(E,null,x);if((i=!p)||z&&b)break}if(!a){if(!b){this._.docEndMarker&&
this._.docEndMarker._4e_remove();return this._.nextNode=null}a=new d(b.startContainer);p=a.blockLimit;z={div:1,th:1,td:1};a=a.block;if((!a||!a[0])&&!this.enforceRealBlocks&&z[p._4e_name()]&&b.checkStartOfBlock()&&b.checkEndOfBlock())a=p;else if(!a||this.enforceRealBlocks&&a._4e_name()=="li"){a=new c(this.range.document.createElement(h||"p"));a[0].appendChild(b.extractContents());a._4e_trim();b.insertNode(a);m=v=r}else if(a._4e_name()!="li"){if(!b.checkStartOfBlock()||!b.checkEndOfBlock()){a=a._4e_clone(t);
a[0].appendChild(b.extractContents());a._4e_trim();v=b.splitBlock();m=!v.wasStartOfBlock;v=!v.wasEndOfBlock;b.insertNode(a)}}else if(!i)this._.nextNode=a._4e_equals(x)?null:b.getBoundaryNodes().endNode._4e_nextSourceNode(r,null,x)}if(m){b=new c(a[0].previousSibling);if(b[0]&&b[0].nodeType==e.NODE_ELEMENT)if(b._4e_name()=="br")b._4e_remove();else b[0].lastChild&&f._4e_name(b[0].lastChild)=="br"&&f._4e_remove(b[0].lastChild)}if(v){b=n.bookmark(t,r);m=new c(a[0].lastChild);if(m[0]&&m[0].nodeType==e.NODE_ELEMENT&&
m._4e_name()=="br")if(u.ie||m._4e_previous(b)||m._4e_next(b))m._4e_remove()}if(!this._.nextNode)this._.nextNode=i||a._4e_equals(x)?null:a._4e_nextSourceNode(r,null,x);return a}});l.prototype.createIterator=function(){return new q(this)}});
KISSY.Editor.add("selection",function(k){function q(z){this.document=this.document=z;this._={cache:{}};if(a){var y=this.getNative().createRange();if(!y||y.item&&y.item(0).ownerDocument!=z||y.parentElement&&y.parentElement().ownerDocument!=z)this.isInvalid=s}}function r(z){z=new q(z);return!z||z.isInvalid?n:z}function t(z){var y=z.document,E=new c(y.body),D=new c(y.documentElement);if(g.ie){g.ieEngine<8&&D.on("click",function(M){(new c(M.target))._4e_name()==="html"&&z.getSelection().getNative().createRange().select()});
var j,A,w=1;D.on("mousedown",function(){w=0});D.on("mouseup",function(){w=1});E.on("focusin",function(M){if((new c(M.target))._4e_name()=="body")if(j){try{w&&j.select()}catch(S){}j=n}});E.on("focus",function(){A=s;B()});E.on("beforedeactivate",function(M){if(!M.relatedTarget){C();w=1}});z.on("blur",function(){try{var M=document.documentElement||document.body,S=M.scrollTop,R=M.scrollLeft;y&&y.selection.empty();M.scrollTop=S;M.scrollLeft=R}catch(T){}});E.on("mousedown",function(){C()});E.on("mouseup",
function(){A=s;setTimeout(function(){B(s)},0)});var C=function(){A=u},B=function(M){if(A){var S=z.document,R=z.getSelection(),T=R&&R.getType(),X=R&&S.selection;if(M&&X&&T==f.SELECTION_NONE)if(!S.queryCommandEnabled("InsertImage")){setTimeout(function(){B(s)},50);return}var Y;if(!(X&&T==f.SELECTION_TEXT&&(Y=e._4e_name(R.getStartElement()))&&Y in{input:1,textarea:1})){j=X&&X.createRange();z._monitor()}}};E.on("keydown",C);E.on("keyup",function(){A=s;B()});d.on(y,"selectionchange",B)}else{d.on(y,"mouseup",
z._monitor,z);d.on(y,"keyup",z._monitor,z)}var F={table:1,pre:1},O=/\s*<(p|div|address|h\d|center)[^>]*>\s*(?:<br[^>]*>|&nbsp;|\u00A0|&#160;|(<!--[\s\S]*?--\>))?\s*(:?<\/\1>)?(?=\s*$|<\/body>)/gi,Q=k.Walker.whitespaces(s),P=function(M){return Q(M)&&M&&M[0].nodeType!=8};z.on("selectionChange",function(M){var S=M.path;M=(M=M.selection)&&M.getRanges()[0];if(!(!M||!M.collapsed||S.block))if(S.blockLimit._4e_name()=="body")if(S=M.fixBlock(s,"p")){if(S._4e_outerHtml().match(O)){var R=S._4e_next(P);if(R&&
R[0].nodeType==h.NODE_ELEMENT&&!F[R._4e_name()]){M.moveToElementEditablePosition(R);S._4e_remove()}else if((R=S._4e_previous(P))&&R[0].nodeType==h.NODE_ELEMENT&&!F[R._4e_name()]){M.moveToElementEditablePosition(R,R._4e_outerHtml().match(O)?u:s);S._4e_remove()}}M.select();a||z.notifySelectionChange()}})}k.SELECTION={SELECTION_NONE:1,SELECTION_TEXT:2,SELECTION_ELEMENT:3};var s=true,u=false,n=null,l=KISSY,g=l.UA,e=l.DOM,d=l.Event,c=l.Node,f=k.SELECTION,o=k.RANGE,h=k.NODE,a=!window.getSelection,b=k.Walker,
i=k.Range,m={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};l.augment(q,{getNative:!a?function(){var z=this._.cache;return z.nativeSel||(z.nativeSel=e._4e_getWin(this.document).getSelection())}:function(){var z=this._.cache;return z.nativeSel||(z.nativeSel=this.document.selection)},getType:!a?function(){var z=this._.cache;if(z.type)return z.type;var y=f.SELECTION_TEXT,E=this.getNative();if(E){if(E.rangeCount==
1){E=E.getRangeAt(0);var D=E.startContainer;if(D==E.endContainer&&D.nodeType==h.NODE_ELEMENT&&E.endOffset-E.startOffset===1&&m[D.childNodes[E.startOffset].nodeName.toLowerCase()])y=f.SELECTION_ELEMENT}}else y=f.SELECTION_NONE;return z.type=y}:function(){var z=this._.cache;if(z.type)return z.type;var y=f.SELECTION_NONE;try{var E=this.getNative(),D=E.type;if(D=="Text")y=f.SELECTION_TEXT;if(D=="Control")y=f.SELECTION_ELEMENT;if(E.createRange().parentElement)y=f.SELECTION_TEXT}catch(j){}return z.type=
y},getRanges:a?function(){var z=function(y,E){y=y.duplicate();y.collapse(E);for(var D=y.parentElement(),j=D.childNodes,A,w=0;w<j.length;w++){var C=j[w];if(C.nodeType==h.NODE_ELEMENT){A=y.duplicate();A.moveToElementText(C);C=A.compareEndPoints("StartToStart",y);var B=A.compareEndPoints("EndToStart",y);A.collapse();if(C>0)break;else if(!C||B==1&&C==-1)return{container:D,offset:w};else if(!B)return{container:D,offset:w+1};A=n}}if(!A){A=y.duplicate();A.moveToElementText(D);A.collapse(u)}A.setEndPoint("StartToStart",
y);A=String(A.text).replace(/\r\n|\r/g,"\n").length;try{for(;A>0;)A-=j[--w].nodeValue.length}catch(F){A=0}return A===0?{container:D,offset:w}:{container:j[w],offset:-A}};return function(){var y=this._.cache;if(y.ranges)return y.ranges;var E=this.getNative(),D=E&&E.createRange(),j=this.getType();if(!E)return[];if(j==f.SELECTION_TEXT){E=new i(this.document);j=z(D,s);E.setStart(new c(j.container),j.offset);j=z(D);E.setEnd(new c(j.container),j.offset);return y.ranges=[E]}else if(j==f.SELECTION_ELEMENT){y=
y.ranges=[];for(j=0;j<D.length;j++){var A=D.item(j),w=A.parentNode,C=0;for(E=new i(this.document);C<w.childNodes.length&&w.childNodes[C]!=A;C++);E.setStart(new c(w),C);E.setEnd(new c(w),C+1);y.push(E)}return y}return y.ranges=[]}}():function(){var z=this._.cache;if(z.ranges)return z.ranges;var y=[],E=this.getNative();if(!E)return[];for(var D=0;D<E.rangeCount;D++){var j=E.getRangeAt(D),A=new i(this.document);A.setStart(new c(j.startContainer),j.startOffset);A.setEnd(new c(j.endContainer),j.endOffset);
y.push(A)}return z.ranges=y},getStartElement:function(){var z=this._.cache;if(z.startElement!==undefined)return z.startElement;var y,E=this.getNative();switch(this.getType()){case f.SELECTION_ELEMENT:return this.getSelectedElement();case f.SELECTION_TEXT:var D=this.getRanges()[0];if(D)if(!D.collapsed){for(D.optimize();s;){y=D.startContainer;if(D.startOffset==(y[0].nodeType===h.NODE_ELEMENT?y[0].childNodes.length:y[0].nodeValue.length)&&!y._4e_isBlockBoundary())D.setStartAfter(y);else break}y=D.startContainer;
if(y[0].nodeType!=h.NODE_ELEMENT)return y.parent();y=new c(y[0].childNodes[D.startOffset]);if(!y[0]||y[0].nodeType!=h.NODE_ELEMENT)return D.startContainer;for(D=y[0].firstChild;D&&D.nodeType==h.NODE_ELEMENT;){y=new c(D);D=D.firstChild}return y}if(a){D=E.createRange();D.collapse(s);y=D.parentElement()}else if((y=E.anchorNode)&&y.nodeType!=h.NODE_ELEMENT)y=y.parentNode}return z.startElement=y?e._4e_wrap(y):n},getSelectedElement:function(){var z=this,y,E=z._.cache;if(E.selectedElement!==undefined)return E.selectedElement;
if(a){y=z.getNative().createRange();y=y.item&&y.item(0)}y||(y=function(){for(var D=z.getRanges()[0],j,A,w=2;w&&!((j=D.getEnclosedNode())&&j[0].nodeType==h.NODE_ELEMENT&&m[j._4e_name()]&&(A=j));w--)D.shrink(o.SHRINK_ELEMENT);return A&&A[0]}());return E.selectedElement=e._4e_wrap(y)},reset:function(){this._.cache={}},selectElement:function(z){var y,E=this.document;if(a)try{y=E.body.createControlRange();y.addElement(z[0]);y.select()}catch(D){y=E.body.createTextRange();y.moveToElementText(z[0]);y.select()}finally{}else{y=
E.createRange();y.selectNode(z[0]);z=this.getNative();z.removeAllRanges();z.addRange(y)}this.reset()},selectRanges:function(z){if(a){if(z.length>1){var y=z[z.length-1];z[0].setEnd(y.endContainer,y.endOffset);z.length=1}z[0]&&z[0].select()}else{y=this.getNative();if(!y)return;y.removeAllRanges();for(var E=0;E<z.length;E++){var D=z[E],j=this.document.createRange(),A=D.startContainer;D.collapsed&&g.gecko&&g.gecko<1.09&&A[0].nodeType==h.NODE_ELEMENT&&!A[0].childNodes.length&&A[0].appendChild(this.document.createTextNode(""));
j.setStart(A[0],D.startOffset);j.setEnd(D.endContainer[0],D.endOffset);y.addRange(j)}}this.reset()},createBookmarks2:function(z){for(var y=[],E=this.getRanges(),D=0;D<E.length;D++)y.push(E[D].createBookmark2(z));return y},createBookmarks:function(z,y){var E=[],D=this.document,j;y=y||this.getRanges();for(var A=y.length,w=0;w<A;w++){E.push(j=y[w].createBookmark(z,s));var C=(z=j.serializable)?l.one("#"+j.startNode,D):j.startNode;j=z?l.one("#"+j.endNode,D):j.endNode;for(var B=w+1;B<A;B++){var F=y[B],
O=F.startContainer,Q=F.endContainer;e._4e_equals(O,C.parent())&&F.startOffset++;e._4e_equals(O,j.parent())&&F.startOffset++;e._4e_equals(Q,C.parent())&&F.endOffset++;e._4e_equals(Q,j.parent())&&F.endOffset++}}return E},selectBookmarks:function(z){for(var y=[],E=0;E<z.length;E++){var D=new i(this.document);D.moveToBookmark(z[E]);y.push(D)}this.selectRanges(y);return this},getCommonAncestor:function(){var z=this.getRanges();return z[0].startContainer._4e_commonAncestor(z[z.length-1].endContainer)},
scrollIntoView:function(){var z=this.getStartElement();z&&z._4e_scrollIntoView()},removeAllRanges:function(){var z=this.getNative();if(a)z&&z.clear();else z&&z.removeAllRanges()}});var v={table:1,tbody:1,tr:1},x=b.whitespaces(s),p=/\ufeff|\u00a0/;i.prototype.select=i.prototype.select=!a?function(){var z=this.startContainer;this.collapsed&&z[0].nodeType==h.NODE_ELEMENT&&!z[0].childNodes.length&&z[0].appendChild(this.document.createTextNode(""));var y=this.document.createRange();y.setStart(z[0],this.startOffset);
try{y.setEnd(this.endContainer[0],this.endOffset)}catch(E){if(E.toString().indexOf("NS_ERROR_ILLEGAL_VALUE")>=0){this.collapse(s);y.setEnd(this.endContainer[0],this.endOffset)}else throw E;}z=r(this.document).getNative();z.removeAllRanges();z.addRange(y)}:function(z){var y=this.collapsed,E,D;if(this.startContainer[0]===this.endContainer[0]&&this.endOffset-this.startOffset==1){var j=this.startContainer[0].childNodes[this.startOffset];if(j.nodeType==h.NODE_ELEMENT){(new q(this.document)).selectElement(new c(j));
return}}if(this.startContainer[0].nodeType==h.NODE_ELEMENT&&this.startContainer._4e_name()in v||this.endContainer[0].nodeType==h.NODE_ELEMENT&&this.endContainer._4e_name()in v)this.shrink(o.SHRINK_ELEMENT,s);var A=this.createBookmark();j=A.startNode;var w;if(!y)w=A.endNode;A=this.document.body.createTextRange();A.moveToElementText(j[0]);A.moveStart("character",1);if(w){z=this.document.body.createTextRange();z.moveToElementText(w[0]);A.setEndPoint("EndToEnd",z);A.moveEnd("character",-1)}else{for(E=
j[0].nextSibling;E&&!x(E);)E=E.nextSibling;E=!(E&&E.nodeValue&&E.nodeValue.match(p))&&(z||!j[0].previousSibling||j[0].previousSibling&&e._4e_name(j[0].previousSibling)=="br");D=new c(this.document.createElement("span"));D.html("&#65279;");D.insertBefore(j);E&&e.insertBefore(this.document.createTextNode("\ufeff"),j)}this.setStartBefore(j);j._4e_remove();if(y){if(E){A.moveStart("character",-1);A.select();this.document.selection.clear()}else A.select();if(D){this.moveToPosition(D,o.POSITION_BEFORE_START);
D._4e_remove()}}else{this.setEndBefore(w);w._4e_remove();A.select()}};q.getSelection=r;k.Selection=q;k.Selection=q;b=q.prototype;k.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});k.on("instanceCreated",function(z){t(z.editor)})});
KISSY.Editor.add("styles",function(k){function q(H){return!H.attr("_ke_bookmark")}function r(H,K){for(var G in H)if(H.hasOwnProperty(G))if(E.isString(H[G]))H[G]=H[G].replace(X,function(J,I){return K[I]});else r(H[G],K)}function t(H,K){if(K){H=E.clone(H);r(H,K)}var G=this.element=this.element=(H.element||"*").toLowerCase();this.type=this.type=G=="#"||S[G]?A.STYLE_BLOCK:R[G]?A.STYLE_OBJECT:A.STYLE_INLINE;this._={definition:H}}function s(H,K){var G=K?this.removeFromRange:this.applyToRange;H.body.focus();
for(var J=new C(H),I=J.getRanges(),N=0;N<I.length;N++)G.call(this,I[N]);J.selectRanges(I)}function u(H,K,G){var J=H.element;if(J=="*")J="span";K=new Q(K.createElement(J));G&&G._4e_copyAttributes(K);return n(K,H)}function n(H,K){var G=K._.definition,J=G.attributes;G=t.getStyleText(G);if(J)for(var I in J)H.attr(I,J[I]);if(G)H[0].style.cssText=G;return H}function l(H){var K=H.createBookmark(p),G=H.createIterator();G.enforceRealBlocks=p;G.enlargeBr=p;for(var J,I=H.document;J=G.getNextParagraph();){var N=
u(this,I,J);J=J;var L=N;N=L._4e_name=="pre";var U=J._4e_name=="pre",V=!N&&U;if(N&&!U){U=J;L=L;V=U.html();V=g(V,/(?:^[ \t\n\r]+)|(?:[ \t\n\r]+$)/g,"");V=V.replace(/[ \t\r\n]*(<br[^>]*>)[ \t\r\n]*/gi,"$1");V=V.replace(/([ \t\n\r]+|&nbsp;)/g," ");V=V.replace(/<br\b[^>]*>/gi,"\n");if(P.ie){U=U[0].ownerDocument.createElement("div");U.appendChild(L[0]);L[0].outerHTML="<pre>"+V+"</pre>";L=new Q(U.firstChild);L._4e_remove()}else L.html(V);L=L}else if(V)L=d(e(J),L);else J._4e_moveChildren(L);J[0].parentNode.replaceChild(L[0],
J[0]);if(N){J=L;N=void 0;if((N=J._4e_previousSourceNode(p,B.NODE_ELEMENT))&&N._4e_name()=="pre"){L=g(N.html(),/\n$/,"")+"\n\n"+g(J.html(),/^\n/,"");if(P.ie)J[0].outerHTML="<pre>"+L+"</pre>";else J.html(L);N._4e_remove()}}}H.moveToBookmark(K)}function g(H,K,G){var J="",I="";H=H.replace(/(^<span[^>]+_ke_bookmark.*?\/span>)|(<span[^>]+_ke_bookmark.*?\/span>$)/gi,function(N,L,U){L&&(J=L);U&&(I=U);return""});return J+H.replace(K,G)+I}function e(H){var K=[];g(H._4e_outerHtml(),/(\S\s*)\n(?:\s|(<span[^>]+_ck_bookmark.*?\/span>))*\n(?!$)/gi,
function(G,J,I){return J+"</pre>"+I+"<pre>"}).replace(/<pre\b.*?>([\s\S]*?)<\/pre>/gi,function(G,J){K.push(J)});return K}function d(H,K){for(var G=K[0].ownerDocument.createDocumentFragment(),J=0;J<H.length;J++){var I=H[J];I=I.replace(/(\r\n|\r)/g,"\n");I=g(I,/^[ \t]*\n/,"");I=g(I,/\n$/,"");I=g(I,/^[ \t]+|[ \t]+$/g,function(L,U){return L.length==1?"&nbsp;":U?" "+Array(L.length).join("&nbsp;"):Array(L.length).join("&nbsp;")+" "});I=I.replace(/\n/g,"<br>");I=I.replace(/[ \t]{2,}/g,function(L){return Array(L.length).join("&nbsp;")+
" "});var N=K._4e_clone();N.html(I);G.appendChild(N[0])}return G}function c(H){var K=H.document;if(H.collapsed){K=u(this,K,undefined);H.insertNode(K);H.moveToPosition(K,w.POSITION_BEFORE_END)}else{var G=this.element,J=this._.definition,I,N=k.XHTML_DTD[G]||(I=p,k.XHTML_DTD.span),L=H.createBookmark();H.enlarge(w.ENLARGE_ELEMENT);H.trim();var U=H.createBookmark(),V=U.startNode;U=U.endNode;for(var Z=V,aa;Z&&Z[0];){var W=z;if(j._4e_equals(Z,U)){Z=y;W=p}else{var $=Z[0].nodeType,ca=$==B.NODE_ELEMENT?Z._4e_name():
y;if(ca&&Z.attr("_ke_bookmark")){Z=Z._4e_nextSourceNode(p);continue}if(!ca||N[ca]&&(Z._4e_position(U)|F.POSITION_PRECEDING|F.POSITION_IDENTICAL|F.POSITION_IS_CONTAINED)==F.POSITION_PRECEDING+F.POSITION_IDENTICAL+F.POSITION_IS_CONTAINED&&(!J.childRule||J.childRule(Z))){var ea=Z.parent();if(ea&&ea[0]&&((k.XHTML_DTD[ea._4e_name()]||k.XHTML_DTD.span)[G]||I)&&(!J.parentRule||J.parentRule(ea))){if(!aa&&(!ca||!k.XHTML_DTD.$removeEmpty[ca]||(Z._4e_position(U)|F.POSITION_PRECEDING|F.POSITION_IDENTICAL|F.POSITION_IS_CONTAINED)==
F.POSITION_PRECEDING+F.POSITION_IDENTICAL+F.POSITION_IS_CONTAINED)){aa=new O(K);aa.setStartBefore(Z)}if($==B.NODE_TEXT||$==B.NODE_ELEMENT&&!Z[0].childNodes.length){$=Z;for(var da;(W=!$._4e_next(q))&&(da=$.parent(),N[da._4e_name()])&&(da._4e_position(V)|F.POSITION_FOLLOWING|F.POSITION_IDENTICAL|F.POSITION_IS_CONTAINED)==F.POSITION_FOLLOWING+F.POSITION_IDENTICAL+F.POSITION_IS_CONTAINED&&(!J.childRule||J.childRule(da));)$=da;aa.setEndAfter($)}}else W=p}else W=p;Z=Z._4e_nextSourceNode()}if(W&&aa&&!aa.collapsed){W=
u(this,K,undefined);$=aa.getCommonAncestor();ca={styles:{},attrs:{},blockedStyles:{},blockedAttrs:{}};for(var ba,fa,ga;W&&$&&W[0]&&$[0];){if($._4e_name()==G){for(ba in J.attributes)if(!(ca.blockedAttrs[ba]||!(ga=$.attr(fa))))if(W.attr(ba)==ga)W.removeAttr(ba);else ca.blockedAttrs[ba]=1;for(fa in J.styles)if(!(ca.blockedStyles[fa]||!(ga=$._4e_style(fa))))if(W._4e_style(fa)==ga)W._4e_style(fa,"");else ca.blockedStyles[fa]=1;if(!W._4e_hasAttributes()){W=y;break}}$=$.parent()}if(W){W[0].appendChild(aa.extractContents());
m(this,W);aa.insertNode(W);W._4e_mergeSiblings();P.ie||W[0].normalize()}else{W=new Q(K.createElement("span"));W[0].appendChild(aa.extractContents());aa.insertNode(W);m(this,W);W._4e_remove(true)}aa=y}}V._4e_remove();U._4e_remove();H.moveToBookmark(L);H.shrink(w.SHRINK_TEXT)}}function f(H){H.enlarge(w.ENLARGE_ELEMENT);var K=H.createBookmark(),G=K.startNode;if(H.collapsed){for(var J=new M(G.parent()),I,N=0,L;N<J.elements.length&&(L=J.elements[N]);N++){if(L==J.block||L==J.blockLimit)break;if(this.checkElementRemovable(L)){var U=
H.checkBoundaryOfElement(L,w.END),V=!U&&H.checkBoundaryOfElement(L,w.START);if(V||U){I=L;I.match=V?"start":"end"}else{L._4e_mergeSiblings();if(L._4e_name()!=this.element){U=a(this);v(L,U[L._4e_name()]||U["*"])}else b(this,L)}}}if(I&&I[0]){L=G;for(N=0;;N++){U=J.elements[N];if(j._4e_equals(U,I))break;else if(U.match)continue;else U=U._4e_clone();U[0].appendChild(L[0]);L=U}j[I.match=="start"?"insertBefore":"insertAfter"](L,I)}}else{var Z=K.endNode,aa=this;J=function(){for(var W=new M(G.parent()),$=new M(Z.parent()),
ca=y,ea=y,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<$.elements.length;da++){ba=$.elements[da];if(ba==$.block||ba==$.blockLimit)break;if(aa.checkElementRemovable(ba))ea=ba}ea&&Z._4e_breakParent(ea);ca&&G._4e_breakParent(ca)};J();for(I=new Q(G[0].nextSibling);I[0]!==Z[0];){N=I._4e_nextSourceNode();if(I[0]&&I[0].nodeType==B.NODE_ELEMENT&&this.checkElementRemovable(I)){if(I._4e_name()==this.element)b(this,
I);else{L=a(this);v(I,L[I._4e_name()]||L["*"])}if(N[0].nodeType==B.NODE_ELEMENT&&N.contains(G)){J();N=new Q(G[0].nextSibling)}}I=N}}H.moveToBookmark(K)}function o(H){H=String(H);var K={};H.replace(/&quot;/g,'"').replace(/\s*([^ :;]+)\s*:\s*([^;]+)\s*(?=;|$)/g,function(G,J,I){K[J]=I});return K}function h(H,K){var G="";if(K!==z){G=document.createElement("span");G.style.cssText=H;G=G.style.cssText||""}else G=H;return G.replace(/\s*([;:])\s*/,"$1").replace(/([^\s;])$/,"$1;").replace(/,\s+/g,",").toLowerCase()}
function a(H){if(H._.overrides)return H._.overrides;var K=H._.overrides={},G=H._.definition.overrides;if(G){E.isArray(G)||(G=[G]);for(var J=0;J<G.length;J++){var I=G[J],N,L,U;if(typeof I=="string")N=I.toLowerCase();else{N=I.element?I.element.toLowerCase():H.element;L=I.attributes;U=I.styles}I=K[N]||(K[N]={});if(L){N=I.attributes=I.attributes||[];for(var V in L)L.hasOwnProperty(V)&&N.push([V.toLowerCase(),L[V]])}if(U){I=I.styles=I.styles||[];for(var Z in U)U.hasOwnProperty(Z)&&I.push([Z.toLowerCase(),
U[Z]])}}}return K}function b(H,K){var G=H._.definition,J=a(H),I=D.mix(G.attributes,(J[K._4e_name()]||J["*"]||{}).attributes);G=D.mix(G.styles,(J[K._4e_name()]||J["*"]||{}).styles);J=E.isEmptyObject(I)&&E.isEmptyObject(G);for(var N in I)if(I.hasOwnProperty(N))if(!((N=="class"||H._.definition.fullMatch)&&K.attr(N)!=i(N,I[N]))){J=J||!!K._4e_hasAttribute(N);K.removeAttr(N)}for(var L in G)if(G.hasOwnProperty(L))if(!(H._.definition.fullMatch&&K._4e_style(L)!=i(L,G[L],p))){J=J||!!K._4e_style(L);K._4e_style(L,
"")}x(K)}function i(H,K,G){var J=new Q("<span>");J[G?"_4e_style":"attr"](H,K);return J[G?"_4e_style":"attr"](H)}function m(H,K){for(var G=a(H),J=K.all(H.element),I=J.length;--I>=0;)b(H,new Q(J[I]));for(var N in G)if(N!=H.element){J=K.all(N);for(I=J.length-1;I>=0;I--){var L=new Q(J[I]);v(L,G[N])}}}function v(H,K){var G,J=K&&K.attributes;if(J)for(G=0;G<J.length;G++){var I=J[G][0],N;if(N=H.attr(I)){var L=J[G][1];if(L===y||L.test&&L.test(N)||typeof L=="string"&&N==L)H[0].removeAttribute(I)}}if(J=K&&K.styles)for(G=
0;G<J.length;G++){I=J[G][0];if(L=H.css(I)){var U=J[G][1];if(U===y||U.test&&U.test(N)||typeof U=="string"&&L==U)H.css(I,"")}}x(H)}function x(H){if(!H._4e_hasAttributes()){var K=H[0].firstChild,G=H[0].lastChild;H._4e_remove(p);if(K){K.nodeType==B.NODE_ELEMENT&&j._4e_mergeSiblings(K);G&&K!=G&&G.nodeType==B.NODE_ELEMENT&&j._4e_mergeSiblings(G)}}}var p=true,z=false,y=null,E=KISSY,D=k.Utils,j=E.DOM,A={STYLE_BLOCK:1,STYLE_INLINE:2,STYLE_OBJECT:3},w=k.RANGE,C=k.Selection,B=k.NODE,F=k.POSITION,O=k.Range,Q=
E.Node,P=E.UA,M=k.ElementPath,S={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},T=/\s*(?:;\s*|$)/g,X=/#\((.+?)\)/g;k.STYLE=A;t.prototype={apply:function(H){s.call(this,H,z)},remove:function(H){s.call(this,H,p)},applyToRange:function(H){return(this.applyToRange=this.type==A.STYLE_INLINE?c:this.type==A.STYLE_BLOCK?l:this.type==A.STYLE_OBJECT?y:y).call(this,H)},removeFromRange:function(H){return(this.removeFromRange=
this.type==A.STYLE_INLINE?f:y).call(this,H)},applyToObject:function(H){n(H,this)},checkElementRemovable:function(H,K){if(!H)return z;var G=this._.definition,J;if(H._4e_name()==this.element){if(!K&&!H._4e_hasAttributes())return p;var I=G._AC;if(I)G=I;else{I={};var N=0,L=G.attributes;if(L)for(var U in L){N++;I[U]=L[U]}if(L=t.getStyleText(G)){I.style||N++;I.style=L}I._length=N;G=G._AC=I}if(G._length){for(var V in G)if(V!="_length"){N=H.attr(V)||"";if(V=="style")a:{I=G[V];N=h(N,z);typeof I=="string"&&
(I=o(I));typeof N=="string"&&(N=o(N));L=void 0;for(L in I)if(!(L in N&&(N[L]==I[L]||I[L]=="inherit"||N[L]=="inherit"))){I=z;break a}I=p}else I=G[V]==N;if(I){if(!K)return p}else if(K)return z}if(K)return p}else return p}V=a(this);if(V=V[H._4e_name()]||V["*"]){if(!(G=V.attributes)&&!(J=V.styles))return p;if(G)for(I=0;I<G.length;I++){V=G[I][0];if(V=H.attr(V)){N=G[I][1];if(N===y||typeof N=="string"&&V==N||N.test&&N.test(V))return p}}if(J)for(I=0;I<J.length;I++)if(V=H.css(J[I][0])){G=J[I][1];if(G===y||
typeof G=="string"&&V==G||G.test&&G.test(V))return p}}return z},checkActive:function(H){switch(this.type){case A.STYLE_BLOCK:return this.checkElementRemovable(H.block||H.blockLimit,p);case A.STYLE_OBJECT:case A.STYLE_INLINE:for(var K=H.elements,G=0,J;G<K.length;G++){J=K[G];if(!(this.type==A.STYLE_INLINE&&(j._4e_equals(J,H.block)||j._4e_equals(J,H.blockLimit))))if(!(this.type==A.STYLE_OBJECT&&!(J._4e_name()in R)))if(this.checkElementRemovable(J,p))return p}}return z}};t.getStyleText=function(H){var K=
H._ST;if(K)return K;K=H.styles;var G=H.attributes&&H.attributes.style||"",J="";if(G.length)G=G.replace(T,";");for(var I in K){var N=K[I],L=(I+":"+N).replace(T,";");if(N=="inherit")J+=L;else G+=L}if(G.length)G=h(G);G+=J;return H._ST=G};k.Style=t;k.Style=t;var Y=t.prototype;k.Utils.extern(Y,{apply:Y.apply,remove:Y.remove,applyToRange:Y.applyToRange,removeFromRange:Y.removeFromRange,applyToObject:Y.applyToObject,checkElementRemovable:Y.checkElementRemovable,checkActive:Y.checkActive})});
KISSY.Editor.add("htmlparser",function(){function k(){this._={htmlPartsRegex:RegExp("<(?:(?:\\/([^>]+)>)|(?:!--([\\S|\\s]*?)--\>)|(?:([^\\s>]+)\\s*((?:(?:[^\"'>]+)|(?:\"[^\"]*\")|(?:'[^']*'))*)\\/?>))","g")}}var q=KISSY,r=function(){},t=q.Editor,s=/([\w\-:.]+)(?:(?:\s*=\s*(?:(?:"([^"]*)")|(?:'([^']*)')|([^\s>]+)))|(?=\s|$))/g,u={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},n=t.XHTML_DTD;q.augment(k,{onTagOpen:r,onTagClose:r,
onText:r,onCDATA:r,onComment:r,parse:function(l){for(var g,e,d=0,c;g=this._.htmlPartsRegex.exec(l);){e=g.index;if(e>d){d=l.substring(d,e);c?c.push(d):this.onText(d)}d=this._.htmlPartsRegex.lastIndex;if(e=g[1]){e=e.toLowerCase();if(c&&n.$cdata[e]){this.onCDATA(c.join(""));c=null}if(!c){this.onTagClose(e);continue}}if(c)c.push(g[0]);else if(e=g[3]){e=e.toLowerCase();if(!/="/.test(e)){var f={},o;g=g[4];var h=!!(g&&g.charAt(g.length-1)=="/");if(g)for(;o=s.exec(g);){var a=o[1].toLowerCase();o=o[2]||o[3]||
o[4]||"";f[a]=!o&&u[a]?a:o}this.onTagOpen(e,f,h);if(!c&&n.$cdata[e])c=[]}}else if(e=g[2])this.onComment(e)}l.length>d&&this.onText(l.substring(d,l.length))}});t.HtmlParser=k;t.HtmlParser=k});
KISSY.Editor.add("htmlparser-basicwriter",function(){function k(){this._={output:[]}}var q=KISSY,r=q.Editor,t=r.Utils;q.augment(k,{openTag:function(s){this._.output.push("<",s)},openTagClose:function(s,u){u?this._.output.push(" />"):this._.output.push(">")},attribute:function(s,u){if(typeof u=="string")u=t.htmlEncodeAttr(u);this._.output.push(" ",s,'="',u,'"')},closeTag:function(s){this._.output.push("</",s,">")},text:function(s){this._.output.push(s)},comment:function(s){this._.output.push("<!--",
s,"--\>")},write:function(s){this._.output.push(s)},reset:function(){this._.output=[];this._.indent=false},getHtml:function(s){var u=this._.output.join("");s&&this.reset();return u}});r.HtmlParser.BasicWriter=k;r.HtmlParser.BasicWriter=k;q=k.prototype;r.Utils.extern(q,{openTag:q.openTag,openTagClose:q.openTagClose,attribute:q.attribute,closeTag:q.closeTag,text:q.text,comment:q.comment,write:q.write,reset:q.reset,getHtml:q.getHtml})});
KISSY.Editor.add("htmlparser-htmlwriter",function(){function k(){k.superclass.constructor.call(this);this.indentationChars="\t";this.selfClosingEnd=" />";this.lineBreakChars="\n";this.forceSimpleAmpersand=u;this.sortAttributes=s;this._.indent=u;this._.indentation="";this._.rules={};var n=r.XHTML_DTD,l;for(l in t.mix({},n.$nonBodyContent,n.$block,n.$listItem,n.$tableContent))this.setRules(l,{indent:s,breakBeforeOpen:s,breakAfterOpen:s,breakBeforeClose:!n[l]["#"],breakAfterClose:s});this.setRules("br",
{breakAfterOpen:s});this.setRules("title",{indent:u,breakAfterOpen:u});this.setRules("style",{indent:u,breakBeforeClose:s});this.setRules("pre",{indent:u})}var q=KISSY,r=q.Editor,t=r.Utils,s=true,u=false;q.extend(k,r.HtmlParser.BasicWriter,{openTag:function(n){var l=this._.rules[n];if(this._.indent)this.indentation();else if(l&&l.breakBeforeOpen){this.lineBreak();this.indentation()}this._.output.push("<",n)},openTagClose:function(n,l){var g=this._.rules[n];if(l)this._.output.push(this.selfClosingEnd);
else{this._.output.push(">");if(g&&g.indent)this._.indentation+=this.indentationChars}g&&g.breakAfterOpen&&this.lineBreak()},attribute:function(n,l){if(typeof l=="string"){this.forceSimpleAmpersand&&(l=l.replace(/&amp;/g,"&"));l=t.htmlEncodeAttr(l)}this._.output.push(" ",n,'="',l,'"')},closeTag:function(n){var l=this._.rules[n];if(l&&l.indent)this._.indentation=this._.indentation.substr(this.indentationChars.length);if(this._.indent)this.indentation();else if(l&&l.breakBeforeClose){this.lineBreak();
this.indentation()}this._.output.push("</",n,">");l&&l.breakAfterClose&&this.lineBreak()},text:function(n){if(this._.indent){this.indentation();n=t.ltrim(n)}this._.output.push(n)},comment:function(n){this._.indent&&this.indentation();this._.output.push("<!--",n,"--\>")},lineBreak:function(){this._.output.length>0&&this._.output.push(this.lineBreakChars);this._.indent=s},indentation:function(){this._.output.push(this._.indentation);this._.indent=u},setRules:function(n,l){var g=this._.rules[n];if(g)t.mix(g,
l);else this._.rules[n]=l}});r.HtmlParser.HtmlWriter=k;r.HtmlParser.HtmlWriter=k;q=k.prototype;r.Utils.extern(q,{openTag:q.openTag,openTagClose:q.openTagClose,attribute:q.attribute,closeTag:q.closeTag,text:q.text,comment:q.comment,lineBreak:q.lineBreak,indentation:q.indentation,setRules:q.setRules})});
KISSY.Editor.add("htmlparser-fragment",function(){function k(){this.children=[];this.parent=t;this._={isBlockLike:q,hasInlineStarted:r}}var q=true,r=false,t=null,s=KISSY.Editor,u={colgroup:1,dd:1,dt:1,li:1,option:1,p:1,td:1,tfoot:1,th:1,thead:1,tr:1},n=KISSY,l=s.Utils,g=s.NODE,e=s.XHTML_DTD;l.mix({table:1,ul:1,ol:1,dl:1},e.table,e.ul,e.ol,e.dl);var d=e.$list,c=e.$listItem;k.FromHtml=function(f,o){function h(j){var A;if(v.length>0)for(var w=0;w<v.length;w++){var C=v[w],B=C.name,F=e[B],O=p.name&&e[p.name];
if((!O||O[B])&&(!j||!F||F[j]||!e[j])){if(!A){a();A=1}C=C.clone();C.parent=p;p=C;v.splice(w,1);w--}}}function a(){for(;x.length;)p.add(x.shift())}function b(j,A,w){A=A||p||m;if(o&&!A.type){var C,B;if((C=j.attributes&&(B=j.attributes._ke_real_element_type)?B:j.name)&&!(C in e.$body)&&!(C in e.$nonBodyContent)){B=p;p=A;i.onTagOpen({li:"ul",dt:"dl",dd:"dl"}[C]||o,{});A=p;if(w)p=B}}if(j._.isBlockLike&&j.name!="pre"){w=j.children.length;if((C=j.children[w-1])&&C.type==g.NODE_TEXT)if(B=l.rtrim(C.value))C.value=
B;else j.children.length=w-1}A.add(j);if(j.returnPoint){p=j.returnPoint;delete j.returnPoint}}var i=new s.HtmlParser,m=new k,v=[],x=[],p=m,z=r,y;i.onTagOpen=function(j,A,w){var C=new s.HtmlParser.Element(j,A);if(C.isUnknown&&w)C.isEmpty=q;if(e.$removeEmpty[j])v.push(C);else{if(j==="pre")z=q;else if(j==="br"&&z){p.add(new s.HtmlParser.Text("\n"));return}if(j==="br")x.push(C);else{var B=p.name,F=B&&(e[B]||(p._.isBlockLike?e.div:e.span));if(F&&!C.isUnknown&&!p.isUnknown&&!F[j]){F=r;var O;if(j in d&&
B in d){B=p.children;(B=B[B.length-1])&&B.name in c||b(B=new s.HtmlParser.Element("li"),p);y=p;O=B}else if(j==B)b(p,p.parent);else{b(p,p.parent,q);!u[B]&&B in e.$inline&&v.unshift(p);F=q}p=O?O:p.returnPoint||p.parent;if(F){i.onTagOpen.apply(this,arguments);return}}h(j);a();C.parent=p;C.returnPoint=y;y=0;if(C.isEmpty)b(C);else p=C}}};i.onTagClose=function(j){for(var A=v.length-1;A>=0;A--)if(j==v[A].name){v.splice(A,1);return}for(var w=[],C=[],B=p;B.type&&B.name!=j;){B._.isBlockLike||C.unshift(B);w.push(B);
B=B.parent}if(B.type){for(A=0;A<w.length;A++){var F=w[A];b(F,F.parent)}p=B;if(p.name=="pre")z=r;B._.isBlockLike&&a();b(B,B.parent);if(B==p)p=p.parent;v=v.concat(C)}if(j=="body")o=r};i.onText=function(j){if(!p._.hasInlineStarted&&!z){j=l.ltrim(j);if(j.length===0)return}a();h();if(o&&(!p.type||p.name=="body")&&l.trim(j))this.onTagOpen(o,{});z||(j=j.replace(/[\t\r\n ]{2,}|[\t\r\n]/g," "));p.add(new s.HtmlParser.Text(j))};i.onCDATA=function(j){p.add(new s.HtmlParser.cdata(j))};i.onComment=function(j){p.add(new s.HtmlParser.Comment(j))};
i.parse(f);for(a();p.type;){var E=p.parent,D=p;if(o&&(!E.type||E.name=="body")&&!e.$body[D.name]){p=E;i.onTagOpen(o,{});E=p}E.add(D);p=E}return m};n.augment(k,{add:function(f){var o=this.children.length;if(o=o>0&&this.children[o-1]||t){if(f._.isBlockLike&&o.type==g.NODE_TEXT){o.value=l.rtrim(o.value);if(o.value.length===0){this.children.pop();this.add(f);return}}o.next=f}f.previous=o;f.parent=this;this.children.push(f);this._.hasInlineStarted=f.type==g.NODE_TEXT||f.type==g.NODE_ELEMENT&&!f._.isBlockLike},
writeHtml:function(f,o){var h;this.filterChildren=this.filterChildren=function(){var a=new s.HtmlParser.BasicWriter;this.writeChildrenHtml.call(this,a,o,q);a=a.getHtml();this.children=(new k.FromHtml(a)).children;h=1};!this.name&&o&&o.onFragment(this);this.writeChildrenHtml(f,h?t:o)},writeChildrenHtml:function(f,o){for(var h=0;h<this.children.length;h++)this.children[h].writeHtml(f,o)}});s.HtmlParser.Fragment=k;s.HtmlParser.Fragment=k;k.FromHtml=k.FromHtml;n=k.prototype;s.Utils.extern(n,{add:n.add,
writeHtml:n.writeHtml,writeChildrenHtml:n.writeChildrenHtml})});
KISSY.Editor.add("htmlparser-element",function(){function k(u,n){this.name=u;this.attributes=n||(n={});this.children=[];var l=n._ke_real_element_type||u,g=q.XHTML_DTD;l=!!(g.$nonBodyContent[l]||g.$block[l]||g.$listItem[l]||g.$tableContent[l]||g.$nonEditable[l]||l=="br");var e=!!g.$empty[u];this.isEmpty=e;this.isUnknown=!g[u];this._={isBlockLike:l,hasInlineStarted:e||!l}}var q=KISSY.Editor,r=q.NODE,t=function(u,n){u=u[0];n=n[0];return u<n?-1:u>n?1:0};KISSY.augment(k,{type:r.NODE_ELEMENT,add:q.HtmlParser.Fragment.prototype.add,
clone:function(){return new k(this.name,this.attributes)},writeHtml:function(u,n){var l=this.attributes,g=this,e=g.name,d,c,f,o;g.filterChildren=function(){if(!o){var b=new q.HtmlParser.BasicWriter;q.HtmlParser.Fragment.prototype.writeChildrenHtml.call(g,b,n);g.children=(new q.HtmlParser.Fragment.FromHtml(b.getHtml())).children;o=1}};g.filterChildren=g.filterChildren;if(n){for(;;){if(!(e=n.onElementName(e)))return;g.name=e;if(!(g=n.onElement(g)))return;g.parent=this.parent;if(g.name==e)break;if(g.type!=
r.NODE_ELEMENT){g.writeHtml(u,n);return}e=g.name;if(!e){this.writeChildrenHtml.call(g,u,o?null:n);return}}l=g.attributes}u.openTag(e,l);for(var h=[],a=0;a<2;a++)for(d in l){c=d;f=l[d];if(a==1)h.push([d,f]);else if(n){for(;;)if(c=n.onAttributeName(d))if(c!=d){delete l[d];d=c}else break;else{delete l[d];break}if(c)if((f=n.onAttribute(g,c,f))===false)delete l[c];else l[c]=f}}u.sortAttributes&&h.sort(t);l=h.length;for(a=0;a<l;a++){d=h[a];u.attribute(d[0],d[1])}u.openTagClose(e,g.isEmpty);if(!g.isEmpty){this.writeChildrenHtml.call(g,
u,o?null:n);u.closeTag(e)}},writeChildrenHtml:function(){q.HtmlParser.Fragment.prototype.writeChildrenHtml.apply(this,arguments)}});q.HtmlParser.Element=k;q.HtmlParser.Element=k;var s=k.prototype;q.Utils.extern(s,{type:s.type,add:s.add,clone:s.clone,writeHtml:s.writeHtml,writeChildrenHtml:s.writeChildrenHtml})});
KISSY.Editor.add("htmlparser-filter",function(){function k(d){this._={elementNames:[],attributeNames:[],elements:{$length:0},attributes:{$length:0}};d&&this.addRules(d,10)}function q(d,c){for(var f=0;d&&f<c.length;f++){var o=c[f];d=d.replace(o[0],o[1])}return d}function r(d,c,f){if(typeof c=="function")c=[c];var o,h;h=d.length;var a=c&&c.length;if(a){for(o=0;o<h&&d[o].pri<f;o++);for(h=a-1;h>=0;h--)if(a=c[h]){a.pri=f;d.splice(o,0,a)}}}function t(d,c,f){if(c)for(var o in c){var h=d[o];d[o]=s(h,c[o],
f);h||d.$length++}}function s(d,c,f){if(c){c.pri=f;if(d){if(d.splice)r(d,c,f);else{d=d.pri>f?[c,d]:[d,c];d.filter=u}return d}else return c.filter=c}}function u(d){for(var c=d.type||d instanceof l.HtmlParser.Fragment,f=0;f<this.length;f++){if(c)var o=d.type,h=d.name;var a=this[f].apply(window,arguments);if(a===e)return a;if(c){if(a&&(a.name!=h||a.type!=o))return a}else if(typeof a!="string")return a;a!=undefined&&(d=a)}return d}var n=KISSY,l=n.Editor,g=l.NODE,e=false;n.augment(k,{addRules:function(d,
c){if(typeof c!="number")c=10;r(this._.elementNames,d.elementNames,c);r(this._.attributeNames,d.attributeNames,c);t(this._.elements,d.elements,c);t(this._.attributes,d.attributes,c);this._.text=s(this._.text,d.text,c)||this._.text;this._.comment=s(this._.comment,d.comment,c)||this._.comment;this._.root=s(this._.root,d.root,c)||this._.root},onElementName:function(d){return q(d,this._.elementNames)},onAttributeName:function(d){return q(d,this._.attributeNames)},onText:function(d){var c=this._.text;
return c?c.filter(d):d},onComment:function(d,c){var f=this._.comment;return f?f.filter(d,c):d},onFragment:function(d){var c=this._.root;return c?c.filter(d):d},onElement:function(d){for(var c=[this._.elements["^"],this._.elements[d.name],this._.elements.$],f,o=0;o<3;o++)if(f=c[o]){f=f.filter(d,this);if(f===e)return null;if(f&&f!=d)return this.onNode(f);if(d.parent&&!d.name)break}return d},onNode:function(d){var c=d.type;return c==g.NODE_ELEMENT?this.onElement(d):c==g.NODE_TEXT?new l.HtmlParser.Text(this.onText(d.value)):
null},onAttribute:function(d,c,f){if(c=this._.attributes[c]){d=c.filter(f,d,this);if(d===e)return e;if(typeof d!="undefined")return d}return f}});l.HtmlParser.Filter=k;n=k.prototype;l.Utils.extern(n,{addRules:n.addRules,onElementName:n.onElementName,onAttributeName:n.onAttributeName,onText:n.onText,onComment:n.onComment,onFragment:n.onFragment,onElement:n.onElement,onNode:n.onNode,onAttribute:n.onAttribute});l.HtmlParser.Filter=k});
KISSY.Editor.add("htmlparser-text",function(){function k(s){this.value=s;this._={isBlockLike:t}}var q=KISSY,r=q.Editor,t=false;q.augment(k,{type:r.NODE.NODE_TEXT,writeHtml:function(s,u){var n=this.value;u&&!(n=u.onText(n,this))||s.text(n)}});r.HtmlParser.Text=k;r.HtmlParser.Text=k});KISSY.Editor.add("htmlparser-cdata",function(k){k.HtmlParser.cdata=function(q){this.value=q};k.HtmlParser.cdata.prototype={type:k.NODE.NODE_TEXT,writeHtml:function(q){q.write(this.value)}}});
KISSY.Editor.add("htmlparser-comment",function(){function k(t){this.value=t;this._={isBlockLike:false}}var q=KISSY.Editor,r=q.NODE;q.HtmlParser.Comment=k;q.HtmlParser.Comment=k;k.prototype={constructor:k,type:r.NODE_COMMENT,writeHtml:function(t,s){var u=this.value;if(s){if(!(u=s.onComment(u,this)))return;if(typeof u!="string"){u.parent=this.parent;u.writeHtml(t,s);return}}t.comment(u)}}});
KISSY.Editor.add("button",function(){var k=KISSY,q=k.Editor;if(q.TripleButton)k.log("TripleButton attach twice","warn");else{var r=k.UIBase.create([k.UIBase.Box.Render||k.UIBase.Box],{bindUI:function(){var t=this,s=t.get("el");s.on("click",t._action,t);s.on("mousedown",function(){t.get("state")=="off"&&s.addClass("ke-triplebutton-active")});s.on("mouseup mouseleave",function(){t.get("state")=="off"&&s.hasClass("ke-triplebutton-active")&&setTimeout(function(){s.removeClass("ke-triplebutton-active")},
300)})},_uiSetTitle:function(){this.get("el").attr("title",this.get("title"))},_uiSetContentCls:function(t){var s=this.get("el");if(t!==undefined){s.html("<span class='ke-toolbar-item "+t+"'>");s._4e_unselectable()}},_uiSetText:function(t){var s=this.get("el");t!==undefined&&s.html(t)},_uiSetState:function(t){this["_"+t]()},disable:function(){this._savedState=this.get("state");this.set("state","disabled")},enable:function(){this.get("state")=="disabled"&&this.set("state",this._savedState)},_action:function(t){this.fire(this.get("state")+
"Click",{TripleEvent:t});this.fire("click",{TripleClickType:this.get("state")+"Click"});t&&t.preventDefault()},bon:function(){this.set("state","on")},boff:function(){this.set("state","off")},_on:function(){var t=this.get("el");t.removeClass("ke-triplebutton-off ke-triplebutton-disabled");t.addClass("ke-triplebutton-on")},_off:function(){var t=this.get("el");t.removeClass("ke-triplebutton-on ke-triplebutton-disabled");t.addClass("ke-triplebutton-off")},_disabled:function(){var t=this.get("el");t.removeClass("ke-triplebutton-off ke-triplebutton-on");
t.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:{}}});r.ON="on";r.OFF="off";r.DISABLED="disabled";r.ON_CLASS="ke-triplebutton-on";r.OFF_CLASS="ke-triplebutton-off";r.DISABLED_CLASS="ke-triplebutton-disabled";q.TripleButton=r;q.prototype.addButton=function(t,s){var u=this,n=new r({render:u.toolBarDiv,autoRender:true,title:s.title,text:s.text,
contentCls:s.contentCls}),l={btn:n,editor:u,cfg:s,call:function(){var g=k.makeArray(arguments),e=g.shift();return s[e].apply(l,g)},reload:function(g){k.mix(s,g);n.enable();u.on("selectionChange",function(){u.getMode()!=q.SOURCE_MODE&&s.selectionChange&&s.selectionChange.apply(l,arguments)});n.on("click",function(e){var d=e.TripleClickType;s[d]&&s[d].apply(l,arguments);e&&e.halt()});if(s.mode==q.WYSIWYG_MODE){u.on("wysiwygmode",n.enable,n);u.on("sourcemode",n.disable,n)}s.init&&s.init.call(l)},destroy:function(){s.destroy&&
s.destroy.call(l);n.destroy()}};s.loading?n.disable():l.reload(undefined);return l}}});
KISSY.Editor.add("select",function(){function k(e){k.superclass.constructor.call(this,e);this._init()}var q=KISSY,r=q.Node,t=q.Event,s=q.DOM,u=q.Editor;if(u.Select)q.log("ke select attach more");else{k.DISABLED=0;k.ENABLED=1;var n=u.XHTML_DTD;k.ATTRS={showValue:{},el:{},cls:{},container:{},doc:{},value:{},width:{},title:{},items:{},emptyText:{},align:{value:["l","b"]},menuContainer:{valueFn:function(){for(var e=this.el.parent();e;){var d=e._4e_name();if(n[d]&&n[d].div)return e;e=e.parent()}return new r(document.body)}},
state:{value:1}};k.decorate=function(e){for(var d=e.width(),c=[],f=e.all("option"),o=0;o<f.length;o++){var h=f[o];c.push({name:s.html(h),value:s.attr(h,"value")})}return new k({width:d+"px",el:e,items:c,cls:"ke-combox",value:e.val()})};var l=u.Utils.addRes,g=u.Utils.destroyRes;q.extend(k,q.Base,{_init:function(){var e=this.get("container"),d=this.get("el"),c=new r("<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>"),
f=this.get("title")||"",o=this.get("cls"),h=c.one(".ke-select-text"),a=c.one(".ke-select-text-inner");c.one(".ke-select-drop");this.get("value")!==undefined?a.html(this._findNameByV(this.get("value"))):a.html(f);h.css("width",this.get("width"));c._4e_unselectable();f&&c.attr("title",f);o&&c.addClass(o);if(d)d[0].parentNode.replaceChild(c[0],d[0]);else e&&c.appendTo(e);c.on("click",this._click,this);this.el=c;this.title=a;this._focusA=c.one("a.ke-select");u.Utils.lazyRun(this,"_prepare","_real");this.on("afterValueChange",
this._valueChange,this);this.on("afterStateChange",this._stateChange,this)},_findNameByV:function(e){var d=this.get("title")||"",c=this.get("items");if(this.get("showValue"))return e||d;for(var f=0;f<c.length;f++){var o=c[f];if(o.value==e){d=o.name;break}}return d},_valueChange:function(e){this.title.html(this._findNameByV(e.newVal))},_itemsChange:function(e){var d;d=e.newVal;e=this._selectList;e.html("");if(d&&d.length)for(var c=0;c<d.length;c++){var f=d[c];(new r("<a class='ke-select-menu-item' href='#' data-value='"+
f.value+"'>"+f.name+"</a>",f.attrs)).appendTo(e)._4e_unselectable()}else if(d=this.get("emptyText"))(new r("<a class='ke-select-menu-item' href='#'>"+d+"</a>")).appendTo(e)._4e_unselectable();this.as=e.all("a")},val:function(e){if(e!==undefined){this.set("value",e);return this}else return this.get("value")},_resize:function(){this.menu.get("visible")&&this._real()},_prepare:function(){function e(b){b=new r(b.target);c.contains(b)||c._4e_equals(b)||h.hide()}var d=this,c=d.el,f=d.get("popUpWidth"),
o=d._focusA,h=new u.Overlay({autoRender:true,render:d.get("menuContainer"),content:"<div>",focus4e:false,elCls:"ke-menu",width:f?f:c.width(),zIndex:u.baseZIndex(u.zIndexManager.SELECT),focusMgr:false}),a=d.get("items");l.call(d,h);f=h.get("contentEl").one("div");d.menu=h;t.on(window,"resize",d._resize,d);l.call(d,function(){t.remove(window,"resize",d._resize,d)});d.get("title")&&(new r("<div class='ke-menu-title ke-select-menu-item' style='margin-top:-6px;' >"+d.get("title")+"</div>")).appendTo(f);
d._selectList=(new r("<div>")).appendTo(f);d._itemsChange({newVal:a});h.on("show",function(){o.addClass("ke-select-active")});h.on("hide",function(){o.removeClass("ke-select-active")});t.on(document,"click",e);l.call(d,function(){t.remove(document,"click",e)});d.get("doc")&&t.on(d.get("doc"),"click",e);f.on("click",d._select,d);d.as=d._selectList.all("a");t.on(f[0],"mouseenter",function(){d.as.removeClass("ke-menu-selected")});l.call(d,f);d.on("afterItemsChange",d._itemsChange,d);d.menuNode=f},_stateChange:function(e){var d=
this.el;e.newVal==1?d.removeClass("ke-select-disabled"):d.addClass("ke-select-disabled")},enable:function(){this.set("state",1)},disable:function(){this.set("state",0)},_select:function(e){e&&e.halt();var d=this.menu,c=this.menuNode;if((e=(new r(e.target))._4e_ascendant(function(h){return c.contains(h)&&h._4e_name()=="a"},true))&&e._4e_hasAttribute("data-value")){var f=this.get("value"),o=e.attr("data-value");this.set("value",o);this.fire("click",{newVal:o,prevVal:f,name:e.html()});d.hide()}},_real:function(){var e=
this.el,d=e.offset(),c=q.clone(d),f=this.menu.get("el").height(),o=this.menu.get("el").width(),h=s.scrollTop(),a=s.scrollLeft(),b=s.viewportHeight(),i=s.viewportWidth();i=a+i-60;b=h+b;var m=d.top+(e.height()-2);e=d.left+e.width()-2;var v=this.get("align"),x=v[0];if(v[1]=="b"){d.top=m;if(d.top+f>b&&c.top-h>b-m)d.top=c.top-f}else{d.top=c.top-f;if(d.top<h&&c.top-h<b-m)d.top=m}if(x=="l"){if(d.left+o>i&&e-a>i-c.left)d.left=e-o}else{d.left=e-o;if(d.left<a&&e-a<i-c.left)d.left=c.left}this.menu.set("xy",
[d.left,d.top]);this.menu.show()},_click:function(e){if(!this.loading){e&&e.preventDefault();var d=this;e=d.el;var c=d.get("value");if(!e.hasClass("ke-select-disabled"))if(d._focusA.hasClass("ke-select-active"))d.menu&&d.menu.hide();else{d.loading=true;u.use("overlay",function(){d.loading=false;d.fire("select");d._prepare();c&&d.menu&&d.as.each(function(f){f.attr("data-value")==c?f.addClass("ke-menu-selected"):f.removeClass("ke-menu-selected")})})}}},destroy:function(){g.call(this);this.el.detach();
this.el.remove()}});u.Select=k;u.prototype.addSelect=function(e,d){var c=this;d=q.mix({container:c.toolBarDiv,doc:c.document,menuContainer:new r(document.body)},d);var f=new k(d),o={btn:f,editor:c,cfg:d,call:function(){var h=q.makeArray(arguments),a=h.shift();return d[a].apply(o,h)},reload:function(h){q.mix(d,h);f.enable();c.on("selectionChange",function(){c.getMode()!=u.SOURCE_MODE&&d.selectionChange&&d.selectionChange.apply(o,arguments)});f.on("click",function(a){var b=a.type;d[b]&&d[b].apply(o,
arguments);a&&a.halt()});if(d.mode==u.WYSIWYG_MODE){c.on("wysiwygmode",f.enable,f);c.on("sourcemode",f.disable,f)}d.init&&d.init.call(o)},destroy:function(){d.destroy&&d.destroy.call(o);f.destroy()}};d.loading?f.disable():o.reload(undefined);return o}}});
KISSY.Editor.add("bubbleview",function(){function k(l){l=n[l];if(!l.bubble){l.bubble=new u({autoRender:true});l.cfg.init&&l.cfg.init.call(l.bubble)}return l.bubble}var q=KISSY,r=q.Editor,t=q.Event,s=q.DOM;if(r.BubbleView)q.log("attach bubbleview more","warn");else{var u=q.UIBase.create(r.Overlay,[],{renderUI:function(){this.get("el").addClass("ke-bubbleview-bubble")},show:function(){var l=this._selectedEl,g=l._4e_getOffset(document);g.top+=l.height()+5;this.set("xy",[g.left,g.top]);var e,d;for(d in n){l=
n[d];if(l.bubble){var c;if(c=this!=l.bubble){if(c=l.bubble.get("visible")){var f=l.bubble;c=this.get("y");var o=c+this.get("el")[0].offsetHeight,h=f.get("y");f=h+f.get("el")[0].offsetHeight;c=!(o<h||f<c)}c=c}if(c)if(e){if(e.get("y")<l.bubble.get("y"))e=l.bubble}else e=l.bubble}}if(e=e)g.top=e.get("y")+e.get("el")[0].offsetHeight;u.superclass.show.call(this);this.set("xy",[g.left,g.top])},destructor:function(){r.Utils.destroyRes.call(this)}},{ATTRS:{focus4e:{value:false},zIndex:{value:r.baseZIndex(r.zIndexManager.BUBBLE_VIEW)}}}),
n={};u.destroy=function(l){if((l=n[l])&&l.bubble){l.bubble.destroy();l.bubble=null}};u.attach=function(l){function g(){o&&o.hide()}var e=l.pluginName;q.mix(l,n[e].cfg,false);var d=l.pluginContext,c=l.func,f=l.editor,o=l.bubble;f.on("selectionChange",function(h){h=h.path;var a=h.elements;if(h&&a)if(h=h.lastElement)if(h=c(h)){o=k(e);o._selectedEl=h;o._plugin=d;o.hide();setTimeout(function(){o.show()},10)}else if(o){o._selectedEl=o._plugin=null;o.hide()}});f.on("sourcemode blur",g);t.on(s._4e_getWin(f.document),
"scroll",g)};u.register=function(l){var g=l.pluginName;n[g]=n[g]||{cfg:l};t.on(document,"click",function(){l.bubble&&l.bubble.hide()});l.editor&&u.attach(l)};r.BubbleView=u}},{attach:false,requires:["overlay"]});
KISSY.Editor.add("clipboard",function(k){var q=KISSY,r=q.Editor,t=q.Node,s=q.UA,u=r.Range,n=r.RANGE,l=q.Event;r.Paste||function(){function g(b){this.editor=b;this._init()}function e(b){if(!(!s.ie||b.document.compatMode=="BackCompat")){var i=b.getSelection(),m;if(i.getType()==h.SELECTION_ELEMENT&&(m=i.getSelectedElement())){var v=i.getRanges()[0],x=new t(b.document.createTextNode(""));x.insertBefore(m);v.setStartBefore(x);v.setEndAfter(m);i.selectRanges([v]);setTimeout(function(){if(m.parent()){x.remove();
i.selectElement(m)}},0)}}}q.augment(g,{_init:function(){var b=this.editor;s.ie?l.on(b.document,"keydown",this._paste,this):l.on(b.document,"paste",this._paste,this);b.addCommand("copy",new o("copy"));b.addCommand("cut",new o("cut"));b.addCommand("paste",new o("paste"))},_paste:function(b){if(!(b.type==="keydown"&&!(b.keyCode===86&&(b.ctrlKey||b.metaKey)))){var i=this,m=i.editor,v=m.document;if(i._running)b.halt();else{var x=m.getSelection();b=new u(v);var p=new t(s.webkit?"<body></body>":"<div></div>",
null,v);s.webkit&&p[0].appendChild(v.createTextNode("\u00a0"));v.body.appendChild(p[0]);p.css({position:"absolute",top:x.getStartElement().offset().top+"px",width:"1px",height:"1px",overflow:"hidden"});p.css("left","-1000px");var z=x.createBookmarks();b.setStartAt(p,n.POSITION_AFTER_START);b.setEndAt(p,n.POSITION_BEFORE_END);b.select(true);i._running=true;setTimeout(function(){p._4e_remove();var y;p=s.webkit&&(y=p._4e_first())&&y.hasClass("Apple-style-span")?y:p;x.selectBookmarks(z);y=p.html();var E=m.fire("paste",
{html:y,holder:p});if(E!==undefined)y=E;E=null;if(/(class="?Mso|style="[^"]*\bmso\-|w:WordDocument)/.test(y))E=m.htmlDataProcessor.wordFilter;m.insertHtml(y,E);i._running=false},0)}}}});r.Paste=g;var d=function(b,i){var m=b.document,v=new t(m.body),x=false,p=function(){x=true};v.on(i,p);(s.ie>7?m:m.selection.createRange()).execCommand(i);v.detach(i,p);return x},c=s.ie?function(b,i){return d(b,i)}:function(b,i){try{return b.document.execCommand(i)}catch(m){return false}},f={cut:"\u60a8\u7684\u6d4f\u89c8\u5668\u5b89\u5168\u8bbe\u7f6e\u4e0d\u5141\u8bb8\u7f16\u8f91\u5668\u81ea\u52a8\u6267\u884c\u526a\u5207\u64cd\u4f5c\uff0c\u8bf7\u4f7f\u7528\u952e\u76d8\u5feb\u6377\u952e(Ctrl/Cmd+X)\u6765\u5b8c\u6210",
copy:"\u60a8\u7684\u6d4f\u89c8\u5668\u5b89\u5168\u8bbe\u7f6e\u4e0d\u5141\u8bb8\u7f16\u8f91\u5668\u81ea\u52a8\u6267\u884c\u590d\u5236\u64cd\u4f5c\uff0c\u8bf7\u4f7f\u7528\u952e\u76d8\u5feb\u6377\u952e(Ctrl/Cmd+C)\u6765\u5b8c\u6210",paste:"\u60a8\u7684\u6d4f\u89c8\u5668\u5b89\u5168\u8bbe\u7f6e\u4e0d\u5141\u8bb8\u7f16\u8f91\u5668\u81ea\u52a8\u6267\u884c\u7c98\u8d34\u64cd\u4f5c\uff0c\u8bf7\u4f7f\u7528\u952e\u76d8\u5feb\u6377\u952e(Ctrl/Cmd+V)\u6765\u5b8c\u6210"},o=function(b){this.type=b;this.canUndo=this.type=="cut"};o.prototype={exec:function(b){this.type=="cut"&&e(b);(b=c(b,this.type))||alert(f[this.type]);return b}};var h=r.Selection,a={copy:"\u590d\u5236",paste:"\u7c98\u8d34",cut:"\u526a\u5207"};r.on("contextmenu",function(b){var i=b.contextmenu,m=i.cfg.editor,v=i.elDom,x={copy:0,cut:0,paste:0},p;for(p in x){if(!x.hasOwnProperty(p))break;x[p]=v.one(".ke-paste-"+p);(function(z){var y=
x[z];if(!y){y=(new t("<a href='#'class='ke-paste-"+z+"'>"+a[z]+"</a>")).appendTo(v);y.on("click",function(E){E.halt();if(!y.hasClass("ke-menuitem-disable")){i.hide();setTimeout(function(){m.execCommand(z)},30)}})}x[z]=y})(p);b=x[p];(m.document.queryCommandEnabled(p)?true:false)?b.removeClass("ke-menuitem-disable"):b.addClass("ke-menuitem-disable")}})}();new r.Paste(k)},{attach:false});
KISSY.Editor.add("color",function(k){k.addPlugin("color",function(){var q=KISSY.Editor,r=k.cfg.pluginConfig,t=[];false!==r.forecolor&&function(){var s=k.addButton("color",{styles:{element:"span",styles:{color:"#(color)"},overrides:[{element:"font",attributes:{color:null}}]},mode:q.WYSIWYG_MODE,title:"\u6587\u672c\u989c\u8272",loading:true,contentCls:"ke-toolbar-color"});q.use("colorsupport",function(){s.reload(q.ColorSupport)});t.push(function(){s.destroy()})}();false!==r.bgcolor&&function(){var s=k.addButton("color",
{styles:{element:"span",styles:{"background-color":"#(color)"},overrides:[{element:"*",styles:{"background-color":null}}]},title:"\u80cc\u666f\u989c\u8272",mode:q.WYSIWYG_MODE,loading:true,contentCls:"ke-toolbar-bgcolor"});q.use("colorsupport",function(){s.reload(q.ColorSupport)});t.push(function(){s.destroy()})}();this.destroy=function(){for(var s=0;s<t.length;s++)t[s]()}})},{attach:false});
KISSY.Editor.add("colorsupport",function(){function k(){if(!l){l="<div class='ke-color-panel'><a class='ke-color-remove' href=\"javascript:void('\u6e05\u9664');\">\u6e05\u9664</a>";for(var d=0;d<3;d++){l+="<div class='ke-color-palette'><table>";for(var c=n[d],f=c.length/8,o=0;o<f;o++){l+="<tr>";for(var h=0;h<8;h++){var a="#"+c[8*o+h];l+="<td>";l+="<a href='javascript:void(0);' class='ke-color-a' style='background-color:"+a+"'></a>";l+="</td>"}l+="</tr>"}l+="</table></div>"}l+="<div><a class='ke-button ke-color-others'>\u5176\u4ed6\u989c\u8272</a></div></div>"}}
var q=KISSY,r=q.Editor,t=q.Node,s=q.Event,u=q.DOM;u.addStyleSheet(".ke-color-panel a {display: block;color:black;text-decoration: none;}.ke-color-panel a:hover {color:black;text-decoration: none;}.ke-color-panel a:active {color:black;}.ke-color-palette {    margin: 5px 8px 8px;}.ke-color-palette table {    border: 1px solid #666666;    border-collapse: collapse;}.ke-color-palette td {    border-right: 1px solid #666666;    height: 18px;    width: 18px;}a.ke-color-a {    height: 18px;    width: 18px;}a.ke-color-a:hover {    border: 1px solid #ffffff;    height: 16px;    width: 16px;}a.ke-color-remove {  padding:3px 8px;  margin:2px 0 3px 0;}a.ke-color-remove:hover {    background-color: #D6E9F8;}",
"ke-color-plugin");var n=[["000","444","666","999","CCC","EEE","F3F3F3","FFF"],["F00","F90","FF0","0F0","0FF","00F","90F","F0F"],["F4CCCC","FCE5CD","FFF2CC","D9EAD3","D0E0E3","CFE2F3","D9D2E9","EAD1DC","EA9999","F9CB9C","FFE599","B6D7A8","A2C4C9","9FC5E8","B4A7D6","D5A6BD","E06666","F6B26B","FFD966","93C47D","76A5AF","6FA8DC","8E7CC3","C27BAD","CC0000","E69138","F1C232","6AA84F","45818E","3D85C6","674EA7","A64D79","990000","B45F06","BF9000","38761D","134F5C","0B5394","351C75","741B47","660000","783F04",
"7F6000","274E13","0C343D","073763","20124D","4C1130"]],l,g=r.Utils.addRes,e=r.Utils.destroyRes;r.ColorSupport={offClick:function(d){var c=this,f=c.cfg;r.use("overlay",function(){f._prepare.call(c,d)})},onClick:function(){this.colorWin&&this.colorWin.hide()},_prepare:function(){var d=this,c=d.cfg,f=document,o=d.btn,h=d.editor,a;k();d.colorWin=new r.Overlay({elCls:"ks-popup",content:l,focus4e:false,autoRender:true,width:"190px",zIndex:r.baseZIndex(r.zIndexManager.POPUP_MENU)});var b=d.colorWin;a=b.get("contentEl");
a.on("click",c._selectColor,d);s.on(f,"click",c._hidePanel,d);s.on(h.document,"click",c._hidePanel,d);b.on("show",o.bon,o);b.on("hide",o.boff,o);f=a.one(".ke-color-others");f.on("click",function(i){i.halt();b.hide();h.useDialog("color/dialog",function(m){m.show(d)})});c._prepare=c._show;c._show.call(d);g.call(d,a,b,f)},_show:function(){var d=this.btn.get("el"),c=this.colorWin,f=parseInt(c.get("width")),o=u.viewportWidth();c.align(d,["bl","tl"],[0,2]);c.get("x")+f>o-30&&c.set("x",o-30-f);c.show()},
_hidePanel:function(d){var c=this.btn.get("el");d=new t(d.target);var f=this.colorWin;c._4e_equals(d)||c.contains(d)||f.hide()},_selectColor:function(d){d.halt();var c=this.cfg;d=new t(d.target);if(d._4e_name()=="a"&&!d.hasClass("ke-button")){c._applyColor.call(this,d._4e_style("background-color"));this.colorWin.hide()}},_applyColor:function(d){var c=this.editor,f=c.document,o=this.cfg.styles;c.fire("save");d?(new r.Style(o,{color:d})).apply(f):(new r.Style(o,{color:"inherit"})).remove(f);c.fire("save")},
destroy:function(){e.call(this);var d=this.editor;s.remove(document,"click",this.cfg._hidePanel,this);d.destroyDialog("color/dialog")}}},{attach:false});
KISSY.Editor.add("contextmenu",function(){function k(e){this.cfg=e;t.Utils.lazyRun(this,"_prepareShow","_realShow")}function q(e,d){for(var c=0;c<d.length;c++){var f=d[c];if(r.isFunction(f)){if(f(new s(e)))return true}else if(u.test(e,f))return true}return false}var r=KISSY,t=r.Editor,s=r.Node,u=r.DOM,n=r.Event;if(t.ContextMenu)r.log("attach ContextMenu twice","warn");else{k.ATTRS={editor:{}};var l=[];k.register=function(e){var d=new k(e),c=e.editor,f=c.document;l.push({doc:f,rules:e.rules||[],instance:d});
if(!f.ke_contextmenu){f.ke_contextmenu=1;n.on(f,"mousedown",k.hide);c.on("sourcemode",k.hide,f);n.on(f,"contextmenu",function(o){k.hide.call(this);for(var h=new s(o.target);h;){var a=false;if(h._4e_name()=="body")break;for(var b=0;b<l.length;b++){var i=l[b].instance,m=l[b].rules;if(f===l[b].doc&&q(h[0],m)){o.preventDefault();a=true;var v=o.pageX,x=o.pageY;if(!v){b=h._4e_getOffset();v=b.left;x=b.top}setTimeout(function(){i.show(t.Utils.getXY(v,x,f,document))},30);break}}if(a)break;h=h.parent()}})}return d};
k.hide=function(){for(var e=0;e<l.length;e++){var d=l[e].instance;this===l[e].doc&&d.hide()}};var g=t.Overlay;r.augment(k,{_init:function(){var e=this,d=e.cfg,c=d.funcs;e.el=new g({content:"<div>",autoRender:true,width:d.width,elCls:"ke-menu"});e.elDom=e.el.get("contentEl").one("div");d=e.elDom;for(var f in c){var o=new s("<a href='#'>"+f+"</a>");d[0].appendChild(o[0]);(function(h,a){h._4e_unselectable();h.on("click",function(b){b.halt();if(!h.hasClass("ke-menuitem-disable")){e.hide();setTimeout(a,
30)}})})(o,c[f])}},destroy:function(){if(this.el){this.elDom.children().detach();this.el.destroy()}},hide:function(){this.el&&this.el.hide()},_realShow:function(e){t.fire("contextmenu",{contextmenu:this});this.el.set("xy",[e.left,e.top]);e=this.cfg;var d=e.statusChecker;if(d)for(var c=this.elDom.children("a"),f=0;f<c.length;f++){var o=new s(c[f]),h=d[r.trim(o.text())];if(h)h(e.editor)?o.removeClass("ke-menuitem-disable"):o.addClass("ke-menuitem-disable")}this.el.show()},_prepareShow:function(){this._init()},
show:function(e){this._prepareShow(e)}});t.ContextMenu=k}},{attach:false,requires:["overlay"]});KISSY.Editor.add("draft",function(k){var q=KISSY.Editor;k.addPlugin("draft",function(){var r=this;q.use("draft/support",function(){q.storeReady(function(){var t=new q.Draft(k);r.destroy=function(){t.destroy()}})})})},{attach:false});
KISSY.Editor.add("draft/support",function(){function k(c,f,o){for(c+="";c.length<f;)c=o+c;return c}function q(c){if(t.isNumber(c))c=new Date(c);return c instanceof Date?[c.getFullYear(),"-",k(c.getMonth()+1,2,"0"),"-",k(c.getDate(),2,"0")," ",k(c.getHours(),2,"0"),":",k(c.getMinutes(),2,"0"),":",k(c.getSeconds(),2,"0")].join(""):c}function r(c){this.editor=c;this._init()}var t=KISSY,s=t.Editor,u=t.Node,n=t.Event,l=t.JSON,g=window[s.STORE],e=s.Utils.addRes,d=s.Utils.destroyRes;t.augment(r,{_getDrafts:function(){if(!this.drafts){var c=
g.getItem("ke-draft-save20110407"),f=[];if(c)f=t.isString(c)?l.parse(decodeURIComponent(c)):c;this.drafts=f}return this.drafts},_init:function(){var c=this,f=c.editor,o=f.statusDiv,h=f.cfg.pluginConfig;h.draft=h.draft||{};c.draftInterval=h.draft.interval=h.draft.interval||5;c.draftLimit=h.draft.limit=h.draft.limit||5;o=(new u("<div class='ke-draft'><spa class='ke-draft-title'>\u5185\u5bb9\u6b63\u6587\u6bcf"+h.draft.interval+"\u5206\u949f\u81ea\u52a8\u4fdd\u5b58\u4e00\u6b21\u3002</span></div>")).appendTo(o);c.timeTip=(new u("<span class='ke-draft-time'>")).appendTo(o);
var a=(new u("<a class='ke-button ke-draft-save-btn' style='vertical-align:middle;padding:1px 9px;'><span class='ke-draft-mansave'></span><span>\u7acb\u5373\u4fdd\u5b58</span></a>")).appendTo(o),b=new s.Select({container:o,menuContainer:document.body,doc:f.document,width:"85px",popUpWidth:"225px",align:["r","t"],emptyText:"&nbsp;&nbsp;&nbsp;\u5c1a\u65e0\u7f16\u8f91\u5668\u5386\u53f2\u5b58\u5728",title:"\u6062\u590d\u7f16\u8f91\u5386\u53f2"});c.versions=b;b.on("select",function(){b.detach("select",arguments.callee);c.sync()});a._4e_unselectable();a.on("click",function(m){c.save(false);m.halt()});
e.call(c,a);f.textarea[0].form&&function(){function m(){c.save(true)}var v=f.textarea[0].form;n.on(v,"submit",m);e.call(c,function(){n.remove(v,"submit",m)})}();var i=setInterval(function(){c.save(true)},c.draftInterval*60*1E3);e.call(c,function(){clearInterval(i)});b.on("click",c.recover,c);e.call(c,b);c.holder=o;if(h.draft.helpHtml){h=new s.TripleButton({cls:"ke-draft-help",title:"\u5e2e\u52a9",text:"\u5e2e\u52a9",container:o});h.on("click",function(m){c._prepareHelp();m&&m.halt()});e.call(c,h);s.Utils.lazyRun(c,"_prepareHelp",
"_realHelp");c.helpBtn=h.el}c._holder=o;e.call(c,o)},_prepareHelp:function(){function c(i){i&&i.halt();i=new u(i.target);i[0]==h[0]||h.contains(i)||f._help.hide()}var f=this,o=f.editor,h=f.helpBtn,a=new u(o.cfg.pluginConfig.draft.helpHtml||""),b=new u("<div style='height:0;position:absolute;font-size:0;width:0;border:8px #000 solid;border-color:#000 transparent transparent transparent;border-style:solid dashed dashed dashed;border-top-color:#CED5E0;'><div style='height:0;position:absolute;font-size:0;width:0;border:8px #000 solid;border-color:#000 transparent transparent transparent;border-style:solid dashed dashed dashed;left:-8px;top:-10px;border-top-color:white;'></div></div>");
a.append(b);a.css({border:"1px solid #ACB4BE","text-align":"left"});f._help=new t.Overlay({content:a,autoRender:true,width:a.width()+"px",mask:false});f._help.el.css("border","none");f._help.arrow=b;n.on([document,o.document],"click",c);e.call(f,f._help,function(){n.remove([document,o.document],"click",c)})},_realHelp:function(){var c=this._help,f=this.helpBtn,o=c.arrow;c.show();f=f.offset();c.el.offset({left:f.left-c.el.width()+17,top:f.top-c.el.height()-7});o.offset({left:f.left-2,top:f.top-8})},
disable:function(){this.holder.css("visibility","hidden")},enable:function(){this.holder.css("visibility","")},sync:function(){var c=this.draftLimit,f=this.timeTip,o=this.versions,h=this._getDrafts();h.length>c&&h.splice(0,h.length-c);c=[];for(var a,b=0;b<h.length;b++){a=h[b];a=(a.auto?"\u81ea\u52a8":"\u624b\u52a8")+"\u4fdd\u5b58\u4e8e : "+q(a.date);c.push({name:a,value:b})}o.set("items",c.reverse());f.html(a);g.setItem("ke-draft-save20110407",encodeURIComponent(l.stringify(h)))},save:function(c){var f=this._getDrafts(),o=this.editor.getData(true);
if(o){var h=this.draftLimit;if(t.UA.ie&&o.length>1E5/(h*1.2))c||alert("\u6587\u7ae0\u6709\u70b9\u957f\uff0c\u8349\u7a3f\u7bb1\u5bb9\u4e0d\u4e0b:(");else{if(f[f.length-1]&&o==f[f.length-1].content)f.length-=1;this.drafts=f.concat({content:o,date:(new Date).getTime(),auto:c});this.sync()}}},recover:function(c){var f=this.editor,o=this.versions,h=this._getDrafts(),a=c.newVal;o.reset("value");if(confirm("\u786e\u8ba4\u6062\u590d "+q(h[a].date)+" \u7684\u7f16\u8f91\u5386\u53f2\uff1f")){f.fire("save");f.setData(h[a].content);f.fire("save")}c&&c.halt()},destroy:function(){d.call(this)}});s.Draft=r},{attach:false,
requires:["localstorage"]});
KISSY.Editor.add("dragupload",function(k){function q(m){m=m.originalEvent.target;if(g._4e_name(m)=="img"&&m.src.match(/^file:\/\//))b[m.src]=m}function r(m,v){var x=new FileReader;x.onload=function(p){var z=m.name;p=p.target.result;var y=new XMLHttpRequest;y.open("POST",o,true);y.onreadystatechange=function(){if(y.readyState==4){if(y.status==200||y.status==304){if(y.responseText!=""){var j=window.JSON.parse(y.responseText);v[0].src=j.imgUrl}}else{alert("\u670d\u52a1\u5668\u7aef\u51fa\u9519\uff01");v._4e_remove();t.log(y)}y.onreadystatechange=
null}};var E="\r\n------kissy-editor-2.1\r\n";E+='Content-Disposition: form-data; name="'+d+'"; filename="'+encodeURIComponent(z)+'"\r\n';E+="Content-Type: "+(m.type||"application/octet-stream")+"\r\n\r\n";E+=p+"\r\n";f=s.Utils.normParams(f);for(var D in f)if(f.hasOwnProperty(D)){E+="------kissy-editor-2.1\r\n";E+='Content-Disposition: form-data; name="'+D+'"\r\n\r\n';E+=f[D]+"\r\n"}E+="------kissy-editor-2.1--";y.setRequestHeader("Content-Type","multipart/form-data, boundary=----kissy-editor-2.1");
y.sendAsBinary("Content-Type: multipart/form-data; boundary=----kissy-editor-2.1\r\nContent-Length: "+E.length+"\r\n"+E+"\r\n");x.onload=null};x.readAsBinaryString(m)}var t=KISSY,s=t.Editor,u=t.Node,n=t.Event,l=t.UA,g=t.DOM,e=k.cfg.pluginConfig.dragupload||{},d=e.fileInput||"Filedata",c=e.sizeLimit||Number.MAX_VALUE,f=e.serverParams||{},o=e.serverUrl||"",h=RegExp((e.suffix||"png,jpg,jpeg,gif").split(/,/).join("|")+"$","i"),a=k.document;if(!l.ie){var b={},i=false;n.on(a,"dragenter",function(){if(!i){n.on(a,
"DOMNodeInserted",q);i=true}});n.on(a,"dragenter dragover",function(m){m.halt()});n.on(a,"drop",function(m){n.remove(a,"DOMNodeInserted",q);i=false;m.halt();m=m.originalEvent;t.log(m);var v,x;if(t.isEmptyObject(b)){x=a.elementFromPoint(m.clientX,m.clientY);v=x.lastChild}else{t.each(b,function(E){if(g._4e_name(E)=="img"){v=E.nextSibling;x=E.parentNode;g._4e_remove(E)}});b={}}m=m.dataTransfer;m.dropEffect="copy";if(m=m.files)for(var p=0;p<m.length;p++){var z=m[p],y=z.size;if(z.name.match(h))if(!(y/
1E3>c)){y=new u("<img src='"+(s.Config.base+"../theme/loading.gif")+"'/>");x.insertBefore(y[0],v);r(z,y)}}});if(window.XMLHttpRequest&&!XMLHttpRequest.prototype.sendAsBinary)XMLHttpRequest.prototype.sendAsBinary=function(m,v){for(var x=new BlobBuilder,p=m.length,z=new Uint8Array(p),y=0;y<p;y++)z[y]=m.charCodeAt(y);x.append(z.buffer);this.send(x.getBlob(v))}}},{attach:false});
KISSY.Editor.add("elementpaths",function(k){var q=KISSY.Editor,r=KISSY,t=r.Node,s=r.DOM;q.ElementPaths||function(){function u(n){this.cfg=n;this._cache=[];this._init()}s.addStyleSheet(".elementpath {   padding: 0 5px;    text-decoration: none;}.elementpath:hover {    background: #CCFFFF;    text-decoration: none;}","ke-ElementPaths");r.augment(u,{_init:function(){var n=this.cfg.editor;this.holder=new t("<span>");this.holder.appendTo(n.statusDiv);n.on("selectionChange",this._selectionChange,this);
q.Utils.sourceDisable(n,this)},disable:function(){this.holder.css("visibility","hidden")},enable:function(){this.holder.css("visibility","")},_selectionChange:function(n){var l=this.cfg.editor,g=this.holder;n=n.path.elements;var e,d;e=this._cache;for(d=0;d<e.length;d++){e[d].detach("click");e[d]._4e_remove()}this._cache=[];for(d=0;d<n.length;d++){e=n[d];var c=new t("<a href='#' class='elementpath'>"+(e.attr("_ke_real_element_type")||e._4e_name())+"</a>");this._cache.push(c);(function(f){c.on("click",
function(o){o.halt();l.focus();setTimeout(function(){l.getSelection().selectElement(f)},50)})})(e);g.prepend(c)}},destroy:function(){this.holder.remove()}});q.ElementPaths=u}();k.addPlugin("elementpaths",function(){var u=new q.ElementPaths({editor:k});this.destroy=function(){u.destroy()}})},{attach:false});
KISSY.Editor.add("enterkey",function(k){var q=KISSY,r=q.Editor,t=q.UA,s=/^h[1-6]$/,u=r.XHTML_DTD,n=q.Node,l=q.Event,g=r.Walker,e=r.ElementPath;r.enterBlock||function(){function d(c){l.on(c.document,"keydown",function(f){if(f.keyCode===13)if(!f.shiftKey){c.fire("save");var o=c.execCommand("enterBlock");c.fire("save");o!==false&&f.preventDefault()}})}d.enterBlock=function(c){var f;f=c.getSelection().getRanges();for(var o=f.length-1;o>0;o--)f[o].deleteContents();f=f[0];o=f.document;if(f.checkStartOfBlock()&&
f.checkEndOfBlock()){var h=(new e(f.startContainer)).block;if(h&&(h._4e_name()=="li"||h.parent()._4e_name()=="li"))if(c.hasCommand("outdent")){c.fire("save");c.execCommand("outdent");c.fire("save");return true}else return false}var a=f.splitBlock("p");if(!a)return true;c=a.previousBlock;h=a.nextBlock;var b=a.wasStartOfBlock,i=a.wasEndOfBlock,m;if(h){m=h.parent();if(m._4e_name()=="li"){h._4e_breakParent(m);h._4e_move(h._4e_next(),true)}}else if(c&&(m=c.parent())&&m._4e_name()=="li"){c._4e_breakParent(m);
f.moveToElementEditablePosition(c._4e_next());c._4e_move(c._4e_previous())}if(!b&&!i){if(h._4e_name()=="li"&&(m=h._4e_first(g.invisible(true)))&&q.inArray(m._4e_name(),["ul","ol"]))(t.ie?new n(o.createTextNode("\u00a0")):new n(o.createElement("br"))).insertBefore(m);h&&f.moveToElementEditablePosition(h)}else{var v;if(c){if(c._4e_name()=="li"||!s.test(c._4e_name()))v=c._4e_clone()}else if(h)v=h._4e_clone();v||(v=new n("<p>",null,o));if(m=a.elementPath){a=0;for(var x=m.elements.length;a<x;a++){var p=m.elements[a];
if(p._4e_equals(m.block)||p._4e_equals(m.blockLimit))break;if(u.$removeEmpty[p._4e_name()]){p=p._4e_clone();v._4e_moveChildren(p);v.append(p)}}}t.ie||v._4e_appendBogus();f.insertNode(v);if(t.ie&&b&&(!i||!c[0].childNodes.length)){f.moveToElementEditablePosition(i?c:v);f.select()}f.moveToElementEditablePosition(b&&!i?h:v)}if(!t.ie)if(h){v=new n(o.createElement("span"));v.html("&nbsp;");f.insertNode(v);v._4e_scrollIntoView();f.deleteContents()}else v._4e_scrollIntoView();f.select();return true};r.EnterKey=
d}();k.addCommand("enterBlock",{exec:r.EnterKey.enterBlock});r.EnterKey(k)},{attach:false});
KISSY.Editor.add("fakeobjects",function(k){var q=KISSY.Editor,r=KISSY,t=r.Node,s=q.NODE,u=q.Config.base+"../theme/spacer.gif",n=q.HtmlParser;q=r.Editor;var l=k.htmlDataProcessor,g=l&&l.htmlFilter,e={elements:{$:function(d){var c=d.attributes;if((c=(c=(c=c&&c._ke_realelement)&&new n.Fragment.FromHtml(decodeURIComponent(c)))&&c.children[0])&&d.attributes._ke_resizable){var f=d.attributes.style;if(f){var o=/(?:^|\s)width\s*:\s*(\d+)/i.exec(f);d=o&&o[1];f=(o=/(?:^|\s)height\s*:\s*(\d+)/i.exec(f))&&o[1];
if(d)c.attributes.width=d;if(f)c.attributes.height=f}}return c}}};g&&g.addRules(e);l&&r.mix(l,{createFakeParserElement:function(d,c,f,o,h){var a;a=new n.BasicWriter;d.writeHtml(a);a=a.getHtml();var b=d.attributes.style||"";if(d.attributes.width)b="width:"+d.attributes.width+"px;"+b;if(d.attributes.height)b="height:"+d.attributes.height+"px;"+b;d={"class":c,src:u,_ke_realelement:encodeURIComponent(a),_ke_real_node_type:d.type,style:b,align:d.attributes.align||""};h&&delete h.width;h&&delete h.height;
h&&r.mix(d,h,false);if(f)d._ke_real_element_type=f;if(o)d._ke_resizable=o;return new n.Element("img",d)}});k.createFakeElement||r.augment(q,{createFakeElement:function(d,c,f,o,h,a){var b=d.attr("style")||"";if(d.attr("width"))b="width:"+d.attr("width")+"px;"+b;if(d.attr("height"))b="height:"+d.attr("height")+"px;"+b;d={"class":c,src:u,_ke_realelement:encodeURIComponent(h||d._4e_outerHtml()),_ke_real_node_type:d[0].nodeType,style:b};a&&delete a.width;a&&delete a.height;a&&r.mix(d,a,false);if(f)d._ke_real_element_type=
f;if(o)d._ke_resizable=o;return new t("<img/>",d,this.document)},restoreRealElement:function(d){if(d.attr("_ke_real_node_type")!=s.NODE_ELEMENT)return null;d=decodeURIComponent(d.attr("_ke_realelement"));var c=new t("<div>",null,this.document);c.html(d);return c._4e_first(function(f){return f[0].nodeType==s.NODE_ELEMENT})._4e_remove()}})},{attach:false,requires:["htmldataprocessor"]});
KISSY.Editor.add("flash",function(k){var q=KISSY.Editor,r=k.htmlDataProcessor,t=k.cfg.pluginConfig,s=r&&r.dataFilter;s&&s.addRules({elements:{object:function(u){var n=u.attributes;if(!(n.classid&&String(n.classid).toLowerCase())){for(n=0;n<u.children.length;n++)if(u.children[n].name=="embed"){if(!q.Utils.isFlashEmbed(u.children[n]))break;return r.createFakeParserElement(u,"ke_flash","flash",true)}return null}return r.createFakeParserElement(u,"ke_flash","flash",true)},embed:function(u){if(!q.Utils.isFlashEmbed(u))return null;
return r.createFakeParserElement(u,"ke_flash","flash",true)}}},5);k.addPlugin("flash",function(){var u;if(!t.flash||t.flash.btn!==false)u=k.addButton("flash",{contentCls:"ke-toolbar-flash",title:"\u63d2\u5165Flash",mode:q.WYSIWYG_MODE,loading:true});q.use("flash/support",function(){var n=new q.Flash(k);u&&u.reload({offClick:function(){n.show()},destroy:function(){n.destroy()}})});this.destroy=function(){u.destroy()}})},{attach:false,requires:["fakeobjects"]});
KISSY.Editor.add("flash/support",function(){function k(f){this.editor=f;this._init()}function q(f){return f._4e_name()==="img"&&!!f.hasClass(e)&&f}var r=KISSY,t=r.Editor,s=r.UA,u=r.Event,n=t.ContextMenu,l=r.Node,g=t.BubbleView,e="ke_flash",d=t.Utils.flash;r.augment(k,{_config:function(){this._cls=e;this._type="flash";this._contextMenu=c;this._flashRules=["img."+e]},_init:function(){this._config();var f=this,o=f.editor,h={},a=f._contextMenu;if(a)for(var b in a)(function(i){h[i]=function(){a[i](f)}})(b);
f._contextMenu=n.register({editor:o,rules:f._flashRules,width:"120px",funcs:h});g.attach({pluginName:f._type,editor:f.editor,pluginContext:f});u.on(o.document,"dblclick",f._dbclick,f)},_getFlashUrl:function(f){return d.getUrl(f)},_updateTip:function(f,o){var h=this.editor.restoreRealElement(o);if(h){h=this._getFlashUrl(h);f.html(h);f.attr("href",h)}},_dbclick:function(f){var o=new l(f.target);if(o._4e_name()==="img"&&o.hasClass(this._cls)){this.show(null,o);f.halt()}},show:function(f,o){this.editor.useDialog(this._type+
"/dialog",function(h){h.show(o)})},destroy:function(){var f=this.editor;this._contextMenu.destroy();g.destroy(this._type);u.remove(f.document,"dblclick",this._dbclick,this);f.destroyDialog(this._type+"/dialog")}});t.Flash=k;k.registerBubble=function(f,o,h){g.register({pluginName:f,func:h,init:function(){var a=this,b=a.get("contentEl");b.html(o+' <a class="ke-bubbleview-url" target="_blank" href="#"></a> -  <span class="ke-bubbleview-link ke-bubbleview-change">\u7f16\u8f91</span> -  <span class="ke-bubbleview-link ke-bubbleview-remove">\u5220\u9664</span>');
var i=b.one(".ke-bubbleview-url"),m=b.one(".ke-bubbleview-change"),v=b.one(".ke-bubbleview-remove");t.Utils.preventFocus(b);m.on("click",function(x){a._plugin.show(null,a._selectedEl);x.halt()});v.on("click",function(x){var p=a._plugin;if(s.webkit){var z=p.editor.getSelection().getRanges();z&&z[0]&&(z[0].collapse(true)||1)&&z[0].select()}a._selectedEl._4e_remove();a.hide();p.editor.notifySelectionChange();x.halt()});t.Utils.addRes.call(a,m,v);a.on("show",function(){var x=a._selectedEl;x&&a._plugin._updateTip(i,
x)})}})};k.registerBubble("flash","Flash \u7f51\u5740\uff1a ",q);k.checkFlash=q;var c={"Flash\u5c5e\u6027":function(f){var o=f.editor.getSelection();o=o&&o.getStartElement();(o=q(o))&&f.show(null,o)}};k.CLS_FLASH=e;k.TYPE_FLASH="flash";k.Insert=function(f,o,h,a,b,i){o=d.createSWF(o,{attrs:h},f.document);var m=o.el;h=f.createFakeElement?f.createFakeElement(m,a||"ke_flash",b||"flash",true,o.html,h):m;f.insertElement(h,null,i)};t.Flash=k},{attach:false,requires:["bubbleview","contextmenu","flashutils"]});
KISSY.Editor.add("flashbridge",function(){function k(d){this._init(d)}function q(d){var c=t.isString(d)?d.match(/(\d)+/g):d;d=d;if(t.isArray(c))d=parseFloat(c[0]+"."+r(c[1],3)+r(c[2],5));return d||0}function r(d,c){for(var f=(d+"").length;f++<c;)d="0"+d;return d}var t=KISSY,s=t.Editor;if(s.FlashBridge)t.log("KE.FlashBridge attach more","warn");else{var u={};t.augment(k,t.EventTarget,{_init:function(d){var c=t.guid("flashbridge-");d.flashVars=d.flashVars||{};d.attrs=d.attrs||{};d.params=d.params||
{};var f=d.flashVars,o=d.params;t.mix(d.attrs,{id:c,width:"100%",height:"100%"},false);t.mix(o,{allowScriptAccess:"sameDomain",allowNetworking:"all",scale:"noScale"},false);t.mix(f,{shareData:false,useCompression:false},false);o={YUISwfId:c,YUIBridgeCallback:"KISSY.Editor.FlashBridge.EventHandler"};if(d.ajbridge)o={swfID:c,jsEntry:"KISSY.Editor.FlashBridge.EventHandler"};t.mix(f,o);u[c]=this;this.id=c;this.swf=s.Utils.flash.createSWFRuntime(d.movie,d);this._expose(d.methods)},_expose:function(d){for(var c=
this,f=0;f<d.length;f++)(function(o){c[o]=function(){return c._callSWF(o,t.makeArray(arguments))}})(d[f])},_callSWF:function(d,c){c=c||[];try{if(this.swf[d])return this.swf[d].apply(this.swf,c)}catch(f){var o="";if(c.length!==0)o="'"+c.join("', '")+"'";return(new Function("self","return self.swf."+d+"("+o+");"))(this)}},_eventHandler:function(d){var c=d.type;if(c==="log")t.log(d.message);else c&&this.fire(c,d)},_destroy:function(){delete u[this.id]}});k.EventHandler=function(d,c){var f=u[d];f&&setTimeout(function(){f._eventHandler.call(f,
c)},100)};s.FlashBridge=k;var n=t.UA,l,g,e=true;n.fpv=function(d){if(d||e){e=false;var c;if(navigator.plugins&&navigator.mimeTypes.length)c=(navigator.plugins["Shockwave Flash"]||{}).description;else if(window.ActiveXObject)try{c=(new ActiveXObject("ShockwaveFlash.ShockwaveFlash")).GetVariable("$version")}catch(f){}l=c?c.match(/(\d)+/g):void 0;g=q(l)}return l};n.fpvGEQ=function(d,c){e&&n.fpv(c);return!!g&&g>=q(d)}}},{attach:false});
KISSY.Editor.add("flashutils",function(){var k=KISSY,q=k.Editor,r=q.Utils.flash;if(r)k.log("flashUtils attach more");else{var t=k.DOM,s=k.Node,u=k.UA;r={getUrl:function(n){var l="",g=q.NODE;if(n._4e_name()=="object"){n=n[0].childNodes;for(var e=0;e<n.length;e++)if(n[e].nodeType==g.NODE_ELEMENT)if((t.attr(n[e],"name")||"").toLowerCase()=="movie")l=t.attr(n[e],"value");else if(t._4e_name(n[e])=="embed")l=t.attr(n[e],"src");else if(t._4e_name(n[e])=="object")l=t.attr(n[e],"data")}else if(n._4e_name()==
"embed")l=n.attr("src");return l},createSWF:function(n,l,g){var e=l.attrs||{},d=l.flashVars,c="",f="";l=l.params||{};var o="";g=g||document;k.mix(e,{wmode:"transparent"});for(var h in e)if(e.hasOwnProperty(h))c+=h+"='"+e[h]+"' ";k.mix(l,{quality:"high",movie:n,wmode:"transparent"});for(var a in l)if(l.hasOwnProperty(a))f+="<param name='"+a+"' value='"+l[a]+"'/>";if(d){for(var b in d)if(d.hasOwnProperty(b))o+="&"+b+"="+encodeURIComponent(d[b]);o=o.substring(1)}n="<object "+c+' classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" >'+
f+(o?'<param name="flashVars" value="'+o+'"/>':"")+"<embed "+c+" "+(o?'FlashVars="'+o+'"':"")+' pluginspage="http://www.macromedia.com/go/getflashplayer"  quality="high"  src="'+n+'"  type="application/x-shockwave-flash"/></object>';return{el:new s(n,null,g),html:n}},createSWFRuntime2:function(n,l,g){g=g||document;var e=(new s("<div style='width:0;height:0;overflow:hidden;'>",null,g)).appendTo(g.body);e=r.createSWF.apply(this,arguments).el.appendTo(e);u.ie||(e=e.one("object"));return e[0]},createSWFRuntime:function(n,
l,g){var e=l.attrs||{},d=l.flashVars||{},c=l.params||{},f="",o="",h="";g=g||document;e.id=e.id||k.guid("ke-runtimeflash-");for(var a in e)if(e.hasOwnProperty(a))f+=a+"='"+e[a]+"' ";for(var b in c)if(c.hasOwnProperty(b))o+="<param name='"+b+"' value='"+c[b]+"'/>";for(var i in d)if(d.hasOwnProperty(i))h+="&"+i+"="+encodeURIComponent(d[i]);h=h.substring(1);n=u.ie?"<object "+f+' classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" >'+o+'<param name="movie" value="'+n+'" />'+(h?'<param name="flashVars" value="'+
h+'" />':"")+"</object>":"<object type='application/x-shockwave-flash' data='"+n+"' "+f+">"+o+(h?'<param name="flashVars" value="'+h+'"/>':"")+"</object>";var m=l.holder;if(!m){m=(new s("<div style='"+(l.style?l.style:"width:1px;height:1px;position:absolute;"+ +"overflow:hidden;")+"'>",null,g)).appendTo(g.body);setTimeout(function(){m.offset({left:t.scrollLeft(),top:t.scrollTop()})},100)}m.html(n);return g.getElementById(e.id)}};q.Utils.flash=r}},{attach:false});
KISSY.Editor.add("font",function(k){k.addPlugin("font",function(){function q(v){for(var x=[],p=0;p<v.length;p++)x.push({name:v[p],value:v[p]});return x}var r=KISSY,t=r.Editor,s=t.Style,u=t.TripleButton,n=k.cfg.pluginConfig,l=n["font-size"],g,e,d,c=[];if(l!==false){l=l||{};r.mix(l,{items:q(["8px","10px","12px","14px","18px","24px","36px","48px","60px","72px","84px","96px"]),width:"55px"},false);var f={},o=[],h={element:"span",styles:{"font-size":"#(size)"},overrides:[{element:"font",attributes:{size:null}}]};
for(m=0;m<l.items.length;m++){g=l.items[m];e=g.name;d=g.attrs;g=g.value;f[g]=new s(h,{size:g});o.push({name:e,value:g,attrs:d})}n["font-size"]=l}h=n["font-family"];if(h!==false){h=h||{};r.mix(h,{items:[{name:"\u5b8b\u4f53",value:"SimSun"},{name:"\u9ed1\u4f53",value:"SimHei"},{name:"\u96b6\u4e66",value:"LiSu"},{name:"\u6977\u4f53",value:"KaiTi_GB2312"},{name:"\u5fae\u8f6f\u96c5\u9ed1",value:"Microsoft YaHei"},{name:"Georgia",value:"Georgia"},{name:"Times New Roman",value:"Times New Roman"},{name:"Impact",value:"Impact"},{name:"Courier New",value:"Courier New"},
{name:"Arial",value:"Arial"},{name:"Verdana",value:"Verdana"},{name:"Tahoma",value:"Tahoma"}],width:"130px"},false);var a={},b=[],i={element:"span",styles:{"font-family":"#(family)"},overrides:[{element:"font",attributes:{face:null}}]},m;n["font-family"]=h;for(m=0;m<h.items.length;m++){g=h.items[m];e=g.name;d=g.attrs||{};g=g.value;d.style=d.style||"";d.style+=";font-family:"+g;a[g]=new s(i,{family:g});b.push({name:e,value:g,attrs:d})}}e={click:function(v){var x=v.newVal;v=v.prevVal;var p=this.cfg.styles;
k.focus();k.fire("save");p=p[x];if(x==v){p.remove(k.document);this.btn.set("value","")}else p.apply(k.document);k.fire("save")},selectionChange:function(v){v=v.path.elements;for(var x=this.cfg.styles,p=0,z;p<v.length;p++){z=v[p];for(var y in x)if(x[y].checkElementRemovable(z,true)){this.btn.set("value",y);return}}this.btn.reset("value")}};false!==n["font-size"]&&c.push(k.addSelect("font-size",r.mix({title:"\u5927\u5c0f",width:"30px",mode:t.WYSIWYG_MODE,showValue:true,popUpWidth:l.width,items:o,styles:f},e)));
false!==n["font-family"]&&c.push(k.addSelect("font-family",r.mix({title:"\u5b57\u4f53",width:"110px",mode:t.WYSIWYG_MODE,popUpWidth:h.width,items:b,styles:a},e)));t={mode:t.WYSIWYG_MODE,offClick:function(){var v=this.editor,x=this.cfg.style;v.fire("save");x.apply(v.document);v.fire("save");v.notifySelectionChange();v.focus()},onClick:function(){var v=this.editor,x=this.cfg.style;v.fire("save");x.remove(v.document);v.fire("save");v.notifySelectionChange();v.focus()},selectionChange:function(v){var x=this.btn;
this.cfg.style.checkActive(v.path)?x.set("state",u.ON):x.set("state",u.OFF)}};false!==n["font-bold"]&&c.push(k.addButton("font-bold",r.mix({contentCls:"ke-toolbar-bold",title:"\u7c97\u4f53 ",style:new s({element:"strong",overrides:[{element:"b"},{element:"span",attributes:{style:"font-weight: bold;"}}]})},t)));false!==n["font-italic"]&&c.push(k.addButton("font-italic",r.mix({contentCls:"ke-toolbar-italic",title:"\u659c\u4f53 ",style:new s({element:"em",overrides:[{element:"i"},{element:"span",attributes:{style:"font-style: italic;"}}]})},
t)));false!==n["font-underline"]&&c.push(k.addButton("font-underline",r.mix({contentCls:"ke-toolbar-underline",title:"\u4e0b\u5212\u7ebf ",style:new s({element:"u",overrides:[{element:"span",attributes:{style:"text-decoration: underline;"}}]})},t)));if(false!==n["font-strikeThrough"])c.push(k.addButton("font-underline",r.mix({contentCls:"ke-toolbar-strikeThrough",title:"\u5220\u9664\u7ebf ",style:new s((n["font-strikeThrough"]||{}).style||{element:"del",overrides:[{element:"span",attributes:{style:"text-decoration: line-through;"}},
{element:"s"},{element:"strike"}]})},t)));this.destroy=function(){for(var v=0;v<c.length;v++)c[v].destroy()}})},{attach:false});
KISSY.Editor.add("format",function(k){k.addPlugin("format",function(){var q=KISSY.Editor,r=[],t={"\u666e\u901a\u6587\u672c":"p","\u6807\u98981":"h1","\u6807\u98982":"h2","\u6807\u98983":"h3","\u6807\u98984":"h4","\u6807\u98985":"h5","\u6807\u98986":"h6"},s={p:"1em",h1:"2em",h2:"1.5em",h3:"1.17em",h4:"1em",h5:"0.83em",h6:"0.67em"},u={},n=q.Style,l;for(l in t)if(t[l]){u[t[l]]=new n({element:t[l]});r.push({name:l,value:t[l],attrs:{style:"font-size:"+s[t[l]]}})}var g=k.addSelect("font-family",{items:r,title:"\u6807\u9898",width:"100px",mode:q.WYSIWYG_MODE,popUpWidth:"120px",click:function(e){var d=
e.newVal;e=e.prevVal;k.fire("save");if(d!=e)u[d].apply(k.document);else{u.p.apply(k.document);this.btn.set("value","p")}k.fire("save")},selectionChange:function(e){e=e.path;for(var d in u)if(u[d].checkActive(e)){this.btn.set("value",d);break}}});this.destroy=function(){g.destroy()}})},{attach:false});
KISSY.Editor.add("htmldataprocessor",function(k){function q(b){return b.replace(o,function(i,m,v){return"<"+m+v.replace(h,function(x,p){if(v.indexOf("_ke_saved_"+p)==-1)return" _ke_saved_"+x+" "+x;return x})+">"})}var r=r,t=KISSY,s=t.Editor,u=t.Node,n=t.UA,l=s.NODE,g=s.HtmlParser,e=new g.Filter,d=new g.Filter,c=new g.Filter,f=s.XHTML_DTD;if(!k.htmlDataProcessor){(function(){var b=s.HtmlParser.Fragment.prototype,i=s.HtmlParser.Element.prototype;b.onlyChild=i.onlyChild=function(){var m=this.children;
return m.length==1&&m[0]||null};i.removeAnyChildWithName=function(m){for(var v=this.children,x=[],p,z=0;z<v.length;z++){p=v[z];if(p.name){if(p.name==m){x.push(p);v.splice(z--,1)}x=x.concat(p.removeAnyChildWithName(m))}}return x};i.getAncestor=function(m){for(var v=this.parent;v&&!(v.name&&v.name.match(m));)v=v.parent;return v};b.firstChild=i.firstChild=function(m){for(var v,x=0;x<this.children.length;x++){v=this.children[x];if(m(v))return v;else if(v.name)if(v=v.firstChild(m))return v}return null};
i.addStyle=function(m,v,x){var p="";if(typeof v=="string")p+=m+":"+v+";";else{if(typeof m=="object")for(var z in m){if(m.hasOwnProperty(z))p+=z+":"+m[z]+";"}else p+=m;x=v}if(!this.attributes)this.attributes={};m=this.attributes.style||"";m=(x?[p,m]:[m,p]).join(";");this.attributes.style=m.replace(/^;|;(?=;)/,"")};f.parentOf=function(m){var v={},x;for(x in this)if(x.indexOf("$")==-1&&this[x][m])v[x]=1;return v}})();(function(){function b(w){if(/mso-list\s*:\s*Ignore/i.test(w.attributes&&w.attributes.style||
""))return true;return r}function i(w,C){var B=new s.HtmlParser.Element("ke:listbullet"),F;if(w)if(w[2]){w=isNaN(w[1])?/^[a-z]+$/.test(w[1])?"lower-alpha":/^[A-Z]+$/.test(w[1])?"upper-alpha":"decimal":"decimal";F="ol"}else{w=/[l\u00B7\u2002]/.test(w[1])?"disc":/[\u006F\u00D8]/.test(w[1])?"circle":/[\u006E\u25C6]/.test(w[1])?"square":"disc";F="ul"}else{w="decimal";F="ol"}B.attributes={"ke:listtype":F,style:"list-style-type:"+w+";"};B.add(new s.HtmlParser.Text(C));return B}function m(w){var C=w.attributes,
B;if((B=w.removeAnyChildWithName("ke:listbullet"))&&B.length&&(B=B[0])){w.name="ke:li";if(C.style)C.style=v([["text-indent"],["line-height"],[/^margin(:?-left)?$/,null,function(F){F=F.split(" ");F=F[3]||F[1]||F[0];F=parseInt(F,10);if(!z&&y&&F>y)z=F-y;C["ke:margin"]=y=F}]],r)(C.style,w)||"";B=B.attributes;w.addStyle(B.style);t.mix(C,B);return true}return false}function v(w,C){return function(B,F){var O=[];String(B).replace(/&quot;/g,'"').replace(/\s*([^ :;]+)\s*:\s*([^;]+)\s*(?=;|$)/g,function(P,M,
S){M=M.toLowerCase();M=="font-family"&&(S=S.replace(/["']/g,""));for(var R,T,X,Y=0;Y<w.length;Y++)if(w[Y]){P=w[Y][0];R=w[Y][1];T=w[Y][2];X=w[Y][3];if(M.match(P)&&(!R||S.match(R))){M=X||M;C&&(T=T||S);if(typeof T=="function")T=T(S,F,M);if(T&&T.push){M=T[0];T=T[1]}typeof T=="string"&&O.push([M,T]);return}}!C&&O.push([M,S])});for(var Q=0;Q<O.length;Q++)O[Q]=O[Q].join(":");return O.length?O.join(";")+";":false}}function x(w){w=w.children;for(var C,B,F,O,Q,P,M,S=0;S<w.length;S++){C=w[S];if("ke:li"==C.name){C.name=
"li";C=C;B=C.attributes;F=C.attributes["ke:listtype"];O=parseInt(B["ke:indent"],10)||z&&Math.ceil(B["ke:margin"]/z)||1;B.style&&(B.style=v([["list-style-type",F=="ol"?"decimal":"disc"]],r)(B.style)||"");if(P){if(O>M){P=new s.HtmlParser.Element(F);P.add(C);Q.add(P)}else{if(O<M){Q=M-O;for(var R;Q--&&(R=P.parent);)P=R.parent}P.add(C)}w.splice(S--,1)}else{P=new s.HtmlParser.Element(F);P.add(C);w[S]=P}Q=C;M=O}else P=null}z=0}var p=v([[/mso/i],[/w:WordDocument/i],[/^-ms/i],[/^-moz/i],[/^-webkit/i],[/line-height/i],
[/display/i,/none/i]],r),z,y=0,E=f.parentOf("ol"),D={elementNames:[[/^script$/i,""],[/^iframe$/i,""],[/^style$/i,""],[/^link$/i,""],[/^meta$/i,""],[/^\?xml.*$/i,""],[/^.*namespace.*$/i,""]],root:function(w){w.filterChildren();x(w)},elements:{p:function(w){w.filterChildren();if(m(w))return r},$:function(w){var C=w.name||"";C.indexOf(":")!=-1&&C.indexOf("ke")==-1&&delete w.name;if(C in E){w.filterChildren();x(w)}},span:function(w){if(!n.gecko&&b(w.parent))return false;if(!n.gecko&&b(w)){w=(w=w.firstChild(function(B){return B.value||
B.name=="img"}))&&(w.value||"l.");var C=w.match(/^([^\s]+?)([.)]?)$/);return i(C,w)}}},attributes:{"class":function(w){if(/(^|\s+)Mso/.test(w))return false;return w},style:function(w){w=p(w);if(!w)return false;return w}},attributeNames:[[/^on/,"ke_on"],[/^lang$/,""]]},j={comment:!n.ie?function(w,C){var B=w.match(/<img.*?>/),F=w.match(/^\[if !supportLists\]([\s\S]*?)\[endif\]$/);if(F){F=(B=F[1]||B&&"l.")&&B.match(/>([^\s]+?)([.)]?)</);return i(F,B)}if(n.gecko&&B){B=s.HtmlParser.Fragment.FromHtml(B[0]).children[0];
(F=(F=(F=C.previous)&&F.value.match(/<v:imagedata[^>]*o:href=['"](.*?)['"]/))&&F[1])&&(B.attributes.src=F);return B}return false}:function(){return false}},A={elementNames:[[/^ke:/,""],[/^\?xml:namespace$/,""]],elements:{$:function(w){var C=w.attributes;if(C)for(var B=["name","href","src"],F,O=0;O<B.length;O++){F="_ke_saved_"+B[O];F in C&&delete C[B[O]]}return w},embed:function(w){var C=w.parent;if(C&&C.name=="object"){var B=C.attributes.width;C=C.attributes.height;B&&(w.attributes.width=B);C&&(w.attributes.height=
C)}},param:function(w){w.children=[];w.isEmpty=true;return w},a:function(w){if(!(w.children.length||w.attributes.name||w.attributes._ke_saved_name))return false},td:function(w){for(var C=w.children,B=0;B<C.length;B++)if(C[B].name=="br"){C.splice(B,1);--B}if(!w.children.length){C=new s.HtmlParser.Text("&nbsp;");w.children.push(C)}},span:function(w){if(!w.children.length&&t.isEmptyObject(w.attributes))return false}},attributes:{style:function(w){if(!t.trim(w))return false}},attributeNames:[[/^_ke_saved_/,
""],[/^ke_on/,"on"],[/^_ke.*/,""],[/^_ks.*/,""],[/^ke:.*$/,""]],comment:function(w){if(w.substr(0,a.length)==a){w=w.substr(a.length,3)=="{C}"?w.substr(a.length+3):w.substr(a.length);return new s.HtmlParser.cdata(decodeURIComponent(w))}return w}};if(n.ie)A.attributes.style=function(w){return w.toLowerCase()};e.addRules(A);d.addRules(D);c.addRules(D);c.addRules(j)})();(function(){function b(j){for(var A=j.children.length,w=j.children[A-1];w&&w.type==l.NODE_TEXT&&!t.trim(w.value);)w=j.children[--A];
return w}function i(j){var A=b(j);return!A||A.type==l.NODE_ELEMENT&&A.name=="br"||j.name=="form"&&A.name=="input"}function m(j,A){var w=j.children,C=b(j);if(C){if((A||!n.ie)&&C.type==l.NODE_ELEMENT&&C.name=="br")w.pop();C.type==l.NODE_TEXT&&p.test(C.value)&&w.pop()}}function v(j){m(j,true);if(i(j))if(n.ie)j.add(new s.HtmlParser.Text("\u00a0"));else{j.add(new s.HtmlParser.Text("&nbsp;"));j.add(new s.HtmlParser.Element("br",{}))}}function x(j){m(j,false);i(j)&&j.add(new s.HtmlParser.Text("\u00a0"))}var p=/^[\t\r\n ]*(?:&nbsp;|\xa0)$/,
z=s.XHTML_DTD,y=s.Utils.mix({},z.$block,z.$listItem,z.$tableContent),E;for(E in y)"br"in z[E]||delete y[E];delete y.pre;z={elements:{}};var D={elements:{}};for(E in y){z.elements[E]=v;D.elements[E]=x}d.addRules(z);e.addRules(D);c.addRules(z)})();(function(){e.addRules({text:function(b){return b.replace(/\xa0/g,"&nbsp;")}})})();var o=/<(a|area|img|input)\b([^>]*)>/gi,h=/\b(href|src|name)\s*=\s*(?:(?:"[^"]*")|(?:'[^']*')|(?:[^ "'>]+))/gi,a="{ke_protected}";k.htmlDataProcessor={wordFilter:c,dataFilter:d,
htmlFilter:e,toHtml:function(b,i){var m=new g.HtmlWriter;g.Fragment.FromHtml(b,i).writeHtml(m,e);return m.getHtml(true)},toDataFormat:function(b,i,m){m=m||d;if(n.gecko)b=b.replace(/(<!--\[if[^<]*?\])--\>([\S\s]*?)<!--(\[endif\]--\>)/gi,"$1$2$3");b=q(b);var v=new u("<div>");v.html("a"+b);b=v.html().substr(1);v=new g.BasicWriter;b=g.Fragment.FromHtml(b,i);v.reset();b.writeHtml(v,m);return b=v.getHtml(true)},toServer:function(b,i){var m=new g.BasicWriter;g.Fragment.FromHtml(b,i).writeHtml(m,e);return m.getHtml(true)}}}},
{attach:false});
KISSY.Editor.add("image",function(k){k.addPlugin("image",function(){var q=KISSY,r=q.Editor,t=q.UA,s=q.Node,u=q.Event,n=function(c){return c._4e_name()==="img"&&!/(^|\s+)ke_/.test(c[0].className)&&c},l={},g=r.Utils.addRes,e=r.Utils.destroyRes,d=k.addButton("image",{contentCls:"ke-toolbar-image",title:"\u63d2\u5165\u56fe\u7247",mode:r.WYSIWYG_MODE,offClick:function(){this.call("show")},_updateTip:function(c,f){var o=f.attr("_ke_saved_src")||f.attr("src");c.html(o);c.attr("href",o)},show:function(c,f){this.editor.useDialog("image/dialog",function(o){o.show(f)})}});
g.call(l,d,function(){k.destroyDialog("image/dialog")});r.use("contextmenu",function(){function c(a){var b=new s(a.target);a.halt();n(b)&&d.call("show",null,b)}var f={"\u56fe\u7247\u5c5e\u6027":function(a){a=(a=a.getSelection())&&a.getStartElement();(a=n(a))&&d.call("show",null,a)}};u.on(k.document,"dblclick",c);g.call(l,function(){u.remove(k.document,"dblclick",c)});var o={},h;for(h in f)(function(a){o[a]=function(){f[a](k)}})(h);h=r.ContextMenu.register({editor:k,rules:[n],width:"120px",funcs:o});g.call(l,h)});r.use("bubbleview",
function(){r.BubbleView.register({pluginName:"image",pluginContext:d,editor:k,func:n,init:function(){var c=this,f=c.get("contentEl");f.html('\u56fe\u7247\u7f51\u5740\uff1a   <a class="ke-bubbleview-url" target="_blank" href="#"></a> -     <span class="ke-bubbleview-link ke-bubbleview-change">\u7f16\u8f91</span> -     <span class="ke-bubbleview-link ke-bubbleview-remove">\u5220\u9664</span>');var o=f.one(".ke-bubbleview-url"),h=f.one(".ke-bubbleview-change"),a=f.one(".ke-bubbleview-remove");r.Utils.preventFocus(f);h.on("click",function(b){c._plugin.call("show",
null,c._selectedEl);b.halt()});a.on("click",function(b){var i=c._plugin;if(t.webkit){var m=i.editor.getSelection().getRanges();m&&m[0]&&(m[0].collapse(true)||1)&&m[0].select()}c._selectedEl._4e_remove();c.hide();i.editor.notifySelectionChange();b.halt()});r.Utils.addRes.call(c,h,a);c.on("show",function(){var b=c._selectedEl;b&&c._plugin.call("_updateTip",o,b)})}});g.call(l,function(){r.BubbleView.destroy("image")})});this.destroy=function(){e.call(l)}})},{attach:false});
KISSY.Editor.add("indent",function(k){k.addPlugin("indent",function(){var q=KISSY.Editor,r=k.addButton("outdent",{title:"\u51cf\u5c11\u7f29\u8fdb\u91cf ",mode:q.WYSIWYG_MODE,contentCls:"ke-toolbar-outdent",type:"outdent",loading:true}),t=k.addButton("indent",{title:"\u589e\u52a0\u7f29\u8fdb\u91cf ",mode:q.WYSIWYG_MODE,contentCls:"ke-toolbar-indent",type:"indent",loading:true});q.use("indent/support",function(){r.reload(q.IndentSupport);t.reload(q.IndentSupport)});k.addCommand("indent",{exec:function(){t.call("offClick")}});k.addCommand("outdent",
{exec:function(){r.call("offClick")}});this.destroy=function(){r.destroy();t.destroy()}})},{attach:false});
KISSY.Editor.add("indent/support",function(){function k(h){this.type=h;this.indentCssProperty="margin-left";this.indentOffset=40;this.indentUnit="px"}function q(h){return h[0].nodeType==c.NODE_ELEMENT&&h._4e_name()=="li"}function r(h,a){for(var b=h.startContainer,i=h.endContainer;b&&!b.parent()._4e_equals(a);)b=b.parent();for(;i&&!i.parent()._4e_equals(a);)i=i.parent();if(b&&i){var m=b;b=[];for(var v=false;!v;){if(m._4e_equals(i))v=true;b.push(m);m=m.next()}if(!(b.length<1)){m=a._4e_parents(true);
for(i=0;i<m.length;i++)if(u[m[i]._4e_name()]){a=m[i];break}m=this.type=="indent"?1:-1;i=b[0];v=b[b.length-1];b={};var x=s.ListUtils.listToArray(a,b),p=x[v.data("listarray_index")].indent;for(i=i.data("listarray_index");i<=v.data("listarray_index");i++){x[i].indent+=m;var z=x[i].parent;x[i].parent=new e(z[0].ownerDocument.createElement(z._4e_name()))}for(i=v.data("listarray_index")+1;i<x.length&&x[i].indent>p;i++)x[i].indent+=m;v=s.ListUtils.arrayToList(x,b,null,"p",0);m=[];if(this.type=="outdent"){var y;
if((y=a.parent())&&y._4e_name()=="li"){x=v.listNode.childNodes;var E;for(i=x.length-1;i>=0;i--)if((E=new e(x[i]))&&E._4e_name()=="li")m.push(E)}}if(v){g.insertBefore(v.listNode,a);a._4e_remove()}if(m&&m.length)for(i=0;i<m.length;i++){for(v=E=m[i];(v=v.next())&&v._4e_name()in u;){d.ie&&!E._4e_first(function(D){return f(D)&&o(D)})&&E[0].appendChild(h.document.createTextNode("\u00a0"));E[0].appendChild(v[0])}g.insertAfter(E[0],y[0])}s.Utils.clearAllMarkers(b)}}}function t(h){var a=parseInt(h._4e_style(this.indentCssProperty),
10);if(isNaN(a))a=0;a+=(this.type=="indent"?1:-1)*this.indentOffset;if(a<0)return false;a=Math.max(a,0);a=Math.ceil(a/this.indentOffset)*this.indentOffset;h.css(this.indentCssProperty,a?a+this.indentUnit:"");h[0].style.cssText===""&&h.removeAttr("style");return true}var s=KISSY.Editor,u={ol:1,ul:1},n=KISSY,l=s.Walker,g=n.DOM,e=n.Node,d=n.UA,c=s.NODE,f=l.whitespaces(true),o=l.bookmark(false,true);n.augment(k,{exec:function(h){for(var a=(h=h.getSelection())&&h.getRanges()[0],b=a.startContainer,i=a.endContainer,
m=a.getCommonAncestor();m&&!(m[0].nodeType==c.NODE_ELEMENT&&u[m._4e_name()]);)m=m.parent();if(m&&b[0].nodeType==c.NODE_ELEMENT&&b._4e_name()in u){b=new l(a);b.evaluator=q;a.startContainer=b.next()}if(m&&i[0].nodeType==c.NODE_ELEMENT&&i._4e_name()in u){b=new l(a);b.evaluator=q;a.endContainer=b.previous()}i=h.createBookmarks(true);if(m){for(b=m._4e_first();b&&b._4e_name()!="li";)b=b.next();var v=a.startContainer;(b[0]==v[0]||b.contains(v))&&t.call(this,m)||r.call(this,a,m)}else{a=a.createIterator();
a.enforceRealBlocks=true;for(a.enlargeBr=true;m=a.getNextParagraph();)t.call(this,m)}h.selectBookmarks(i)}});s.IndentSupport={init:function(){this.indentCommand=new k(this.cfg.type)},offClick:function(){var h=this,a=h.editor;a.fire("save");setTimeout(function(){h.indentCommand.exec(a);a.fire("save");a.notifySelectionChange()},10)},selectionChange:function(h){if(this.cfg.type=="outdent"){var a=h.path,b=a.blockLimit;h=this.btn;if(a.contains(u))h.boff();else(a=a.block||b)&&a._4e_style(this.indentCommand.indentCssProperty)?
h.boff():h.disable()}}}},{attach:false});
KISSY.Editor.add("justify",function(k){k.addPlugin("justify",function(){var q=KISSY,r=q.Editor,t=r.TripleButton,s=/(-moz-|-webkit-|start|auto)/gi;r={mode:r.WYSIWYG_MODE,offClick:function(){this.call("_change")},onClick:function(){this.call("_change")},_change:function(){var g=this.editor,e=g.getSelection(),d=this.btn.get("state");if(e){var c=e.createBookmarks(),f=e.getRanges(),o,h;g.fire("save");for(var a=f.length-1;a>=0;a--){o=f[a].createIterator();for(o.enlargeBr=true;h=o.getNextParagraph();){h.removeAttr("align");
d==t.OFF?h.css("text-align",this.cfg.v):h.css("text-align","")}}g.notifySelectionChange();e.selectBookmarks(c);g.fire("save")}},selectionChange:function(g){var e=this.btn;g=g.path;g=g.block||g.blockLimit;if(!g||g._4e_name()==="body")e.boff();else(g.css("text-align").replace(s,"")||"left")==this.cfg.v?e.bon():e.boff()}};var u=k.addButton("alignleft",q.mix({contentCls:"ke-toolbar-alignleft",title:"\u5de6\u5bf9\u9f50",v:"left"},r)),n=k.addButton("aligncenter",q.mix({contentCls:"ke-toolbar-aligncenter",title:"\u5c45\u4e2d\u5bf9\u9f50",
v:"center"},r)),l=k.addButton("alignright",q.mix({contentCls:"ke-toolbar-alignright",title:"\u53f3\u5bf9\u9f50",v:"right"},r));this.destroy=function(){u.destroy();n.destroy();l.destroy()}})},{attach:false});
KISSY.Editor.add("link",function(k){k.addPlugin("link",function(){function q(c){return c._4e_ascendant(function(f){return f._4e_name()==="a"},true)}var r=KISSY,t=r.Editor,s=r.Node,u=t.Style,n={element:"a",attributes:{href:"#(href)",title:"#(title)",_ke_saved_href:"#(_ke_saved_href)",target:"#(target)"}},l={},g=t.Utils.addRes,e=t.Utils.destroyRes,d=k.addButton("link",{contentCls:"ke-toolbar-link",title:"\u63d2\u5165\u94fe\u63a5",mode:t.WYSIWYG_MODE,_getSelectedLink:function(){var c=this.editor.getSelection();if(c=c&&
c.getStartElement())c=q(c);return c},_getSelectionLinkUrl:function(){var c=this.cfg._getSelectedLink.call(this);if(c)return c.attr("_ke_saved_href")||c.attr("href")},_removeLink:function(c){var f=this.editor;f.fire("save");var o=f.getSelection(),h=o.getRanges()[0];if(h&&h.collapsed){h=o.createBookmarks();c._4e_remove(true);o.selectBookmarks(h)}else if(h){c=c[0];o=c.attributes;h={};for(var a=0;a<o.length;a++){var b=o[a];if(b.specified)h[b.name]=b.value}if(c.style.cssText)h.style=c.style.cssText;(new u(n,
h)).remove(f.document)}f.fire("save");f.notifySelectionChange()},_link:function(c,f){var o=this.editor;c._ke_saved_href=c.href;if(f){o.fire("save");f.attr(c);o.fire("save")}else{var h=o.getSelection();h=h&&h.getRanges()[0];if(!h||h.collapsed){h=new s("<a>"+c.href+"</a>",c,o.document);o.insertElement(h)}else{o.fire("save");(new u(n,c)).apply(o.document);o.fire("save")}}o.notifySelectionChange()},offClick:function(){var c=this;c.editor.useDialog("link/dialog",function(f){f.show(c)})},destroy:function(){this.editor.destroyDialog("link/dialog")}});
g.call(l,d);t.use("bubbleview",function(){t.BubbleView.register({pluginName:"link",editor:k,pluginContext:d,func:q,init:function(){var c=this,f=c.get("contentEl");f.html('\u524d\u5f80\u94fe\u63a5\uff1a  <a href=""  target="_blank" class="ke-bubbleview-url"></a> -  <span class="ke-bubbleview-link ke-bubbleview-change">\u7f16\u8f91</span> -  <span class="ke-bubbleview-link ke-bubbleview-remove">\u53bb\u9664</span>');var o=f.one(".ke-bubbleview-url"),h=f.one(".ke-bubbleview-change"),a=f.one(".ke-bubbleview-remove");t.Utils.preventFocus(f);h.on("click",
function(b){c._plugin.call("offClick");b.halt()});a.on("click",function(b){c._plugin.call("_removeLink",c._selectedEl);b.halt()});g.call(c,h,a);c.on("show",function(){var b=c._selectedEl;if(b){b=b.attr("_ke_saved_href")||b.attr("href");o.html(b);o.attr("href",b)}})}});g.call(l,function(){t.BubbleView.destroy("link")})});this.destroy=function(){e.call(l)}})},{attach:false});
KISSY.Editor.add("list",function(k){k.addPlugin("list",function(){var q=KISSY.Editor,r=k.addButton("ul",{title:"\u9879\u76ee\u5217\u8868",mode:q.WYSIWYG_MODE,contentCls:"ke-toolbar-ul",loading:true,type:"ul"}),t=k.addButton("ol",{title:"\u7f16\u53f7\u5217\u8868",mode:q.WYSIWYG_MODE,contentCls:"ke-toolbar-ol",loading:true,type:"ol"});q.use("list/support",function(){r.reload(q.ListSupport);t.reload(q.ListSupport)});this.destroy=function(){r.destroy();t.destroy()}})},{attach:false});
KISSY.Editor.add("list/support",function(){function k(h){this.type=h}var q=KISSY.Editor,r={ol:1,ul:1},t=["ol","ul"],s=KISSY,u=q.RANGE,n=q.ElementPath,l=q.Walker,g=q.NODE,e=s.UA,d=s.Node,c=s.DOM,f={listToArray:function(h,a,b,i,m){if(!r[h._4e_name()])return[];i||(i=0);b||(b=[]);for(var v=0,x=h[0].childNodes.length;v<x;v++){var p=new d(h[0].childNodes[v]);if(p._4e_name()=="li"){var z={parent:h,indent:i,element:p,contents:[]};if(m)z.grandparent=m;else{z.grandparent=h.parent();if(z.grandparent&&z.grandparent._4e_name()==
"li")z.grandparent=z.grandparent.parent()}a&&p._4e_setMarker(a,"listarray_index",b.length);b.push(z);for(var y=0,E=p[0].childNodes.length,D;y<E;y++){D=new d(p[0].childNodes[y]);D[0].nodeType==g.NODE_ELEMENT&&r[D._4e_name()]?f.listToArray(D,a,b,i+1,z.grandparent):z.contents.push(D)}}}return b},arrayToList:function(h,a,b,i){b||(b=0);if(!h||h.length<b+1)return null;for(var m=h[b].parent[0].ownerDocument,v=m.createDocumentFragment(),x=null,p=b,z=Math.max(h[b].indent,0),y=null;;){var E=h[p];if(E.indent==
z){if(!x||h[p].parent._4e_name()!=x._4e_name()){x=h[p].parent._4e_clone(false,true);v.appendChild(x[0])}y=x[0].appendChild(E.element._4e_clone(false,true)[0]);for(var D=0;D<E.contents.length;D++)y.appendChild(E.contents[D]._4e_clone(true,true)[0]);p++}else if(E.indent==Math.max(z,0)+1){p=f.arrayToList(h,null,p,i);y.appendChild(p.listNode);p=p.nextIndex}else if(E.indent==-1&&!b&&E.grandparent){if(r[E.grandparent._4e_name()])y=E.element._4e_clone(false,true)[0];else if(E.grandparent._4e_name()!="td"){y=
m.createElement(i);E.element._4e_copyAttributes(new d(y))}else y=m.createDocumentFragment();for(D=0;D<E.contents.length;D++){x=E.contents[D]._4e_clone(true,true);y.nodeType==g.NODE_DOCUMENT_FRAGMENT&&E.element._4e_copyAttributes(new d(x));y.appendChild(x[0])}if(y.nodeType==g.NODE_DOCUMENT_FRAGMENT&&p!=h.length-1){y.lastChild&&y.lastChild.nodeType==g.NODE_ELEMENT&&y.lastChild.getAttribute("type")=="_moz"&&c._4e_remove(y.lastChild);c._4e_appendBogus(y)}if(y.nodeType==g.NODE_ELEMENT&&c._4e_name(y)==
i&&y.firstChild){c._4e_trim(y);x=y.firstChild;if(x.nodeType==g.NODE_ELEMENT&&c._4e_isBlockBoundary(x)){x=m.createDocumentFragment();c._4e_moveChildren(y,x);y=x}}x=c._4e_name(y);if(!e.ie&&(x=="div"||x=="p"))c._4e_appendBogus(y);v.appendChild(y);x=null;p++}else return null;if(h.length<=p||Math.max(h[p].indent,0)<z)break}if(a)for(h=new d(v.firstChild);h&&h[0];){h[0].nodeType==g.NODE_ELEMENT&&h._4e_clearMarkers(a,true);h=h._4e_nextSourceNode()}return{listNode:v,nextIndex:p}}},o=/^h[1-6]$/;k.prototype=
{changeListType:function(h,a,b,i){var m=f.listToArray(a.root,b,undefined,undefined,undefined),v=[];for(h=0;h<a.contents.length;h++){var x=a.contents[h];x=x._4e_ascendant("li",true);if(!(!x||!x[0]||x.data("list_item_processed"))){v.push(x);x._4e_setMarker(b,"list_item_processed",true)}}x=new d(a.root[0].ownerDocument.createElement(this.type));for(h=0;h<v.length;h++){var p=v[h].data("listarray_index");m[p].parent=x}b=f.arrayToList(m,b,null,"p");var z;m=b.listNode.childNodes.length;for(h=0;h<m&&(z=new d(b.listNode.childNodes[h]));h++)z._4e_name()==
this.type&&i.push(z);c.insertBefore(b.listNode,a.root);a.root._4e_remove()},createList:function(h,a,b){var i=a.contents;h=a.root[0].ownerDocument;var m=[];if(i.length==1&&i[0][0]===a.root[0]){var v=new d(h.createElement("div"));i[0][0].nodeType!=g.NODE_TEXT&&i[0]._4e_moveChildren(v);i[0][0].appendChild(v[0]);i[0]=v}a=a.contents[0].parent();for(v=0;v<i.length;v++)a=a._4e_commonAncestor(i[v].parent());for(v=0;v<i.length;v++)for(var x=i[v],p;p=x.parent();){if(p[0]===a[0]){m.push(x);break}x=p}if(!(m.length<
1)){i=new d(m[m.length-1][0].nextSibling);v=new d(h.createElement(this.type));for(b.push(v);m.length;){b=m.shift();x=new d(h.createElement("li"));if(o.test(b._4e_name()))x[0].appendChild(b[0]);else{b._4e_copyAttributes(x);b._4e_moveChildren(x);b._4e_remove()}v[0].appendChild(x[0]);e.ie||x._4e_appendBogus()}i[0]?c.insertBefore(v,i):a.append(v)}},removeList:function(h,a,b){function i(D){if((y=new d(z[D?"firstChild":"lastChild"]))&&!(y[0].nodeType==g.NODE_ELEMENT&&y._4e_isBlockBoundary())&&(E=a.root[D?
"_4e_previous":"_4e_next"](l.whitespaces(true)))&&!(y[0].nodeType==g.NODE_ELEMENT&&E._4e_isBlockBoundary({br:1})))c[D?"insertBefore":"insertAfter"](h.document.createElement("br"),y)}for(var m=f.listToArray(a.root,b,undefined,undefined,undefined),v=[],x=0;x<a.contents.length;x++){var p=a.contents[x];p=p._4e_ascendant("li",true);if(!(!p||p.data("list_item_processed"))){v.push(p);p._4e_setMarker(b,"list_item_processed",true)}}p=null;for(x=0;x<v.length;x++){p=v[x].data("listarray_index");m[p].indent=
-1;p=p}for(x=p+1;x<m.length;x++)if(m[x].indent>Math.max(m[x-1].indent,0)){v=m[x-1].indent+1-m[x].indent;for(p=m[x].indent;m[x]&&m[x].indent>=p;){m[x].indent+=v;x++}x--}var z=f.arrayToList(m,b,null,"p").listNode,y,E;i(true);i(undefined);c.insertBefore(z,a.root);a.root._4e_remove()},exec:function(h){var a=h.getSelection(),b=a&&a.getRanges();if(!(!b||b.length<1)){for(var i=a.createBookmarks(true),m=[],v={};b.length>0;){var x=b.shift(),p=x.getBoundaryNodes(),z=p.startNode,y=p.endNode;z[0].nodeType==g.NODE_ELEMENT&&
z._4e_name()=="td"&&x.setStartAt(p.startNode,u.POSITION_AFTER_START);y[0].nodeType==g.NODE_ELEMENT&&y._4e_name()=="td"&&x.setEndAt(p.endNode,u.POSITION_BEFORE_END);x=x.createIterator();for(x.forceBrBreak=false;p=x.getNextParagraph();)if(!p.data("list_block")){p._4e_setMarker(v,"list_block",1);y=new n(p);var E=y.elements,D=null,j=false,A=y.blockLimit,w;for(z=E.length-1;z>=0&&(w=E[z]);z--)if(r[w._4e_name()]&&A.contains(w)){A.removeData("list_group_object");if(z=w.data("list_group_object"))z.contents.push(p);
else{z={root:w,contents:[p]};m.push(z);w._4e_setMarker(v,"list_group_object",z)}j=true;break}if(!j){y=A||y.block;if(y.data("list_group_object"))y.data("list_group_object").contents.push(p);else{z={root:y,contents:[p]};y._4e_setMarker(v,"list_group_object",z);m.push(z)}}}}for(b=[];m.length>0;){z=m.shift();if(this.state=="off")if(r[z.root._4e_name()])this.changeListType(h,z,v,b);else{q.Utils.clearAllMarkers(v);this.createList(h,z,b)}else this.state=="on"&&r[z.root._4e_name()]&&this.removeList(h,z,v)}for(z=
0;z<b.length;z++){D=b[z];var C=this;(h=function(B){var F=D[B?"_4e_previous":"_4e_next"](l.whitespaces(true));if(F&&F[0]&&F._4e_name()==C.type){F._4e_remove();F._4e_moveChildren(D,B?true:false)}})();h(true)}q.Utils.clearAllMarkers(v);a.selectBookmarks(i)}}};q.ListUtils=f;q.ListSupport={init:function(){this.listCommand=new k(this.cfg.type)},selectionChange:function(h){var a=this.cfg.type,b=h.path,i;h=this.btn;var m=b.blockLimit;b=b.elements;if(m){if(b)for(var v=0;v<b.length&&(i=b[v])&&i[0]!==m[0];v++){var x=
s.indexOf(b[v]._4e_name(),t);if(x!==-1)if(t[x]===a){h.bon();return}else break}h.boff()}},offClick:function(){this.call("_change")},onClick:function(){this.call("_change")},_change:function(){var h=this.editor,a=this.btn;h.fire("save");this.listCommand.state=a.get("state");this.listCommand.exec(h);h.fire("save");h.notifySelectionChange()}}},{attach:false});
KISSY.Editor.add("localstorage",function(){var k=KISSY,q=k.Editor,r;r=q.STORE="localStorage";if(q.storeReady)k.log("localstorage attach more","warn");else{q.storeReady=function(s){q.on("storeReady",s)};q.on("storeReady",function(){q.storeReady=function(s){s()};q.detach("storeReady")});if(window[r])window[r]._ke||q.fire("storeReady");else{var t=q.Utils.debugUrl("localstorage/swfstore.swf?t="+ +new Date);window[r]=new q.FlashBridge({movie:t,flashVars:{useCompression:true},methods:["setItem","removeItem",
"getValueOf"]});k.mix(window[r],{_ke:1,getItem:function(s){return this.getValueOf(s)}});window[r].on("contentReady",function(){q.fire("storeReady")})}}},{attach:false,requires:["flashutils","flashbridge"]});
KISSY.Editor.add("maximize",function(k){k.addPlugin("maximize",function(){var q=KISSY,r=q.Editor;if(!(q.UA.gecko<1.92)){var t=k.addButton("maximize",{title:"\u5168\u5c4f",contentCls:"ke-toolbar-maximize",loading:true});r.use("maximize/support",function(){t.reload(r.Maximize)});this.destroy=function(){t.destroy()}}})},{attach:false});
KISSY.Editor.add("maximize/support",function(){var k=KISSY.Editor,q=KISSY,r=q.UA,t=q.Node,s=q.Event,u=q.DOM,n;u.addStyleSheet(".ke-toolbar-padding {padding:5px;}","ke-maximize");var l={};q.mix(l,{onClick:function(){var g=this,e=g.editor;g._resize&&s.remove(window,"resize",g._resize);g.call("_saveEditorStatus");g.call("_restoreState");g.btn.boff();setTimeout(function(){g.call("_restoreEditorStatus");e.notifySelectionChange();e.fire("restoreWindow")},30)},_restoreState:function(){var g=document,e=this.editor,
d=this._savedParents;if(d){for(var c=0;c<d.length;c++){var f=d[c];f.el.css("position",f.position)}this._savedParents=null}e.wrap.css({height:this.iframeHeight});u.css(g.body,{width:"",height:"",overflow:""});g.documentElement.style.overflow="";e.editorWrap.css({position:"static",width:this.editorWrapWidth});n.css({left:"-99999px",top:"-99999px"});window.scrollTo(this.scrollLeft,this.scrollTop);g=this.btn.get("el");g.one("span").removeClass("ke-toolbar-restore").addClass("ke-toolbar-maximize");g.attr("title",
"\u5168\u5c4f");r.ie<8&&this.editor.toolBarDiv.removeClass("ke-toolbar-padding")},_saveSate:function(){var g=this.editor,e=[],d=g.editorWrap;this.iframeHeight=g.wrap._4e_style("height");this.editorWrapWidth=d._4e_style("width");this.scrollLeft=u.scrollLeft();this.scrollTop=u.scrollTop();window.scrollTo(0,0);for(g=d.parent();g;){d=g.css("position");if(d!="static"){e.push({el:g,position:d});g.css("position","static")}g=g.parent()}this._savedParents=e;e=this.btn.get("el");e.one("span").removeClass("ke-toolbar-maximize").addClass("ke-toolbar-restore");
e.attr("title","\u53d6\u6d88\u5168\u5c4f");r.ie<8&&this.editor.toolBarDiv.addClass("ke-toolbar-padding")},_saveEditorStatus:function(){var g=this.editor;this.savedRanges=null;if(r.gecko&&g.iframeFocus)this.savedRanges=(g=g.getSelection())&&g.getRanges()},_restoreEditorStatus:function(){var g=this.editor,e=g.getSelection(),d=this.savedRanges;g.activateGecko();d&&e&&e.selectRanges(d);if(g.iframeFocus&&e)(g=e.getStartElement())&&g[0]&&g._4e_scrollIntoView();r.ie<8&&this.btn.get("el").one("span").css("background-image",
"")},_maximize:function(g){var e=document,d=this.editor,c=d.editorWrap,f=u.viewportHeight(),o=u.viewportWidth(),h=d.statusDiv?d.statusDiv[0].offsetHeight:0,a=d.toolBarDiv[0].offsetHeight;if(r.ie)e.body.style.overflow="hidden";else u.css(e.body,{width:0,height:0,overflow:"hidden"});e.documentElement.style.overflow="hidden";c.css({position:"absolute",zIndex:k.baseZIndex(k.zIndexManager.MAXIMIZE),width:o+"px"});n.css({zIndex:k.baseZIndex(k.zIndexManager.MAXIMIZE-5),height:f+"px",width:o+"px"});c.offset({left:0,
top:0});n.css({left:0,top:0});d.wrap.css({height:f-h-a+"px"});g!==true&&arguments.callee.call(this,true)},_real:function(){var g=this,e=g.editor;g.call("_saveEditorStatus");g.call("_saveSate");g.call("_maximize");g._resize=g._resize||k.Utils.buffer(g.cfg._maximize,g,100);s.on(window,"resize",g._resize);g.btn.bon();setTimeout(function(){g.call("_restoreEditorStatus");e.notifySelectionChange();e.fire("maximizeWindow")},30)},offClick:function(){n||(n=(new t("<iframe  class='ke-maximize-shim' style='position:absolute;top:-9999px;left:-9999px;' frameborder='0'>")).prependTo(document.body));
this.call("_real")},destroy:function(){}});k.Maximize=l},{attach:false});
KISSY.Editor.add("music",function(k){k.addPlugin("music",function(){function q(l){l=l||"";return l.indexOf(t)!=-1}var r=KISSY.Editor,t="niftyplayer.swf",s=k.htmlDataProcessor,u=s&&s.dataFilter;u&&u.addRules({elements:{object:function(l){var g=l.attributes;if(!(g.classid&&String(g.classid).toLowerCase())){for(g=0;g<l.children.length;g++)if(l.children[g].name=="embed"){if(!r.Utils.isFlashEmbed(l.children[g]))break;if(q(l.children[g].attributes.src))return s.createFakeParserElement(l,"ke_music","music",
true)}return null}for(g=0;g<l.children.length;g++){var e=l.children[g];if(e.name=="param"&&e.attributes.name.toLowerCase()=="movie")if(q(e.attributes.value))return s.createFakeParserElement(l,"ke_music","music",true)}},embed:function(l){if(!r.Utils.isFlashEmbed(l))return null;if(q(l.attributes.src))return s.createFakeParserElement(l,"ke_music","music",true)}}},4);var n=k.addButton("music",{contentCls:"ke-toolbar-music",title:"\u63d2\u5165\u97f3\u4e50",mode:r.WYSIWYG_MODE,loading:true});r.use("music/support",function(){var l=
new r.MusicInserter(k);n.reload({offClick:function(){l.show()},destroy:function(){l.destroy()}})});this.destroy=function(){n.destroy()}})},{attach:false,requires:["fakeobjects"]});
KISSY.Editor.add("music/support",function(){function k(d){k.superclass.constructor.apply(this,arguments);d.cfg.disableObjectResizing||s.on(d.document.body,n.ie?"resizestart":"resize",function(c){(new r.Node(c.target)).hasClass(l)&&c.preventDefault()})}function q(d){return d._4e_name()==="img"&&!!d.hasClass(l)&&d}var r=KISSY,t=r.Editor,s=r.Event,u=t.Flash,n=r.UA,l="ke_music",g=["img."+l];r.extend(k,u,{_config:function(){this._cls=l;this._type="music";this._contextMenu=e;this._flashRules=g},_getFlashUrl:function(){return k.superclass._getFlashUrl.apply(this,
arguments).replace(/^.+niftyplayer\.swf\?file=/,"")}});u.registerBubble("music","\u97f3\u4e50\u7f51\u5740\uff1a ",q);t.MusicInserter=k;var e={"\u97f3\u4e50\u5c5e\u6027":function(d){var c=d.editor.getSelection();(c=(c=c&&c.getStartElement())&&q(c))&&d.show(null,c)}}},{attach:false,requires:["flash/support"]});
KISSY.Editor.add("overlay",function(){function k(){}var q=KISSY,r=q.UA,t=q.Editor,s=t.focusManager;t.namespace("UIBase");if(t.UIBase.Focus)q.log("ke uibase focus attach more","warn");else{k.ATTRS={focus4e:{value:true}};k.prototype={_uiSetFocus4e:function(u){if(u){this.on("show",this._show4FocusExt,this);this.on("hide",this._hide4FocusExt,this)}else{this.detach("show",this._show4FocusExt,this);this.detach("hide",this._hide4FocusExt,this)}},__syncUI:function(){},__renderUI:function(){},__bindUI:function(){this._focus4e=
(new q.Node("<a href='#' class='ke-focus' style='width:0;height:0;margin:0;padding:0;overflow:hidden;outline:none;font-size:0;'></a>")).appendTo(this.get("el"))},_show4FocusExt:function(){var u=this._focusEditor=s.currentInstance();if(r.ie&&u){window.focus();document.body.focus();this._focus4e[0].focus();var n=u.document.selection.createRange();if(n)if(n.item&&n.item(0).ownerDocument==u.document){u=document.body.createTextRange();u.moveToElementText(this.get("el")._4e_first()[0]);u.collapse(true);
u.select()}}},_hide4FocusExt:function(){var u=this._focusEditor;u&&u.focus()}};t.UIBase.Focus=k}},{attach:false});
KISSY.Editor.add("overlay",function(){var k=KISSY,q=k.UIBase,r=k.Editor;if(r.Overlay)k.log("ke overlay attach more");else{var t=q.create(k.Overlay,[r.UIBase.Focus],{syncUI:function(){r.Utils.preventFocus(this.get("contentEl"))}},{ATTRS:{zIndex:{value:r.baseZIndex(r.zIndexManager.OVERLAY)}}}),s=q.create(k.Dialog,[r.UIBase.Focus],{show:function(){this.center();var n=this.get("y");if(n-k.DOM.scrollTop()>200){n=k.DOM.scrollTop()+200;this.set("y",n)}s.superclass.show.call(this)}},{ATTRS:{constrain:{value:true},
zIndex:{value:r.baseZIndex(r.zIndexManager.OVERLAY)}}});r.Overlay=t;r.Dialog=s;var u;r.Overlay.loading=function(){u||(u=new r.Overlay({x:0,focus4e:false,width:k.UA.ie==6?k.DOM.docWidth():"100%",y:0,zIndex:r.baseZIndex(r.zIndexManager.LOADING),elCls:"ke-global-loading"}));u.set("height",k.DOM.docHeight());u.show();u.loading()};r.Overlay.unloading=function(){u&&u.hide()}}});
KISSY.Editor.add("pagebreak",function(k){k.addPlugin("pagebreak",function(){var q=KISSY,r=q.Editor,t=q.Node,s=k.htmlDataProcessor;(q=s&&s.dataFilter)&&q.addRules({elements:{div:function(n){var l=n.attributes;var g=(l=l&&l.style)&&n.children.length==1&&n.children[0];if((g=g&&g.name=="span"&&g.attributes.style)&&/page-break-after\s*:\s*always/i.test(l)&&/display\s*:\s*none/i.test(g))return s.createFakeParserElement(n,"ke_pagebreak","div")}}});var u=k.addButton("page-break",{title:"\u5206\u9875",mode:r.WYSIWYG_MODE,
contentCls:"ke-toolbar-pagebreak",offClick:function(){var n=this.editor,l=new t('<div style="page-break-after: always; "><span style="DISPLAY:none">&nbsp;</span></div>',null,n.document);l=n.createFakeElement?n.createFakeElement(l,"ke_pagebreak","div",false,'<div style="page-break-after: always; "><span style="DISPLAY:none">&nbsp;</span></div>'):l;var g=n.getSelection();if(g=g&&g.getRanges()[0]){n.fire("save");for(var e=g.startContainer,d=e;e._4e_name()!=="body";){d=e;e=e.parent()}g.collapse(true);
g.splitElement(d);l.insertAfter(d);n.fire("save")}}});this.destroy=function(){u.destroy()}})},{attach:false,requires:["fakeobjects"]});
KISSY.Editor.add("preview",function(k){k.addPlugin("preview",function(){var q=k.addButton("preview",{title:"\u9884\u89c8",contentCls:"ke-toolbar-preview",offClick:function(){var r=this.editor,t=640,s=420,u=80;try{var n=window.screen;t=Math.round(n.width*0.8);s=Math.round(n.height*0.7);u=Math.round(n.width*0.1)}catch(l){}r=r._prepareIFrameHtml().replace(/<body[^>]+>.+<\/body>/,"<body>\n"+r.getData(true)+"\n</body>").replace(/\${title}/,"\u9884\u89c8");t=window.open("","","toolbar=yes,location=no,status=yes,menubar=yes,scrollbars=yes,resizable=yes,width="+
t+",height="+s+",left="+u);s=t.document;s.open();s.write(r);s.close();t.focus()}});this.destroy=function(){q.destroy()}})},{attach:false});
KISSY.Editor.add("progressbar",function(){function k(){k.superclass.constructor.apply(this,arguments);this._init()}var q=KISSY,r=q.Editor;if(!r.ProgressBar){var t=q.Node;q.DOM.addStyleSheet(".ke-progressbar {border:1px solid #D6DEE6;position:relative;margin-left:auto;margin-right:auto;background-color: #EAEFF4;background: -webkit-gradient(linear, left top, left bottom, from(#EAEFF4), .to(#EBF0F3)); background: -moz-linear-gradient(top, #EAEFF4, #EBF0F3);filter: progid:DXImageTransform.Microsoft.gradient(startColorstr = '#EAEFF4', endColorstr = '#EBF0F3');}.ke-progressbar-inner {border:1px solid #3571B4;background-color:#6FA5DB;padding:1px;}.ke-progressbar-inner-bg {height:100%;background-color: #73B1E9;background: -webkit-gradient(linear, left top, left bottom, from(#73B1E9), .to(#3F81C8)); background: -moz-linear-gradient(top, #73B1E9, #3F81C8);filter: progid:DXImageTransform.Microsoft.gradient(startColorstr = '#73B1E9', endColorstr = '#3F81C8');}.ke-progressbar-title {width:30px;top:0;left:40%;line-height:1.2;position:absolute;}","ke_progressbar");
k.ATTRS={container:{},width:{},height:{},progress:{value:0}};q.extend(k,q.Base,{destroy:function(){this.detach();this.el.remove()},_init:function(){var s=this.get("height"),u=new t("<div class='ke-progressbar'  style='width:"+this.get("width")+";height:"+s+";'></div>"),n=this.get("container");s=(new t("<div style='overflow:hidden;'><div class='ke-progressbar-inner' style='height:"+(parseInt(s)-4)+"px'><div class='ke-progressbar-inner-bg'></div></div></div>")).appendTo(u);var l=(new t("<span class='ke-progressbar-title'>")).appendTo(u);
n&&u.appendTo(n);this.el=u;this._title=l;this._p=s;this.on("afterProgressChange",this._progressChange,this);this._progressChange({newVal:this.get("progress")})},_progressChange:function(s){s=s.newVal;this._p.css("width",s+"%");this._title.html(s+"%")}});r.ProgressBar=k}},{attach:false});
KISSY.Editor.add("removeformat",function(k){k.addPlugin("removeformat",function(){function q(e,d){for(var c=0;c<d.length;c++)e.removeAttr(d[c])}var r=KISSY.Editor,t=r.RANGE,s=r.ElementPath,u=r.NODE,n="class,style,lang,width,height,align,hspace,valign".split(/,/),l=RegExp("^(?:"+"b,big,code,del,dfn,em,font,i,ins,kbd,q,samp,small,span,strike,strong,sub,sup,tt,u,var,s".replace(/,/g,"|")+")$","i"),g=k.addButton("removeformat",{title:"\u6e05\u9664\u683c\u5f0f",mode:r.WYSIWYG_MODE,contentCls:"ke-toolbar-removeformat",offClick:function(){var e=
this.editor;e.focus();l.lastIndex=0;var d=e.getSelection().getRanges();e.fire("save");for(var c=0,f;f=d[c];c++)if(!f.collapsed){f.enlarge(t.ENLARGE_ELEMENT);var o=f.createBookmark(),h=o.startNode,a=o.endNode,b=function(i){for(var m=new s(i),v=m.elements,x=1,p;p=v[x];x++){if(p._4e_equals(m.block)||p._4e_equals(m.blockLimit))break;l.test(p._4e_name())&&i._4e_breakParent(p)}};b(h);b(a);for(h=h._4e_nextSourceNode(true,u.NODE_ELEMENT);h;){if(h._4e_equals(a))break;b=h._4e_nextSourceNode(false,u.NODE_ELEMENT);
h._4e_name()=="img"&&h.attr("_ke_realelement")||(l.test(h._4e_name())?h._4e_remove(true):q(h,n));h=b}f.moveToBookmark(o)}e.getSelection().selectRanges(d);e.fire("save")}});this.destroy=function(){g.destroy()}})},{attach:false});
KISSY.Editor.add("resize",function(k){var q=KISSY,r=q.Node;q.use("dd",function(){var t=q.Draggable,s=k.statusDiv,u=k.textarea,n=new r("<div class='ke-resizer'>"),l=k.cfg.pluginConfig.resize||{};l=l.direction||["x","y"];n.appendTo(s);k.on("maximizeWindow",function(){n.css("display","none")});k.on("restoreWindow",function(){n.css("display","")});n._4e_unselectable();var g=new t({node:n}),e=0,d=0,c=0,f=0,o=k.wrap,h=k.editorWrap;g.on("dragstart",function(){e=o.height();d=h.width();c=u.height();f=u.width()});
g.on("drag",function(a){var b=a.left-this.startNodePos.left;a=a.top-this.startNodePos.top;if(q.inArray("y",l)){o.height(e+a);u.height(c+a)}if(q.inArray("x",l)){h.width(d+b);u.width(f+b)}});k.on("destroy",function(){g.destroy();n.remove()})})},{attach:false});KISSY.Editor.add("separator",function(k){k.addPlugin("separator",function(){var q=(new KISSY.Node('<span class="ke-toolbar-separator">&nbsp;</span>')).appendTo(k.toolBarDiv);k.on("destroy",function(){q.remove()})},{duplicate:true})},{attach:false});
KISSY.Editor.add("smiley",function(k){k.addPlugin("smiley",function(){var q=KISSY.Editor,r=k.addButton("smiley",{contentCls:"ke-toolbar-smiley",title:"\u63d2\u5165\u8868\u60c5",mode:q.WYSIWYG_MODE,loading:true});q.use("smiley/support",function(){r.reload(q.SmileySupport)});this.destroy=function(){r.destroy()}})},{attach:false});
KISSY.Editor.add("smiley/support",function(){function k(){if(u)return u;u="<div class='ke-smiley-sprite'>";for(var g=0;g<=98;g++)u+="<a href='#' data-icon='" + _PUBLIC_ + "/js/editor/editor/plugins/smiley/48x48/"+g+".gif'></a>";u+="</div>";return u}var q=KISSY,r=q.Event,t=q.Editor,s=q.DOM;s.addStyleSheet('.ke-smiley-sprite { background: url("' + _PUBLIC_ + '/js/editor/editor/plugins/smiley/sprite.png") no-repeat scroll -1px 0 transparent; height: 235px; width: 288px; margin: 5px;zoom: 1; overflow: hidden;}.ke-smiley-sprite a {   width: 24px;height: 24px; border: 1px solid white; float: left;}.ke-smiley-sprite a:hover { border: 1px solid #808080;}',
"smiley");var u,n=t.Utils.addRes,l=t.Utils.destroyRes;t.SmileySupport={_selectSmiley:function(g){g.halt();var e=this.editor;g=new q.Node(g.target);var d;if(g._4e_name()=="a"&&(d=g.attr("data-icon"))){d=new q.Node("<img alt='' src='"+d+"'/>",null,e.document);e.insertElement(d);this.smileyWin.hide()}},_hidePanel:function(g){var e=this.btn.get("el");g=new q.Node(g.target);var d=this.smileyWin;e._4e_equals(g)||e.contains(g)||d.hide()},_prepare:function(){var g=this,e=g.cfg,d=g.btn,c=g.editor,f=k();g.smileyWin=
new t.Overlay({content:f,focus4e:false,width:"297px",autoRender:true,elCls:"ks-popup",zIndex:t.baseZIndex(t.zIndexManager.POPUP_MENU),mask:false});f=g.smileyWin;g.smileyPanel=f.get("contentEl");f.on("show",d.bon,d);f.on("hide",d.boff,d);g.smileyPanel.on("click",e._selectSmiley,g);r.on(document,"click",e._hidePanel,g);r.on(c.document,"click",e._hidePanel,g);g.cfg._prepare=g.cfg._real;n.call(g,g.smileyWin,g.smileyPanel,function(){r.remove(document,"click",e._hidePanel,g);r.remove(c.document,"click",
e._hidePanel,g)});g.call("_real")},_real:function(){var g=this.btn.get("el"),e=g.offset();e.top+=g.height()+5;if(e.left+this.smileyPanel.width()>s.viewportWidth()-60)e.left=s.viewportWidth()-this.smileyPanel.width()-60;this.smileyWin.set("xy",[e.left,e.top]);this.smileyWin.show()},offClick:function(){var g=this;t.use("overlay",function(){g.call("_prepare")})},onClick:function(){this.smileyWin&&this.smileyWin.hide()},destroy:function(){l.call(this)}}},{attach:false});
KISSY.Editor.add("sourcearea",function(k){k.addPlugin("sourcearea",function(){function q(){var g=k.textarea;g.on("keydown",function(e){if(e.ctrlKey&&e.keyCode==87){e.halt();e=g.attr("wrap")=="off"?"soft":"off";if(s.ie)g.attr("wrap",e);else{g.detach();var d=g._4e_clone();k.textarea=d;d.attr("wrap",e);d.val(g.val());g[0].parentNode.replaceChild(d[0],g[0]);q();g=null}}})}var r=KISSY,t=r.Editor,s=r.UA;if(!(s.gecko<1.92)){var u=t.SOURCE_MODE,n=t.WYSIWYG_MODE,l=k.addButton("sourcearea",{title:"\u6e90\u7801",contentCls:"ke-toolbar-source",
loading:true});t.use("sourcearea/support",function(){l.reload({init:function(){var g=this.btn,e=this.editor;e.on("wysiwygmode",g.boff,g);e.on("sourcemode",g.bon,g)},offClick:function(){this.editor.execCommand("sourceAreaSupport",u)},onClick:function(){this.editor.execCommand("sourceAreaSupport",n)}});k.addCommand("sourceAreaSupport",t.SourceAreaSupport)});this.destroy=function(){l.destroy()};q()}})},{attach:false});
KISSY.Editor.add("sourcearea/support",function(){function k(){var n=this.mapper={};n[s]=this._show;n[u]=this._hide}var q=KISSY,r=q.Editor,t=q.UA,s=r.SOURCE_MODE,u=r.WYSIWYG_MODE;q.augment(k,{exec:function(n,l){var g=this.mapper;g[l]&&g[l].call(this,n)},_show:function(n){n.textarea.val(n.getData(true));this._showSource(n);n.fire("sourcemode")},_showSource:function(n){var l=n.textarea,g=n.iframe;l.css("display","");g.css("display","none");t.ieEngine<8&&l.css("height",n.wrap.css("height"));l[0].focus()},
_hideSource:function(n){var l=n.textarea;n.iframe.css("display","");l.css("display","none")},_hide:function(n){var l=n.textarea;this._hideSource(n);n.fire("save");n.setData(l.val());n.fire("wysiwygmode");n.fire("save");t.gecko&&n.activateGecko()}});r.SourceAreaSupport=new k},{attach:false});
KISSY.Editor.add("table",function(k){k.addPlugin("table",function(){var q=KISSY,r=q.Editor,t=q.trim;q=(q.UA.ie===6?["table.%2,","table.%2 td, table.%2 th,","{","border : #d3d3d3 1px dotted","}"]:[" table.%2,"," table.%2 > tr > td,  table.%2 > tr > th,"," table.%2 > tbody > tr > td,  table.%2 > tbody > tr > th,"," table.%2 > thead > tr > td,  table.%2 > thead > tr > th,"," table.%2 > tfoot > tr > td,  table.%2 > tfoot > tr > th","{","border : #d3d3d3 1px dotted","}"]).join("").replace(/%2/g,"ke_show_border");
var s=k.htmlDataProcessor,u=s&&s.dataFilter;s=s&&s.htmlFilter;u&&u.addRules({elements:{table:function(l){l=l.attributes;var g=l["class"],e=parseInt(l.border,10);if(!e||e<=0)l["class"]=(g||"")+" ke_show_border"}}});s&&s.addRules({elements:{table:function(l){l=l.attributes;var g=l["class"];if(g)l["class"]=t(g.replace("ke_show_border","").replace(/\s{2}/," "))}}});var n=k.addButton("table",{contentCls:"ke-toolbar-table",mode:r.WYSIWYG_MODE,title:"\u63d2\u5165\u8868\u683c",loading:true});r.use("table/support",function(){var l=
new r.TableUI(k);n.reload({offClick:function(){l._tableShow()},destroy:function(){l.destroy()}})});this.destroy=function(){n.destroy()};k.addCustomStyle(q)})},{attach:false});
KISSY.Editor.add("table/support",function(){function k(p){var z=this,y={},E;for(E in x)(function(D){y[D]=function(){p.fire("save");x[D](z);p.fire("save")}})(E);E=o.ContextMenu.register({editor:p,statusChecker:v,rules:a,width:"120px",funcs:y});b.call(z,E);z.editor=p}function q(p){function z(B){if(!(D.length>0))if(B[0].nodeType==h.NODE_ELEMENT&&m.test(B._4e_name())&&!B.data("selected_cell")){B._4e_setMarker(j,"selected_cell",true);D.push(B)}}for(var y=p.createBookmarks(),E=p.getRanges(),D=[],j={},A=
0;A<E.length;A++){var w=E[A];if(w.collapsed){w=w.getCommonAncestor();(w=w._4e_ascendant("td",true)||w._4e_ascendant("th",true))&&D.push(w)}else{w=new Walker(w);var C;for(w.guard=z;C=w.next();)if((C=C.parent())&&m.test(C._4e_name())&&!C.data("selected_cell")){C._4e_setMarker(j,"selected_cell",true);D.push(C)}}}o.Utils.clearAllMarkers(j);p.selectBookmarks(y);return D}function r(p,z){var y=p.getStartElement()._4e_ascendant("tr");if(y){var E=y._4e_clone(true);E.insertBefore(y);y=(z?E[0]:y[0]).cells;for(E=
0;E<y.length;E++){y[E].innerHTML="";c.ie||(new f(y[E]))._4e_appendBogus()}}}function t(p){if(p instanceof o.Selection){var z=q(p),y=z.length;p=[];for(var E,D,j=0;j<y;j++){var A=z[j].parent(),w=A[0].rowIndex;!j&&(E=w-1);p[w]=A;j==y-1&&(D=w+1)}j=A._4e_ascendant("table");E=new f(D<j[0].rows.length&&j[0].rows[D]||E>0&&j[0].rows[E]||j[0].parentNode);for(j=p.length;j>=0;j--)p[j]&&t(p[j]);return E}else if(p instanceof f){j=p._4e_ascendant("table");j[0].rows.length==1?j._4e_remove():p._4e_remove()}return 0}
function s(p,z){var y=p.getStartElement();if(y=y._4e_ascendant("td",true)||y._4e_ascendant("th",true))for(var E=y._4e_ascendant("table"),D=y[0].cellIndex,j=0;j<E[0].rows.length;j++){var A=E[0].rows[j];if(!(A.cells.length<D+1)){y=new f(A.cells[D].cloneNode(false));c.ie||y._4e_appendBogus();A=new f(A.cells[D]);z?y.insertBefore(A):y.insertAfter(A)}}}function u(p){if(p instanceof o.Selection){var z=q(p),y,E=[];p=z[0]&&z[0]._4e_ascendant("table");var D,j,A;D=0;for(j=z.length;D<j;D++)E.push(z[D][0].cellIndex);
E.sort();D=1;for(j=E.length;D<j;D++)if(E[D]-E[D-1]>1){A=E[D-1]+1;break}A||(A=E[0]>0?E[0]-1:E[E.length-1]+1);E=p[0].rows;D=0;for(j=E.length;D<j;D++)if(y=E[D].cells[A])break;y=y?new f(y):p._4e_previous();for(A=z.length-1;A>=0;A--)z[A]&&u(z[A]);return y}else if(p instanceof f){z=p._4e_ascendant("table");if(!z)return null;y=p[0].cellIndex;for(A=z[0].rows.length-1;A>=0;A--){p=new f(z[0].rows[A]);if(!y&&p[0].cells.length==1)t(p);else p[0].cells[y]&&p[0].removeChild(p[0].cells[y])}}return null}function n(p,
z){var y=new o.Range(p[0].ownerDocument);if(!y.moveToElementEditablePosition(p,z?true:undefined)){y.selectNodeContents(p);y.collapse(z?false:true)}y.select(true)}function l(p){var z=(p=p.getSelection())&&p.getStartElement(),y=z&&z._4e_ascendant("table",true);if(y){p=z._4e_ascendant(function(E){var D=E._4e_name();return y.contains(E)&&(D=="td"||D=="th")},true);z=z._4e_ascendant(function(E){var D=E._4e_name();return y.contains(E)&&D=="tr"},true);return{table:y,td:p,tr:z}}}function g(p){return(p=l(p))&&
p.td}function e(p){return(p=l(p))&&p.tr}var d=KISSY,c=d.UA,f=d.Node,o=d.Editor,h=o.NODE,a=["tr","th","td","tbody","table"],b=o.Utils.addRes,i=o.Utils.destroyRes;d.augment(k,{_tableShow:function(p,z,y){this.editor.useDialog("table/dialog",function(E){E.show(z,y)})},destroy:function(){i.call(this);this.editor.destroyDialog("table/dialog")}});var m=/^(?:td|th)$/,v={"\u8868\u683c\u5c5e\u6027":l,"\u5220\u9664\u8868\u683c":g,"\u5220\u9664\u5217":g,"\u5220\u9664\u884c":e,"\u5728\u4e0a\u65b9\u63d2\u5165\u884c":e,"\u5728\u4e0b\u65b9\u63d2\u5165\u884c":e,"\u5728\u5de6\u4fa7\u63d2\u5165\u5217":g,"\u5728\u53f3\u4fa7\u63d2\u5165\u5217":g},x={"\u8868\u683c\u5c5e\u6027":function(p){var z=l(p.editor);z&&p._tableShow(null,
z.table,z.td)},"\u5220\u9664\u8868\u683c":function(p){var z=(p=p.editor.getSelection())&&p.getStartElement();if(z=z&&z._4e_ascendant("table",true)){p.selectElement(z);var y=p.getRanges()[0];y.collapse();p.selectRanges([y]);p=z.parent();p[0].childNodes.length==1&&p._4e_name()!="body"&&p._4e_name()!="td"?p._4e_remove():z._4e_remove()}},"\u5220\u9664\u884c ":function(p){p=p.editor.getSelection();n(t(p),undefined)},"\u5220\u9664\u5217 ":function(p){p=p.editor.getSelection();(p=u(p))&&n(p,true)},"\u5728\u4e0a\u65b9\u63d2\u5165\u884c":function(p){p=p.editor.getSelection();r(p,true)},
"\u5728\u4e0b\u65b9\u63d2\u5165\u884c":function(p){p=p.editor.getSelection();r(p,undefined)},"\u5728\u5de6\u4fa7\u63d2\u5165\u5217":function(p){p=p.editor.getSelection();s(p,true)},"\u5728\u53f3\u4fa7\u63d2\u5165\u5217":function(p){p=p.editor.getSelection();s(p,undefined)}};o.TableUI=k},{attach:false,requires:["contextmenu"]});
KISSY.Editor.add("tabs",function(){function k(u){this.cfg=u;this._init()}var q=KISSY,r=q.Editor,t=q.DOM,s=q.Node;if(r.Tabs)q.log("ke tabs attach more","warn");else{q.augment(k,q.EventTarget,{_init:function(){var u=this,n=u.cfg,l=n.tabs,g=n.contents.children("div"),e=l.children("li");l.on("click",function(d){d&&d.halt();d=new s(d.target);if(d=d._4e_ascendant(function(f){return f._4e_name()==="li"&&l.contains(f)},true)){e.removeClass("ke-tab-selected");var c=d.attr("rel");d.addClass("ke-tab-selected");
g.hide();t.show(g[q.indexOf(d[0],e)]);u.fire(c)}})},getTab:function(u){var n=this.cfg,l=n.tabs;n=n.contents.children("div");l=l.children("li");for(var g=0;g<l.length;g++){var e=new s(l[g]),d=new s(n[g]);if(q.isNumber(u)&&u==g||q.isString(u)&&u==e.attr("rel"))return{tab:e,content:d}}},remove:function(u){u=this.getTab(u);u.tab.remove();u.content.remove()},_getActivate:function(){for(var u=this.cfg.tabs.children("li"),n=0;n<u.length;n++){var l=new s(u[n]);if(l.hasClass("ke-tab-selected"))return l.attr("rel")}},
activate:function(u){if(arguments.length==0)return this._getActivate();var n=this.cfg,l=n.tabs;n=n.contents.children("div");l.children("li").removeClass("ke-tab-selected");n.hide();l=this.getTab(u);l.tab.addClass("ke-tab-selected");l.content.show()},destroy:function(){var u=this.cfg.tabs;u.detach();u.remove()}});r.Tabs=k}},{attach:false});
KISSY.Editor.add("templates",function(k){k.addPlugin("templates",function(){var q=KISSY,r=q.Editor,t=q.Node;q.DOM.addStyleSheet(".ke-tpl {    border: 2px solid #EEEEEE;    width: 95%;    margin: 20px auto;}.ke-tpl-list {    border: 1px solid #EEEEEE;    margin: 5px;    padding: 7px;    display: block;    text-decoration: none;    zoom: 1;}.ke-tpl-list:hover, .ke-tpl-selected {    background-color: #FFFACD;    text-decoration: none;    border: 1px solid #FF9933;}","ke-templates");var s=k.addButton("templates",
{contentCls:"ke-toolbar-template",title:"\u6a21\u677f",mode:r.WYSIWYG_MODE,offClick:function(){var u=this;r.use("overlay",function(){u.cfg._prepare.call(u)})},_prepare:function(){for(var u=this.editor,n=u.cfg.pluginConfig.templates||[],l="<div class='ke-tpl'>",g=0;g<n.length;g++)l+="<a href='javascript:void(0)' class='ke-tpl-list' tabIndex='-1'>"+n[g].demo+"</a>";l+="</div>";var e=new r.Dialog({width:500,mask:true,autoRender:true,headerContent:"\u5185\u5bb9\u6a21\u677f",bodyContent:l});e.get("el").all(".ke-tpl-list").on("click",
function(d){d.halt();d=(new t(d.target))._4e_index();d!=-1&&u.insertHtml(n[d].html);e.hide()});this.ui=e;this.cfg.show.call(this);this.cfg._prepare=this.cfg.show},show:function(){this.ui.show()}});this.destroy=function(){s.destroy()}})},{attach:false});
KISSY.Editor.add("undo",function(k){var q=KISSY,r=q.Editor,t={redo:1,undo:-1},s={mode:r.WYSIWYG_MODE,init:function(){this.editor.on("afterSave afterRestore",this.cfg._respond,this);this.btn.disable()},offClick:function(){this.editor.fire("restore",{d:t[this.cfg.flag]})}},u=q.mix({flag:"undo",_respond:function(l){var g=this.btn;l.index>0?g.boff():g.disable()}},s,false),n=q.mix({flag:"redo",_respond:function(l){var g=this.btn;l.index<l.history.length-1?g.boff():g.disable()}},s,false);k.addPlugin("undo",
function(){var l=k.addButton("undo",{title:"\u64a4\u9500",loading:true,contentCls:"ke-toolbar-undo"}),g=k.addButton("undo",{title:"\u91cd\u505a",loading:true,contentCls:"ke-toolbar-redo"});r.use("undo/support",function(){new r.UndoManager(k);l.reload(u);g.reload(n)});this.destroy=function(){l.destroy();g.destroy()}})},{attach:false});
KISSY.Editor.add("undo/support",function(){function k(e){var d=e._getRawData(),c;if(d)c=e.getSelection();this.contents=d;this.bookmarks=c&&c.createBookmarks2(true)}function q(e){this.history=[];this.index=-1;this.editor=e;this.bufferRunner=t.Utils.buffer(this.save,this,500);this._init()}var r=KISSY,t=r.Editor,s=t.Utils.arrayCompare,u=r.UA,n=r.Event;r.augment(k,{equals:function(e){if(this.contents!=e.contents)return false;var d=this.bookmarks;e=e.bookmarks;if(d||e){if(!d||!e||d.length!=e.length)return false;
for(var c=0;c<d.length;c++){var f=d[c],o=e[c];if(f.startOffset!=o.startOffset||f.endOffset!=o.endOffset||!s(f.start,o.start)||!s(f.end,o.end))return false}}return true}});var l={16:1,17:1,18:1},g={37:1,38:1,39:1,40:1,33:1,34:1};r.augment(q,{_keyMonitor:function(){var e=this.editor;n.on([e.document,e.textarea],"keydown",function(d){var c=d.keyCode;if(!(c in g||c in l))if(c===90&&(d.ctrlKey||d.metaKey)){e.fire("restore",{d:-1});d.halt()}else if(c===89&&(d.ctrlKey||d.metaKey)){e.fire("restore",{d:1});
d.halt()}else e.fire("save",{buffer:1})})},_init:function(){var e=this,d=e.editor;d.on("save",function(c){if(d.getMode()==t.WYSIWYG_MODE)c.buffer?e.bufferRunner():e.save()});d.on("restore",function(c){d.getMode()==t.WYSIWYG_MODE&&e.restore(c)});e._keyMonitor();setTimeout(function(){e.save()},0)},save:function(){var e=this.history,d=this.index;e.length>d+1&&e.splice(d+1,e.length-d-1);var c=this.editor;d=e[e.length-1];var f=new k(c);if(!d||!d.equals(f)){e.length===30&&e.shift();e.push(f);this.index=
d=e.length-1;c.fire("afterSave",{history:e,index:d})}},restore:function(e){e=e.d;var d=this.history,c=this.editor,f=d[this.index+e];if(f){c._setRawData(f.contents);if(f.bookmarks)c.getSelection().selectBookmarks(f.bookmarks);else if(u.ie){f=c.document.body.createTextRange();f.collapse(true);f.select()}(f=c.getSelection())&&f.scrollIntoView();this.index+=e;c.fire("afterRestore",{history:d,index:this.index});c.notifySelectionChange()}}});t.UndoManager=q},{attach:false});
