From 3165e6d50a80470284021eab09b1806db2629a1c Mon Sep 17 00:00:00 2001 From: koopersmith Date: Tue, 15 May 2012 22:14:46 +0000 Subject: [PATCH] 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 --- wp-includes/js/customize-base.dev.js | 34 +++--------------------- wp-includes/js/customize-controls.dev.js | 4 +-- wp-includes/js/customize-preview.dev.js | 6 +++-- 3 files changed, 10 insertions(+), 34 deletions(-) diff --git a/wp-includes/js/customize-base.dev.js b/wp-includes/js/customize-base.dev.js index 04fe2f2af..cf3f168d3 100644 --- a/wp-includes/js/customize-base.dev.js +++ b/wp-includes/js/customize-base.dev.js @@ -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. * diff --git a/wp-includes/js/customize-controls.dev.js b/wp-includes/js/customize-controls.dev.js index e6fa3bc5c..3b1287a38 100644 --- a/wp-includes/js/customize-controls.dev.js +++ b/wp-includes/js/customize-controls.dev.js @@ -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' ); }); diff --git a/wp-includes/js/customize-preview.dev.js b/wp-includes/js/customize-preview.dev.js index 5aee86342..674855912 100644 --- a/wp-includes/js/customize-preview.dev.js +++ b/wp-includes/js/customize-preview.dev.js @@ -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);