wp/wp-includes/js/wp-a11y.js
changeset 5 5e2f62d02dcd
child 7 cf61fcea0001
equal deleted inserted replaced
4:346c88efed21 5:5e2f62d02dcd
       
     1 window.wp = window.wp || {};
       
     2 
       
     3 ( function ( wp, $ ) {
       
     4 	'use strict';
       
     5 
       
     6 	var $container;
       
     7 
       
     8 	/**
       
     9 	 * Update the ARIA live notification area text node.
       
    10 	 *
       
    11 	 * @since 4.2.0
       
    12 	 *
       
    13 	 * @param {String} message
       
    14 	 */
       
    15 	function speak( message ) {
       
    16 		if ( $container ) {
       
    17 			$container.text( message );
       
    18 		}
       
    19 	}
       
    20 
       
    21 	/**
       
    22 	 * Initialize wp.a11y and define ARIA live notification area.
       
    23 	 *
       
    24 	 * @since 4.2.0
       
    25 	 */
       
    26 	$( document ).ready( function() {
       
    27 		$container = $( '#wp-a11y-speak' );
       
    28 
       
    29 		if ( ! $container.length ) {
       
    30 			$container = $( '<div>', {
       
    31 				id: 'wp-a11y-speak',
       
    32 				role: 'status',
       
    33 				'aria-live': 'polite',
       
    34 				'aria-relevant': 'all',
       
    35 				'aria-atomic': 'true',
       
    36 				'class': 'screen-reader-text'
       
    37 			} );
       
    38 
       
    39 			$( document.body ).append( $container );
       
    40 		}
       
    41 	} );
       
    42 
       
    43 	wp.a11y = wp.a11y || {};
       
    44 	wp.a11y.speak = speak;
       
    45 
       
    46 } )( window.wp, window.jQuery );