Ticket #3570: 3570_2.patch

File 3570_2.patch, 5.4 KB (added by Garry Yao, 14 years ago)
  • _source/plugins/elementspath/plugin.js

     
    5656                                        }
    5757                                });
    5858
     59                        var filters = editor.config.elementsPath_filters;
     60
    5961                        editor.on( 'selectionChange', function( ev )
    6062                                {
    6163                                        var env = CKEDITOR.env;
     
    6870
    6971                                        while ( element )
    7072                                        {
    71                                                 var index = elementsList.push( element ) - 1;
    72                                                 var name;
    73                                                 if ( element.getAttribute( '_cke_real_element_type' ) )
    74                                                         name = element.getAttribute( '_cke_real_element_type' );
    75                                                 else
    76                                                         name = element.getName();
     73                                                var ignore = 0;
     74                                                for ( var i = 0; i < filters.length; i++ )
     75                                                {
     76                                                        if ( filters[ i ]( element ) === false )
     77                                                        {
     78                                                                ignore = 1;
     79                                                                break;
     80                                                        }
     81                                                }
     82
     83                                                if ( !ignore )
     84                                                {
     85                                                        var index = elementsList.push( element ) - 1;
     86                                                        var name;
     87                                                        if ( element.getAttribute( '_cke_real_element_type' ) )
     88                                                                name = element.getAttribute( '_cke_real_element_type' );
     89                                                        else
     90                                                                name = element.getName();
    7791
    78                                                 // Use this variable to add conditional stuff to the
    79                                                 // HTML (because we are doing it in reverse order... unshift).
    80                                                 var extra = '';
     92                                                        // Use this variable to add conditional stuff to the
     93                                                        // HTML (because we are doing it in reverse order... unshift).
     94                                                        var extra = '';
    8195
    82                                                 // Some browsers don't cancel key events in the keydown but in the
    83                                                 // keypress.
    84                                                 // TODO: Check if really needed for Gecko+Mac.
    85                                                 if ( env.opera || ( env.gecko && env.mac ) )
    86                                                         extra += ' onkeypress="return false;"';
     96                                                        // Some browsers don't cancel key events in the keydown but in the
     97                                                        // keypress.
     98                                                        // TODO: Check if really needed for Gecko+Mac.
     99                                                        if ( env.opera || ( env.gecko && env.mac ) )
     100                                                                extra += ' onkeypress="return false;"';
    87101
    88                                                 // With Firefox, we need to force the button to redraw, otherwise it
    89                                                 // will remain in the focus state.
    90                                                 if ( env.gecko )
    91                                                         extra += ' onblur="this.style.cssText = this.style.cssText;"';
     102                                                        // With Firefox, we need to force the button to redraw, otherwise it
     103                                                        // will remain in the focus state.
     104                                                        if ( env.gecko )
     105                                                                extra += ' onblur="this.style.cssText = this.style.cssText;"';
    92106
    93                                                 var label = editor.lang.elementsPath.eleTitle.replace( /%1/, name );
    94                                                 html.unshift(
    95                                                         '<a' +
    96                                                                 ' id="', idBase, index, '"' +
    97                                                                 ' href="javascript:void(\'', name, '\')"' +
    98                                                                 ' tabindex="-1"' +
    99                                                                 ' title="', label, '"' +
    100                                                                 ( ( CKEDITOR.env.gecko && CKEDITOR.env.version < 10900 ) ?
    101                                                                 ' onfocus="event.preventBubble();"' : '' ) +
    102                                                                 ' hidefocus="true" ' +
    103                                                                 ' onkeydown="return CKEDITOR._.elementsPath.keydown(\'', this.name, '\',', index, ', event);"' +
    104                                                                 extra ,
    105                                                                 ' onclick="return CKEDITOR._.elementsPath.click(\'', this.name, '\',', index, ');"',
    106                                                                 ' role="button" aria-labelledby="' + idBase + index + '_label">',
    107                                                                         name,
    108                                                                         '<span id="', idBase, index, '_label" class="cke_label">' + label + '</span>',
    109                                                         '</a>' );
     107                                                        var label = editor.lang.elementsPath.eleTitle.replace( /%1/, name );
     108                                                        html.unshift(
     109                                                                '<a' +
     110                                                                        ' id="', idBase, index, '"' +
     111                                                                        ' href="javascript:void(\'', name, '\')"' +
     112                                                                        ' tabindex="-1"' +
     113                                                                        ' title="', label, '"' +
     114                                                                        ( ( CKEDITOR.env.gecko && CKEDITOR.env.version < 10900 ) ?
     115                                                                        ' onfocus="event.preventBubble();"' : '' ) +
     116                                                                        ' hidefocus="true" ' +
     117                                                                        ' onkeydown="return CKEDITOR._.elementsPath.keydown(\'', this.name, '\',', index, ', event);"' +
     118                                                                        extra ,
     119                                                                        ' onclick="return CKEDITOR._.elementsPath.click(\'', this.name, '\',', index, ');"',
     120                                                                        ' role="button" aria-labelledby="' + idBase + index + '_label">',
     121                                                                                name,
     122                                                                                '<span id="', idBase, index, '_label" class="cke_label">' + label + '</span>',
     123                                                                '</a>' );
    110124
     125                                                }
     126
    111127                                                if ( name == 'body' )
    112128                                                        break;
    113129
     
    187203                return true;
    188204        }
    189205};
     206
     207/**
     208 * A list of filter functions to determinate whether an element should display in elements path bar.
     209 * @type Array Array of functions that optionaly return 'false' to prevent the element from displaying.
     210 * @default  []
     211 * @example
     212 *      // Prevent elements with attribute 'myAttribue' to appear in elements path.
     213 *      editor.config.elementsPath_filters.push( function( element )
     214 *      {
     215 *              if( element.hasAttribute( 'myAttribute') )
     216 *                      return false;
     217 *      });
     218 */
     219CKEDITOR.config.elementsPath_filters = [];
  • _source/plugins/scayt/plugin.js

     
    594594
    595595                                plugin.loadEngine( editor );
    596596                        }
    597                 }
     597
     598                        // Prevent word marker line from displaying in elements path. (#3570)
     599                        var elementsPathFilters;
     600                        if ( elementsPathFilters = editor.config.elementsPath_filters )
     601                        {
     602                                elementsPathFilters.push( function( element )
     603                                {
     604                                        if ( element.hasAttribute( 'scaytid' ) )
     605                                                return false;
     606                                } );
     607                        }
     608
     609                }
    598610        });
    599611})();
    600612
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy