CKEDITOR.plugins.add('panel',{beforeInit:function(a){a.ui.addHandler(CKEDITOR.UI_PANEL,CKEDITOR.ui.panel.handler);}});CKEDITOR.UI_PANEL='panel';CKEDITOR.ui.panel=function(a,b){var c=this;if(b)CKEDITOR.tools.extend(c,b);CKEDITOR.tools.extend(c,{className:'',css:[]});c.id=CKEDITOR.tools.getNextId();c.document=a;c._={blocks:{}};};CKEDITOR.ui.panel.handler={create:function(a){return new CKEDITOR.ui.panel(a);}};CKEDITOR.ui.panel.prototype={renderHtml:function(a){var b=[];this.render(a,b);return b.join('');},render:function(a,b){var d=this;var c=d.id;b.push('<div class="',a.skinClass,'" lang="',a.langCode,'" role="presentation" style="display:none;z-index:'+(a.config.baseFloatZIndex+1)+'">'+'<div'+' id=',c,' dir=',a.lang.dir,' role="presentation" class="cke_panel cke_',a.lang.dir);if(d.className)b.push(' ',d.className);b.push('">');if(d.forceIFrame||d.css.length){b.push('<iframe id="',c,'_frame" frameborder="0" role="application" src="javascript:void(');b.push(CKEDITOR.env.isCustomDomain()?"(function(){document.open();document.domain='"+document.domain+"';"+'document.close();'+'})()':'0');b.push(')"></iframe>');}b.push('</div></div>');return c;},getHolderElement:function(){var a=this._.holder;if(!a){if(this.forceIFrame||this.css.length){var b=this.document.getById(this.id+'_frame'),c=b.getParent(),d=c.getAttribute('dir'),e=c.getParent().getAttribute('class'),f=c.getParent().getAttribute('lang'),g=b.getFrameDocument(),h=CKEDITOR.tools.addFunction(CKEDITOR.tools.bind(function(k){this.isLoaded=true;if(this.onLoad)this.onLoad();},this)),i='<!DOCTYPE html><html dir="'+d+'" class="'+e+'_container" lang="'+f+'">'+'<head>'+'<style>.'+e+'_container{visibility:hidden}</style>'+'</head>'+'<body class="cke_'+d+' cke_panel_frame '+CKEDITOR.env.cssClass+'" style="margin:0;padding:0"'+' onload="( window.CKEDITOR || window.parent.CKEDITOR ).tools.callFunction('+h+');"></body>'+CKEDITOR.tools.buildStyleHtml(this.css)+'</html>';g.write(i);var j=g.getWindow();j.$.CKEDITOR=CKEDITOR;g.on('key'+(CKEDITOR.env.opera?'press':'down'),function(k){var n=this;var l=k.data.getKeystroke(),m=n.document.getById(n.id).getAttribute('dir');if(n._.onKeyDown&&n._.onKeyDown(l)===false){k.data.preventDefault();return;}if(l==27||l==(m=='rtl'?39:37))if(n.onEscape&&n.onEscape(l)===false)k.data.preventDefault();},this);a=g.getBody();a.unselectable();CKEDITOR.env.air&&CKEDITOR.tools.callFunction(h);}else a=this.document.getById(this.id);this._.holder=a;}return a;},addBlock:function(a,b){var c=this;b=c._.blocks[a]=b instanceof CKEDITOR.ui.panel.block?b:new CKEDITOR.ui.panel.block(c.getHolderElement(),b);
if(!c._.currentBlock)c.showBlock(a);return b;},getBlock:function(a){return this._.blocks[a];},showBlock:function(a){var b=this._.blocks,c=b[a],d=this._.currentBlock,e=this.forceIFrame?this.document.getById(this.id+'_frame'):this._.holder;e.getParent().getParent().disableContextMenu();if(d){e.removeAttributes(d.attributes);d.hide();}this._.currentBlock=c;e.setAttributes(c.attributes);CKEDITOR.fire('ariaWidget',e);c._.focusIndex=-1;this._.onKeyDown=c.onKeyDown&&CKEDITOR.tools.bind(c.onKeyDown,c);c.onMark=function(f){e.setAttribute('aria-activedescendant',f.getId()+'_option');};c.onUnmark=function(){e.removeAttribute('aria-activedescendant');};c.show();return c;},destroy:function(){this.element&&this.element.remove();}};CKEDITOR.ui.panel.block=CKEDITOR.tools.createClass({$:function(a,b){var c=this;c.element=a.append(a.getDocument().createElement('div',{attributes:{tabIndex:-1,'class':'cke_panel_block',role:'presentation'},styles:{display:'none'}}));if(b)CKEDITOR.tools.extend(c,b);if(!c.attributes.title)c.attributes.title=c.attributes['aria-label'];c.keys={};c._.focusIndex=-1;c.element.disableContextMenu();},_:{markItem:function(a){var d=this;if(a==-1)return;var b=d.element.getElementsByTag('a'),c=b.getItem(d._.focusIndex=a);if(CKEDITOR.env.webkit||CKEDITOR.env.opera)c.getDocument().getWindow().focus();c.focus();d.onMark&&d.onMark(c);}},proto:{show:function(){this.element.setStyle('display','');},hide:function(){var a=this;if(!a.onHide||a.onHide.call(a)!==true)a.element.setStyle('display','none');},onKeyDown:function(a){var f=this;var b=f.keys[a];switch(b){case 'next':var c=f._.focusIndex,d=f.element.getElementsByTag('a'),e;while(e=d.getItem(++c)){if(e.getAttribute('_cke_focus')&&e.$.offsetWidth){f._.focusIndex=c;e.focus();break;}}return false;case 'prev':c=f._.focusIndex;d=f.element.getElementsByTag('a');while(c>0&&(e=d.getItem(--c))){if(e.getAttribute('_cke_focus')&&e.$.offsetWidth){f._.focusIndex=c;e.focus();break;}}return false;case 'click':c=f._.focusIndex;e=c>=0&&f.element.getElementsByTag('a').getItem(c);if(e)e.$.click?e.$.click():e.$.onclick();return false;}return true;}}});
