Changeset 22746
- Timestamp:
- 11/21/2012 11:35:30 AM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/js/media-models.js
r22743 r22746 363 363 hasAttachment = !! this.getByCid( attachment.cid ); 364 364 365 // Only retain the `silent` option.366 options = {367 silent: options && options.silent368 };369 370 365 if ( ! valid && hasAttachment ) 371 366 this.remove( attachment, options ); … … 376 371 }, 377 372 378 validateAll: function( attachments ) { 373 validateAll: function( attachments, options ) { 374 options = options || {}; 375 379 376 _.each( attachments.models, function( attachment ) { 380 377 this.validate( attachment, { silent: true }); 381 378 }, this ); 379 380 if ( ! options.silent ) 381 this.trigger( 'reset', this, options ); 382 382 383 383 return this; … … 411 411 412 412 _validateHandler: function( attachment, attachments, options ) { 413 // If we're not mirroring this `attachments` collection, 414 // only retain the `silent` option. 415 options = attachments === this.mirroring ? options : { 416 silent: options && options.silent 417 }; 418 413 419 return this.validate( attachment, options ); 414 420 }, … … 424 430 this.unmirror(); 425 431 this.mirroring = attachments; 426 this.reset( attachments.models ); 427 attachments.on( 'add', this._mirrorAdd, this ); 428 attachments.on( 'remove', this._mirrorRemove, this ); 429 attachments.on( 'reset', this._mirrorReset, this ); 432 433 // Clear the collection silently. A `reset` event will be fired 434 // when `observe()` calls `validateAll()`. 435 this.reset( [], { silent: true } ); 436 this.observe( attachments ); 430 437 }, 431 438 … … 434 441 return; 435 442 436 this.mirroring.off( 'add', this._mirrorAdd, this ); 437 this.mirroring.off( 'remove', this._mirrorRemove, this ); 438 this.mirroring.off( 'reset', this._mirrorReset, this ); 443 this.unobserve( this.mirroring ); 439 444 delete this.mirroring; 440 },441 442 _mirrorAdd: function( attachment, attachments, options ) {443 this.add( attachment, { at: options.index });444 },445 446 _mirrorRemove: function( attachment ) {447 this.remove( attachment );448 },449 450 _mirrorReset: function( attachments ) {451 this.reset( attachments.models );452 445 }, 453 446
Note: See TracChangeset
for help on using the changeset viewer.