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 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
*/

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
* 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
*/

File diff suppressed because one or more lines are too long