Add wp.a11y.speak() for audible alerts/updates in screen readers. Props afercia, GrahamArmfield (for the idea), iseulde. Fixes #31368.

Built from https://develop.svn.wordpress.org/trunk@31594


git-svn-id: http://core.svn.wordpress.org/trunk@31575 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Andrew Ozz
2015-03-01 19:11:27 +00:00
parent a337c34c4e
commit 5e07bfdfd1
9 changed files with 65 additions and 9 deletions

46
wp-includes/js/wp-a11y.js Normal file
View File

@@ -0,0 +1,46 @@
window.wp = window.wp || {};
( function ( wp, $ ) {
'use strict';
var $container;
/**
* Update the ARIA live notification area text node.
*
* @since 4.2.0
*
* @param {String} message
*/
function speak( message ) {
if ( $container ) {
$container.text( message );
}
}
/**
* Initialize wp.a11y and define ARIA live notification area.
*
* @since 4.2.0
*/
$( document ).ready( function() {
$container = $( '#wp-a11y-speak' );
if ( ! $container.length ) {
$container = $( '<div>', {
id: 'wp-a11y-speak',
role: 'status',
'aria-live': 'polite',
'aria-relevant': 'all',
'aria-atomic': 'true',
'class': 'screen-reader-text'
} );
$( document.body ).append( $container );
}
} );
wp.a11y = wp.a11y || {};
wp.a11y.speak = speak;
} )( window.wp, window.jQuery );

1
wp-includes/js/wp-a11y.min.js vendored Normal file
View File

@@ -0,0 +1 @@
window.wp=window.wp||{},function(a,b){"use strict";function c(a){d&&d.text(a)}var d;b(document).ready(function(){d=b("#wp-a11y-speak"),d.length||(d=b("<div>",{id:"wp-a11y-speak",role:"status","aria-live":"polite","aria-relevant":"all","aria-atomic":"true","class":"screen-reader-text"}),b(document.body).append(d))}),a.a11y=a.a11y||{},a.a11y.speak=c}(window.wp,window.jQuery);

View File

@@ -82,6 +82,8 @@ function wp_default_scripts( &$scripts ) {
'warnDelete' => __("You are about to permanently delete the selected items.\n 'Cancel' to stop, 'OK' to delete.")
) );
$scripts->add( 'wp-a11y', "/wp-includes/js/wp-a11y$suffix.js", array( 'jquery' ), false, 1 );
$scripts->add( 'sack', "/wp-includes/js/tw-sack$suffix.js", array(), '1.6.1', 1 );
$scripts->add( 'quicktags', "/wp-includes/js/quicktags$suffix.js", array(), false, 1 );
@@ -380,7 +382,7 @@ function wp_default_scripts( &$scripts ) {
$scripts->add( 'hoverIntent', "/wp-includes/js/hoverIntent$suffix.js", array('jquery'), 'r7', 1 );
$scripts->add( 'customize-base', "/wp-includes/js/customize-base$suffix.js", array( 'jquery', 'json2', 'underscore' ), false, 1 );
$scripts->add( 'customize-base', "/wp-includes/js/customize-base$suffix.js", array( 'jquery', 'json2', 'underscore', 'wp-a11y' ), false, 1 );
$scripts->add( 'customize-loader', "/wp-includes/js/customize-loader$suffix.js", array( 'customize-base' ), false, 1 );
$scripts->add( 'customize-preview', "/wp-includes/js/customize-preview$suffix.js", array( 'customize-base' ), false, 1 );
$scripts->add( 'customize-models', "/wp-includes/js/customize-models.js", array( 'underscore', 'backbone' ), false, 1 );
@@ -532,7 +534,7 @@ function wp_default_scripts( &$scripts ) {
'ays' => __('Are you sure you want to install this plugin?')
) );
$scripts->add( 'updates', "/wp-admin/js/updates$suffix.js", array( 'jquery', 'wp-util' ) );
$scripts->add( 'updates', "/wp-admin/js/updates$suffix.js", array( 'jquery', 'wp-util', 'wp-a11y' ) );
did_action( 'init' ) && $scripts->localize( 'updates', '_wpUpdatesSettings', array(
'ajax_nonce' => wp_create_nonce( 'updates' ),
'l10n' => array(
@@ -543,6 +545,10 @@ function wp_default_scripts( &$scripts ) {
'installing' => __( 'Installing...' ),
'installed' => __( 'Installed!' ),
'installFailed' => __( 'Installation failed' ),
'updatingMsg' => __( 'Updating... please wait.' ),
'installingMsg' => __( 'Installing... please wait.' ),
'updatedMsg' => __( 'Update completed successfully.' ),
'installedMsg' => __( 'Installation completed successfully.' ),
)
) );

View File

@@ -4,7 +4,7 @@
*
* @global string $wp_version
*/
$wp_version = '4.2-alpha-31593';
$wp_version = '4.2-alpha-31594';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.