| 1 |
( function() { |
| 2 |
|
| 3 |
/* ====== Tabs ====== */ |
| 4 |
|
| 5 |
// Hides the tab content. |
| 6 |
jQuery( '.members-tabs .members-tab-content' ).hide(); |
| 7 |
|
| 8 |
// Shows the first tab's content. |
| 9 |
jQuery( '.members-tabs .members-tab-content:first-child' ).show(); |
| 10 |
|
| 11 |
// Makes the 'aria-selected' attribute true for the first tab nav item. |
| 12 |
jQuery( '.members-tab-nav :first-child' ).attr( 'aria-selected', 'true' ); |
| 13 |
|
| 14 |
// When a tab nav item is clicked. |
| 15 |
jQuery( '.members-tab-nav li a' ).on( |
| 16 |
'click', |
| 17 |
function( j ) { |
| 18 |
|
| 19 |
// Prevent the default browser action when a link is clicked. |
| 20 |
j.preventDefault(); |
| 21 |
|
| 22 |
// Get the `href` attribute of the item. |
| 23 |
var href = jQuery( this ).attr( 'href' ); |
| 24 |
|
| 25 |
// Hide all tab content. |
| 26 |
jQuery( this ).parents( '.members-tabs' ).find( '.members-tab-content' ).hide(); |
| 27 |
|
| 28 |
// Find the tab content that matches the tab nav item and show it. |
| 29 |
jQuery( this ).parents( '.members-tabs' ).find( href ).show(); |
| 30 |
|
| 31 |
// Set the `aria-selected` attribute to false for all tab nav items. |
| 32 |
jQuery( this ).parents( '.members-tabs' ).find( '.members-tab-title' ).attr( 'aria-selected', 'false' ); |
| 33 |
|
| 34 |
// Set the `aria-selected` attribute to true for this tab nav item. |
| 35 |
jQuery( this ).parent().attr( 'aria-selected', 'true' ); |
| 36 |
} |
| 37 |
); // click() |
| 38 |
|
| 39 |
}() ); |
| 40 |
|