(function(){CKEDITOR.plugins.add('stylescombo',{requires:['richcombo','styles'],init:function(b){var c=b.config,d=b.lang.stylesCombo,e={},f=[],g;function h(i){b.getStylesSet(function(j){if(!f.length){var k,l;for(var m=0,n=j.length;m<n;m++){var o=j[m];l=o.name;k=e[l]=new CKEDITOR.style(o);k._name=l;k._.enterMode=c.enterMode;f.push(k);}f.sort(a);}i&&i();});};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(){g=this;h(function(){var i,j,k,l,m,n;for(m=0,n=f.length;m<n;m++){i=f[m];j=i._name;l=i.type;if(l!=k){g.startGroup(d['panelTitle'+String(l)]);k=l;}g.add(j,i.type==CKEDITOR.STYLE_OBJECT?j:i.buildPreview(),j);}g.commit();g.onOpen();});},onClick:function(i){b.focus();b.fire('saveSnapshot');var j=e[i],k=b.getSelection(),l=new CKEDITOR.dom.elementPath(k.getStartElement());j[j.checkActive(l)?'remove':'apply'](b.document);b.fire('saveSnapshot');},onRender:function(){b.on('selectionChange',function(i){var j=this.getValue(),k=i.data.path,l=k.elements;for(var m=0,n=l.length,o;m<n;m++){o=l[m];for(var p in e){if(e[p].checkElementRemovable(o,true)){if(p!=j)this.setValue(p);return;}}}this.setValue('');},this);},onOpen:function(){var p=this;if(CKEDITOR.env.ie||CKEDITOR.env.webkit)b.focus();var i=b.getSelection(),j=i.getSelectedElement(),k=new CKEDITOR.dom.elementPath(j||i.getStartElement()),l=[0,0,0,0];p.showAll();p.unmarkAll();for(var m in e){var n=e[m],o=n.type;if(n.checkActive(k))p.mark(m);else if(o==CKEDITOR.STYLE_OBJECT&&!n.checkApplicable(k)){p.hideItem(m);l[o]--;}l[o]++;}if(!l[CKEDITOR.STYLE_BLOCK])p.hideGroup(d['panelTitle'+String(CKEDITOR.STYLE_BLOCK)]);if(!l[CKEDITOR.STYLE_INLINE])p.hideGroup(d['panelTitle'+String(CKEDITOR.STYLE_INLINE)]);if(!l[CKEDITOR.STYLE_OBJECT])p.hideGroup(d['panelTitle'+String(CKEDITOR.STYLE_OBJECT)]);},reset:function(){if(g){delete g._.panel;delete g._.list;g._.committed=0;g._.items={};g._.state=CKEDITOR.TRISTATE_OFF;}e={};f=[];h();}});b.on('instanceReady',function(){h();});}});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;};})();
