Ticket #6749: 6749.patch

File 6749.patch, 12.5 KB (added by Alfonso Martínez de Lizarrondo, 12 years ago)

Proposed patch

  • _source/plugins/button/plugin.js

     
    8787                                var element = CKEDITOR.document.getById( id );
    8888                                element.focus();
    8989                        },
    90                         execute : function()
     90                        execute : function( button, onArrow )
    9191                        {
    9292                                // IE 6 needs some time before execution (#7922)
    9393                                if ( CKEDITOR.env.ie && CKEDITOR.env.version < 7 )
    94                                         CKEDITOR.tools.setTimeout( function(){ this.button.click( editor ); }, 0, this );
     94                                        CKEDITOR.tools.setTimeout( function(){ this.button.click( editor, button, onArrow ); }, 0, this );
    9595                                else
    96                                         this.button.click( editor );
     96                                        this.button.click( editor, button, onArrow );
    9797                        }
    9898                };
    9999
     
    179179                if ( this.className )
    180180                        classes += ' ' + this.className;
    181181
     182                if ( this.className )
     183                        classes += ' cke_pane_button';
     184
    182185                output.push(
    183186                        '<span class="cke_button' + ( this.icon && this.icon.indexOf( '.png' ) == -1 ? ' cke_noalphafix' : '' ) + '">',
    184187                        '<a id="', id, '"' +
     
    225228                                        '>&nbsp;</span>' +
    226229                                        '<span id="', id, '_label" class="cke_label">', this.label, '</span>' );
    227230
     231                if (this.additionalHTML)
     232                        output.push( this.additionalHTML );
     233
     234                output.push( '</a>' );
     235
    228236                if ( this.hasArrow )
    229237                {
    230238                        output.push(
     239                        '<a id="', id, '_arrow"' +
     240                                ' class="', classes, '"',
     241                                env.gecko && env.version >= 10900 && !env.hc  ? '' : '" href="javascript:void(\''+ ( this.title || '' ).replace( "'", '' )+ '\')"',
     242                                ' title="', this.title, '"' +
     243                                ' tabindex="-1"' +
     244                                ' hidefocus="true"' +
     245                            ' role="button"' +
     246                                ' aria-labelledby="' + id + '_label"' +
     247                                ' aria-haspopup="true"' );
     248
     249                        // Some browsers don't cancel key events in the keydown but in the
     250                        // keypress.
     251                        // TODO: Check if really needed for Gecko+Mac.
     252                        if ( env.opera || ( env.gecko && env.mac ) )
     253                        {
     254                                output.push(
     255                                        ' onkeypress="return false;"' );
     256                        }
     257
     258                        // With Firefox, we need to force the button to redraw, otherwise it
     259                        // will remain in the focus state.
     260                        if ( env.gecko )
     261                        {
     262                                output.push(
     263                                        ' onblur="this.style.cssText = this.style.cssText;"' );
     264                        }
     265
     266                        output.push(
     267                                        ' onkeydown="return CKEDITOR.tools.callFunction(', keydownFn, ', event);"' +
     268                                        ' onfocus="return CKEDITOR.tools.callFunction(', focusFn,', event);" ' +
     269                                        ( CKEDITOR.env.ie ? 'onclick="return false;" onmouseup' : 'onclick' ) +         // #188
     270                                                '="CKEDITOR.tools.callFunction(', clickFn, ', this, true); return false;">' );
     271
     272                        output.push(
    231273                                        '<span class="cke_buttonarrow">'
    232274                                        // BLACK DOWN-POINTING TRIANGLE
    233275                                        + ( CKEDITOR.env.hc ? '&#9660;' : '&nbsp;' )
    234276                                        + '</span>' );
     277                        output.push( '</a>' );
    235278                }
    236279
    237                 output.push(
    238                         '</a>',
    239                         '</span>' );
     280                output.push( '</span>' );
    240281
    241282                if ( this.onRender )
    242283                        this.onRender();
     
    264305                                element.setAttribute( 'aria-pressed', true ) :
    265306                                element.removeAttribute( 'aria-pressed' );
    266307
     308                        // If the button has an arrow, apply the same state to it
     309                        if ( this.hasArrow )
     310                        {
     311                                element = CKEDITOR.document.getById( this._.id  + '_arrow' );
     312
     313                                if ( element )
     314                                {
     315                                        element.setState( state );
     316                                        state == CKEDITOR.TRISTATE_DISABLED ?
     317                                                element.setAttribute( 'aria-disabled', true ) :
     318                                                element.removeAttribute( 'aria-disabled' );
     319
     320                                        state == CKEDITOR.TRISTATE_ON ?
     321                                                element.setAttribute( 'aria-pressed', true ) :
     322                                                element.removeAttribute( 'aria-pressed' );
     323                                }
     324                        }
     325
    267326                        return true;
    268327                }
    269328                else
  • _source/plugins/colorbutton/plugin.js

     
    1515        init : function( editor )
    1616        {
    1717                var config = editor.config,
    18                         lang = editor.lang.colorButton;
     18                        lang = editor.lang.colorButton,
     19                        lastColor = {};
    1920
    2021                var clickFn;
    2122
    2223                if ( !CKEDITOR.env.hc )
    2324                {
    24                         addButton( 'TextColor', 'fore', lang.textColorTitle );
    25                         addButton( 'BGColor', 'back', lang.bgColorTitle );
     25                        addButton( 'TextColor', 'fore', lang.textColorTitle, editor.config.colorButton_defaultFore || '#f00' );
     26                        addButton( 'BGColor', 'back', lang.bgColorTitle, editor.config.colorButton_defaultBack || '#a9a9a9' );
    2627                }
    2728
    28                 function addButton( name, type, title )
     29                function addButton( name, type, title, initialValue )
    2930                {
    3031                        var colorBoxId = CKEDITOR.tools.getNextId() + '_colorBox';
     32
     33                        lastColor[ type ] = initialValue;
     34
    3135                        editor.ui.add( name, CKEDITOR.UI_PANELBUTTON,
    3236                                {
    3337                                        label : title,
    3438                                        title : title,
    3539                                        className : 'cke_button_' + name.toLowerCase(),
    3640                                        modes : { wysiwyg : 1 },
    37 
     41                                        additionalHTML : '<span class="cke_color_preview" id="' + type + '_preview_' + editor.id + '" style="background:' + initialValue + ';"></span>',
    3842                                        panel :
    3943                                        {
    4044                                                css : editor.skin.editor.css,
    4145                                                attributes : { role : 'listbox', 'aria-label' : lang.panelTitle }
    4246                                        },
    4347
     48                                        onButtonClick: function()
     49                                        {
     50                                                // one-click color
     51                                                applyColor( lastColor[ type ], type );
     52                                        },
     53
    4454                                        onBlock : function( panel, block )
    4555                                        {
    4656                                                block.autoSize = true;
     
    8999                                });
    90100                }
    91101
     102                function applyColor( color, type )
     103                {
     104                        editor.focus();
    92105
     106                        editor.fire( 'saveSnapshot' );
     107
     108                        // Clean up any conflicting style within the range.
     109                        new CKEDITOR.style( config['colorButton_' + type + 'Style'], { color : 'inherit' } ).remove( editor.document );
     110
     111                        if ( color )
     112                        {
     113                                var colorStyle = config['colorButton_' + type + 'Style'];
     114
     115                                colorStyle.childRule = type == 'back' ?
     116                                        function( element )
     117                                        {
     118                                                // It's better to apply background color as the innermost style. (#3599)
     119                                                // Except for "unstylable elements". (#6103)
     120                                                return isUnstylable( element );
     121                                        }
     122                                        :
     123                                        function( element )
     124                                        {
     125                                                // Fore color style must be applied inside links instead of around it. (#4772,#6908)
     126                                                return !( element.is( 'a' ) || element.getElementsByTag( 'a' ).count() ) || isUnstylable( element );
     127                                        };
     128
     129                                new CKEDITOR.style( colorStyle, { color : color } ).apply( editor.document );
     130                        }
     131
     132                        editor.fire( 'saveSnapshot' );
     133
     134                        // Update toolbar preview:
     135                        var preview = CKEDITOR.document.getById( type + '_preview_' + editor.id );
     136                        if ( preview )
     137                                preview.setStyle('backgroundColor', color);
     138                }
     139
    93140                function renderColors( panel, type, colorBoxId )
    94141                {
    95142                        var output = [],
     
    117164                                                return;
    118165                                        }
    119166
    120                                         editor.focus();
     167                                        // Store it for one-click reuse
     168                                        lastColor[ type ] = color;
    121169
    122170                                        panel.hide( false );
    123171
    124                                         editor.fire( 'saveSnapshot' );
    125 
    126                                         // Clean up any conflicting style within the range.
    127                                         new CKEDITOR.style( config['colorButton_' + type + 'Style'], { color : 'inherit' } ).remove( editor.document );
    128 
    129                                         if ( color )
    130                                         {
    131                                                 var colorStyle = config['colorButton_' + type + 'Style'];
    132 
    133                                                 colorStyle.childRule = type == 'back' ?
    134                                                         function( element )
    135                                                         {
    136                                                                 // It's better to apply background color as the innermost style. (#3599)
    137                                                                 // Except for "unstylable elements". (#6103)
    138                                                                 return isUnstylable( element );
    139                                                         }
    140                                                         :
    141                                                         function( element )
    142                                                         {
    143                                                                 // Fore color style must be applied inside links instead of around it. (#4772,#6908)
    144                                                                 return !( element.is( 'a' ) || element.getElementsByTag( 'a' ).count() ) || isUnstylable( element );
    145                                                         };
    146 
    147                                                 new CKEDITOR.style( colorStyle, { color : color } ).apply( editor.document );
    148                                         }
    149 
    150                                         editor.fire( 'saveSnapshot' );
     172                                        applyColor( color, type );
    151173                                });
    152174
    153175                        // Render the "Automatic" button.
     
    298320                element         : 'span',
    299321                styles          : { 'background-color' : '#(color)' }
    300322        };
     323
     324/**
     325 * Default value for the text foreground color button.
     326 * @name CKEDITOR.config.colorButton_defaultFore
     327 * @default <code>'#f00'</code>
     328 * @type string
     329 * @since 3.6.3
     330 * @example
     331 * config.colorButton_defaultFore = '#0f0';
     332 */
     333
     334/**
     335 * Default value for the text background color button.
     336 * @name CKEDITOR.config.colorButton_defaultBack
     337 * @default <code>'#a9a9a9'</code>
     338 * @type string
     339 * @since 3.6.3
     340 * @example
     341 * config.colorButton_defaultBack = '#ff0';
     342 */
     343 No newline at end of file
  • _source/plugins/panelbutton/plugin.js

     
    88        requires : [ 'button' ],
    99        onLoad : function()
    1010        {
    11                 function clickFn( editor )
     11                function clickFn( editor, button, onArrow )
    1212                {
    1313                        var _ = this._;
    1414
    1515                        if ( _.state == CKEDITOR.TRISTATE_DISABLED )
    1616                                return;
    1717
     18                        // If the click wasn't on the arrow and the instance has a handler defined
     19                        // notify it and don't show the pane
     20                        if ( !onArrow && this.onButtonClick )
     21                        {
     22                                this.onButtonClick();
     23                                return;
     24                        }
     25
    1826                        this.createPanel( editor );
    1927
    2028                        if ( _.on )
  • _source/skins/kama/toolbar.css

     
    206206}
    207207
    208208.cke_skin_kama .cke_button a:hover.cke_on,
     209.cke_skin_kama .cke_button:hover a.cke_on,
    209210.cke_skin_kama .cke_button a:focus.cke_on,
    210211.cke_skin_kama .cke_button a:active.cke_on,     /* IE */
    211212.cke_skin_kama .cke_button a:hover.cke_off,
     213.cke_skin_kama .cke_button:hover a.cke_off,
    212214.cke_skin_kama .cke_button a:focus.cke_off,
    213215.cke_skin_kama .cke_button a:active.cke_off     /* IE */
    214216{
     
    218220}
    219221
    220222.cke_skin_kama .cke_button a:hover,
     223.cke_skin_kama .cke_button:hover a,
    221224.cke_skin_kama .cke_button a:focus,
    222225.cke_skin_kama .cke_button a:active     /* IE */
    223226{
     
    225228}
    226229
    227230.cke_skin_kama .cke_button a:hover.cke_on,
     231.cke_skin_kama .cke_button:hover a.cke_on,
    228232.cke_skin_kama .cke_button a:focus.cke_on,
    229233.cke_skin_kama .cke_button a:active.cke_on      /* IE */
    230234{
     
    232236}
    233237
    234238.cke_skin_kama .cke_hc .cke_button a:hover,
     239.cke_skin_kama .cke_hc .cke_button:hover a,
    235240.cke_skin_kama .cke_hc .cke_button a:focus,
    236241.cke_skin_kama .cke_hc .cke_button a:active     /* IE */
    237242{
     
    406411{
    407412        padding-bottom: 0;
    408413}
     414
     415.cke_pane_button
     416{
     417        position: relative;
     418}
     419
     420.cke_color_preview
     421{
     422        bottom: 0;
     423        display: inline-block;
     424        height: 3px;
     425        left: 4px;
     426        position: absolute;
     427        width: 16px;
     428}
  • _source/skins/office2003/toolbar.css

     
    269269}
    270270
    271271.cke_skin_office2003 .cke_hc .cke_button a:hover,
     272.cke_skin_office2003 .cke_hc .cke_button:hover a,
    272273.cke_skin_office2003 .cke_hc .cke_button a:focus,
    273274.cke_skin_office2003 .cke_hc .cke_button a:active       /* IE */
    274275{
     
    308309}
    309310
    310311.cke_skin_office2003 .cke_button a:hover,
     312.cke_skin_office2003 .cke_button:hover a,
    311313.cke_skin_office2003 .cke_button a:focus,
    312314.cke_skin_office2003 .cke_button a:active       /* IE */
    313315{
     
    520522{
    521523        cursor: default;
    522524}
     525
     526.cke_pane_button
     527{
     528        position: relative;
     529}
     530
     531.cke_color_preview
     532{
     533        bottom: 0;
     534        display: inline-block;
     535        height: 3px;
     536        left: 4px;
     537        position: absolute;
     538        width: 16px;
     539}
  • _source/skins/v2/toolbar.css

     
    278278}
    279279
    280280.cke_skin_v2 .cke_button a:hover,
     281.cke_skin_v2 .cke_button:hover a,
    281282.cke_skin_v2 .cke_button a:focus,
    282283.cke_skin_v2 .cke_button a:active       /* IE */
    283284{
     
    287288}
    288289
    289290.cke_skin_v2 .cke_hc .cke_button a:hover,
     291.cke_skin_v2 .cke_hc .cke_button:hover a,
    290292.cke_skin_v2 .cke_hc .cke_button a:focus,
    291293.cke_skin_v2 .cke_hc .cke_button a:active       /* IE */
    292294{
     
    463465{
    464466        cursor: default;
    465467}
     468
     469.cke_pane_button
     470{
     471        position: relative;
     472}
     473
     474.cke_color_preview
     475{
     476        bottom: 0;
     477        display: inline-block;
     478        height: 3px;
     479        left: 4px;
     480        position: absolute;
     481        width: 16px;
     482}
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy