// action must be string with 'expand' or 'collapse'
return;
}
- if ( $defaultToggle && !$defaultToggle.jquery ) {
- // is optional, but if passed must be an instance of jQuery
+ if ( typeof $defaultToggle !== 'undefined' && !($defaultToggle instanceof jQuery) ) {
+ // is optional (may be undefined), but if passed it must be an instance of jQuery and nothing else
return;
}
var $containers = null;
// Slide doens't work with tables, but fade does as of jQuery 1.1.3
// http://stackoverflow.com/questions/467336#920480
$containers = $collapsible.find( '>tbody>tr' );
- if ( $defaultToggle && $defaultToggle.jquery ) {
+ if ( typeof $defaultToggle !== 'undefined' && ($defaultToggle instanceof jQuery) ) {
// Exclude tablerow containing togglelink
- $containers.not( $defaultToggle.parent().parent() ).stop(true, true).fadeOut();
+ $containers.not( $defaultToggle.closest( 'tr' ) ).stop(true, true).fadeOut();
} else {
if ( instantHide ) {
$containers.hide();
// The collapsible element could have multiple togglers
// To toggle the initial state only click one of them (ie. the first one, eq(0) )
// Else it would go like: hide,show,hide,show for each toggle link.
- toggleElement( $that, 'collapse', null, /* instantHide = */ true );
+ toggleElement( $that, 'collapse', $toggleLink.eq(0), /* instantHide = */ true );
$toggleLink.eq(0).click();
}
} );