Accessibility: Add an ARIA role button to links that behave like buttons when JavaScript is on.

Introduces a simple way to give a proper semantics of `button` to links that behave
like UI controls when JavaScript is on and behave like actual links when JavaScript
is off. First implementation on the Terms list table.

Patch prepared during WordCamp US 2015 Contributor Day.

Props mcapybara, garusky, takayukister.

See #26504.
Fixes #34867.
Built from https://develop.svn.wordpress.org/trunk@35947


git-svn-id: http://core.svn.wordpress.org/trunk@35911 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Andrea Fercia 2015-12-15 13:25:28 +00:00
parent 8db5455eea
commit 282e7c36eb
4 changed files with 14 additions and 4 deletions

View File

@ -430,10 +430,10 @@ class WP_Terms_List_Table extends WP_List_Table {
$actions = array();
if ( current_user_can( $tax->cap->edit_terms ) ) {
$actions['edit'] = '<a href="' . esc_url( $edit_link ) . '">' . __( 'Edit' ) . '</a>';
$actions['inline hide-if-no-js'] = '<a href="#" class="editinline">' . __( 'Quick&nbsp;Edit' ) . '</a>';
$actions['inline hide-if-no-js'] = '<a href="#" class="editinline aria-button-if-js">' . __( 'Quick&nbsp;Edit' ) . '</a>';
}
if ( current_user_can( $tax->cap->delete_terms ) && $tag->term_id != $default_term )
$actions['delete'] = "<a class='delete-tag' href='" . wp_nonce_url( "edit-tags.php?action=delete&amp;taxonomy=$taxonomy&amp;tag_ID=$tag->term_id", 'delete-tag_' . $tag->term_id ) . "'>" . __( 'Delete' ) . "</a>";
$actions['delete'] = "<a class='delete-tag aria-button-if-js' href='" . wp_nonce_url( "edit-tags.php?action=delete&amp;taxonomy=$taxonomy&amp;tag_ID=$tag->term_id", 'delete-tag_' . $tag->term_id ) . "'>" . __( 'Delete' ) . "</a>";
if ( $tax->public )
$actions['view'] = '<a href="' . get_term_link( $tag ) . '">' . __( 'View' ) . '</a>';

View File

@ -897,10 +897,20 @@ $document.ready( function() {
}
};
// Add an ARIA role `button` to elements that behave like UI controls when JavaScript is on.
function aria_button_if_js() {
$( '.aria-button-if-js' ).attr( 'role', 'button' );
}
$( document ).ajaxComplete( function() {
aria_button_if_js();
});
window.wpResponsive.init();
setPinMenu();
currentMenuItemHasPopup();
makeNoticesDismissible();
aria_button_if_js();
$document.on( 'wp-pin-menu wp-window-resized.pin-menu postboxes-columnchange.pin-menu postbox-toggled.pin-menu wp-collapse-menu.pin-menu wp-scroll-start.pin-menu', setPinMenu );
});

File diff suppressed because one or more lines are too long

View File

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