Ticket #2912: 2912.patch

File 2912.patch, 3.8 KB (added by Frederico Caldeira Knabben, 15 years ago)
  • _source/core/command.js

     
    55
    66CKEDITOR.command = function( editor, commandDefinition )
    77{
    8         this.state = CKEDITOR.TRISTATE_OFF;
     8        this.state = ( 'state' in commandDefinition ) ? commandDefinition.state : CKEDITOR.TRISTATE_OFF;
    99
    1010        this.exec = function()
    1111        {
     
    1818        CKEDITOR.event.call( this );
    1919};
    2020
     21CKEDITOR.command.prototype =
     22{
     23        setState : function( newState )
     24        {
     25                // Do nothing if there is no state change.
     26                if ( this.state == newState )
     27                        return false;
     28
     29                // Set the new state.
     30                this.state = newState;
     31
     32                // Fire the "state" event, so other parts of the code can react to the
     33                // change.
     34                this.fire( 'state' );
     35
     36                return true;
     37        }
     38}
     39
    2140CKEDITOR.event.implementOn( CKEDITOR.command.prototype );
  • _source/plugins/basicstyles/plugin.js

     
    1717
    1818                        editor.attachStyleStateChange( style, function( state )
    1919                                {
    20                                         var command = editor.getCommand( commandName );
    21                                         command.state = state;
    22                                         command.fire( 'state' );
     20                                        editor.getCommand( commandName ).setState( state );
    2321                                });
    2422
    2523                        editor.addCommand( commandName, new CKEDITOR.styleCommand( style ) );
  • _source/plugins/indent/plugin.js

     
    1313
    1414        function setState( editor, state )
    1515        {
    16                 var command = editor.getCommand( this.name );
    17                 command.state = state;
    18                 command.fire( 'state' );
     16                editor.getCommand( this.name ).setState( state );
    1917        }
    2018
    2119        function onSelectionChange( evt )
  • _source/plugins/link/plugin.js

     
    6060                                var command = editor.getCommand( 'unlink' ),
    6161                                        element = evt.data.path.lastElement.getAscendant( 'a', true );
    6262                                if ( element && element.getName() == 'a' && element.getAttribute( 'href' ) )
    63                                         command.state = CKEDITOR.TRISTATE_OFF;
     63                                        command.setState( CKEDITOR.TRISTATE_OFF );
    6464                                else
    65                                         command.state = CKEDITOR.TRISTATE_DISABLED;
    66                                 command.fire( 'state' );
     65                                        command.setState( CKEDITOR.TRISTATE_DISABLED );
    6766                        } );
    6867
    6968                // Register a contentDom handler for displaying placeholders after mode change.
  • _source/plugins/list/plugin.js

     
    168168
    169169        function setState( editor, state )
    170170        {
    171                 var command = editor.getCommand( this.name );
    172                 command.state = state;
    173                 command.fire( 'state' );
     171                editor.getCommand( this.name ).setState( state );
    174172        }
    175173
    176174        function onSelectionChange( evt )
  • _source/plugins/sourcearea/plugin.js

     
    113113
    114114                editor.on( 'mode', function()
    115115                        {
    116                                 var command = editor.getCommand( 'source' );
    117                                 command.state = ( editor.mode == 'source' ? CKEDITOR.TRISTATE_ON : CKEDITOR.TRISTATE_OFF );
    118                                 command.fire( 'state' );
     116                                editor.getCommand( 'source' ).setState(
     117                                        editor.mode == 'source' ?
     118                                                CKEDITOR.TRISTATE_ON :
     119                                                CKEDITOR.TRISTATE_OFF );
    119120                        });
    120121        }
    121122});
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy