KISSY.Editor.add("bubbleview",function(){function n(a){a=h[a];if(!a.bubble){a.bubble=new i({autoRender:true});a.cfg.init&&a.cfg.init.call(a.bubble)}return a.bubble}var j=KISSY,k=j.Editor,m=j.Event,o=j.DOM;if(k.BubbleView)j.log("attach bubbleview more","warn");else{var i=j.UIBase.create(k.Overlay,[],{renderUI:function(){this.get("el").addClass("ke-bubbleview-bubble")},show:function(){var a=this._selectedEl,c=a._4e_getOffset(document);c.top+=a.height()+5;this.set("xy",[c.left,c.top]);var e,l;for(l in h){a=
h[l];if(a.bubble){var f;if(f=this!=a.bubble){if(f=a.bubble.get("visible")){var g=a.bubble;f=this.get("y");var b=f+this.get("el")[0].offsetHeight,d=g.get("y");g=d+g.get("el")[0].offsetHeight;f=!(b<d||g<f)}f=f}if(f)if(e){if(e.get("y")<a.bubble.get("y"))e=a.bubble}else e=a.bubble}}if(e=e)c.top=e.get("y")+e.get("el")[0].offsetHeight;i.superclass.show.call(this);this.set("xy",[c.left,c.top])},destructor:function(){k.Utils.destroyRes.call(this)}},{ATTRS:{focus4e:{value:false},zIndex:{value:k.baseZIndex(k.zIndexManager.BUBBLE_VIEW)}}}),
h={};i.destroy=function(a){if((a=h[a])&&a.bubble){a.bubble.destroy();a.bubble=null}};i.attach=function(a){function c(){b&&b.hide()}var e=a.pluginName;j.mix(a,h[e].cfg,false);var l=a.pluginContext,f=a.func,g=a.editor,b=a.bubble;g.on("selectionChange",function(d){d=d.path;var p=d.elements;if(d&&p)if(d=d.lastElement)if(d=f(d)){b=n(e);b._selectedEl=d;b._plugin=l;b.hide();setTimeout(function(){b.show()},10)}else if(b){b._selectedEl=b._plugin=null;b.hide()}});g.on("sourcemode blur",c);m.on(o._4e_getWin(g.document),
"scroll",c)};i.register=function(a){var c=a.pluginName;h[c]=h[c]||{cfg:a};m.on(document,"click",function(){a.bubble&&a.bubble.hide()});a.editor&&i.attach(a)};k.BubbleView=i}},{attach:false,requires:["overlay"]});
