Ticket #7594: 7645.patch

File 7645.patch, 3.7 KB (added by Garry Yao, 13 years ago)
  • _source/plugins/toolbar/plugin.js

     
    393393                                                instance = items[ i ];
    394394                                                if ( instance.clickFn ) CKEDITOR.tools.removeFunction( instance.clickFn );
    395395                                                if ( instance.keyDownFn ) CKEDITOR.tools.removeFunction( instance.keyDownFn );
    396 
    397                                                 if ( instance.index ) CKEDITOR.ui.button._.instances[ instance.index ] = null;
    398396                                        }
    399397                                }
    400398                        });
  • _source/plugins/button/plugin.js

     
    5555        }
    5656};
    5757
    58 /**
    59  * Handles a button click.
    60  * @private
    61  */
    62 CKEDITOR.ui.button._ =
    63 {
    64         instances : [],
    65 
    66         keydown : function( index, ev )
    67         {
    68                 var instance = CKEDITOR.ui.button._.instances[ index ];
    69 
    70                 if ( instance.onkey )
    71                 {
    72                         ev = new CKEDITOR.dom.event( ev );
    73                         return ( instance.onkey( instance, ev.getKeystroke() ) !== false );
    74                 }
    75         },
    76 
    77         focus : function( index, ev )
    78         {
    79                 var instance = CKEDITOR.ui.button._.instances[ index ],
    80                         retVal;
    81 
    82                 if ( instance.onfocus )
    83                         retVal = ( instance.onfocus( instance, new CKEDITOR.dom.event( ev ) ) !== false );
    84 
    85                 // FF2: prevent focus event been bubbled up to editor container, which caused unexpected editor focus.
    86                 if ( CKEDITOR.env.gecko && CKEDITOR.env.version < 10900 )
    87                         ev.preventBubble();
    88                 return retVal;
    89         }
    90 };
    91 
    9258( function()
    9359{
    94         var keydownFn = CKEDITOR.tools.addFunction( CKEDITOR.ui.button._.keydown, CKEDITOR.ui.button._ ),
    95                 focusFn = CKEDITOR.tools.addFunction( CKEDITOR.ui.button._.focus, CKEDITOR.ui.button._ );
    96 
    9760CKEDITOR.ui.button.prototype =
    9861{
    9962        canGroup : true,
     
    11275                        id = this._.id = CKEDITOR.tools.getNextId(),
    11376                        classes = '',
    11477                        command = this.command, // Get the command name.
    115                         clickFn,
    116                         index;
     78                        clickFn;
    11779
    11880                this._.editor = editor;
    11981
     
    13395                        }
    13496                };
    13597
     98                var keydownFn = CKEDITOR.tools.addFunction( function( ev )
     99                        {
     100                                if ( instance.onkey )
     101                                {
     102                                        ev = new CKEDITOR.dom.event( ev );
     103                                        return ( instance.onkey( instance, ev.getKeystroke() ) !== false );
     104                                }
     105                        });
     106
     107                var focusFn = CKEDITOR.tools.addFunction( function( ev )
     108                        {
     109                                var retVal;
     110
     111                                if ( instance.onfocus )
     112                                          retVal = ( instance.onfocus( instance, new CKEDITOR.dom.event( ev ) ) !== false );
     113
     114                                // FF2: prevent focus event been bubbled up to editor container, which caused unexpected editor focus.
     115                                if ( CKEDITOR.env.gecko && CKEDITOR.env.version < 10900 )
     116                                          ev.preventBubble();
     117                                return retVal;
     118                        });
     119
    136120                instance.clickFn = clickFn = CKEDITOR.tools.addFunction( instance.execute, instance );
    137121
    138                 instance.index = index = CKEDITOR.ui.button._.instances.push( instance ) - 1;
    139122
    140123                // Indicate a mode sensitive button.
    141124                if ( this.modes )
     
    224207                }
    225208
    226209                output.push(
    227                                         ' onkeydown="return CKEDITOR.tools.callFunction(', keydownFn, ', ', index, ', event);"' +
    228                                         ' onfocus="return CKEDITOR.tools.callFunction(', focusFn,', ', index, ', event);"' +
     210                                        ' onkeydown="return CKEDITOR.tools.callFunction(', keydownFn, ', event);"' +
     211                                        ' onfocus="return CKEDITOR.tools.callFunction(', focusFn,', event);"' +
    229212                                ' onclick="CKEDITOR.tools.callFunction(', clickFn, ', this); return false;">' +
    230213                                        '<span class="cke_icon"' );
    231214
     
    302285{
    303286        this.add( name, CKEDITOR.UI_BUTTON, definition );
    304287};
    305 
    306 CKEDITOR.on( 'reset', function()
    307         {
    308                 CKEDITOR.ui.button._.instances = [];
    309         });
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy