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:
parent
f2ecf78e88
commit
3165e6d50a
|
@ -291,43 +291,24 @@ if ( typeof wp === 'undefined' )
|
||||||
return this._value[ id ];
|
return this._value[ id ];
|
||||||
},
|
},
|
||||||
|
|
||||||
|
create: function( id ) {
|
||||||
|
return this.add( id, new this.defaultConstructor( api.Class.applicator, slice.call( arguments, 1 ) ) );
|
||||||
|
},
|
||||||
|
|
||||||
get: function() {
|
get: function() {
|
||||||
var result = {};
|
var result = {};
|
||||||
|
|
||||||
if ( arguments.length )
|
|
||||||
return this.pass( 'get', arguments );
|
|
||||||
|
|
||||||
$.each( this._value, function( key, obj ) {
|
$.each( this._value, function( key, obj ) {
|
||||||
result[ key ] = obj.get();
|
result[ key ] = obj.get();
|
||||||
} );
|
} );
|
||||||
return result;
|
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 ) {
|
remove: function( id ) {
|
||||||
delete this._value[ id ];
|
delete this._value[ id ];
|
||||||
delete this._deferreds[ 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.
|
* 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.
|
* An observable value that syncs with an element.
|
||||||
*
|
*
|
||||||
|
|
|
@ -435,7 +435,7 @@
|
||||||
});
|
});
|
||||||
|
|
||||||
$.each( api.settings.settings, function( id, data ) {
|
$.each( api.settings.settings, function( id, data ) {
|
||||||
api.set( id, id, data.value, {
|
api.create( id, id, data.value, {
|
||||||
transport: data.transport,
|
transport: data.transport,
|
||||||
previewer: previewer
|
previewer: previewer
|
||||||
} );
|
} );
|
||||||
|
@ -526,7 +526,7 @@
|
||||||
|
|
||||||
control.element.bind( function( to ) {
|
control.element.bind( function( to ) {
|
||||||
if ( ! to )
|
if ( ! to )
|
||||||
last = api.get( 'header_textcolor' );
|
last = api( 'header_textcolor' ).get();
|
||||||
|
|
||||||
control.setting.set( to ? last : 'blank' );
|
control.setting.set( to ? last : 'blank' );
|
||||||
});
|
});
|
||||||
|
|
|
@ -65,11 +65,13 @@
|
||||||
preview = new api.Preview( window.location.href );
|
preview = new api.Preview( window.location.href );
|
||||||
|
|
||||||
$.each( api.settings.values, function( id, value ) {
|
$.each( api.settings.values, function( id, value ) {
|
||||||
api.set( id, value );
|
api.create( id, value );
|
||||||
});
|
});
|
||||||
|
|
||||||
preview.bind( 'setting', function( args ) {
|
preview.bind( 'setting', function( args ) {
|
||||||
api.set.apply( api, args );
|
var value = api( args.shift() );
|
||||||
|
if ( value )
|
||||||
|
value.apply( value, args );
|
||||||
});
|
});
|
||||||
|
|
||||||
body = $(document.body);
|
body = $(document.body);
|
||||||
|
|
Loading…
Reference in New Issue