Rename 'popular' to 'latest'. First stab at 'Hot' tab.
This commit is contained in:
@@ -98,7 +98,7 @@ Discourse.ListController = Discourse.Controller.extend({
|
||||
});
|
||||
|
||||
Discourse.ListController.reopenClass({
|
||||
filters: ['popular', 'favorited', 'read', 'unread', 'new', 'posted']
|
||||
filters: ['latest', 'hot', 'favorited', 'read', 'unread', 'new', 'posted']
|
||||
});
|
||||
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
This controller supports actions when listing topics or categories
|
||||
|
||||
@class ListTopicsController
|
||||
@class ListTopicsController
|
||||
@extends Discourse.ObjectController
|
||||
@namespace Discourse
|
||||
@module Discourse
|
||||
@@ -11,31 +11,30 @@ Discourse.ListTopicsController = Discourse.ObjectController.extend({
|
||||
// If we're changing our channel
|
||||
previousChannel: null,
|
||||
|
||||
popular: (function() {
|
||||
return this.get('content.filter') === 'popular';
|
||||
}).property('content.filter'),
|
||||
latest: Ember.computed.equal('content.filter', 'latest'),
|
||||
|
||||
filterModeChanged: function() {
|
||||
|
||||
filterModeChanged: (function() {
|
||||
// Unsubscribe from a previous channel if necessary
|
||||
var channel, filterMode, previousChannel,
|
||||
_this = this;
|
||||
if (previousChannel = this.get('previousChannel')) {
|
||||
var previousChannel = this.get('previousChannel');
|
||||
if (previousChannel) {
|
||||
Discourse.MessageBus.unsubscribe("/" + previousChannel);
|
||||
this.set('previousChannel', null);
|
||||
}
|
||||
filterMode = this.get('controllers.list.filterMode');
|
||||
if (!filterMode) {
|
||||
return;
|
||||
}
|
||||
channel = filterMode;
|
||||
Discourse.MessageBus.subscribe("/" + channel, function(data) {
|
||||
return _this.get('content').insert(data);
|
||||
|
||||
var filterMode = this.get('controllers.list.filterMode');
|
||||
if (!filterMode) return;
|
||||
|
||||
var lsitTopicsController = this;
|
||||
Discourse.MessageBus.subscribe("/" + filterMode, function(data) {
|
||||
return lsitTopicsController.get('content').insert(data);
|
||||
});
|
||||
return this.set('previousChannel', channel);
|
||||
}).observes('controllers.list.filterMode'),
|
||||
draftLoaded: (function() {
|
||||
var draft;
|
||||
draft = this.get('content.draft');
|
||||
this.set('previousChannel', filterMode);
|
||||
|
||||
}.observes('controllers.list.filterMode'),
|
||||
|
||||
draftLoaded: function() {
|
||||
var draft = this.get('content.draft');
|
||||
if (draft) {
|
||||
return this.get('controllers.composer').open({
|
||||
draft: draft,
|
||||
@@ -44,7 +43,7 @@ Discourse.ListTopicsController = Discourse.ObjectController.extend({
|
||||
ignoreIfChanged: true
|
||||
});
|
||||
}
|
||||
}).observes('content.draft'),
|
||||
}.observes('content.draft'),
|
||||
|
||||
// Star a topic
|
||||
toggleStar: function(topic) {
|
||||
|
||||
@@ -6,9 +6,8 @@
|
||||
@namespace Discourse
|
||||
@module Discourse
|
||||
**/
|
||||
var validAnon, validNavNames;
|
||||
validNavNames = ['read', 'popular', 'categories', 'favorited', 'category', 'unread', 'new', 'posted'];
|
||||
validAnon = ['popular', 'category', 'categories'];
|
||||
var validNavNames = ['read', 'latest', 'hot', 'categories', 'favorited', 'category', 'unread', 'new', 'posted'];
|
||||
var validAnon = ['latest', 'hot', 'category', 'categories'];
|
||||
|
||||
Discourse.NavItem = Discourse.Model.extend({
|
||||
categoryName: (function() {
|
||||
|
||||
@@ -33,7 +33,8 @@ Discourse.Route.buildRoutes(function() {
|
||||
router.route(r, { path: "/" + r + "/more" });
|
||||
});
|
||||
|
||||
this.route('popular', { path: '/' });
|
||||
this.route('latest', { path: '/' });
|
||||
this.route('hot', { path: '/hot' });
|
||||
this.route('categories', { path: '/categories' });
|
||||
this.route('category', { path: '/category/:slug/more' });
|
||||
this.route('category', { path: '/category/:slug' });
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
A class used to handle filtering routes such as popular, read, etc.
|
||||
A class used to handle filtering routes such as latest, hot, read, etc.
|
||||
|
||||
@class FilteredListRoute
|
||||
@extends Discourse.Route
|
||||
|
||||
@@ -70,7 +70,7 @@
|
||||
<li><a href="/admin/flags/active"><i class='icon-flag'></i>{{i18n flags_title}}</a></li>
|
||||
{{/if}}
|
||||
<li>
|
||||
{{#titledLinkTo "list.popular" titleKey="filters.popular.help"}}{{i18n filters.popular.title}}{{/titledLinkTo}}
|
||||
{{#titledLinkTo "list.latest" titleKey="filters.latest.help"}}{{i18n filters.latest.title}}{{/titledLinkTo}}
|
||||
</li>
|
||||
<li>{{#linkTo 'faq'}}{{i18n faq}}{{/linkTo}}</li>
|
||||
{{#if Discourse.currentUser.admin}}
|
||||
|
||||
@@ -54,12 +54,12 @@
|
||||
<h3>
|
||||
{{view.footerMessage}}
|
||||
{{#if view.allLoaded}}
|
||||
{{#if controller.popular}}
|
||||
{{#if controller.latest}}
|
||||
{{#if view.canCreateTopic}}
|
||||
<a href='#' {{action createTopic}}>{{i18n topic.suggest_create_topic}}</a>
|
||||
{{/if}}
|
||||
{{else}}
|
||||
{{#linkTo list.categories}}{{i18n topic.browse_all_categories}}{{/linkTo}} {{i18n or}} {{#linkTo list.popular}}{{i18n topic.view_popular_topics}}{{/linkTo}}
|
||||
{{#linkTo list.categories}}{{i18n topic.browse_all_categories}}{{/linkTo}} {{i18n or}} {{#linkTo list.latest}}{{i18n topic.view_latest_topics}}{{/linkTo}}
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
</h3>
|
||||
|
||||
@@ -115,7 +115,7 @@
|
||||
<h2>{{message}}</h2>
|
||||
|
||||
<p>
|
||||
{{#linkTo list.popular}}{{i18n topic.back_to_list}}{{/linkTo}}
|
||||
{{#linkTo list.latest}}{{i18n topic.back_to_list}}{{/linkTo}}
|
||||
</div>
|
||||
</div>
|
||||
{{else}}
|
||||
|
||||
@@ -437,7 +437,7 @@ Discourse.TopicView = Discourse.View.extend(Discourse.Scrolling, {
|
||||
var category, opts;
|
||||
|
||||
opts = {
|
||||
popularLink: "<a href=\"/\">" + (Em.String.i18n("topic.view_popular_topics")) + "</a>"
|
||||
latestLink: "<a href=\"/\">" + (Em.String.i18n("topic.view_latest_topics")) + "</a>"
|
||||
};
|
||||
if (category = this.get('controller.content.category')) {
|
||||
opts.catLink = Discourse.Utilities.categoryLink(category);
|
||||
|
||||
+359
-84
@@ -1,5 +1,5 @@
|
||||
// Version: v1.0.0-pre.2-892-g1283274
|
||||
// Last commit: 1283274 (2013-03-21 14:18:06 -0700)
|
||||
// Version: v1.0.0-pre.2-924-g9e5ec3b
|
||||
// Last commit: 9e5ec3b (2013-03-26 21:49:38 -0700)
|
||||
|
||||
|
||||
(function() {
|
||||
@@ -151,8 +151,8 @@ Ember.deprecateFunc = function(message, func) {
|
||||
|
||||
})();
|
||||
|
||||
// Version: v1.0.0-pre.2-892-g1283274
|
||||
// Last commit: 1283274 (2013-03-21 14:18:06 -0700)
|
||||
// Version: v1.0.0-pre.2-924-g9e5ec3b
|
||||
// Last commit: 9e5ec3b (2013-03-26 21:49:38 -0700)
|
||||
|
||||
|
||||
(function() {
|
||||
@@ -3679,59 +3679,238 @@ Ember.cacheFor = function cacheFor(obj, key) {
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
@method computed.not
|
||||
@for Ember
|
||||
@param {String} dependentKey
|
||||
@return {Ember.ComputedProperty} computed property which negate the original value for property
|
||||
*/
|
||||
Ember.computed.not = function(dependentKey) {
|
||||
return Ember.computed(dependentKey, function(key) {
|
||||
return !get(this, dependentKey);
|
||||
});
|
||||
};
|
||||
function getProperties(self, propertyNames) {
|
||||
var ret = {};
|
||||
for(var i = 0; i < propertyNames.length; i++) {
|
||||
ret[propertyNames[i]] = get(self, propertyNames[i]);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
@method computed.none
|
||||
@for Ember
|
||||
@param {String} dependentKey
|
||||
*/
|
||||
Ember.computed.none = function(dependentKey) {
|
||||
return Ember.computed(dependentKey, function(key) {
|
||||
var val = get(this, dependentKey);
|
||||
return Ember.isNone(val);
|
||||
});
|
||||
};
|
||||
function registerComputed(name, macro) {
|
||||
Ember.computed[name] = function(dependentKey) {
|
||||
var args = a_slice.call(arguments);
|
||||
return Ember.computed(dependentKey, function() {
|
||||
return macro.apply(this, args);
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
function registerComputedWithProperties(name, macro) {
|
||||
Ember.computed[name] = function() {
|
||||
var properties = a_slice.call(arguments);
|
||||
|
||||
var computed = Ember.computed(function() {
|
||||
return macro.apply(this, [getProperties(this, properties)]);
|
||||
});
|
||||
|
||||
return computed.property.apply(computed, properties);
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
@method computed.empty
|
||||
@for Ember
|
||||
@param {String} dependentKey
|
||||
@return {Ember.ComputedProperty} computed property which negate
|
||||
the original value for property
|
||||
*/
|
||||
Ember.computed.empty = function(dependentKey) {
|
||||
return Ember.computed(dependentKey, function(key) {
|
||||
var val = get(this, dependentKey);
|
||||
return Ember.isEmpty(val);
|
||||
});
|
||||
};
|
||||
registerComputed('empty', function(dependentKey) {
|
||||
return Ember.isEmpty(get(this, dependentKey));
|
||||
});
|
||||
|
||||
/**
|
||||
@method computed.notEmpty
|
||||
@for Ember
|
||||
@param {String} dependentKey
|
||||
@return {Ember.ComputedProperty} computed property which returns true if
|
||||
original value for property is not empty.
|
||||
*/
|
||||
registerComputed('notEmpty', function(dependentKey) {
|
||||
return !Ember.isEmpty(get(this, dependentKey));
|
||||
});
|
||||
|
||||
/**
|
||||
@method computed.none
|
||||
@for Ember
|
||||
@param {String} dependentKey
|
||||
@return {Ember.ComputedProperty} computed property which
|
||||
rturns true if original value for property is null or undefined.
|
||||
*/
|
||||
registerComputed('none', function(dependentKey) {
|
||||
return Ember.isNone(get(this, dependentKey));
|
||||
});
|
||||
|
||||
/**
|
||||
@method computed.not
|
||||
@for Ember
|
||||
@param {String} dependentKey
|
||||
@return {Ember.ComputedProperty} computed property which returns
|
||||
inverse of the original value for property
|
||||
*/
|
||||
registerComputed('not', function(dependentKey) {
|
||||
return !get(this, dependentKey);
|
||||
});
|
||||
|
||||
/**
|
||||
@method computed.bool
|
||||
@for Ember
|
||||
@param {String} dependentKey
|
||||
@return {Ember.ComputedProperty} computed property which convert to boolean the original value for property
|
||||
@return {Ember.ComputedProperty} computed property which convert
|
||||
to boolean the original value for property
|
||||
*/
|
||||
Ember.computed.bool = function(dependentKey) {
|
||||
return Ember.computed(dependentKey, function(key) {
|
||||
return !!get(this, dependentKey);
|
||||
});
|
||||
};
|
||||
registerComputed('bool', function(dependentKey) {
|
||||
return !!get(this, dependentKey);
|
||||
});
|
||||
|
||||
/**
|
||||
@method computed.match
|
||||
@for Ember
|
||||
@param {String} dependentKey
|
||||
@param {RegExp} regexp
|
||||
@return {Ember.ComputedProperty} computed property which match
|
||||
the original value for property against a given RegExp
|
||||
*/
|
||||
registerComputed('match', function(dependentKey, regexp) {
|
||||
var value = get(this, dependentKey);
|
||||
return typeof value === 'string' ? !!value.match(regexp) : false;
|
||||
});
|
||||
|
||||
/**
|
||||
@method computed.equal
|
||||
@for Ember
|
||||
@param {String} dependentKey
|
||||
@param {String|Number|Object} value
|
||||
@return {Ember.ComputedProperty} computed property which returns true if
|
||||
the original value for property is equal to the given value.
|
||||
*/
|
||||
registerComputed('equal', function(dependentKey, value) {
|
||||
return get(this, dependentKey) === value;
|
||||
});
|
||||
|
||||
/**
|
||||
@method computed.gt
|
||||
@for Ember
|
||||
@param {String} dependentKey
|
||||
@param {Number} value
|
||||
@return {Ember.ComputedProperty} computed property which returns true if
|
||||
the original value for property is greater then given value.
|
||||
*/
|
||||
registerComputed('gt', function(dependentKey, value) {
|
||||
return get(this, dependentKey) > value;
|
||||
});
|
||||
|
||||
/**
|
||||
@method computed.gte
|
||||
@for Ember
|
||||
@param {String} dependentKey
|
||||
@param {Number} value
|
||||
@return {Ember.ComputedProperty} computed property which returns true if
|
||||
the original value for property is greater or equal then given value.
|
||||
*/
|
||||
registerComputed('gte', function(dependentKey, value) {
|
||||
return get(this, dependentKey) >= value;
|
||||
});
|
||||
|
||||
/**
|
||||
@method computed.lt
|
||||
@for Ember
|
||||
@param {String} dependentKey
|
||||
@param {Number} value
|
||||
@return {Ember.ComputedProperty} computed property which returns true if
|
||||
the original value for property is less then given value.
|
||||
*/
|
||||
registerComputed('lt', function(dependentKey, value) {
|
||||
return get(this, dependentKey) < value;
|
||||
});
|
||||
|
||||
/**
|
||||
@method computed.lte
|
||||
@for Ember
|
||||
@param {String} dependentKey
|
||||
@param {Number} value
|
||||
@return {Ember.ComputedProperty} computed property which returns true if
|
||||
the original value for property is less or equal then given value.
|
||||
*/
|
||||
registerComputed('lte', function(dependentKey, value) {
|
||||
return get(this, dependentKey) <= value;
|
||||
});
|
||||
|
||||
/**
|
||||
@method computed.and
|
||||
@for Ember
|
||||
@param {String} dependentKey, [dependentKey...]
|
||||
@return {Ember.ComputedProperty} computed property which peforms
|
||||
a logical `and` on the values of all the original values for properties.
|
||||
*/
|
||||
registerComputedWithProperties('and', function(properties) {
|
||||
for (var key in properties) {
|
||||
if (properties.hasOwnProperty(key) && !properties[key]) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
});
|
||||
|
||||
/**
|
||||
@method computed.or
|
||||
@for Ember
|
||||
@param {String} dependentKey, [dependentKey...]
|
||||
@return {Ember.ComputedProperty} computed property which peforms
|
||||
a logical `or` on the values of all the original values for properties.
|
||||
*/
|
||||
registerComputedWithProperties('or', function(properties) {
|
||||
for (var key in properties) {
|
||||
if (properties.hasOwnProperty(key) && properties[key]) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
});
|
||||
|
||||
/**
|
||||
@method computed.any
|
||||
@for Ember
|
||||
@param {String} dependentKey, [dependentKey...]
|
||||
@return {Ember.ComputedProperty} computed property which returns
|
||||
the first trouthy value of given list of properties.
|
||||
*/
|
||||
registerComputedWithProperties('any', function(properties) {
|
||||
for (var key in properties) {
|
||||
if (properties.hasOwnProperty(key) && properties[key]) {
|
||||
return properties[key];
|
||||
}
|
||||
}
|
||||
return null;
|
||||
});
|
||||
|
||||
/**
|
||||
@method computed.map
|
||||
@for Ember
|
||||
@param {String} dependentKey, [dependentKey...]
|
||||
@return {Ember.ComputedProperty} computed property which maps
|
||||
values of all passed properties in to an array.
|
||||
*/
|
||||
registerComputedWithProperties('map', function(properties) {
|
||||
var res = [];
|
||||
for (var key in properties) {
|
||||
if (properties.hasOwnProperty(key)) {
|
||||
if (Ember.isNone(properties[key])) {
|
||||
res.push(null);
|
||||
} else {
|
||||
res.push(properties[key]);
|
||||
}
|
||||
}
|
||||
}
|
||||
return res;
|
||||
});
|
||||
|
||||
/**
|
||||
@method computed.alias
|
||||
@for Ember
|
||||
|
||||
@param {String} dependentKey
|
||||
@return {Ember.ComputedProperty} computed property which creates an
|
||||
alias to the original value for property.
|
||||
*/
|
||||
Ember.computed.alias = function(dependentKey) {
|
||||
return Ember.computed(dependentKey, function(key, value){
|
||||
@@ -3744,6 +3923,23 @@ Ember.computed.alias = function(dependentKey) {
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
@method computed.defaultTo
|
||||
@for Ember
|
||||
@param {String} defaultPath
|
||||
@return {Ember.ComputedProperty} computed property which acts like
|
||||
a standard getter and setter, but defaults to the value from `defaultPath`.
|
||||
*/
|
||||
Ember.computed.defaultTo = function(defaultPath) {
|
||||
return Ember.computed(function(key, newValue, cachedValue) {
|
||||
var result;
|
||||
if (arguments.length === 1) {
|
||||
return cachedValue != null ? cachedValue : get(this, defaultPath);
|
||||
}
|
||||
return newValue != null ? newValue : get(this, defaultPath);
|
||||
});
|
||||
};
|
||||
|
||||
})();
|
||||
|
||||
|
||||
@@ -4576,8 +4772,7 @@ function invokeLaterTimers() {
|
||||
If you pass a string it will be resolved on the
|
||||
target at the time the method is invoked.
|
||||
@param {Object} [args*] Optional arguments to pass to the timeout.
|
||||
@param {Number} wait
|
||||
Number of milliseconds to wait.
|
||||
@param {Number} wait Number of milliseconds to wait.
|
||||
@return {String} a string you can use to cancel the timer in
|
||||
{{#crossLink "Ember/run.cancel"}}{{/crossLink}} later.
|
||||
*/
|
||||
@@ -4699,15 +4894,54 @@ Ember.run.scheduleOnce = function(queue, target, method, args) {
|
||||
};
|
||||
|
||||
/**
|
||||
Schedules an item to run after control has been returned to the system.
|
||||
This is equivalent to calling `Ember.run.later` with a wait time of 1ms.
|
||||
Schedules an item to run from within a separate run loop, after
|
||||
control has been returned to the system. This is equivalent to calling
|
||||
`Ember.run.later` with a wait time of 1ms.
|
||||
|
||||
```javascript
|
||||
Ember.run.next(myContext, function(){
|
||||
// code to be executed in the next RunLoop, which will be scheduled after the current one
|
||||
// code to be executed in the next run loop, which will be scheduled after the current one
|
||||
});
|
||||
```
|
||||
|
||||
Multiple operations scheduled with `Ember.run.next` will coalesce
|
||||
into the same later run loop, along with any other operations
|
||||
scheduled by `Ember.run.later` that expire right around the same
|
||||
time that `Ember.run.next` operations will fire.
|
||||
|
||||
Note that there are often alternatives to using `Ember.run.next`.
|
||||
For instance, if you'd like to schedule an operation to happen
|
||||
after all DOM element operations have completed within the current
|
||||
run loop, you can make use of the `afterRender` run loop queue (added
|
||||
by the `ember-views` package, along with the preceding `render` queue
|
||||
where all the DOM element operations happen). Example:
|
||||
|
||||
```javascript
|
||||
App.MyCollectionView = Ember.CollectionView.extend({
|
||||
didInsertElement: function() {
|
||||
Ember.run.scheduleOnce('afterRender', this, 'processChildElements');
|
||||
},
|
||||
processChildElements: function() {
|
||||
// ... do something with collectionView's child view
|
||||
// elements after they've finished rendering, which
|
||||
// can't be done within the CollectionView's
|
||||
// `didInsertElement` hook because that gets run
|
||||
// before the child elements have been added to the DOM.
|
||||
}
|
||||
});
|
||||
```
|
||||
|
||||
One benefit of the above approach compared to using `Ember.run.next` is
|
||||
that you will be able to perform DOM/CSS operations before unprocessed
|
||||
elements are rendered to the screen, which may prevent flickering or
|
||||
other artifacts caused by delaying processing until after rendering.
|
||||
|
||||
The other major benefit to the above approach is that `Ember.run.next`
|
||||
introduces an element of non-determinism, which can make things much
|
||||
harder to test, due to its reliance on `setTimeout`; it's much harder
|
||||
to guarantee the order of scheduled operations when they are scheduled
|
||||
outside of the current run loop, i.e. with `Ember.run.next`.
|
||||
|
||||
@method next
|
||||
@param {Object} [target] target of method to invoke
|
||||
@param {Function|String} method The method to invoke.
|
||||
@@ -6266,7 +6500,7 @@ define("container",
|
||||
factory = name;
|
||||
fullName = type;
|
||||
} else {
|
||||
Ember.deprecate('register("'+type +'", "'+ name+'") is now deprecated in-favour of register("'+type+':'+name+'");', true);
|
||||
Ember.deprecate('register("'+type +'", "'+ name+'") is now deprecated in-favour of register("'+type+':'+name+'");', false);
|
||||
fullName = type + ":" + name;
|
||||
}
|
||||
|
||||
@@ -12825,7 +13059,7 @@ Ember Runtime
|
||||
*/
|
||||
|
||||
var jQuery = Ember.imports.jQuery;
|
||||
Ember.assert("Ember Views require jQuery 1.8 or 1.9", jQuery && (jQuery().jquery.match(/^1\.(8|9)(\.\d+)?(pre|rc\d?)?/) || Ember.ENV.FORCE_JQUERY));
|
||||
Ember.assert("Ember Views require jQuery 1.8, 1.9 or 2.0", jQuery && (jQuery().jquery.match(/^((1\.(8|9))|2.0)(\.\d+)?(pre|rc\d?)?/) || Ember.ENV.FORCE_JQUERY));
|
||||
|
||||
/**
|
||||
Alias for jQuery
|
||||
@@ -12967,9 +13201,11 @@ var setInnerHTML = function(element, html) {
|
||||
if (canSetInnerHTML(tagName)) {
|
||||
setInnerHTMLWithoutFix(element, html);
|
||||
} else {
|
||||
Ember.assert("Can't set innerHTML on "+element.tagName+" in this browser", element.outerHTML);
|
||||
// Firefox versions < 11 do not have support for element.outerHTML.
|
||||
var outerHTML = element.outerHTML || new XMLSerializer().serializeToString(element);
|
||||
Ember.assert("Can't set innerHTML on "+element.tagName+" in this browser", outerHTML);
|
||||
|
||||
var startTag = element.outerHTML.match(new RegExp("<"+tagName+"([^>]*)>", 'i'))[0],
|
||||
var startTag = outerHTML.match(new RegExp("<"+tagName+"([^>]*)>", 'i'))[0],
|
||||
endTag = '</'+tagName+'>';
|
||||
|
||||
var wrapper = document.createElement('div');
|
||||
@@ -13452,7 +13688,9 @@ Ember._RenderBuffer.prototype =
|
||||
*/
|
||||
string: function() {
|
||||
if (this._element) {
|
||||
return this.element().outerHTML;
|
||||
// Firefox versions < 11 do not have support for element.outerHTML.
|
||||
return this.element().outerHTML ||
|
||||
new XMLSerializer().serializeToString(this.element());
|
||||
} else {
|
||||
return this.innerString();
|
||||
}
|
||||
@@ -15324,9 +15562,9 @@ Ember.View = Ember.CoreView.extend(
|
||||
willInsertElement: Ember.K,
|
||||
|
||||
/**
|
||||
Called when the element of the view has been inserted into the DOM.
|
||||
Override this function to do any set up that requires an element in the
|
||||
document body.
|
||||
Called when the element of the view has been inserted into the DOM
|
||||
or after the view was re-rendered. Override this function to do any
|
||||
set up that requires an element in the document body.
|
||||
|
||||
@event didInsertElement
|
||||
*/
|
||||
@@ -17774,7 +18012,7 @@ if(!Handlebars && typeof require === 'function') {
|
||||
Handlebars = require('handlebars');
|
||||
}
|
||||
|
||||
Ember.assert("Ember Handlebars requires Handlebars 1.0.0-rc.3 or greater", Handlebars && Handlebars.VERSION.match(/^1\.0\.[0-9](\.rc\.[23456789]+)?/));
|
||||
Ember.assert("Ember Handlebars requires Handlebars 1.0.0-rc.3 or greater. Include a SCRIPT tag in the HTML HEAD linking to the Handlebars file before you link to Ember.", Handlebars && Handlebars.VERSION.match(/^1\.0\.[0-9](\.rc\.[23456789]+)?/));
|
||||
|
||||
/**
|
||||
Prepares the Handlebars templating library for use inside Ember's view
|
||||
@@ -20531,11 +20769,12 @@ Ember.Handlebars.registerHelper('each', function(path, options) {
|
||||
*/
|
||||
|
||||
Ember.Handlebars.registerHelper('template', function(name, options) {
|
||||
var template = Ember.TEMPLATES[name];
|
||||
var view = options.data.view,
|
||||
template = view.templateForName(name);
|
||||
|
||||
Ember.assert("Unable to find template with name '"+name+"'.", !!template);
|
||||
|
||||
Ember.TEMPLATES[name](this, { data: options.data });
|
||||
template(this, { data: options.data });
|
||||
});
|
||||
|
||||
})();
|
||||
@@ -20550,7 +20789,7 @@ Ember.Handlebars.registerHelper('template', function(name, options) {
|
||||
|
||||
/**
|
||||
`partial` renders a template directly using the current context.
|
||||
If needed the context can be set using the `{{#with foo}}` helper.
|
||||
If needed the context can be set using the `{{#with foo}}` helper.
|
||||
|
||||
```html
|
||||
<script type="text/x-handlebars" data-template-name="header_bar">
|
||||
@@ -20579,10 +20818,10 @@ Ember.Handlebars.registerHelper('partial', function(name, options) {
|
||||
|
||||
nameParts[nameParts.length - 1] = "_" + lastPart;
|
||||
|
||||
var underscoredName = nameParts.join("/");
|
||||
|
||||
var template = Ember.TEMPLATES[underscoredName],
|
||||
deprecatedTemplate = Ember.TEMPLATES[name];
|
||||
var view = options.data.view,
|
||||
underscoredName = nameParts.join("/"),
|
||||
template = view.templateForName(underscoredName),
|
||||
deprecatedTemplate = view.templateForName(name);
|
||||
|
||||
Ember.deprecate("You tried to render the partial " + name + ", which should be at '" + underscoredName + "', but Ember found '" + name + "'. Please use a leading underscore in your partials", template);
|
||||
Ember.assert("Unable to find partial with name '"+name+"'.", template || deprecatedTemplate);
|
||||
@@ -21426,7 +21665,7 @@ helpers = helpers || Ember.Handlebars.helpers; data = data || {};
|
||||
var buffer = '', stack1, hashTypes, escapeExpression=this.escapeExpression, self=this;
|
||||
|
||||
function program1(depth0,data) {
|
||||
|
||||
|
||||
var buffer = '', hashTypes;
|
||||
data.buffer.push("<option value=\"\">");
|
||||
hashTypes = {};
|
||||
@@ -21436,7 +21675,7 @@ function program1(depth0,data) {
|
||||
}
|
||||
|
||||
function program3(depth0,data) {
|
||||
|
||||
|
||||
var hashTypes;
|
||||
hashTypes = {'contentBinding': "STRING"};
|
||||
data.buffer.push(escapeExpression(helpers.view.call(depth0, "Ember.SelectOption", {hash:{
|
||||
@@ -21451,7 +21690,7 @@ function program3(depth0,data) {
|
||||
stack1 = helpers.each.call(depth0, "view.content", {hash:{},inverse:self.noop,fn:self.program(3, program3, data),contexts:[depth0],types:["ID"],hashTypes:hashTypes,data:data});
|
||||
if(stack1 || stack1 === 0) { data.buffer.push(stack1); }
|
||||
return buffer;
|
||||
|
||||
|
||||
}),
|
||||
attributeBindings: ['multiple', 'disabled', 'tabindex', 'name'],
|
||||
|
||||
@@ -23051,7 +23290,7 @@ Ember.controllerFor = function(container, controllerName, context, lookupOptions
|
||||
`App.ObjectController` and `App.ArrayController`
|
||||
*/
|
||||
Ember.generateController = function(container, controllerName, context) {
|
||||
var controller, DefaultController;
|
||||
var controller, DefaultController, fullName;
|
||||
|
||||
if (context && Ember.isArray(context)) {
|
||||
DefaultController = container.resolve('controller:array');
|
||||
@@ -23072,8 +23311,10 @@ Ember.generateController = function(container, controllerName, context) {
|
||||
return "(generated " + controllerName + " controller)";
|
||||
};
|
||||
|
||||
container.register('controller', controllerName, controller);
|
||||
return container.lookup('controller:' + controllerName);
|
||||
|
||||
fullName = 'controller:' + controllerName;
|
||||
container.register(fullName, controller);
|
||||
return container.lookup(fullName);
|
||||
};
|
||||
|
||||
})();
|
||||
@@ -23136,8 +23377,8 @@ Ember.Router = Ember.Object.extend({
|
||||
|
||||
setupRouter(this, router, location);
|
||||
|
||||
container.register('view', 'default', DefaultView);
|
||||
container.register('view', 'toplevel', Ember.View.extend());
|
||||
container.register('view:default', DefaultView);
|
||||
container.register('view:toplevel', Ember.View.extend());
|
||||
|
||||
location.onUpdateURL(function(url) {
|
||||
self.handleURL(url);
|
||||
@@ -23233,7 +23474,9 @@ function getHandlerFunction(router) {
|
||||
DefaultRoute = container.resolve('route:basic');
|
||||
|
||||
return function(name) {
|
||||
var handler = container.lookup('route:' + name);
|
||||
var routeName = 'route:' + name,
|
||||
handler = container.lookup(routeName);
|
||||
|
||||
if (seen[name]) { return handler; }
|
||||
|
||||
seen[name] = true;
|
||||
@@ -23242,8 +23485,8 @@ function getHandlerFunction(router) {
|
||||
if (name === 'loading') { return {}; }
|
||||
if (name === 'failure') { return router.constructor.defaultFailureHandler; }
|
||||
|
||||
container.register('route', name, DefaultRoute.extend());
|
||||
handler = container.lookup('route:' + name);
|
||||
container.register(routeName, DefaultRoute.extend());
|
||||
handler = container.lookup(routeName);
|
||||
}
|
||||
|
||||
handler.routeName = name;
|
||||
@@ -23252,7 +23495,8 @@ function getHandlerFunction(router) {
|
||||
}
|
||||
|
||||
function handlerIsActive(router, handlerName) {
|
||||
var handler = router.container.lookup('route:' + handlerName),
|
||||
var routeName = 'route:' + handlerName,
|
||||
handler = router.container.lookup(routeName),
|
||||
currentHandlerInfos = router.router.currentHandlerInfos,
|
||||
handlerInfo;
|
||||
|
||||
@@ -23962,7 +24206,25 @@ Ember.onLoad('Ember.Handlebars', function(Handlebars) {
|
||||
return ret.concat(resolvedPaths(linkView.parameters));
|
||||
}
|
||||
|
||||
var LinkView = Ember.View.extend({
|
||||
/**
|
||||
Renders a link to the supplied route.
|
||||
|
||||
When the rendered link matches the current route, and the same object instance is passed into the helper,
|
||||
then the link is given class="active" by default.
|
||||
|
||||
You may re-open LinkView in order to change the default active class:
|
||||
|
||||
``` javascript
|
||||
Ember.LinkView.reopen({
|
||||
activeClass: "is-active"
|
||||
})
|
||||
```
|
||||
|
||||
@class LinkView
|
||||
@namespace Ember
|
||||
@extends Ember.View
|
||||
**/
|
||||
var LinkView = Ember.LinkView = Ember.View.extend({
|
||||
tagName: 'a',
|
||||
namedRoute: null,
|
||||
currentWhen: null,
|
||||
@@ -25554,7 +25816,7 @@ var get = Ember.get, set = Ember.set,
|
||||
name: "store",
|
||||
|
||||
initialize: function(container, application) {
|
||||
container.register('store', 'main', application.Store);
|
||||
container.register('store:main', application.Store);
|
||||
}
|
||||
});
|
||||
```
|
||||
@@ -25596,7 +25858,8 @@ var get = Ember.get, set = Ember.set,
|
||||
@namespace Ember
|
||||
@extends Ember.Namespace
|
||||
*/
|
||||
var Application = Ember.Application = Ember.Namespace.extend({
|
||||
|
||||
var Application = Ember.Application = Ember.Namespace.extend(Ember.DeferredMixin, {
|
||||
|
||||
/**
|
||||
The root DOM element of the Application. This can be specified as an
|
||||
@@ -25750,10 +26013,17 @@ var Application = Ember.Application = Ember.Namespace.extend({
|
||||
*/
|
||||
scheduleInitialize: function() {
|
||||
var self = this;
|
||||
this.$().ready(function() {
|
||||
if (self.isDestroyed || self.isInitialized) { return; }
|
||||
|
||||
function initialize(){
|
||||
if (self.isDestroyed) { return; }
|
||||
Ember.run.schedule('actions', self, 'initialize');
|
||||
});
|
||||
}
|
||||
|
||||
if (!this.$ || this.$.isReady) {
|
||||
initialize();
|
||||
} else {
|
||||
this.$().ready(initialize);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -25861,7 +26131,7 @@ var Application = Ember.Application = Ember.Namespace.extend({
|
||||
this.isInitialized = true;
|
||||
|
||||
// At this point, the App.Router must already be assigned
|
||||
this.register('router', 'main', this.Router);
|
||||
this.register('router:main', this.Router);
|
||||
|
||||
this.runInitializers();
|
||||
Ember.runLoadHooks('application', this);
|
||||
@@ -25879,8 +26149,11 @@ var Application = Ember.Application = Ember.Namespace.extend({
|
||||
this.buildContainer();
|
||||
|
||||
this.isInitialized = false;
|
||||
this.initialize();
|
||||
this.startRouting();
|
||||
|
||||
Ember.run.schedule('actions', this, function(){
|
||||
this.initialize();
|
||||
this.startRouting();
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -25920,6 +26193,8 @@ var Application = Ember.Application = Ember.Namespace.extend({
|
||||
Ember.Namespace.processAll();
|
||||
Ember.BOOTED = true;
|
||||
}
|
||||
|
||||
this.resolve(this);
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -26054,7 +26329,7 @@ Ember.Application.reopenClass({
|
||||
container.resolver = resolverFor(namespace);
|
||||
container.optionsForType('view', { singleton: false });
|
||||
container.optionsForType('template', { instantiate: false });
|
||||
container.register('application', 'main', namespace, { instantiate: false });
|
||||
container.register('application:main', namespace, { instantiate: false });
|
||||
|
||||
container.register('controller:basic', Ember.Controller, { instantiate: false });
|
||||
container.register('controller:object', Ember.ObjectController, { instantiate: false });
|
||||
@@ -27468,8 +27743,8 @@ Ember States
|
||||
|
||||
|
||||
})();
|
||||
// Version: v1.0.0-pre.2-892-g1283274
|
||||
// Last commit: 1283274 (2013-03-21 14:18:06 -0700)
|
||||
// Version: v1.0.0-pre.2-924-g9e5ec3b
|
||||
// Last commit: 9e5ec3b (2013-03-26 21:49:38 -0700)
|
||||
|
||||
|
||||
(function() {
|
||||
|
||||
@@ -3518,59 +3518,238 @@ Ember.cacheFor = function cacheFor(obj, key) {
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
@method computed.not
|
||||
@for Ember
|
||||
@param {String} dependentKey
|
||||
@return {Ember.ComputedProperty} computed property which negate the original value for property
|
||||
*/
|
||||
Ember.computed.not = function(dependentKey) {
|
||||
return Ember.computed(dependentKey, function(key) {
|
||||
return !get(this, dependentKey);
|
||||
});
|
||||
};
|
||||
function getProperties(self, propertyNames) {
|
||||
var ret = {};
|
||||
for(var i = 0; i < propertyNames.length; i++) {
|
||||
ret[propertyNames[i]] = get(self, propertyNames[i]);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
@method computed.none
|
||||
@for Ember
|
||||
@param {String} dependentKey
|
||||
*/
|
||||
Ember.computed.none = function(dependentKey) {
|
||||
return Ember.computed(dependentKey, function(key) {
|
||||
var val = get(this, dependentKey);
|
||||
return Ember.isNone(val);
|
||||
});
|
||||
};
|
||||
function registerComputed(name, macro) {
|
||||
Ember.computed[name] = function(dependentKey) {
|
||||
var args = a_slice.call(arguments);
|
||||
return Ember.computed(dependentKey, function() {
|
||||
return macro.apply(this, args);
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
function registerComputedWithProperties(name, macro) {
|
||||
Ember.computed[name] = function() {
|
||||
var properties = a_slice.call(arguments);
|
||||
|
||||
var computed = Ember.computed(function() {
|
||||
return macro.apply(this, [getProperties(this, properties)]);
|
||||
});
|
||||
|
||||
return computed.property.apply(computed, properties);
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
@method computed.empty
|
||||
@for Ember
|
||||
@param {String} dependentKey
|
||||
@return {Ember.ComputedProperty} computed property which negate
|
||||
the original value for property
|
||||
*/
|
||||
Ember.computed.empty = function(dependentKey) {
|
||||
return Ember.computed(dependentKey, function(key) {
|
||||
var val = get(this, dependentKey);
|
||||
return Ember.isEmpty(val);
|
||||
});
|
||||
};
|
||||
registerComputed('empty', function(dependentKey) {
|
||||
return Ember.isEmpty(get(this, dependentKey));
|
||||
});
|
||||
|
||||
/**
|
||||
@method computed.notEmpty
|
||||
@for Ember
|
||||
@param {String} dependentKey
|
||||
@return {Ember.ComputedProperty} computed property which returns true if
|
||||
original value for property is not empty.
|
||||
*/
|
||||
registerComputed('notEmpty', function(dependentKey) {
|
||||
return !Ember.isEmpty(get(this, dependentKey));
|
||||
});
|
||||
|
||||
/**
|
||||
@method computed.none
|
||||
@for Ember
|
||||
@param {String} dependentKey
|
||||
@return {Ember.ComputedProperty} computed property which
|
||||
rturns true if original value for property is null or undefined.
|
||||
*/
|
||||
registerComputed('none', function(dependentKey) {
|
||||
return Ember.isNone(get(this, dependentKey));
|
||||
});
|
||||
|
||||
/**
|
||||
@method computed.not
|
||||
@for Ember
|
||||
@param {String} dependentKey
|
||||
@return {Ember.ComputedProperty} computed property which returns
|
||||
inverse of the original value for property
|
||||
*/
|
||||
registerComputed('not', function(dependentKey) {
|
||||
return !get(this, dependentKey);
|
||||
});
|
||||
|
||||
/**
|
||||
@method computed.bool
|
||||
@for Ember
|
||||
@param {String} dependentKey
|
||||
@return {Ember.ComputedProperty} computed property which convert to boolean the original value for property
|
||||
@return {Ember.ComputedProperty} computed property which convert
|
||||
to boolean the original value for property
|
||||
*/
|
||||
Ember.computed.bool = function(dependentKey) {
|
||||
return Ember.computed(dependentKey, function(key) {
|
||||
return !!get(this, dependentKey);
|
||||
});
|
||||
};
|
||||
registerComputed('bool', function(dependentKey) {
|
||||
return !!get(this, dependentKey);
|
||||
});
|
||||
|
||||
/**
|
||||
@method computed.match
|
||||
@for Ember
|
||||
@param {String} dependentKey
|
||||
@param {RegExp} regexp
|
||||
@return {Ember.ComputedProperty} computed property which match
|
||||
the original value for property against a given RegExp
|
||||
*/
|
||||
registerComputed('match', function(dependentKey, regexp) {
|
||||
var value = get(this, dependentKey);
|
||||
return typeof value === 'string' ? !!value.match(regexp) : false;
|
||||
});
|
||||
|
||||
/**
|
||||
@method computed.equal
|
||||
@for Ember
|
||||
@param {String} dependentKey
|
||||
@param {String|Number|Object} value
|
||||
@return {Ember.ComputedProperty} computed property which returns true if
|
||||
the original value for property is equal to the given value.
|
||||
*/
|
||||
registerComputed('equal', function(dependentKey, value) {
|
||||
return get(this, dependentKey) === value;
|
||||
});
|
||||
|
||||
/**
|
||||
@method computed.gt
|
||||
@for Ember
|
||||
@param {String} dependentKey
|
||||
@param {Number} value
|
||||
@return {Ember.ComputedProperty} computed property which returns true if
|
||||
the original value for property is greater then given value.
|
||||
*/
|
||||
registerComputed('gt', function(dependentKey, value) {
|
||||
return get(this, dependentKey) > value;
|
||||
});
|
||||
|
||||
/**
|
||||
@method computed.gte
|
||||
@for Ember
|
||||
@param {String} dependentKey
|
||||
@param {Number} value
|
||||
@return {Ember.ComputedProperty} computed property which returns true if
|
||||
the original value for property is greater or equal then given value.
|
||||
*/
|
||||
registerComputed('gte', function(dependentKey, value) {
|
||||
return get(this, dependentKey) >= value;
|
||||
});
|
||||
|
||||
/**
|
||||
@method computed.lt
|
||||
@for Ember
|
||||
@param {String} dependentKey
|
||||
@param {Number} value
|
||||
@return {Ember.ComputedProperty} computed property which returns true if
|
||||
the original value for property is less then given value.
|
||||
*/
|
||||
registerComputed('lt', function(dependentKey, value) {
|
||||
return get(this, dependentKey) < value;
|
||||
});
|
||||
|
||||
/**
|
||||
@method computed.lte
|
||||
@for Ember
|
||||
@param {String} dependentKey
|
||||
@param {Number} value
|
||||
@return {Ember.ComputedProperty} computed property which returns true if
|
||||
the original value for property is less or equal then given value.
|
||||
*/
|
||||
registerComputed('lte', function(dependentKey, value) {
|
||||
return get(this, dependentKey) <= value;
|
||||
});
|
||||
|
||||
/**
|
||||
@method computed.and
|
||||
@for Ember
|
||||
@param {String} dependentKey, [dependentKey...]
|
||||
@return {Ember.ComputedProperty} computed property which peforms
|
||||
a logical `and` on the values of all the original values for properties.
|
||||
*/
|
||||
registerComputedWithProperties('and', function(properties) {
|
||||
for (var key in properties) {
|
||||
if (properties.hasOwnProperty(key) && !properties[key]) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
});
|
||||
|
||||
/**
|
||||
@method computed.or
|
||||
@for Ember
|
||||
@param {String} dependentKey, [dependentKey...]
|
||||
@return {Ember.ComputedProperty} computed property which peforms
|
||||
a logical `or` on the values of all the original values for properties.
|
||||
*/
|
||||
registerComputedWithProperties('or', function(properties) {
|
||||
for (var key in properties) {
|
||||
if (properties.hasOwnProperty(key) && properties[key]) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
});
|
||||
|
||||
/**
|
||||
@method computed.any
|
||||
@for Ember
|
||||
@param {String} dependentKey, [dependentKey...]
|
||||
@return {Ember.ComputedProperty} computed property which returns
|
||||
the first trouthy value of given list of properties.
|
||||
*/
|
||||
registerComputedWithProperties('any', function(properties) {
|
||||
for (var key in properties) {
|
||||
if (properties.hasOwnProperty(key) && properties[key]) {
|
||||
return properties[key];
|
||||
}
|
||||
}
|
||||
return null;
|
||||
});
|
||||
|
||||
/**
|
||||
@method computed.map
|
||||
@for Ember
|
||||
@param {String} dependentKey, [dependentKey...]
|
||||
@return {Ember.ComputedProperty} computed property which maps
|
||||
values of all passed properties in to an array.
|
||||
*/
|
||||
registerComputedWithProperties('map', function(properties) {
|
||||
var res = [];
|
||||
for (var key in properties) {
|
||||
if (properties.hasOwnProperty(key)) {
|
||||
if (Ember.isNone(properties[key])) {
|
||||
res.push(null);
|
||||
} else {
|
||||
res.push(properties[key]);
|
||||
}
|
||||
}
|
||||
}
|
||||
return res;
|
||||
});
|
||||
|
||||
/**
|
||||
@method computed.alias
|
||||
@for Ember
|
||||
|
||||
@param {String} dependentKey
|
||||
@return {Ember.ComputedProperty} computed property which creates an
|
||||
alias to the original value for property.
|
||||
*/
|
||||
Ember.computed.alias = function(dependentKey) {
|
||||
return Ember.computed(dependentKey, function(key, value){
|
||||
@@ -3583,6 +3762,23 @@ Ember.computed.alias = function(dependentKey) {
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
@method computed.defaultTo
|
||||
@for Ember
|
||||
@param {String} defaultPath
|
||||
@return {Ember.ComputedProperty} computed property which acts like
|
||||
a standard getter and setter, but defaults to the value from `defaultPath`.
|
||||
*/
|
||||
Ember.computed.defaultTo = function(defaultPath) {
|
||||
return Ember.computed(function(key, newValue, cachedValue) {
|
||||
var result;
|
||||
if (arguments.length === 1) {
|
||||
return cachedValue != null ? cachedValue : get(this, defaultPath);
|
||||
}
|
||||
return newValue != null ? newValue : get(this, defaultPath);
|
||||
});
|
||||
};
|
||||
|
||||
})();
|
||||
|
||||
|
||||
@@ -4415,8 +4611,7 @@ function invokeLaterTimers() {
|
||||
If you pass a string it will be resolved on the
|
||||
target at the time the method is invoked.
|
||||
@param {Object} [args*] Optional arguments to pass to the timeout.
|
||||
@param {Number} wait
|
||||
Number of milliseconds to wait.
|
||||
@param {Number} wait Number of milliseconds to wait.
|
||||
@return {String} a string you can use to cancel the timer in
|
||||
{{#crossLink "Ember/run.cancel"}}{{/crossLink}} later.
|
||||
*/
|
||||
@@ -4538,15 +4733,54 @@ Ember.run.scheduleOnce = function(queue, target, method, args) {
|
||||
};
|
||||
|
||||
/**
|
||||
Schedules an item to run after control has been returned to the system.
|
||||
This is equivalent to calling `Ember.run.later` with a wait time of 1ms.
|
||||
Schedules an item to run from within a separate run loop, after
|
||||
control has been returned to the system. This is equivalent to calling
|
||||
`Ember.run.later` with a wait time of 1ms.
|
||||
|
||||
```javascript
|
||||
Ember.run.next(myContext, function(){
|
||||
// code to be executed in the next RunLoop, which will be scheduled after the current one
|
||||
// code to be executed in the next run loop, which will be scheduled after the current one
|
||||
});
|
||||
```
|
||||
|
||||
Multiple operations scheduled with `Ember.run.next` will coalesce
|
||||
into the same later run loop, along with any other operations
|
||||
scheduled by `Ember.run.later` that expire right around the same
|
||||
time that `Ember.run.next` operations will fire.
|
||||
|
||||
Note that there are often alternatives to using `Ember.run.next`.
|
||||
For instance, if you'd like to schedule an operation to happen
|
||||
after all DOM element operations have completed within the current
|
||||
run loop, you can make use of the `afterRender` run loop queue (added
|
||||
by the `ember-views` package, along with the preceding `render` queue
|
||||
where all the DOM element operations happen). Example:
|
||||
|
||||
```javascript
|
||||
App.MyCollectionView = Ember.CollectionView.extend({
|
||||
didInsertElement: function() {
|
||||
Ember.run.scheduleOnce('afterRender', this, 'processChildElements');
|
||||
},
|
||||
processChildElements: function() {
|
||||
// ... do something with collectionView's child view
|
||||
// elements after they've finished rendering, which
|
||||
// can't be done within the CollectionView's
|
||||
// `didInsertElement` hook because that gets run
|
||||
// before the child elements have been added to the DOM.
|
||||
}
|
||||
});
|
||||
```
|
||||
|
||||
One benefit of the above approach compared to using `Ember.run.next` is
|
||||
that you will be able to perform DOM/CSS operations before unprocessed
|
||||
elements are rendered to the screen, which may prevent flickering or
|
||||
other artifacts caused by delaying processing until after rendering.
|
||||
|
||||
The other major benefit to the above approach is that `Ember.run.next`
|
||||
introduces an element of non-determinism, which can make things much
|
||||
harder to test, due to its reliance on `setTimeout`; it's much harder
|
||||
to guarantee the order of scheduled operations when they are scheduled
|
||||
outside of the current run loop, i.e. with `Ember.run.next`.
|
||||
|
||||
@method next
|
||||
@param {Object} [target] target of method to invoke
|
||||
@param {Function|String} method The method to invoke.
|
||||
@@ -12800,9 +13034,11 @@ var setInnerHTML = function(element, html) {
|
||||
if (canSetInnerHTML(tagName)) {
|
||||
setInnerHTMLWithoutFix(element, html);
|
||||
} else {
|
||||
// Firefox versions < 11 do not have support for element.outerHTML.
|
||||
var outerHTML = element.outerHTML || new XMLSerializer().serializeToString(element);
|
||||
|
||||
|
||||
var startTag = element.outerHTML.match(new RegExp("<"+tagName+"([^>]*)>", 'i'))[0],
|
||||
var startTag = outerHTML.match(new RegExp("<"+tagName+"([^>]*)>", 'i'))[0],
|
||||
endTag = '</'+tagName+'>';
|
||||
|
||||
var wrapper = document.createElement('div');
|
||||
@@ -13285,7 +13521,9 @@ Ember._RenderBuffer.prototype =
|
||||
*/
|
||||
string: function() {
|
||||
if (this._element) {
|
||||
return this.element().outerHTML;
|
||||
// Firefox versions < 11 do not have support for element.outerHTML.
|
||||
return this.element().outerHTML ||
|
||||
new XMLSerializer().serializeToString(this.element());
|
||||
} else {
|
||||
return this.innerString();
|
||||
}
|
||||
@@ -15150,9 +15388,9 @@ Ember.View = Ember.CoreView.extend(
|
||||
willInsertElement: Ember.K,
|
||||
|
||||
/**
|
||||
Called when the element of the view has been inserted into the DOM.
|
||||
Override this function to do any set up that requires an element in the
|
||||
document body.
|
||||
Called when the element of the view has been inserted into the DOM
|
||||
or after the view was re-rendered. Override this function to do any
|
||||
set up that requires an element in the document body.
|
||||
|
||||
@event didInsertElement
|
||||
*/
|
||||
@@ -20345,10 +20583,11 @@ Ember.Handlebars.registerHelper('each', function(path, options) {
|
||||
*/
|
||||
|
||||
Ember.Handlebars.registerHelper('template', function(name, options) {
|
||||
var template = Ember.TEMPLATES[name];
|
||||
var view = options.data.view,
|
||||
template = view.templateForName(name);
|
||||
|
||||
|
||||
Ember.TEMPLATES[name](this, { data: options.data });
|
||||
template(this, { data: options.data });
|
||||
});
|
||||
|
||||
})();
|
||||
@@ -20363,7 +20602,7 @@ Ember.Handlebars.registerHelper('template', function(name, options) {
|
||||
|
||||
/**
|
||||
`partial` renders a template directly using the current context.
|
||||
If needed the context can be set using the `{{#with foo}}` helper.
|
||||
If needed the context can be set using the `{{#with foo}}` helper.
|
||||
|
||||
```html
|
||||
<script type="text/x-handlebars" data-template-name="header_bar">
|
||||
@@ -20392,10 +20631,10 @@ Ember.Handlebars.registerHelper('partial', function(name, options) {
|
||||
|
||||
nameParts[nameParts.length - 1] = "_" + lastPart;
|
||||
|
||||
var underscoredName = nameParts.join("/");
|
||||
|
||||
var template = Ember.TEMPLATES[underscoredName],
|
||||
deprecatedTemplate = Ember.TEMPLATES[name];
|
||||
var view = options.data.view,
|
||||
underscoredName = nameParts.join("/"),
|
||||
template = view.templateForName(underscoredName),
|
||||
deprecatedTemplate = view.templateForName(name);
|
||||
|
||||
|
||||
|
||||
@@ -22862,7 +23101,7 @@ Ember.controllerFor = function(container, controllerName, context, lookupOptions
|
||||
`App.ObjectController` and `App.ArrayController`
|
||||
*/
|
||||
Ember.generateController = function(container, controllerName, context) {
|
||||
var controller, DefaultController;
|
||||
var controller, DefaultController, fullName;
|
||||
|
||||
if (context && Ember.isArray(context)) {
|
||||
DefaultController = container.resolve('controller:array');
|
||||
@@ -22883,8 +23122,10 @@ Ember.generateController = function(container, controllerName, context) {
|
||||
return "(generated " + controllerName + " controller)";
|
||||
};
|
||||
|
||||
container.register('controller', controllerName, controller);
|
||||
return container.lookup('controller:' + controllerName);
|
||||
|
||||
fullName = 'controller:' + controllerName;
|
||||
container.register(fullName, controller);
|
||||
return container.lookup(fullName);
|
||||
};
|
||||
|
||||
})();
|
||||
@@ -22947,8 +23188,8 @@ Ember.Router = Ember.Object.extend({
|
||||
|
||||
setupRouter(this, router, location);
|
||||
|
||||
container.register('view', 'default', DefaultView);
|
||||
container.register('view', 'toplevel', Ember.View.extend());
|
||||
container.register('view:default', DefaultView);
|
||||
container.register('view:toplevel', Ember.View.extend());
|
||||
|
||||
location.onUpdateURL(function(url) {
|
||||
self.handleURL(url);
|
||||
@@ -23044,7 +23285,9 @@ function getHandlerFunction(router) {
|
||||
DefaultRoute = container.resolve('route:basic');
|
||||
|
||||
return function(name) {
|
||||
var handler = container.lookup('route:' + name);
|
||||
var routeName = 'route:' + name,
|
||||
handler = container.lookup(routeName);
|
||||
|
||||
if (seen[name]) { return handler; }
|
||||
|
||||
seen[name] = true;
|
||||
@@ -23053,8 +23296,8 @@ function getHandlerFunction(router) {
|
||||
if (name === 'loading') { return {}; }
|
||||
if (name === 'failure') { return router.constructor.defaultFailureHandler; }
|
||||
|
||||
container.register('route', name, DefaultRoute.extend());
|
||||
handler = container.lookup('route:' + name);
|
||||
container.register(routeName, DefaultRoute.extend());
|
||||
handler = container.lookup(routeName);
|
||||
}
|
||||
|
||||
handler.routeName = name;
|
||||
@@ -23063,7 +23306,8 @@ function getHandlerFunction(router) {
|
||||
}
|
||||
|
||||
function handlerIsActive(router, handlerName) {
|
||||
var handler = router.container.lookup('route:' + handlerName),
|
||||
var routeName = 'route:' + handlerName,
|
||||
handler = router.container.lookup(routeName),
|
||||
currentHandlerInfos = router.router.currentHandlerInfos,
|
||||
handlerInfo;
|
||||
|
||||
@@ -23767,7 +24011,25 @@ Ember.onLoad('Ember.Handlebars', function(Handlebars) {
|
||||
return ret.concat(resolvedPaths(linkView.parameters));
|
||||
}
|
||||
|
||||
var LinkView = Ember.View.extend({
|
||||
/**
|
||||
Renders a link to the supplied route.
|
||||
|
||||
When the rendered link matches the current route, and the same object instance is passed into the helper,
|
||||
then the link is given class="active" by default.
|
||||
|
||||
You may re-open LinkView in order to change the default active class:
|
||||
|
||||
``` javascript
|
||||
Ember.LinkView.reopen({
|
||||
activeClass: "is-active"
|
||||
})
|
||||
```
|
||||
|
||||
@class LinkView
|
||||
@namespace Ember
|
||||
@extends Ember.View
|
||||
**/
|
||||
var LinkView = Ember.LinkView = Ember.View.extend({
|
||||
tagName: 'a',
|
||||
namedRoute: null,
|
||||
currentWhen: null,
|
||||
@@ -25356,7 +25618,7 @@ var get = Ember.get, set = Ember.set,
|
||||
name: "store",
|
||||
|
||||
initialize: function(container, application) {
|
||||
container.register('store', 'main', application.Store);
|
||||
container.register('store:main', application.Store);
|
||||
}
|
||||
});
|
||||
```
|
||||
@@ -25398,7 +25660,8 @@ var get = Ember.get, set = Ember.set,
|
||||
@namespace Ember
|
||||
@extends Ember.Namespace
|
||||
*/
|
||||
var Application = Ember.Application = Ember.Namespace.extend({
|
||||
|
||||
var Application = Ember.Application = Ember.Namespace.extend(Ember.DeferredMixin, {
|
||||
|
||||
/**
|
||||
The root DOM element of the Application. This can be specified as an
|
||||
@@ -25552,10 +25815,17 @@ var Application = Ember.Application = Ember.Namespace.extend({
|
||||
*/
|
||||
scheduleInitialize: function() {
|
||||
var self = this;
|
||||
this.$().ready(function() {
|
||||
if (self.isDestroyed || self.isInitialized) { return; }
|
||||
|
||||
function initialize(){
|
||||
if (self.isDestroyed) { return; }
|
||||
Ember.run.schedule('actions', self, 'initialize');
|
||||
});
|
||||
}
|
||||
|
||||
if (!this.$ || this.$.isReady) {
|
||||
initialize();
|
||||
} else {
|
||||
this.$().ready(initialize);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -25663,7 +25933,7 @@ var Application = Ember.Application = Ember.Namespace.extend({
|
||||
this.isInitialized = true;
|
||||
|
||||
// At this point, the App.Router must already be assigned
|
||||
this.register('router', 'main', this.Router);
|
||||
this.register('router:main', this.Router);
|
||||
|
||||
this.runInitializers();
|
||||
Ember.runLoadHooks('application', this);
|
||||
@@ -25681,8 +25951,11 @@ var Application = Ember.Application = Ember.Namespace.extend({
|
||||
this.buildContainer();
|
||||
|
||||
this.isInitialized = false;
|
||||
this.initialize();
|
||||
this.startRouting();
|
||||
|
||||
Ember.run.schedule('actions', this, function(){
|
||||
this.initialize();
|
||||
this.startRouting();
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -25722,6 +25995,8 @@ var Application = Ember.Application = Ember.Namespace.extend({
|
||||
Ember.Namespace.processAll();
|
||||
Ember.BOOTED = true;
|
||||
}
|
||||
|
||||
this.resolve(this);
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -25855,7 +26130,7 @@ Ember.Application.reopenClass({
|
||||
container.resolver = resolverFor(namespace);
|
||||
container.optionsForType('view', { singleton: false });
|
||||
container.optionsForType('template', { instantiate: false });
|
||||
container.register('application', 'main', namespace, { instantiate: false });
|
||||
container.register('application:main', namespace, { instantiate: false });
|
||||
|
||||
container.register('controller:basic', Ember.Controller, { instantiate: false });
|
||||
container.register('controller:object', Ember.ObjectController, { instantiate: false });
|
||||
|
||||
Reference in New Issue
Block a user