WordPress.org

Make WordPress Core

Changeset 20799


Ignore:
Timestamp:
05/15/2012 10:43:49 PM (6 years ago)
Author:
koopersmith
Message:

Theme Customizer: Add the wp.customize.Events mixin to wp.customize.Values. Provide 'add', 'remove', and 'change' events by default. see #19910.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/js/customize-base.dev.js

    r20798 r20799  
    284284
    285285            this._value[ id ] = value;
    286             this._value[ id ].parent = this;
     286            value.parent = this;
     287            if ( value.extended( api.Value ) )
     288                value.bind( this._change );
     289
     290            this.trigger( 'add', value );
    287291
    288292            if ( this._deferreds[ id ] )
     
    306310
    307311        remove: function( id ) {
     312            var value;
     313
     314            if ( this.has( id ) ) {
     315                value = this.value( id );
     316                this.trigger( 'remove', value );
     317                if ( value.extended( api.Value ) )
     318                    value.unbind( this._change );
     319                delete value.parent;
     320            }
     321
    308322            delete this._value[ id ];
    309323            delete this._deferreds[ id ];
     
    353367
    354368            return dfd.promise();
     369        },
     370
     371        _change: function() {
     372            this.parent.trigger( 'change', this );
    355373        }
    356374    });
     375
     376    $.extend( api.Values.prototype, api.Events );
    357377
    358378    /* =====================================================================
Note: See TracChangeset for help on using the changeset viewer.