KISSY.Editor.add("smiley/support",function(){function k(){if(e)return e;e="<div class='ke-smiley-sprite'>";for(var a=0;a<=98;a++)e+="<a href='#' data-icon='http://a.tbcdn.cn/sys/wangwang/smiley/48x48/"+a+".gif'></a>";e+="</div>";return e}var f=KISSY,h=f.Event,d=f.Editor,i=f.DOM;i.addStyleSheet('.ke-smiley-sprite { background: url("http://a.tbcdn.cn/sys/wangwang/smiley/sprite.png") no-repeat scroll -1px 0 transparent; height: 235px; width: 288px; margin: 5px;zoom: 1; overflow: hidden;}.ke-smiley-sprite a {   width: 24px;height: 24px; border: 1px solid white; float: left;}.ke-smiley-sprite a:hover { border: 1px solid #808080;}',
"smiley");var e,l=d.Utils.addRes,m=d.Utils.destroyRes;d.SmileySupport={_selectSmiley:function(a){a.halt();var b=this.editor;a=new f.Node(a.target);var c;if(a._4e_name()=="a"&&(c=a.attr("data-icon"))){c=new f.Node("<img alt='' src='"+c+"'/>",null,b.document);b.insertElement(c);this.smileyWin.hide()}},_hidePanel:function(a){var b=this.btn.get("el");a=new f.Node(a.target);var c=this.smileyWin;b._4e_equals(a)||b.contains(a)||c.hide()},_prepare:function(){var a=this,b=a.cfg,c=a.btn,j=a.editor,g=k();a.smileyWin=
new d.Overlay({content:g,focus4e:false,width:"297px",autoRender:true,elCls:"ks-popup",zIndex:d.baseZIndex(d.zIndexManager.POPUP_MENU),mask:false});g=a.smileyWin;a.smileyPanel=g.get("contentEl");g.on("show",c.bon,c);g.on("hide",c.boff,c);a.smileyPanel.on("click",b._selectSmiley,a);h.on(document,"click",b._hidePanel,a);h.on(j.document,"click",b._hidePanel,a);a.cfg._prepare=a.cfg._real;l.call(a,a.smileyWin,a.smileyPanel,function(){h.remove(document,"click",b._hidePanel,a);h.remove(j.document,"click",
b._hidePanel,a)});a.call("_real")},_real:function(){var a=this.btn.get("el"),b=a.offset();b.top+=a.height()+5;if(b.left+this.smileyPanel.width()>i.viewportWidth()-60)b.left=i.viewportWidth()-this.smileyPanel.width()-60;this.smileyWin.set("xy",[b.left,b.top]);this.smileyWin.show()},offClick:function(){var a=this;d.use("overlay",function(){a.call("_prepare")})},onClick:function(){this.smileyWin&&this.smileyWin.hide()},destroy:function(){m.call(this)}}},{attach:false});
