mirror of
https://github.com/WordPress/WordPress.git
synced 2024-09-10 22:58:33 +02:00
See #28510. Built from https://develop.svn.wordpress.org/trunk@31491 git-svn-id: http://core.svn.wordpress.org/trunk@31472 1a063a9b-81f0-0310-95a4-ce76da25c4cd
67 lines
1.7 KiB
JavaScript
67 lines
1.7 KiB
JavaScript
/*globals wp */
|
|
|
|
/**
|
|
* wp.media.View
|
|
*
|
|
* The base view class for media.
|
|
*
|
|
* Undelegating events, removing events from the model, and
|
|
* removing events from the controller mirror the code for
|
|
* `Backbone.View.dispose` in Backbone 0.9.8 development.
|
|
*
|
|
* This behavior has since been removed, and should not be used
|
|
* outside of the media manager.
|
|
*
|
|
* @class
|
|
* @augments wp.Backbone.View
|
|
* @augments Backbone.View
|
|
*/
|
|
var View = wp.Backbone.View.extend({
|
|
constructor: function( options ) {
|
|
if ( options && options.controller ) {
|
|
this.controller = options.controller;
|
|
}
|
|
wp.Backbone.View.apply( this, arguments );
|
|
},
|
|
/**
|
|
* @todo The internal comment mentions this might have been a stop-gap
|
|
* before Backbone 0.9.8 came out. Figure out if Backbone core takes
|
|
* care of this in Backbone.View now.
|
|
*
|
|
* @returns {wp.media.View} Returns itself to allow chaining
|
|
*/
|
|
dispose: function() {
|
|
// Undelegating events, removing events from the model, and
|
|
// removing events from the controller mirror the code for
|
|
// `Backbone.View.dispose` in Backbone 0.9.8 development.
|
|
this.undelegateEvents();
|
|
|
|
if ( this.model && this.model.off ) {
|
|
this.model.off( null, null, this );
|
|
}
|
|
|
|
if ( this.collection && this.collection.off ) {
|
|
this.collection.off( null, null, this );
|
|
}
|
|
|
|
// Unbind controller events.
|
|
if ( this.controller && this.controller.off ) {
|
|
this.controller.off( null, null, this );
|
|
}
|
|
|
|
return this;
|
|
},
|
|
/**
|
|
* @returns {wp.media.View} Returns itself to allow chaining
|
|
*/
|
|
remove: function() {
|
|
this.dispose();
|
|
/**
|
|
* call 'remove' directly on the parent class
|
|
*/
|
|
return wp.Backbone.View.prototype.remove.apply( this, arguments );
|
|
}
|
|
});
|
|
|
|
module.exports = View;
|