Ticket #6749: 6749_2.patch

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

Improved 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
     
    182182                output.push(
    183183                        '<span class="cke_button' + ( this.icon && this.icon.indexOf( '.png' ) == -1 ? ' cke_noalphafix' : '' ) + '">',
    184184                        '<a id="', id, '"' +
    185                                 ' class="', classes, '"',
     185                                ' class="', classes, ( this.hasArrow ?  ' cke_pane_button' : '' ), '"',
    186186                                env.gecko && env.version >= 10900 && !env.hc  ? '' : '" href="javascript:void(\''+ ( this.title || '' ).replace( "'", '' )+ '\')"',
    187187                                ' title="', this.title, '"' +
    188188                                ' tabindex="-1"' +
     
    225225                                        '>&nbsp;</span>' +
    226226                                        '<span id="', id, '_label" class="cke_label">', this.label, '</span>' );
    227227
     228                if (this.additionalHTML)
     229                        output.push( this.additionalHTML );
     230
     231                output.push( '</a>' );
     232
    228233                if ( this.hasArrow )
    229234                {
    230235                        output.push(
     236                        '<a id="', id, '_arrow"' +
     237                                ' class="', classes, ' cke_pane_arrow', '"',
     238                                env.gecko && env.version >= 10900 && !env.hc  ? '' : '" href="javascript:void(\''+ ( this.title || '' ).replace( "'", '' )+ '\')"',
     239                                ' title="', this.title, '"' +
     240                                ' tabindex="-1"' +
     241                                ' hidefocus="true"' +
     242                            ' role="button"' +
     243                                ' aria-labelledby="' + id + '_label"' +
     244                                ' aria-haspopup="true"' );
     245
     246                        // Some browsers don't cancel key events in the keydown but in the
     247                        // keypress.
     248                        // TODO: Check if really needed for Gecko+Mac.
     249                        if ( env.opera || ( env.gecko && env.mac ) )
     250                        {
     251                                output.push(
     252                                        ' onkeypress="return false;"' );
     253                        }
     254
     255                        // With Firefox, we need to force the button to redraw, otherwise it
     256                        // will remain in the focus state.
     257                        if ( env.gecko )
     258                        {
     259                                output.push(
     260                                        ' onblur="this.style.cssText = this.style.cssText;"' );
     261                        }
     262
     263                        output.push(
     264                                        ' onkeydown="return CKEDITOR.tools.callFunction(', keydownFn, ', event);"' +
     265                                        ' onfocus="return CKEDITOR.tools.callFunction(', focusFn,', event);" ' +
     266                                        ( CKEDITOR.env.ie ? 'onclick="return false;" onmouseup' : 'onclick' ) +         // #188
     267                                                '="CKEDITOR.tools.callFunction(', clickFn, ', this, true); return false;">' );
     268
     269                        output.push(
    231270                                        '<span class="cke_buttonarrow">'
    232271                                        // BLACK DOWN-POINTING TRIANGLE
    233272                                        + ( CKEDITOR.env.hc ? '&#9660;' : '&nbsp;' )
    234273                                        + '</span>' );
     274                        output.push( '</a>' );
    235275                }
    236276
    237                 output.push(
    238                         '</a>',
    239                         '</span>' );
     277                output.push( '</span>' );
    240278
    241279                if ( this.onRender )
    242280                        this.onRender();
     
    264302                                element.setAttribute( 'aria-pressed', true ) :
    265303                                element.removeAttribute( 'aria-pressed' );
    266304
     305                        // If the button has an arrow, apply the same state to it
     306                        if ( this.hasArrow )
     307                        {
     308                                element = CKEDITOR.document.getById( this._.id  + '_arrow' );
     309
     310                                if ( element )
     311                                {
     312                                        element.setState( state );
     313                                        state == CKEDITOR.TRISTATE_DISABLED ?
     314                                                element.setAttribute( 'aria-disabled', true ) :
     315                                                element.removeAttribute( 'aria-disabled' );
     316
     317                                        state == CKEDITOR.TRISTATE_ON ?
     318                                                element.setAttribute( 'aria-pressed', true ) :
     319                                                element.removeAttribute( 'aria-pressed' );
     320                                }
     321                        }
     322
    267323                        return true;
    268324                }
    269325                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/menubutton/plugin.js

     
    2121
    2222(function()
    2323{
    24         var clickFn = function( editor )
     24        var clickFn = function( editor, button, onArrow )
    2525        {
    2626                var _ = this._;
    2727
     
    2929                if ( _.state === CKEDITOR.TRISTATE_DISABLED )
    3030                        return;
    3131
     32                // If the click wasn't on the arrow and the instance has a handler defined
     33                // notify it and don't show the pane
     34                if ( !onArrow && this.onButtonClick )
     35                {
     36                        this.onButtonClick();
     37                        return;
     38                }
     39
    3240                _.previousState = _.state;
    3341
    3442                // Check if we already have a menu for it, otherwise just create it.
  • _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/plugins/scayt/plugin.js

     
    615615                                                {
    616616                                                        command.on( 'state', function()
    617617                                                        {
     618                                                                console.log(this)
    618619                                                                this.setState( command.state );
    619620                                                        },
    620621                                                        this);
    621622                                                },
     623                                                onButtonClick: function()
     624                                                {
     625                                                        // one-click toggle
     626                                                        command.exec();
     627                                                },
    622628                                                onMenu : function()
    623629                                                {
    624630                                                        var isEnabled = plugin.isScaytEnabled( editor );
  • _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_skin_kama .cke_button a.cke_pane_button
     421{
     422        border-radius: 3px 0px 0px 3px;
     423        border-right: 0;
     424        padding-right: 0 !important;
     425}
     426
     427.cke_skin_kama .cke_button a.cke_pane_arrow
     428{
     429        border-radius: 0px 3px 3px 0px;
     430        padding-left: 0 !important;
     431}
     432
     433.cke_color_preview
     434{
     435        bottom: 0;
     436        display: inline-block;
     437        height: 3px;
     438        left: 4px;
     439        position: absolute;
     440        width: 16px;
     441}
  • _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_skin_office2003 .cke_button a.cke_pane_button
     532{
     533        border-radius: 3px 0px 0px 3px;
     534        border-right: 0;
     535        padding-right: 0 !important;
     536}
     537
     538.cke_skin_office2003 .cke_button a.cke_pane_arrow
     539{
     540        border-radius: 0px 3px 3px 0px;
     541        padding-left: 0 !important;
     542}
     543
     544.cke_color_preview
     545{
     546        bottom: 0;
     547        display: inline-block;
     548        height: 3px;
     549        left: 4px;
     550        position: absolute;
     551        width: 16px;
     552}
  • _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_skin_v2 .cke_button a.cke_pane_button
     475{
     476        border-radius: 3px 0px 0px 3px;
     477        border-right: 0;
     478        padding-right: 0 !important;
     479}
     480
     481.cke_skin_v2 .cke_button a.cke_pane_arrow
     482{
     483        border-radius: 0px 3px 3px 0px;
     484        padding-left: 0 !important;
     485        position: relative;
     486        top: -1px;
     487}
     488
     489.cke_color_preview
     490{
     491        bottom: 0;
     492        display: inline-block;
     493        height: 3px;
     494        left: 4px;
     495        position: absolute;
     496        width: 16px;
     497}
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy