WordPress.org

Make WordPress Core

Changeset 23856


Ignore:
Timestamp:
03/29/13 08:28:58 (2 years ago)
Author:
markjaquith
Message:

Use jQuery.on() properly in accordion code. Some other cleanup.

see #23890.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/js/accordion.js

    r23855 r23856  
    11jQuery(document).ready( function($) { 
    22    // Expand/Collapse 
    3     $('.accordion-section-title').on('click keydown', function( event ) { 
     3    $('.accordion-container').on( 'click keydown', '.accordion-section-title', function(e) { 
     4        if ( e.type === 'keydown' && 13 !== e.which ) // "return" key 
     5                return; 
     6        e.preventDefault(); // Keep this AFTER the key filter above 
    47 
    5         if ( event.type === 'keydown' &&  13 !== event.which ) // enter 
    6                 return; 
     8        var section = $( this ).closest( '.accordion-section' ); 
    79 
    8         var clicked = $( this ).closest( '.accordion-section' ); 
    9  
    10         if ( clicked.hasClass('cannot-expand') ) 
     10        if ( section.hasClass('cannot-expand') ) 
    1111            return; 
    1212 
    13         clicked.closest( '.accordion-container' ).find( '.accordion-section' ).not( clicked ).removeClass( 'open' ); 
    14         clicked.toggleClass( 'open' ); 
    15         event.preventDefault(); 
     13        section.closest( '.accordion-container' ).find( '.accordion-section' ).not( section ).removeClass( 'open' ); 
     14        section.toggleClass( 'open' ); 
    1615    }); 
    1716}); 
Note: See TracChangeset for help on using the changeset viewer.