mirror of
https://github.com/WordPress/WordPress.git
synced 2024-10-02 09:07:59 +02:00
Use jQuery.on() properly in accordion code. Some other cleanup.
see #23890. git-svn-id: http://core.svn.wordpress.org/trunk@23856 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
a1ef45a3ec
commit
06c8737aec
@ -1,17 +1,16 @@
|
|||||||
jQuery(document).ready( function($) {
|
jQuery(document).ready( function($) {
|
||||||
// Expand/Collapse
|
// Expand/Collapse
|
||||||
$('.accordion-section-title').on('click keydown', function( event ) {
|
$('.accordion-container').on( 'click keydown', '.accordion-section-title', function(e) {
|
||||||
|
if ( e.type === 'keydown' && 13 !== e.which ) // "return" key
|
||||||
if ( event.type === 'keydown' && 13 !== event.which ) // enter
|
|
||||||
return;
|
return;
|
||||||
|
e.preventDefault(); // Keep this AFTER the key filter above
|
||||||
|
|
||||||
var clicked = $( this ).closest( '.accordion-section' );
|
var section = $( this ).closest( '.accordion-section' );
|
||||||
|
|
||||||
if ( clicked.hasClass('cannot-expand') )
|
if ( section.hasClass('cannot-expand') )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
clicked.closest( '.accordion-container' ).find( '.accordion-section' ).not( clicked ).removeClass( 'open' );
|
section.closest( '.accordion-container' ).find( '.accordion-section' ).not( section ).removeClass( 'open' );
|
||||||
clicked.toggleClass( 'open' );
|
section.toggleClass( 'open' );
|
||||||
event.preventDefault();
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user