CKEDITOR.plugins.add('richcombo',{requires:['floatpanel','listblock','button'],beforeInit:function(a){a.ui.addHandler(CKEDITOR.UI_RICHCOMBO,CKEDITOR.ui.richCombo.handler);}});CKEDITOR.UI_RICHCOMBO='richcombo';CKEDITOR.ui.richCombo=CKEDITOR.tools.createClass({$:function(a){var c=this;CKEDITOR.tools.extend(c,a,{title:a.label,modes:{wysiwyg:1}});var b=c.panel||{};delete c.panel;c.id=CKEDITOR.tools.getNextNumber();c.document=b&&b.parent&&b.parent.getDocument()||CKEDITOR.document;b.className=(b.className||'')+' cke_rcombopanel';b.block={multiSelect:b.multiSelect,attributes:b.attributes};c._={panelDefinition:b,items:{},state:CKEDITOR.TRISTATE_OFF};},statics:{handler:{create:function(a){return new CKEDITOR.ui.richCombo(a);}}},proto:{renderHtml:function(a){var b=[];this.render(a,b);return b.join('');},render:function(a,b){var c=CKEDITOR.env,d='cke_'+this.id,e=CKEDITOR.tools.addFunction(function(i){var l=this;var j=l._;if(j.state==CKEDITOR.TRISTATE_DISABLED)return;l.createPanel(a);if(j.on){j.panel.hide();return;}l.commit();var k=l.getValue();if(k)j.list.mark(k);else j.list.unmarkAll();j.panel.showBlock(l.id,new CKEDITOR.dom.element(i),4);},this),f={id:d,combo:this,focus:function(){var i=CKEDITOR.document.getById(d).getChild(1);i.focus();},clickFn:e};function g(){var j=this;var i=j.modes[a.mode]?CKEDITOR.TRISTATE_OFF:CKEDITOR.TRISTATE_DISABLED;j.setState(a.readOnly&&!j.readOnly?CKEDITOR.TRISTATE_DISABLED:i);j.setValue('');};a.on('mode',g,this);!this.readOnly&&a.on('readOnly',g,this);var h=CKEDITOR.tools.addFunction(function(i,j){i=new CKEDITOR.dom.event(i);var k=i.getKeystroke();switch(k){case 13:case 32:case 40:CKEDITOR.tools.callFunction(e,j);break;default:f.onkey(f,k);}i.preventDefault();});f.keyDownFn=h;b.push('<span class="cke_rcombo" role="presentation">','<span id=',d);if(this.className)b.push(' class="',this.className,' cke_off"');b.push(' role="presentation">','<span id="'+d+'_label" class=cke_label>',this.label,'</span>','<a hidefocus=true title="',this.title,'" tabindex="-1"',c.gecko&&c.version>=10900&&!c.hc?'':" href=\"javascript:void('"+this.label+"')\"",' role="button" aria-labelledby="',d,'_label" aria-describedby="',d,'_text" aria-haspopup="true"');if(CKEDITOR.env.opera||CKEDITOR.env.gecko&&CKEDITOR.env.mac)b.push(' onkeypress="return false;"');if(CKEDITOR.env.gecko)b.push(' onblur="this.style.cssText = this.style.cssText;"');b.push(' onkeydown="CKEDITOR.tools.callFunction( ',h,', event, this );" onclick="CKEDITOR.tools.callFunction(',e,', this); return false;"><span><span id="'+d+'_text" class="cke_text cke_inline_label">'+this.label+'</span>'+'</span>'+'<span class=cke_openbutton><span class=cke_icon>'+(CKEDITOR.env.hc?'&#9660;':CKEDITOR.env.air?'&nbsp;':'')+'</span></span>'+'</a>'+'</span>'+'</span>');
if(this.onRender)this.onRender();return f;},createPanel:function(a){if(this._.panel)return;var b=this._.panelDefinition,c=this._.panelDefinition.block,d=b.parent||CKEDITOR.document.getBody(),e=new CKEDITOR.ui.floatPanel(a,d,b),f=e.addListBlock(this.id,c),g=this;e.onShow=function(){if(g.className)this.element.getFirst().addClass(g.className+'_panel');g.setState(CKEDITOR.TRISTATE_ON);f.focus(!g.multiSelect&&g.getValue());g._.on=1;if(g.onOpen)g.onOpen();};e.onHide=function(h){if(g.className)this.element.getFirst().removeClass(g.className+'_panel');g.setState(g.modes&&g.modes[a.mode]?CKEDITOR.TRISTATE_OFF:CKEDITOR.TRISTATE_DISABLED);g._.on=0;if(!h&&g.onClose)g.onClose();};e.onEscape=function(){e.hide();g.document.getById('cke_'+g.id).getFirst().getNext().focus();};f.onClick=function(h,i){g.document.getWindow().focus();if(g.onClick)g.onClick.call(g,h,i);if(i)g.setValue(h,g._.items[h]);else g.setValue('');e.hide();};this._.panel=e;this._.list=f;e.getBlock(this.id).onHide=function(){g._.on=0;g.setState(CKEDITOR.TRISTATE_OFF);};if(this.init)this.init();},setValue:function(a,b){var d=this;d._.value=a;var c=d.document.getById('cke_'+d.id+'_text');if(c){if(!(a||b)){b=d.label;c.addClass('cke_inline_label');}else c.removeClass('cke_inline_label');c.setHtml(typeof b!='undefined'?b:a);}},getValue:function(){return this._.value||'';},unmarkAll:function(){this._.list.unmarkAll();},mark:function(a){this._.list.mark(a);},hideItem:function(a){this._.list.hideItem(a);},hideGroup:function(a){this._.list.hideGroup(a);},showAll:function(){this._.list.showAll();},add:function(a,b,c){this._.items[a]=c||a;this._.list.add(a,b,c);},startGroup:function(a){this._.list.startGroup(a);},commit:function(){var a=this;if(!a._.committed){a._.list.commit();a._.committed=1;CKEDITOR.ui.fire('ready',a);}a._.committed=1;},setState:function(a){var b=this;if(b._.state==a)return;b.document.getById('cke_'+b.id).setState(a);b._.state=a;}}});CKEDITOR.ui.prototype.addRichCombo=function(a,b){this.add(a,CKEDITOR.UI_RICHCOMBO,b);};
