KISSY.Editor.add("flash/support",function(){function e(a){this.editor=a;this._init()}function n(a){return a._4e_name()==="img"&&!!a.hasClass(l)&&a}var j=KISSY,g=j.Editor,t=j.UA,p=j.Event,u=g.ContextMenu,v=j.Node,o=g.BubbleView,l="ke_flash",q=g.Utils.flash;j.augment(e,{_config:function(){this._cls=l;this._type="flash";this._contextMenu=w;this._flashRules=["img."+l]},_init:function(){this._config();var a=this,b=a.editor,c={},d=a._contextMenu;if(d)for(var f in d)(function(h){c[h]=function(){d[h](a)}})(f);
a._contextMenu=u.register({editor:b,rules:a._flashRules,width:"120px",funcs:c});o.attach({pluginName:a._type,editor:a.editor,pluginContext:a});p.on(b.document,"dblclick",a._dbclick,a)},_getFlashUrl:function(a){return q.getUrl(a)},_updateTip:function(a,b){var c=this.editor.restoreRealElement(b);if(c){c=this._getFlashUrl(c);a.html(c);a.attr("href",c)}},_dbclick:function(a){var b=new v(a.target);if(b._4e_name()==="img"&&b.hasClass(this._cls)){this.show(null,b);a.halt()}},show:function(a,b){this.editor.useDialog(this._type+
"/dialog",function(c){c.show(b)})},destroy:function(){var a=this.editor;this._contextMenu.destroy();o.destroy(this._type);p.remove(a.document,"dblclick",this._dbclick,this);a.destroyDialog(this._type+"/dialog")}});g.Flash=e;e.registerBubble=function(a,b,c){o.register({pluginName:a,func:c,init:function(){var d=this,f=d.get("contentEl");f.html(b+' <a class="ke-bubbleview-url" target="_blank" href="#"></a> -  <span class="ke-bubbleview-link ke-bubbleview-change">\u7f16\u8f91</span> -  <span class="ke-bubbleview-link ke-bubbleview-remove">\u5220\u9664</span>');
var h=f.one(".ke-bubbleview-url"),k=f.one(".ke-bubbleview-change"),r=f.one(".ke-bubbleview-remove");g.Utils.preventFocus(f);k.on("click",function(i){d._plugin.show(null,d._selectedEl);i.halt()});r.on("click",function(i){var s=d._plugin;if(t.webkit){var m=s.editor.getSelection().getRanges();m&&m[0]&&(m[0].collapse(true)||1)&&m[0].select()}d._selectedEl._4e_remove();d.hide();s.editor.notifySelectionChange();i.halt()});g.Utils.addRes.call(d,k,r);d.on("show",function(){var i=d._selectedEl;i&&d._plugin._updateTip(h,
i)})}})};e.registerBubble("flash","Flash \u7f51\u5740\uff1a ",n);e.checkFlash=n;var w={"Flash\u5c5e\u6027":function(a){var b=a.editor.getSelection();b=b&&b.getStartElement();(b=n(b))&&a.show(null,b)}};e.CLS_FLASH=l;e.TYPE_FLASH="flash";e.Insert=function(a,b,c,d,f,h){b=q.createSWF(b,{attrs:c},a.document);var k=b.el;c=a.createFakeElement?a.createFakeElement(k,d||"ke_flash",f||"flash",true,b.html,c):k;a.insertElement(c,null,h)};g.Flash=e},{attach:false,requires:["bubbleview","contextmenu","flashutils"]});
