Ticket #33301: 33301.14.a11y.patch
File 33301.14.a11y.patch, 8.9 KB (added by , 7 years ago) |
---|
-
src/wp-includes/js/tinymce/plugins/wplink/plugin.js
1 ( function( tinymce ) {1 ( function( tinymce, wp ) { 2 2 tinymce.ui.WPLinkPreview = tinymce.ui.Control.extend( { 3 3 url: '#', 4 4 renderHtml: function() { … … 56 56 renderHtml: function() { 57 57 return ( 58 58 '<div id="' + this._id + '" class="wp-link-input">' + 59 '<input type="text" value="" tabindex="-1" placeholder="' + tinymce.translate('Paste URL or type to search') + '" />' +59 '<input type="text" value="" placeholder="' + tinymce.translate( 'Paste URL or type to search' ) + '" />' + 60 60 '<input type="text" style="display:none" value="" />' + 61 61 '</div>' 62 62 ); … … 231 231 232 232 inputInstance.reset(); 233 233 editor.nodeChanged(); 234 // Audible confirmation message when a link has been inserted in the Editor. 235 wp.a11y.speak( ( typeof window.uiAutocompleteL10n !== 'undefined' ) ? window.uiAutocompleteL10n.linkInserted : '' ); 234 236 } ); 235 237 236 238 editor.addCommand( 'wp_link_cancel', function() { … … 348 350 }, 349 351 focus: function( event, ui ) { 350 352 $input.attr( 'aria-activedescendant', 'mce-wp-autocomplete-' + ui.item.ID ); 353 /* 354 * Don't empty the URL input field, when using the arrow keys to 355 * highlight items. See api.jqueryui.com/autocomplete/#event-focus 356 */ 351 357 event.preventDefault(); 352 358 }, 353 359 select: function( event, ui ) { 354 360 $input.val( ui.item.permalink ); 355 361 $( element.firstChild.nextSibling ).val( ui.item.title ); 362 if ( 9 === event.keyCode ) { 363 // Audible confirmation message when a link has been selected. 364 wp.a11y.speak( ( typeof window.uiAutocompleteL10n !== 'undefined' ) ? window.uiAutocompleteL10n.linkSelected : '' ); 365 } 356 366 return false; 357 367 }, 358 368 open: function() { … … 390 400 'aria-autocomplete': 'list', 391 401 'aria-expanded': 'false', 392 402 'aria-owns': $input.autocomplete( 'widget' ).attr( 'id' ) 393 } 403 } ) 394 404 .on( 'focus', function() { 395 $input.autocomplete( 'search' ); 405 var $inputValue = $input.val(); 406 /* 407 * Don't trigger a search if the URL field already has a link or is empty. 408 * Also, avoids screen readers announce `No search results`. 409 */ 410 if ( ! /^https?:/.test( $inputValue ) && '' !== $inputValue ) { 411 $input.autocomplete( 'search' ); 412 } 396 413 } ) 397 414 .autocomplete( 'widget' ) 398 415 .addClass( 'wplink-autocomplete' ) 399 .attr( 'role', 'listbox' ); 416 .attr( 'role', 'listbox' ) 417 .removeAttr( 'tabindex' ); // Remove the `tabindex=0` attribute added by jQuery UI. 400 418 } 401 419 402 420 tinymce.$( input ).on( 'keydown', function( event ) { … … 460 478 var url = inputInstance.getURL() || null, 461 479 text = inputInstance.getLinkText() || null; 462 480 463 editor.focus(); // Needed for IE 481 /* 482 * Accessibility note: moving focus back to the editor confuses 483 * screen readers. They will announce again the Editor ARIA role 484 * `application` and the iframe `title` attribute. 485 * Should be preferably limited to IE or removed if not strictly 486 * necessary. 487 */ 488 if ( tinymce.Env.ie ) { 489 editor.focus(); // Needed for IE 490 } 464 491 window.wpLink.open( editor.id, url, text, linkNode ); 465 492 466 493 editToolbar.tempHide = true; … … 483 510 } 484 511 }; 485 512 } ); 486 } )( window.tinymce );513 } )( window.tinymce, window.wp ); -
src/wp-includes/js/wplink.js
1 1 2 2 var wpLink; 3 3 4 ( function( $, wpLinkL10n ) {4 ( function( $, wpLinkL10n, wp ) { 5 5 var editor, correctedURL, linkNode, 6 6 inputs = {}, 7 7 isTouch = ( 'ontouchend' in document ); … … 76 76 }, 77 77 focus: function( event, ui ) { 78 78 $input.attr( 'aria-activedescendant', 'mce-wp-autocomplete-' + ui.item.ID ); 79 /* 80 * Don't empty the URL input field, when using the arrow keys to 81 * highlight items. See api.jqueryui.com/autocomplete/#event-focus 82 */ 79 83 event.preventDefault(); 80 84 }, 81 85 select: function( event, ui ) { … … 85 89 inputs.text.val( ui.item.title ); 86 90 } 87 91 92 // Audible confirmation message when a link has been selected. 93 wp.a11y.speak( ( typeof window.uiAutocompleteL10n !== 'undefined' ) ? window.uiAutocompleteL10n.linkSelected : '' ); 88 94 return false; 89 95 }, 90 96 open: function() { … … 117 123 118 124 $input.attr( { 119 125 'aria-owns': $input.autocomplete( 'widget' ).attr( 'id' ) 120 } 126 } ) 121 127 .on( 'focus', function() { 122 $input.autocomplete( 'search' ); 128 var $inputValue = $input.val(); 129 /* 130 * Don't trigger a search if the URL field already has a link or is empty. 131 * Also, avoids screen readers announce `No search results`. 132 */ 133 if ( ! /^https?:/.test( $inputValue ) && '' !== $inputValue ) { 134 $input.autocomplete( 'search' ); 135 } 123 136 } ) 124 137 .autocomplete( 'widget' ) 125 138 .addClass( 'wplink-autocomplete' ) 126 .attr( 'role', 'listbox' ); 127 128 139 .attr( 'role', 'listbox' ) 140 .removeAttr( 'tabindex' ); // Remove the `tabindex=0` attribute added by jQuery UI. 129 141 }, 130 142 131 143 // If URL wasn't corrected last time and doesn't start with http:, https:, ? # or /, prepend http:// … … 402 414 403 415 wpLink.close(); 404 416 textarea.focus(); 417 // Audible confirmation message when a link has been inserted in the Editor. 418 wp.a11y.speak( ( typeof window.uiAutocompleteL10n !== 'undefined' ) ? window.uiAutocompleteL10n.linkInserted : '' ); 405 419 }, 406 420 407 421 mceUpdate: function() { … … 450 464 wpLink.close( 'noReset' ); 451 465 editor.focus(); 452 466 editor.nodeChanged(); 467 // Audible confirmation message when a link has been inserted in the Editor. 468 wp.a11y.speak( ( typeof window.uiAutocompleteL10n !== 'undefined' ) ? window.uiAutocompleteL10n.linkInserted : '' ); 453 469 }, 454 470 455 471 keydown: function( event ) { … … 511 527 }; 512 528 513 529 $( document ).ready( wpLink.init ); 514 })( jQuery, window.wpLinkL10n );530 })( jQuery, window.wpLinkL10n, window.wp ); -
src/wp-includes/script-loader.php
204 204 $scripts->add( 'jquery-effects-transfer', "/wp-includes/js/jquery/ui/effect-transfer$dev_suffix.js", array('jquery-effects-core'), '1.11.4', 1 ); 205 205 206 206 $scripts->add( 'jquery-ui-accordion', "/wp-includes/js/jquery/ui/accordion$dev_suffix.js", array('jquery-ui-core', 'jquery-ui-widget'), '1.11.4', 1 ); 207 $scripts->add( 'jquery-ui-autocomplete', "/wp-includes/js/jquery/ui/autocomplete$dev_suffix.js", array( 'jquery-ui-menu'), '1.11.4', 1 );207 $scripts->add( 'jquery-ui-autocomplete', "/wp-includes/js/jquery/ui/autocomplete$dev_suffix.js", array( 'jquery-ui-menu', 'wp-a11y' ), '1.11.4', 1 ); 208 208 $scripts->add( 'jquery-ui-button', "/wp-includes/js/jquery/ui/button$dev_suffix.js", array('jquery-ui-core', 'jquery-ui-widget'), '1.11.4', 1 ); 209 209 $scripts->add( 'jquery-ui-datepicker', "/wp-includes/js/jquery/ui/datepicker$dev_suffix.js", array('jquery-ui-core'), '1.11.4', 1 ); 210 210 $scripts->add( 'jquery-ui-dialog', "/wp-includes/js/jquery/ui/dialog$dev_suffix.js", array('jquery-ui-resizable', 'jquery-ui-draggable', 'jquery-ui-button', 'jquery-ui-position'), '1.11.4', 1 ); … … 226 226 227 227 // Strings for 'jquery-ui-autocomplete' live region messages 228 228 did_action( 'init' ) && $scripts->localize( 'jquery-ui-autocomplete', 'uiAutocompleteL10n', array( 229 'noResults' => __( 'No search results.' ),229 'noResults' => __( 'No search results.' ), 230 230 /* translators: Number of results found when using jQuery UI Autocomplete */ 231 'oneResult' => __( '1 result found. Use up and down arrow keys to navigate.' ), 232 'manyResults' => __( '%d results found. Use up and down arrow keys to navigate.' ), 231 'oneResult' => __( '1 result found. Use up and down arrow keys to navigate.' ), 232 'manyResults' => __( '%d results found. Use up and down arrow keys to navigate.' ), 233 'linkSelected' => __( 'Link selected.' ), 234 'linkInserted' => __( 'Link inserted.' ), 233 235 ) ); 234 236 235 237 // deprecated, not used in core, most functionality is included in jQuery 1.3 … … 401 403 402 404 $scripts->add( 'admin-bar', "/wp-includes/js/admin-bar$suffix.js", array(), false, 1 ); 403 405 404 $scripts->add( 'wplink', "/wp-includes/js/wplink$suffix.js", array( 'jquery' ), false, 1 );406 $scripts->add( 'wplink', "/wp-includes/js/wplink$suffix.js", array( 'jquery', 'wp-a11y' ), false, 1 ); 405 407 did_action( 'init' ) && $scripts->localize( 'wplink', 'wpLinkL10n', array( 406 408 'title' => __('Insert/edit link'), 407 409 'update' => __('Update'),