3 $( document ).ready( function () {
5 // Expand/Collapse on click
6 $( '.accordion-container' ).on( 'click keydown', '.accordion-section-title', function( e ) {
7 if ( e.type === 'keydown' && 13 !== e.which ) // "return" key
9 e.preventDefault(); // Keep this AFTER the key filter above
11 accordionSwitch( $( this ) );
14 // Re-initialize accordion when screen options are toggled
15 $( '.hide-postbox-tog' ).click( function () {
21 var accordionOptions = $( '.accordion-container li.accordion-section' ),
22 sectionContent = $( '.accordion-section-content' );
24 function accordionInit () {
26 accordionOptions.removeClass( 'top bottom' );
27 accordionOptions.filter( ':visible' ).first().addClass( 'top' );
28 accordionOptions.filter( ':visible' ).last().addClass( 'bottom' ).find( sectionContent ).addClass( 'bottom' );
31 function accordionSwitch ( el ) {
32 var section = el.closest( '.accordion-section' ),
33 siblings = section.closest( '.accordion-container' ).find( '.open' ),
34 content = section.find( sectionContent );
36 if ( section.hasClass( 'cannot-expand' ) )
39 if ( section.hasClass( 'open' ) ) {
40 section.toggleClass( 'open' );
41 content.toggle( true ).slideToggle( 150 );
43 siblings.removeClass( 'open' );
44 siblings.find( sectionContent ).show().slideUp( 150 );
45 content.toggle( false ).slideToggle( 150 );
46 section.toggleClass( 'open' );
52 // Initialize the accordion (currently just corner fixes)