Ticket #5292: 5292_2.patch

File 5292_2.patch, 3.5 KB (added by Alfonso Martínez de Lizarrondo, 14 years ago)

Revised patch

  • _source/plugins/font/plugin.js

     
    2929                                vars[ styleType ] = values[ i ] = parts[ 1 ] || name;
    3030
    3131                                styles[ name ] = new CKEDITOR.style( styleDefinition, vars );
     32                                styles[ name ]._.definition.name = name;
    3233                        }
    3334                        else
    3435                                names.splice( i--, 1 );
     
    5556                                                var name = names[ i ];
    5657
    5758                                                // Add the tag entry to the panel list.
    58                                                 this.add( name, '<span style="font-' + styleType + ':' + values[ i ] + '">' + name + '</span>', name );
     59                                                this.add( name, styles[ name ].buildPreview(), name );
    5960                                        }
    6061                                },
    6162
  • _source/plugins/styles/plugin.js

     
    298298                                }
    299299                        }
    300300                        return false;
     301                },
     302
     303                // Builds the preview HTML based on the styles definition.
     304                buildPreview : function()
     305                {
     306                        var styleDefinition = this._.definition,
     307                                html = [],
     308                                elementName = styleDefinition.element;
     309
     310                        // Avoid <bdo> in the preview.
     311                        if ( elementName == 'bdo' )
     312                                elementName = 'span';
     313
     314                        html = [ '<', elementName ];
     315
     316                        // Assign all defined attributes.
     317                        var attribs     = styleDefinition.attributes;
     318                        if ( attribs )
     319                        {
     320                                for ( var att in attribs )
     321                                {
     322                                        html.push( ' ', att, '="', attribs[ att ], '"' );
     323                                }
     324                        }
     325
     326                        // Assign the style attribute.
     327                        var cssStyle = CKEDITOR.style.getStyleText( styleDefinition );
     328                        if ( cssStyle )
     329                                html.push( ' style="', cssStyle, '"' );
     330
     331                        html.push( '>', styleDefinition.name, '</', elementName, '>' );
     332
     333                        return html.join( '' );
    301334                }
    302335        };
    303336
     
    12341267                temp [ isStyle ? 'setStyle' : 'setAttribute' ]( name, value );
    12351268                return temp[ isStyle ? 'getStyle' : 'getAttribute' ]( name );
    12361269        }
    1237        
     1270
    12381271        function normalizeCssText( unparsedCssText, nativeNormalize )
    12391272        {
    12401273                var styleText;
  • _source/plugins/stylescombo/plugin.js

     
    8585
    8686                                                                        combo.add(
    8787                                                                                styleName,
    88                                                                                 style.type == CKEDITOR.STYLE_OBJECT ? styleName : buildPreview( style._.definition ),
     88                                                                                style.type == CKEDITOR.STYLE_OBJECT ? styleName : style.buildPreview(),
    8989                                                                                styleName );
    9090                                                                }
    9191
     
    190190                }
    191191        });
    192192
    193         function buildPreview( styleDefinition )
    194         {
    195                 var html = [];
    196 
    197                 var elementName = styleDefinition.element;
    198 
    199                 // Avoid <bdo> in the preview.
    200                 if ( elementName == 'bdo' )
    201                         elementName = 'span';
    202 
    203                 html = [ '<', elementName ];
    204 
    205                 // Assign all defined attributes.
    206                 var attribs     = styleDefinition.attributes;
    207                 if ( attribs )
    208                 {
    209                         for ( var att in attribs )
    210                         {
    211                                 html.push( ' ', att, '="', attribs[ att ], '"' );
    212                         }
    213                 }
    214 
    215                 // Assign the style attribute.
    216                 var cssStyle = CKEDITOR.style.getStyleText( styleDefinition );
    217                 if ( cssStyle )
    218                         html.push( ' style="', cssStyle, '"' );
    219 
    220                 html.push( '>', styleDefinition.name, '</', elementName, '>' );
    221 
    222                 return html.join( '' );
    223         }
    224 
    225193        function sortStyles( styleA, styleB )
    226194        {
    227195                var typeA = styleA.type,
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy