Make WordPress Core

Ticket #33902: 33902.patch

File 33902.patch, 8.4 KB (added by afercia, 8 years ago)
  • src/wp-admin/css/edit.css

     
    10841084}
    10851085
    10861086.ac_results {
     1087        display: none;
     1088        margin: -1px 0 0;
    10871089        padding: 0;
    1088         margin: 0;
    10891090        list-style: none;
    10901091        position: absolute;
    10911092        z-index: 10000;
    1092         display: none;
    1093         border: 1px solid #808080;
     1093        border: 1px solid #5b9dd9;
    10941094        background-color: #fff;
    10951095}
    10961096
     
    10991099}
    11001100
    11011101.ac_results li {
    1102         padding: 2px 5px;
     1102        margin: 0;
     1103        padding: 5px 10px;
    11031104        white-space: nowrap;
    1104         color: #101010;
    1105         text-align: left;
     1105        cursor: pointer;
    11061106}
    11071107
    1108 .ac_over {
    1109         background-color: #f0f0b8;
    1110         cursor: pointer;
     1108.ac_results .ac_over,
     1109.ac_over .ac_match {
     1110        background-color: #0073aa;
     1111        color: #fff;
    11111112}
    11121113
    11131114.ac_match {
  • src/wp-includes/js/jquery/suggest.js

     
    1212 *
    1313 */
    1414
    15 (function($) {
     15window.wp = window.wp || {};
    1616
     17( function( $, wp ) {
     18
     19        var uid = 1,
     20                l10n = window.suggestL10n;
     21
    1722        $.suggest = function(input, options) {
    1823                var $input, $results, timeout, prevLength, cache, cacheSize;
    1924
    20                 $input = $(input).attr("autocomplete", "off");
    21                 $results = $("<ul/>");
     25                $input = $( input ).attr({
     26                        'autocomplete': 'off',
     27                        'autocorrect': 'off',
     28                        'autocapitalize': 'none',
     29                        'spellcheck': 'false',
     30                        'role': 'combobox',
     31                        'aria-owns': 'results-list-' + uid,
     32                        'aria-autocomplete': 'list',
     33                        'aria-expanded': 'false'
     34                });
    2235
    23                 timeout = false;                // hold timeout ID for suggestion results to appear
    24                 prevLength = 0;                 // last recorded length of $input.val()
    25                 cache = [];                             // cache MRU list
    26                 cacheSize = 0;                  // size of cache in chars (bytes?)
     36                $results = $("<ul/>").attr({
     37                        'id': 'results-list-' + uid,
     38                        'role': 'listbox'
     39                });
    2740
     41                // Increment the unique ID in case of multiple suggest on the same page.
     42                uid++;
     43
     44                // Hold timeout ID for suggestion results to appear.
     45                timeout = false;
     46                // Last recorded length of $input.val().
     47                prevLength = 0;
     48                // Cache MRU list
     49                cache = [];
     50                // Size of cache in chars (bytes?).
     51                cacheSize = 0;
     52
    2853                $results.addClass(options.resultsClass).appendTo('body');
    2954
     55                resetPosition();
    3056
    31                 resetPosition();
    3257                $(window)
    3358                        .load(resetPosition)            // just in case user is changing size of page while loading
    3459                        .resize(resetPosition);
    3560
    36                 $input.blur(function() {
    37                         setTimeout(function() { $results.hide() }, 200);
     61                $input.blur( function() {
     62                        if ( timeout ) {
     63                                clearTimeout( timeout );
     64                        }
     65
     66                        setTimeout( function() {
     67                                hideItems();
     68                        }, 200 );
    3869                });
    3970
    4071                $input.keydown(processKey);
     
    4879                        });
    4980                }
    5081
    51 
    5282                function processKey(e) {
    5383
    5484                        // handling up/down/escape requires results to be visible
     
    80110                                                break;
    81111
    82112                                        case 27: //     escape
    83                                                 $results.hide();
     113                                                hideItems();
    84114                                                break;
    85115
    86116                                }
    87117
    88                         } else if ($input.val().length != prevLength) {
     118                        } else if ( $input.val().length != prevLength ) {
    89119
    90120                                if (timeout)
    91121                                        clearTimeout(timeout);
     
    94124
    95125                        }
    96126
    97 
    98127                }
    99128
    100 
    101129                function suggest() {
    102130
    103131                        var q = $.trim($input.val()), multipleSepPos, items;
     
    120148
    121149                                        $.get(options.source, {q: q}, function(txt) {
    122150
    123                                                 $results.hide();
     151                                                hideItems();
    124152
    125153                                                items = parseTxt(txt, q);
    126154
     
    132160                                }
    133161
    134162                        } else {
    135 
    136                                 $results.hide();
    137 
     163                                hideItems();
    138164                        }
    139165
    140166                }
    141167
    142 
    143168                function checkCache(q) {
    144169                        var i;
    145170                        for (i = 0; i < cache.length; i++)
     
    170195                }
    171196
    172197                function displayItems(items) {
    173                         var html = '', i;
     198                        var html = '', i, ariaLabel;
    174199                        if (!items)
    175200                                return;
    176201
    177202                        if (!items.length) {
    178                                 $results.hide();
     203                                hideItems();
    179204                                return;
    180205                        }
    181206
    182207                        resetPosition(); // when the form moves after the page has loaded
    183208
    184                         for (i = 0; i < items.length; i++)
    185                                 html += '<li>' + items[i] + '</li>';
     209                        for ( i = 0; i < items.length; i++ ) {
     210                                uid++;
     211                                ariaLabel = '<span>' + items[i] + '</span>';
     212                                ariaLabel = $( ariaLabel ).text();
     213                                html += '<li role="option" id="suggestion-' + uid + '" aria-label="' + ariaLabel + '">' + items[i] + '</li>';
     214                        }
    186215
    187216                        $results.html(html).show();
    188217
     218                        $input.attr( 'aria-expanded', 'true' );
     219
     220                        setTimeout( function() {
     221                                wp.a11y.speak( l10n.suggestionsFound.replace( '%d', items.length ) );
     222                        }, 10 );
     223
    189224                        $results
    190225                                .children('li')
    191226                                .mouseover(function() {
     
    200235
    201236                }
    202237
     238                function hideItems() {
     239                        $results.hide();
     240                        $input.attr( 'aria-expanded', 'false' );
     241                }
     242
    203243                function parseTxt(txt, q) {
    204244
    205245                        var items = [], tokens = txt.split(options.delimiter), i, token;
     
    249289                                } else {
    250290                                        $input.val($currentResult.text());
    251291                                }
    252                                 $results.hide();
    253                                 $input.trigger('change');
     292                                hideItems();
     293                                $input.trigger( 'change' ).removeAttr( 'aria-activedescendant' );
     294                                wp.a11y.speak( 'Selected: ' + $currentResult.text() );
    254295
    255296                                if (options.onSelect)
    256297                                        options.onSelect.apply($input[0]);
     
    263304
    264305                        $currentResult = getCurrentResult();
    265306
    266                         if ($currentResult)
     307                        if ( $currentResult ) {
    267308                                $currentResult
    268309                                        .removeClass(options.selectClass)
    269310                                        .next()
    270311                                                .addClass(options.selectClass);
    271                         else
     312
     313                                if ( $currentResult.next().length ) {
     314                                        $input.attr( 'aria-activedescendant', $currentResult.next().attr( 'id' ) );
     315                                } else {
     316                                        $input.removeAttr( 'aria-activedescendant' );
     317                                }
     318                        } else {
    272319                                $results.children('li:first-child').addClass(options.selectClass);
    273 
     320                                $input.attr( 'aria-activedescendant', $results.children('li:first-child').attr( 'id' ) );
     321                        }
    274322                }
    275323
    276324                function prevResult() {
    277325                        var $currentResult = getCurrentResult();
    278326
    279                         if ($currentResult)
     327                        if ( $currentResult ) {
    280328                                $currentResult
    281329                                        .removeClass(options.selectClass)
    282330                                        .prev()
    283331                                                .addClass(options.selectClass);
    284                         else
     332
     333                                if ( $currentResult.prev().length ) {
     334                                        $input.attr( 'aria-activedescendant', $currentResult.prev().attr( 'id' ) );
     335                                } else {
     336                                        $input.removeAttr( 'aria-activedescendant' );
     337                                }
     338                        } else {
    285339                                $results.children('li:last-child').addClass(options.selectClass);
    286 
     340                                $input.attr( 'aria-activedescendant', $results.children('li:last-child').attr( 'id' ) );
     341                        }
    287342                }
    288343        }
    289344
     
    313368
    314369        };
    315370
    316 })(jQuery);
     371})( jQuery, window.wp );
  • src/wp-includes/script-loader.php

     
    235235        // jQuery plugins
    236236        $scripts->add( 'jquery-color', "/wp-includes/js/jquery/jquery.color.min.js", array('jquery'), '2.1.1', 1 );
    237237        $scripts->add( 'suggest', "/wp-includes/js/jquery/suggest$suffix.js", array('jquery'), '1.1-20110113', 1 );
     238        did_action( 'init' ) && $scripts->localize( 'suggest', 'suggestL10n', array(
     239                'suggestionsFound' => __( 'Suggestions found: %d' ),
     240        ) );
     241
    238242        $scripts->add( 'schedule', '/wp-includes/js/jquery/jquery.schedule.js', array('jquery'), '20m', 1 );
    239243        $scripts->add( 'jquery-query', "/wp-includes/js/jquery/jquery.query.js", array('jquery'), '2.1.7', 1 );
    240244        $scripts->add( 'jquery-serialize-object', "/wp-includes/js/jquery/jquery.serialize-object.js", array('jquery'), '0.2', 1 );
     
    481485
    482486                $scripts->add( 'postbox', "/wp-admin/js/postbox$suffix.js", array('jquery-ui-sortable'), false, 1 );
    483487
    484                 $scripts->add( 'tags-box', "/wp-admin/js/tags-box$suffix.js", array( 'jquery', 'suggest' ), false, 1 );
     488                $scripts->add( 'tags-box', "/wp-admin/js/tags-box$suffix.js", array( 'jquery', 'suggest', 'wp-a11y' ), false, 1 );
    485489                did_action( 'init' ) && $scripts->localize( 'tags-box', 'tagsBoxL10n', array(
    486490                        'tagDelimiter' => _x( ',', 'tag delimiter' ),
    487491                ) );
     
    541545
    542546                $scripts->add( 'theme', "/wp-admin/js/theme$suffix.js", array( 'wp-backbone', 'wp-a11y' ), false, 1 );
    543547
    544                 $scripts->add( 'inline-edit-post', "/wp-admin/js/inline-edit-post$suffix.js", array( 'jquery', 'suggest' ), false, 1 );
     548                $scripts->add( 'inline-edit-post', "/wp-admin/js/inline-edit-post$suffix.js", array( 'jquery', 'suggest', 'wp-a11y' ), false, 1 );
    545549                did_action( 'init' ) && $scripts->localize( 'inline-edit-post', 'inlineEditL10n', array(
    546550                        'error' => __('Error while saving the changes.'),
    547551                        'ntdeltitle' => __('Remove From Bulk Edit'),