WordPress.org

Make WordPress Core

Changeset 30307


Ignore:
Timestamp:
11/11/2014 10:36:51 PM (6 years ago)
Author:
ocean90
Message:

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.

Location:
trunk/src/wp-admin/js
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/js/customize-controls.js

    r30306 r30307  
    132132     */
    133133    Container = api.Class.extend({
    134         defaultActiveArguments: { duration: 'fast' },
    135         defaultExpandedArguments: { duration: 'fast' },
     134        defaultActiveArguments: { duration: 'fast', completeCallback: $.noop },
     135        defaultExpandedArguments: { duration: 'fast', completeCallback: $.noop },
    136136
    137137        initialize: function ( id, options ) {
     
    218218        onChangeActive: function ( active, args ) {
    219219            var duration = ( 'resolved' === api.previewer.deferred.active.state() ? args.duration : 0 );
    220             if ( active ) {
     220            if ( ! $.contains( document, this.container ) ) {
     221                // jQuery.fn.slideUp is not hiding an element if it is not in the DOM
     222                this.container.toggle( active );
     223                args.completeCallback();
     224            } else if ( active ) {
    221225                this.container.stop( true, true ).slideDown( duration, args.completeCallback );
    222226            } else {
     
    641645     */
    642646    api.Control = api.Class.extend({
    643         defaultActiveArguments: { duration: 'fast' },
     647        defaultActiveArguments: { duration: 'fast', completeCallback: $.noop },
    644648
    645649        initialize: function( id, options ) {
     
    782786         */
    783787        onChangeActive: function ( active, args ) {
    784             if ( active ) {
     788            if ( ! $.contains( document, this.container ) ) {
     789                // jQuery.fn.slideUp is not hiding an element if it is not in the DOM
     790                this.container.toggle( active );
     791                args.completeCallback();
     792            } else if ( active ) {
    785793                this.container.slideDown( args.duration, args.completeCallback );
    786794            } else {
  • trunk/src/wp-admin/js/customize-widgets.js

    r30104 r30307  
    406406    api.Widgets.WidgetControl = api.Control.extend({
    407407        defaultExpandedArguments: {
    408             duration: 'fast'
     408            duration: 'fast',
     409            completeCallback: $.noop
    409410        },
    410411
Note: See TracChangeset for help on using the changeset viewer.