Ticket #33902: 33902.patch
File 33902.patch, 8.4 KB (added by , 8 years ago) |
---|
-
src/wp-admin/css/edit.css
1084 1084 } 1085 1085 1086 1086 .ac_results { 1087 display: none; 1088 margin: -1px 0 0; 1087 1089 padding: 0; 1088 margin: 0;1089 1090 list-style: none; 1090 1091 position: absolute; 1091 1092 z-index: 10000; 1092 display: none; 1093 border: 1px solid #808080; 1093 border: 1px solid #5b9dd9; 1094 1094 background-color: #fff; 1095 1095 } 1096 1096 … … 1099 1099 } 1100 1100 1101 1101 .ac_results li { 1102 padding: 2px 5px; 1102 margin: 0; 1103 padding: 5px 10px; 1103 1104 white-space: nowrap; 1104 color: #101010; 1105 text-align: left; 1105 cursor: pointer; 1106 1106 } 1107 1107 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; 1111 1112 } 1112 1113 1113 1114 .ac_match { -
src/wp-includes/js/jquery/suggest.js
12 12 * 13 13 */ 14 14 15 (function($) { 15 window.wp = window.wp || {}; 16 16 17 ( function( $, wp ) { 18 19 var uid = 1, 20 l10n = window.suggestL10n; 21 17 22 $.suggest = function(input, options) { 18 23 var $input, $results, timeout, prevLength, cache, cacheSize; 19 24 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 }); 22 35 23 timeout = false; // hold timeout ID for suggestion results to appear24 prevLength = 0; // last recorded length of $input.val()25 cache = []; // cache MRU list26 cacheSize = 0; // size of cache in chars (bytes?)36 $results = $("<ul/>").attr({ 37 'id': 'results-list-' + uid, 38 'role': 'listbox' 39 }); 27 40 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 28 53 $results.addClass(options.resultsClass).appendTo('body'); 29 54 55 resetPosition(); 30 56 31 resetPosition();32 57 $(window) 33 58 .load(resetPosition) // just in case user is changing size of page while loading 34 59 .resize(resetPosition); 35 60 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 ); 38 69 }); 39 70 40 71 $input.keydown(processKey); … … 48 79 }); 49 80 } 50 81 51 52 82 function processKey(e) { 53 83 54 84 // handling up/down/escape requires results to be visible … … 80 110 break; 81 111 82 112 case 27: // escape 83 $results.hide();113 hideItems(); 84 114 break; 85 115 86 116 } 87 117 88 } else if ( $input.val().length != prevLength) {118 } else if ( $input.val().length != prevLength ) { 89 119 90 120 if (timeout) 91 121 clearTimeout(timeout); … … 94 124 95 125 } 96 126 97 98 127 } 99 128 100 101 129 function suggest() { 102 130 103 131 var q = $.trim($input.val()), multipleSepPos, items; … … 120 148 121 149 $.get(options.source, {q: q}, function(txt) { 122 150 123 $results.hide();151 hideItems(); 124 152 125 153 items = parseTxt(txt, q); 126 154 … … 132 160 } 133 161 134 162 } else { 135 136 $results.hide(); 137 163 hideItems(); 138 164 } 139 165 140 166 } 141 167 142 143 168 function checkCache(q) { 144 169 var i; 145 170 for (i = 0; i < cache.length; i++) … … 170 195 } 171 196 172 197 function displayItems(items) { 173 var html = '', i ;198 var html = '', i, ariaLabel; 174 199 if (!items) 175 200 return; 176 201 177 202 if (!items.length) { 178 $results.hide();203 hideItems(); 179 204 return; 180 205 } 181 206 182 207 resetPosition(); // when the form moves after the page has loaded 183 208 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 } 186 215 187 216 $results.html(html).show(); 188 217 218 $input.attr( 'aria-expanded', 'true' ); 219 220 setTimeout( function() { 221 wp.a11y.speak( l10n.suggestionsFound.replace( '%d', items.length ) ); 222 }, 10 ); 223 189 224 $results 190 225 .children('li') 191 226 .mouseover(function() { … … 200 235 201 236 } 202 237 238 function hideItems() { 239 $results.hide(); 240 $input.attr( 'aria-expanded', 'false' ); 241 } 242 203 243 function parseTxt(txt, q) { 204 244 205 245 var items = [], tokens = txt.split(options.delimiter), i, token; … … 249 289 } else { 250 290 $input.val($currentResult.text()); 251 291 } 252 $results.hide(); 253 $input.trigger('change'); 292 hideItems(); 293 $input.trigger( 'change' ).removeAttr( 'aria-activedescendant' ); 294 wp.a11y.speak( 'Selected: ' + $currentResult.text() ); 254 295 255 296 if (options.onSelect) 256 297 options.onSelect.apply($input[0]); … … 263 304 264 305 $currentResult = getCurrentResult(); 265 306 266 if ( $currentResult)307 if ( $currentResult ) { 267 308 $currentResult 268 309 .removeClass(options.selectClass) 269 310 .next() 270 311 .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 { 272 319 $results.children('li:first-child').addClass(options.selectClass); 273 320 $input.attr( 'aria-activedescendant', $results.children('li:first-child').attr( 'id' ) ); 321 } 274 322 } 275 323 276 324 function prevResult() { 277 325 var $currentResult = getCurrentResult(); 278 326 279 if ( $currentResult)327 if ( $currentResult ) { 280 328 $currentResult 281 329 .removeClass(options.selectClass) 282 330 .prev() 283 331 .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 { 285 339 $results.children('li:last-child').addClass(options.selectClass); 286 340 $input.attr( 'aria-activedescendant', $results.children('li:last-child').attr( 'id' ) ); 341 } 287 342 } 288 343 } 289 344 … … 313 368 314 369 }; 315 370 316 })( jQuery);371 })( jQuery, window.wp ); -
src/wp-includes/script-loader.php
235 235 // jQuery plugins 236 236 $scripts->add( 'jquery-color', "/wp-includes/js/jquery/jquery.color.min.js", array('jquery'), '2.1.1', 1 ); 237 237 $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 238 242 $scripts->add( 'schedule', '/wp-includes/js/jquery/jquery.schedule.js', array('jquery'), '20m', 1 ); 239 243 $scripts->add( 'jquery-query', "/wp-includes/js/jquery/jquery.query.js", array('jquery'), '2.1.7', 1 ); 240 244 $scripts->add( 'jquery-serialize-object', "/wp-includes/js/jquery/jquery.serialize-object.js", array('jquery'), '0.2', 1 ); … … 481 485 482 486 $scripts->add( 'postbox', "/wp-admin/js/postbox$suffix.js", array('jquery-ui-sortable'), false, 1 ); 483 487 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 ); 485 489 did_action( 'init' ) && $scripts->localize( 'tags-box', 'tagsBoxL10n', array( 486 490 'tagDelimiter' => _x( ',', 'tag delimiter' ), 487 491 ) ); … … 541 545 542 546 $scripts->add( 'theme', "/wp-admin/js/theme$suffix.js", array( 'wp-backbone', 'wp-a11y' ), false, 1 ); 543 547 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 ); 545 549 did_action( 'init' ) && $scripts->localize( 'inline-edit-post', 'inlineEditL10n', array( 546 550 'error' => __('Error while saving the changes.'), 547 551 'ntdeltitle' => __('Remove From Bulk Edit'),