CKEDITOR.plugins.add("floatpanel",{requires:["panel"]});(function(){var b={};var a=false;function c(h,i,e,g,j){var f=CKEDITOR.tools.genKey(i.getUniqueId(),e.getUniqueId(),h.skinName,h.lang.dir,h.uiColor||"",g.css||"",j||"");var d=b[f];if(!d){d=b[f]=new CKEDITOR.ui.panel(i,g);d.element=e.append(CKEDITOR.dom.element.createFromHtml(d.renderHtml(h),i));d.element.setStyles({display:"none",position:"absolute"})}return d}CKEDITOR.ui.floatPanel=CKEDITOR.tools.createClass({$:function(i,e,g,k){g.forceIFrame=1;var j=e.getDocument(),d=c(i,j,e,g,k||0),f=d.element,h=f.getFirst().getFirst();this.element=f;this._={editor:i,panel:d,parentElement:e,definition:g,document:j,iframe:h,children:[],dir:i.lang.dir};i.on("mode",function(){this.hide()},this)},proto:{addBlock:function(d,e){return this._.panel.addBlock(d,e)},addListBlock:function(d,e){return this._.panel.addListBlock(d,e)},getBlock:function(d){return this._.panel.getBlock(d)},showBlock:function(f,e,r,n,k){var d=this._.panel,i=d.showBlock(f);this.allowBlur(false);a=1;this._.returnFocus=this._.editor.focusManager.hasFocus?this._.editor:new CKEDITOR.dom.element(CKEDITOR.document.$.activeElement);var l=this.element,j=this._.iframe,g=this._.definition,m=e.getDocumentPosition(l.getDocument()),q=this._.dir=="rtl";var h=m.x+(n||0),p=m.y+(k||0);if(q&&(r==1||r==4)){h+=e.$.offsetWidth}else{if(!q&&(r==2||r==3)){h+=e.$.offsetWidth-1}}if(r==3||r==4){p+=e.$.offsetHeight-1}this._.panel._.offsetParentId=e.getId();l.setStyles({top:p+"px",left:0,display:""});l.setOpacity(0);l.getFirst().removeStyle("width");if(!this._.blurSet){var o=CKEDITOR.env.ie?j:new CKEDITOR.dom.window(j.$.contentWindow);CKEDITOR.event.useCapture=true;o.on("blur",function(s){if(!this.allowBlur()){return}var t=s.data.getTarget();if(t.getName&&t.getName()!="iframe"){return}if(this.visible&&!this._.activeChild&&!a){delete this._.returnFocus;this.hide()}},this);o.on("focus",function(){this._.focused=true;this.hideChild();this.allowBlur(true)},this);CKEDITOR.event.useCapture=false;this._.blurSet=1}d.onEscape=CKEDITOR.tools.bind(function(s){if(this.onEscape&&this.onEscape(s)===false){return false}},this);CKEDITOR.tools.setTimeout(function(){if(q){h-=l.$.offsetWidth}var s=CKEDITOR.tools.bind(function(){var A=l.getFirst();if(i.autoSize){var E=i.element.$;if(CKEDITOR.env.gecko||CKEDITOR.env.opera){E=E.parentNode}if(CKEDITOR.env.ie){E=E.document.body}var u=E.scrollWidth;if(CKEDITOR.env.ie&&CKEDITOR.env.quirks&&u>0){u+=(A.$.offsetWidth||0)-(A.$.clientWidth||0)+3}u+=4;A.setStyle("width",u+"px");i.element.addClass("cke_frameLoaded");var F=i.element.$.scrollHeight;if(CKEDITOR.env.ie&&CKEDITOR.env.quirks&&F>0){F+=(A.$.offsetHeight||0)-(A.$.clientHeight||0)+3}A.setStyle("height",F+"px");d._.currentBlock.element.setStyle("display","none").removeStyle("display")}else{A.removeStyle("height")}var w=d.element,v=w.getWindow(),D=v.getScrollPosition(),x=v.getViewPaneSize(),B={height:w.$.offsetHeight,width:w.$.offsetWidth};if(q?h<0:h+B.width>x.width+D.x){h+=(B.width*(q?1:-1))}if(p+B.height>x.height+D.y){p-=B.height}if(CKEDITOR.env.ie){var t=new CKEDITOR.dom.element(l.$.offsetParent),C=t;if(C.getName()=="html"){C=C.getDocument().getBody()}if(C.getComputedStyle("direction")=="rtl"){if(CKEDITOR.env.ie8Compat){h-=l.getDocument().getDocumentElement().$.scrollLeft*2}else{h-=(t.$.scrollWidth-t.$.clientWidth)}}}var z=l.getFirst(),y;if((y=z.getCustomData("activePanel"))){y.onHide&&y.onHide.call(this,1)}z.setCustomData("activePanel",this);l.setStyles({top:p+"px",left:h+"px"});l.setOpacity(1)},this);d.isLoaded?s():d.onLoad=s;CKEDITOR.tools.setTimeout(function(){j.$.contentWindow.focus();this.allowBlur(true)},0,this)},CKEDITOR.env.air?200:0,this);this.visible=1;if(this.onShow){this.onShow.call(this)}a=0},hide:function(e){if(this.visible&&(!this.onHide||this.onHide.call(this)!==true)){this.hideChild();CKEDITOR.env.gecko&&this._.iframe.getFrameDocument().$.activeElement.blur();this.element.setStyle("display","none");this.visible=0;this.element.getFirst().removeCustomData("activePanel");var d=e!==false&&this._.returnFocus;if(d){if(CKEDITOR.env.webkit&&d.type){d.getWindow().$.focus()}d.focus()}}},allowBlur:function(e){var d=this._.panel;if(e!=undefined){d.allowBlur=e}return d.allowBlur},showAsChild:function(e,f,h,g,d,i){if(this._.activeChild==e&&e._.panel._.offsetParentId==h.getId()){return}this.hideChild();e.onHide=CKEDITOR.tools.bind(function(){CKEDITOR.tools.setTimeout(function(){if(!this._.focused){this.hide()}},0,this)},this);this._.activeChild=e;this._.focused=false;e.showBlock(f,h,g,d,i);if(CKEDITOR.env.ie7Compat||(CKEDITOR.env.ie8&&CKEDITOR.env.ie6Compat)){setTimeout(function(){e.element.getChild(0).$.style.cssText+=""},100)}},hideChild:function(){var d=this._.activeChild;if(d){delete d.onHide;delete d._.returnFocus;delete this._.activeChild;d.hide()}}}});CKEDITOR.on("instanceDestroyed",function(){var e=CKEDITOR.tools.isEmpty(CKEDITOR.instances);for(var f in b){var d=b[f];if(e){d.destroy()}else{d.element.hide()}}e&&(b={})})})();