Ticket #6042: 6042.patch

File 6042.patch, 2.2 KB (added by Sa'ar Zac Elias, 14 years ago)
  • _source/plugins/justify/plugin.js

     
    1919                        return CKEDITOR.TRISTATE_OFF;
    2020
    2121                var currentAlign = firstBlock.getComputedStyle( 'text-align' ).replace( alignRemoveRegex, '' );
    22                 if ( ( !currentAlign && this.isDefaultAlign ) || currentAlign == this.value )
     22                if ( ( !currentAlign && isDefaultAlign( this, firstBlock ) ) || currentAlign == this.value )
    2323                        return CKEDITOR.TRISTATE_ON;
    2424                return CKEDITOR.TRISTATE_OFF;
    2525        }
     
    3131                command.fire( 'state' );
    3232        }
    3333
     34        function isDefaultAlign( command, element )
     35        {
     36                var direction = element.getComputedStyle( 'direction' ),
     37                        val = command.value;
     38                return ( direction == 'rtl' && val == 'right' ) || ( direction == 'ltr' && val == 'left' );
     39               
     40        }
     41
    3442        function justifyCommand( editor, name, value )
    3543        {
    3644                this.name = name;
    3745                this.value = value;
    3846
    39                 var contentDir = editor.config.contentsLangDirection;
    40                 this.isDefaultAlign = ( value == 'left' && contentDir == 'ltr' ) ||
    41                         ( value == 'right' && contentDir == 'rtl' );
    42 
    4347                var classes = editor.config.justifyClasses;
    4448                if ( classes )
    4549                {
     
    8892                                {
    8993                                        block.removeAttribute( 'align' );
    9094
     95                                        var isDefault = isDefaultAlign( this, block );
     96
    9197                                        if ( cssClassName )
    9298                                        {
    9399                                                // Remove any of the alignment classes from the className.
     
    95101                                                        CKEDITOR.tools.ltrim( block.$.className.replace( this.cssClassRegex, '' ) );
    96102
    97103                                                // Append the desired class name.
    98                                                 if ( this.state == CKEDITOR.TRISTATE_OFF && !this.isDefaultAlign )
     104                                                if ( this.state == CKEDITOR.TRISTATE_OFF && !isDefault )
    99105                                                        block.addClass( cssClassName );
    100106                                                else if ( !className )
    101107                                                        block.removeAttribute( 'class' );
    102108                                        }
    103109                                        else
    104110                                        {
    105                                                 if ( this.state == CKEDITOR.TRISTATE_OFF && !this.isDefaultAlign )
     111                                                if ( this.state == CKEDITOR.TRISTATE_OFF && !isDefault )
    106112                                                        block.setStyle( 'text-align', this.value );
    107113                                                else
    108114                                                        block.removeStyle( 'text-align' );
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy