Ticket #3042: 3042.patch

File 3042.patch, 7.2 KB (added by Garry Yao, 15 years ago)
  • _source/plugins/listblock/plugin.js

     
    2929                                        {
    3030                                                pendingHtml : [],
    3131                                                items : {},
     32                                                // List item ids in rendering sequence.
     33                                                itemList : [],
    3234                                                groups : {}
    3335                                        };
    3436                                },
     
    7981                                                        this._.started = 1;
    8082                                                }
    8183
    82                                                 this._.items[ value ] = id;
     84                                                this._.itemList.push ( this._.items[ value ] = id );
    8385
    8486                                                pendingHtml.push( '<li id=cke_', id, ' class=cke_panel_listItem><a hidefocus=true href="javascript:void(\'', value, '\')" onclick="CKEDITOR.tools.callFunction(', this._.getClick(), ',\'', value, '\');">', html || value, '</a></li>' );
    8587                                        },
    86 
     88                                       
     89                                        /**
     90                                         *  Get the navigator cursor of the list items.
     91                                         *  Note : This function is used for establish keyboard accessiblity through the list.
     92                                         */
     93                                        getCursor : function()
     94                                        {
     95                                                var doc = this.element.getDocument(),
     96                                                        idPrefix = 'cke_',
     97                                                        self = this,
     98                                                        itemList = self._.itemList,
     99                                                        items = self._.items;
     100                                               
     101                                                var getItem = function ( itemIndex )
     102                                                        {
     103                                                                return doc.getById( idPrefix + itemList[ itemIndex ] );
     104                                                        },
     105                                                        getItemLink = function ( itemIndex )
     106                                                        {
     107                                                                return getItem( itemIndex ).getFirst().$;
     108                                                        },
     109                                                        getItemValue = function ( itemIndex )
     110                                                        {
     111                                                                for( var i in  items )
     112                                                                {
     113                                                                        if( items [ i ] == itemList[ itemIndex ] )
     114                                                                                return i;
     115                                                                }
     116                                                        },
     117                                                        isHiddenItem = function( itemIndex ){
     118                                                                return getItem( itemIndex ).getComputedStyle( 'display' ) == 'none';
     119                                                        };
     120                                               
     121                                                return {
     122                                                       
     123                                                        currentIndex : -1,
     124                                                       
     125                                                        forward : function() {
     126                                                                this.currentIndex = this.currentIndex == itemList.length -1 ? 0 : ( this.currentIndex + 1 ) ;
     127                                                                if( isHiddenItem( this.currentIndex ) )
     128                                                                        this.forward();
     129                                                        },
     130                                                       
     131                                                        back : function()       {
     132                                                                this.currentIndex = this.currentIndex <= 0 ?  itemList.length -1 : ( this.currentIndex - 1 );
     133                                                                if( isHiddenItem( this.currentIndex ) )
     134                                                                        this.back();
     135                                                        },
     136                                                       
     137                                                        // Set current cursor position
     138                                                        setCursor : function( itemValue )
     139                                                        {
     140                                                                var itemId = items[ itemValue ];
     141                                                                var i, l = itemList.length;
     142                                                                for (i = 0; i < l; i++) {
     143                                                                        if( itemList[ i ] == itemId )
     144                                                                        {
     145                                                                                this.currentIndex = i;
     146                                                                                return;
     147                                                                        }
     148                                                                }
     149                                                        },
     150                                                       
     151                                                        focusAtCursor : function()
     152                                                        {
     153                                                                getItemLink( this.currentIndex ).focus();
     154                                                                self.mark( getItemValue( this.currentIndex ) );                                                         
     155                                                        },
     156                                                       
     157                                                        clickAtCursor: function()
     158                                                        {
     159                                                                getItemLink( this.currentIndex ).onclick();
     160                                                        }
     161                                                };
     162                                        },
     163                                       
    87164                                        startGroup : function( title )
    88165                                        {
    89166                                                this._.close();
     
    157234
    158235                                        mark : function( value )
    159236                                        {
    160                                                 if ( !this.multiSelect )
    161                                                         this.unmarkAll();
    162 
     237                                                if( this._.previousMarked )
     238                                                        this.unmark( this._.previousMarked );
    163239                                                this.element.getDocument().getById( 'cke_' + this._.items[ value ] ).addClass( 'cke_selected' );
     240                                                this._.previousMarked = value;
    164241                                        },
    165242
    166243                                        unmark : function( value )
  • _source/plugins/richcombo/plugin.js

     
    4747                this._ =
    4848                {
    4949                        panelDefinition : panelDefinition,
    50                         items : {}
     50                        items : {},
     51                        /**
     52                         * @see {@link CKEDITOR.ui.listBlock::getCursor}
     53                         */
     54                        listItemCursor : null,
    5155                };
    5256        },
    5357
     
    100104                                                _.committed = 1;
    101105                                        }
    102106                                       
     107                                        _.listItemCursor = _.list.getCursor();
     108                                       
    103109                                        var value = this.getValue();
    104110                                        if ( value )
     111                                        {
    105112                                                _.list.mark( value );
     113                                               
     114                                                // Ignore initial cursor position of multiple select combo
     115                                                if ( !this.multiSelect )
     116                                                        _.listItemCursor.setCursor( value );
     117                                        }
    106118                                        else
    107119                                                _.list.unmarkAll();
     120                                               
     121                                        // Register combo key processing on CKEDITOR.ui.panel.
     122                                        _.panel._.panel.onKeyDown = CKEDITOR.tools.bind( this.onPanelKeyDown, this );
     123                                        _.panel.showBlock( this.id, new CKEDITOR.dom.element( $element ).getFirst(), 4 );
    108124                                       
    109                                         _.panel.showBlock( this.id, new CKEDITOR.dom.element( $element ).getFirst(), 4 );
    110125                                },
    111126                                this );
    112127                               
     
    297312                commit : function()
    298313                {
    299314                        this._.list.commit();
     315                },
     316               
     317                /**
     318                 * Key navigation logic for combo panel.
     319                 * @see {@link CKEDITOR.ui.panel.onKeyDown}
     320                 */
     321                onPanelKeyDown : function( keystroke )
     322                {
     323                        var cursor = this._.listItemCursor;
     324                        switch ( keystroke )
     325                        {
     326                                case 40 :                                       // DOWN-ARROW
     327                                case 9 :                                        // TAB
     328                                        cursor.forward();
     329                                        cursor.focusAtCursor();
     330                                        break;
     331                                case 38 :                                       // UP-ARROW
     332                                case CKEDITOR.SHIFT + 9 :       // SHIFT + TAB
     333                                        cursor.back();
     334                                        cursor.focusAtCursor();
     335                                        break;
     336                                case 27 :                                       // ESC
     337                                        this._.panel.hide();
     338                                        break;
     339                                case 13 :                                       // ENTER
     340                                case 32 :                                       // SPACE
     341                                        cursor.clickAtCursor();
     342                                        break;
     343                        }
    300344                }
    301345        }
    302346});
  • _source/plugins/floatpanel/plugin.js

     
    120121                                else
    121122                                        element.removeStyle( 'height' );
    122123
    123                                 // Configure the IFrame blur event. Do that only once.
    124                                 if ( !this._.blurSet )
     124                                // Configure the Panel(IFrame) events only once.
     125                                if ( !this._.panel._.eventInited )
    125126                                {
    126127                                        // Non IE prefer the event into a window object.
    127128                                        var focused = CKEDITOR.env.ie ? iframe : new CKEDITOR.dom.window( iframe.$.contentWindow );
     
    139140                                                        this.hideChild();
    140141                                                },
    141142                                                this );
    142 
    143                                         this._.blurSet = 1;
     143                                               
     144                                        focused.on( 'keydown', function( evt ){
     145                                               
     146                                                // Delegate key processing to specific control types.
     147                                                if( this.onKeyDown )
     148                                                {
     149                                                        var keystroke = evt.data.getKeystroke();
     150                                                        this.onKeyDown( keystroke );
     151                                                        evt.data.preventDefault();
     152                                                }
     153                                        }, this._.panel );
     154                               
     155                                        this._.panel._.eventInited = true;
    144156                                }
    145157
    146158                                // Set the IFrame focus, so the blur event gets fired.
  • _source/plugins/panel/plugin.js

     
    177177                block.show();
    178178               
    179179                return block;
    180         }
     180        },
     181       
     182        /**
     183         * This's a hook function provided by various panel based controls
     184         * to handle keystrokes. When a control is opening it's own block,
     185         * this function is required to be registered.
     186         *
     187         * @param {String} keystroke The current keystroke presentaton.
     188         */
     189        onKeyDown : null
    181190};
    182191
    183192CKEDITOR.ui.panel.block = function( blockHolder )
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy