Customizer: Use `jQuery.fn.toggle()` instead of `slideUp`/`slideDown` if panel/section/control is not inserted into DOM yet.
jQuery does nothing when calling `slideUp` on elements that are not inserted into the DOM yet, which can now be the case now when first loading the Customizer as the panels, sections and controls get dynamically inserted, see #28709. props westonruter. fixes #30251. Built from https://develop.svn.wordpress.org/trunk@30307 git-svn-id: http://core.svn.wordpress.org/trunk@30306 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
b250062311
commit
d21799ee1f
|
@ -131,8 +131,8 @@
|
|||
* @augments wp.customize.Class
|
||||
*/
|
||||
Container = api.Class.extend({
|
||||
defaultActiveArguments: { duration: 'fast' },
|
||||
defaultExpandedArguments: { duration: 'fast' },
|
||||
defaultActiveArguments: { duration: 'fast', completeCallback: $.noop },
|
||||
defaultExpandedArguments: { duration: 'fast', completeCallback: $.noop },
|
||||
|
||||
initialize: function ( id, options ) {
|
||||
var container = this;
|
||||
|
@ -217,7 +217,11 @@
|
|||
*/
|
||||
onChangeActive: function ( active, args ) {
|
||||
var duration = ( 'resolved' === api.previewer.deferred.active.state() ? args.duration : 0 );
|
||||
if ( active ) {
|
||||
if ( ! $.contains( document, this.container ) ) {
|
||||
// jQuery.fn.slideUp is not hiding an element if it is not in the DOM
|
||||
this.container.toggle( active );
|
||||
args.completeCallback();
|
||||
} else if ( active ) {
|
||||
this.container.stop( true, true ).slideDown( duration, args.completeCallback );
|
||||
} else {
|
||||
this.container.stop( true, true ).slideUp( duration, args.completeCallback );
|
||||
|
@ -640,7 +644,7 @@
|
|||
* @augments wp.customize.Class
|
||||
*/
|
||||
api.Control = api.Class.extend({
|
||||
defaultActiveArguments: { duration: 'fast' },
|
||||
defaultActiveArguments: { duration: 'fast', completeCallback: $.noop },
|
||||
|
||||
initialize: function( id, options ) {
|
||||
var control = this,
|
||||
|
@ -781,7 +785,11 @@
|
|||
* @param {Object} args merged on top of this.defaultActiveArguments
|
||||
*/
|
||||
onChangeActive: function ( active, args ) {
|
||||
if ( active ) {
|
||||
if ( ! $.contains( document, this.container ) ) {
|
||||
// jQuery.fn.slideUp is not hiding an element if it is not in the DOM
|
||||
this.container.toggle( active );
|
||||
args.completeCallback();
|
||||
} else if ( active ) {
|
||||
this.container.slideDown( args.duration, args.completeCallback );
|
||||
} else {
|
||||
this.container.slideUp( args.duration, args.completeCallback );
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -405,7 +405,8 @@
|
|||
*/
|
||||
api.Widgets.WidgetControl = api.Control.extend({
|
||||
defaultExpandedArguments: {
|
||||
duration: 'fast'
|
||||
duration: 'fast',
|
||||
completeCallback: $.noop
|
||||
},
|
||||
|
||||
initialize: function ( id, options ) {
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -4,7 +4,7 @@
|
|||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '4.1-alpha-30306';
|
||||
$wp_version = '4.1-alpha-30307';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
|
Loading…
Reference in New Issue