mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-06-28 22:30:04 +00:00
Media: Update total attachment count when media added or removed.
Add handlers to increment the total attachments count for the media collection when an item is added or removed. props adamsilverstein. Fixes #53171. git-svn-id: https://develop.svn.wordpress.org/trunk@51191 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -212,6 +212,8 @@ var Attachments = Backbone.Collection.extend(/** @lends wp.media.model.Attachmen
|
||||
this.observers.push( attachments );
|
||||
|
||||
attachments.on( 'add change remove', this._validateHandler, this );
|
||||
attachments.on( 'add', this._addToTotalAttachments, this );
|
||||
attachments.on( 'remove', this._removeFromTotalAttachments, this );
|
||||
attachments.on( 'reset', this._validateAllHandler, this );
|
||||
this.validateAll( attachments );
|
||||
return this;
|
||||
@@ -236,6 +238,30 @@ var Attachments = Backbone.Collection.extend(/** @lends wp.media.model.Attachmen
|
||||
|
||||
return this;
|
||||
},
|
||||
/**
|
||||
* Update total attachment count when items are added to a collection.
|
||||
*
|
||||
* @access private
|
||||
*
|
||||
* @since 5.8.0
|
||||
*/
|
||||
_removeFromTotalAttachments: function() {
|
||||
if ( this.mirroring ) {
|
||||
this.mirroring.totalAttachments = this.mirroring.totalAttachments - 1;
|
||||
}
|
||||
},
|
||||
/**
|
||||
* Update total attachment count when items are added to a collection.
|
||||
*
|
||||
* @access private
|
||||
*
|
||||
* @since 5.8.0
|
||||
*/
|
||||
_addToTotalAttachments: function() {
|
||||
if ( this.mirroring ) {
|
||||
this.mirroring.totalAttachments = this.mirroring.totalAttachments + 1;
|
||||
}
|
||||
},
|
||||
/**
|
||||
* @access private
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user