Fix regressions from [32649] wrt Customizer `expanded` and `active` state changes for sections.

The `args.completeCallback` was not always called when `onChangeExpanded()` was called. And when a section became inactive (`active` state goes to `false`) and it was currently `expanded`, the Customizer panel would then becomes blank as the section was hidden; it needed to `collapse()` the section first before hiding the element.

See #31336.


Built from https://develop.svn.wordpress.org/trunk@32743


git-svn-id: http://core.svn.wordpress.org/trunk@32714 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Weston Ruter 2015-06-12 22:28:25 +00:00
parent c11e433858
commit 40ad21b58b
3 changed files with 29 additions and 9 deletions

View File

@ -284,17 +284,27 @@
* @param {Object} args.completeCallback * @param {Object} args.completeCallback
*/ */
onChangeActive: function ( active, args ) { onChangeActive: function ( active, args ) {
var duration = ( 'resolved' === api.previewer.deferred.active.state() ? args.duration : 0 ); var duration, construct = this;
if ( ! $.contains( document, this.container ) ) { duration = ( 'resolved' === api.previewer.deferred.active.state() ? args.duration : 0 );
if ( ! $.contains( document, construct.container[0] ) ) {
// jQuery.fn.slideUp is not hiding an element if it is not in the DOM // jQuery.fn.slideUp is not hiding an element if it is not in the DOM
this.container.toggle( active ); construct.container.toggle( active );
if ( args.completeCallback ) { if ( args.completeCallback ) {
args.completeCallback(); args.completeCallback();
} }
} else if ( active ) { } else if ( active ) {
this.container.stop( true, true ).slideDown( duration, args.completeCallback ); construct.container.stop( true, true ).slideDown( duration, args.completeCallback );
} else { } else {
this.container.stop( true, true ).slideUp( duration, args.completeCallback ); if ( construct.expanded() ) {
construct.collapse({
duration: duration,
completeCallback: function() {
construct.container.stop( true, true ).slideUp( duration, args.completeCallback );
}
});
} else {
construct.container.stop( true, true ).slideUp( duration, args.completeCallback );
}
} }
}, },
@ -596,6 +606,9 @@
position = content.offset().top; position = content.offset().top;
scroll = container.scrollTop(); scroll = container.scrollTop();
content.css( 'margin-top', ( 45 - position - scroll ) ); content.css( 'margin-top', ( 45 - position - scroll ) );
if ( args.completeCallback ) {
args.completeCallback();
}
}; };
} }
@ -616,12 +629,19 @@
expand(); expand();
} }
} else if ( section.container.hasClass( 'open' ) ) { } else if ( ! expanded && section.container.hasClass( 'open' ) ) {
section.container.removeClass( 'open' ); section.container.removeClass( 'open' );
overlay.removeClass( 'section-open' ); overlay.removeClass( 'section-open' );
content.css( 'margin-top', 'inherit' ); content.css( 'margin-top', 'inherit' );
container.scrollTop( 0 ); container.scrollTop( 0 );
section.container.find( '.accordion-section-title' ).focus(); section.container.find( '.accordion-section-title' ).focus();
if ( args.completeCallback ) {
args.completeCallback();
}
} else {
if ( args.completeCallback ) {
args.completeCallback();
}
} }
} }
}); });

File diff suppressed because one or more lines are too long

View File

@ -4,7 +4,7 @@
* *
* @global string $wp_version * @global string $wp_version
*/ */
$wp_version = '4.3-alpha-32742'; $wp_version = '4.3-alpha-32743';
/** /**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema. * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.