Ticket #4479: 4479_2.patch
File 4479_2.patch, 3.5 KB (added by , 14 years ago) |
---|
-
_source/plugins/stylescombo/plugin.js
16 16 var config = editor.config, 17 17 lang = editor.lang.stylesCombo, 18 18 pluginPath = this.path, 19 styles; 19 styles = {}, 20 stylesList = []; 20 21 21 22 if ( !stylesManager ) 22 23 stylesManager = CKEDITOR.stylesSet; … … 30 31 comboStylesSet.slice( 1 ).join( ':' ) : 31 32 pluginPath + 'styles/' + styleSetName + '.js', '' ); 32 33 33 editor.ui.addRichCombo( 'Styles', 34 { 35 label : lang.label, 36 title : lang.panelTitle, 37 className : 'cke_styles', 38 39 panel : 40 { 41 css : editor.skin.editor.css.concat( config.contentsCss ), 42 multiSelect : true, 43 attributes : { 'aria-label' : lang.panelTitle } 44 }, 45 46 init : function() 47 { 48 var combo = this; 49 50 CKEDITOR.stylesSet.load( styleSetName, function( stylesSet ) 51 { 52 var stylesDefinitions = stylesSet[ styleSetName ], 53 style, 54 styleName, 55 stylesList = []; 34 function loadStylesSet( callback ) 35 { 36 CKEDITOR.stylesSet.load( styleSetName, function( stylesSet ) 37 { 38 if ( !stylesList.length ) 39 { 40 var stylesDefinitions = stylesSet[ styleSetName ], 41 style, 42 styleName; 56 43 57 styles = {}; 58 59 // Put all styles into an Array. 60 for ( var i = 0 ; i < stylesDefinitions.length ; i++ ) 61 { 62 var styleDefinition = stylesDefinitions[ i ]; 44 // Put all styles into an Array. 45 for ( var i = 0 ; i < stylesDefinitions.length ; i++ ) 46 { 47 var styleDefinition = stylesDefinitions[ i ]; 63 48 64 49 styleName = styleDefinition.name; 65 50 66 67 51 style = styles[ styleName ] = new CKEDITOR.style( styleDefinition ); 52 style._name = styleName; 68 53 69 70 54 stylesList.push( style ); 55 } 71 56 72 // Sorts the Array, so the styles get grouped 73 // by type. 74 stylesList.sort( sortStyles ); 57 // Sorts the Array, so the styles get grouped 58 // by type. 59 stylesList.sort( sortStyles ); 60 } 75 61 62 callback && callback(); 63 }); 64 } 65 66 editor.ui.addRichCombo( 'Styles', 67 { 68 label : lang.label, 69 title : lang.panelTitle, 70 className : 'cke_styles', 71 72 panel : 73 { 74 css : editor.skin.editor.css.concat( config.contentsCss ), 75 multiSelect : true, 76 attributes : { 'aria-label' : lang.panelTitle } 77 }, 78 79 init : function() 80 { 81 var combo = this; 82 83 loadStylesSet( function() 84 { 85 var style, styleName; 86 76 87 // Loop over the Array, adding all items to the 77 88 // combo. 78 89 var lastType; 79 for ( i = 0 ; i < stylesList.length ; i++ )90 for ( var i = 0 ; i < stylesList.length ; i++ ) 80 91 { 81 92 style = stylesList[ i ]; 82 93 styleName = style._name; … … 191 202 this.hideGroup( lang[ 'panelTitle' + String( CKEDITOR.STYLE_OBJECT ) ] ); 192 203 } 193 204 }); 205 206 editor.on( 'instanceReady', function() { loadStylesSet(); } ); 194 207 } 195 208 }); 196 209