(function(){CKEDITOR.plugins.add('stylescombo',{requires:['richcombo','styles'],init:function(b){var c=b.config,d=b.lang.stylesCombo,e={},f=[];function g(h){b.getStylesSet(function(i){if(!f.length){var j,k;for(var l=0;l<i.length;l++){var m=i[l];k=m.name;j=e[k]=new CKEDITOR.style(m);j._name=k;j._.enterMode=c.enterMode;f.push(j);}f.sort(a);}h&&h();});};b.ui.addRichCombo('Styles',{label:d.label,title:d.panelTitle,className:'cke_styles',panel:{css:b.skin.editor.css.concat(c.contentsCss),multiSelect:true,attributes:{'aria-label':d.panelTitle}},init:function(){var h=this;g(function(){var i,j,k;for(var l=0;l<f.length;l++){i=f[l];j=i._name;var m=i.type;if(m!=k){h.startGroup(d['panelTitle'+String(m)]);k=m;}h.add(j,i.type==CKEDITOR.STYLE_OBJECT?j:i.buildPreview(),j);}h.commit();h.onOpen();});},onClick:function(h){b.focus();b.fire('saveSnapshot');var i=e[h],j=b.getSelection(),k=new CKEDITOR.dom.elementPath(j.getStartElement());if(i.type==CKEDITOR.STYLE_INLINE&&i.checkActive(k))i.remove(b.document);else i.apply(b.document);b.fire('saveSnapshot');},onRender:function(){b.on('selectionChange',function(h){var i=this.getValue(),j=h.data.path,k=j.elements;for(var l=0,m;l<k.length;l++){m=k[l];for(var n in e){if(e[n].checkElementRemovable(m,true)){if(n!=i)this.setValue(n);return;}}}this.setValue('');},this);},onOpen:function(){var o=this;if(CKEDITOR.env.ie||CKEDITOR.env.webkit)b.focus();var h=b.getSelection(),i=h.getSelectedElement(),j=new CKEDITOR.dom.elementPath(i||h.getStartElement()),k=[0,0,0,0];o.showAll();o.unmarkAll();for(var l in e){var m=e[l],n=m.type;if(m.checkActive(j))o.mark(l);else if(n==CKEDITOR.STYLE_OBJECT&&!m.checkApplicable(j)){o.hideItem(l);k[n]--;}k[n]++;}if(!k[CKEDITOR.STYLE_BLOCK])o.hideGroup(d['panelTitle'+String(CKEDITOR.STYLE_BLOCK)]);if(!k[CKEDITOR.STYLE_INLINE])o.hideGroup(d['panelTitle'+String(CKEDITOR.STYLE_INLINE)]);if(!k[CKEDITOR.STYLE_OBJECT])o.hideGroup(d['panelTitle'+String(CKEDITOR.STYLE_OBJECT)]);}});b.on('instanceReady',function(){g();});}});function a(b,c){var d=b.type,e=c.type;return d==e?0:d==CKEDITOR.STYLE_OBJECT?-1:e==CKEDITOR.STYLE_OBJECT?1:e==CKEDITOR.STYLE_BLOCK?1:-1;};})();
