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

Props ericlewis.
See #24716.


git-svn-id: https://develop.svn.wordpress.org/trunk@29066 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Scott Taylor 2014-07-10 16:01:49 +00:00
parent 868d88800c
commit b11d095c7d
2 changed files with 23 additions and 59 deletions

View File

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

View File

@ -337,11 +337,16 @@
});
/**
* A more abstracted state, because media.controller.State expects
* specific regions (menu, title, etc.) to exist on the frame, which do not
* exist in media.view.Frame.EditAttachment.
* 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 = Backbone.Model.extend({
media.controller.State = Backbone.Model.extend({
constructor: function() {
this.on( 'activate', this._preActivate, 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( '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 );
},
/**
* @abstract
*/
@ -372,58 +378,18 @@
* @abstract
*/
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
*/
_ready: function() {
this._updateMenu();
},
/**
* @access private
*/
_preActivate: function() {
this.active = true;
},
/**
* @access private
*/