- *
- *
*
@@ -34,13 +34,7 @@
$( function () {
// Expand/Collapse accordion sections on click.
- $( '.accordion-container' ).on( 'click keydown', '.accordion-section-title', function( e ) {
- if ( e.type === 'keydown' && 13 !== e.which ) { // "Return" key.
- return;
- }
-
- e.preventDefault(); // Keep this AFTER the key filter above.
-
+ $( '.accordion-container' ).on( 'click', '.accordion-section-title button', function() {
accordionSwitch( $( this ) );
});
@@ -54,7 +48,6 @@
*/
function accordionSwitch ( el ) {
var section = el.closest( '.accordion-section' ),
- sectionToggleControl = section.find( '[aria-expanded]' ).first(),
container = section.closest( '.accordion-container' ),
siblings = container.find( '.open' ),
siblingsToggleControl = siblings.find( '[aria-expanded]' ).first(),
@@ -86,8 +79,8 @@
}, 150);
// If there's an element with an aria-expanded attribute, assume it's a toggle control and toggle the aria-expanded value.
- if ( sectionToggleControl ) {
- sectionToggleControl.attr( 'aria-expanded', String( sectionToggleControl.attr( 'aria-expanded' ) === 'false' ) );
+ if ( el ) {
+ el.attr( 'aria-expanded', String( el.attr( 'aria-expanded' ) === 'false' ) );
}
}