Media Grid, remove unnecessary abstraction: `wp.media.controller._State`

Props ericlewis.
See #24716.

Built from https://develop.svn.wordpress.org/trunk@29066


git-svn-id: http://core.svn.wordpress.org/trunk@28852 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Scott Taylor 2014-07-10 16:02:15 +00:00
parent dd9bfea6bb
commit d297258d99
4 changed files with 27 additions and 63 deletions

View File

@ -17,7 +17,7 @@
* @augments wp.media.controller.State * @augments wp.media.controller.State
* @augments Backbone.Model * @augments Backbone.Model
*/ */
media.controller.EditImageNoFrame = media.controller._State.extend({ media.controller.EditImageNoFrame = media.controller.State.extend({
defaults: { defaults: {
id: 'edit-attachment', id: 'edit-attachment',
title: l10n.editImage, title: l10n.editImage,
@ -29,19 +29,17 @@
url: '' url: ''
}, },
initialize: function() { _ready: function() {},
media.controller._State.prototype.initialize.apply( this, arguments );
},
/**
* Override media.controller.State._postActivate, since this state doesn't
* include the regions expected there.
*/
_postActivate: function() { _postActivate: function() {
this._content(); this._content();
this._router(); this._router();
}, },
deactivate: function() {
this.stopListening( this.frame );
},
/** /**
* @access private * @access private
*/ */

File diff suppressed because one or more lines are too long

View File

@ -337,11 +337,16 @@
}); });
/** /**
* A more abstracted state, because media.controller.State expects * wp.media.controller.State
* specific regions (menu, title, etc.) to exist on the frame, which do not *
* exist in media.view.Frame.EditAttachment. * A state is a step in a workflow that when set will trigger the controllers
* for the regions to be updated as specified in the frame. This is the base
* class that the various states used in wp.media extend.
*
* @constructor
* @augments Backbone.Model
*/ */
media.controller._State = Backbone.Model.extend({ media.controller.State = Backbone.Model.extend({
constructor: function() { constructor: function() {
this.on( 'activate', this._preActivate, this ); this.on( 'activate', this._preActivate, this );
this.on( 'activate', this.activate, this ); this.on( 'activate', this.activate, this );
@ -349,13 +354,14 @@
this.on( 'deactivate', this._deactivate, this ); this.on( 'deactivate', this._deactivate, this );
this.on( 'deactivate', this.deactivate, this ); this.on( 'deactivate', this.deactivate, this );
this.on( 'reset', this.reset, this ); this.on( 'reset', this.reset, this );
this.on( 'ready', this._ready, this );
this.on( 'ready', this.ready, this ); this.on( 'ready', this.ready, this );
/** /**
* Call parent constructor with passed arguments * Call parent constructor with passed arguments
*/ */
Backbone.Model.apply( this, arguments ); Backbone.Model.apply( this, arguments );
this.on( 'change:menu', this._updateMenu, this );
}, },
/** /**
* @abstract * @abstract
*/ */
@ -372,58 +378,18 @@
* @abstract * @abstract
*/ */
reset: function() {}, reset: function() {},
/**
* @access private
*/
_preActivate: function() {
this.active = true;
},
/**
* @access private
*/
_postActivate: function() {},
/**
* @access private
*/
_deactivate: function() {
this.active = false;
}
});
/**
* wp.media.controller.State
*
* A state is a step in a workflow that when set will trigger the controllers
* for the regions to be updated as specified in the frame. This is the base
* class that the various states used in wp.media extend.
*
* @constructor
* @augments Backbone.Model
*/
media.controller.State = media.controller._State.extend({
constructor: function() {
this.on( 'activate', this._preActivate, this );
this.on( 'activate', this.activate, this );
this.on( 'activate', this._postActivate, this );
this.on( 'deactivate', this._deactivate, this );
this.on( 'deactivate', this.deactivate, this );
this.on( 'reset', this.reset, this );
this.on( 'ready', this._ready, this );
this.on( 'ready', this.ready, this );
/**
* Call parent constructor with passed arguments
*/
Backbone.Model.apply( this, arguments );
this.on( 'change:menu', this._updateMenu, this );
},
/** /**
* @access private * @access private
*/ */
_ready: function() { _ready: function() {
this._updateMenu(); this._updateMenu();
}, },
/**
* @access private
*/
_preActivate: function() {
this.active = true;
},
/** /**
* @access private * @access private
*/ */

File diff suppressed because one or more lines are too long