Ticket #3042: 3042_3.patch

File 3042_3.patch, 15.9 KB (added by Frederico Caldeira Knabben, 15 years ago)
  • _source/core/dom/element.js

     
    311311                 */
    312312                focus : function()
    313313                {
    314                         this.$.focus();
     314                        // IE throws error if the element is not visible.
     315                        try
     316                        {
     317                                this.$.focus();
     318                        }
     319                        catch (e)
     320                        {}
    315321                },
    316322
    317323                /**
  • _source/core/dom/nodelist.js

     
    1717
    1818        getItem : function( index )
    1919        {
    20                 return new CKEDITOR.dom.node( this.$[ index ] );
     20                var $node = this.$[ index ];
     21                return $node ? new CKEDITOR.dom.node( $node ) : null;
    2122        }
    2223};
  • _source/plugins/colorbutton/plugin.js

     
    3838                                                block.autoSize = true;
    3939                                                block.element.addClass( 'cke_colorblock' );
    4040                                                block.element.setHtml( renderColors( panel, type ) );
     41
     42                                                var keys = block.keys;
     43                                                keys[ 39 ]      = 'next';                                       // ARROW-RIGHT
     44                                                keys[ 9 ]       = 'next';                                       // TAB
     45                                                keys[ 37 ]      = 'prev';                                       // ARROW-LEFT
     46                                                keys[ CKEDITOR.SHIFT + 9 ]      = 'prev';       // SHIFT + TAB
     47                                                keys[ 32 ]      = 'click';                                      // SPACE
    4148                                        },
    4249
    4350                                        onOpen : function()
     
    94101
    95102                        // Render the "Automatic" button.
    96103                        output.push(
    97                                 '<a class="cke_colorauto"' +
     104                                '<a class="cke_colorauto" _cke_focus=1 hidefocus=true' +
     105                                        ' title="', lang.auto, '"' +
    98106                                        ' onclick="CKEDITOR.tools.callFunction(', clickFn, ',null,\'', type, '\');"' +
    99107                                        ' href="javascript:void(\'', lang.auto, '\')">' +
    100108                                        '<table cellspacing=0 cellpadding=0 width="100%">' +
     
    119127                                var color = colors[ i ];
    120128                                output.push(
    121129                                        '<td>' +
    122                                                 '<a class="cke_colorbox"' +
     130                                                '<a class="cke_colorbox" _cke_focus=1 hidefocus=true' +
     131                                                        ' title="', color, '"' +
    123132                                                        ' onclick="CKEDITOR.tools.callFunction(', clickFn, ',\'#', color, '\',\'', type, '\');"' +
    124133                                                        ' href="javascript:void(\'', color, '\')">' +
    125134                                                        '<span class="cke_colorbox" style="background-color:#', color, '"></span>' +
     
    134143                                        '</tr>' +
    135144                                        '<tr>' +
    136145                                                '<td colspan=8 align=center>' +
    137                                                         '<a class="cke_colormore"' +
     146                                                        '<a class="cke_colormore" _cke_focus=1 hidefocus=true' +
     147                                                                ' title="', lang.more, '"' +
    138148                                                                ' onclick="CKEDITOR.tools.callFunction(', clickFn, ',\'?\',\'', type, '\');"' +
    139149                                                                ' href="javascript:void(\'', lang.more, '\')">',
    140150                                                                lang.more,
  • _source/plugins/floatpanel/plugin.js

     
    149149                                                iframe.$.contentWindow.focus();
    150150                                        }, 0);
    151151
     152                                panel.onEscape = CKEDITOR.tools.bind( function()
     153                                        {
     154                                                this.onEscape && this.onEscape();
     155                                        },
     156                                        this );
     157
    152158                                if ( this.onShow )
    153159                                        this.onShow.call( this );
    154160                        },
  • _source/plugins/listblock/plugin.js

     
    1 /*
     1/*
    22Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved.
    33For licensing, see LICENSE.html or http://ckeditor.com/license
    44*/
     
    2424                                        this.base( blockHolder );
    2525
    2626                                        this.multiSelect = !!multiSelect;
     27                                       
     28                                        var keys = this.keys;
     29                                        keys[ 40 ]      = 'next';                                       // ARROW-DOWN
     30                                        keys[ 9 ]       = 'next';                                       // TAB
     31                                        keys[ 38 ]      = 'prev';                                       // ARROW-UP
     32                                        keys[ CKEDITOR.SHIFT + 9 ]      = 'prev';       // SHIFT + TAB
     33                                        keys[ 32 ]      = 'click';                                      // SPACE
    2734
    2835                                        this._.pendingHtml = [];
    2936                                        this._.items = {};
     
    6572
    6673                                proto :
    6774                                {
    68                                         add : function( value, html )
     75                                        add : function( value, html, title )
    6976                                        {
    7077                                                var pendingHtml = this._.pendingHtml,
    71                                                         id = CKEDITOR.tools.getNextNumber();
     78                                                        id = 'cke_' + CKEDITOR.tools.getNextNumber();
    7279
    7380                                                if ( !this._.started )
    7481                                                {
     
    7885
    7986                                                this._.items[ value ] = id;
    8087
    81                                                 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>' );
     88                                                pendingHtml.push(
     89                                                        '<li id=', id, ' class=cke_panel_listItem>' +
     90                                                                '<a _cke_focus=1 hidefocus=true' +
     91                                                                        ' title="', title || value, '"' +
     92                                                                        ' href="javascript:void(\'', value, '\')"' +
     93                                                                        ' onclick="CKEDITOR.tools.callFunction(', this._.getClick(), ',\'', value, '\');">',
     94                                                                        html || value,
     95                                                                '</a>' +
     96                                                        '</li>' );
    8297                                        },
    8398
    8499                                        startGroup : function( title )
    85100                                        {
    86101                                                this._.close();
    87102
    88                                                 var id = CKEDITOR.tools.getNextNumber();
     103                                                var id = 'cke_' + CKEDITOR.tools.getNextNumber();
    89104
    90105                                                this._.groups[ title ] = id;
    91106
    92                                                 this._.pendingHtml.push( '<h1 id=cke_', id, ' class=cke_panel_grouptitle>', title, '</h1>' );
     107                                                this._.pendingHtml.push( '<h1 id=', id, ' class=cke_panel_grouptitle>', title, '</h1>' );
    93108                                        },
    94109
    95110                                        commit : function()
     
    112127
    113128                                        hideGroup : function( groupTitle )
    114129                                        {
    115                                                 var group = this.element.getDocument().getById( 'cke_' + this._.groups[ groupTitle ] ),
     130                                                var group = this.element.getDocument().getById( this._.groups[ groupTitle ] ),
    116131                                                        list = group && group.getNext();
    117132
    118133                                                if ( group )
     
    126141
    127142                                        hideItem : function( value )
    128143                                        {
    129                                                 this.element.getDocument().getById( 'cke_' + this._.items[ value ] ).setStyle( 'display', 'none' );
     144                                                this.element.getDocument().getById( this._.items[ value ] ).setStyle( 'display', 'none' );
    130145                                        },
    131146
    132147                                        showAll : function()
     
    137152
    138153                                                for ( var value in items )
    139154                                                {
    140                                                         doc.getById( 'cke_' + items[ value ] ).setStyle( 'display', '' );
     155                                                        doc.getById( items[ value ] ).setStyle( 'display', '' );
    141156                                                }
    142157
    143158                                                for ( title in groups )
    144159                                                {
    145                                                         var group = doc.getById( 'cke_' + groups[ title ] ),
     160                                                        var group = doc.getById( groups[ title ] ),
    146161                                                                list = group.getNext();
    147162
    148163                                                        group.setStyle( 'display', '' );
     
    157172                                                if ( !this.multiSelect )
    158173                                                        this.unmarkAll();
    159174
    160                                                 this.element.getDocument().getById( 'cke_' + this._.items[ value ] ).addClass( 'cke_selected' );
     175                                                this.element.getDocument().getById( this._.items[ value ] ).addClass( 'cke_selected' );
    161176                                        },
    162177
    163178                                        unmark : function( value )
    164179                                        {
    165                                                 this.element.getDocument().getById( 'cke_' + this._.items[ value ] ).removeClass( 'cke_selected' );
     180                                                this.element.getDocument().getById( this._.items[ value ] ).removeClass( 'cke_selected' );
    166181                                        },
    167182
    168183                                        unmarkAll : function()
     
    172187
    173188                                                for ( var value in items )
    174189                                                {
    175                                                         doc.getById( 'cke_' + items[ value ] ).removeClass( 'cke_selected' );
     190                                                        doc.getById( items[ value ] ).removeClass( 'cke_selected' );
    176191                                                }
    177192                                        },
    178193
    179194                                        isMarked : function( value )
    180195                                        {
    181                                                 return this.element.getDocument().getById( 'cke_' + this._.items[ value ] ).hasClass( 'cke_selected' );
     196                                                return this.element.getDocument().getById( this._.items[ value ] ).hasClass( 'cke_selected' );
     197                                        },
     198
     199                                        focus : function( value )
     200                                        {
     201                                                this._.focusIndex = -1;
     202
     203                                                if ( value )
     204                                                {
     205                                                        var selected = this.element.getDocument().getById( this._.items[ value ] ).getFirst();
     206
     207                                                        var links = this.element.getElementsByTag( 'a' ),
     208                                                                link,
     209                                                                i = -1;
     210
     211                                                        while( ( link = links.getItem( ++i ) ) )
     212                                                        {
     213                                                                if ( link.equals( selected ) )
     214                                                                {
     215                                                                        this._.focusIndex = i;
     216                                                                        break;
     217                                                                }
     218                                                        }
     219
     220                                                        setTimeout( function()
     221                                                                {
     222                                                                        selected.focus();
     223                                                                },
     224                                                                0 );
     225                                                }
    182226                                        }
    183227                                }
    184228                        });
  • _source/plugins/panel/plugin.js

     
    137137                                        },
    138138                                        this);
    139139
     140                                doc.on( 'keydown', function( evt )
     141                                        {
     142                                                var keystroke = evt.data.getKeystroke();
     143
     144                                                // Delegate key processing to block.
     145                                                if ( this._.onKeyDown && this._.onKeyDown( keystroke ) === false )
     146                                                {
     147                                                        evt.data.preventDefault();
     148                                                        return;
     149                                                }
     150
     151                                                if ( keystroke == 27 )          // ESC
     152                                                        this.onEscape && this.onEscape();
     153                                        },
     154                                        this );
     155
    140156                                holder = doc.getBody();
    141157                        }
    142158                        else
     
    174190
    175191                this._.currentBlock = block;
    176192
     193                this._.onKeyDown = block.onKeyDown && CKEDITOR.tools.bind( block.onKeyDown, block );
     194
    177195                block.show();
    178196               
    179197                return block;
    180198        }
    181199};
    182200
    183 CKEDITOR.ui.panel.block = function( blockHolder )
     201CKEDITOR.ui.panel.block = CKEDITOR.tools.createClass(
    184202{
    185         this.element = blockHolder.append(
    186                 blockHolder.getDocument().createElement( 'div',
    187                         {
    188                                 attributes :
     203        $ : function( blockHolder )
     204        {
     205                this.element = blockHolder.append(
     206                        blockHolder.getDocument().createElement( 'div',
    189207                                {
    190                                         'class' : 'cke_panel_block'
    191                                 },
    192                                 styles :
    193                                 {
    194                                         display : 'none'
    195                                 }
    196                         }) );
    197 };
     208                                        attributes :
     209                                        {
     210                                                'class' : 'cke_panel_block'
     211                                        },
     212                                        styles :
     213                                        {
     214                                                display : 'none'
     215                                        }
     216                                }) );
     217               
     218                this.keys = {};
     219               
     220                this._.focusIndex = -1;
     221        },
     222       
     223        _ : {},
    198224
    199 CKEDITOR.ui.panel.block.prototype =
    200 {
    201         show : function()
     225        proto :
    202226        {
    203                 this.element.setStyle( 'display', '' );
    204         },
     227                show : function()
     228                {
     229                        this.element.setStyle( 'display', '' );
     230                },
    205231
    206         hide : function()
    207         {
    208                 this.element.setStyle( 'display', 'none' );
     232                hide : function()
     233                {
     234                        this.element.setStyle( 'display', 'none' );
     235                },
     236
     237                onKeyDown : function( keystroke )
     238                {
     239                        var keyAction = this.keys[ keystroke ];
     240                        switch ( keyAction )
     241                        {
     242                                // Move forward.
     243                                case 'next' :
     244                                        var index = this._.focusIndex,
     245                                                links = this.element.getElementsByTag( 'a' ),
     246                                                link;
     247                                       
     248                                        while ( ( link = links.getItem( ++index ) ) )
     249                                        {
     250                                                if ( link.getAttribute( '_cke_focus' ) && link.getStyle( 'display' ) != 'none' )
     251                                                {
     252                                                        this._.focusIndex = index;
     253                                                        link.focus();
     254                                                        break;
     255                                                }
     256                                        }
     257                                        return false;
     258
     259                                // Move backward.
     260                                case 'prev' :
     261                                        var index = this._.focusIndex,
     262                                                links = this.element.getElementsByTag( 'a' ),
     263                                                link;
     264
     265                                        while ( index > 0 && ( link = links.getItem( --index ) ) )
     266                                        {
     267                                                if ( link.getAttribute( '_cke_focus' ) && link.getComputedStyle( 'display' ) != 'none' )
     268                                                {
     269                                                        this._.focusIndex = index;
     270                                                        link.focus();
     271                                                        break;
     272                                                }
     273                                        }
     274                                        return false;
     275
     276                                case 'click' :
     277                                        var index = this._.focusIndex,
     278                                                link = index >= 0 && this.element.getElementsByTag( 'a' ).getItem( index );
     279
     280                                        if ( link )
     281                                                link.$.click();
     282
     283                                        return false;
     284                        }
     285                }
    209286        }
    210 };
     287});
  • _source/plugins/panelbutton/plugin.js

     
    9393                        var keyDownFn = CKEDITOR.tools.addFunction( function( ev, element ){
    9494                               
    9595                                ev = new CKEDITOR.dom.event( ev );
     96
    9697                                var keystroke = ev.getKeystroke();
    9798                                switch ( keystroke )
    9899                                {
    99                                         case 13 :                                       // ENTER
    100                                         case 32 :                                       // SPACE
     100                                        case 13 :       // ENTER
     101                                        case 32 :       // SPACE
     102                                        case 40 :       // ARROW-DOWN
    101103                                                // Show panel 
    102104                                                CKEDITOR.tools.callFunction( clickFn, element );
    103105                                                break;
     
    105107                                                // Delegate the default behavior to toolbar button key handling.
    106108                                                instance.onkey( instance,  keystroke );
    107109                                }
     110
    108111                                // Avoid subsequent focus grab on editor document.
    109112                                ev.preventDefault();
    110113                        });
     
    191194                                        if ( me.onClose )
    192195                                                me.onClose();
    193196                                };
     197
     198                        panel.onEscape = function()
     199                                {
     200                                        panel.hide();
     201                                        me.document.getById( _.id ).focus();
     202                                };
     203
    194204                       
    195205                        if ( this.onBlock )
    196206                                this.onBlock( panel, _.id );
  • _source/plugins/richcombo/plugin.js

     
    1 /*
     1/*
    22Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved.
    33For licensing, see LICENSE.html or http://ckeditor.com/license
    44*/
     
    120120                                },
    121121                                execute : clickFn
    122122                        };
    123                        
    124                         var keyDownFn = CKEDITOR.tools.addFunction( function( ev, element ){
    125                                
    126                                 ev = new CKEDITOR.dom.event( ev );
    127                                 var keystroke = ev.getKeystroke();
    128                                 switch ( keystroke )
     123
     124                        var keyDownFn = CKEDITOR.tools.addFunction( function( ev, element )
    129125                                {
    130                                         case 13 :                                       // ENTER
    131                                         case 32 :                                       // SPACE
    132                                                 // Show panel 
    133                                                 CKEDITOR.tools.callFunction( clickFn, element );
    134                                                 break;
    135                                         default :
    136                                                 // Delegate the default behavior to toolbar button key handling.
    137                                                 instance.onkey( instance,  keystroke );
    138                                 }
    139                                
    140                                 // Avoid subsequent focus grab on editor document.
    141                                 ev.preventDefault();
    142                         });
    143                        
     126                                        ev = new CKEDITOR.dom.event( ev );
     127
     128                                        var keystroke = ev.getKeystroke();
     129                                        switch ( keystroke )
     130                                        {
     131                                                case 13 :       // ENTER
     132                                                case 32 :       // SPACE
     133                                                case 40 :       // ARROW-DOWN
     134                                                        // Show panel
     135                                                        CKEDITOR.tools.callFunction( clickFn, element );
     136                                                        break;
     137                                                default :
     138                                                        // Delegate the default behavior to toolbar button key handling.
     139                                                        instance.onkey( instance,  keystroke );
     140                                        }
     141
     142                                        // Avoid subsequent focus grab on editor document.
     143                                        ev.preventDefault();
     144                                });
     145
    144146                        output.push(
    145147                                '<span id=', id, ' class="cke_rcombo' );
    146148
     
    200202                                                this.element.addClass( me.className );
    201203
    202204                                        me.document.getById( 'cke_' + me.id ).addClass( 'cke_on');
     205                                       
     206                                        list.focus( !me.multiSelect && me.getValue() );
    203207
    204208                                        me._.on = 1;
    205209
     
    220224                                                me.onClose();
    221225                                };
    222226
     227                        panel.onEscape = function()
     228                                {
     229                                        panel.hide();
     230                                        me.document.getById( 'cke_' + me.id ).getFirst().getNext().focus();
     231                                };
     232
    223233                        list.onClick = function( value, marked )
    224234                                {
    225235                                        // Move the focus to the main windows, otherwise it will stay
     
    286296                add : function( value, html, text )
    287297                {
    288298                        this._.items[ value ] = text || value;
    289                         this._.list.add( value, html );
     299                        this._.list.add( value, html, text );
    290300                },
    291301
    292302                startGroup : function( title )
  • _source/skins/default/panel.css

     
    154154    float: left;
    155155}
    156156
    157 a:hover.cke_colorbox
     157a:hover.cke_colorbox,
     158a:focus.cke_colorbox,
     159a:active.cke_colorbox
    158160{
    159161    border: #316ac5 1px solid;
    160162    background-color: #dff1ff;
     
    169171}
    170172
    171173a:hover.cke_colorauto,
    172 a:hover.cke_colormore
     174a:hover.cke_colormore,
     175a:focus.cke_colorauto,
     176a:focus.cke_colormore,
     177a:active.cke_colorauto,
     178a:active.cke_colormore
    173179{
    174180    border: #316ac5 1px solid;
    175181    background-color: #dff1ff;
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy