Skip to content

Commit

Permalink
Break out view state related code into ViewStateSupport
Browse files Browse the repository at this point in the history
  • Loading branch information
ebryn committed Jan 31, 2015
1 parent fe35913 commit ee12bb2
Showing 1 changed file with 18 additions and 16 deletions.
34 changes: 18 additions & 16 deletions packages/ember-views/lib/views/view.js
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,22 @@ var ViewChildViewsSupport = Mixin.create({
}
});

var ViewStateSupport = Mixin.create({
transitionTo: function(state, children) {
Ember.deprecate("Ember.View#transitionTo has been deprecated, it is for internal use only");
this._transitionTo(state, children);
},

_transitionTo: function(state, children) {
var priorState = this.currentState;
var currentState = this.currentState = this._states[state];
this._state = state;

if (priorState && priorState.exit) { priorState.exit(this); }
if (currentState.enter) { currentState.enter(this); }
}
});

/**
`Ember.View` is the class in Ember responsible for encapsulating templates of
HTML content, combining templates with data to render as sections of a page's
Expand Down Expand Up @@ -1003,7 +1019,7 @@ var ViewChildViewsSupport = Mixin.create({
@namespace Ember
@extends Ember.CoreView
*/
var View = CoreView.extend(ViewStreamSupport, ViewKeywordSupport, ViewContextSupport, ViewChildViewsSupport, {
var View = CoreView.extend(ViewStreamSupport, ViewKeywordSupport, ViewContextSupport, ViewChildViewsSupport, ViewStateSupport, {

concatenatedProperties: ['classNames', 'classNameBindings', 'attributeBindings'],

Expand Down Expand Up @@ -2077,20 +2093,6 @@ var View = CoreView.extend(ViewStreamSupport, ViewKeywordSupport, ViewContextSup
return false;
},

transitionTo: function(state, children) {
Ember.deprecate("Ember.View#transitionTo has been deprecated, it is for internal use only");
this._transitionTo(state, children);
},

_transitionTo: function(state, children) {
var priorState = this.currentState;
var currentState = this.currentState = this._states[state];
this._state = state;

if (priorState && priorState.exit) { priorState.exit(this); }
if (currentState.enter) { currentState.enter(this); }
},

// .......................................................
// EVENT HANDLING
//
Expand Down Expand Up @@ -2229,4 +2231,4 @@ View.applyAttributeBindings = function(dom, elem, name, initialValue) {

export default View;

export { ViewKeywordSupport, ViewStreamSupport, ViewContextSupport, ViewChildViewsSupport };
export { ViewKeywordSupport, ViewStreamSupport, ViewContextSupport, ViewChildViewsSupport, ViewStateSupport };

0 comments on commit ee12bb2

Please sign in to comment.