Customize: Fix failure to collapse expanded sections and panels that become deactivated.

Improve jsdoc for `onChangeActive` function. Restores fix from [34557] which got dropped in [38648].

Props dlh, westonruter.
See #34391, #33509.
Fixes #39430.

Merges [40304] to the 4.7 branch.


git-svn-id: https://develop.svn.wordpress.org/branches/4.7@40375 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Pascal Birchler 2017-04-04 06:51:39 +00:00
parent 7abacb8516
commit 5b74245108
1 changed files with 10 additions and 9 deletions

View File

@ -528,10 +528,11 @@
*
* @since 4.1.0
*
* @param {Boolean} active
* @param {Object} args
* @param {Object} args.duration
* @param {Object} args.completeCallback
* @param {boolean} active - The active state to transiution to.
* @param {Object} [args] - Args.
* @param {Object} [args.duration] - The duration for the slideUp/slideDown animation.
* @param {boolean} [args.unchanged] - Whether the state is already known to not be changed, and so short-circuit with calling completeCallback early.
* @param {Function} [args.completeCallback] - Function to call when the slideUp/slideDown has completed.
*/
onChangeActive: function( active, args ) {
var construct = this,
@ -564,24 +565,24 @@
}
}
if ( ! $.contains( document, headContainer ) ) {
// jQuery.fn.slideUp is not hiding an element if it is not in the DOM
if ( ! $.contains( document, headContainer.get( 0 ) ) ) {
// If the element is not in the DOM, then jQuery.fn.slideUp() does nothing. In this case, a hard toggle is required instead.
headContainer.toggle( active );
if ( args.completeCallback ) {
args.completeCallback();
}
} else if ( active ) {
headContainer.stop( true, true ).slideDown( duration, args.completeCallback );
headContainer.slideDown( duration, args.completeCallback );
} else {
if ( construct.expanded() ) {
construct.collapse({
duration: duration,
completeCallback: function() {
headContainer.stop( true, true ).slideUp( duration, args.completeCallback );
headContainer.slideUp( duration, args.completeCallback );
}
});
} else {
headContainer.stop( true, true ).slideUp( duration, args.completeCallback );
headContainer.slideUp( duration, args.completeCallback );
}
}
},