Theme Customizer: Clarify wp.customize.Values API by removing Values.pass and all methods that passed through to the wp.customize.Value objects it contained. see #19910.

git-svn-id: http://core.svn.wordpress.org/trunk@20798 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
koopersmith 2012-05-15 22:14:46 +00:00
parent f2ecf78e88
commit 3165e6d50a
3 changed files with 10 additions and 34 deletions

View File

@ -291,43 +291,24 @@ if ( typeof wp === 'undefined' )
return this._value[ id ];
},
create: function( id ) {
return this.add( id, new this.defaultConstructor( api.Class.applicator, slice.call( arguments, 1 ) ) );
},
get: function() {
var result = {};
if ( arguments.length )
return this.pass( 'get', arguments );
$.each( this._value, function( key, obj ) {
result[ key ] = obj.get();
} );
return result;
},
set: function( id ) {
if ( this.has( id ) )
return this.pass( 'set', arguments );
return this.add( id, new this.defaultConstructor( api.Class.applicator, slice.call( arguments, 1 ) ) );
},
remove: function( id ) {
delete this._value[ id ];
delete this._deferreds[ id ];
},
pass: function( fn, args ) {
var id, value;
args = slice.call( args );
id = args.shift();
if ( ! this.has( id ) )
return;
value = this.value( id );
return value[ fn ].apply( value, args );
},
/**
* Runs a callback once all requested values exist.
*
@ -374,13 +355,6 @@ if ( typeof wp === 'undefined' )
}
});
$.each( [ 'bind', 'unbind', 'link', 'unlink', 'sync', 'unsync', 'setter', 'resetSetter' ], function( i, method ) {
api.Values.prototype[ method ] = function() {
return this.pass( method, arguments );
};
});
/* =====================================================================
* An observable value that syncs with an element.
*

View File

@ -435,7 +435,7 @@
});
$.each( api.settings.settings, function( id, data ) {
api.set( id, id, data.value, {
api.create( id, id, data.value, {
transport: data.transport,
previewer: previewer
} );
@ -526,7 +526,7 @@
control.element.bind( function( to ) {
if ( ! to )
last = api.get( 'header_textcolor' );
last = api( 'header_textcolor' ).get();
control.setting.set( to ? last : 'blank' );
});

View File

@ -65,11 +65,13 @@
preview = new api.Preview( window.location.href );
$.each( api.settings.values, function( id, value ) {
api.set( id, value );
api.create( id, value );
});
preview.bind( 'setting', function( args ) {
api.set.apply( api, args );
var value = api( args.shift() );
if ( value )
value.apply( value, args );
});
body = $(document.body);