Skip to content

Commit

Permalink
Merge pull request emberjs#9 from chadhietala/api-documentation-audit
Browse files Browse the repository at this point in the history
Documentation For ember-routing/lib/ext/view.js
  • Loading branch information
trek committed Aug 9, 2013
2 parents 2c1ec02 + 4f8c90b commit bd87f72
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions packages/ember-routing/lib/ext/view.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,30 @@
var get = Ember.get, set = Ember.set;

Ember.View.reopen({

/**
Sets the private `_outlets` object on the view.
@method init
*/
init: function() {
set(this, '_outlets', {});
this._super();
},

/**
Allows you to connect a unique view as the parent
view's `{{outlet}}`.
```javascript
myView.connectOutlet('main', Ember.View.extend({
template: Ember.Handlebars.compile('<h1>Foo</h1> ')
}));
```
@method connectOutlet
@param {String} outletName A unique name for the outlet
@param {Object} view An Ember.View
*/
connectOutlet: function(outletName, view) {
if (this._pendingDisconnections) {
delete this._pendingDisconnections[outletName];
Expand All @@ -33,6 +52,18 @@ Ember.View.reopen({
}
},

/**
@private
Determines if the view has already been created by checking if
the view has the same constructor, template, and context as the
view in the `_outlets` object.
@method _hasEquivalentView
@param {String} outletName The name of the outlet we are checking
@param {Object} view An Ember.View
@return {Boolean}
*/
_hasEquivalentView: function(outletName, view) {
var existingView = get(this, '_outlets.'+outletName);
return existingView &&
Expand All @@ -41,6 +72,12 @@ Ember.View.reopen({
existingView.get('context') === view.get('context');
},

/**
Removes an outlet from the current view.
@method disconnectOutlet
@param {String} outletName The name of the outlet to be removed
*/
disconnectOutlet: function(outletName) {
if (!this._pendingDisconnections) {
this._pendingDisconnections = {};
Expand All @@ -49,6 +86,14 @@ Ember.View.reopen({
Ember.run.once(this, '_finishDisconnections');
},

/**
@private
Gets an outlet that is pending disconnection and then
nullifys the object on the `_outlet` object.
@method _finishDisconnections
*/
_finishDisconnections: function() {
var outlets = get(this, '_outlets');
var pendingDisconnections = this._pendingDisconnections;
Expand Down

0 comments on commit bd87f72

Please sign in to comment.