Ticket #6376: 6376_2.patch

File 6376_2.patch, 2.0 KB (added by Tobiasz Cudnik, 14 years ago)
  • _source/plugins/bidi/plugin.js

     
    5252                        chromeRoot.removeClass( 'cke_mixed_dir_content' );
    5353        }
    5454
    55         function switchDir( element, dir, editor, state )
     55        function switchDir( element, dir, editor )
    5656        {
    57                 var dirBefore = element.getComputedStyle( 'direction' );
    58 
    59                 element.removeStyle( 'direction' );
    60                 element.removeAttribute( 'dir' );
     57                var useComputedState = editor.config.useComputedState;
     58                useComputedState = useComputedState === undefined || useComputedState;
     59               
     60                var elementDir = useComputedState ? element.getComputedStyle( 'direction' )
     61                        : element.hasAttribute( 'dir' ) || element.getStyle( 'direction' );
    6162
    62                 if ( state == CKEDITOR.TRISTATE_OFF && element.getComputedStyle( 'direction' ).toLowerCase() != dir )
    63                         element.setAttribute( 'dir', dir );
     63                // Stop if direction is same as present.
     64                if ( elementDir == dir )
     65                        return;
     66
     67                var dirBefore = element.getComputedStyle( 'direction' );
     68
     69                element.setAttribute( 'dir', dir );
    6470
    6571                // If the element direction changed, we need to switch the margins of
    6672                // the element and all its children, so it will get really reflected
     
    98104                }
    99105
    100106                editor.forceNextSelectionCheck();
     107
     108                return null;
    101109        }
    102110
    103111        function getFullySelected( selection, elements )
     
    136144                                if ( selectedElement )
    137145                                {
    138146                                        if ( !selectedElement.isReadOnly() )
    139                                                 switchDir( selectedElement, dir, editor, this.state );
     147                                                switchDir( selectedElement, dir, editor );
    140148                                }
    141149                                else
    142150                                {
     
    163171
    164172                                                while ( ( block = walker.next() ) )
    165173                                                {
    166                                                         switchDir( block, dir, editor, this.state );
     174                                                        switchDir( block, dir, editor );
    167175                                                        processedElements.push( block );
    168176                                                }
    169177
     
    199207
    200208                                                        if ( !_break )
    201209                                                        {
    202                                                                 switchDir( block, dir, editor, this.state );
     210                                                                switchDir( block, dir, editor );
    203211                                                        }
    204212                                                }
    205213                                        }
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy