Theme Customizer: Add the wp.customize.Events mixin to wp.customize.Values. Provide 'add', 'remove', and 'change' events by default. see #19910.
git-svn-id: http://core.svn.wordpress.org/trunk@20799 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
3165e6d50a
commit
7ea4eef7f0
@ -283,7 +283,11 @@ if ( typeof wp === 'undefined' )
|
|||||||
return this.value( id );
|
return this.value( id );
|
||||||
|
|
||||||
this._value[ id ] = value;
|
this._value[ id ] = value;
|
||||||
this._value[ id ].parent = this;
|
value.parent = this;
|
||||||
|
if ( value.extended( api.Value ) )
|
||||||
|
value.bind( this._change );
|
||||||
|
|
||||||
|
this.trigger( 'add', value );
|
||||||
|
|
||||||
if ( this._deferreds[ id ] )
|
if ( this._deferreds[ id ] )
|
||||||
this._deferreds[ id ].resolve();
|
this._deferreds[ id ].resolve();
|
||||||
@ -305,6 +309,16 @@ if ( typeof wp === 'undefined' )
|
|||||||
},
|
},
|
||||||
|
|
||||||
remove: function( id ) {
|
remove: function( id ) {
|
||||||
|
var value;
|
||||||
|
|
||||||
|
if ( this.has( id ) ) {
|
||||||
|
value = this.value( id );
|
||||||
|
this.trigger( 'remove', value );
|
||||||
|
if ( value.extended( api.Value ) )
|
||||||
|
value.unbind( this._change );
|
||||||
|
delete value.parent;
|
||||||
|
}
|
||||||
|
|
||||||
delete this._value[ id ];
|
delete this._value[ id ];
|
||||||
delete this._deferreds[ id ];
|
delete this._deferreds[ id ];
|
||||||
},
|
},
|
||||||
@ -352,9 +366,15 @@ if ( typeof wp === 'undefined' )
|
|||||||
});
|
});
|
||||||
|
|
||||||
return dfd.promise();
|
return dfd.promise();
|
||||||
|
},
|
||||||
|
|
||||||
|
_change: function() {
|
||||||
|
this.parent.trigger( 'change', this );
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$.extend( api.Values.prototype, api.Events );
|
||||||
|
|
||||||
/* =====================================================================
|
/* =====================================================================
|
||||||
* An observable value that syncs with an element.
|
* An observable value that syncs with an element.
|
||||||
*
|
*
|
||||||
|
Loading…
Reference in New Issue
Block a user