diff --git a/src/wp-includes/js/customize-base.js b/src/wp-includes/js/customize-base.js
index 2e0ab19..720a312 100644
a
|
b
|
window.wp = window.wp || {}; |
74 | 74 | } |
75 | 75 | |
76 | 76 | magic = this; |
| 77 | |
| 78 | /* |
| 79 | * If the class has a method called "instance", |
| 80 | * the return value from the class' constructor will be a function that |
| 81 | * calls invoked, along with all the object properties of the class. |
| 82 | */ |
77 | 83 | if ( this.instance ) { |
78 | 84 | magic = function() { |
79 | 85 | return magic.instance.apply( magic, arguments ); |
… |
… |
window.wp = window.wp || {}; |
101 | 107 | |
102 | 108 | api.Class.applicator = {}; |
103 | 109 | |
| 110 | /** |
| 111 | * Initialize a class instance. |
| 112 | * |
| 113 | * Override this function in a subclass as needed. |
| 114 | */ |
104 | 115 | api.Class.prototype.initialize = function() {}; |
105 | 116 | |
106 | 117 | /* |
… |
… |
window.wp = window.wp || {}; |
281 | 292 | this._deferreds = {}; |
282 | 293 | }, |
283 | 294 | |
| 295 | /** |
| 296 | * Get the instance of an item from the collection if only ID is specified. |
| 297 | * |
| 298 | * If more than one argument is supplied, all are expected to be IDs and |
| 299 | * the last to be a function callback that will be invoked when the requested |
| 300 | * items are available. |
| 301 | * |
| 302 | * @see {api.Values.when} |
| 303 | * |
| 304 | * @param {string} id ID of the item. |
| 305 | * @param {...} Zero or more IDs of items to wait for and a callback |
| 306 | * function to invoke when they're available. Optional. |
| 307 | * @return {mixed} The item instance if only one ID was supplied. |
| 308 | * A Deferred Promise object if a callback function is supplied. |
| 309 | */ |
284 | 310 | instance: function( id ) { |
285 | 311 | if ( arguments.length === 1 ) |
286 | 312 | return this.value( id ); |
… |
… |
window.wp = window.wp || {}; |
288 | 314 | return this.when.apply( this, arguments ); |
289 | 315 | }, |
290 | 316 | |
| 317 | /** |
| 318 | * Get the instance of an item. |
| 319 | * |
| 320 | * @param {string} id The ID of the item. |
| 321 | * @return {[type]} [description] |
| 322 | */ |
291 | 323 | value: function( id ) { |
292 | 324 | return this._value[ id ]; |
293 | 325 | }, |
294 | 326 | |
| 327 | /** |
| 328 | * Whether the collection has an item with the given ID. |
| 329 | * |
| 330 | * @param {string} id The ID of the item to look for. |
| 331 | * @return {Boolean} |
| 332 | */ |
295 | 333 | has: function( id ) { |
296 | 334 | return typeof this._value[ id ] !== 'undefined'; |
297 | 335 | }, |
298 | 336 | |
| 337 | /** |
| 338 | * Add an item to the collection. |
| 339 | * |
| 340 | * @param {string} id The ID of the item. |
| 341 | * @param {mixed} value The item instance. |
| 342 | * @return {mixed} The new item's instance. |
| 343 | */ |
299 | 344 | add: function( id, value ) { |
300 | 345 | if ( this.has( id ) ) |
301 | 346 | return this.value( id ); |
… |
… |
window.wp = window.wp || {}; |
307 | 352 | |
308 | 353 | this.trigger( 'add', value ); |
309 | 354 | |
| 355 | // If a deferred object exists for this item, |
| 356 | // resolve it. |
310 | 357 | if ( this._deferreds[ id ] ) |
311 | 358 | this._deferreds[ id ].resolve(); |
312 | 359 | |
313 | 360 | return this._value[ id ]; |
314 | 361 | }, |
315 | 362 | |
| 363 | /** |
| 364 | * Create a new item of the collection using the collection's default constructor |
| 365 | * and store it in the collection. |
| 366 | * |
| 367 | * @param {string} id The ID of the item. |
| 368 | * @param {mixed} value Any extra arguments are passed into the item's initialize method. |
| 369 | * @return {mixed} The new item's instance. |
| 370 | */ |
316 | 371 | create: function( id ) { |
317 | 372 | return this.add( id, new this.defaultConstructor( api.Class.applicator, slice.call( arguments, 1 ) ) ); |
318 | 373 | }, |
… |
… |
window.wp = window.wp || {}; |
325 | 380 | }); |
326 | 381 | }, |
327 | 382 | |
| 383 | /** |
| 384 | * Remove an item from the collection. |
| 385 | * |
| 386 | * @param {string} id The ID of the item to remove. |
| 387 | */ |
328 | 388 | remove: function( id ) { |
329 | 389 | var value; |
330 | 390 | |
… |
… |
window.wp = window.wp || {}; |
359 | 419 | if ( $.isFunction( ids[ ids.length - 1 ] ) ) |
360 | 420 | dfd.done( ids.pop() ); |
361 | 421 | |
| 422 | /* |
| 423 | * Create a stack of deferred objects for each item that is not |
| 424 | * yet available, and invoke the supplied callback when they are. |
| 425 | */ |
362 | 426 | $.when.apply( $, $.map( ids, function( id ) { |
363 | 427 | if ( self.has( id ) ) |
364 | 428 | return; |
365 | 429 | |
| 430 | /* |
| 431 | * The requested item is not available yet, create a deferred |
| 432 | * object to resolve when it becomes available. |
| 433 | */ |
366 | 434 | return self._deferreds[ id ] = self._deferreds[ id ] || $.Deferred(); |
367 | 435 | })).done( function() { |
368 | 436 | var values = $.map( ids, function( id ) { |