Ticket #8706: 8706.patch

File 8706.patch, 7.3 KB (added by Garry Yao, 12 years ago)
  • _source/plugins/colordialog/dialogs/colordialog.js

    IDEA additional info:
    Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
    <+>UTF-8
     
    3434                        var target = evt.getTarget(),
    3535                                color;
    3636
    37                         if ( target.getName() == 'a' && ( color = target.getChild( 0 ).getHtml() ) )
     37                        if ( target.getName() == 'td' && ( color = target.getChild( 0 ).getHtml() ) )
    3838                                dialog.getContentElement( 'picker', 'selectedColor' ).setValue( color );
    3939                }
    4040
     41                // Basing black-white decision off of luma scheme using the Rec. 709 version
     42                function whiteOrBlack( color )
     43                {
     44                        color = color.replace( /^#/, '' );
     45                        for ( var i = 0, rgb = []; i <= 2; i++ )
     46                                rgb[i] = parseInt( color.substr( i * 2, 2 ), 16 );
     47                        var luma = (0.2126 * rgb[0]) + (0.7152 * rgb[1]) + (0.0722 * rgb[2]);
     48                        return '#' + ( luma >= 165 ? '000' : 'fff' );
     49                }
     50
     51                var focused;
    4152                function updateHighlight( event )
    4253                {
    4354                        if ( ! ( event instanceof CKEDITOR.dom.event ) )
    4455                                event = event.data;
    4556
    46                         var target = event.getTarget(),
    47                                         color;
     57                        var target = event.getTarget(), color, orgColor;
    4858
    49                         if ( target.getName() == 'a' && ( color = target.getChild( 0 ).getHtml() ) )
     59                        if ( target.getName() == 'td' && ( color = target.getChild( 0 ).getHtml() ) )
    5060                        {
     61                                // Remove previously focused style.
     62                                if ( focused )
     63                                {
     64                                        orgColor = focused.getChild( 0 ).getHtml();
     65                                        focused.setStyle( 'border-color', orgColor );
     66                                        focused.setStyle( 'border-style', 'solid' );
     67                                }
     68
     69                                focused = target;
     70
     71                                // Apply outline style to show focus.
     72                                focused.setStyle( 'border-color', whiteOrBlack( color ) );
     73                                focused.setStyle( 'border-style', 'dotted' );
     74
    5175                                $doc.getById( hicolorId ).setStyle( 'background-color', color );
    5276                                $doc.getById( hicolorTextId ).setHtml( color );
    5377                        }
     
    76100                                // UP-ARROW
    77101                                case 38 :
    78102                                        // relative is TR
    79                                         if ( ( relative = element.getParent().getParent().getPrevious() ) )
     103                                        if ( ( relative = element.getParent().getPrevious() ) )
    80104                                        {
    81                                                 nodeToMove = relative.getChild( [element.getParent().getIndex(), 0] );
     105                                                nodeToMove = relative.getChild( [ element.getIndex() ] );
    82106                                                nodeToMove.focus();
    83107                                        }
    84108                                        ev.preventDefault();
     
    86110                                // DOWN-ARROW
    87111                                case 40 :
    88112                                        // relative is TR
    89                                         if ( ( relative = element.getParent().getParent().getNext() ) )
     113                                        if ( ( relative = element.getParent().getNext() ) )
    90114                                        {
    91                                                 nodeToMove = relative.getChild( [ element.getParent().getIndex(), 0 ] );
     115                                                nodeToMove = relative.getChild( [ element.getIndex() ] );
    92116                                                if ( nodeToMove && nodeToMove.type == 1 )
    93117                                                {
    94118                                                        nodeToMove.focus();
     
    106130                                // RIGHT-ARROW
    107131                                case rtl ? 37 : 39 :
    108132                                        // relative is TD
    109                                         if ( ( relative = element.getParent().getNext() ) )
     133                                        if ( ( nodeToMove = element.getNext() ) )
    110134                                        {
    111                                                 nodeToMove = relative.getChild( 0 );
    112135                                                if ( nodeToMove.type == 1 )
    113136                                                {
    114137                                                        nodeToMove.focus();
     
    116139                                                }
    117140                                        }
    118141                                        // relative is TR
    119                                         else if ( ( relative = element.getParent().getParent().getNext() ) )
     142                                        else if ( ( relative = element.getParent().getNext() ) )
    120143                                        {
    121                                                 nodeToMove = relative.getChild( [ 0, 0 ] );
     144                                                nodeToMove = relative.getChild( [ 0 ] );
    122145                                                if ( nodeToMove && nodeToMove.type == 1 )
    123146                                                {
    124147                                                        nodeToMove.focus();
     
    130153                                // LEFT-ARROW
    131154                                case rtl ? 39 : 37 :
    132155                                        // relative is TD
    133                                         if ( ( relative = element.getParent().getPrevious() ) )
     156                                        if ( ( nodeToMove = element.getPrevious() ) )
    134157                                        {
    135                                                 nodeToMove = relative.getChild( 0 );
    136158                                                nodeToMove.focus();
    137159                                                ev.preventDefault( true );
    138160                                        }
    139161                                        // relative is TR
    140                                         else if ( ( relative = element.getParent().getParent().getPrevious() ) )
     162                                        else if ( ( relative = element.getParent().getPrevious() ) )
    141163                                        {
    142                                                 nodeToMove = relative.getLast().getChild( 0 );
     164                                                nodeToMove = relative.getLast();
    143165                                                nodeToMove.focus();
    144166                                                ev.preventDefault( true );
    145167                                        }
     
    160182                        {
    161183                                for ( var i = rangeA ; i < rangeA + 3 ; i++ )
    162184                                {
    163                                         var row = table.$.insertRow( -1 );
     185                                        var row = new $el( table.$.insertRow( -1 ) );
     186                                        row.setAttribute( 'role', 'row' );
    164187
    165188                                        for ( var j = rangeB ; j < rangeB + 3 ; j++ )
    166189                                        {
    167190                                                for ( var n = 0 ; n < 6 ; n++ )
    168191                                                {
    169                                                         appendColorCell( row, '#' + aColors[j] + aColors[n] + aColors[i] );
     192                                                        appendColorCell( row.$, '#' + aColors[j] + aColors[n] + aColors[i] );
    170193                                                }
    171194                                        }
    172195                                }
     
    177200                        {
    178201                                var cell = new $el( targetRow.insertCell( -1 ) );
    179202                                cell.setAttribute( 'class', 'ColorCell' );
     203                                cell.setAttribute( 'tabIndex', -1 );
     204                                cell.setAttribute( 'role', 'gridcell' );
     205                                cell.setAttribute( 'onkeydown', 'CKEDITOR.tools.callFunction( ' + onKeydownHandler + ', event, this )' );
     206                                cell.setAttribute( 'onclick', 'CKEDITOR.tools.callFunction( ' + onClickHandler + ', event, this )' );
    180207                                cell.setStyle( 'background-color', color );
     208                                cell.setStyle( 'border', '1px solid ' + color );
    181209
    182                                 cell.setStyle( 'width', '15px' );
    183                                 cell.setStyle( 'height', '15px' );
     210                                cell.setStyle( 'width', '14px' );
     211                                cell.setStyle( 'height', '14px' );
    184212
    185                                 var index = cell.$.cellIndex + 1 + 18 * targetRow.rowIndex;
    186                                 cell.append( CKEDITOR.dom.element.createFromHtml(
    187                                                 '<a href="javascript: void(0);" role="option"' +
    188                                                 ' aria-posinset="' + index + '"' +
    189                                                 ' aria-setsize="' + 13 * 18 + '"' +
    190                                                 ' style="cursor: pointer;display:block;width:100%;height:100% " title="'+ CKEDITOR.tools.htmlEncode( color )+ '"' +
    191                                                 ' onkeydown="CKEDITOR.tools.callFunction( ' + onKeydownHandler + ', event, this )"' +
    192                                                 ' onclick="CKEDITOR.tools.callFunction(' + onClickHandler + ', event, this ); return false;"' +
    193                                                 ' tabindex="-1"><span class="cke_voice_label">' + color + '</span>&nbsp;</a>', CKEDITOR.document ) );
     213                                cell.append( CKEDITOR.dom.element.createFromHtml( '<span class="cke_voice_label">' + color + '</span>', CKEDITOR.document ) );
    194214                        }
    195215
    196216                        appendColorRow( 0, 0 );
     
    251271                                                        [
    252272                                                                {
    253273                                                                        type : 'html',
    254                                                                         html :  '<table role="listbox" aria-labelledby="' + tableLabelId + '" onmouseout="CKEDITOR.tools.callFunction( ' + onMouseout + ' );">' +
    255                                                                                         ( !CKEDITOR.env.webkit ? html : '' ) +
    256                                                                                 '</table><span id="' + tableLabelId + '" class="cke_voice_label">' + lang.options +'</span>',
     274                                                                        html :  '<table tabIndex="-1" role="grid" aria-labelledby="' + tableLabelId +
     275                                                                                          '" onmouseout="CKEDITOR.tools.callFunction( ' + onMouseout +
     276                                                                                          ' );" style="border-collapse:separate;" cellspacing="0">' +
     277                                                                                        ( !CKEDITOR.env.webkit ? html : '' ) + '</table><span id="' + tableLabelId + '" class="cke_voice_label">' + lang.options +'</span>',
    257278                                                                        onLoad : function()
    258279                                                                        {
    259280                                                                                var table = CKEDITOR.document.getById( this.domId );
     
    267288                                                                        },
    268289                                                                        focus: function()
    269290                                                                        {
    270                                                                                 var firstColor = this.getElement().getElementsByTag( 'a' ).getItem( 0 );
     291                                                                                var firstColor = this.getElement().getElementsByTag( 'td' ).getItem( 0 );
    271292                                                                                firstColor.focus();
    272293                                                                        }
    273294                                                                },
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy