/*
Copyright 2012, KISSY UI Library v1.30rc
MIT Licensed
build time: Jul 11 21:28
*/
/*
 thanks to CKSource's intelligent work on CKEditor
 @author yiminghe@gmail.com
*/
KISSY.add("editor/core/base",function(d,g,k){g=k.Controller.extend({initializer:function(){this.__commands={};this.__controls={}}},{Config:{},XHTML_DTD:g.DTD,ATTRS:{textarea:{},iframe:{},window:{},document:{},toolBarEl:{},statusBarEl:{},handleMouseEvents:{value:!1},focusable:{value:!1},mode:{value:1},data:{getter:function(){return this._getData()},setter:function(d){return this._setData(d)}},formatData:{getter:function(){return this._getData(1)},setter:function(d){return this._setData(d)}},customStyle:{value:""},
customLink:{value:[]}}},{xclass:"editor"});g.HTML_PARSER={textarea:function(d){return d.one(".ks-editor-textarea")}};d.mix(g,d.EventTarget);return KISSY.Editor=g},{requires:["htmlparser","component","core"]});
KISSY.add("editor/core/clipboard",function(d,g,k,h){function f(a){this.editor=a;this._init()}function a(a){if(e.ie&&"BackCompat"!=a.get("document")[0].compatMode){var b=a.getSelection(),i;if(b.getType()==h.SELECTION_ELEMENT&&(i=b.getSelectedElement())){var o=b.getRanges()[0],q=c(a.get("document")[0].createTextNode(""));q.insertBefore(i);o.setStartBefore(q);o.setEndAfter(i);b.selectRanges([o]);setTimeout(function(){i.parent()&&(q.remove(),b.selectElement(i))},0)}}}var c=d.all,e=d.UA,b=g.RANGE,m=d.Event;
d.augment(f,{_init:function(){var a=this.editor,c=a.get("document")[0].body;m.on(c,e.ie?"beforepaste":"paste",this._paste,this);m.on(c,"contextmenu",function(){i=1;setTimeout(function(){i=0},10)});a.addCommand("copy",new p("copy"));a.addCommand("cut",new p("cut"));a.addCommand("paste",new p("paste"))},_paste:function(){if(!i){var a=this.editor,o=a.get("document")[0];if(!o.getElementById("ke_pastebin")){var x=a.getSelection(),j=new k(o),q=c(e.webkit?"<body></body>":"<div></div>",null,o);q.attr("id",
"ke_pastebin");e.webkit&&q[0].appendChild(o.createTextNode("\u00a0"));o.body.appendChild(q[0]);q.css({position:"absolute",top:x.getStartElement().offset().top+"px",width:"1px",height:"1px",overflow:"hidden"});q.css("left","-1000px");var f=x.createBookmarks();j.setStartAt(q,b.POSITION_AFTER_START);j.setEndAt(q,b.POSITION_BEFORE_END);j.select(!0);setTimeout(function(){var c;q=e.webkit&&(c=q.first())&&c.hasClass("Apple-style-span")?c:q;x.selectBookmarks(f);q.remove();var b=q.html();if(b=d.trim(b.replace(/<span[^>]+_ke_bookmark[^<]*?<\/span>(&nbsp;)*/ig,
"")))c=a.fire("paste",{html:b,holder:q}),void 0!==c&&(b=c),/(class="?Mso|style="[^"]*\bmso\-|w:WordDocument)/.test(b)?d.use("editor/core/dynamic/wordFilter",function(c,i){a.insertHtml(i.toDataFormat(b,a))}):a.insertHtml(b)},0)}}}});var l=function(a,b){var i=a.get("document")[0],o=c(i.body),q=!1,d=function(){q=!0};o.on(b,d);(7<e.ie?i:i.selection.createRange()).execCommand(b);o.detach(b,d);return q},j=e.ie?function(a,c){return l(a,c)}:function(a,c){try{return a.get("document")[0].execCommand(c)}catch(b){return!1}},
r={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"},p=function(a){this.type=a};p.prototype={exec:function(c){"cut"==this.type&&a(c);(c=j(c,this.type))||alert(r[this.type]);return c}};var o={copy:"\u590d\u5236",paste:"\u7c98\u8d34",cut:"\u526a\u5207"},i;return{init:function(a){a.docReady(function(){new f(a)});var c={copy:1,cut:1,paste:1};a.on("contextmenu",function(b){b=b.contextmenu;if(!b.__copy_fix){b.__copy_fix=
1;for(var i in c)c.hasOwnProperty(i)&&b.addChild({xclass:"menuitem",content:o[i],value:i});b.on("click",function(b){var i=b.target.get("value");c[i]&&(this.hide(),setTimeout(function(){a.execCommand(i)},30))})}})}}},{requires:["./base","./range","./selection"]});
KISSY.add("editor/core/dom",function(d,g,k){function h(a,i){var e=a[i?"next":"prev"](f,1);if(e&&e[0].nodeType==c.ELEMENT_NODE){for(var d=[];e.attr("_ke_bookmark")||e._4e_isEmptyInlineRemovable(f);)if(d.push(e),e=i?e.next(f,1):e.prev(f,1),!e)return;if(a._4e_isIdentical(e,f)){for(var j=new b(i?a[0].lastChild:a[0].firstChild);d.length;)d.shift()._4e_move(a,!i,f);e._4e_moveChildren(a,!i,f);e.remove();j[0]&&j[0].nodeType==c.ELEMENT_NODE&&j._4e_mergeSiblings()}}}var f=f,a=g.XHTML_DTD,c=d.DOM,e=d.UA,b=d.Node,
m={a:1,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};g.POSITION={POSITION_IDENTICAL:0,POSITION_DISCONNECTED:1,POSITION_FOLLOWING:2,POSITION_PRECEDING:4,POSITION_IS_CONTAINED:8,POSITION_CONTAINS:16};var l=g.POSITION,j={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},r={hr:1},p=function(a){return a&&(a[0]||a)};k.injectDom({_4e_sameLevel:function(a,c){var c=p(c),b=a.parentNode;return b&&b==c.parentNode},_4e_isBlockBoundary:function(a,b){var e=d.merge(r,b);return!(!j[c.css(a,"display")]&&!e[c.nodeName(a)])},_4e_index:function(a,c){for(var b=a.parentNode.childNodes,e,d=-1,j=0;j<b.length;j++)if(e=b[j],!c||!(3==e.nodeType&&e.previousSibling&&3==e.previousSibling.nodeType))if(d++,e===a)return d;return-1},_4e_move:function(a,c,b){c=
p(c);b?c.insertBefore(a,c.firstChild):c.appendChild(a)},_4e_isIdentical:function(a,b){if(!b)return!1;b=p(b);if(c.nodeName(a)!=c.nodeName(b))return!1;var e=a.attributes,d=b.attributes,j=e.length,f=d.length;if(j!=f)return!1;for(var q=0;q<j;q++){var l=e[q],m=l.name;if(l.specified&&c.attr(a,m)!=c.attr(b,m))return!1}if(8>k.ieEngine)for(q=0;q<f;q++)if(l=d[q],m=l.name,l.specified&&c.attr(a,m)!=c.attr(b,m))return!1;return!0},_4e_isEmptyInlineRemovable:function(b){if(!a.$removeEmpty[c.nodeName(b)])return!1;
for(var b=b.childNodes,i=0,e=b.length;i<e;i++){var j=b[i],f=j.nodeType;if(!(f==c.ELEMENT_NODE&&j.getAttribute("_ke_bookmark"))&&(f==c.ELEMENT_NODE&&!c._4e_isEmptyInlineRemovable(j)||f==c.TEXT_NODE&&d.trim(j.nodeValue)))return!1}return!0},_4e_moveChildren:function(a,c,b){c=p(c);if(a!=c)if(b)for(;b=a.lastChild;)c.insertBefore(a.removeChild(b),c.firstChild);else for(;b=a.firstChild;)c.appendChild(a.removeChild(b))},_4e_mergeSiblings:function(a){a=new b(a);m[a.nodeName()]&&(h(a,!0),h(a))},_4e_splitText:function(a,
b){var d=a.ownerDocument;if(a.nodeType==c.TEXT_NODE){if(e.ie&&b==a.nodeValue.length){var j=d.createTextNode("");c.insertAfter(j,a);return j}j=a.splitText(b);d.documentMode&&(d=d.createTextNode(""),c.insertAfter(d,j),c.remove(d));return j}},_4e_parents:function(a,b){var c=[];c.__IS_NODELIST=1;do c[b?"push":"unshift"](a);while(a=a.parentNode);return c},_4e_nextSourceNode:function(a,b,e,d){if(d&&!d.call)var j=p(d),d=function(a){return a!==j};var b=!b&&a.firstChild,f=a;if(!b){if(a.nodeType==c.ELEMENT_NODE&&
d&&!1===d(a,!0))return null;b=a.nextSibling}for(;!b&&(f=f.parentNode);){if(d&&!1===d(f,!0))return null;b=f.nextSibling}return!b||d&&!1===d(b)?null:e&&e!=b.nodeType?c._4e_nextSourceNode(b,!1,e,d):b},_4e_previousSourceNode:function(a,b,e,d){if(d&&!d.call)var j=p(d),d=function(a){return a!==j};var b=!b&&a.lastChild,f=a;if(!b){if(a.nodeType==c.ELEMENT_NODE&&d&&!1===d(a,!0))return null;b=a.previousSibling}for(;!b&&(f=f.parentNode);){if(d&&!1===d(f,!0))return null;b=f.previousSibling}return!b||d&&!1===
d(b)?null:e&&b.nodeType!=e?c._4e_previousSourceNode(b,!1,e,d):b},_4e_commonAncestor:function(a,b){b=p(b);if(a===b)return a;if(c.contains(b,a))return b;var e=a;do if(c.contains(e,b))return e;while(e=e.parentNode);return null},_4e_hasAttributes:9>k.ieEngine?function(a){for(var b=a.attributes,c=0;c<b.length;c++){var e=b[c];switch(e.name){case "class":if(a.getAttribute("class"))return!0;break;default:if(e.specified)return!0}}return!1}:function(a){e.gecko&&a.removeAttribute("_moz_dirty");return a.hasAttributes()},
_4e_position:function(a,b){var e=p(b);if(a.compareDocumentPosition)return a.compareDocumentPosition(e);if(a==e)return l.POSITION_IDENTICAL;if(a.nodeType==c.ELEMENT_NODE&&e.nodeType==c.ELEMENT_NODE){if(c.contains(a,e))return l.POSITION_CONTAINS+l.POSITION_PRECEDING;if(c.contains(e,a))return l.POSITION_IS_CONTAINED+l.POSITION_FOLLOWING;if("sourceIndex"in a)return 0>a.sourceIndex||0>e.sourceIndex?l.POSITION_DISCONNECTED:a.sourceIndex<e.sourceIndex?l.POSITION_PRECEDING:l.POSITION_FOLLOWING}for(var d=
c._4e_address(a),e=c._4e_address(e),j=Math.min(d.length,e.length),f=0;f<=j-1;f++)if(d[f]!=e[f])return d[f]<e[f]?l.POSITION_PRECEDING:l.POSITION_FOLLOWING;return d.length<e.length?l.POSITION_CONTAINS+l.POSITION_PRECEDING:l.POSITION_IS_CONTAINED+l.POSITION_FOLLOWING},_4e_address:function(a,b){for(var e=[],d=a.ownerDocument.documentElement,j=a;j&&j!=d;)e.unshift(c._4e_index(j,b)),j=j.parentNode;return e},_4e_remove:function(a,b){var c=a.parentNode;if(c){if(b)for(var e;e=a.firstChild;)c.insertBefore(a.removeChild(e),
a);c.removeChild(a)}return a},_4e_trim:function(a){c._4e_ltrim(a);c._4e_rtrim(a)},_4e_ltrim:function(a){for(var b;b=a.firstChild;){if(b.nodeType==c.TEXT_NODE){var e=k.ltrim(b.nodeValue),d=b.nodeValue.length;if(e)e.length<d&&(c._4e_splitText(b,d-e.length),a.removeChild(a.firstChild));else{a.removeChild(b);continue}}break}},_4e_rtrim:function(a){for(var b;b=a.lastChild;){if(b.type==c.TEXT_NODE){var d=k.rtrim(b.nodeValue),j=b.nodeValue.length;if(d)d.length<j&&(c._4e_splitText(b,d.length),a.removeChild(a.lastChild));
else{a.removeChild(b);continue}}break}!e.ie&&!e.opera&&(b=a.lastChild)&&1==b.nodeType&&"br"==c.nodeName(b)&&a.removeChild(b)},_4e_appendBogus:function(a){for(var b=a.lastChild;b&&b.nodeType==c.TEXT_NODE&&!d.trim(b.nodeValue);)b=b.previousSibling;if(!b||b.nodeType==c.TEXT_NODE||"br"!==c.nodeName(b))b=e.opera?a.ownerDocument.createTextNode(""):a.ownerDocument.createElement("br"),e.gecko&&b.setAttribute("type","_moz"),a.appendChild(b)},_4e_outerHtml:function(a){if(a.outerHTML)return a.outerHTML.replace(/<\?[^>]*>/,
"");var b=a.ownerDocument.createElement("div");b.appendChild(a.cloneNode(!0));return b.innerHTML},_4e_setMarker:function(a,c,e,j){var a=new b(a),f=a.data("list_marker_id")||a.data("list_marker_id",d.guid()).data("list_marker_id"),l=a.data("list_marker_names")||a.data("list_marker_names",{}).data("list_marker_names");c[f]=a;l[e]=1;return a.data(e,j)},_4e_clearMarkers:function(a,c,e){var a=new b(a),d=a.data("list_marker_names"),j=a.data("list_marker_id"),f;for(f in d)d.hasOwnProperty(f)&&a.removeData(f);
a.removeData("list_marker_names");e&&(a.removeData("list_marker_id"),delete c[j])},_4e_copyAttributes:function(a,d,j){for(var d=new b(d),f=a.attributes,j=j||{},l=0;l<f.length;l++){var m=f[l],q=m.name.toLowerCase(),g;if(!(q in j))if("checked"==q&&(g=c.attr(a,q)))d.attr(q,g);else if(m.specified||e.ie&&m.value&&"value"==q)g=c.attr(a,q),null===g&&(g=m.nodeValue),d.attr(q,g)}""!==a.style.cssText&&(d[0].style.cssText=a.style.cssText)},_4e_isEditable:function(b){b=c.nodeName(b);return(b=!a.$nonEditable[b]&&
(a[b]||a.span))&&b["#text"]},_4e_getByAddress:function(a,b,c){for(var a=a.documentElement,e=0;a&&e<b.length;e++){var d=b[e];if(c)for(var j=-1,q=0;q<a.childNodes.length;q++){var f=a.childNodes[q];if(!(!0===c&&3==f.nodeType&&f.previousSibling&&3==f.previousSibling.nodeType)&&(j++,j==d)){a=f;break}}else a=a.childNodes[d]}return a}})},{requires:["./base","./utils"]});
KISSY.add("editor/core/domIterator",function(d){function g(a){1>arguments.length||(this.range=a,this.forceBrBreak=h,this.enlargeBr=k,this.enforceRealBlocks=h,this._||(this._={}))}var k=!0,h=!1,f=d.Editor,a=d.UA,c=f.Walker,e=f.Range,b=f.RANGE,m=f.ElementPath,l=d.Node,j=d.DOM,r=/^[\r\n\t ]*$/;d.augment(g,{getNextParagraph:function(f){var g,i,n,v,x;if(!this._.lastNode){i=this.range.clone();i.shrink(b.SHRINK_ELEMENT,k);i.enlarge(this.forceBrBreak||!this.enlargeBr?b.ENLARGE_LIST_ITEM_CONTENTS:b.ENLARGE_BLOCK_CONTENTS);
var t=new c(i),q=c.bookmark(k,k);t.evaluator=q;this._.nextNode=t.next();t=new c(i);t.evaluator=q;t=t.previous();this._.lastNode=t._4e_nextSourceNode(k);this._.lastNode&&this._.lastNode[0].nodeType==j.TEXT_NODE&&!d.trim(this._.lastNode[0].nodeValue)&&this._.lastNode.parent()._4e_isBlockBoundary()&&(q=new e(i.document),q.moveToPosition(this._.lastNode,b.POSITION_AFTER_END),q.checkEndOfBlock()&&(q=new m(q.endContainer),this._.lastNode=(q.block||q.blockLimit)._4e_nextSourceNode(k)));this._.lastNode||
(this._.lastNode=this._.docEndMarker=new l(i.document.createTextNode("")),j.insertAfter(this._.lastNode[0],t[0]));i=null}q=this._.nextNode;t=this._.lastNode;for(this._.nextNode=null;q;){var u=h,y=q[0].nodeType!=j.ELEMENT_NODE,s=h;if(y)q[0].nodeType==j.TEXT_NODE&&r.test(q[0].nodeValue)&&(y=h);else{var w=q.nodeName();if(q._4e_isBlockBoundary(this.forceBrBreak&&{br:1})){if("br"==w)y=k;else if(!i&&!q[0].childNodes.length&&"hr"!=w){g=q;n=q.equals(t);break}i&&(i.setEndAt(q,b.POSITION_BEFORE_START),"br"!=
w&&(this._.nextNode=q));u=k}else{if(q[0].firstChild){i||(i=new e(this.range.document),i.setStartAt(q,b.POSITION_BEFORE_START));q=new l(q[0].firstChild);continue}y=k}}y&&!i&&(i=new e(this.range.document),i.setStartAt(q,b.POSITION_BEFORE_START));n=(!u||y)&&q.equals(t);if(i&&!u)for(;!q[0].nextSibling&&!n;){w=q.parent();if(w._4e_isBlockBoundary(this.forceBrBreak&&{br:1})){u=k;n||w.equals(t);break}q=w;y=k;n=q.equals(t);s=k}y&&i.setEndAt(q,b.POSITION_AFTER_END);q=q._4e_nextSourceNode(s,null,t);if((n=!q)||
u&&i)break}if(!g){if(!i)return this._.docEndMarker&&this._.docEndMarker._4e_remove(),this._.nextNode=null;g=new m(i.startContainer);q=g.blockLimit;u={div:1,th:1,td:1};g=g.block;if((!g||!g[0])&&!this.enforceRealBlocks&&u[q.nodeName()]&&i.checkStartOfBlock()&&i.checkEndOfBlock())g=q;else if(!g||this.enforceRealBlocks&&"li"==g.nodeName())g=new l(this.range.document.createElement(f||"p")),g[0].appendChild(i.extractContents()),g._4e_trim(),i.insertNode(g),v=x=k;else if("li"!=g.nodeName()){if(!i.checkStartOfBlock()||
!i.checkEndOfBlock())g=g.clone(h),g[0].appendChild(i.extractContents()),g._4e_trim(),x=i.splitBlock(),v=!x.wasStartOfBlock,x=!x.wasEndOfBlock,i.insertNode(g)}else n||(this._.nextNode=g.equals(t)?null:i.getBoundaryNodes().endNode._4e_nextSourceNode(k,null,t))}v&&(i=new l(g[0].previousSibling),i[0]&&i[0].nodeType==j.ELEMENT_NODE&&("br"==i.nodeName()?i._4e_remove():i[0].lastChild&&"br"==j.nodeName(i[0].lastChild)&&j._4e_remove(i[0].lastChild)));x&&(i=c.bookmark(h,k),v=new l(g[0].lastChild),v[0]&&v[0].nodeType==
j.ELEMENT_NODE&&"br"==v.nodeName()&&(a.ie||v.prev(i,1)||v.next(i,1))&&v.remove());this._.nextNode||(this._.nextNode=n||g.equals(t)?null:g._4e_nextSourceNode(k,null,t));return g}});e.prototype.createIterator=function(){return new g(this)};return g},{requires:["./base","./range","./elementPath","./walker"]});
KISSY.add("editor/core/elementPath",function(d){function g(b){for(var d=a,l=a,j=[];b;){if(b[0].nodeType==h.ELEMENT_NODE){this.lastElement||(this.lastElement=b);var g=b.nodeName();if(!l&&(!d&&c[g]&&(d=b),e[g])){var k;if(k=!d)if(k="div"==g){a:{k=b[0].childNodes;for(var o=0,i=k.length;o<i;o++){var n=k[o];if(n.nodeType==h.ELEMENT_NODE&&f.$block[n.nodeName.toLowerCase()]){k=!0;break a}}k=!1}k=!k}k?d=b:l=b}j.push(b);if("body"==g)break}b=b.parent()}this.block=d;this.blockLimit=l;this.elements=j}var k=d.Editor,
h=d.DOM,f=k.XHTML_DTD,a=null,c={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},e={body:1,div:1,table:1,tbody:1,tr:1,td:1,th:1,caption:1,form:1};g.prototype={compare:function(a){var c=this.elements,a=a&&a.elements;if(!a||c.length!=a.length)return!1;for(var e=0;e<c.length;e++)if(!h.equals(c[e],a[e]))return!1;return!0},contains:function(b){for(var c=this.elements,e=0;e<c.length;e++)if(c[e].nodeName()in b)return c[e];return a},toString:function(){var a=this.elements,
c,e=[];for(c=0;c<a.length;c++)e.push(a[c].nodeName());return e.toString()}};return k.ElementPath=g},{requires:["./base","./dom"]});
KISSY.add("editor/core/enterKey",function(d,g,k,h){function f(a){var f;f=a.getSelection().getRanges();for(var g=f.length-1;0<g;g--)f[g].deleteContents();f=f[0];g=f.document;if(f.checkStartOfBlock()&&f.checkEndOfBlock()){var l=(new h(f.startContainer)).block;if(l&&("li"==l.nodeName()||"li"==l.parent().nodeName()))return a.hasCommand("outdent")?(a.execCommand("save"),a.execCommand("outdent"),a.execCommand("save"),!0):!1}var i=f.splitBlock("p");if(!i)return!0;var a=i.previousBlock,l=i.nextBlock,n=i.wasStartOfBlock,
v=i.wasEndOfBlock,x;if(l)x=l.parent(),"li"==x.nodeName()&&(l._4e_breakParent(x),l._4e_move(l.next(),!0));else if(a&&(x=a.parent())&&"li"==x.nodeName())a._4e_breakParent(x),f.moveToElementEditablePosition(a.next()),a._4e_move(a.prev());if(!n&&!v){if("li"==l.nodeName()&&(x=l.first(k.invisible(!0)))&&d.inArray(x.nodeName(),["ul","ol"]))(c.ie?new m(g.createTextNode("\u00a0")):new m(g.createElement("br"))).insertBefore(x);l&&f.moveToElementEditablePosition(l)}else{var t;if(a){if("li"==a.nodeName()||!e.test(a.nodeName()))t=
a.clone()}else l&&(t=l.clone());t||(t=new m("<p>",null,g));if(x=i.elementPath)for(var i=0,q=x.elements.length;i<q;i++){var u=x.elements[i];if(u.equals(x.block)||u.equals(x.blockLimit))break;b.$removeEmpty[u.nodeName()]&&(u=u.clone(),t._4e_moveChildren(u),t.append(u))}c.ie||t._4e_appendBogus();f.insertNode(t);if(c.ie&&n&&(!v||!a[0].childNodes.length))f.moveToElementEditablePosition(v?a:t),f.select();f.moveToElementEditablePosition(n&&!v?l:t)}c.ie||(l?(t=new m(g.createElement("span")),t.html("&nbsp;"),
f.insertNode(t),t.scrollIntoView(void 0,!1),f.deleteContents()):t.scrollIntoView(void 0,!1));f.select();return!0}function a(a){var b=a.get("document")[0];l.on(b,"keydown",function(b){if(13===b.keyCode&&!b.shiftKey&&!b.ctrlKey&&!b.metaKey){a.execCommand("save");var c=a.execCommand("enterBlock");a.execCommand("save");!1!==c&&b.preventDefault()}})}var c=d.UA,e=/^h[1-6]$/,b=g.XHTML_DTD,m=d.Node,l=d.Event;return{init:function(b){b.addCommand("enterBlock",{exec:f});b.docReady(function(){a(b)})}}},{requires:["./base",
"./walker","./elementPath"]});
KISSY.add("editor/core/focusManager",function(d){function g(){var a=this;a.__iframeFocus=b;e=a;c&&clearTimeout(c);c=setTimeout(function(){a.fire("focus")},100)}function k(){var a=this;a.__iframeFocus=m;e=l;c&&clearTimeout(c);c=setTimeout(function(){a.fire("blur")},100)}var h=d.Editor,f=d.Event,a={},c,e,d={refreshAll:function(){for(var b in a)if(a.hasOwnProperty(b)){var c=a[b].get("document")[0];c.designMode="off";c.designMode="on"}},currentInstance:function(){return e},getInstance:function(b){return a[b]},
add:function(a){var b=a.get("window")[0];f.on(b,"focus",g,a);f.on(b,"blur",k,a)},register:function(b){a[b._UUID]=b},remove:function(b){delete a[b._UUID];var c=b.get("window")[0];f.remove(c,"focus",g,b);f.remove(c,"blur",k,b)}},b=!0,m=!1,l=null;d.refreshAll=d.refreshAll;h.focusManager=d;h.getInstances=function(){return a};return d},{requires:["./base","./dom"]});
KISSY.add("editor/core/htmlDataProcessor",function(d,g){return{init:function(k){function h(a){if((a.getAttribute("class")+"").match(/Apple-\w+-span/)||!a.attributes.length)a.setTagName(null);else if(!a.childNodes.length&&!a.attributes.length)return!1}function f(a){return a.replace(r,function(a,b,c){return"<"+b+c.replace(p,function(a,b){return-1==c.indexOf("_ke_saved_"+b)?" _ke_saved_"+a+" "+a:a})+">"})}function a(a){return a.replace(i,function(a){return"<ke:encoded>"+encodeURIComponent(a)+"</ke:encoded>"})}
function c(a){return a.replace(n,function(a,b){return decodeURIComponent(b)})}var e=d.Node,b=d.UA,m=d.require("htmlparser"),l=new m.Filter,j=new m.Filter;(function(){function a(b){b=m.serialize(b);return new m.Comment(o+encodeURIComponent(b).replace(/--/g,"%2D%2D"))}var c={tagNames:[[/^\?xml.*$/i,""],[/^.*namespace.*$/i,""]],attributeNames:[[/^on/,"ke_on"],[/^lang$/,""]],tags:{script:a,noscript:a,span:h}},e={tagNames:[[/^ke:/,""],[/^\?xml:namespace$/,""]],tags:{$:function(a){if(a.attributes.length)for(var b=
["name","href","src"],c,e=0;e<b.length;e++)c="_ke_saved_"+b[e],a.getAttribute(c)&&a.removeAttribute(b[e]);return a},embed:function(a){var b=a.parentNode;if(b&&"object"==b.nodeName){var c=b.getAttribute("width"),b=b.getAttribute("height");c&&a.setAttribute("width",c);b&&a.setAttribute("width",b)}},a:function(a){if(!a.childNodes.length&&!a.attributes.length)return!1},span:h},attributes:{style:function(a){if(!d.trim(a))return!1}},attributeNames:[[/^_ke_saved_/,""],[/^ke_on/,"on"],[/^_ke.*/,""],[/^ke:.*$/,
""],[/^_ks.*/,""]],comment:function(a){if(a.substr(0,o.length)==o)return a=d.trim(decodeURIComponent(a.substr(o.length))),m.parse(a).childNodes[0]}};b.ie&&(e.attributes.style=function(a){return a.replace(/(^|;)([^:]+)/g,function(a){return a.toLowerCase()})});l.addRules(e);j.addRules(c)})();(function(){function a(b){for(var b=b.childNodes,c=b.length,e=b[c-1];e&&3==e.nodeType&&!d.trim(e.nodeValue);)e=b[--c];return e}function c(e,d){var f=a(e);f&&((d||!b.ie)&&1==f.nodeType&&"br"==f.nodeName?e.removeChild(f):
3==f.nodeType&&x.test(f.nodeValue)&&e.removeChild(f))}function e(b){var c=a(b);return!c||1==c.nodeType&&"br"==c.nodeName||"form"==b.nodeName&&"input"==c.nodeName}function f(a){c(a,!0);e(a)&&(b.ie?a.appendChild(new m.Text("\u00a0")):(a.appendChild(new m.Text("&nbsp;")),a.appendChild(new m.Tag("br"))))}function i(a){c(a,!1);e(a)&&a.appendChild(new m.Text("\u00a0"))}var x=/^[\t\r\n ]*(?:&nbsp;|\xa0)$/,h=g.XHTML_DTD,C=d.merge(h.$block,h.$listItem,h.$tableContent),n;for(n in C)C.hasOwnProperty(n)&&("br"in h[n]||
delete C[n]);delete C.td;delete C.pre;var h={tags:{}},t={tags:{}};for(n in C)C.hasOwnProperty(n)&&(h.tags[n]=f,t.tags[n]=i);j.addRules(h);l.addRules(t)})();l.addRules({text:function(a){return a.replace(/\xa0/g,"&nbsp;")}});var r=/<(a|area|img|input)\b([^>]*)>/gi,p=/\b(href|src|name)\s*=\s*(?:(?:"[^"]*")|(?:'[^']*')|(?:[^ "'>]+))/gi,o="{ke_protected}",i=/(?:<style[^>]*>[\s\S]*<\/style>)|(?:<(:?link|meta|base)[^>]*>)/gi,n=/<ke:encoded>([^<]*)<\/ke:encoded>/gi,v=/(<\/?)((?:object|embed|param|html|body|head|title|script|noscript)[^>]*>)/gi,
x=/(<\/?)ke:((?:object|embed|param|html|body|head|title|script|noscript)[^>]*>)/gi,t=/<ke:(param|embed)([^>]*?)\/?>(?!\s*<\/ke:\1)/gi;k.htmlDataProcessor={dataFilter:j,htmlFilter:l,toHtml:function(a){var b=new m.BeautifyWriter;(new m.Parser(a)).parse().writeHtml(b,l);return a=b.getHtml()},toDataFormat:function(b,d){var d=d||j,b=f(b),b=a(b),b=b.replace(v,"$1ke:$2"),b=b.replace(t,"<ke:$1$2></ke:$1>"),i=new e("<div>");i.html("a"+b);b=i.html().substr(1);b=b.replace(x,"$1$2");b=c(b);i=new m.BasicWriter;
(new m.Parser(b)).parse().writeHtml(i,d);return b=i.getHtml()},toServer:function(a){var b=new m.MinifyWriter;(new m.Parser(a)).parse().writeHtml(b,l);return b.getHtml()}}}}},{requires:["./base"]});
KISSY.add("editor/core/meta",function(){var d={backColor:["../color/btn","./cmd"],localStorage:["../flashBridge/"],bold:["../font/ui","./cmd"],draft:["../localStorage/","../menubutton/"],flash:["../flashCommon/baseClass","../flashCommon/utils"],fontFamily:["../font/ui","./cmd"],fontSize:["../font/ui","./cmd"],foreColor:["../color/btn","./cmd"],heading:["./cmd"],image:["../button/","../bubble/","../contextmenu/","../dialogLoader/"],indent:["./cmd"],orderedList:["../listUtils/btn","./cmd"],unorderedList:["../listUtils/btn",
"./cmd"],italic:["../font/ui","./cmd"],justifyCenter:["./cmd"],justifyLeft:["./cmd"],justifyRight:["./cmd"],link:["../bubble/","./utils","../dialogLoader/"],maximize:["./cmd"],multipleUpload:["../dialogLoader/"],outdent:["./cmd"],overlay:["dd","../focusFix/"],pageBreak:["../fakeObjects/"],removeFormat:["./cmd","../button/"],resize:["dd"],menubutton:["menubutton"],smiley:["../overlay/"],sourceArea:["../button/"],strikeThrough:["../font/ui","./cmd"],table:["../dialogLoader/","../contextmenu/"],underline:["../font/ui",
"./cmd"],undo:["./btn","./cmd"],contextmenu:["menu","../focusFix/"],video:["../flashCommon/utils","../flashCommon/baseClass"],xiamiMusic:["../flashCommon/baseClass","../flashCommon/utils"]},g,k,h={"backColor/cmd":["../color/cmd"],"bold/cmd":["../font/cmd"],"color/btn":["../button/","../overlay/","../dialogLoader/"],"color/colorPicker/dialog":["../../overlay/"],"dentUtils/cmd":["../listUtils/"],"flash/dialog":["../flashCommon/utils","../overlay/","../menubutton/"],"flashCommon/baseClass":["../contextmenu/",
"../bubble/","../dialogLoader/","./utils"],"font/ui":["../button/","../menubutton/"],"fontFamily/cmd":["../font/cmd"],"fontSize/cmd":["../font/cmd"],"foreColor/cmd":["../color/cmd"],"image/dialog":["../overlay/","switchable","../menubutton/"],"indent/cmd":["../dentUtils/cmd"],"orderedList/cmd":["../listUtils/cmd"],"unorderedList/cmd":["../listUtils/cmd"],"italic/cmd":["../font/cmd"],"justifyCenter/cmd":["../justifyUtils/cmd"],"justifyLeft/cmd":["../justifyUtils/cmd"],"justifyRight/cmd":["../justifyUtils/cmd"],
"link/dialog":["../overlay/","./utils"],"listUtils/btn":["../button/"],"listUtils/cmd":["../listUtils/"],"multipleUpload/dialog":["../progressbar/","../overlay/","../flashBridge/","../localStorage/"],"outdent/cmd":["../dentUtils/cmd"],"strikeThrough/cmd":["../font/cmd"],"table/dialog":["../overlay/","../menubutton/"],"underline/cmd":["../font/cmd"],"undo/btn":["../button/"],"video/dialog":["../flash/dialog","../menubutton/"],"xiamiMusic/dialog":["../flash/dialog","../menubutton/"]},f={};for(g in d)k=
"editor/plugin/"+g+"/index",f[k]={requires:d[g]};for(g in h)k="editor/plugin/"+g,f[k]={requires:h[g]};KISSY.add(f)});
KISSY.add("editor/core/range",function(d,g,k,h,f){function a(a){var b=a.nodeType!=n.TEXT_NODE&&n.nodeName(a)in x.$removeEmpty,c=a.nodeType==n.TEXT_NODE&&!d.trim(a.nodeValue),a=!!a.parentNode.getAttribute("_ke_bookmark");return b||c||a}function c(a){return!y(a)&&!s(a)}function e(a){var b=r;return function(c){if(s(c))return j;if(c.nodeType==n.TEXT_NODE){if(d.trim(c.nodeValue).length)return r}else if(c.nodeType==n.ELEMENT_NODE&&(c=n.nodeName(c),!B[c]))if(!a&&!v.ie&&"br"==c&&!b)b=j;else return r;return j}}
function b(a,b){var c=a.startContainer,e=a.endContainer,d=a.startOffset,f=a.endOffset,i,g=r,q=r,l=void 0,m=a.document,h;0<b&&(l=m.createDocumentFragment());if(a.collapsed)return l;a.optimizeBookmark();e[0].nodeType==n.TEXT_NODE?(q=j,e=e._4e_splitText(f)):0<e[0].childNodes.length&&(f>=e[0].childNodes.length?(e=new t(e[0].appendChild(m.createTextNode(""))),h=j):e=new t(e[0].childNodes[f]));c[0].nodeType==n.TEXT_NODE?(g=j,c._4e_splitText(d)):d?d>=c[0].childNodes.length?(c=new t(c[0].appendChild(m.createTextNode(""))),
i=j):c=new t(c[0].childNodes[d].previousSibling):(i=new t(m.createTextNode("")),c.prepend(i),c=i,i=j);var x=c._4e_parents(),y=e._4e_parents();x.each(function(a,b){x[b]=a});y.each(function(a,b){y[b]=a});for(var k,u,m=0;m<x.length&&!(k=x[m],u=y[m],!k.equals(u));m++);for(var d=l,s,o,v=m;v<x.length;v++){s=x[v];f=0<b&&!s.equals(c)?d.appendChild(s.clone()[0]):null;s=s[0].nextSibling;o=y[v];for(var p=e[0],w=o&&o[0];s&&!(w==s||p==s);)o=s.nextSibling,2==b?d.appendChild(s.cloneNode(j)):(n._4e_remove(s),1==
b&&d.appendChild(s)),s=o;f&&(d=f)}for(d=l;m<y.length;m++){s=y[m];f=0<b&&!s.equals(e)?d.appendChild(s.clone()[0]):null;if(!x[m]||!s._4e_sameLevel(x[m]))for(s=s[0].previousSibling;s;)o=s.previousSibling,2==b?d.insertBefore(s.cloneNode(j),d.firstChild):(n._4e_remove(s),1==b&&d.insertBefore(s,d.firstChild)),s=o;f&&(d=f)}if(2==b){if(g&&(k=c[0],k.nodeType==n.TEXT_NODE&&k.nextSibling&&k.nextSibling.nodeType==n.TEXT_NODE&&(k.data+=k.nextSibling.data,k.parentNode.removeChild(k.nextSibling))),q)q=e[0],q.nodeType==
n.TEXT_NODE&&q.previousSibling&&q.previousSibling.nodeType==n.TEXT_NODE&&(q.previousSibling.data+=q.data,q.parentNode.removeChild(q))}else{if(k&&u&&(!c._4e_sameLevel(k)||!e._4e_sameLevel(u)))q=k._4e_index(),i&&k._4e_sameLevel(c)&&q--,a.setStart(k.parent(),q+1);a.collapse(j)}i&&c.remove();h&&e.remove();return l}function m(a){a.collapsed=a.startContainer&&a.endContainer&&a.startContainer[0]==a.endContainer[0]&&a.startOffset==a.endOffset}function l(a){this.endOffset=this.endContainer=this.startOffset=
this.startContainer=p;this.collapsed=j;this.document=a}g.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,SHRINK_ELEMENT:1,SHRINK_TEXT:2};var j=!0,r=!1,p=null,o=g.RANGE,i=g.POSITION,n=d.DOM,v=d.UA,x=g.XHTML_DTD,t=d.Node,q=t.all,u={area:1,base:1,br:1,col:1,hr:1,img:1,input:1,link:1,meta:1,param:1},y=new h.whitespaces,s=new h.bookmark,w=h.whitespaces(j),A=h.bookmark(!1,
!0),B={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};d.augment(l,{toString:function(){var a=[],b=this.startContainer[0],c=this.endContainer[0];a.push((b.id||b.nodeName)+":"+this.startOffset);a.push((c.id||c.nodeName)+":"+this.endOffset);return a.join("<br/>")},optimize:function(){var a=this.startContainer,b=this.startOffset;a[0].nodeType!=n.ELEMENT_NODE&&(b?b>=a[0].nodeValue.length&&
this.setStartAfter(a):this.setStartBefore(a));a=this.endContainer;b=this.endOffset;a[0].nodeType!=n.ELEMENT_NODE&&(b?b>=a[0].nodeValue.length&&this.setEndAfter(a):this.setEndBefore(a))},setStartAfter:function(a){this.setStart(a.parent(),a._4e_index()+1)},setStartBefore:function(a){this.setStart(a.parent(),a._4e_index())},setEndAfter:function(a){this.setEnd(a.parent(),a._4e_index()+1)},setEndBefore:function(a){this.setEnd(a.parent(),a._4e_index())},optimizeBookmark:function(){var a=this.startContainer,
b=this.endContainer;a&&"span"==a.nodeName()&&a.attr("_ke_bookmark")&&this.setStartBefore(a);b&&"span"==b.nodeName()&&b.attr("_ke_bookmark")&&this.setEndAfter(b)},setStart:function(a,b){a[0].nodeType==n.ELEMENT_NODE&&u[a.nodeName()]&&(a=a.parent(),b=a._4e_index());this.startContainer=a;this.startOffset=b;this.endContainer||(this.endContainer=a,this.endOffset=b);m(this)},setEnd:function(a,b){a[0].nodeType==n.ELEMENT_NODE&&u[a.nodeName()]&&(a=a.parent(),b=a._4e_index()+1);this.endContainer=a;this.endOffset=
b;this.startContainer||(this.startContainer=a,this.startOffset=b);m(this)},setStartAt:function(a,b){switch(b){case o.POSITION_AFTER_START:this.setStart(a,0);break;case o.POSITION_BEFORE_END:a[0].nodeType==n.TEXT_NODE?this.setStart(a,a[0].nodeValue.length):this.setStart(a,a[0].childNodes.length);break;case o.POSITION_BEFORE_START:this.setStartBefore(a);break;case o.POSITION_AFTER_END:this.setStartAfter(a)}m(this)},setEndAt:function(a,b){switch(b){case o.POSITION_AFTER_START:this.setEnd(a,0);break;
case o.POSITION_BEFORE_END:a[0].nodeType==n.TEXT_NODE?this.setEnd(a,a[0].nodeValue.length):this.setEnd(a,a[0].childNodes.length);break;case o.POSITION_BEFORE_START:this.setEndBefore(a);break;case o.POSITION_AFTER_END:this.setEndAfter(a)}m(this)},cloneContents:function(){return b(this,2)},deleteContents:function(){return b(this,0)},extractContents:function(){return b(this,1)},collapse:function(a){a?(this.endContainer=this.startContainer,this.endOffset=this.startOffset):(this.startContainer=this.endContainer,
this.startOffset=this.endOffset);this.collapsed=j},clone:function(){var a=new l(this.document);a.startContainer=this.startContainer;a.startOffset=this.startOffset;a.endContainer=this.endContainer;a.endOffset=this.endOffset;a.collapsed=this.collapsed;return a},getEnclosedNode:function(){var a=this.clone();a.optimize();if(a.startContainer[0].nodeType!=n.ELEMENT_NODE||a.endContainer[0].nodeType!=n.ELEMENT_NODE)return p;var b=new h(a);b.evaluator=function(a){return w(a)&&A(a)};a=b.next();b.reset();b=
b.previous();return a&&a.equals(b)?a:p},shrink:function(a,b){if(!this.collapsed){var a=a||o.SHRINK_TEXT,c=this.clone(),e=this.startContainer,d=this.endContainer,f=this.startOffset,i=this.endOffset,q=j,l,g,m=j;e&&e[0].nodeType==n.TEXT_NODE&&(f?f>=e[0].nodeValue.length?c.setStartAfter(e):(c.setStartBefore(e),q=r):c.setStartBefore(e));d&&d[0].nodeType==n.TEXT_NODE&&(i?i>=d[0].nodeValue.length?c.setEndAfter(d):(c.setEndAfter(d),m=r):c.setEndBefore(d));if(q||m)g=new h(c),g.evaluator=function(b){return b.nodeType==
(a==o.SHRINK_ELEMENT?n.ELEMENT_NODE:n.TEXT_NODE)},g.guard=function(b,c){if(a==o.SHRINK_ELEMENT&&b.nodeType==n.TEXT_NODE||c&&b==l)return r;!c&&b.nodeType==n.ELEMENT_NODE&&(l=b);return j};q&&(c=g[a==o.SHRINK_ELEMENT?"lastForward":"next"]())&&this.setStartAt(c,b?o.POSITION_AFTER_START:o.POSITION_BEFORE_START);m&&(g.reset(),(g=g[a==o.SHRINK_ELEMENT?"lastBackward":"previous"]())&&this.setEndAt(g,b?o.POSITION_BEFORE_END:o.POSITION_AFTER_END));return q||m}},createBookmark2:function(a){var b=this.startContainer,
c=this.endContainer,e=this.startOffset,d=this.endOffset,f,i;if(!b||!c)return{start:0,end:0};if(a){if(b[0].nodeType==n.ELEMENT_NODE&&(f=new t(b[0].childNodes[e]))&&f[0]&&f[0].nodeType==n.TEXT_NODE&&0<e&&f[0].previousSibling.nodeType==n.TEXT_NODE)b=f,e=0;for(;b[0].nodeType==n.TEXT_NODE&&(i=b.prev(void 0,1))&&i[0].nodeType==n.TEXT_NODE;)b=i,e+=i[0].nodeValue.length;if(!this.collapsed){if(c[0].nodeType==n.ELEMENT_NODE&&(f=new t(c[0].childNodes[d]))&&f[0]&&f[0].nodeType==n.TEXT_NODE&&0<d&&f[0].previousSibling.nodeType==
n.TEXT_NODE)c=f,d=0;for(;c[0].nodeType==n.TEXT_NODE&&(i=c.prev(void 0,1))&&i[0].nodeType==n.TEXT_NODE;)c=i,d+=i[0].nodeValue.length}}return{start:b._4e_address(a),end:this.collapsed?p:c._4e_address(a),startOffset:e,endOffset:d,normalized:a,is2:j}},createBookmark:function(a){var b,c,e,f,i=this.collapsed;b=new t("<span>",p,this.document);b.attr("_ke_bookmark",1);b.css("display","none");b.html("&nbsp;");a&&(e=d.guid("ke_bm_"),b.attr("id",e+"S"));i||(c=b.clone(),c.html("&nbsp;"),a&&c.attr("id",e+"E"),
f=this.clone(),f.collapse(),f.insertNode(c));f=this.clone();f.collapse(j);f.insertNode(b);c?(this.setStartAfter(b),this.setEndBefore(c)):this.moveToPosition(b,o.POSITION_AFTER_END);return{startNode:a?e+"S":b,endNode:a?e+"E":c,serializable:a,collapsed:i}},moveToPosition:function(a,b){this.setStartAt(a,b);this.collapse(j)},trim:function(a,b){var c=this.startContainer,e=this.startOffset,d=this.collapsed;if((!a||d)&&c[0]&&c[0].nodeType==n.TEXT_NODE){if(e)if(e>=c[0].nodeValue.length)e=c._4e_index()+1,
c=c.parent();else{var f=c._4e_splitText(e),e=c._4e_index()+1,c=c.parent();n.equals(this.startContainer,this.endContainer)?this.setEnd(f,this.endOffset-this.startOffset):n.equals(c,this.endContainer)&&(this.endOffset+=1)}else e=c._4e_index(),c=c.parent();this.setStart(c,e);if(d){this.collapse(j);return}}c=this.endContainer;e=this.endOffset;!b&&!d&&c[0]&&c[0].nodeType==n.TEXT_NODE&&(e?(e>=c[0].nodeValue.length||c._4e_splitText(e),e=c._4e_index()+1):e=c._4e_index(),c=c.parent(),this.setEnd(c,e))},insertNode:function(a){this.optimizeBookmark();
this.trim(r,j);var b=this.startContainer;b[0].insertBefore(a[0],b[0].childNodes[this.startOffset]||null);b[0]==this.endContainer[0]&&this.endOffset++;this.setStartBefore(a)},moveToBookmark:function(a){var b=q(this.document);if(a.is2){var c=b._4e_getByAddress(a.start,a.normalized),e=a.startOffset,b=a.end&&b._4e_getByAddress(a.end,a.normalized),a=a.endOffset;this.setStart(c,e);b?this.setEnd(b,a):this.collapse(j)}else c=(e=a.serializable)?d.one("#"+a.startNode,b):a.startNode,a=e?d.one("#"+a.endNode,
b):a.endNode,this.setStartBefore(c),c._4e_remove(),a&&a[0]?(this.setEndBefore(a),a._4e_remove()):this.collapse(j)},getCommonAncestor:function(a,b){var c=this.startContainer,e=this.endContainer,c=c[0]==e[0]?a&&c[0].nodeType==n.ELEMENT_NODE&&this.startOffset==this.endOffset-1?new t(c[0].childNodes[this.startOffset]):c:c._4e_commonAncestor(e);return b&&c[0].nodeType==n.TEXT_NODE?c.parent():c},enlarge:function(){function a(b,c,e,d){var f=b[c?"startContainer":"endContainer"],i,g=c?0:1,l=0,j=c?"previousSibling":
"nextSibling";i=b[c?"startOffset":"endOffset"];if(f[0].nodeType==n.TEXT_NODE){if(c){if(i)return}else if(i<f[0].nodeValue.length)return;i=f[0][j];f=f[0].parentNode}else i=f[0].childNodes[i+(c?-1:1)]||null,f=f[0];for(;f;){for(;i;)if(y(i)||s(i))i=i[j];else break;if(i){if(!l)b[c?"setStartAfter":"setEndBefore"](q(i));break}f=q(f);if("body"==f.nodeName())break;if(l||f.equals(d))e[g]=f,l=1;else b[c?"setStartBefore":"setEndAfter"](f);i=f[0][j];f=f[0].parentNode}}return function(b){switch(b){case o.ENLARGE_ELEMENT:if(this.collapsed)break;
var b=this.getCommonAncestor(),c=[];a(this,1,c,b);a(this,0,c,b);c[0]&&c[1]&&(b=c[0].contains(c[1])?c[1]:c[0],this.setStartBefore(b),this.setEndAfter(b));break;case o.ENLARGE_BLOCK_CONTENTS:case o.ENLARGE_LIST_ITEM_CONTENTS:var e=new l(this.document),c=new t(this.document.body);e.setStartAt(c,o.POSITION_AFTER_START);e.setEnd(this.startContainer,this.startOffset);var e=new h(e),d,f,i=h.blockBoundary(b==o.ENLARGE_LIST_ITEM_CONTENTS?{br:1}:p),g=function(a){var b=i(a);b||(d=q(a));return b},j=function(a){var b=
g(a);!b&&"br"==n.nodeName(a)&&(f=q(a));return b};e.guard=g;e=e.lastBackward();d=d||c;this.setStartAt(d,"br"!=d.nodeName()&&(!e&&this.checkStartOfBlock()||e&&d.contains(e))?o.POSITION_AFTER_START:o.POSITION_AFTER_END);e=this.clone();e.collapse();e.setEndAt(c,o.POSITION_BEFORE_END);e=new h(e);e.guard=b==o.ENLARGE_LIST_ITEM_CONTENTS?j:g;d=p;e=e.lastForward();d=d||c;this.setEndAt(d,!e&&this.checkEndOfBlock()||e&&d.contains(e)?o.POSITION_BEFORE_END:o.POSITION_BEFORE_START);f&&this.setEndAfter(f)}}}(),
checkStartOfBlock:function(){var a=this.startContainer,b=this.startOffset;if(b&&a[0].nodeType==n.TEXT_NODE&&d.trim(a[0].nodeValue.substring(0,b)).length)return r;this.trim();a=new f(this.startContainer);b=this.clone();b.collapse(j);b.setStartAt(a.block||a.blockLimit,o.POSITION_AFTER_START);a=new h(b);a.evaluator=e(j);return a.checkBackward()},checkEndOfBlock:function(){var a=this.endContainer,b=this.endOffset;if(a[0].nodeType==n.TEXT_NODE&&d.trim(a[0].nodeValue.substring(b)).length)return r;this.trim();
a=new f(this.endContainer);b=this.clone();b.collapse(r);b.setEndAt(a.block||a.blockLimit,o.POSITION_BEFORE_END);a=new h(b);a.evaluator=e(r);return a.checkForward()},checkBoundaryOfElement:function(b,c){var e=this.clone();e[c==o.START?"setStartAt":"setEndAt"](b,c==o.START?o.POSITION_AFTER_START:o.POSITION_BEFORE_END);e=new h(e);e.evaluator=a;return e[c==o.START?"checkBackward":"checkForward"]()},getBoundaryNodes:function(){var a=this.startContainer,b=this.endContainer,c=this.startOffset,e=this.endOffset,
d;if(a[0].nodeType==n.ELEMENT_NODE)if(d=a[0].childNodes.length,d>c)a=q(a[0].childNodes[c]);else if(0==d)a=a._4e_previousSourceNode();else{for(a=a[0];a.lastChild;)a=a.lastChild;a=q(a);a=a._4e_nextSourceNode()||a}if(b[0].nodeType==n.ELEMENT_NODE)if(d=b[0].childNodes.length,d>e)b=q(b[0].childNodes[e])._4e_previousSourceNode(j);else if(0==d)b=b._4e_previousSourceNode();else{for(b=b[0];b.lastChild;)b=b.lastChild;b=q(b)}a._4e_position(b)&i.POSITION_FOLLOWING&&(a=b);return{startNode:a,endNode:b}},fixBlock:function(a,
b){var c=this.createBookmark(),e=q(this.document.createElement(b));this.collapse(a);this.enlarge(o.ENLARGE_BLOCK_CONTENTS);e[0].appendChild(this.extractContents());e._4e_trim();v.ie||e._4e_appendBogus();this.insertNode(e);this.moveToBookmark(c);return e},splitBlock:function(a){var b=new f(this.startContainer),c=new f(this.endContainer),e=b.block,i=c.block,g=p;if(!b.blockLimit.equals(c.blockLimit))return p;"br"!=a&&(e||(e=this.fixBlock(j,a),i=(new f(this.endContainer)).block),i||(i=this.fixBlock(r,
a)));a=e&&this.checkStartOfBlock();b=i&&this.checkEndOfBlock();this.deleteContents();e&&e[0]==i[0]&&(b?(g=new f(this.startContainer),this.moveToPosition(i,o.POSITION_AFTER_END),i=p):a?(g=new f(this.startContainer),this.moveToPosition(e,o.POSITION_BEFORE_START),e=p):(i=this.splitElement(e),!v.ie&&!d.inArray(e.nodeName(),["ul","ol"])&&e._4e_appendBogus()));return{previousBlock:e,nextBlock:i,wasStartOfBlock:a,wasEndOfBlock:b,elementPath:g}},splitElement:function(a){if(!this.collapsed)return p;this.setEndAt(a,
o.POSITION_BEFORE_END);var b=this.extractContents(),c=a.clone(r);c[0].appendChild(b);c.insertAfter(a);this.moveToPosition(a,o.POSITION_AFTER_END);return c},moveToElementEditablePosition:function(a,b){for(var e=0;a;){if(a[0].nodeType==n.TEXT_NODE){this.moveToPosition(a,b?o.POSITION_AFTER_END:o.POSITION_BEFORE_START);e=1;break}a[0].nodeType==n.ELEMENT_NODE&&a._4e_isEditable()&&(this.moveToPosition(a,b?o.POSITION_BEFORE_END:o.POSITION_AFTER_START),e=1);var d=a,f=e,i=void 0;d[0].nodeType==n.ELEMENT_NODE&&
d._4e_isEditable()&&(i=d[b?"last":"first"](c,1));!f&&!i&&(i=d[b?"prev":"next"](c,1));a=i}return!!e},selectNodeContents:function(a){var b=a[0];this.setStart(a,0);this.setEnd(a,b.nodeType==n.TEXT_NODE?b.nodeValue.length:b.childNodes.length)},insertNodeByDtd:function(a){var b,c,e,d=a.nodeName();b=x.$block[d];this.deleteContents();if(b){for(b=this.getCommonAncestor(r,j);(c=x[b.nodeName()])&&(!c||!c[d]);){var f=b.parent();this.checkStartOfBlock()&&this.checkEndOfBlock()?(this.setStartBefore(b),this.collapse(j),
b.remove()):e=b;b=f}e&&this.splitElement(e)}this.insertNode(a)}});k.injectDom({_4e_breakParent:function(a,b){var b=q(b),a=q(a),c,e=new g.Range(a[0].ownerDocument);e.setStartAfter(a);e.setEndAfter(b);c=e.extractContents();e.insertNode(a.remove());a.after(c)}});return g.Range=l},{requires:["./base","./utils","./walker","./elementPath","./dom"]});
KISSY.add("editor/core/selection",function(d){function g(a){this.document=a;this._={cache:{}};if(j)try{var b=this.getNative().createRange();if(!b||b.item&&b.item(0).ownerDocument!=a||b.parentElement&&b.parentElement().ownerDocument!=a)this.isInvalid=f}catch(c){this.isInvalid=f}}function k(b){b=new g(b);return!b||b.isInvalid?a:b}var h=d.Editor;h.SELECTION={SELECTION_NONE:1,SELECTION_TEXT:2,SELECTION_ELEMENT:3};var f=!0,a=null,c=d.UA,e=d.DOM,b=d.Node,m=h.SELECTION,l=h.RANGE,j=c.ie,r=h.Walker,p=h.Range,
o={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};d.augment(g,{getNative:!j?function(){var a=this._.cache;return a.nativeSel||(a.nativeSel=e._getWin(this.document).getSelection())}:function(){var a=this._.cache;return a.nativeSel||(a.nativeSel=this.document.selection)},getType:!j?function(){var a=this._.cache;if(a.type)return a.type;var b=m.SELECTION_TEXT,c=this.getNative();if(c){if(1==c.rangeCount){var c=
c.getRangeAt(0),d=c.startContainer;d==c.endContainer&&d.nodeType==e.ELEMENT_NODE&&1==Number(c.endOffset-c.startOffset)&&o[d.childNodes[c.startOffset].nodeName.toLowerCase()]&&(b=m.SELECTION_ELEMENT)}}else b=m.SELECTION_NONE;return a.type=b}:function(){var a=this._.cache;if(a.type)return a.type;var b=m.SELECTION_NONE;try{var c=this.getNative(),e=c.type;"Text"==e&&(b=m.SELECTION_TEXT);"Control"==e&&(b=m.SELECTION_ELEMENT);c.createRange().parentElement&&(b=m.SELECTION_TEXT)}catch(d){}return a.type=b},
getRanges:j?function(){var c=function(b,c){b=b.duplicate();b.collapse(c);for(var d=b.parentElement(),f=d.childNodes,i,g=0;g<f.length;g++){var l=f[g];if(l.nodeType==e.ELEMENT_NODE){i=b.duplicate();i.moveToElementText(l);var l=i.compareEndPoints("StartToStart",b),j=i.compareEndPoints("EndToStart",b);i.collapse();if(0<l)break;else{if(!l||1==j&&-1==l)return{container:d,offset:g};if(!j)return{container:d,offset:g+1}}i=a}}i||(i=b.duplicate(),i.moveToElementText(d),i.collapse(!1));i.setEndPoint("StartToStart",
b);i=(""+i.text).replace(/\r\n|\r/g,"\n").length;try{for(;0<i;)i-=f[--g].nodeValue.length}catch(m){i=0}return 0===i?{container:d,offset:g}:{container:f[g],offset:-i}};return function(a){var e=this._.cache;if(e.ranges&&!a)return e.ranges;var d=this.getNative(),a=d&&d.createRange(),i=this.getType();if(!d)return[];if(i==m.SELECTION_TEXT)return d=new p(this.document),i=c(a,f),d.setStart(new b(i.container),i.offset),i=c(a),d.setEnd(new b(i.container),i.offset),e.ranges=[d];if(i==m.SELECTION_ELEMENT){e=
e.ranges=[];for(i=0;i<a.length;i++){for(var g=a.item(i),l=g.parentNode,j=0,d=new p(this.document);j<l.childNodes.length&&l.childNodes[j]!=g;j++);d.setStart(new b(l),j);d.setEnd(new b(l),j+1);e.push(d)}return e}return e.ranges=[]}}():function(a){var c=this._.cache;if(c.ranges&&!a)return c.ranges;var a=[],e=this.getNative();if(!e)return[];for(var d=0;d<e.rangeCount;d++){var f=e.getRangeAt(d),i=new p(this.document);i.setStart(new b(f.startContainer),f.startOffset);i.setEnd(new b(f.endContainer),f.endOffset);
a.push(i)}return c.ranges=a},getStartElement:function(){var a=this._.cache;if(void 0!==a.startElement)return a.startElement;var c,d=this.getNative();switch(this.getType()){case m.SELECTION_ELEMENT:return this.getSelectedElement();case m.SELECTION_TEXT:var i=this.getRanges()[0];if(i&&!i.collapsed){for(i.optimize();f;)if(c=i.startContainer,i.startOffset==(c[0].nodeType===e.ELEMENT_NODE?c[0].childNodes.length:c[0].nodeValue.length)&&!c._4e_isBlockBoundary())i.setStartAfter(c);else break;c=i.startContainer;
if(c[0].nodeType!=e.ELEMENT_NODE)return c.parent();c=new b(c[0].childNodes[i.startOffset]);if(!c[0]||c[0].nodeType!=e.ELEMENT_NODE)return i.startContainer;for(i=c[0].firstChild;i&&i.nodeType==e.ELEMENT_NODE;)c=new b(i),i=i.firstChild;return c}if(j)i=d.createRange(),i.collapse(f),c=new b(i.parentElement());else{if((c=d.anchorNode)&&c.nodeType!=e.ELEMENT_NODE)c=c.parentNode;c&&(c=new b(c))}}return a.startElement=c},getSelectedElement:function(){var a,c=this._.cache;if(void 0!==c.selectedElement)return c.selectedElement;
j&&(a=this.getNative().createRange(),a=a.item&&a.item(0));var d;if(a)d=new b(a);else{a=this.getRanges()[0];for(var f,i=2;i&&(!(d=a.getEnclosedNode())||!(d[0].nodeType==e.ELEMENT_NODE&&o[d.nodeName()]&&(f=d)));i--)a.shrink(l.SHRINK_ELEMENT);d=f}return c.selectedElement=d},reset:function(){this._.cache={}},selectElement:function(a){var b,c=this.document;if(j)try{b=c.body.createControlRange(),b.addElement(a[0]),b.select()}catch(e){b=c.body.createTextRange(),b.moveToElementText(a[0]),b.select()}finally{}else b=
c.createRange(),b.selectNode(a[0]),a=this.getNative(),a.removeAllRanges(),a.addRange(b);this.reset()},selectRanges:function(a){if(j){if(1<a.length){var b=a[a.length-1];a[0].setEnd(b.endContainer,b.endOffset);a.length=1}a[0]&&a[0].select()}else{b=this.getNative();if(!b)return;b.removeAllRanges();for(var d=0;d<a.length;d++){var f=a[d],i=this.document.createRange(),g=f.startContainer;if(f.collapsed&&(c.gecko&&1.09>c.gecko||c.opera||c.webkit)&&g[0].nodeType==e.ELEMENT_NODE&&!g[0].childNodes.length)g[0].appendChild(this.document.createTextNode(c.webkit?
"\u200b":"")),f.startOffset++,f.endOffset++;i.setStart(g[0],f.startOffset);i.setEnd(f.endContainer[0],f.endOffset);b.addRange(i)}}this.reset()},createBookmarks2:function(a){for(var b=[],c=this.getRanges(),e=0;e<c.length;e++)b.push(c[e].createBookmark2(a));return b},createBookmarks:function(a,b){for(var c=[],i=this.document,g,b=b||this.getRanges(),l=b.length,j=0;j<l;j++){c.push(g=b[j].createBookmark(a,f));var m=(a=g.serializable)?d.one("#"+g.startNode,i):g.startNode;g=a?d.one("#"+g.endNode,i):g.endNode;
for(var h=j+1;h<l;h++){var n=b[h],k=n.startContainer,r=n.endContainer;e.equals(k,m.parent())&&n.startOffset++;e.equals(k,g.parent())&&n.startOffset++;e.equals(r,m.parent())&&n.endOffset++;e.equals(r,g.parent())&&n.endOffset++}}return c},selectBookmarks:function(a){for(var b=[],c=0;c<a.length;c++){var e=new p(this.document);e.moveToBookmark(a[c]);b.push(e)}this.selectRanges(b);return this},getCommonAncestor:function(){var a=this.getRanges();return a[0].startContainer._4e_commonAncestor(a[a.length-
1].endContainer)},scrollIntoView:function(){var a=this.getStartElement();a&&a.scrollIntoView(void 0,!1)},removeAllRanges:function(){var a=this.getNative();j?a&&a.clear():a&&a.removeAllRanges()}});var i={table:1,tbody:1,tr:1},n=r.whitespaces(f),v=/\ufeff|\u00a0/;p.prototype.select=p.prototype.select=!j?function(){var a=this.startContainer;this.collapsed&&a[0].nodeType==e.ELEMENT_NODE&&!a[0].childNodes.length&&a[0].appendChild(this.document.createTextNode(""));var b=this.document.createRange();b.setStart(a[0],
this.startOffset);try{b.setEnd(this.endContainer[0],this.endOffset)}catch(c){if(0<=c.toString().indexOf("NS_ERROR_ILLEGAL_VALUE"))this.collapse(f),b.setEnd(this.endContainer[0],this.endOffset);else throw c;}a=k(this.document).getNative();a.removeAllRanges();a.addRange(b)}:function(a){var c=this.collapsed,d,j;if(this.startContainer[0]===this.endContainer[0]&&1==this.endOffset-this.startOffset){var m=this.startContainer[0].childNodes[this.startOffset];if(m.nodeType==e.ELEMENT_NODE){(new g(this.document)).selectElement(new b(m));
return}}(this.startContainer[0].nodeType==e.ELEMENT_NODE&&this.startContainer.nodeName()in i||this.endContainer[0].nodeType==e.ELEMENT_NODE&&this.endContainer.nodeName()in i)&&this.shrink(l.SHRINK_ELEMENT,f);var h=this.createBookmark(),m=h.startNode,k;c||(k=h.endNode);h=this.document.body.createTextRange();h.moveToElementText(m[0]);h.moveStart("character",1);if(k)a=this.document.body.createTextRange(),a.moveToElementText(k[0]),h.setEndPoint("EndToEnd",a),h.moveEnd("character",-1);else{for(d=m[0].nextSibling;d&&
!n(d);)d=d.nextSibling;d=!(d&&d.nodeValue&&d.nodeValue.match(v))&&(a||!m[0].previousSibling||m[0].previousSibling&&"br"==e.nodeName(m[0].previousSibling));j=new b(this.document.createElement("span"));j.html("&#65279;");j.insertBefore(m);d&&e.insertBefore(this.document.createTextNode("\ufeff"),m[0]||m)}this.setStartBefore(m);m._4e_remove();if(c){if(d?(h.moveStart("character",-1),h.select(),this.document.selection.clear()):h.select(),j)this.moveToPosition(j,l.POSITION_BEFORE_START),j._4e_remove()}else this.setEndBefore(k),
k._4e_remove(),h.select()};g.getSelection=k;return h.Selection=g},{requires:["./base","./walker","./range","./dom"]});
KISSY.add("editor/core/selectionFix",function(d,g){function k(a){function c(a,e){var d=j.body.createTextRange();try{d.moveToPoint(a,e)}catch(f){d=b}return d}function e(){var a=j.selection.createRange();m&&!a.item&&0===a.compareEndPoints("StartToEnd",a)&&m.select();l.remove(j,"mouseup",e);l.remove(j,"mousemove",d);m=f=0}function d(a){if(a.button){if(a=c(a.pageX,a.pageY))0<a.compareEndPoints("StartToStart",m)?a.setEndPoint("StartToStart",m):a.setEndPoint("EndToEnd",m),a.select()}else e()}var f,g=a.get("window")[0],
j=a.get("document")[0],m;l.on(j,"mousedown contextmenu",function(a){var b=j.documentElement;if(a.target===b&&(f&&e(),!(b.scrollHeight>b.clientHeight)&&(f=1,m=c(a.pageX,a.pageY))))l.on(j,"mouseup",e),l.on(j,"mousemove",d),g.focus(),m.select()})}function h(a){function d(b){if(h){var e=a.getSelection(),g=e&&e.getType(),j=e&&f.selection;if(b&&j&&g==p.SELECTION_NONE&&!f.queryCommandEnabled("InsertImage"))setTimeout(function(){d(c)},50);else{var l;if(!j||!j.type||!("Control"!=j.type&&(l=j.createRange())&&
(l=l.parentElement())&&(l=l.nodeName)&&l.toLowerCase()in{input:1,textarea:1}))m=j&&e.getRanges()[0],a.checkSelectionChange()}}}var f=a.get("document")[0],j=new r(f.body),l=new r(f.documentElement);if(8>g.Utils.ieEngine)l.on("click",function(b){"html"===(new r(b.target)).nodeName()&&a.getSelection().getNative().createRange().select()});var m,h,k=c;l.on("mousedown",function(){k=e});l.on("mouseup",function(){k=c});j.on("focusin",function(a){if("body"==(new r(a.target)).nodeName()&&m){try{k&&m.select()}catch(c){}m=
b}});j.on("focus",function(){h=c;d()});j.on("beforedeactivate",function(a){a.relatedTarget||(h=e,k=c)});j.on("mousedown",function(){h=e});j.on("mouseup",function(){h=c;setTimeout(function(){d(c)},0)});j.on("keydown",function(){h=e});j.on("keyup",function(){h=c;setTimeout(function(){d()},0)})}function f(a){var b=a.get("document")[0];l.on(b,"mouseup keyup",function(){a.checkSelectionChange()})}function a(a){function b(a){var c=g.XHTML_DTD;return a._4e_isBlockBoundary()&&c.$empty[a.nodeName()]}function d(a){return l(a)&&
h(a)}var f=/\s*<(p|div|address|h\d|center)[^>]*>\s*(?:<br[^>]*>|&nbsp;|\u00A0|&#160;|(<\!--[\s\S]*?--\>))?\s*(:?<\/\1>)?(?=\s*$|<\/body>)/gi,l=g.Walker.whitespaces(c),h=g.Walker.bookmark(e,c),k=function(a){return l(a)&&8!=a.nodeType};a.on("selectionChange",function(l){var h=l.path,x=new r(a.get("document")[0].body),l=(l=l.selection)&&l.getRanges()[0],p=h.blockLimit;if(m.gecko){var t=h.block||h.blockLimit,B=t&&t.last(d);t&&t._4e_isBlockBoundary()&&(!B||!(1==B[0].nodeType&&B._4e_isBlockBoundary()))&&
"pre"!=t.nodeName()&&!t._4e_getBogus()&&t._4e_appendBogus()}if(l&&l.collapsed&&!h.block){if("body"==p.nodeName()){if((h=l.fixBlock(c,"p"))&&h[0]!=x[0].lastChild&&h._4e_outerHtml().match(f))if((p=h.next(k,1))&&p[0].nodeType==j.ELEMENT_NODE&&!b[p])l.moveToElementEditablePosition(p),h._4e_remove();else if((p=h.prev(k,1))&&p[0].nodeType==j.ELEMENT_NODE&&!b[p])l.moveToElementEditablePosition(p,p._4e_outerHtml().match(f)?e:c),h._4e_remove();l.select();a.notifySelectionChange()}h=a.get("document")[0];l=
new g.Range(h);l.moveToElementEditablePosition(x,c);"body"!==(new g.ElementPath(l.startContainer)).blockLimit.nodeName()&&(x=(new r(h.createElement("p"))).appendTo(x),m.ie||x._4e_appendBogus())}})}var c=!0,e=!1,b=null,m=d.UA,l=d.Event,j=d.DOM,r=d.Node,p=g.SELECTION;return{init:function(b){b.docReady(function(){m.ie?(k(b),h(b)):f(b)});a(b)}}},{requires:["./base","./selection"]});
KISSY.add("editor/core/styles",function(d,g){function k(a){return!w.attr(a,"_ke_bookmark")}function h(a,b){for(var c in a)a.hasOwnProperty(c)&&(d.isString(a[c])?a[c]=a[c].replace(L,function(a,c){return b[c]}):h(a[c],b))}function f(a,b){b&&(a=d.clone(a),h(a,b));var c=this.element=this.element=(a.element||"*").toLowerCase();this.type=this.type="#text"==c||K[c]?A.STYLE_BLOCK:I[c]?A.STYLE_OBJECT:A.STYLE_INLINE;this._={definition:a}}function a(a,b){var c=b?this.removeFromRange:this.applyToRange;a.body.focus();
for(var e=new C(a),d=e.getRanges(),f=0;f<d.length;f++)c.call(this,d[f]);e.selectRanges(d)}function c(a,b,c){var e=a.element;"*"==e&&(e="span");b=new D(b.createElement(e));c&&c._4e_copyAttributes(b);c=a._.definition;a=c.attributes;c=f.getStyleText(c);if(a)for(var d in a)a.hasOwnProperty(d)&&b.attr(d,a[d]);c&&(b[0].style.cssText=c);return b}function e(a){var e=a.createBookmark(u),d=a.createIterator();d.enforceRealBlocks=u;d.enlargeBr=u;for(var f,i=a.document;f=d.getNextParagraph();){var g=c(this,i,
f),j=g,g="pre"==j.nodeName,h="pre"==f.nodeName,n=!g&&h;g&&!h?(h=f,n=h.html(),n=b(n,/(?:^[ \t\n\r]+)|(?:[ \t\n\r]+$)/g,""),n=n.replace(/[ \t\r\n]*(<br[^>]*>)[ \t\r\n]*/gi,"$1"),n=n.replace(/([ \t\n\r]+|&nbsp;)/g," "),n=n.replace(/<br\b[^>]*>/gi,"\n"),G.ie?(h=h[0].ownerDocument.createElement("div"),h.appendChild(j[0]),j[0].outerHTML="<pre>"+n+"</pre>",j=new D(h.firstChild),j._4e_remove()):j.html(n)):n?j=l(m(f),j):f._4e_moveChildren(j);f[0].parentNode.replaceChild(j[0],f[0]);if(g&&(f=j,g=void 0,(g=f._4e_previousSourceNode(u,
w.ELEMENT_NODE))&&"pre"==g.nodeName()))j=b(g.html(),/\n$/,"")+"\n\n"+b(f.html(),/^\n/,""),G.ie?f[0].outerHTML="<pre>"+j+"</pre>":f.html(j),g._4e_remove()}a.moveToBookmark(e)}function b(a,b,c){var e="",d="",a=a.replace(/(^<span[^>]+_ke_bookmark.*?\/span>)|(<span[^>]+_ke_bookmark.*?\/span>$)/gi,function(a,b,c){b&&(e=b);c&&(d=c);return""});return e+a.replace(b,c)+d}function m(a){var c=[];b(a._4e_outerHtml(),/(\S\s*)\n(?:\s|(<span[^>]+_ck_bookmark.*?\/span>))*\n(?!$)/gi,function(a,b,c){return b+"</pre>"+
c+"<pre>"}).replace(/<pre\b.*?>([\s\S]*?)<\/pre>/gi,function(a,b){c.push(b)});return c}function l(a,c){for(var e=c[0].ownerDocument.createDocumentFragment(),d=0;d<a.length;d++){var f=a[d],f=f.replace(/(\r\n|\r)/g,"\n"),f=b(f,/^[ \t]*\n/,""),f=b(f,/\n$/,""),f=b(f,/^[ \t]+|[ \t]+$/g,function(a,b){return 1==a.length?"&nbsp;":b?" "+Array(a.length).join("&nbsp;"):Array(a.length).join("&nbsp;")+" "}),f=f.replace(/\n/g,"<br>"),f=f.replace(/[ \t]{2,}/g,function(a){return Array(a.length).join("&nbsp;")+" "}),
i=c.clone();i.html(f);e.appendChild(i[0])}return e}function j(a){var b=a.document;if(a.collapsed)b=c(this,b,void 0),a.insertNode(b),a.moveToPosition(b,B.POSITION_BEFORE_END);else{var e=this.element,d=this._.definition,f,i=F[e];i||(f=u,i=F.span);var j=a.createBookmark();a.enlarge(B.ENLARGE_ELEMENT);a.trim();for(var g=a.createBookmark(),l=g.startNode,g=g.endNode,m=l,h;m&&m[0];){var n=y;if(w.equals(m,g))m=s,n=u;else{var q=m[0].nodeType,r=q==w.ELEMENT_NODE?m.nodeName():s;if(r&&m.attr("_ke_bookmark")){m=
m._4e_nextSourceNode(u);continue}if(!r||i[r]&&(m._4e_position(g)|z.POSITION_PRECEDING|z.POSITION_IDENTICAL|z.POSITION_IS_CONTAINED)==z.POSITION_PRECEDING+z.POSITION_IDENTICAL+z.POSITION_IS_CONTAINED&&(!d.childRule||d.childRule(m))){var o=m.parent();if(o&&"a"==e&&o.nodeName()==e)q=c(this,b,void 0),o._4e_moveChildren(q),o[0].parentNode.replaceChild(q[0],o[0]),q._4e_mergeSiblings();else if(o&&o[0]&&((F[o.nodeName()]||F.span)[e]||f)&&(!d.parentRule||d.parentRule(o))){if(!h&&(!r||!F.$removeEmpty[r]||(m._4e_position(g)|
z.POSITION_PRECEDING|z.POSITION_IDENTICAL|z.POSITION_IS_CONTAINED)==z.POSITION_PRECEDING+z.POSITION_IDENTICAL+z.POSITION_IS_CONTAINED))h=new E(b),h.setStartBefore(m);if(q==w.TEXT_NODE||q==w.ELEMENT_NODE&&!m[0].childNodes.length){o=m;for(q=null;(n=!o.next(k,1))&&(q=o.parent())&&i[q.nodeName()]&&(q._4e_position(l)|z.POSITION_FOLLOWING|z.POSITION_IDENTICAL|z.POSITION_IS_CONTAINED)==z.POSITION_FOLLOWING+z.POSITION_IDENTICAL+z.POSITION_IS_CONTAINED&&(!d.childRule||d.childRule(q));)o=q;h.setEndAfter(o)}}else n=
u}else n=u;m=m._4e_nextSourceNode()}if(n&&h&&!h.collapsed){for(var n=c(this,b,void 0),o=h.getCommonAncestor(),q={},r={},p,v=null,t;n&&o&&n[0]&&o[0];){if(o.nodeName()==e){for(p in d.attributes)if(d.attributes.hasOwnProperty(p)&&!r[p]&&(t=o.attr(v)))n.attr(p)==t?n.removeAttr(p):r[p]=1;for(v in d.styles)if(d.styles.hasOwnProperty(v)&&!q[v]&&(t=o.style(v)))n.style(v)==t?n.style(v,""):q[v]=1;if(!n._4e_hasAttributes()){n=s;break}}o=o.parent()}n?(n[0].appendChild(h.extractContents()),x(this,n),h.insertNode(n),
n._4e_mergeSiblings(),G.ie||n[0].normalize()):(n=new D(b.createElement("span")),n[0].appendChild(h.extractContents()),h.insertNode(n),x(this,n),n._4e_remove(!0));h=s}}l._4e_remove();g._4e_remove();a.moveToBookmark(j);a.shrink(B.SHRINK_TEXT)}}function r(a){a.enlarge(B.ENLARGE_ELEMENT);var b=a.createBookmark(),c=b.startNode;if(a.collapsed){for(var e=new H(c.parent()),d,f=0,g;f<e.elements.length&&(g=e.elements[f])&&!(g==e.block||g==e.blockLimit);f++)if(this.checkElementRemovable(g)){var j=a.checkBoundaryOfElement(g,
B.END),l=!j&&a.checkBoundaryOfElement(g,B.START);l||j?(d=g,d.match=l?"start":"end"):(g._4e_mergeSiblings(),g.nodeName()!=this.element?(j=i(this),t(g,j[g.nodeName()]||j["*"])):n(this,g))}if(d){g=c;for(f=0;;f++){j=e.elements[f];if(w.equals(j,d))break;else if(j.match)continue;else j=j.clone();j[0].appendChild(g[0]);g=j}g["start"==d.match?"insertBefore":"insertAfter"](d)}}else{var m=b.endNode,h=this,e=function(){for(var a=new H(c.parent()),b=new H(m.parent()),e=s,d=s,f=0;f<a.elements.length;f++){var i=
a.elements[f];if(i==a.block||i==a.blockLimit)break;h.checkElementRemovable(i)&&(e=i)}for(f=0;f<b.elements.length;f++){i=b.elements[f];if(i==b.block||i==b.blockLimit)break;h.checkElementRemovable(i)&&(d=i)}d&&m._4e_breakParent(d);e&&c._4e_breakParent(e)};e();for(d=new D(c[0].nextSibling);d[0]!==m[0];){f=d._4e_nextSourceNode();if(d[0]&&d[0].nodeType==w.ELEMENT_NODE&&this.checkElementRemovable(d)&&(d.nodeName()==this.element?n(this,d):(g=i(this),t(d,g[d.nodeName()]||g["*"])),f[0].nodeType==w.ELEMENT_NODE&&
f.contains(c)))e(),f=new D(c[0].nextSibling);d=f}}a.moveToBookmark(b)}function p(a){var b={};(""+a).replace(/&quot;/g,'"').replace(/\s*([^ :;]+)\s*:\s*([^;]+)\s*(?=;|$)/g,function(a,c,e){b[c]=e});return b}function o(a,b){var c="";b!==y?(c=document.createElement("span"),c.style.cssText=a,c=c.style.cssText||""):c=a;return c.replace(/\s*([;:])\s*/,"$1").replace(/([^\s;])$/,"$1;").replace(/,\s+/g,",").toLowerCase()}function i(a){if(a._.overrides)return a._.overrides;var b=a._.overrides={},c=a._.definition.overrides;
if(c){d.isArray(c)||(c=[c]);for(var e=0;e<c.length;e++){var f=c[e],i,g,j;"string"==typeof f?i=f.toLowerCase():(i=f.element?f.element.toLowerCase():a.element,g=f.attributes,j=f.styles);f=b[i]||(b[i]={});if(g){i=f.attributes=f.attributes||[];for(var l in g)g.hasOwnProperty(l)&&i.push([l.toLowerCase(),g[l]])}if(j){var f=f.styles=f.styles||[],m;for(m in j)j.hasOwnProperty(m)&&f.push([m.toLowerCase(),j[m]])}}}return b}function n(a,b){var c=a._.definition,e=i(a),f=d.merge(c.attributes,(e[b.nodeName()]||
e["*"]||{}).attributes),c=d.merge(c.styles,(e[b.nodeName()]||e["*"]||{}).styles),e=d.isEmptyObject(f)&&d.isEmptyObject(c),g;for(g in f)if(f.hasOwnProperty(g)&&!(("class"==g||a._.definition.fullMatch)&&b.attr(g)!=v(g,f[g])))e=e||!!b.hasAttr(g),b.removeAttr(g);for(var j in c)c.hasOwnProperty(j)&&!(a._.definition.fullMatch&&b.style(j)!=v(j,c[j],u))&&(e=e||!!b.style(j),b.style(j,""));q(b)}function v(a,b,c){var e=new D("<span>");e[c?"style":"attr"](a,b);return e[c?"style":"attr"](a)}function x(a,b){for(var c=
i(a),e=b.all(a.element),d=e.length;0<=--d;)n(a,new D(e[d]));for(var f in c)if(c.hasOwnProperty(f)&&f!=a.element){e=b.all(f);for(d=e.length-1;0<=d;d--){var g=new D(e[d]);t(g,c[f])}}}function t(a,b){var c,e=b&&b.attributes;if(e)for(c=0;c<e.length;c++){var d=e[c][0],f;if(f=a.attr(d)){var i=e[c][1];(i===s||i.test&&i.test(f)||"string"==typeof i&&f==i)&&a[0].removeAttribute(d)}}if(e=b&&b.styles)for(c=0;c<e.length;c++)if(d=e[c][0],i=a.css(d)){var g=e[c][1];(g===s||g.test&&g.test(f)||"string"==typeof g&&
i==g)&&a.css(d,"")}q(a)}function q(a){if(!a._4e_hasAttributes()){var b=a[0].firstChild,c=a[0].lastChild;a._4e_remove(u);b&&(b.nodeType==w.ELEMENT_NODE&&w._4e_mergeSiblings(b),c&&b!=c&&c.nodeType==w.ELEMENT_NODE&&w._4e_mergeSiblings(c))}}var u=!0,y=!1,s=null,w=d.DOM,A={STYLE_BLOCK:1,STYLE_INLINE:2,STYLE_OBJECT:3},B=g.RANGE,C=g.Selection,z=g.POSITION,E=g.Range,D=d.Node,G=d.UA,H=g.ElementPath,K={address:1,div:1,h1:1,h2:1,h3:1,h4:1,h5:1,h6:1,p:1,pre:1},F=g.XHTML_DTD,I={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},J=/\s*(?:;\s*|$)/g,L=/#\((.+?)\)/g;g.STYLE=A;f.prototype={apply:function(b){a.call(this,b,y)},remove:function(b){a.call(this,b,u)},applyToRange:function(a){return(this.applyToRange=this.type==A.STYLE_INLINE?j:this.type==A.STYLE_BLOCK?e:s).call(this,a)},removeFromRange:function(a){return(this.removeFromRange=this.type==A.STYLE_INLINE?r:s).call(this,a)},checkElementRemovable:function(a,b){if(!a)return y;var c=this._.definition,e;if(a.nodeName()==
this.element){if(!b&&!a._4e_hasAttributes())return u;var d=c._AC;if(d)c=d;else{var d={},g=0,j=c.attributes;if(j)for(var l in j)j.hasOwnProperty(l)&&(g++,d[l]=j[l]);if(j=f.getStyleText(c))d.style||g++,d.style=j;d._length=g;c=c._AC=d}if(c._length){for(var m in c)if("_length"!=m&&c.hasOwnProperty(m)){g=a.attr(m)||"";if("style"==m)a:{d=c[m];g=o(g,y);"string"==typeof d&&(d=p(d));"string"==typeof g&&(g=p(g));j=void 0;for(j in d)if(d.hasOwnProperty(j)&&!(j in g&&(g[j]==d[j]||"inherit"==d[j]||"inherit"==
g[j]))){d=y;break a}d=u}else d=c[m]==g;if(d){if(!b)return u}else if(b)return y}if(b)return u}else return u}m=i(this);if(m=m[a.nodeName()]||m["*"]){if(!(c=m.attributes)&&!(e=m.styles))return u;if(c)for(d=0;d<c.length;d++)if(m=c[d][0],m=a.attr(m))if(g=c[d][1],g===s||"string"==typeof g&&m==g||g.test&&g.test(m))return u;if(e)for(d=0;d<e.length;d++)if(m=a.css(e[d][0]))if(c=e[d][1],c===s||"string"==typeof c&&m==c||c.test&&c.test(m))return u}return y},checkActive:function(a){switch(this.type){case A.STYLE_BLOCK:return this.checkElementRemovable(a.block||
a.blockLimit,u);case A.STYLE_OBJECT:case A.STYLE_INLINE:for(var b=a.elements,c=0,e;c<b.length;c++)if(e=b[c],!(this.type==A.STYLE_INLINE&&(w.equals(e,a.block)||w.equals(e,a.blockLimit))))if((this.type!=A.STYLE_OBJECT||e.nodeName()in I)&&this.checkElementRemovable(e,u))return u}return y}};f.getStyleText=function(a){var b=a._ST;if(b)return b;var b=a.styles,c=a.attributes&&a.attributes.style||"",e="";c.length&&(c=c.replace(J,";"));for(var d in b)if(b.hasOwnProperty(d)){var f=b[d],i=(d+":"+f).replace(J,
";");"inherit"==f?e+=i:c+=i}c.length&&(c=o(c));return a._ST=c+e};return g.Style=f},{requires:["./base","./range","./selection","./domIterator","./elementPath"]});
KISSY.add("editor/core/utils",function(d){var g=d.Node,k=d.DOM,h=d.UA,f={debugUrl:function(a){var c=d.Config;c.debug||(a=a.replace(/\.(js|css)/i,"-min.$1"));-1==a.indexOf("?t")&&(a=-1!=a.indexOf("?")?a+"&":a+"?",a+="t="+encodeURIComponent(c.tag));return c.base+"editor/"+a},lazyRun:function(a,c,e){var b=a[c],d=a[e];a[c]=function(){b.apply(this,arguments);a[c]=a[e];return d.apply(this,arguments)}},getXY:function(a,c){var e=a.left,b=a.top,d=c.get("window")[0],e=e-k.scrollLeft(d),b=b-k.scrollTop(d),d=
c.get("iframe").offset(),e=e+d.left,b=b+d.top;return{left:e,top:b}},tryThese:function(a){for(var c,e=0,b=arguments.length;e<b;e++){var d=arguments[e];try{c=d();break}catch(f){}}return c},arrayCompare:function(a,c){if(!a&&!c)return!0;if(!a||!c||a.length!=c.length)return!1;for(var e=0;e<a.length;e++)if(a[e]!==c[e])return!1;return!0},clearAllMarkers:function(a){for(var c in a)a.hasOwnProperty(c)&&a[c]._4e_clearMarkers(a,!0,void 0)},ltrim:function(a){return a.replace(/^\s+/,"")},rtrim:function(a){return a.replace(/\s+$/,
"")},isNumber:function(a){return/^\d+(.\d+)?$/.test(d.trim(a))},verifyInputs:function(a){for(var c=0;c<a.length;c++){var e=new g(a[c]),b=d.trim(f.valInput(e)),m=e.attr("data-verify"),e=e.attr("data-warning");if(m&&!RegExp(m).test(b))return alert(e),!1}return!0},sourceDisable:function(a,c){a.on("sourceMode",c.disable,c);a.on("wysiwygMode",c.enable,c)},resetInput:function(a){var c=a.attr("placeholder");c&&h.ie?(a.addClass("ks-editor-input-tip"),a.val(c)):h.ie||a.val("")},valInput:function(a,c){if(void 0===
c)return a.hasClass("ks-editor-input-tip")?"":a.val();a.removeClass("ks-editor-input-tip");a.val(c)},placeholder:function(a,c){a.attr("placeholder",c);h.ie&&(a.on("blur",function(){d.trim(a.val())||(a.addClass("ks-editor-input-tip"),a.val(c))}),a.on("focus",function(){a.removeClass("ks-editor-input-tip");d.trim(a.val())==c&&a.val("")}))},htmlEncode:function(a){return!a?a:(""+a).replace(/&/g,"&amp;").replace(/>/g,"&gt;").replace(/</g,"&lt;").replace(/"/g,"&quot;")},normParams:function(a){var a=d.clone(a),
c;for(c in a)if(a.hasOwnProperty(c)){var e=a[c];d.isFunction(e)&&(a[c]=e())}return a},map:function(a,c){for(var e=0;e<a.length;e++)a[e]=c(a[e]);return a},ieEngine:document.documentMode||h.ie,preventFocus:function(a){h.ie?a.unselectable(void 0):a.attr("onmousedown","return false;")},injectDom:function(a){d.mix(k,a);for(var c in a)a.hasOwnProperty(c)&&function(c){g.prototype[c]=function(){var b=[].slice.call(arguments,0);b.unshift(this[0]);return(b=a[c].apply(null,b))&&(b.nodeType||d.isWindow(b))?new g(b):
d.isArray(b)&&(b.__IS_NODELIST||b[0]&&b[0].nodeType)?new g(b):b}}(c)},addRes:function(){var a=this.__res=this.__res||[];a.push.apply(a,d.makeArray(arguments))},destroyRes:function(){for(var a=this.__res||[],c=0;c<a.length;c++){var e=a[c];d.isFunction(e)?e():e.destroy?e.destroy():e.remove&&e.remove()}this.__res=[]},getQueryCmd:function(a){return"query"+("-"+a).replace(/-(\w)/g,function(a,e){return e.toUpperCase()})+"Value"}};return d.Editor.Utils=f},{requires:["./base"]});
KISSY.add("editor/core/walker",function(d,g){function k(b,d){if(this._.end)return e;var f,i=this.range,g,l=this.guard,h=this.type,k=b?"_4e_previousSourceNode":"_4e_nextSourceNode";if(!this._.start&&(this._.start=1,i.trim(),i.collapsed))return this.end(),e;if(!b&&!this._.guardLTR){var r=i.endContainer[0],o=r.childNodes[i.endOffset];this._.guardLTR=function(a,b){return b&&(r==a||"body"==m.nodeName(a))?!1:a!=o}}if(b&&!this._.guardRTL){var p=i.startContainer[0],C=0<i.startOffset&&p.childNodes[i.startOffset-
1]||null;this._.guardRTL=function(a,b){return b&&(p==a||"body"==m.nodeName(a))?!1:a!=C}}var z=b?this._.guardRTL:this._.guardLTR;g=l?function(a,b){return z(a,b)===c?c:l(a,b)}:z;this.current?f=this.current[k](c,h,g):b?(f=i.endContainer,0<i.endOffset?(f=new j(f[0].childNodes[i.endOffset-1]),g(f[0])===c&&(f=e)):f=g(f,a)===c?e:f._4e_previousSourceNode(a,h,g,void 0)):(f=i.startContainer,f=new j(f[0].childNodes[i.startOffset]),f.length?g(f[0])===c&&(f=e):f=g(i.startContainer,a)===c?e:i.startContainer._4e_nextSourceNode(a,
h,g,void 0));for(;f&&!this._.end;){this.current=f;if(!this.evaluator||this.evaluator(f[0])!==c){if(!d)return f}else if(d&&this.evaluator)return c;f=f[k](c,h,g)}this.end();return this.current=e}function h(a){for(var b,c=e;b=k.call(this,a);)c=b;return c}function f(a){this.range=a;this.guard=this.evaluator=e;this._={}}var a=!0,c=!1,e=null,b=d.UA,m=d.DOM,l=g.XHTML_DTD,j=d.Node;d.augment(f,{end:function(){this._.end=1},next:function(){return k.call(this)},previous:function(){return k.call(this,a)},checkForward:function(){return k.call(this,
c,a)!==c},checkBackward:function(){return k.call(this,a,a)!==c},lastForward:function(){return h.call(this)},lastBackward:function(){return h.call(this,a)},reset:function(){delete this.current;this._={}},_iterator:k});d.mix(f,{blockBoundary:function(a){return function(b){return!(b.nodeType==m.ELEMENT_NODE&&m._4e_isBlockBoundary(b,a))}},bookmark:function(a,b){function c(a){return"span"==m.nodeName(a)&&m.attr(a,"_ke_bookmark")}return function(e){var d,f;d=e.nodeType==m.TEXT_NODE&&(f=e.parentNode)&&c(f);
d=a?d:d||c(e);return!!(b^d)}},whitespaces:function(a){return function(b){b=b.nodeType==m.TEXT_NODE&&!d.trim(b.nodeValue);return!!(a^b)}},invisible:function(a){var b=f.whitespaces();return function(c){c=b(c)||c.nodeType==m.ELEMENT_NODE&&!c.offsetHeight;return!!(a^c)}}});var r=/^[\t\r\n ]*(?:&nbsp;|\xa0)$/,p=f.whitespaces(),o=f.bookmark(),i=function(a){var b=m.nodeName(a);return o(a)||p(a)||1==a.nodeType&&b in l.$inline&&!(b in l.$empty)};g.Utils.injectDom({_4e_getBogus:function(a){a=new j(a);do a=
a._4e_previousSourceNode();while(a&&i(a[0]));return a&&(!b.ie?"br"==a.nodeName():3==a[0].nodeType&&r.test(a.text()))?a[0]:!1}});return g.Walker=f},{requires:["./base","./utils","./dom"]});KISSY.add("editor/core/zIndexManager",function(d){var g=d.Editor,d=g.zIndexManager={BUBBLE_VIEW:1100,POPUP_MENU:1200,STORE_FLASH_SHOW:99999,MAXIMIZE:900,OVERLAY:9999,LOADING:11E3,LOADING_CANCEL:12E3,SELECT:1200};g.baseZIndex=function(d){return(g.Config.baseZIndex||1E4)+d};return d},{requires:["./base"]});
KISSY.add("editor",function(d,g,k,h,f,a,c,e,b,m,l){function j(a,b){var c=a.body;B(function(){a.designMode="on";setTimeout(function(){a.designMode="off";c.focus();arguments.callee.retry||(arguments.callee.retry=n)},50)},function(){a.designMode="off";s.attr(c,"contentEditable",t);s.attr(c,"contentEditable",n);!b&&j(a,1)})}function r(a){a.get("iframe");var b=a.get("textarea")[0],c=a.get("window")[0],e=a.get("document")[0];u.webkit&&(A.on(e,"click",function(a){var b=new w(a.target);d.inArray(b.nodeName(),
["input","select"])&&a.preventDefault()}),A.on(e,"mouseup",function(a){var b=new w(a.target);d.inArray(b.nodeName(),["input","textarea"])&&a.preventDefault()}));if(u.gecko||y||u.opera){var f;f=(new w('<span tabindex="-1" style="position:absolute; left:-10000" role="presentation"></span>')).insertAfter(b);f.on("focus",function(){a.focus()});a.activateGecko=function(){u.gecko&&a.__iframeFocus&&f[0].focus()};a.on("destroy",function(){f.detach();f.remove()})}A.on(c,"focus",function(){u.gecko?j(e,t):u.opera&&
e.body.focus();a.notifySelectionChange()});if(u.gecko)A.on(e,"mousedown",function(){a.__iframeFocus||j(e,t)});if(y&&(A.on(e,"keydown",function(b){if(b.keyCode in{8:1,46:1}){var c=a.getSelection(),e=c.getSelectedElement();if(e){a.execCommand("save");var d=c.getRanges()[0].createBookmark();e.remove();c.selectBookmarks([d]);a.execCommand("save");b.preventDefault()}}}),"CSS1Compat"==e.compatMode)){var i={33:1,34:1};A.on(e,"keydown",function(b){b.keyCode in i&&setTimeout(function(){a.getSelection().scrollIntoView()},
0)})}if(u.webkit)A.on(e,"mousedown",function(b){b=new w(b.target);d.inArray(b.nodeName(),["img","hr","input","textarea","select"])&&a.getSelection().selectElement(b)});if(u.gecko)A.on(e,"dragstart",function(a){var b=new w(a.target);b.nodeName()==="img"&&/ke_/.test(b[0].className)&&a.preventDefault()});h.add(a)}function p(a,b,c,e){var f="",i,g=k.debugUrl("theme/editor-iframe.css");for(i=0;i<c.length;i++)f+=d.substitute('<link href="{href}" rel="stylesheet" />',{href:c[i]});return d.substitute(C,{doctype:8===
q.documentMode?'<meta http-equiv="X-UA-Compatible" content="IE=7" />':"",title:"${title}",href:g,style:b,data:e||"&nbsp;",script:a?'<script id="ke_active_script">'+(s.isCustomDomain()?'document.domain="'+q.domain+'";':"")+'parent.KISSY.Editor._initIFrame("'+a+'");<\/script>':""})}function o(a,b){function c(){g=i.document;a.__set("document",new w(g));a.__set("window",new w(i));e.detach();g.open("text/html","replace");g.write(d);g.close()}var e=a.get("iframe"),d=p(a._UUID,a.get("customStyle"),a.get("customLink"),
b),f=e[0],i=f.contentWindow,g;e.__loaded=1;try{g=i.document}catch(j){if(f.src=f.src,7>y){setTimeout(c,10);return}}c()}function i(a,b){var c=s.getEmptyIframeSrc()||"";c&&(c=' src="'+c+'" ');var c=new w(d.substitute(z,{iframeSrc:c})),e=a.get("textarea");e.hasAttr("tabindex")&&c.attr("tabIndex",u.webkit?-1:e.attr("tabIndex"));e.parent().prepend(c);a.set("iframe",c);a.__docReady=0;if(u.gecko&&!c.__loaded)c.on("load",function(){o(a,b)},a);else o(a,b)}var n=!0,v=v,x=d.all,t=!1,q=document,u=d.UA,y=u.ie,
s=d.DOM,w=d.Node,A=d.Event,B=k.tryThese,C="<!doctype html><html><head>{doctype}<title>{title}</title><link href='{href}' rel='stylesheet' /><style>{style}</style>{links}</head><body class='ks-editor'>{data}{script}</body></html>",z='<iframe style="width:100%;height:100%;border:none;"  frameborder="0"  title="kissy-editor"  allowTransparency="true"  {iframeSrc} ></iframe>';d.mix(g,{SOURCE_MODE:0,WYSIWYG_MODE:1});var E=g.WYSIWYG_MODE;d.augment(g,{createDom:function(){var a,b=this.get("textarea"),c;
b||this.set("textarea",b=x("<textarea class='ks-editor-textarea'></textarea>"));c=this.get("el");c.html('<div class="ks-editor-tools"></div><div class="ks-editor-textarea-wrap"></div><div class=\'ks-editor-status\'></div>');a=c.one(".ks-editor-textarea-wrap");this._UUID=d.guid();this.set({toolBarEl:c.one(".ks-editor-tools"),statusBarEl:c.one(".ks-editor-status")},{silent:1});b.css("width","100%");b.css("display","none");a.append(b);h.register(this)},renderUI:function(){e.init(this);b.init(this);m.init(this);
l.init(this)},bindUI:function(){function a(){b.detach("docReady",a);if(b.get("focused"))b.focus();else{var c=b.getSelection();c&&c.removeAllRanges()}}var b=this,c,e=b.get("prefixCls"),d=b.get("textarea");if(b.get("attachForm")&&(c=d[0].form))s.on(c,"submit",b.sync,b),b.on("destroy",function(){s.detach(c,"submit",b.sync,b)});b.on("docReady",a);b.on("blur",function(){b.get("el").removeClass(e+"editor-focused")});b.on("focus",function(){b.get("el").addClass(e+"editor-focused")})},_uiSetHeight:function(a){var b=
this.get("textarea"),c=this.get("toolBarEl"),e=this.get("statusBarEl"),a=parseInt(a,10),a=a-((c&&c.outerHeight()||0)+(e&&e.outerHeight()||0));b.parent().css("height",a);b.css("height",a)},_uiSetMode:function(a){var b=this,c,e=b.get("rendered"),d=b.get("iframe"),f=b.get("textarea");a==E?(e&&b.execCommand("save"),b.on("docReady",c=function(){e&&b.execCommand("save");b.detach("docReady",c)}),b._setData(f.val()),b.fire("wysiwygMode")):(f.val(b._getData(1,E)),f.show(),d.hide(),b.fire("sourceMode"))},_uiSetFocused:function(a){a&&
this.__docReady&&this.focus()},destructor:function(){var a=this.get("document")[0],b=this.get("window");this.sync();h.remove(this);A.remove([a,a.documentElement,a.body,b[0]]);d.each(this.__controls,function(a){a.destroy&&a.destroy()});this.__commands={};this.__controls={}},getControl:function(a){return this.__controls[a]},getControls:function(){return this.__controls},addControl:function(a,b){this.__controls[a]=b},showDialog:function(a,b){var a=a+"/dialog",c=this.__controls[a];c.show(b);this.fire("dialogShow",
{dialog:c.dialog,pluginDialog:c,dialogName:a})},addCommand:function(a,b){this.__commands[a]=b},hasCommand:function(a){return this.__commands[a]},execCommand:function(a){var b=this.__commands[a],c=d.makeArray(arguments);c.shift();c.unshift(this);if(b)return b.exec.apply(b,c)},queryCommandValue:function(a){return this.execCommand(k.getQueryCmd(a))},_getData:function(a,b){var c=this.htmlDataProcessor,e;b==v&&(b=this.get("mode"));e=b==E?this.get("document")[0].body.innerHTML:c.toDataFormat(this.get("textarea").val());
e=a?c.toHtml(e):c.toServer(e);e=d.trim(e);/^(?:<(p)>)?(?:(?:&nbsp;)|\s)*(?:<\/\1>)?$/.test(e)&&(e="");return e},_setData:function(a){var b,c=a;if(this.get("mode")!=E)this.get("textarea").val(a);else{if(b=this.htmlDataProcessor)c=b.toDataFormat(a);if(this.get("iframe")){a=this.get("iframe");b=this.get("window")[0];var e=this.get("document")[0];A.remove([e,e.documentElement,e.body,b]);a.remove()}i(this,c)}},sync:function(){this.get("textarea").val(this.get("data"))},getDocHtml:function(){return p(0,
this.get("customStyle"),this.get("customLink"),this.get("formatData"))},getSelection:function(){return g.Selection.getSelection(this.get("document")[0])},focus:function(){var a=this.get("document")[0],b=this.get("window")[0];u.ie||b&&b.parent&&b.parent.focus();b&&b.focus();try{a.body.focus()}catch(c){}this.notifySelectionChange()},blur:function(){this.get("window")[0].blur();this.get("document")[0].body.blur()},addCustomStyle:function(a,b){var c=this.get("customStyle")||"",c=c+("\n"+a);this.set("customStyle",
c);s.addStyleSheet(this.get("window"),c,b)},removeCustomStyle:function(a){s.remove(s.get("#"+a,this.get("window")[0]))},addCustomLink:function(a){var b=this.get("customLink")||[],c=this.get("document")[0];b.push(a);this.set("customLink",b);b=c.createElement("link");b.rel="stylesheet";c.getElementsByTagName("head")[0].appendChild(b);b.href=a},removeCustomLink:function(a){for(var b=this.get("document")[0],b=s.query("link",b),c=0;c<b.length;c++)s.attr(b[c],"href")==a&&s.remove(b[c]);b=this.get("customLink")||
[];a=d.indexOf(a,b);-1!=a&&b.splice(a,1)},docReady:function(a){this.on("docReady",a);this.__docReady&&a.call(this)},checkSelectionChange:function(){var a=this;a.__checkSelectionChangeId&&clearTimeout(a.__checkSelectionChangeId);a.__checkSelectionChangeId=setTimeout(function(){var b=a.getSelection();if(b&&!b.isInvalid){var c=b.getStartElement(),e=new g.ElementPath(c);if(!a.__previousPath||!a.__previousPath.compare(e))a.__previousPath=e,a.fire("selectionChange",{selection:b,path:e,element:c})}},100)},
notifySelectionChange:function(){this.__previousPath=null;this.checkSelectionChange()},insertElement:function(a){if(this.get("mode")===E){this.focus();var b,c=a.nodeName(),e=g.XHTML_DTD,d=e.$block[c],f=g.RANGE,i=(c=this.getSelection())&&c.getRanges(),j,l,m;if(i&&0!=i.length){this.execCommand("save");for(l=i.length-1;0<=l;l--)j=i[l],b=!l&&a||a.clone(n),j.insertNodeByDtd(b),m||(m=b);if(m)return j.moveToPosition(m,f.POSITION_AFTER_END),d&&(a=g.Walker.whitespaces(!0),(a=(m=m.next(a,1))&&m[0].nodeType==
s.ELEMENT_NODE&&m.nodeName())&&e.$block[a]&&e[a]["#text"]&&j.moveToElementEditablePosition(m)),c.selectRanges([j]),this.focus(),b&&1==b[0].nodeType&&b.scrollIntoView(v,!1),D.call(this),b}}},insertHtml:function(a,b){var c=this,e,d=c.get("document")[0];if(c.get("mode")===E){if(e=c.htmlDataProcessor)a=e.toDataFormat(a,b);c.focus();c.execCommand("save");if(y){e=d.selection;"Control"==e.type&&e.clear();try{e.createRange().pasteHTML(a)}catch(f){}}else try{d.execCommand("inserthtml",t,a)}catch(i){setTimeout(function(){if(0==
c.getSelection().getRanges().length){var b=new g.Range(d),e=s.first(d.body,function(a){return 1==a.nodeType&&"br"!=s.nodeName(a)});e||(e=new w(d.createElement("p")),e._4e_appendBogus(v),d.body.appendChild(e[0]));b.setStartAt(e,g.RANGE.POSITION_AFTER_START);b.select()}d.execCommand("inserthtml",t,a)},50)}setTimeout(function(){c.getSelection().scrollIntoView()},50);D.call(c)}}});g._initIFrame=function(a){var b=h.getInstance(a),c=b.get("document")[0],a=c.getElementById("ke_active_script");s.remove(a);
r(b);var e=c.body;y?(e.hideFocus=n,e.disabled=n,e.contentEditable=n,e.removeAttribute("disabled")):setTimeout(function(){u.gecko||u.opera?e.contentEditable=n:u.webkit?e.parentNode.contentEditable=n:c.designMode="on"},0);if(u.gecko||u.opera){var d=c.documentElement;A.on(d,"mousedown",function(a){if(a.target==d){u.gecko&&j(c,t);b.activateGecko()}})}setTimeout(function(){y&&setTimeout(function(){if(c){e.runtimeStyle.marginBottom="0px";e.runtimeStyle.marginBottom=""}},1E3)},0);setTimeout(function(){b.__docReady=
1;b.fire("docReady");var a=b.get("disableObjectResizing"),d=b.get("disableInlineTableEditing");if(a||d)try{c.execCommand("enableObjectResizing",t,!a);c.execCommand("enableInlineTableEditing",t,!d)}catch(f){A.on(e,y?"resizestart":"resize",function(b){var c=new w(b.target);(a||c.nodeName()==="table"&&d)&&b.preventDefault()})}},10)};var D=d.buffer(function(){this.execCommand("save")},50);return g},{requires:"editor/core/base,editor/core/utils,editor/core/focusManager,editor/core/styles,editor/core/zIndexManager,editor/core/meta,editor/core/clipboard,editor/core/enterKey,editor/core/htmlDataProcessor,editor/core/selectionFix".split(",")});
KISSY.add("editor/plugin/backColor/cmd",function(d,g){var k={element:"span",styles:{"background-color":"#(color)"},overrides:[{element:"*",styles:{"background-color":null}}],childRule:function(){return!1}};return{init:function(d){d.hasCommand("backColor")||d.addCommand("backColor",{exec:function(d,a){d.execCommand("save");g.applyColor(d,a,k);d.execCommand("save")}})}}},{requires:["../color/cmd"]});
KISSY.add("editor/plugin/backColor/index",function(d,g,k,h){function f(a){this.config=a||{}}d.augment(f,{renderUI:function(a){h.init(a);a.addButton("backColor",{cmdType:"backColor",tooltip:"\u80cc\u666f\u989c\u8272",pluginConfig:this.config},k)}});return f},{requires:["editor","../color/btn","./cmd"]});
KISSY.add("editor/plugin/bold/cmd",function(d,g,k){var h=new g.Style({element:"strong",overrides:[{element:"b"},{element:"span",attributes:{style:"font-weight: bold;"}}]});return{init:function(d){k.addButtonCmd(d,"bold",h)}}},{requires:["editor","../font/cmd"]});
KISSY.add("editor/plugin/bold/index",function(d,g,k,h){function f(){}d.augment(f,{renderUI:function(a){h.init(a);a.addButton("bold",{cmdType:"bold",tooltip:"\u7c97\u4f53 "},k.Button);a.docReady(function(){a.get("document").on("keydown",function(c){c.ctrlKey&&c.keyCode==d.Node.KeyCodes.B&&(a.execCommand("bold"),c.preventDefault())})})}});return f},{requires:["editor","../font/ui","./cmd"]});
KISSY.add("editor/plugin/bubble/index",function(d,g,k){function h(a){var c=null,e=a.get("editor").getControls();d.each(e,function(e){var d;if(d=e.get)if(d=-1!=(e.get("elCls")||"").indexOf("bubble"))if(d=e!==a)if(d=e.get("visible")){d=a.get("y");var f=d+a.get("el").outerHeight(),g=e.get("y"),i=g+e.get("el").outerHeight();d=d<=i&&f>=i||d<=g&&f>=g}d&&(c?c.get("y")<e.get("y")&&(c=e):c=e);return c})}var f=d.Event,a={}.a,c=d.DOM,e={zIndex:k.baseZIndex(k.zIndexManager.BUBBLE_VIEW),elCls:"ks-editor-bubble",
prefixCls:"ks-editor-",effect:{effect:"fade",duration:0.3}};k.prototype.addBubble=function(b,m,l){function j(){n.hide();var a=i.get("window")[0];f.remove(a,"scroll",p)}function r(){var b;var e=n,d=e.get("editorSelectedEl");if(d){var f=e.get("editor"),i=f.get("window")[0],g=f.get("iframe").offset(),e=g.top,g=g.left,j=g+c.width(i),i=e+c.height(i),l=d.offset(),l=k.Utils.getXY(l,f),f=l.top,l=l.left,m=l+d.width(),d=f+d.height(),r;d>i&&f<i?r=i-30:d>e&&d<i&&(r=d);m>g&&l<g?b=g:l>g&&l<j&&(b=l);b=b!==a&&r!==
a?[b,r]:a}else b=a;if(b){n.set("xy",b);if(r=h(n))b[1]=r.get("y")+r.get("el").outerHeight(),n.set("xy",b);n.get("visible")||n.show()}}function p(){n.get("editorSelectedEl")&&(n.get("el"),n.hide(),v())}function o(){var a=i.get("window")[0];f.on(a,"scroll",p);r()}var i=this,n,l=l||{};l.editor=i;d.mix(l,e);n=new g(l);i.addControl(b+"/bubble",n);i.on("selectionChange",function(a){var a=a.path,b=a.elements;if(a&&b&&(a=a.lastElement))(a=m(a))?(n.set("editorSelectedEl",a),n.hide(),d.later(o,10)):j()});i.on("sourceMode",
j);var v=d.buffer(r,350)}},{requires:["overlay","editor"]});
KISSY.add("editor/plugin/button/index",function(d,g,k){g.prototype.addButton=function(h,f,a){void 0===a&&(a=k);var c=this.get("prefixCls")+"editor-",e=new a(d.mix({render:this.get("toolBarEl"),elAttrs:{hideFocus:"hideFocus"},autoRender:!0,content:'<span class="'+c+"toolbar-item "+c+"toolbar-"+h+'"></span>',elCls:c+"toolbar-button",prefixCls:c,editor:this},f)),b=e.get("el").one("span");e.get("el").unselectable();e.on("afterContentClsChange",function(a){b[0].className=c+"toolbar-item "+c+"toolbar-"+
a.newVal});e.get("mode")==g.WYSIWYG_MODE&&(this.on("wysiwygMode",function(){e.set("disabled",!1)}),this.on("sourceMode",function(){e.set("disabled",!0)}));this.addControl(h+"/button",e);return e};return k},{requires:["editor","button"]});
KISSY.add("editor/plugin/checkboxSourcearea/index",function(d,g){function k(a){this.editor=a;this._init()}function h(){}var f=d.Node,a=g.SOURCE_MODE,c=g.WYSIWYG_MODE;d.augment(k,{_init:function(){var a=this.editor,b=a.get("statusBarEl");this.holder=(new f("<span style='zoom:1;display:inline-block;height:22px;line-height:22px;'><input style='margin:0 5px;vertical-align:middle;' type='checkbox' /><span style='vertical-align:middle;'>\u7f16\u8f91\u6e90\u4ee3\u7801</span></span>")).appendTo(b);(this.el=this.holder.one("input")).on("click",
this._check,this);a.on("wysiwygMode",this._wysiwygmode,this);a.on("sourceMode",this._sourcemode,this)},_sourcemode:function(){this.el.attr("checked",!0)},_wysiwygmode:function(){this.el.attr("checked",!1)},_check:function(){var e=this.editor;this.el.attr("checked")?e.set("mode",a):e.set("mode",c)},destroy:function(){this.holder.remove()}});d.augment(h,{renderUI:function(a){var b=new k(a);a.on("destroy",function(){b.destroy()})}});return h},{requires:["editor"]});
KISSY.add("editor/plugin/color/btn",function(d,g,k,h,f){var a=d.Node;d.DOM.addStyleSheet(window,".ks-editor-color-panel a {display: block;color:black;text-decoration: none;}.ks-editor-color-panel a:hover {color:black;text-decoration: none;}.ks-editor-color-panel a:active {color:black;}.ks-editor-color-palette {    margin: 5px 8px 8px;}.ks-editor-color-palette table {    border: 1px solid #666666;    border-collapse: collapse;}.ks-editor-color-palette td {    border-right: 1px solid #666666;    height: 18px;    width: 18px;}a.ks-editor-color-a {    height: 18px;    width: 18px;}a.ks-editor-color-a:hover {    border: 1px solid #ffffff;    height: 16px;    width: 16px;}a.ks-editor-color-remove {  padding:3px 8px;  margin:2px 0 3px 0;}a.ks-editor-color-remove:hover {    background-color: #D6E9F8;}",
"ks-editor-color-plugin");var c=["000,444,666,999,CCC,EEE,F3F3F3,FFF".split(","),"F00,F90,FF0,0F0,0FF,00F,90F,F0F".split(","),"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".split(",")],e;(function(){e="<div class='ks-editor-color-panel'><a class='ks-editor-color-remove' href=\"javascript:void('\u6e05\u9664');\">\u6e05\u9664</a>";
for(var a=0;3>a;a++){e+="<div class='ks-editor-color-palette'><table>";for(var d=c[a],f=d.length/8,g=0;g<f;g++){e+="<tr>";for(var h=0;8>h;h++){var k="#"+d[8*g+h];e+="<td>";e+="<a href='javascript:void(0);' class='ks-editor-color-a' style='background-color:"+k+"'></a>";e+="</td>"}e+="</tr>"}e+="</table></div>"}e+="<div><a class='ks-editor-button ks-editor-color-others ks-inline-block'>\u5176\u4ed6\u989c\u8272</a></div></div>"})();return k.extend({initializer:function(){var a=this;a.on("blur",function(){setTimeout(function(){a.colorWin&&
a.colorWin.hide()},150)});a.on("click",function(){a.get("checked")?a._prepare():a.colorWin&&a.colorWin.hide()})},_prepare:function(){var a=this,c=a.get("editor"),d;a.colorWin=new h({elAttrs:{tabindex:0},elCls:"ks-editor-popup",content:e,autoRender:!0,width:170,zIndex:g.baseZIndex(g.zIndexManager.POPUP_MENU)});var j=a.colorWin;d=j.get("contentEl");d.on("click",a._selectColor,a);j.on("hide",function(){a.set("checked",!1)});d.one(".ks-editor-color-others").on("click",function(e){e.halt();j.hide();f.useDialog(c,
"color/colorPicker",a.get("pluginConfig"),a.get("cmdType"))});a._prepare=a._show;a._show()},_show:function(){var a=this.get("el"),c=this.colorWin;c.align(a,["bl","tl"],[0,2]);c.show()},_selectColor:function(b){b.halt();b=new a(b.target);b.hasClass("ks-editor-color-a")&&this.get("editor").execCommand(this.get("cmdType"),b.style("background-color"))},destructor:function(){this.colorWin&&this.colorWin.destroy()}},{ATTRS:{checkable:{value:!0},mode:{value:g.WYSIWYG_MODE}}})},{requires:["editor","../button/",
"../overlay/","../dialogLoader/"]});KISSY.add("editor/plugin/color/cmd",function(d,g){return{applyColor:function(d,h,f){var a=d.get("document")[0];d.execCommand("save");h?(new g.Style(f,{color:h})).apply(a):(new g.Style(f,{color:"inherit"})).remove(a);d.execCommand("save")}}},{requires:["editor"]});
KISSY.add("editor/plugin/contextmenu/index",function(d,g,k,h){g.prototype.addContextMenu=function(f,a,c){var e=this,c=c||{};c.prefixCls=e.get("prefixCls")+"editor-";c.editor=e;c.focusable=1;c.zIndex=g.baseZIndex(g.zIndexManager.POPUP_MENU);c.elAttrs={hideFocus:"hideFocus"};c.children&&d.each(c.children,function(a){a.xclass="menuitem"});var b=new k.PopupMenu(c);h.init(b);b.on("afterRenderUI",function(){b.get("el").on("keydown",function(a){a.keyCode==d.Event.KeyCodes.ESC&&b.hide()})});e.docReady(function(){var c=
e.get("document");c.on("mousedown",function(a){1==a.which&&b.hide()});c.delegate("contextmenu",a,function(a){var c=d.all(a.target);a.halt();var f=a.pageX,m=a.pageY;f&&(a=g.Utils.getXY({left:f,top:m},e),f=a.left,m=a.top,setTimeout(function(){b.set("editorSelectedEl",c,{silent:1});b.set("xy",[f,m]);b.show();e.fire("contextmenu",{contextmenu:b});window.focus();document.body.focus();b.get("el")[0].focus()},30))})});e.addControl(f+"/contextmenu",b);return b}},{requires:["editor","menu","../focusFix/"]});
KISSY.add("editor/plugin/dentUtils/cmd",function(d,g,k){function h(a){return a.nodeType==b.ELEMENT_NODE&&"li"==b.nodeName(a)}function f(a,e,d){for(var f=a.startContainer,h=a.endContainer;f&&!f.parent().equals(e);)f=f.parent();for(;h&&!h.parent().equals(e);)h=h.parent();if(f&&h){for(var r=f,f=[],o=!1;!o;)r.equals(h)&&(o=!0),f.push(r),r=r.next();if(!(1>f.length)){var p=e._4e_parents(!0,void 0);p.each(function(a,b){p[b]=a});for(h=0;h<p.length;h++)if(c[p[h].nodeName()]){e=p[h];break}for(var r="indent"==
d?1:-1,h=f[0],o=f[f.length-1],f={},w=k.listToArray(e,f),A=w[o.data("listarray_index")].indent,h=h.data("listarray_index");h<=o.data("listarray_index");h++){w[h].indent+=r;var B=w[h].parent;w[h].parent=new m(B[0].ownerDocument.createElement(B.nodeName()))}for(h=o.data("listarray_index")+1;h<w.length&&w[h].indent>A;h++)w[h].indent+=r;o=k.arrayToList(w,f,null,"p");r=[];if("outdent"==d){var C;if((C=e.parent())&&"li"==C.nodeName())for(var d=o.listNode.childNodes,z,h=d.length-1;0<=h;h--)(z=new m(d[h]))&&
"li"==z.nodeName()&&r.push(z)}o&&(b.insertBefore(o.listNode[0]||o.listNode,e[0]||e),e.remove());if(r&&r.length)for(h=0;h<r.length;h++){for(z=e=r[h];(z=z.next())&&z.nodeName()in c;)l.ie&&!e.first(function(a){return j(a)&&i(a)},1)&&e[0].appendChild(a.document.createTextNode("\u00a0")),e[0].appendChild(z[0]);b.insertAfter(e[0],C[0])}g.Utils.clearAllMarkers(f)}}}function a(a,b){var c=parseInt(a.style(r),10);isNaN(c)&&(c=0);c+=("indent"==b?1:-1)*p;if(0>c)return!1;c=Math.max(c,0);c=Math.ceil(c/p)*p;a.css(r,
c?c+o:"");""===a[0].style.cssText&&a.removeAttr("style");return!0}var c={ol:1,ul:1},e=g.Walker,b=d.DOM,m=d.Node,l=d.UA,j=e.whitespaces(!0),r="margin-left",p=40,o="px",i=e.bookmark(!1,!0);return{checkOutdentActive:function(a){var b=a.blockLimit;return a.contains(c)?!0:(a=a.block||b)&&a.style(r)},addCommand:function(d,i){d.hasCommand(i)||d.addCommand(i,{exec:function(d){d.execCommand("save");var g=d.getSelection(),j=g&&g.getRanges()[0];if(j){for(var l=j.startContainer,m=j.endContainer,k=j.getCommonAncestor();k&&
!(k[0].nodeType==b.ELEMENT_NODE&&c[k.nodeName()]);)k=k.parent();k&&l[0].nodeType==b.ELEMENT_NODE&&l.nodeName()in c&&(l=new e(j),l.evaluator=h,j.startContainer=l.next());k&&m[0].nodeType==b.ELEMENT_NODE&&m.nodeName()in c&&(l=new e(j),l.evaluator=h,j.endContainer=l.previous());m=g.createBookmarks(!0);if(k){for(l=k.first();l&&"li"!=l.nodeName();)l=l.next();var n=j.startContainer;(!(l[0]==n[0]||l.contains(n))||!a(k,i))&&f(j,k,i)}else{j=j.createIterator();j.enforceRealBlocks=!0;for(j.enlargeBr=!0;k=j.getNextParagraph();)a(k,
i)}g.selectBookmarks(m)}d.execCommand("save");d.notifySelectionChange()}})}}},{requires:["editor","../listUtils/"]});
KISSY.add("editor/plugin/dialogLoader/index",function(d,g,k){var h,f={loading:function(){h||(h=new g({x:0,width:6==d.UA.ie?d.DOM.docWidth():"100%",y:0,zIndex:k.baseZIndex(k.zIndexManager.LOADING),prefixCls:"ks-editor-",elCls:"ks-editor-global-loading"}));h.set("height",d.DOM.docHeight());h.show();h.loading()},unloading:function(){h.hide()}};return{useDialog:function(a,c,e,b){a.focus();a.getControl(c+"/dialog")?setTimeout(function(){a.showDialog(c,b)},0):(f.loading(),d.use("editor/plugin/"+c+"/dialog",
function(d,g){f.unloading();a.addControl(c+"/dialog",new g(a,e));a.showDialog(c,b)}))}}},{requires:["overlay","editor"]});
KISSY.add("editor/plugin/draft/index",function(d,g,k,h,f){function a(a,b,c){for(a+="";a.length<b;)a=c+a;return a}function c(b){d.isNumber(b)&&(b=new Date(b));return b instanceof Date?[b.getFullYear(),"-",a(b.getMonth()+1,2,"0"),"-",a(b.getDate(),2,"0")," ",a(b.getHours(),2,"0"),":",a(b.getMinutes(),2,"0"),":",a(b.getSeconds(),2,"0")].join(""):b}function e(a,b){this.editor=a;this.config=b;this._init()}function b(a,b){var c=new e(a,b);a.on("destroy",function(){c.destroy()})}function m(a){this.config=
a||{}}var l=d.Node,j=d.Event,r=d.JSON,p=g.Utils.addRes,o=g.Utils.destroyRes;d.augment(e,{_getSaveKey:function(){var a=this.config;return a.draft&&a.draft.saveKey||"ks-editor-draft-save20110503"},_getDrafts:function(){if(!this.drafts){var a=k.getItem(this._getSaveKey()),b=[];a&&(b=k==window.localStorage?r.parse(decodeURIComponent(a)):a);this.drafts=b}return this.drafts},_init:function(){var a=this,b=a.editor,c=b.get("statusBarEl"),e=this.config;e.draft=e.draft||{};a.draftInterval=e.draft.interval=
e.draft.interval||5;a.draftLimit=e.draft.limit=e.draft.limit||5;c=(new l("<div class='ks-editor-draft'><span class='ks-editor-draft-title'>\u5185\u5bb9\u6b63\u6587\u6bcf"+e.draft.interval+"\u5206\u949f\u81ea\u52a8\u4fdd\u5b58\u4e00\u6b21\u3002</span></div>")).appendTo(c);a.timeTip=(new l("<span class='ks-editor-draft-time'/>")).appendTo(c);var d=(new l("<a href='#' onclick='return false;' class='ks-editor-button ks-editor-draft-save-btn ks-inline-block' style='vertical-align:middle;padding:1px 9px;'><span class='ks-editor-draft-save'></span><span>\u7acb\u5373\u4fdd\u5b58</span></a>")).unselectable().appendTo(c),
h=new f({render:c,collapseOnClick:!0,width:"100px",prefixCls:"ks-editor-",menuCfg:{width:"225px",align:{points:["tr","br"]}},matchElWidth:!1,autoRender:!0,content:"\u6062\u590d\u7f16\u8f91\u5386\u53f2"});a.versions=h;h.on("beforeCollapsedChange",function(b){b.newValue||(h.detach("beforeCollapsedChange",arguments.callee),a.sync())});d.on("click",function(b){a.save(!1);b.halt()});p.call(a,d);b.get("textarea")[0].form&&function(){function c(){a.save(!0)}var e=b.get("textarea")[0].form;j.on(e,"submit",c);p.call(a,function(){j.remove(e,
"submit",c)})}();var m=setInterval(function(){a.save(!0)},6E4*a.draftInterval);p.call(a,function(){clearInterval(m)});h.on("click",a.recover,a);p.call(a,h);a.holder=c;if(e.draft.helpHtml){var k=(new l('<a tabindex="0" hidefocus="hidefocus" class="ks-editor-draft-help" title="\u70b9\u51fb\u67e5\u770b\u5e2e\u52a9" href="javascript:void(\'\u70b9\u51fb\u67e5\u770b\u5e2e\u52a9 \')">\u70b9\u51fb\u67e5\u770b\u5e2e\u52a9</a>')).unselectable().appendTo(c);k.on("click",function(){k[0].focus();a.helpPopup&&a.helpPopup.get("visible")?a.helpPopup.hide():a._prepareHelp()});k.on("blur",function(){a.helpPopup&&
a.helpPopup.hide()});a.helpBtn=k;p.call(a,k);g.Utils.lazyRun(a,"_prepareHelp","_realHelp")}p.call(a,c)},_prepareHelp:function(){var a=new l(this.config.draft.helpHtml||""),b=new l("<div style='height:0;position:absolute;fontSize: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;fontSize: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"});this.helpPopup=new h({content:a,prefixCls:"ks-editor-",autoRender:!0,width:a.width()+"px",zIndex:g.baseZIndex(g.zIndexManager.OVERLAY),mask:!1});this.helpPopup.get("el").css("border","none");this.helpPopup.arrow=b},_realHelp:function(){var a=this.helpPopup,b=this.helpBtn,c=a.arrow;a.show();b=b.offset();a.get("el").offset({left:b.left-a.get("el").width()+17,top:b.top-a.get("el").height()-7});c.offset({left:b.left-2,top:b.top-8})},
disable:function(){this.holder.css("visibility","hidden")},enable:function(){this.holder.css("visibility","")},sync:function(){var a;a=this.draftLimit;var b=this.timeTip,e=this.versions,d=this._getDrafts(),f;d.length>a&&d.splice(0,d.length-a);for(a=0;a<d.length;a++)f=d[a],f=(f.auto?"\u81ea\u52a8":"\u624b\u52a8")+"\u4fdd\u5b58\u4e8e : "+c(f.date),e.addItem({xclass:"menuitem",content:f,value:a});b.html(f);k.setItem(this._getSaveKey(),k==window.localStorage?encodeURIComponent(r.stringify(d)):d)},save:function(a){var b=this._getDrafts(),
c=this.editor.get("formatData");c&&(b[b.length-1]&&c==b[b.length-1].content&&(b.length-=1),this.drafts=b.concat({content:c,date:(new Date).getTime(),auto:a}),this.sync())},recover:function(a){var b=this.editor,e=this._getDrafts(),d=a.target.get("value");confirm("\u786e\u8ba4\u6062\u590d "+c(e[d].date)+" \u7684\u7f16\u8f91\u5386\u53f2\uff1f")&&(b.execCommand("save"),b.set("data",e[d].content),b.execCommand("save"));a.halt()},destroy:function(){o.call(this)}});d.augment(m,{renderUI:function(a){var c=this.config;k.ready?k.ready(function(){b(a,c)}):
b(a,c)}});return m},{requires:["editor","../localStorage/","overlay","../menubutton/"]});
KISSY.add("editor/plugin/dragUpload/index",function(d,g){function k(a){this.config=a||{}}var h=d.Node,f=d.Event,a=g.Utils,c=d.DOM;d.augment(k,{renderUI:function(e){function b(a){a=a.originalEvent.target;"img"==c.nodeName(a)&&a.src.match(/^file:\/\//)&&(n[a.src]=a)}function m(a,b){var c=new window.FileReader;c.onload=function(e){var d=a.name,e=e.target.result,f=new XMLHttpRequest;f.open("POST",o,!0);f.onreadystatechange=function(){if(4==f.readyState){if(200==f.status||304==f.status){if(""!=f.responseText){var a=
window.JSON.parse(f.responseText);b[0].src=a.imgUrl}}else alert("\u670d\u52a1\u5668\u7aef\u51fa\u9519\uff01"),b.remove();f.onreadystatechange=null}};d="\r\n------kissy-editor-yiminghe\r\n"+('Content-Disposition: form-data; name="'+j+'"; filename="'+encodeURIComponent(d)+'"\r\n');d+="Content-Type: "+(a.type||"application/octet-stream")+"\r\n\r\n";d+=e+"\r\n";p=g.Utils.normParams(p);for(var i in p)p.hasOwnProperty(i)&&(d+="------kissy-editor-yiminghe\r\n",d+='Content-Disposition: form-data; name="'+i+'"\r\n\r\n',d+=p[i]+"\r\n");d+="------kissy-editor-yiminghe--";
f.setRequestHeader("Content-Type","multipart/form-data, boundary=----kissy-editor-yiminghe");f.sendAsBinary("Content-Type: multipart/form-data; boundary=----kissy-editor-yiminghe\r\nContent-Length: "+d.length+"\r\n"+d+"\r\n");c.onload=null};c.readAsBinaryString(a)}var l=this.config,j=l.fileInput||"Filedata",k=l.sizeLimit||Number.MAX_VALUE,p=l.serverParams||{},o=l.serverUrl||"",i=RegExp((l.suffix||"png,jpg,jpeg,gif").split(/,/).join("|")+"$","i"),n={},v=!1;e.docReady(function(){var g=e.get("document")[0];
f.on(g,"dragenter",function(){v||(f.on(g,"DOMNodeInserted",b),v=!0)});f.on(g,"drop",function(e){f.remove(g,"DOMNodeInserted",b);v=!1;e.halt();var e=e.originalEvent,j,l;d.isEmptyObject(n)?(l=g.elementFromPoint(e.clientX,e.clientY),j=l.lastChild):(d.each(n,function(a){"img"==c.nodeName(a)&&(j=a.nextSibling,l=a.parentNode,c.remove(a))}),n={});e=e.dataTransfer;e.dropEffect="copy";if(e=e.files)for(var o=0;o<e.length;o++){var p=e[o],w=p.size;if(p.name.match(i)&&!(w/1E3>k)){var w=new h("<img src='"+a.debugUrl("theme/tao-loading.gif")+
"'/>"),A=w[0];l.insertBefore(A,j);var B=c.nodeName(A.parentNode);("head"==B||"html"==B)&&c.insertBefore(A,g.body.firstChild);m(p,w)}}})});window.XMLHttpRequest&&!XMLHttpRequest.prototype.sendAsBinary&&(XMLHttpRequest.prototype.sendAsBinary=function(a,b){for(var c=new (window.BlobBuilder||window.WebKitBlobBuilder),e=a.length,d=new window.Uint8Array(e),f=0;f<e;f++)d[f]=a.charCodeAt(f);c.append(d.buffer);this.send(c.getBlob(b))})}});return k},{requires:["editor"]});
KISSY.add("editor/plugin/elementPath/index",function(d,g){function k(a){this.cfg=a;this._cache=[];this._init()}function h(){}var f=d.Node;d.augment(k,{_init:function(){var a=this.cfg.editor;this.holder=new f("<span>");this.holder.appendTo(a.get("statusBarEl"),void 0);a.on("selectionChange",this._selectionChange,this);g.Utils.sourceDisable(a,this)},disable:function(){this.holder.css("visibility","hidden")},enable:function(){this.holder.css("visibility","")},_selectionChange:function(a){var c=this.cfg.editor,
e=this.holder,a=a.path.elements,b,d;b=this._cache;for(d=0;d<b.length;d++)b[d].remove();this._cache=[];for(d=0;d<a.length;d++){b=a[d];var g=b.attr("_ke_real_element_type")||b.nodeName(),j=new f("<a href='javascript(\""+g+"\")' class='ks-editor-element-path'>"+g+"</a>");this._cache.push(j);(function(a){j.on("click",function(b){b.halt();c.focus();setTimeout(function(){c.getSelection().selectElement(a)},50)})})(b);e.prepend(j)}},destroy:function(){this.holder.remove()}});d.augment(h,{renderUI:function(a){var c=
new k({editor:a});a.on("destroy",function(){c.destroy()})}});return h},{requires:["editor"]});
KISSY.add("editor/plugin/fakeObjects/index",function(d,g){var k=d.Node,h=d.DOM,f=g.Utils.debugUrl("theme/spacer.gif"),a=d.require("htmlparser");d.augment(g,{createFakeElement:function(a,b,c,g,j,h){var p=a.attr("style")||"";a.attr("width")&&(p="width:"+a.attr("width")+"px;"+p);a.attr("height")&&(p="height:"+a.attr("height")+"px;"+p);var o=d.trim(a.attr("class")),a={"class":b+" "+o,src:f,_ke_realelement:encodeURIComponent(j||a._4e_outerHtml(void 0)),_ke_real_node_type:a[0].nodeType,style:p};h&&(delete h.width,
delete h.height,d.mix(a,h,!1));c&&(a._ke_real_element_type=c);g&&(a._ke_resizable=g);return new k("<img/>",a,this.get("document")[0])},restoreRealElement:function(a){if(a.attr("_ke_real_node_type")!=h.ELEMENT_NODE)return null;var a=decodeURIComponent(a.attr("_ke_realelement")),b=new k("<div>",null,this.get("document")[0]);b.html(a);return b.first().remove()}});var c={tags:{$:function(c){var b=c.getAttribute("_ke_realelement"),d;b&&(d=(new a.Parser(decodeURIComponent(b))).parse());if(b=d&&d.childNodes[0]){if(d=
c.getAttribute("style")){var f=/(?:^|\s)width\s*:\s*(\d+)/i.exec(d),c=f&&f[1];d=(f=/(?:^|\s)height\s*:\s*(\d+)/i.exec(d))&&f[1];c&&b.setAttribute("width",c);d&&b.setAttribute("height",d)}return b}}}};return{init:function(e){var b=e.htmlDataProcessor,g=b&&b.htmlFilter;b.createFakeParserElement||(g&&g.addRules(c),d.mix(b,{restoreRealElement:function(a){if(a.attr("_ke_real_node_type")!=h.ELEMENT_NODE)return null;var a=decodeURIComponent(a.attr("_ke_realelement")),b=new k("<div>",null,e.get("document")[0]);
b.html(a);return b.first().remove()},createFakeParserElement:function(b,c,e,g,h){var i=a.serialize(b),m=b.getAttribute("style")||"";b.getAttribute("width")&&(m="width:"+b.getAttribute("width")+"px;"+m);b.getAttribute("height")&&(m="height:"+b.getAttribute("height")+"px;"+m);var k=d.trim(b.getAttribute("class")),b={"class":c+" "+k,src:f,_ke_realelement:encodeURIComponent(i),_ke_real_node_type:b.nodeType+"",style:m,align:b.getAttribute("align")||""};h&&(delete h.width,delete h.height,d.mix(b,h,!1));
e&&(b._ke_real_element_type=e);g&&(b._ke_resizable="_ke_resizable");return new a.Tag("img",b)}}))}}},{requires:["editor"]});
KISSY.add("editor/plugin/flashBridge/index",function(d,g,k){function h(a){this._init(a)}function f(b){var c=d.isString(b)?b.match(/(\d)+/g):b;d.isArray(c)&&(b=parseFloat(c[0]+"."+a(c[1],3)+a(c[2],5)));return b||0}function a(a,b){for(var c=(a+"").length;c++<b;)a="0"+a;return a}var c={};d.augment(h,d.EventTarget,{_init:function(a){var b=d.guid("flashbridge-");a.flashVars=a.flashVars||{};a.attrs=a.attrs||{};a.params=a.params||{};var e=a.flashVars,f=a.params;d.mix(a.attrs,{id:b,width:"100%",height:"100%"},
!1);d.mix(f,{allowScriptAccess:"always",allowNetworking:"all",scale:"noScale"},!1);d.mix(e,{shareData:!1,useCompression:!1},!1);f={YUISwfId:b,YUIBridgeCallback:"KISSY.Editor.FlashBridge.EventHandler"};a.ajbridge&&(f={swfID:b,jsEntry:"KISSY.Editor.FlashBridge.EventHandler"});d.mix(e,f);c[b]=this;this.id=b;this.swf=k.createSWFRuntime(a.movie,a);this._expose(a.methods)},_expose:function(a){for(var b=this,c=0;c<a.length;c++)(function(a){b[a]=function(){return b._callSWF(a,d.makeArray(arguments))}})(a[c])},
_callSWF:function(a,b){b=b||[];try{if(this.swf[a])return this.swf[a].apply(this.swf,b)}catch(c){var e="";0!==b.length&&(e="'"+b.join("', '")+"'");return(new Function("self","return self.swf."+a+"("+e+");"))(this)}},_eventHandler:function(a){var b=a.type;"log"!==b&&b&&this.fire(b,a)},ready:function(a){if(this._ready)a.call(this);else this.on("contentReady",a)},destroy:function(){delete c[this.id]}});h.EventHandler=function(a,b){var e=c[a];e&&setTimeout(function(){e._eventHandler.call(e,b)},100)};g.FlashBridge=
h;var e=d.UA,b,m,l=!0;e.fpv=function(a){if(a||l){l=!1;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(e){}b=!c?void 0:c.match(/(\d)+/g);m=f(b)}return b};e.fpvGEQ=function(a,b){l&&e.fpv(b);return!!m&&m>=f(a)};return h},{requires:["editor","../flashCommon/utils"]});
KISSY.add("editor/plugin/flashCommon/baseClass",function(d,g,k,h,f,a){function c(){c.superclass.constructor.apply(this,arguments);this._init()}var e=d.Node;c.ATTRS={cls:{},type:{},label:{value:"\u5728\u65b0\u7a97\u53e3\u67e5\u770b"},bubbleId:{},contextMenuId:{},contextMenuHandlers:{}};d.extend(c,d.Base,{_init:function(){var a=this,c=a.get("cls"),e=a.get("editor"),f=[],h=a.get("bubbleId"),k=a.get("contextMenuId"),o=a.get("contextMenuHandlers");d.each(o,function(a,b){f.push({content:b})});e.addContextMenu(k,"."+c,{width:"120px",
children:f,listeners:{click:function(a){a=a.target.get("content");o[a]&&o[a].call(this)}}});e.addBubble(h,function(a){return a.hasClass(c,void 0)&&a},{listeners:{afterRenderUI:function(){var c=this,f=c.get("contentEl");f.html(d.substitute(' <a class="ks-editor-bubble-url" target="_blank" href="#">{label}</a>   |    <span class="ks-editor-bubble-link ks-editor-bubble-change">\u7f16\u8f91</span>   |    <span class="ks-editor-bubble-link ks-editor-bubble-remove">\u5220\u9664</span>',{label:a.get("label")}));var h=f.one(".ks-editor-bubble-url"),
j=f.one(".ks-editor-bubble-change"),m=f.one(".ks-editor-bubble-remove");g.Utils.preventFocus(f);j.on("click",function(e){a.show(c.get("editorSelectedEl"));e.halt()});m.on("click",function(a){if(d.UA.webkit){var b=e.getSelection().getRanges();if(b=b&&b[0])b.collapse(!0),b.select()}c.get("editorSelectedEl").remove();c.hide();e.notifySelectionChange();a.halt()});c.on("show",function(){var e=c.get("editorSelectedEl");e&&a._updateTip(h,e)})}}});e.docReady(function(){e.get("document").on("dblclick",a._dbClick,
a)})},_getFlashUrl:function(b){return a.getUrl(b)},_updateTip:function(a,c){var e=this.get("editor").restoreRealElement(c);e&&(e=this._getFlashUrl(e),a.attr("href",e))},_dbClick:function(a){var c=new e(a.target);"img"===c.nodeName()&&c.hasClass(this.get("cls"),void 0)&&(this.show(c),a.halt())},show:function(a){var c=this.get("editor");f.useDialog(c,this.get("type"),this.get("pluginConfig"),a)}});return c},{requires:["editor","../contextmenu/","../bubble/","../dialogLoader/","./utils"]});
KISSY.add("editor/plugin/flashCommon/utils",function(d){var g=d.DOM,k=d.Node,h=d.UA,f={insertFlash:function(a,c,e,b,d){c=f.createSWF(c,{attrs:e},a.get("document")[0]);e=a.createFakeElement(c.el,b||"ke_flash",d||"flash",!0,c.html,e);a.insertElement(e);return e},isFlashEmbed:function(a){return"application/x-shockwave-flash"==a.getAttribute("type")||/\.swf(?:$|\?)/i.test(a.getAttribute("src")||"")},getUrl:function(a){var c="";if("object"==a.nodeName())for(var a=a[0].childNodes,e=0;e<a.length;e++)1==
a[e].nodeType&&("movie"==(g.attr(a[e],"name")||"").toLowerCase()?c=g.attr(a[e],"value"):"embed"==g.nodeName(a[e])?c=g.attr(a[e],"src"):"object"==g.nodeName(a[e])&&(c=g.attr(a[e],"data")));else"embed"==a.nodeName()&&(c=a.attr("src"));return c},createSWF:function(a,c,e){var b=c.attrs||{},f=c.flashVars,g="",h="",c=c.params||{},r="",e=e||document;d.mix(b,{wmode:"transparent"});for(var p in b)b.hasOwnProperty(p)&&(g+=p+"='"+b[p]+"' ");d.mix(c,{quality:"high",movie:a,wmode:"transparent"});for(var o in c)c.hasOwnProperty(o)&&
(h+="<param name='"+o+"' value='"+c[o]+"'/>");if(f){for(var i in f)f.hasOwnProperty(i)&&(r+="&"+i+"="+encodeURIComponent(f[i]));r=r.substring(1)}a="<object "+g+' classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" >'+h+(r?'<param name="flashVars" value="'+r+'"/>':"")+"<embed "+g+" "+(r?'FlashVars="'+r+'"':"")+' pluginspage="http://www.macromedia.com/go/getflashplayer"  quality="high"  src="'+a+'"  type="application/x-shockwave-flash"/></object>';return{el:new k(a,null,e),html:a}},createSWFRuntime2:function(a,
c,e){var e=e||document,b=(new k("<div style='width:0;height:0;overflow:hidden;'>",null,e)).appendTo(e.body),b=f.createSWF.apply(this,arguments).el.appendTo(b);h.ie||(b=b.one("object"));return b[0]},createSWFRuntime:function(a,c,e){var b=c.attrs||{},f=c.flashVars||{},l=c.params||{},j="",r="",p="",e=e||document;b.id=b.id||d.guid("ks-editor-runtimeflash-");for(var o in b)b.hasOwnProperty(o)&&(j+=o+"='"+b[o]+"' ");for(var i in l)l.hasOwnProperty(i)&&(r+="<param name='"+i+"' value='"+l[i]+"'/>");for(var n in f)f.hasOwnProperty(n)&&
(p+="&"+n+"="+encodeURIComponent(f[n]));var p=p.substring(1),a=h.ie?"<object "+j+' classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" >'+r+'<param name="movie" value="'+a+'" />'+(p?'<param name="flashVars" value="'+p+'" />':"")+"</object>":"<object type='application/x-shockwave-flash' data='"+a+"' "+j+">"+r+(p?'<param name="flashVars" value="'+p+'"/>':"")+"</object>",v=c.holder;v||(v=(new k("<div style='"+(c.style?c.style:"width:1px;height:1px;position:absolute;NaN")+"'>",null,e)).appendTo(e.body),
setTimeout(function(){v.offset({left:g.scrollLeft(),top:g.scrollTop()})},100));v.html(a);return e.getElementById(b.id)}};return f});
KISSY.add("editor/plugin/flash/index",function(d,g,k,h,f){function a(a){this.config=a||{}}d.augment(a,{renderUI:function(a){f.init(a);var e=a.htmlDataProcessor;e.dataFilter.addRules({tags:{object:function(a){var b;if(!a.getAttribute("classid")){var c=a.childNodes;for(b=0;b<c.length;b++)if("embed"==c[b].nodeName)if(h.isFlashEmbed(c[b][b]))break;else return e.createFakeParserElement(a,"ke_flash","flash",!0);return null}return e.createFakeParserElement(a,"ke_flash","flash",!0)},embed:function(a){return h.isFlashEmbed(a)?
e.createFakeParserElement(a,"ke_flash","flash",!0):null}}},5);var b=new k({editor:a,cls:"ke_flash",type:"flash",pluginConfig:this.config,bubbleId:"flash",contextMenuId:"flash",contextMenuHandlers:{"Flash\u5c5e\u6027":function(){var a=this.get("editorSelectedEl");a&&b.show(a)}}});this.flashControl=b;a.addButton("flash",{tooltip:"\u63d2\u5165Flash",listeners:{click:function(){b.show()}},mode:g.WYSIWYG_MODE})}});return a},{requires:["editor","../flashCommon/baseClass","../flashCommon/utils","../fakeObjects/"]});
KISSY.add("editor/plugin/focusFix/index",function(d,g){function k(){var c=this._focusEditor=a.currentInstance();if(f.ie&&c){window.focus();document.body.focus();var e=c.get("document")[0].selection,b;try{b=e.createRange()}catch(d){b=0}b&&b.item&&b.item(0).ownerDocument==c.get("document")[0]&&(c=document.body.createTextRange(),c.moveToElementText(this.get("el").first()[0]),c.collapse(!0),c.select())}}function h(){var a=this._focusEditor;a&&a.focus()}var f=d.UA,a=g.focusManager;return{init:function(a){a.on("beforeVisibleChange",
function(e){e.newVal&&k.call(a)});a.on("hide",function(){h.call(a)})}}},{requires:["editor"]});KISSY.add("editor/plugin/fontFamily/cmd",function(d,g,k){var h={element:"span",styles:{"font-family":"#(value)"},overrides:[{element:"font",attributes:{face:null}}]};return{init:function(d){k.addSelectCmd(d,"fontFamily",h)}}},{requires:["editor","../font/cmd"]});
KISSY.add("editor/plugin/fontFamily/index",function(d,g,k,h){function f(a){this.config=a||{}}d.augment(f,{renderUI:function(a){h.init(a);var c=this.config,e={};d.mix(e,{children:[{content:"\u5b8b\u4f53",value:"SimSun"},{content:"\u9ed1\u4f53",value:"SimHei"},{content:"\u96b6\u4e66",value:"LiSu"},{content:"\u6977\u4f53",value:"KaiTi_GB2312"},{content:"\u5fae\u8f6f\u96c5\u9ed1",value:"Microsoft YaHei"},{content:"Georgia",value:"Georgia"},{content:"Times New Roman",value:"Times New Roman"},{content:"Impact",value:"Impact"},{content:"Courier New",value:"Courier New"},
{content:"Arial",value:"Arial"},{content:"Verdana",value:"Verdana"},{content:"Tahoma",value:"Tahoma"}],width:"130px"});d.each(e.children,function(a){var c=a.elAttrs||{},e=a.value;c.style=c.style||"";c.style+=";font-family:"+e;a.elAttrs=c});c.menu=d.mix(e,c.menu);a.addSelect("fontFamily",d.mix({cmdType:"fontFamily",defaultCaption:"\u5b57\u4f53",width:130,mode:g.WYSIWYG_MODE},c),k.Select)}});return f},{requires:["editor","../font/ui","./cmd"]});
KISSY.add("editor/plugin/fontSize/cmd",function(d,g,k){var h={element:"span",styles:{"font-size":"#(value)"},overrides:[{element:"font",attributes:{size:null}}]};return{init:function(d){k.addSelectCmd(d,"fontSize",h)}}},{requires:["editor","../font/cmd"]});
KISSY.add("editor/plugin/fontSize/index",function(d,g,k,h){function f(a){this.config=a||{}}d.augment(f,{renderUI:function(a){h.init(a);var c=this.config;c.menu=d.mix({children:function(a){var b=[];d.each(a,function(a){b.push({content:a,value:a})});return b}("8px,10px,12px,14px,18px,24px,36px,48px,60px,72px,84px,96px".split(","))},c.menu);a.addSelect("fontSize",d.mix({cmdType:"fontSize",defaultCaption:"\u5927\u5c0f",width:"70px",mode:g.WYSIWYG_MODE},c),k.Select)}});return f},{requires:["editor","../font/ui",
"./cmd"]});
KISSY.add("editor/plugin/font/cmd",function(d,g){function k(d,a){var c=d.nodeName();if(a.element!=c)return!1;var e=a.styles,b,g;for(g in e)if(b=d.style(g))return b;e=a.overrides;for(g=0;g<e.length;g++)if(b=e[g],b.element==c){var h=b.attributes,j;for(j in h)if(b=d.attr(j))return b}return!1}var h=g.Utils.getQueryCmd;return{addButtonCmd:function(d,a,c){var e=h(a);d.hasCommand(a)||(d.addCommand(a,{exec:function(b){var e=b.get("document")[0];b.execCommand("save");b.queryCommandValue(a)?c.remove(e):c.apply(e);
b.execCommand("save");b.notifySelectionChange()}}),d.addCommand(e,{exec:function(a){if((a=a.getSelection())&&!a.isInvalid)return a=a.getStartElement(),a=new g.ElementPath(a),c.checkActive(a)}}))},addSelectCmd:function(d,a,c){var e=h(a);d.hasCommand(a)||(d.addCommand(a,{exec:function(b,e){b.focus();var d=b.queryCommandValue(a)||"",f=new g.Style(c,{value:e}),h=b.get("document")[0];b.execCommand("save");e.toLowerCase()==d.toLowerCase()?f.remove(h):f.apply(h);b.execCommand("save")}}),d.addCommand(e,{exec:function(a){if((a=
a.getSelection())&&!a.isInvalid){var a=a.getStartElement(),a=new g.ElementPath(a),e=a.elements,d,f,h;for(f=0;f<e.length;f++)if(d=e[f],!(d[0]==a.block[0]||d[0]==a.blockLimit[0]))if(h=k(d,c),!1!==h)break;return h}}}))}}},{requires:["editor"]});
KISSY.add("editor/plugin/font/ui",function(d,g,k,h){d=h.Select.extend({initializer:function(){var d=this,a=d.get("editor");d.on("click",function(c){var c=c.target.get("value"),e=d.get("cmdType");a.execCommand(e,c)});a.on("selectionChange",function(){if(a.get("mode")!=g.SOURCE_MODE){var c=d.get("cmdType"),e=d.get("menu");if(e=e.get&&e.get("children")){c=a.queryCommandValue(c);if(!1!==c)for(var c=(c+"").toLowerCase(),b=0;b<e.length;b++){var h=e[b].get("value");if(c==h.toLowerCase()){d.set("value",h);
return}}d.set("value",null)}}})}});return{Button:k.extend({initializer:function(){var d=this,a=d.get("editor"),c=d.get("cmdType");d.on("click",function(){d.get("checked")?a.execCommand(c):a.execCommand(c,!1);a.focus()});a.on("selectionChange",function(){if(a.get("mode")!=g.SOURCE_MODE){var c=d.get("cmdType");a.queryCommandValue(c)?d.set("checked",!0):d.set("checked",!1)}})}},{ATTRS:{checkable:{value:!0},mode:{value:g.WYSIWYG_MODE}}}),Select:d}},{requires:["editor","../button/","../menubutton/"]});
KISSY.add("editor/plugin/foreColor/cmd",function(d,g){var k={element:"span",styles:{color:"#(color)"},overrides:[{element:"font",attributes:{color:null}}],childRule:function(d){return!("a"==d.nodeName()||d.all("a").length)}};return{init:function(d){d.hasCommand("foreColor")||d.addCommand("foreColor",{exec:function(d,a){d.execCommand("save");g.applyColor(d,a,k);d.execCommand("save")}})}}},{requires:["../color/cmd"]});
KISSY.add("editor/plugin/foreColor/index",function(d,g,k,h){function f(a){this.config=a||{}}d.augment(f,{renderUI:function(a){h.init(a);a.addButton("foreColor",{cmdType:"foreColor",tooltip:"\u6587\u672c\u989c\u8272",pluginConfig:this.config},k)}});return f},{requires:["editor","../color/btn","./cmd"]});
KISSY.add("editor/plugin/heading/cmd",function(d,g){return{init:function(d){if(!d.hasCommand("heading")){d.addCommand("heading",{exec:function(d,a){d.execCommand("save");if("p"!=a)var c=d.queryCommandValue("heading");a==c&&(a="p");(new g.Style({element:a})).apply(d.get("document")[0]);d.execCommand("save")}});var h=g.Utils.getQueryCmd("heading");d.addCommand(h,{exec:function(d){if((d=d.getSelection())&&!d.isInvalid)if(d=d.getStartElement(),d=new g.ElementPath(d),d=(d=d.block||d.blockLimit)&&d.nodeName()||
"",d.match(/^h\d$/)||"p"==d)return d}})}}}},{requires:["editor"]});
KISSY.add("editor/plugin/heading/index",function(d,g,k){function h(){}d.augment(h,{renderUI:function(d){k.init(d);var a=[],c={"\u666e\u901a\u6587\u672c":"p","\u6807\u98981":"h1","\u6807\u98982":"h2","\u6807\u98983":"h3","\u6807\u98984":"h4","\u6807\u98985":"h5","\u6807\u98986":"h6"},e={p:"1em",h1:"2em",h2:"1.5em",h3:"1.17em",h4:"1em",h5:"0.83em",h6:"0.67em"},b;for(b in c)c.hasOwnProperty(b)&&a.push({content:b,value:c[b],elAttrs:{style:"font-size:"+e[c[b]]}});d.addSelect("heading",{defaultCaption:"\u6807\u9898",width:"120px",menu:{children:a},mode:g.WYSIWYG_MODE,listeners:{click:function(a){a=
a.target.get("value");d.execCommand("heading",a)},afterSyncUI:function(){var a=this;d.on("selectionChange",function(){if(d.get("mode")!=g.SOURCE_MODE){var b=d.queryCommandValue("heading"),c;for(c in e)if(e.hasOwnProperty(c)&&c==b){a.set("value",c);return}a.set("value",null)}})}}})}});return h},{requires:["editor","./cmd"]});
KISSY.add("editor/plugin/image/index",function(d,g,k,h,f,a){function c(a){this.config=a||{}}var e=d.UA,b=d.Node,m=d.all,l=d.Event,j=function(a){a=m(a);if("img"===a.nodeName()&&!/(^|\s+)ke_/.test(a[0].className))return a};d.augment(c,{renderUI:function(c){function f(b){a.useDialog(c,"image",h.config,b)}var h=this;c.addButton("image",{tooltip:"\u63d2\u5165\u56fe\u7247",listeners:{click:function(){f(null)}},mode:g.WYSIWYG_MODE});var i=[{content:"\u56fe\u7247\u5c5e\u6027",fn:function(){var a=j(this.get("editorSelectedEl"));a&&(this.hide(),
f(m(a)))}},{content:"\u63d2\u5165\u65b0\u884c",fn:function(){this.hide();var a=c.get("document")[0],d=new b(a.createElement("p"));e.ie||d._4e_appendBogus(void 0);a=new g.Range(a);a.setStartAfter(this.get("editorSelectedEl"));a.select();c.insertElement(d);a.moveToElementEditablePosition(d,1);a.select()}}],k=[];d.each(i,function(a){k.push({content:a.content})});c.addContextMenu("image",j,{width:120,children:k,listeners:{click:function(a){var b=this,c=a.target.get("content");d.each(i,function(a){a.content==c&&a.fn.call(b)})}}});
c.docReady(function(){l.on(c.get("document")[0],"dblclick",function(a){a.halt();a=m(a.target);j(a)&&f(a)})});c.addBubble("image",j,{listeners:{afterRenderUI:function(){var a=this,b=a.get("contentEl");b.html('<a class="ks-editor-bubble-url" target="_blank" href="#">\u5728\u65b0\u7a97\u53e3\u67e5\u770b</a>  |  <a class="ks-editor-bubble-link ks-editor-bubble-change" href="#">\u7f16\u8f91</a>  |  <a class="ks-editor-bubble-link ks-editor-bubble-remove" href="#">\u5220\u9664</a>');var d=b.one(".ks-editor-bubble-url"),h=b.one(".ks-editor-bubble-change"),
i=b.one(".ks-editor-bubble-remove");g.Utils.preventFocus(b);h.on("click",function(b){f(a.get("editorSelectedEl"));b.halt()});i.on("click",function(b){if(e.webkit){var d=c.getSelection().getRanges();d&&d[0]&&(d[0].collapse(),d[0].select())}a.get("editorSelectedEl").remove();a.hide();c.notifySelectionChange();b.halt()});a.on("show",function(){var b=a.get("editorSelectedEl");b&&(b=b.attr("_ke_saved_src")||b.attr("src"),d.attr("href",b))})}}})}});return c},{requires:["editor","../button/","../bubble/",
"../contextmenu/","../dialogLoader/"]});KISSY.add("editor/plugin/indent/cmd",function(d,g,k){var h=k.addCommand;return{init:function(d){h(d,"indent")}}},{requires:["editor","../dentUtils/cmd"]});KISSY.add("editor/plugin/indent/index",function(d,g,k){function h(){}d.augment(h,{renderUI:function(d){k.init(d);d.addButton("indent",{tooltip:"\u589e\u52a0\u7f29\u8fdb\u91cf ",listeners:{click:function(){d.execCommand("indent");d.focus()}},mode:g.WYSIWYG_MODE})}});return h},{requires:["editor","./cmd"]});
KISSY.add("editor/plugin/italic/cmd",function(d,g,k){var h=new g.Style({element:"em",overrides:[{element:"i"},{element:"span",attributes:{style:"font-style: italic;"}}]});return{init:function(d){k.addButtonCmd(d,"italic",h)}}},{requires:["editor","../font/cmd"]});
KISSY.add("editor/plugin/italic/index",function(d,g,k,h){function f(){}d.augment(f,{renderUI:function(a){h.init(a);a.addButton("italic",{cmdType:"italic",tooltip:"\u659c\u4f53 "},k.Button);a.docReady(function(){a.get("document").on("keydown",function(c){c.ctrlKey&&c.keyCode==d.Node.KeyCodes.I&&(a.execCommand("italic"),c.preventDefault())})})}});return f},{requires:["editor","../font/ui","./cmd"]});
KISSY.add("editor/plugin/justifyCenter/cmd",function(d,g){return{init:function(d){g.addCommand(d,"justifyCenter","center")}}},{requires:["../justifyUtils/cmd"]});
KISSY.add("editor/plugin/justifyCenter/index",function(d,g,k){function h(){var a=this.get("editor");a.execCommand("justifyCenter");a.focus()}function f(){}d.augment(f,{renderUI:function(a){k.init(a);a.addButton("justifyCenter",{tooltip:"\u5c45\u4e2d\u5bf9\u9f50",checkable:!0,listeners:{click:h,afterSyncUI:function(){var c=this;a.on("selectionChange",function(){a.get("mode")!=g.SOURCE_MODE&&(a.queryCommandValue("justifyCenter")?c.set("checked",!0):c.set("checked",!1))})}},mode:g.WYSIWYG_MODE});a.docReady(function(){a.get("document").on("keydown",
function(c){c.ctrlKey&&c.keyCode==d.Node.KeyCodes.E&&(a.execCommand("justifyCenter"),c.preventDefault())})})}});return f},{requires:["editor","./cmd"]});KISSY.add("editor/plugin/justifyLeft/cmd",function(d,g){return{init:function(d){g.addCommand(d,"justifyLeft","left")}}},{requires:["../justifyUtils/cmd"]});
KISSY.add("editor/plugin/justifyLeft/index",function(d,g,k){function h(){var a=this.get("editor");a.execCommand("justifyLeft");a.focus()}function f(){}d.augment(f,{renderUI:function(a){k.init(a);a.addButton("justifyLeft",{tooltip:"\u5de6\u5bf9\u9f50",checkable:!0,listeners:{click:h,afterSyncUI:function(){var c=this;a.on("selectionChange",function(){a.get("mode")!=g.SOURCE_MODE&&(a.queryCommandValue("justifyLeft")?c.set("checked",!0):c.set("checked",!1))})}},mode:g.WYSIWYG_MODE});a.docReady(function(){a.get("document").on("keydown",
function(c){c.ctrlKey&&c.keyCode==d.Node.KeyCodes.L&&(a.execCommand("justifyLeft"),c.preventDefault())})})}});return f},{requires:["editor","./cmd"]});KISSY.add("editor/plugin/justifyRight/cmd",function(d,g){return{init:function(d){g.addCommand(d,"justifyRight","right")}}},{requires:["../justifyUtils/cmd"]});
KISSY.add("editor/plugin/justifyRight/index",function(d,g,k){function h(){var a=this.get("editor");a.execCommand("justifyRight");a.focus()}function f(){}d.augment(f,{renderUI:function(a){k.init(a);a.addButton("justifyRight",{tooltip:"\u53f3\u5bf9\u9f50",checkable:!0,listeners:{click:h,afterSyncUI:function(){var c=this;a.on("selectionChange",function(){a.get("mode")!=g.SOURCE_MODE&&(a.queryCommandValue("justifyRight")?c.set("checked",!0):c.set("checked",!1))})}},mode:g.WYSIWYG_MODE});a.docReady(function(){a.get("document").on("keydown",
function(c){c.ctrlKey&&c.keyCode==d.Node.KeyCodes.R&&(a.execCommand("justifyRight"),c.preventDefault())})})}});return f},{requires:["editor","./cmd"]});
KISSY.add("editor/plugin/justifyUtils/cmd",function(d,g){var k=/(-moz-|-webkit-|start|auto)/gi;return{addCommand:function(d,f,a){d.hasCommand(f)||(d.addCommand(f,{exec:function(c){c.focus();c.execCommand("save");for(var d=c.getSelection(),b=d.createBookmarks(),f=d.getRanges(),g,h,r=f.length-1;0<=r;r--){g=f[r].createIterator();for(g.enlargeBr=!0;h=g.getNextParagraph();)h.removeAttr("align"),(h.css("text-align").replace(k,"")||"left")==a?h.css("text-align",""):h.css("text-align",a)}d.selectBookmarks(b);
c.execCommand("save");c.notifySelectionChange()}}),d.addCommand(g.Utils.getQueryCmd(f),{exec:function(c){if((c=c.getSelection())&&!c.isInvalid)return c=c.getStartElement(),c=new g.ElementPath(c),c=c.block||c.blockLimit,!c||"body"===c.nodeName()?!1:(c.css("text-align").replace(k,"")||"left")==a}}))}}},{requires:["editor"]});
KISSY.add("editor/plugin/link/index",function(d,g,k,h,f){function a(a){a=e(a);return a.closest("a",void 0)}function c(a){this.config=a||{}}var e=d.all;d.augment(c,{renderUI:function(b){b.addButton("link",{tooltip:"\u63d2\u5165\u94fe\u63a5",listeners:{click:function(){f.useDialog(b,"link",c.config,void 0)}},mode:g.WYSIWYG_MODE});var c=this;b.addBubble("link",a,{listeners:{afterRenderUI:function(){var a=this,d=a.get("contentEl");d.html('<a href=""  target="_blank" class="ks-editor-bubble-url">\u5728\u65b0\u7a97\u53e3\u67e5\u770b</a>  \u2013   <span class="ks-editor-bubble-link ks-editor-bubble-change">\u7f16\u8f91</span>   |    <span class="ks-editor-bubble-link ks-editor-bubble-remove">\u53bb\u9664</span>');
var e=d.one(".ks-editor-bubble-url"),k=d.one(".ks-editor-bubble-change"),o=d.one(".ks-editor-bubble-remove");g.Utils.preventFocus(d);k.on("click",function(d){var e=a.get("editorSelectedEl");f.useDialog(b,"link",c.config,e);d.halt()});o.on("click",function(c){h.removeLink(b,a.get("editorSelectedEl"));c.halt()});a.on("show",function(){var b=a.get("editorSelectedEl");b&&(b=b.attr(h._ke_saved_href)||b.attr("href"),e.html(b),e.attr("href",b))})}}})}});return c},{requires:["editor","../bubble/","./utils",
"../dialogLoader/","../button/"]});
KISSY.add("editor/plugin/link/utils",function(d,g){var k=d.Node,h=g.Style,f={element:"a",attributes:{href:"#(href)",title:"#(title)",_ke_saved_href:"#(_ke_saved_href)",target:"#(target)"}};return{removeLink:function(a,c){a.execCommand("save");var d=a.getSelection(),b=d.getRanges()[0];if(b&&b.collapsed)b=d.createBookmarks(),c._4e_remove(!0),d.selectBookmarks(b);else if(b){for(var d=c[0],b=d.attributes,g={},l=0;l<b.length;l++){var j=b[l];j.specified&&(g[j.name]=j.value)}d.style.cssText&&(g.style=d.style.cssText);
(new h(f,g)).remove(a.get("document")[0])}a.execCommand("save");a.notifySelectionChange()},applyLink:function(a,c,d){c._ke_saved_href=c.href;d?(a.execCommand("save"),d.attr(c)):(d=(d=a.getSelection())&&d.getRanges()[0],!d||d.collapsed?(c=new k("<a>"+c.href+"</a>",c,a.get("document")[0]),a.insertElement(c)):(a.execCommand("save"),(new h(f,c)).apply(a.get("document")[0])));a.execCommand("save");a.notifySelectionChange()},_ke_saved_href:"_ke_saved_href"}},{requires:["editor"]});
KISSY.add("editor/plugin/listUtils/btn",function(d,g,k){function h(){var d=this.get("editor"),a=this.get("cmdType");d.execCommand(a);d.focus()}return k.extend({initializer:function(){var d=this;d.on("click",h,d);var a=d.get("editor");a.on("selectionChange",function(){var c=d.get("cmdType");a.queryCommandValue(c)?d.set("checked",!0):d.set("checked",!1)})}},{ATTRS:{checkable:{value:!0},mode:{value:g.WYSIWYG_MODE}}})},{requires:["editor","../button/"]});
KISSY.add("editor/plugin/listUtils/cmd",function(d,g,k,h){function f(a){this.type=a}function a(a,b){var d,e,f=b.blockLimit,g=b.elements;if(!f)return!1;if(g)for(var h=0;h<g.length&&(d=g[h])&&d[0]!==f[0];h++)if(c[e=d.nodeName()]&&e==a)return!0;return!1}var c={ol:"insertOrderedList",ul:"insertUnorderedList"},e=g.RANGE,b=g.ElementPath,m=g.Walker,l=d.UA,j=d.Node,r=d.DOM,p=/^h[1-6]$/;f.prototype={changeListType:function(a,b,c,d){for(var e=k.listToArray(b.root,c,h,h,h),f=[],a=0;a<b.contents.length;a++){var g=
b.contents[a];if((g=g.closest("li",h))&&g[0]&&!g.data("list_item_processed"))f.push(g),g._4e_setMarker(c,"list_item_processed",!0,h)}g=new j(b.root[0].ownerDocument.createElement(this.type));for(a=0;a<f.length;a++){var l=f[a].data("listarray_index");e[l].parent=g}for(var c=k.arrayToList(e,c,null,"p"),m,e=c.listNode.childNodes.length,a=0;a<e&&(m=new j(c.listNode.childNodes[a]));a++)m.nodeName()==this.type&&d.push(m);b.root.before(c.listNode);b.root.remove()},createList:function(a,b,c){var d=b.contents,
a=b.root[0].ownerDocument,e=[];if(1==d.length&&d[0][0]===b.root[0]){var f=new j(a.createElement("div"));d[0][0].nodeType!=r.TEXT_NODE&&d[0]._4e_moveChildren(f,h,h);d[0][0].appendChild(f[0]);d[0]=f}b=b.contents[0].parent();for(f=0;f<d.length;f++)b=b._4e_commonAncestor(d[f].parent(),h);for(f=0;f<d.length;f++)for(var g=d[f],k;k=g.parent();){if(k[0]===b[0]){e.push(g);break}g=k}if(!(1>e.length)){d=new j(e[e.length-1][0].nextSibling);f=new j(a.createElement(this.type));for(c.push(f);e.length;)c=e.shift(),
g=new j(a.createElement("li")),p.test(c.nodeName())?g[0].appendChild(c[0]):(c._4e_copyAttributes(g,h,h),c._4e_moveChildren(g,h,h),c.remove()),f[0].appendChild(g[0]),l.ie||g._4e_appendBogus(h);d[0]?f.insertBefore(d,h):b.append(f)}},removeList:function(a,b,c){function d(c){if((s=new j(p[c?"firstChild":"lastChild"]))&&!(s[0].nodeType==r.ELEMENT_NODE&&s._4e_isBlockBoundary(h,h))&&(w=b.root[c?"prev":"next"](m.whitespaces(!0),1))&&!(s[0].nodeType==r.ELEMENT_NODE&&w._4e_isBlockBoundary({br:1},h)))s[c?"before":
"after"](a.get("document")[0].createElement("br"))}for(var e=k.listToArray(b.root,c,h,h,h),f=[],g=0;g<b.contents.length;g++){var l=b.contents[g];if((l=l.closest("li",h))&&!l.data("list_item_processed"))f.push(l),l._4e_setMarker(c,"list_item_processed",!0,h)}l=null;for(g=0;g<f.length;g++)l=f[g].data("listarray_index"),e[l].indent=-1;for(g=l+1;g<e.length;g++)if(e[g].indent>Math.max(e[g-1].indent,0)){f=e[g-1].indent+1-e[g].indent;for(l=e[g].indent;e[g]&&e[g].indent>=l;)e[g].indent+=f,g++;g--}var p=k.arrayToList(e,
c,null,"p").listNode,s,w;d(!0);d(h);b.root.before(p);b.root.remove()},exec:function(d){var f=d.getSelection(),j=f&&f.getRanges();if(j&&!(1>j.length)){for(var l=f.getStartElement(),l=new g.ElementPath(l),k=a(this.type,l),l=f.createBookmarks(!0),p=[],q={};0<j.length;){var u=j.shift(),y=u.getBoundaryNodes(),s=y.startNode,w=y.endNode;s[0].nodeType==r.ELEMENT_NODE&&"td"==s.nodeName()&&u.setStartAt(y.startNode,e.POSITION_AFTER_START);w[0].nodeType==r.ELEMENT_NODE&&"td"==w.nodeName()&&u.setEndAt(y.endNode,
e.POSITION_BEFORE_END);u=u.createIterator();for(u.forceBrBreak=!1;y=u.getNextParagraph();)if(!y.data("list_block")){y._4e_setMarker(q,"list_block",1,h);for(var w=new b(y),A=w.elements,B=null,C=!1,B=w.blockLimit,z,s=A.length-1;0<=s&&(z=A[s]);s--)if(c[z.nodeName()]&&B.contains(z)){B.removeData("list_group_object");(s=z.data("list_group_object"))?s.contents.push(y):(s={root:z,contents:[y]},p.push(s),z._4e_setMarker(q,"list_group_object",s,h));C=!0;break}C||(w=B||w.block,w.data("list_group_object")?w.data("list_group_object").contents.push(y):
(s={root:w,contents:[y]},w._4e_setMarker(q,"list_group_object",s,h),p.push(s)))}}for(j=[];0<p.length;)s=p.shift(),k?c[s.root.nodeName()]&&this.removeList(d,s,q):c[s.root.nodeName()]?this.changeListType(d,s,q,j):(g.Utils.clearAllMarkers(q),this.createList(d,s,j));for(var E=this,s=0;s<j.length;s++)B=j[s],d=function(a,b){var c=b[a?"prev":"next"](m.whitespaces(!0),1);c&&c[0]&&c.nodeName()==E.type&&(c.remove(),c._4e_moveChildren(b,a?!0:!1,h))},d(h,B),d(!0,B);g.Utils.clearAllMarkers(q);f.selectBookmarks(l)}}};
return{ListCommand:f,queryActive:a}},{requires:["editor","../listUtils/"]});
KISSY.add("editor/plugin/listUtils/index",function(d){var g={ol:1,ul:1},k=d.Node,h=d.DOM,f=d.UA,a={listToArray:function(c,d,b,f,l){if(!g[c.nodeName()])return[];f||(f=0);b||(b=[]);for(var j=0,r=c[0].childNodes.length;j<r;j++){var p=new k(c[0].childNodes[j]);if("li"==p.nodeName()){var o={parent:c,indent:f,element:p,contents:[]};l?o.grandparent=l:(o.grandparent=c.parent(),o.grandparent&&"li"==o.grandparent.nodeName()&&(o.grandparent=o.grandparent.parent()));d&&p._4e_setMarker(d,"listarray_index",b.length,
void 0);b.push(o);for(var i=0,n=p[0].childNodes.length,v;i<n;i++)v=new k(p[0].childNodes[i]),v[0].nodeType==h.ELEMENT_NODE&&g[v.nodeName()]?a.listToArray(v,d,b,f+1,o.grandparent):o.contents.push(v)}}return b},arrayToList:function(c,d,b,m){b||(b=0);if(!c||c.length<b+1)return null;for(var l=c[b].parent[0].ownerDocument,j=l.createDocumentFragment(),r=null,p=b,o=Math.max(c[b].indent,0),i=null;;){var n=c[p];if(n.indent==o){if(!r||c[p].parent.nodeName()!=r.nodeName())r=c[p].parent.clone(!1),j.appendChild(r[0]);
for(var i=r[0].appendChild(n.element.clone(!1)[0]),v=0;v<n.contents.length;v++)i.appendChild(n.contents[v].clone(!0)[0]);p++}else if(n.indent==Math.max(o,0)+1)p=a.arrayToList(c,null,p,m),i.appendChild(p.listNode),p=p.nextIndex;else if(-1==n.indent&&!b&&n.grandparent){g[n.grandparent.nodeName()]?i=n.element.clone(!1)[0]:"td"!=n.grandparent.nodeName()?(i=l.createElement(m),n.element._4e_copyAttributes(new k(i))):i=l.createDocumentFragment();for(v=0;v<n.contents.length;v++)r=n.contents[v].clone(!0),
i.nodeType==h.DOCUMENT_FRAGMENT_NODE&&n.element._4e_copyAttributes(new k(r)),i.appendChild(r[0]);i.nodeType==h.DOCUMENT_FRAGMENT_NODE&&p!=c.length-1&&(i.lastChild&&i.lastChild.nodeType==h.ELEMENT_NODE&&"_moz"==i.lastChild.getAttribute("type")&&h._4e_remove(i.lastChild),h._4e_appendBogus(i));i.nodeType==h.ELEMENT_NODE&&h.nodeName(i)==m&&i.firstChild&&(h._4e_trim(i),r=i.firstChild,r.nodeType==h.ELEMENT_NODE&&h._4e_isBlockBoundary(r)&&(r=l.createDocumentFragment(),h._4e_moveChildren(i,r),i=r));r=h.nodeName(i);
!f.ie&&("div"==r||"p"==r)&&h._4e_appendBogus(i);j.appendChild(i);r=null;p++}else return null;if(c.length<=p||Math.max(c[p].indent,0)<o)break}if(d)for(c=new k(j.firstChild);c&&c[0];)c[0].nodeType==h.ELEMENT_NODE&&c._4e_clearMarkers(d,!0),c=c._4e_nextSourceNode();return{listNode:j,nextIndex:p}}};return a},{requires:["editor"]});
KISSY.add("editor/plugin/localStorage/index",function(d,g,k,h){if(!d.UA.ie&&window.localStorage)return window.localStorage;var f=g.Utils.debugUrl("plugin/localStorage/swfstore.swf?t="+ +new Date),a=new h({movie:f,flashVars:{useCompression:!0},methods:["setItem","removeItem","getItem","setMinDiskSpace","getValueOf"]});a.swf.height=138;var c=new k({width:"0px",prefixCls:"ks-editor-",elStyle:{overflow:"hidden"},content:"<h1 style='border:1px solid black;border-bottom:none;background:white;text-align:center;'>\u8bf7\u70b9\u51fb\u5141\u8bb8</h1>",
zIndex:g.baseZIndex(g.zIndexManager.STORE_FLASH_SHOW)});c.render();c.get("contentEl").append(a.swf);c.center();c.show();a.on("pending",function(){c.set("width",215);c.center();c.show();setTimeout(function(){a.retrySave()},1E3)});a.on("save",function(){c.set("width",0)});var e=a.setItem;d.mix(a,{_ke:1,getItem:function(a){return this.getValueOf(a)},retrySave:function(){this.setItem(this.lastSave.k,this.lastSave.v)},setItem:function(a,c){this.lastSave={k:a,v:c};e.call(this,a,c)}});a.on("contentReady",
function(){a._ready=1});return a},{attach:!1,requires:["editor","overlay","../flashBridge/"]});
KISSY.add("editor/plugin/maximize/cmd",function(d,g){function k(a){this.editor=a}var h=d.UA,f=h.ie,a=document,c=d.Node,e=d.Event,b=d.DOM,m;d.augment(k,{restoreWindow:function(){var a=this,b=a.editor;!1!==b.fire("beforeRestoreWindow")&&a._resize&&(e.remove(window,"resize",a._resize),a._resize=0,a._saveEditorStatus(),a._restoreState(),setTimeout(function(){a._restoreEditorStatus();b.notifySelectionChange();b.fire("afterRestoreWindow")},30))},_restoreState:function(){var c=this.editor,d=c.get("textarea"),
e=this._savedParents;if(e){for(var g=0;g<e.length;g++){var h=e[g];h.el.css("position",h.position)}this._savedParents=null}d.parent().css({height:this.iframeHeight});d.css({height:this.iframeHeight});b.css(a.body,{width:"",height:"",overflow:""});a.documentElement.style.overflow="";c=c.get("el")[0].style;c.position="static";c.width=this.editorElWidth;m.css({left:"-99999px",top:"-99999px"});window.scrollTo(this.scrollLeft,this.scrollTop);8>f&&this.editor.get("toolBarEl").removeClass("ks-editor-toolbar-padding",
void 0)},_saveSate:function(){var a=this.editor,c=[],d=a.get("el");this.iframeHeight=a.get("textarea").parent().style("height");this.editorElWidth=d.style("width");this.scrollLeft=b.scrollLeft();this.scrollTop=b.scrollTop();window.scrollTo(0,0);for(a=d.parent();a;)d=a.css("position"),"static"!=d&&(c.push({el:a,position:d}),a.css("position","static")),a=a.parent();this._savedParents=c;8>f&&this.editor.get("toolBarEl").addClass("ks-editor-toolbar-padding",void 0)},_saveEditorStatus:function(){var a=
this.editor;this.savedRanges=null;h.gecko&&a.__iframeFocus&&(this.savedRanges=(a=a.getSelection())&&a.getRanges())},_restoreEditorStatus:function(){var a=this.editor,b=a.getSelection(),c=this.savedRanges;h.gecko&&a.activateGecko();c&&b&&b.selectRanges(c);a.__iframeFocus&&b&&(a=b.getStartElement())&&a.scrollIntoView(void 0,!1)},_maximize:function(c){var d=this.editor,e=d.get("el"),h=b.viewportHeight(),k=b.viewportWidth(),i=d.get("textarea"),n=d.get("statusBarEl")?d.get("statusBarEl")[0].offsetHeight:
0,d=d.get("toolBarEl")[0].offsetHeight;f?a.body.style.overflow="hidden":b.css(a.body,{width:0,height:0,overflow:"hidden"});a.documentElement.style.overflow="hidden";e.css({position:"absolute",zIndex:g.baseZIndex(g.zIndexManager.MAXIMIZE),width:k+"px"});m.css({zIndex:g.baseZIndex(g.zIndexManager.MAXIMIZE-5),height:h+"px",width:k+"px"});e.offset({left:0,top:0});m.css({left:0,top:0});i.parent().css({height:h-n-d+"px"});i.css({height:h-n-d+"px"});!0!==c&&arguments.callee.call(this,!0)},_real:function(){var a=
this,b=a.editor;a._resize||(a._saveEditorStatus(),a._saveSate(),a._maximize(),a._resize||(a._resize=d.buffer(function(){a._maximize();b.fire("afterMaximizeWindow")},100)),e.on(window,"resize",a._resize),setTimeout(function(){a._restoreEditorStatus();b.notifySelectionChange();b.fire("afterMaximizeWindow")},30))},maximizeWindow:function(){!1!==this.editor.fire("beforeMaximizeWindow")&&(m||(m=(new c("<iframe  class='ks-editor-maximize-shim' style='position:absolute;top:-9999px;left:-9999px;' frameborder='0'>")).prependTo(a.body,
void 0)),this._real())},destroy:function(){this._resize&&(e.remove(window,"resize",this._resize),this._resize=0)}});return{init:function(a){if(!a.hasCommand("maximizeWindow")){var b=new k(a);a.addCommand("maximizeWindow",{exec:function(){b.maximizeWindow()}});a.addCommand("restoreWindow",{exec:function(){b.restoreWindow()}})}}}},{requires:["editor"]});
KISSY.add("editor/plugin/maximize/index",function(d,g,k){function h(){}d.augment(h,{renderUI:function(d){k.init(d);d.addButton("maximize",{tooltip:"\u5168\u5c4f",listeners:{click:function(){this.get("checked")?(d.execCommand("maximizeWindow"),this.set("tooltip","\u53d6\u6d88\u5168\u5c4f"),this.set("contentCls","restore")):(d.execCommand("restoreWindow"),this.set("tooltip","\u5168\u5c4f"),this.set("contentCls","maximize"));d.focus()}},checkable:!0})}});return h},{requires:["editor","./cmd"]});
KISSY.add("editor/plugin/menubutton/index",function(d,g,k){g.prototype.addSelect=function(h,f,a){var a=a||k.Select,c=this.get("prefixCls")+"editor-";f&&(f.editor=this,f.menu&&(f.menu.zIndex=g.baseZIndex(g.zIndexManager.SELECT),f.menu.xclass="popupmenu",d.each(f.menu.children,function(a){a.xclass="option"})));var e=new a(d.mix({elAttrs:{hideFocus:"hideFocus"},render:this.get("toolBarEl"),prefixCls:c,autoRender:!0},f));e.get("el").unselectable();f.mode==g.WYSIWYG_MODE&&(this.on("wysiwygMode",function(){e.set("disabled",
false)}),this.on("sourceMode",function(){e.set("disabled",true)}));this.addControl(h+"/select",e);return e};return k},{requires:["editor","menubutton"]});KISSY.add("editor/plugin/multipleUpload/index",function(d,g,k){function h(d){this.config=d||{}}d.augment(h,{renderUI:function(d){var a=this;d.addButton("multipleUpload",{tooltip:"\u6279\u91cf\u63d2\u56fe",listeners:{click:function(){k.useDialog(d,"multipleUpload",a.config)}},mode:g.WYSIWYG_MODE})}});return h},{requires:["editor","../dialogLoader/"]});
KISSY.add("editor/plugin/orderedList/cmd",function(d,g,k){var h=k.queryActive,f=new k.ListCommand("ol");return{init:function(a){a.hasCommand("insertOrderedList")||a.addCommand("insertOrderedList",{exec:function(a){a.focus();f.exec(a)}});var c=g.Utils.getQueryCmd("insertOrderedList");a.hasCommand(c)||a.addCommand(c,{exec:function(a){if((a=a.getSelection())&&!a.isInvalid)return a=a.getStartElement(),a=new g.ElementPath(a),h("ol",a)}})}}},{requires:["editor","../listUtils/cmd"]});
KISSY.add("editor/plugin/orderedList/index",function(d,g,k,h){function f(){}d.augment(f,{renderUI:function(a){h.init(a);a.addButton("orderedList",{cmdType:"insertOrderedList",mode:g.WYSIWYG_MODE},k)}});return f},{requires:["editor","../listUtils/btn","./cmd"]});
KISSY.add("editor/plugin/outdent/cmd",function(d,g,k){var h=k.addCommand,f=k.checkOutdentActive;return{init:function(a){h(a,"outdent");var c=g.Utils.getQueryCmd("outdent");a.hasCommand(c)||a.addCommand(c,{exec:function(a){if((a=a.getSelection())&&!a.isInvalid)return a=a.getStartElement(),a=new g.ElementPath(a),f(a)}})}}},{requires:["editor","../dentUtils/cmd"]});
KISSY.add("editor/plugin/outdent/index",function(d,g,k){function h(){}d.augment(h,{renderUI:function(d){k.init(d);d.addButton("outdent",{tooltip:"\u51cf\u5c11\u7f29\u8fdb\u91cf ",listeners:{click:function(){d.execCommand("outdent");d.focus()},afterSyncUI:function(){var a=this;d.on("selectionChange",function(){d.get("mode")!=g.SOURCE_MODE&&(d.queryCommandValue("outdent")?a.set("disabled",!1):a.set("disabled",!0))})}},mode:g.WYSIWYG_MODE})}});return h},{requires:["editor","./cmd"]});
KISSY.add("editor/plugin/overlay/index",function(d,g,k,h){var f=k.extend({bindUI:function(){h.init(this)}},{ATTRS:{prefixCls:{value:"ks-editor-"},zIndex:{value:g.baseZIndex(g.zIndexManager.OVERLAY)}}});f.Dialog=k.Dialog.extend({bindUI:function(){h.init(this)},show:function(){this.center();var a=this.get("y");200<a-d.DOM.scrollTop()&&(a=d.DOM.scrollTop()+200,this.set("y",a));f.prototype.show.call(this)}},{ATTRS:{elAttrs:{value:{hideFocus:"hideFocus"}},prefixCls:{value:"ks-editor-"},zIndex:{value:g.baseZIndex(g.zIndexManager.OVERLAY)},
draggable:{value:!0},constrain:{value:!0},aria:{value:!0}}});return f},{requires:["editor","overlay","../focusFix/","dd"]});
KISSY.add("editor/plugin/pageBreak/index",function(d,g,k){function h(){}var f=d.Node;d.augment(h,{renderUI:function(a){k.init(a);var c=a.htmlDataProcessor;(c&&c.dataFilter).addRules({tags:{div:function(a){var b=a.getAttribute("style"),d;if(b)for(var f=a.childNodes,g=0;g<f.length;g++)1==f[g].nodeType&&(d=f[g]);if((d=d&&"span"==d.nodeName&&d.getAttribute("style"))&&/page-break-after\s*:\s*always/i.test(b)&&/display\s*:\s*none/i.test(d))return c.createFakeParserElement(a,"ke_pagebreak","div")}}});a.addButton("pageBreak",
{tooltip:"\u5206\u9875",listeners:{click:function(){var c=new f('<div style="page-break-after: always; "><span style="DISPLAY:none">&nbsp;</span></div>',null,a.get("document")[0]),c=a.createFakeElement(c,"ke_pagebreak","div",!1,'<div style="page-break-after: always; "><span style="DISPLAY:none">&nbsp;</span></div>');a.focus();var b=a.getSelection();if(b=b&&b.getRanges()[0]){a.execCommand("save");for(var d=b.startContainer,g=d;"body"!==d.nodeName();)g=d,d=d.parent();b.collapse(!0);b.splitElement(g);c.insertAfter(g);
a.execCommand("save")}}},mode:g.WYSIWYG_MODE})}});return h},{requires:["editor","../fakeObjects/"]});
KISSY.add("editor/plugin/preview/index",function(d){function g(){}var k=window;d.augment(g,{renderUI:function(d){d.addButton("preview",{tooltip:"\u9884\u89c8",listeners:{click:function(){try{var f=k.screen,a=Math.round(0.8*f.width),c=Math.round(0.7*f.height),e=Math.round(0.1*f.width)}catch(b){a=640,c=420,e=80}f=d.getDocHtml().replace(/\${title}/,"\u9884\u89c8");a=k.open("","","toolbar=yes,location=no,status=yes,menubar=yes,scrollbars=yes,resizable=yes,width="+a+",height="+c+",left="+e);c=a.document;c.open();c.write(f);
c.close();a.focus()}}})}});return g});
KISSY.add("editor/plugin/progressbar/index",function(d){function g(){g.superclass.constructor.apply(this,arguments);this._init()}var k=d.Node;g.ATTRS={container:{},width:{},height:{},progress:{value:0}};d.extend(g,d.Base,{destroy:function(){this.detach();this.el.remove()},_init:function(){var d=this.get("height"),f=new k("<div class='ks-editor-progressbar'  style='width:"+this.get("width")+";height:"+d+";'></div>"),a=this.get("container"),d=(new k("<div style='overflow:hidden;'><div class='ks-editor-progressbar-inner' style='height:"+(parseInt(d)-
4)+"px'><div class='ks-editor-progressbar-inner-bg'></div></div></div>")).appendTo(f),c=(new k("<span class='ks-editor-progressbar-title'></span>")).appendTo(f);a&&f.appendTo(a);this.el=f;this._title=c;this._p=d;this.on("afterProgressChange",this._progressChange,this);this._progressChange({newVal:this.get("progress")})},_progressChange:function(d){d=d.newVal;this._p.css("width",d+"%");this._title.html(d+"%")}});return g});
KISSY.add("editor/plugin/removeFormat/cmd",function(d,g){function k(a,c){for(var d=0;d<c.length;d++)a.removeAttr(c[d])}var h=g.RANGE,f=g.ElementPath,a=d.DOM,c="class,style,lang,width,height,align,hspace,valign".split(/,/),e=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");return{init:function(b){b.hasCommand("removeFormat")||b.addCommand("removeFormat",{exec:function(){b.focus();e.lastIndex=0;var d=b.getSelection().getRanges();
b.execCommand("save");for(var g=0,j;j=d[g];g++)if(!j.collapsed){j.enlarge(h.ENLARGE_ELEMENT);var r=j.createBookmark(),p=r.startNode,o=r.endNode,i=function(a){for(var b=new f(a),c=b.elements,d=1,g;(g=c[d])&&!g.equals(b.block)&&!g.equals(b.blockLimit);d++)e.test(g.nodeName())&&a._4e_breakParent(g)};i(p);i(o);for(p=p._4e_nextSourceNode(!0,a.ELEMENT_NODE,void 0,void 0);p&&!p.equals(o);)i=p._4e_nextSourceNode(!1,a.ELEMENT_NODE,void 0,void 0),"img"==p.nodeName()&&(p.attr("_ke_realelement")||/\bke_/.test(p[0].className))||
(e.test(p.nodeName())?p._4e_remove(!0):k(p,c)),p=i;j.moveToBookmark(r)}b.getSelection().selectRanges(d);b.execCommand("save")}})}}},{requires:["editor"]});KISSY.add("editor/plugin/removeFormat/index",function(d,g,k){function h(){}d.augment(h,{renderUI:function(d){k.init(d);d.addButton("removeFormat",{tooltip:"\u6e05\u9664\u683c\u5f0f",listeners:{click:function(){d.execCommand("removeFormat")}},mode:g.WYSIWYG_MODE})}});return h},{requires:["editor","./cmd","../button/"]});
KISSY.add("editor/plugin/resize/index",function(d,g,k){function h(a){this.config=a||{}}var f=d.Node;d.augment(h,{renderUI:function(a){var c=k.Draggable,e=a.get("statusBarEl");a.get("textarea");var b=this.config.direction||["x","y"],g="se-resize";1==b.length&&(g="x"==b[0]?"e-resize":"s-resize");var h=(new f("<div class='ks-editor-resizer' style='cursor: "+g+"'></div>")).appendTo(e);a.on("maximizeWindow",function(){h.css("display","none")});a.on("restoreWindow",function(){h.css("display","")});var j=
new c({node:h}),r=0,p=0,o=a.get("el"),i=a.get("el");j.on("dragstart",function(){r=o.height();p=i.width();a.fire("resizeStart")});j.on("drag",function(c){var e=c.left-this.startNodePos.left,c=c.top-this.startNodePos.top;d.inArray("y",b)&&a.set("height",r+c);d.inArray("x",b)&&a.set("width",p+e);a.fire("resize")});a.on("destroy",function(){j.destroy();h.remove()})}});return h},{requires:["editor","dd"]});
KISSY.add("editor/plugin/separator/index",function(d){function g(){}d.augment(g,{renderUI:function(g){d.all('<span class="ks-editor-toolbar-separator">&nbsp;</span>').appendTo(g.get("toolBarEl"))}});return g},{requires:["editor"]});
KISSY.add("editor/plugin/smiley/index",function(d,g,k){function h(){}for(var f="<div class='ks-editor-smiley-sprite'>",a=0;98>=a;a++)f+="<a href='javascript:void(0)' data-icon='http://a.tbcdn.cn/sys/wangwang/smiley/48x48/"+a+".gif'></a>";f+="</div>";d.augment(h,{renderUI:function(a){a.addButton("smiley",{tooltip:"\u63d2\u5165\u8868\u60c5",checkable:!0,listeners:{afterSyncUI:function(){var a=this;a.on("blur",function(){setTimeout(function(){a.smiley&&a.smiley.hide()},150)})},click:function(){var e=this,b;if(e.get("checked")){if(!(b=
e.smiley))b=e.smiley=new k({content:f,focus4e:!1,width:"297px",autoRender:!0,elCls:"ks-editor-popup",zIndex:g.baseZIndex(g.zIndexManager.POPUP_MENU),mask:!1}),b.get("el").on("click",function(b){var b=new d.Node(b.target),e;if("a"==b.nodeName()&&(e=b.attr("data-icon")))e=new d.Node("<img alt='' src='"+e+"'/>",null,a.get("document")[0]),a.insertElement(e)}),b.on("hide",function(){e.set("checked",!1)});b.set("align",{node:this.get("el"),points:["bl","tl"]});b.show()}else e.smiley&&e.smiley.hide()},destroy:function(){this.smiley&&
this.smiley.destroy()}},mode:g.WYSIWYG_MODE})}});return h},{requires:["editor","../overlay/"]});
KISSY.add("editor/plugin/sourceArea/index",function(d,g){function k(){}var h=g.SOURCE_MODE,f=g.WYSIWYG_MODE;d.augment(k,{renderUI:function(a){a.addButton("sourceArea",{tooltip:"\u6e90\u7801",listeners:{afterSyncUI:function(){var c=this;a.on("wysiwygMode",function(){c.set("checked",!1)});a.on("sourceMode",function(){c.set("checked",!0)})},click:function(){this.get("checked")?a.set("mode",h):a.set("mode",f)}},checkable:!0})}});return k},{requires:["editor","../button/"]});
KISSY.add("editor/plugin/strikeThrough/cmd",function(d,g,k){var h=new g.Style({element:"del",overrides:[{element:"span",attributes:{style:"text-decoration: line-through;"}},{element:"s"},{element:"strike"}]});return{init:function(d){k.addButtonCmd(d,"strikeThrough",h)}}},{requires:["editor","../font/cmd"]});
KISSY.add("editor/plugin/strikeThrough/index",function(d,g,k,h){function f(){}d.augment(f,{renderUI:function(a){h.init(a);a.addButton("strikeThrough",{cmdType:"strikeThrough",tooltip:"\u5220\u9664\u7ebf "},k.Button)}});return f},{requires:["editor","../font/ui","./cmd"]});
KISSY.add("editor/plugin/table/index",function(d,g,k){function h(a){function b(a){!(0<e.length)&&a[0].nodeType==o.ELEMENT_NODE&&v.test(a.nodeName())&&!a.data("selected_cell")&&(a._4e_setMarker(f,"selected_cell",!0,void 0),e.push(a))}for(var c=a.createBookmarks(),d=a.getRanges(),e=[],f={},h=0;h<d.length;h++){var i=d[h];if(i.collapsed)i=i.getCommonAncestor(),(i=i.closest("td",void 0)||i.closest("th",void 0))&&e.push(i);else{var i=new Walker(i),j;for(i.guard=b;j=i.next();)if((j=j.parent())&&v.test(j.nodeName())&&
!j.data("selected_cell"))j._4e_setMarker(f,"selected_cell",!0,void 0),e.push(j)}}g.Utils.clearAllMarkers(f);a.selectBookmarks(c);return e}function f(a,b){var c=a.getStartElement().parent("tr");if(c){var d=c.clone(!0);d.insertBefore(c);c=(b?d[0]:c[0]).cells;for(d=0;d<c.length;d++)c[d].innerHTML="",p.ie||(new i(c[d]))._4e_appendBogus(void 0)}}function a(b){if(b instanceof g.Selection){for(var c=h(b),d=c.length,b=[],e,f,j=0;j<d;j++){var k=c[j].parent(),l=k[0].rowIndex;!j&&(e=l-1);b[l]=k;j==d-1&&(f=l+
1)}j=k.parent("table");e=new i(f<j[0].rows.length&&j[0].rows[f]||0<e&&j[0].rows[e]||j[0].parentNode);for(j=b.length;0<=j;j--)b[j]&&a(b[j]);return e}b instanceof i&&(j=b.parent("table"),1==j[0].rows.length?j.remove():b.remove());return 0}function c(a,b){var c=a.getStartElement();if(c=c.closest("td",void 0)||c.closest("th",void 0))for(var d=c.parent("table"),e=c[0].cellIndex,f=0;f<d[0].rows.length;f++){var g=d[0].rows[f];g.cells.length<e+1||(c=new i(g.cells[e].cloneNode(void 0)),p.ie||c._4e_appendBogus(void 0),
g=new i(g.cells[e]),b?c.insertBefore(g):c.insertAfter(g))}}function e(b){if(b instanceof g.Selection){var c=h(b),d,f=[],b=c[0]&&c[0].parent("table"),j,k,l;j=0;for(k=c.length;j<k;j++)f.push(c[j][0].cellIndex);f.sort();j=1;for(k=f.length;j<k;j++)if(1<f[j]-f[j-1]){l=f[j-1]+1;break}l||(l=0<f[0]?f[0]-1:f[f.length-1]+1);f=b[0].rows;j=0;for(k=f.length;j<k&&!(d=f[j].cells[l]);j++);d=d?new i(d):b.prev();for(l=c.length-1;0<=l;l--)c[l]&&e(c[l]);return d}if(b instanceof i){c=b.parent("table");if(!c)return null;
d=b[0].cellIndex;for(l=c[0].rows.length-1;0<=l;l--)b=new i(c[0].rows[l]),!d&&1==b[0].cells.length?a(b):b[0].cells[d]&&b[0].removeChild(b[0].cells[d])}return null}function b(a,b){var c=new g.Range(a[0].ownerDocument);if(!c.moveToElementEditablePosition(a,b?!0:void 0))c.selectNodeContents(a),c.collapse(b?!1:!0);c.select(!0)}function m(a){var b=(a=a.getSelection())&&a.getStartElement(),c=b&&b.closest("table",void 0);if(c)return a=b.closest(function(a){var b=o.nodeName(a);return c.contains(a)&&("td"==
b||"th"==b)},void 0),b=b.closest(function(a){var b=o.nodeName(a);return c.contains(a)&&"tr"==b},void 0),{table:c,td:a,tr:b}}function l(a){return(a=m(a))&&a.td}function j(a){return(a=m(a))&&a.tr}function r(a){this.config=a||{}}var p=d.UA,o=d.DOM,i=d.Node,n=["tr","th","td","tbody","table"],v=/^(?:td|th)$/,x={"\u8868\u683c\u5c5e\u6027":m,"\u5220\u9664\u8868\u683c":l,"\u5220\u9664\u5217":l,"\u5220\u9664\u884c":j,"\u5728\u4e0a\u65b9\u63d2\u5165\u884c":j,"\u5728\u4e0b\u65b9\u63d2\u5165\u884c":j,"\u5728\u5de6\u4fa7\u63d2\u5165\u5217":l,"\u5728\u53f3\u4fa7\u63d2\u5165\u5217":l},t=(6===p.ie?["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;}".split(";")).join("").replace(/%2/g,
"ke_show_border"),q={tags:{table:function(a){var b=a.getAttribute("class"),c=parseInt(a.getAttribute("border"),10);if(!c||0>=c)a.setAttribute("class",d.trim((b||"")+" ke_show_border"))}}},u={tags:{table:function(a){var b=a.getAttribute("class");b&&((b=d.trim(b.replace("ke_show_border","")))?a.setAttribute("class",b):a.removeAttribute("class"))}}};d.augment(r,{renderUI:function(h){h.addCustomStyle(t);var i=h.htmlDataProcessor,j=i&&i.htmlFilter;(i&&i.dataFilter).addRules(q);j.addRules(u);var l=this,
p={"\u8868\u683c\u5c5e\u6027":function(){this.hide();var a=m(h);a&&k.useDialog(h,"table",l.config,{selectedTable:a.table,selectedTd:a.td})},"\u5220\u9664\u8868\u683c":function(){this.hide();var a=h.getSelection(),b=a&&a.getStartElement();if(b=b&&b.closest("table",void 0)){h.execCommand("save");a.selectElement(b);var c=a.getRanges()[0];c.collapse();a.selectRanges([c]);a=b.parent();1==a[0].childNodes.length&&"body"!=a.nodeName()&&"td"!=a.nodeName()?a.remove():b.remove();h.execCommand("save")}},"\u5220\u9664\u884c ":function(){this.hide();h.execCommand("save");
var c=h.getSelection();b(a(c),void 0);h.execCommand("save")},"\u5220\u9664\u5217 ":function(){this.hide();h.execCommand("save");var a=h.getSelection();(a=e(a))&&b(a,!0);h.execCommand("save")},"\u5728\u4e0a\u65b9\u63d2\u5165\u884c":function(){this.hide();h.execCommand("save");var a=h.getSelection();f(a,!0);h.execCommand("save")},"\u5728\u4e0b\u65b9\u63d2\u5165\u884c":function(){this.hide();h.execCommand("save");var a=h.getSelection();f(a,void 0);h.execCommand("save")},"\u5728\u5de6\u4fa7\u63d2\u5165\u5217":function(){this.hide();h.execCommand("save");var a=h.getSelection();c(a,!0);h.execCommand("save")},
"\u5728\u53f3\u4fa7\u63d2\u5165\u5217":function(){this.hide();h.execCommand("save");var a=h.getSelection();c(a,void 0);h.execCommand("save")}},r=[];d.each(p,function(a,b){r.push({content:b})});h.addContextMenu("table",function(a){if(d.inArray(o.nodeName(a),n))return!0},{width:"120px",children:r,listeners:{click:function(a){a=a.target.get("content");p[a]&&p[a].apply(this)},beforeVisibleChange:function(a){if(a.newVal){var b=this,a=b.get("children"),c=b.get("editor");d.each(a,function(a){var d=a.get("content");!x[d]||x[d].call(b,
c)?a.set("disabled",!1):a.set("disabled",!0)})}}}});h.addButton("table",{mode:g.WYSIWYG_MODE,listeners:{click:function(){k.useDialog(h,"table",l.config,{selectedTable:0,selectedTd:0})}},tooltip:"\u63d2\u5165\u8868\u683c"})}});return r},{requires:["editor","../dialogLoader/","../contextmenu/"]});
KISSY.add("editor/plugin/underline/cmd",function(d,g,k){var h=new g.Style({element:"u",overrides:[{element:"span",attributes:{style:"text-decoration: underline;"}}]});return{init:function(d){k.addButtonCmd(d,"underline",h)}}},{requires:["editor","../font/cmd"]});
KISSY.add("editor/plugin/underline/index",function(d,g,k,h){function f(){}d.augment(f,{renderUI:function(a){h.init(a);a.addButton("underline",{cmdType:"underline",tooltip:"\u4e0b\u5212\u7ebf "},k.Button);a.docReady(function(){a.get("document").on("keydown",function(c){c.ctrlKey&&c.keyCode==d.Node.KeyCodes.U&&(a.execCommand("underline"),c.preventDefault())})})}});return f},{requires:["editor","../font/ui","./cmd"]});
KISSY.add("editor/plugin/undo/btn",function(d,g,k){d=k.extend({bindUI:function(){var d=this,f=d.get("editor");d.on("click",function(){f.execCommand("undo")});f.on("afterUndo afterRedo afterSave",function(a){0<a.index?d.set("disabled",!1):d.set("disabled",!0)})}},{ATTRS:{mode:{value:g.WYSIWYG_MODE},disabled:{value:!0}}});return{RedoBtn:k.extend({bindUI:function(){var d=this,f=d.get("editor");d.on("click",function(){f.execCommand("redo")});f.on("afterUndo afterRedo afterSave",function(a){a.index<a.history.length-
1?d.set("disabled",!1):d.set("disabled",!0)})}},{mode:{value:g.WYSIWYG_MODE},ATTRS:{disabled:{value:!0}}}),UndoBtn:d}},{requires:["editor","../button/"]});
KISSY.add("editor/plugin/undo/cmd",function(d,g){function k(a){var c=a.get("document")[0].body.innerHTML,d;c&&(d=a.getSelection());this.contents=c;this.bookmarks=d&&d.createBookmarks2(!0)}function h(a){this.history=[];this.index=-1;this.editor=a;this.bufferRunner=d.buffer(this.save,500,this);this._init()}var f=g.Utils.arrayCompare,a=d.UA;d.augment(k,{equals:function(a){if(this.contents!=a.contents)return!1;var c=this.bookmarks,a=a.bookmarks;if(c||a){if(!c||!a||c.length!=a.length)return!1;for(var d=
0;d<c.length;d++){var e=c[d],g=a[d];if(e.startOffset!=g.startOffset||e.endOffset!=g.endOffset||!f(e.start,g.start)||!f(e.end,g.end))return!1}}return!0}});var c={16:1,17:1,18:1},e={37:1,38:1,39:1,40:1,33:1,34:1};d.augment(h,{_keyMonitor:function(){var a=this,d=a.editor;d.docReady(function(){d.get("document").on("keydown",function(f){var g=f.keyCode;g in e||g in c||(90===g&&(f.ctrlKey||f.metaKey)?(!1!==d.fire("beforeRedo")&&a.restore(-1),f.halt()):89===g&&(f.ctrlKey||f.metaKey)?(!1!==d.fire("beforeUndo")&&
a.restore(1),f.halt()):!1!==d.fire("beforeSave",{buffer:1})&&a.save(1))})})},_init:function(){var a=this;a._keyMonitor();setTimeout(function(){a.save()},0)},save:function(a){var c=this.editor;if(c.get("mode")==g.WYSIWYG_MODE&&c.get("document"))if(a)this.bufferRunner();else{var a=this.history,d=this.index;a.length>d+1&&a.splice(d+1,a.length-d-1);var d=a[a.length-1],e=new k(c);if(!d||!d.equals(e))30===a.length&&a.shift(),a.push(e),this.index=d=a.length-1,c.fire("afterSave",{history:a,index:d})}},restore:function(b){if(this.editor.get("mode")==
g.WYSIWYG_MODE){var c=this.history,d=this.editor,e=d.get("document")[0].body,f=c[this.index+b];f&&(e.innerHTML=f.contents,f.bookmarks?d.getSelection().selectBookmarks(f.bookmarks):a.ie&&(e=e.createTextRange(),e.collapse(!0),e.select()),(e=d.getSelection())&&e.scrollIntoView(),this.index+=b,d.fire(0<b?"afterUndo":"afterRedo",{history:c,index:this.index}),d.notifySelectionChange());return f}}});return{init:function(a){if(!a.hasCommand("save")){var c=new h(a);a.addCommand("save",{exec:function(d,e){a.focus();
c.save(e)}});a.addCommand("undo",{exec:function(){a.focus();c.restore(-1)}});a.addCommand("redo",{exec:function(){a.focus();c.restore(1)}})}}}},{requires:["editor"]});KISSY.add("editor/plugin/undo/index",function(d,g,k,h){function f(){}d.augment(f,{renderUI:function(a){h.init(a);a.addButton("undo",{mode:g.WYSIWYG_MODE,tooltip:"\u64a4\u9500",editor:a},k.UndoBtn);a.addButton("redo",{mode:g.WYSIWYG_MODE,tooltip:"\u91cd\u505a",editor:a},k.RedoBtn)}});return f},{requires:["editor","./btn","./cmd"]});
KISSY.add("editor/plugin/unorderedList/cmd",function(d,g,k){var h=k.queryActive,f=new k.ListCommand("ul");return{init:function(a){a.hasCommand("insertUnorderedList")||a.addCommand("insertUnorderedList",{exec:function(a){a.focus();f.exec(a)}});var c=g.Utils.getQueryCmd("insertUnorderedList");a.hasCommand(c)||a.addCommand(c,{exec:function(a){if((a=a.getSelection())&&!a.isInvalid)return a=a.getStartElement(),a=new g.ElementPath(a),h("ul",a)}})}}},{requires:["editor","../listUtils/cmd"]});
KISSY.add("editor/plugin/unorderedList/index",function(d,g,k,h){function f(){}d.augment(f,{renderUI:function(a){h.init(a);a.addButton("unorderedList",{cmdType:"insertUnorderedList",mode:g.WYSIWYG_MODE},k)}});return f},{requires:["editor","../listUtils/btn","./cmd"]});
KISSY.add("editor/plugin/video/index",function(d,g,k,h,f){function a(a){this.config=a}d.augment(a,{renderUI:function(a){function d(a){for(var b=0;b<l.length;b++){var c=l[b];if(c.reg.test(a))return c}}f.init(a);var b=a.htmlDataProcessor,m=b&&b.dataFilter,l=[],j=this.config;j.providers&&l.push.apply(l,j.providers);j.getProvider=d;m&&m.addRules({tags:{object:function(a){var c=a.getAttribute("classid"),f=a.childNodes;if(!c){for(c=0;c<f.length;c++)if("embed"==f[c].nodeName){if(!k.isFlashEmbed(f[c]))break;
if(d(f[c].getAttribute("src")))return b.createFakeParserElement(a,"ke_video","video",!0)}return null}for(c=0;c<f.length;c++){var g=f[c];if("param"==g.nodeName&&"movie"==g.getAttribute("name").toLowerCase()&&d(g.getAttribute("value")))return b.createFakeParserElement(a,"ke_video","video",!0)}},embed:function(a){if(!k.isFlashEmbed(a))return null;if(d(a.getAttribute("src")))return b.createFakeParserElement(a,"ke_video","video",!0)}}},4);var r=new h({editor:a,cls:"ke_video",type:"video",pluginConfig:this.config,
bubbleId:"video",contextMenuId:"video",contextMenuHandlers:{"\u89c6\u9891\u5c5e\u6027":function(){var a=this.get("editorSelectedEl");a&&r.show(a)}}});a.addButton("video",{tooltip:"\u63d2\u5165\u89c6\u9891",listeners:{click:function(){r.show()}},mode:g.WYSIWYG_MODE})}});return a},{requires:["editor","../flashCommon/utils","../flashCommon/baseClass","../fakeObjects/"]});
KISSY.add("editor/plugin/xiamiMusic/index",function(d,g,k,h,f){function a(){a.superclass.constructor.apply(this,arguments)}function c(a){this.config=a||{}}d.extend(a,k,{_updateTip:function(a,b){var c=this.get("editor").restoreRealElement(b);c&&(a.html(b.attr("title")),a.attr("href",this._getFlashUrl(c)))}});d.augment(c,{renderUI:function(c){function b(a){return/xiami\.com/i.test(a)}f.init(c);var d=c.htmlDataProcessor,k=d&&d.dataFilter;k&&k.addRules({tags:{object:function(a){var c=a.getAttribute("title"),
e,f;e=a.getAttribute("classid");var g=a.childNodes;if(!e){for(e=0;e<g.length;e++)if(f=g[e],"embed"==f.nodeName){if(!h.isFlashEmbed(f))break;if(b(f.attributes.src))return d.createFakeParserElement(a,"ke_xiami","xiamiMusic",!0,{title:c})}return null}for(e=0;e<g.length;e++)if(f=g[e],"param"==f.nodeName&&"movie"==f.getAttribute("name")&&b(f.getAttribute("value")))return d.createFakeParserElement(a,"ke_xiami","xiamiMusic",!0,{title:c})},embed:function(a){if(h.isFlashEmbed(a)&&b(a.getAttribute("src")))return d.createFakeParserElement(a,
"ke_xiami","xiamiMusic",!0,{title:a.getAttribute("title")})}}},4);var j=new a({editor:c,cls:"ke_xiami",type:"xiamiMusic",bubbleId:"xiami",pluginConfig:this.config,contextMenuId:"xiami",contextMenuHandlers:{"\u867e\u7c73\u5c5e\u6027":function(){var a=this.get("editorSelectedEl");a&&j.show(a)}}});c.addButton("xiamiMusic",{tooltip:"\u63d2\u5165\u867e\u7c73\u97f3\u4e50",listeners:{click:function(){j.show()}},mode:g.WYSIWYG_MODE})}});return c},{requires:["editor","../flashCommon/baseClass","../flashCommon/utils","../fakeObjects/"]});
KISSY.add("editor/full",function(d,g){return g},{requires:["editor"]});
