Ticket #32600: 32600.patch
File 32600.patch, 2.7 KB (added by , 10 years ago) |
---|
-
src/wp-includes/js/wp-a11y.js
3 3 ( function ( wp, $ ) { 4 4 'use strict'; 5 5 6 var $container; 6 var $containerPolite, 7 $containerAssertive; 7 8 8 9 /** 9 10 * Update the ARIA live notification area text node. 10 11 * 11 12 * @since 4.2.0 13 * @since 4.3.0 Introduced the 'politeness' argument. 12 14 * 13 * @param {String} message 15 * @param {String} message The message to be announced by Assistive Technologies. 16 * @param {String} politeness The politeness level for aria-live. Possible values: 17 * polite or assertive. Default polite. 14 18 */ 15 function speak( message ) { 16 if ( $container ) { 17 $container.text( message ); 19 function speak( message, politeness ) { 20 21 // Clear previous messages if any to allow repeated strings being read out. 22 clearSpeak(); 23 24 if ( $containerAssertive && 'assertive' === politeness ) { 25 26 // Print the message to the assertive live region. 27 $containerAssertive.text( message ); 28 29 } else if ( $containerPolite ) { 30 31 // Print the message to the polite live region. 32 $containerPolite.text( message ); 33 18 34 } 19 35 } 20 36 … … 22 38 * Initialize wp.a11y and define ARIA live notification area. 23 39 * 24 40 * @since 4.2.0 41 * @since 4.3.0 Added the assertive live region. 25 42 */ 26 43 $( document ).ready( function() { 27 $container = $( '#wp-a11y-speak' ); 44 $containerPolite = $( '#wp-a11y-speak-polite' ); 45 $containerAssertive = $( '#wp-a11y-speak-assertive' ); 28 46 29 if ( ! $container.length ) { 30 $container = $( '<div>', { 31 id: 'wp-a11y-speak', 32 role: 'status', 47 if ( ! $containerPolite.length ) { 48 49 $containerPolite = $( '<div>', { 50 'id': 'wp-a11y-speak-polite', 51 'role': 'status', 33 52 'aria-live': 'polite', 34 'aria-relevant': 'a ll',53 'aria-relevant': 'additions text', 35 54 'aria-atomic': 'true', 36 'class': 'screen-reader-text '37 } 55 'class': 'screen-reader-text wp-a11y-speak-region' 56 }); 38 57 39 $( document.body ).append( $container );58 $( document.body ).append( $containerPolite ); 40 59 } 41 } );42 60 61 if ( ! $containerAssertive.length ) { 62 63 $containerAssertive = $( '<div>', { 64 'id': 'wp-a11y-speak-assertive', 65 'role': 'status', 66 'aria-live': 'assertive', 67 'aria-relevant': 'additions text', 68 'aria-atomic': 'true', 69 'class': 'screen-reader-text wp-a11y-speak-region' 70 }); 71 72 $( document.body ).append( $containerAssertive ); 73 } 74 }); 75 76 /** 77 * Clear the live regions. 78 * 79 * @since 4.3.0 80 */ 81 function clearSpeak() { 82 $( '.wp-a11y-speak-region' ).text( '' ); 83 } 84 43 85 wp.a11y = wp.a11y || {}; 44 86 wp.a11y.speak = speak; 45 87