Changeset 36984
- Timestamp:
- 03/14/2016 12:52:20 AM (9 years ago)
- Location:
- trunk/src/wp-includes
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/js/tinymce/plugins/wplink/plugin.js
r36982 r36984 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>' … … 236 236 inputInstance.reset(); 237 237 editor.nodeChanged(); 238 239 // Audible confirmation message when a link has been inserted in the Editor. 240 if ( typeof window.wp !== 'undefined' && window.wp.a11y && typeof window.wpLinkL10n !== 'undefined' ) { 241 window.wp.a11y.speak( window.wpLinkL10n.linkInserted ); 242 } 238 243 } ); 239 244 … … 372 377 focus: function( event, ui ) { 373 378 $input.attr( 'aria-activedescendant', 'mce-wp-autocomplete-' + ui.item.ID ); 379 /* 380 * Don't empty the URL input field, when using the arrow keys to 381 * highlight items. See api.jqueryui.com/autocomplete/#event-focus 382 */ 374 383 event.preventDefault(); 375 384 }, … … 377 386 $input.val( ui.item.permalink ); 378 387 $( element.firstChild.nextSibling ).val( ui.item.title ); 388 389 if ( 9 === event.keyCode && typeof window.wp !== 'undefined' && 390 window.wp.a11y && typeof window.wpLinkL10n !== 'undefined' ) { 391 // Audible confirmation message when a link has been selected. 392 window.wp.a11y.speak( window.wpLinkL10n.linkSelected ); 393 } 394 379 395 return false; 380 396 }, … … 414 430 'aria-expanded': 'false', 415 431 'aria-owns': $input.autocomplete( 'widget' ).attr( 'id' ) 416 } 432 } ) 417 433 .on( 'focus', function() { 418 $input.autocomplete( 'search' ); 434 var inputValue = $input.val(); 435 /* 436 * Don't trigger a search if the URL field already has a link or is empty. 437 * Also, avoids screen readers announce `No search results`. 438 */ 439 if ( inputValue && ! /^https?:/.test( inputValue ) ) { 440 $input.autocomplete( 'search' ); 441 } 419 442 } ) 420 443 .autocomplete( 'widget' ) 421 444 .addClass( 'wplink-autocomplete' ) 422 .attr( 'role', 'listbox' ); 445 .attr( 'role', 'listbox' ) 446 .removeAttr( 'tabindex' ); // Remove the `tabindex=0` attribute added by jQuery UI. 423 447 } 424 448 … … 484 508 text = inputInstance.getLinkText() || null; 485 509 486 editor.focus(); // Needed for IE 510 /* 511 * Accessibility note: moving focus back to the editor confuses 512 * screen readers. They will announce again the Editor ARIA role 513 * `application` and the iframe `title` attribute. 514 * 515 * Unfortunately IE looses the selection when the editor iframe 516 * looses focus, so without returning focus to the editor, the code 517 * in the modal will not be able to get the selection, place the caret 518 * at the same location, etc. 519 */ 520 if ( tinymce.Env.ie ) { 521 editor.focus(); // Needed for IE 522 } 523 487 524 window.wpLink.open( editor.id, url, text, linkNode ); 488 525 -
trunk/src/wp-includes/js/wplink.js
r36977 r36984 2 2 var wpLink; 3 3 4 ( function( $, wpLinkL10n ) {4 ( function( $, wpLinkL10n, wp ) { 5 5 var editor, correctedURL, linkNode, 6 6 inputs = {}, … … 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 }, … … 85 89 inputs.text.val( ui.item.title ); 86 90 } 91 92 // Audible confirmation message when a link has been selected. 93 wp.a11y.speak( wpLinkL10n.linkSelected ); 87 94 88 95 return false; … … 118 125 $input.attr( { 119 126 'aria-owns': $input.autocomplete( 'widget' ).attr( 'id' ) 120 } 127 } ) 121 128 .on( 'focus', function() { 122 $input.autocomplete( 'search' ); 129 var inputValue = $input.val(); 130 /* 131 * Don't trigger a search if the URL field already has a link or is empty. 132 * Also, avoids screen readers announce `No search results`. 133 */ 134 if ( inputValue && ! /^https?:/.test( inputValue ) ) { 135 $input.autocomplete( 'search' ); 136 } 123 137 } ) 124 138 .autocomplete( 'widget' ) 125 139 .addClass( 'wplink-autocomplete' ) 126 .attr( 'role', 'listbox' ); 127 128 140 .attr( 'role', 'listbox' ) 141 .removeAttr( 'tabindex' ); // Remove the `tabindex=0` attribute added by jQuery UI. 129 142 }, 130 143 … … 171 184 } 172 185 173 if ( editor && window.tinymce.isIE && ! editor.windowManager.wplinkBookmark) {186 if ( editor && window.tinymce.isIE ) { 174 187 editor.windowManager.wplinkBookmark = editor.selection.getBookmark(); 175 188 } … … 403 416 wpLink.close(); 404 417 textarea.focus(); 418 419 // Audible confirmation message when a link has been inserted in the Editor. 420 wp.a11y.speak( wpLinkL10n.linkInserted ); 405 421 }, 406 422 … … 451 467 editor.focus(); 452 468 editor.nodeChanged(); 469 470 // Audible confirmation message when a link has been inserted in the Editor. 471 wp.a11y.speak( wpLinkL10n.linkInserted ); 453 472 }, 454 473 … … 512 531 513 532 $( document ).ready( wpLink.init ); 514 })( jQuery, window.wpLinkL10n );533 })( jQuery, window.wpLinkL10n, window.wp ); -
trunk/src/wp-includes/script-loader.php
r36964 r36984 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 ); … … 227 227 // Strings for 'jquery-ui-autocomplete' live region messages 228 228 did_action( 'init' ) && $scripts->localize( 'jquery-ui-autocomplete', 'uiAutocompleteL10n', array( 229 230 231 232 229 'noResults' => __( 'No search results.' ), 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.' ), 233 233 ) ); 234 234 … … 253 253 $scripts->add( 'thickbox', "/wp-includes/js/thickbox/thickbox.js", array('jquery'), '3.1-20121105', 1 ); 254 254 did_action( 'init' ) && $scripts->localize( 'thickbox', 'thickboxL10n', array( 255 256 257 258 259 260 261 255 'next' => __('Next >'), 256 'prev' => __('< Prev'), 257 'image' => __('Image'), 258 'of' => __('of'), 259 'close' => __('Close'), 260 'noiframes' => __('This feature requires inline frames. You have iframes disabled or your browser does not support them.'), 261 'loadingAnimation' => includes_url('js/thickbox/loadingAnimation.gif'), 262 262 ) ); 263 263 … … 402 402 $scripts->add( 'admin-bar', "/wp-includes/js/admin-bar$suffix.js", array(), false, 1 ); 403 403 404 $scripts->add( 'wplink', "/wp-includes/js/wplink$suffix.js", array( 'jquery' ), false, 1 );404 $scripts->add( 'wplink', "/wp-includes/js/wplink$suffix.js", array( 'jquery', 'wp-a11y' ), false, 1 ); 405 405 did_action( 'init' ) && $scripts->localize( 'wplink', 'wpLinkL10n', array( 406 406 'title' => __('Insert/edit link'), … … 408 408 'save' => __('Add Link'), 409 409 'noTitle' => __('(no title)'), 410 'noMatchesFound' => __('No results found.') 410 'noMatchesFound' => __('No results found.'), 411 'linkSelected' => __( 'Link selected.' ), 412 'linkInserted' => __( 'Link inserted.' ), 411 413 ) ); 412 414
Note: See TracChangeset
for help on using the changeset viewer.