Ticket #4479: 4479_2.patch

File 4479_2.patch, 3.5 KB (added by Garry Yao, 14 years ago)
  • _source/plugins/stylescombo/plugin.js

     
    1616                        var config = editor.config,
    1717                                lang = editor.lang.stylesCombo,
    1818                                pluginPath = this.path,
    19                                 styles;
     19                                styles = {},
     20                                stylesList = [];
    2021
    2122                        if ( !stylesManager )
    2223                                stylesManager = CKEDITOR.stylesSet;
     
    3031                                                comboStylesSet.slice( 1 ).join( ':' ) :
    3132                                                pluginPath + 'styles/' + styleSetName + '.js', '' );
    3233
    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;
    5643
    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 ];
    6348
    64                                                                         styleName = styleDefinition.name;
     49                                                           styleName = styleDefinition.name;
    6550
    66                                                                         style = styles[ styleName ] = new CKEDITOR.style( styleDefinition );
    67                                                                         style._name = styleName;
     51                                                           style = styles[ styleName ] = new CKEDITOR.style( styleDefinition );
     52                                                           style._name = styleName;
    6853
    69                                                                         stylesList.push( style );
    70                                                                 }
     54                                                           stylesList.push( style );
     55                                                   }
    7156
    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                                           }
    7561
     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
    7687                                                                // Loop over the Array, adding all items to the
    7788                                                                // combo.
    7889                                                                var lastType;
    79                                                                 for ( i = 0 ; i < stylesList.length ; i++ )
     90                                                                for ( var i = 0 ; i < stylesList.length ; i++ )
    8091                                                                {
    8192                                                                        style = stylesList[ i ];
    8293                                                                        styleName = style._name;
     
    191202                                                        this.hideGroup( lang[ 'panelTitle' + String( CKEDITOR.STYLE_OBJECT ) ] );
    192203                                        }
    193204                                });
     205
     206                        editor.on( 'instanceReady', function() { loadStylesSet(); } );
    194207                }
    195208        });
    196209
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy