CKEDITOR.plugins.add('richcombo',{requires:['floatpanel','listblock','button'],beforeInit:function(a){a.ui.addHandler(CKEDITOR.UI_RICHCOMBO,CKEDITOR.ui.richCombo.handler);}});CKEDITOR.UI_RICHCOMBO=3;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(h){var k=this;var i=k._;if(i.state==CKEDITOR.TRISTATE_DISABLED)return;k.createPanel(a);if(i.on){i.panel.hide();return;}if(!i.committed){i.list.commit();i.committed=1;}var j=k.getValue();if(j)i.list.mark(j);else i.list.unmarkAll();i.panel.showBlock(k.id,new CKEDITOR.dom.element(h),4);},this),f={id:d,combo:this,focus:function(){var h=CKEDITOR.document.getById(d).getChild(1);h.focus();},clickFn:e};a.on('mode',function(){this.setState(this.modes[a.mode]?CKEDITOR.TRISTATE_OFF:CKEDITOR.TRISTATE_DISABLED);},this);var g=CKEDITOR.tools.addFunction(function(h,i){h=new CKEDITOR.dom.event(h);var j=h.getKeystroke();switch(j){case 13:case 32:case 40:CKEDITOR.tools.callFunction(e,i);break;default:f.onkey(f,j);}h.preventDefault();});f.keyDownFn=g;b.push('<span class="cke_rcombo">','<span id=',d);if(this.className)b.push(' class="',this.className,' cke_off"');b.push('>','<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( ',g,', 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>'+(CKEDITOR.env.hc?'<span>&#9660;</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(){if(g.className)this.element.getFirst().removeClass(g.className+'_panel');g.setState(CKEDITOR.TRISTATE_OFF);g._.on=0;if(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(!(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(){this._.list.commit();},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);};
