<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[42794] trunk/src: Accessibility: Widgets: Make the "Available Widgets" section operable with a keyboard.</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta" style="font-size: 105%">
<dt style="float: left; width: 6em; font-weight: bold">Revision</dt> <dd><a style="font-weight: bold" href="https://core.trac.wordpress.org/changeset/42794">42794</a><script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","description":"Review this Commit","action":{"@type":"ViewAction","url":"https://core.trac.wordpress.org/changeset/42794","name":"Review Commit"}}</script></dd>
<dt style="float: left; width: 6em; font-weight: bold">Author</dt> <dd>afercia</dd>
<dt style="float: left; width: 6em; font-weight: bold">Date</dt> <dd>2018-03-07 22:26:39 +0000 (Wed, 07 Mar 2018)</dd>
</dl>
<pre style='padding-left: 1em; margin: 2em 0; border-left: 2px solid #ccc; line-height: 1.25; font-size: 105%; font-family: sans-serif'>Accessibility: Widgets: Make the "Available Widgets" section operable with a keyboard.
For a number of years, the "Available Widgets" section has been off-limits for
keyboard users. Now it can be used also with the keyboard. This change introduces
also some improvements for assistive technologies.
- makes the widget toggles focusable and adds an `aria-expanded` attribute to indicate their state
- improves the toggles labelling to clarify context (add/edit)
- changes the controls to choose a sidebar from list items to buttons
- adds an `aria-label` attribute to the buttons to clarify their purpose
- adds an `aria-pressed` attribute to the buttons to indicate which one is selected
- improves color contrast of the selected button
- uses a `wp.a11y.speak()` message to announce to screen reader users when a widget has been added to a sidebar
- moves focus back to the toggle button when closing a widget
See <a href="https://core.trac.wordpress.org/ticket/40677">#40677</a>.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunksrcwpadmincsscommoncss">trunk/src/wp-admin/css/common.css</a></li>
<li><a href="#trunksrcwpadmincsswidgetscss">trunk/src/wp-admin/css/widgets.css</a></li>
<li><a href="#trunksrcwpadminincludeswidgetsphp">trunk/src/wp-admin/includes/widgets.php</a></li>
<li><a href="#trunksrcwpadminjswidgetsjs">trunk/src/wp-admin/js/widgets.js</a></li>
<li><a href="#trunksrcwpincludesscriptloaderphp">trunk/src/wp-includes/script-loader.php</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunksrcwpadmincsscommoncss"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-admin/css/common.css</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-admin/css/common.css 2018-03-07 19:40:58 UTC (rev 42793)
+++ trunk/src/wp-admin/css/common.css 2018-03-07 22:26:39 UTC (rev 42794)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -3368,7 +3368,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> .control-section.open .accordion-section-title:after,
</span><span class="cx" style="display: block; padding: 0 10px"> #customize-info.open .accordion-section-title:after,
</span><span class="cx" style="display: block; padding: 0 10px"> .nav-menus-php .menu-item-edit-active .item-edit:before,
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-.widget.open .widget-top .widget-action .toggle-indicator:before {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+.widget.open .widget-top .widget-action .toggle-indicator:before,
+.widget.widget-in-question .widget-top .widget-action .toggle-indicator:before {
</ins><span class="cx" style="display: block; padding: 0 10px"> content: "\f142";
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span></span></pre></div>
<a id="trunksrcwpadmincsswidgetscss"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-admin/css/widgets.css</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-admin/css/widgets.css 2018-03-07 19:40:58 UTC (rev 42793)
+++ trunk/src/wp-admin/css/widgets.css 2018-03-07 22:26:39 UTC (rev 42794)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -381,10 +381,6 @@
</span><span class="cx" style="display: block; padding: 0 10px"> box-shadow: none;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-#available-widgets .widget-action {
- display: none;
-}
-
</del><span class="cx" style="display: block; padding: 0 10px"> #available-widgets .widget {
</span><span class="cx" style="display: block; padding: 0 10px"> margin: 0;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -516,8 +512,11 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> #available-widgets .widget-control-edit .edit,
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+#available-widgets .widget-action .edit,
</ins><span class="cx" style="display: block; padding: 0 10px"> #widgets-left .inactive-sidebar .widget-control-edit .add,
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-#widgets-right .widget-control-edit .add {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+#widgets-left .inactive-sidebar .widget-action .add,
+#widgets-right .widget-control-edit .add,
+#widgets-right .widget-action .add {
</ins><span class="cx" style="display: block; padding: 0 10px"> display: none;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -664,44 +663,40 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> .widgets-chooser li {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- padding: 10px 15px 10px 35px;
</del><span class="cx" style="display: block; padding: 0 10px"> border-bottom: 1px solid #ccc;
</span><span class="cx" style="display: block; padding: 0 10px"> background: #fff;
</span><span class="cx" style="display: block; padding: 0 10px"> margin: 0;
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- cursor: pointer;
- outline: none;
</del><span class="cx" style="display: block; padding: 0 10px"> position: relative;
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- transition: background 0.2s ease-in-out;
</del><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /* @todo looks like these hover/focus states are overridden by .widgets-chooser-selected */
-.widgets-chooser li:hover,
-.widgets-chooser li:focus {
- background: rgba(255,255,255,0.7);
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+.widgets-chooser .widgets-chooser-button {
+ width: 100%;
+ padding: 10px 15px 10px 35px;
+ background: transparent;
+ border: 0;
+ box-sizing: border-box;
+ text-align: left;
+ cursor: pointer;
+ transition: background 0.2s ease-in-out;
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-.widgets-chooser li:focus:before {
- content: "\f147";
- display: block;
- -webkit-font-smoothing: antialiased;
- font: normal 26px/1 dashicons;
- color: #555d66;
- position: absolute;
- top: 7px;
- left: 5px;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+/* @todo looks like these hover/focus states are overridden by .widgets-chooser-selected */
+.widgets-chooser .widgets-chooser-button:hover,
+.widgets-chooser .widgets-chooser-button:focus {
+ outline: none;
+ text-decoration: underline;
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> .widgets-chooser li:last-child {
</span><span class="cx" style="display: block; padding: 0 10px"> border: none;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-.widgets-chooser li.widgets-chooser-selected {
- background: #00a0d2;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+.widgets-chooser .widgets-chooser-selected .widgets-chooser-button {
+ background: #0073aa;
</ins><span class="cx" style="display: block; padding: 0 10px"> color: #fff;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-.widgets-chooser li.widgets-chooser-selected:before,
-.widgets-chooser li.widgets-chooser-selected:focus:before {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+.widgets-chooser .widgets-chooser-selected:before {
</ins><span class="cx" style="display: block; padding: 0 10px"> content: "\f147";
</span><span class="cx" style="display: block; padding: 0 10px"> display: block;
</span><span class="cx" style="display: block; padding: 0 10px"> -webkit-font-smoothing: antialiased;
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -717,10 +712,6 @@
</span><span class="cx" style="display: block; padding: 0 10px"> text-align: center;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-.widgets-chooser button {
- margin-right: 5px;
-}
-
</del><span class="cx" style="display: block; padding: 0 10px"> #available-widgets .widget .widget-top {
</span><span class="cx" style="display: block; padding: 0 10px"> cursor: pointer;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span></span></pre></div>
<a id="trunksrcwpadminincludeswidgetsphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-admin/includes/widgets.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-admin/includes/widgets.php 2018-03-07 19:40:58 UTC (rev 42793)
+++ trunk/src/wp-admin/includes/widgets.php 2018-03-07 22:26:39 UTC (rev 42794)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -90,8 +90,13 @@
</span><span class="cx" style="display: block; padding: 0 10px"> echo '<div id="' . esc_attr( $sidebar ) . '" class="widgets-sortables">';
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( $sidebar_name ) {
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $add_to = sprintf(
+ /* translators: %s: widgets sidebar name. */
+ __( 'Add to: %s' ),
+ $sidebar_name
+ );
</ins><span class="cx" style="display: block; padding: 0 10px"> ?>
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- <div class="sidebar-name">
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ <div class="sidebar-name" data-add-to="<?php echo esc_attr( $add_to ); ?>">
</ins><span class="cx" style="display: block; padding: 0 10px"> <button type="button" class="handlediv hide-if-no-js" aria-expanded="true">
</span><span class="cx" style="display: block; padding: 0 10px"> <span class="screen-reader-text"><?php echo esc_html( $sidebar_name ); ?></span>
</span><span class="cx" style="display: block; padding: 0 10px"> <span class="toggle-indicator" aria-hidden="true"></span>
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -239,7 +244,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> <div class="widget-top">
</span><span class="cx" style="display: block; padding: 0 10px"> <div class="widget-title-action">
</span><span class="cx" style="display: block; padding: 0 10px"> <button type="button" class="widget-action hide-if-no-js" aria-expanded="false">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- <span class="screen-reader-text"><?php printf( __( 'Edit widget: %s' ), $widget_title ); ?></span>
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ <span class="screen-reader-text edit"><?php printf( __( 'Edit widget: %s' ), $widget_title ); ?></span>
+ <span class="screen-reader-text add"><?php printf( __( 'Add widget: %s' ), $widget_title ); ?></span>
</ins><span class="cx" style="display: block; padding: 0 10px"> <span class="toggle-indicator" aria-hidden="true"></span>
</span><span class="cx" style="display: block; padding: 0 10px"> </button>
</span><span class="cx" style="display: block; padding: 0 10px"> <a class="widget-control-edit hide-if-js" href="<?php echo esc_url( add_query_arg( $query_arg ) ); ?>">
</span></span></pre></div>
<a id="trunksrcwpadminjswidgetsjs"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-admin/js/widgets.js</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-admin/js/widgets.js 2018-03-07 19:40:58 UTC (rev 42793)
+++ trunk/src/wp-admin/js/widgets.js 2018-03-07 22:26:39 UTC (rev 42794)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -21,7 +21,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> l10n: {
</span><span class="cx" style="display: block; padding: 0 10px"> save: '{save}',
</span><span class="cx" style="display: block; padding: 0 10px"> saved: '{saved}',
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- saveAlert: '{saveAlert}'
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ saveAlert: '{saveAlert}',
+ widgetAdded: '{widgetAdded}'
</ins><span class="cx" style="display: block; padding: 0 10px"> },
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -176,19 +177,16 @@
</span><span class="cx" style="display: block; padding: 0 10px"> widget.removeClass( 'open' );
</span><span class="cx" style="display: block; padding: 0 10px"> });
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- e.preventDefault();
</del><span class="cx" style="display: block; padding: 0 10px"> } else if ( target.hasClass('widget-control-save') ) {
</span><span class="cx" style="display: block; padding: 0 10px"> wpWidgets.save( target.closest('div.widget'), 0, 1, 0 );
</span><span class="cx" style="display: block; padding: 0 10px"> e.preventDefault();
</span><span class="cx" style="display: block; padding: 0 10px"> } else if ( target.hasClass('widget-control-remove') ) {
</span><span class="cx" style="display: block; padding: 0 10px"> wpWidgets.save( target.closest('div.widget'), 1, 1, 0 );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- e.preventDefault();
</del><span class="cx" style="display: block; padding: 0 10px"> } else if ( target.hasClass('widget-control-close') ) {
</span><span class="cx" style="display: block; padding: 0 10px"> widget = target.closest('div.widget');
</span><span class="cx" style="display: block; padding: 0 10px"> widget.removeClass( 'open' );
</span><span class="cx" style="display: block; padding: 0 10px"> toggleBtn.attr( 'aria-expanded', 'false' );
</span><span class="cx" style="display: block; padding: 0 10px"> wpWidgets.close( widget );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- e.preventDefault();
</del><span class="cx" style="display: block; padding: 0 10px"> } else if ( target.attr( 'id' ) === 'inactive-widgets-control-remove' ) {
</span><span class="cx" style="display: block; padding: 0 10px"> wpWidgets.removeInactiveWidgets();
</span><span class="cx" style="display: block; padding: 0 10px"> e.preventDefault();
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -433,35 +431,53 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $( '#widgets-right .widgets-holder-wrap' ).each( function( index, element ) {
</span><span class="cx" style="display: block; padding: 0 10px"> var $element = $( element ),
</span><span class="cx" style="display: block; padding: 0 10px"> name = $element.find( '.sidebar-name h2' ).text(),
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ ariaLabel = $element.find( '.sidebar-name' ).data( 'add-to' ),
</ins><span class="cx" style="display: block; padding: 0 10px"> id = $element.find( '.widgets-sortables' ).attr( 'id' ),
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- li = $('<li tabindex="0">').text( $.trim( name ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ li = $( '<li>' ),
+ button = $( '<button>', {
+ type: 'button',
+ 'aria-pressed': 'false',
+ 'class': 'widgets-chooser-button',
+ 'aria-label': ariaLabel
+ } ).text( $.trim( name ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ li.append( button );
+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( index === 0 ) {
</span><span class="cx" style="display: block; padding: 0 10px"> li.addClass( 'widgets-chooser-selected' );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ button.attr( 'aria-pressed', 'true' );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> selectSidebar.append( li );
</span><span class="cx" style="display: block; padding: 0 10px"> li.data( 'sidebarId', id );
</span><span class="cx" style="display: block; padding: 0 10px"> });
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $( '#available-widgets .widget .widget-title' ).on( 'click.widgets-chooser', function() {
- var $widget = $(this).closest( '.widget' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $( '#available-widgets .widget .widget-top' ).on( 'click.widgets-chooser', function() {
+ var $widget = $( this ).closest( '.widget' ),
+ toggleButton = $( this ).find( '.widget-action' ),
+ chooserButtons = selectSidebar.find( '.widgets-chooser-button' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( $widget.hasClass( 'widget-in-question' ) || $( '#widgets-left' ).hasClass( 'chooser' ) ) {
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ toggleButton.attr( 'aria-expanded', 'false' );
</ins><span class="cx" style="display: block; padding: 0 10px"> self.closeChooser();
</span><span class="cx" style="display: block; padding: 0 10px"> } else {
</span><span class="cx" style="display: block; padding: 0 10px"> // Open the chooser
</span><span class="cx" style="display: block; padding: 0 10px"> self.clearWidgetSelection();
</span><span class="cx" style="display: block; padding: 0 10px"> $( '#widgets-left' ).addClass( 'chooser' );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Add CSS class and insert the chooser after the widget description.
</ins><span class="cx" style="display: block; padding: 0 10px"> $widget.addClass( 'widget-in-question' ).children( '.widget-description' ).after( chooser );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Open the chooser with a slide down animation.
</ins><span class="cx" style="display: block; padding: 0 10px"> chooser.slideDown( 300, function() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- selectSidebar.find('.widgets-chooser-selected').focus();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Update the toggle button aria-expanded attribute after previous DOM manipulations.
+ toggleButton.attr( 'aria-expanded', 'true' );
</ins><span class="cx" style="display: block; padding: 0 10px"> });
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- selectSidebar.find( 'li' ).on( 'focusin.widgets-chooser', function() {
- selectSidebar.find('.widgets-chooser-selected').removeClass( 'widgets-chooser-selected' );
- $(this).addClass( 'widgets-chooser-selected' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ chooserButtons.on( 'click.widgets-chooser', function() {
+ selectSidebar.find( '.widgets-chooser-selected' ).removeClass( 'widgets-chooser-selected' );
+ chooserButtons.attr( 'aria-pressed', 'false' );
+ $( this )
+ .attr( 'aria-pressed', 'true' )
+ .closest( 'li' ).addClass( 'widgets-chooser-selected' );
</ins><span class="cx" style="display: block; padding: 0 10px"> } );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> });
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -477,15 +493,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> self.closeChooser();
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> }).on( 'keyup.widgets-chooser', function( event ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( event.which === $.ui.keyCode.ENTER ) {
- if ( $( event.target ).hasClass( 'widgets-chooser-cancel' ) ) {
- // Close instead of adding when pressing Enter on the Cancel button
- self.closeChooser();
- } else {
- self.addWidget( chooser );
- self.closeChooser();
- }
- } else if ( event.which === $.ui.keyCode.ESCAPE ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( event.which === $.ui.keyCode.ESCAPE ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> self.closeChooser();
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> });
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -705,15 +713,20 @@
</span><span class="cx" style="display: block; padding: 0 10px"> // Cannot use a callback in the animation above as it fires twice,
</span><span class="cx" style="display: block; padding: 0 10px"> // have to queue this "by hand".
</span><span class="cx" style="display: block; padding: 0 10px"> widget.find( '.widget-title' ).trigger('click');
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // At the end of the animation, announce the widget has been added.
+ window.wp.a11y.speak( wpWidgets.l10n.widgetAdded, 'assertive' );
</ins><span class="cx" style="display: block; padding: 0 10px"> }, 250 );
</span><span class="cx" style="display: block; padding: 0 10px"> },
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> closeChooser: function() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- var self = this;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ var self = this,
+ widgetInQuestion = $( '#available-widgets .widget-in-question' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $( '.widgets-chooser' ).slideUp( 200, function() {
</span><span class="cx" style="display: block; padding: 0 10px"> $( '#wpbody-content' ).append( this );
</span><span class="cx" style="display: block; padding: 0 10px"> self.clearWidgetSelection();
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Move focus back to the toggle button.
+ widgetInQuestion.find( '.widget-action' ).attr( 'aria-expanded', 'false' ).focus();
</ins><span class="cx" style="display: block; padding: 0 10px"> });
</span><span class="cx" style="display: block; padding: 0 10px"> },
</span><span class="cx" style="display: block; padding: 0 10px">
</span></span></pre></div>
<a id="trunksrcwpincludesscriptloaderphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/script-loader.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/script-loader.php 2018-03-07 19:40:58 UTC (rev 42793)
+++ trunk/src/wp-includes/script-loader.php 2018-03-07 22:26:39 UTC (rev 42794)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -786,14 +786,15 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $scripts->add( 'admin-gallery', "/wp-admin/js/gallery$suffix.js", array( 'jquery-ui-sortable' ) );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $scripts->add( 'admin-widgets', "/wp-admin/js/widgets$suffix.js", array( 'jquery-ui-sortable', 'jquery-ui-draggable', 'jquery-ui-droppable' ), false, 1 );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $scripts->add( 'admin-widgets', "/wp-admin/js/widgets$suffix.js", array( 'jquery-ui-sortable', 'jquery-ui-draggable', 'jquery-ui-droppable', 'wp-a11y' ), false, 1 );
</ins><span class="cx" style="display: block; padding: 0 10px"> did_action( 'init' ) && $scripts->add_inline_script(
</span><span class="cx" style="display: block; padding: 0 10px"> 'admin-widgets', sprintf(
</span><span class="cx" style="display: block; padding: 0 10px"> 'wpWidgets.l10n = %s;', wp_json_encode(
</span><span class="cx" style="display: block; padding: 0 10px"> array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'save' => __( 'Save' ),
- 'saved' => __( 'Saved' ),
- 'saveAlert' => __( 'The changes you made will be lost if you navigate away from this page.' ),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'save' => __( 'Save' ),
+ 'saved' => __( 'Saved' ),
+ 'saveAlert' => __( 'The changes you made will be lost if you navigate away from this page.' ),
+ 'widgetAdded' => __( 'Widget has been added to the selected sidebar' ),
</ins><span class="cx" style="display: block; padding: 0 10px"> )
</span><span class="cx" style="display: block; padding: 0 10px"> )
</span><span class="cx" style="display: block; padding: 0 10px"> )
</span></span></pre>
</div>
</div>
</body>
</html>