CKEDITOR.plugins.add('button',{beforeInit:function(a){a.ui.addHandler(CKEDITOR.UI_BUTTON,CKEDITOR.ui.button.handler);}});CKEDITOR.UI_BUTTON=1;CKEDITOR.ui.button=function(a){CKEDITOR.tools.extend(this,a,{title:a.label,className:a.className||a.command&&'cke_button_'+a.command||'',click:a.click||(function(b){b.execCommand(a.command);})});this._={};};CKEDITOR.ui.button.handler={create:function(a){return new CKEDITOR.ui.button(a);}};CKEDITOR.ui.button.prototype={canGroup:true,render:function(a,b){var c=CKEDITOR.env,d=this._.id='cke_'+CKEDITOR.tools.getNextNumber(),e='',f=this.command,g,h;this._.editor=a;var i={id:d,button:this,editor:a,focus:function(){var k=CKEDITOR.document.getById(d);k.focus();},execute:function(){this.button.click(a);}};i.clickFn=g=CKEDITOR.tools.addFunction(i.execute,i);i.index=h=CKEDITOR.ui.button._.instances.push(i)-1;if(this.modes)a.on('mode',function(){this.setState(this.modes[a.mode]?CKEDITOR.TRISTATE_OFF:CKEDITOR.TRISTATE_DISABLED);},this);else if(f){f=a.getCommand(f);if(f){f.on('state',function(){this.setState(f.state);},this);e+='cke_'+(f.state==CKEDITOR.TRISTATE_ON?'on':f.state==CKEDITOR.TRISTATE_DISABLED?'disabled':'off');}}if(!f)e+='cke_off';if(this.className)e+=' '+this.className;b.push('<span class="cke_button">','<a id="',d,'" class="',e,'"',c.gecko&&c.version>=10900&&!c.hc?'':'" href="javascript:void(\''+(this.title||'').replace("'")+"')\"",' title="',this.title,'" tabindex="-1" hidefocus="true" role="button" aria-labelledby="'+d+'_label"'+(this.hasArrow?' aria-haspopup="true"':''));if(c.opera||c.gecko&&c.mac)b.push(' onkeypress="return false;"');if(c.gecko)b.push(' onblur="this.style.cssText = this.style.cssText;"');b.push(' onkeydown="return CKEDITOR.ui.button._.keydown(',h,', event);" onfocus="return CKEDITOR.ui.button._.focus(',h,', event);" onclick="CKEDITOR.tools.callFunction(',g,', this); return false;"><span class="cke_icon"');if(this.icon){var j=(this.iconOffset||0)*-16;b.push(' style="background-image:url(',CKEDITOR.getUrl(this.icon),');background-position:0 '+j+'px;"');}b.push('>&nbsp;</span><span id="',d,'_label" class="cke_label">',this.label,'</span>');if(this.hasArrow)b.push('<span class="cke_buttonarrow">'+(CKEDITOR.env.hc?'&#9660;':'&nbsp;')+'</span>');b.push('</a>','</span>');if(this.onRender)this.onRender();return i;},setState:function(a){if(this._.state==a)return false;this._.state=a;var b=CKEDITOR.document.getById(this._.id);if(b){b.setState(a);a==CKEDITOR.TRISTATE_DISABLED?b.setAttribute('aria-disabled',true):b.removeAttribute('aria-disabled');
a==CKEDITOR.TRISTATE_ON?b.setAttribute('aria-pressed',true):b.removeAttribute('aria-pressed');return true;}else return false;}};CKEDITOR.ui.button._={instances:[],keydown:function(a,b){var c=CKEDITOR.ui.button._.instances[a];if(c.onkey){b=new CKEDITOR.dom.event(b);return c.onkey(c,b.getKeystroke())!==false;}},focus:function(a,b){var c=CKEDITOR.ui.button._.instances[a],d;if(c.onfocus)d=c.onfocus(c,new CKEDITOR.dom.event(b))!==false;if(CKEDITOR.env.gecko&&CKEDITOR.env.version<10900)b.preventBubble();return d;}};CKEDITOR.ui.prototype.addButton=function(a,b){this.add(a,CKEDITOR.UI_BUTTON,b);};CKEDITOR.on('reset',function(){CKEDITOR.ui.button._.instances=[];});
