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:
parent
7abacb8516
commit
5b74245108
@ -528,10 +528,11 @@
|
|||||||
*
|
*
|
||||||
* @since 4.1.0
|
* @since 4.1.0
|
||||||
*
|
*
|
||||||
* @param {Boolean} active
|
* @param {boolean} active - The active state to transiution to.
|
||||||
* @param {Object} args
|
* @param {Object} [args] - Args.
|
||||||
* @param {Object} args.duration
|
* @param {Object} [args.duration] - The duration for the slideUp/slideDown animation.
|
||||||
* @param {Object} args.completeCallback
|
* @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 ) {
|
onChangeActive: function( active, args ) {
|
||||||
var construct = this,
|
var construct = this,
|
||||||
@ -564,24 +565,24 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! $.contains( document, headContainer ) ) {
|
if ( ! $.contains( document, headContainer.get( 0 ) ) ) {
|
||||||
// jQuery.fn.slideUp is not hiding an element if it is not in the DOM
|
// 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 );
|
headContainer.toggle( active );
|
||||||
if ( args.completeCallback ) {
|
if ( args.completeCallback ) {
|
||||||
args.completeCallback();
|
args.completeCallback();
|
||||||
}
|
}
|
||||||
} else if ( active ) {
|
} else if ( active ) {
|
||||||
headContainer.stop( true, true ).slideDown( duration, args.completeCallback );
|
headContainer.slideDown( duration, args.completeCallback );
|
||||||
} else {
|
} else {
|
||||||
if ( construct.expanded() ) {
|
if ( construct.expanded() ) {
|
||||||
construct.collapse({
|
construct.collapse({
|
||||||
duration: duration,
|
duration: duration,
|
||||||
completeCallback: function() {
|
completeCallback: function() {
|
||||||
headContainer.stop( true, true ).slideUp( duration, args.completeCallback );
|
headContainer.slideUp( duration, args.completeCallback );
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
headContainer.stop( true, true ).slideUp( duration, args.completeCallback );
|
headContainer.slideUp( duration, args.completeCallback );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user