Created
April 24, 2015 04:35
-
-
Save tricknotes/206412c5bbac52bc8890 to your computer and use it in GitHub Desktop.
diff -u gem.js web.js
This file has been truncated, but you can view the full file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- gem.js 2015-04-24 11:35:45.000000000 +0900 | |
+++ web.js 2015-04-24 11:36:43.000000000 +0900 | |
@@ -1107,7 +1107,7 @@ | |
*/ | |
Ember.MODEL_FACTORY_INJECTIONS = false; | |
- if (Ember.ENV && typeof Ember.ENV.MODEL_FACTORY_INJECTIONS !== "undefined") { | |
+ if (Ember.ENV && typeof Ember.ENV.MODEL_FACTORY_INJECTIONS !== 'undefined') { | |
Ember.MODEL_FACTORY_INJECTIONS = !!Ember.ENV.MODEL_FACTORY_INJECTIONS; | |
} | |
@@ -1135,18 +1135,20 @@ | |
@class Container | |
*/ | |
function Container(registry, options) { | |
- this._registry = registry || (function () { | |
- Ember['default'].deprecate("A container should only be created for an already instantiated " + "registry. For backward compatibility, an isolated registry will " + "be instantiated just for this container."); | |
+ this._registry = registry || (function() { | |
+ Ember['default'].deprecate( | |
+ "A container should only be created for an already instantiated " + | |
+ "registry. For backward compatibility, an isolated registry will " + | |
+ "be instantiated just for this container." | |
+ ); | |
// TODO - See note above about transpiler import workaround. | |
- if (!Registry) { | |
- Registry = requireModule("container/registry")["default"]; | |
- } | |
+ if (!Registry) { Registry = requireModule('container/registry')['default']; } | |
return new Registry(); | |
- })(); | |
+ }()); | |
- this.cache = dictionary['default'](options && options.cache ? options.cache : null); | |
+ this.cache = dictionary['default'](options && options.cache ? options.cache : null); | |
this.factoryCache = dictionary['default'](options && options.factoryCache ? options.factoryCache : null); | |
this.validationCache = dictionary['default'](options && options.validationCache ? options.validationCache : null); | |
} | |
@@ -1154,7 +1156,8 @@ | |
Container.prototype = { | |
/** | |
@private | |
- @property _registry | |
+ | |
+ @property _registry | |
@type Registry | |
@since 1.11.0 | |
*/ | |
@@ -1180,57 +1183,72 @@ | |
/** | |
Given a fullName return a corresponding instance. | |
- The default behaviour is for lookup to return a singleton instance. | |
+ | |
+ The default behaviour is for lookup to return a singleton instance. | |
The singleton is scoped to the container, allowing multiple containers | |
to all have their own locally scoped singletons. | |
- ```javascript | |
+ | |
+ ```javascript | |
var registry = new Registry(); | |
var container = registry.container(); | |
- registry.register('api:twitter', Twitter); | |
- var twitter = container.lookup('api:twitter'); | |
- twitter instanceof Twitter; // => true | |
- // by default the container will return singletons | |
+ | |
+ registry.register('api:twitter', Twitter); | |
+ | |
+ var twitter = container.lookup('api:twitter'); | |
+ | |
+ twitter instanceof Twitter; // => true | |
+ | |
+ // by default the container will return singletons | |
var twitter2 = container.lookup('api:twitter'); | |
twitter2 instanceof Twitter; // => true | |
- twitter === twitter2; //=> true | |
+ | |
+ twitter === twitter2; //=> true | |
``` | |
- If singletons are not wanted an optional flag can be provided at lookup. | |
- ```javascript | |
+ | |
+ If singletons are not wanted an optional flag can be provided at lookup. | |
+ | |
+ ```javascript | |
var registry = new Registry(); | |
var container = registry.container(); | |
- registry.register('api:twitter', Twitter); | |
- var twitter = container.lookup('api:twitter', { singleton: false }); | |
+ | |
+ registry.register('api:twitter', Twitter); | |
+ | |
+ var twitter = container.lookup('api:twitter', { singleton: false }); | |
var twitter2 = container.lookup('api:twitter', { singleton: false }); | |
- twitter === twitter2; //=> false | |
+ | |
+ twitter === twitter2; //=> false | |
``` | |
- @method lookup | |
+ | |
+ @method lookup | |
@param {String} fullName | |
@param {Object} options | |
@return {any} | |
*/ | |
- lookup: function (fullName, options) { | |
- Ember['default'].assert("fullName must be a proper full name", this._registry.validateFullName(fullName)); | |
+ lookup: function(fullName, options) { | |
+ Ember['default'].assert('fullName must be a proper full name', this._registry.validateFullName(fullName)); | |
return lookup(this, this._registry.normalize(fullName), options); | |
}, | |
/** | |
Given a fullName return the corresponding factory. | |
- @method lookupFactory | |
+ | |
+ @method lookupFactory | |
@param {String} fullName | |
@return {any} | |
*/ | |
- lookupFactory: function (fullName) { | |
- Ember['default'].assert("fullName must be a proper full name", this._registry.validateFullName(fullName)); | |
+ lookupFactory: function(fullName) { | |
+ Ember['default'].assert('fullName must be a proper full name', this._registry.validateFullName(fullName)); | |
return factoryFor(this, this._registry.normalize(fullName)); | |
}, | |
/** | |
A depth first traversal, destroying the container, its descendant containers and all | |
their managed objects. | |
- @method destroy | |
+ | |
+ @method destroy | |
*/ | |
- destroy: function () { | |
- eachDestroyable(this, function (item) { | |
+ destroy: function() { | |
+ eachDestroyable(this, function(item) { | |
if (item.destroy) { | |
item.destroy(); | |
} | |
@@ -1241,10 +1259,11 @@ | |
/** | |
Clear either the entire cache or just the cache for a particular key. | |
- @method reset | |
+ | |
+ @method reset | |
@param {String} fullName optional key to reset; if missing, resets everything | |
*/ | |
- reset: function (fullName) { | |
+ reset: function(fullName) { | |
if (arguments.length > 0) { | |
resetMember(this, this._registry.normalize(fullName)); | |
} else { | |
@@ -1254,11 +1273,23 @@ | |
}; | |
(function exposeRegistryMethods() { | |
- var methods = ["register", "unregister", "resolve", "normalize", "typeInjection", "injection", "factoryInjection", "factoryTypeInjection", "has", "options", "optionsForType"]; | |
+ var methods = [ | |
+ 'register', | |
+ 'unregister', | |
+ 'resolve', | |
+ 'normalize', | |
+ 'typeInjection', | |
+ 'injection', | |
+ 'factoryInjection', | |
+ 'factoryTypeInjection', | |
+ 'has', | |
+ 'options', | |
+ 'optionsForType' | |
+ ]; | |
function exposeRegistryMethod(method) { | |
- Container.prototype[method] = function () { | |
- Ember['default'].deprecate(method + " should be called on the registry instead of the container"); | |
+ Container.prototype[method] = function() { | |
+ Ember['default'].deprecate(method + ' should be called on the registry instead of the container'); | |
return this._registry[method].apply(this._registry, arguments); | |
}; | |
} | |
@@ -1277,11 +1308,9 @@ | |
var value = instantiate(container, fullName); | |
- if (value === undefined) { | |
- return; | |
- } | |
+ if (value === undefined) { return; } | |
- if (container._registry.getOption(fullName, "singleton") !== false && options.singleton !== false) { | |
+ if (container._registry.getOption(fullName, 'singleton') !== false && options.singleton !== false) { | |
container.cache[fullName] = value; | |
} | |
@@ -1320,13 +1349,11 @@ | |
} | |
var registry = container._registry; | |
var factory = registry.resolve(fullName); | |
- if (factory === undefined) { | |
- return; | |
- } | |
+ if (factory === undefined) { return; } | |
- var type = fullName.split(":")[0]; | |
- if (!factory || typeof factory.extend !== "function" || !Ember['default'].MODEL_FACTORY_INJECTIONS && type === "model") { | |
- if (factory && typeof factory._onLookup === "function") { | |
+ var type = fullName.split(':')[0]; | |
+ if (!factory || typeof factory.extend !== 'function' || (!Ember['default'].MODEL_FACTORY_INJECTIONS && type === 'model')) { | |
+ if (factory && typeof factory._onLookup === 'function') { | |
factory._onLookup(fullName); | |
} | |
@@ -1334,6 +1361,7 @@ | |
// for now just fallback to create time injection | |
cache[fullName] = factory; | |
return factory; | |
+ | |
} else { | |
var injections = injectionsFor(container, fullName); | |
var factoryInjections = factoryInjectionsFor(container, fullName); | |
@@ -1343,7 +1371,7 @@ | |
var injectedFactory = factory.extend(injections); | |
injectedFactory.reopenClass(factoryInjections); | |
- if (factory && typeof factory._onLookup === "function") { | |
+ if (factory && typeof factory._onLookup === 'function') { | |
factory._onLookup(fullName); | |
} | |
@@ -1355,10 +1383,12 @@ | |
function injectionsFor(container, fullName) { | |
var registry = container._registry; | |
- var splitName = fullName.split(":"); | |
+ var splitName = fullName.split(':'); | |
var type = splitName[0]; | |
- var injections = buildInjections(container, registry.getTypeInjections(type), registry.getInjections(fullName)); | |
+ var injections = buildInjections(container, | |
+ registry.getTypeInjections(type), | |
+ registry.getInjections(fullName)); | |
injections._debugContainerKey = fullName; | |
injections.container = container; | |
@@ -1367,10 +1397,12 @@ | |
function factoryInjectionsFor(container, fullName) { | |
var registry = container._registry; | |
- var splitName = fullName.split(":"); | |
+ var splitName = fullName.split(':'); | |
var type = splitName[0]; | |
- var factoryInjections = buildInjections(container, registry.getFactoryTypeInjections(type), registry.getFactoryInjections(fullName)); | |
+ var factoryInjections = buildInjections(container, | |
+ registry.getFactoryTypeInjections(type), | |
+ registry.getFactoryInjections(fullName)); | |
factoryInjections._debugContainerKey = fullName; | |
return factoryInjections; | |
@@ -1380,19 +1412,20 @@ | |
var factory = factoryFor(container, fullName); | |
var lazyInjections, validationCache; | |
- if (container._registry.getOption(fullName, "instantiate") === false) { | |
+ if (container._registry.getOption(fullName, 'instantiate') === false) { | |
return factory; | |
} | |
if (factory) { | |
- if (typeof factory.create !== "function") { | |
- throw new Error("Failed to create an instance of '" + fullName + "'. " + "Most likely an improperly defined class or an invalid module export."); | |
+ if (typeof factory.create !== 'function') { | |
+ throw new Error('Failed to create an instance of \'' + fullName + '\'. ' + | |
+ 'Most likely an improperly defined class or an invalid module export.'); | |
} | |
validationCache = container.validationCache; | |
// Ensure that all lazy injections are valid at instantiation time | |
- if (!validationCache[fullName] && typeof factory._lazyInjections === "function") { | |
+ if (!validationCache[fullName] && typeof factory._lazyInjections === 'function') { | |
lazyInjections = factory._lazyInjections(); | |
lazyInjections = container._registry.normalizeInjectionsHash(lazyInjections); | |
@@ -1401,7 +1434,7 @@ | |
validationCache[fullName] = true; | |
- if (typeof factory.extend === "function") { | |
+ if (typeof factory.extend === 'function') { | |
// assume the factory was extendable and is already injected | |
return factory.create(); | |
} else { | |
@@ -1422,14 +1455,14 @@ | |
key = keys[i]; | |
value = cache[key]; | |
- if (container._registry.getOption(key, "instantiate") !== false) { | |
+ if (container._registry.getOption(key, 'instantiate') !== false) { | |
callback(value); | |
} | |
} | |
} | |
function resetCache(container) { | |
- eachDestroyable(container, function (value) { | |
+ eachDestroyable(container, function(value) { | |
if (value.destroy) { | |
value.destroy(); | |
} | |
@@ -1480,26 +1513,27 @@ | |
function Registry(options) { | |
this.fallback = options && options.fallback ? options.fallback : null; | |
- this.resolver = options && options.resolver ? options.resolver : function () {}; | |
+ this.resolver = options && options.resolver ? options.resolver : function() {}; | |
- this.registrations = dictionary['default'](options && options.registrations ? options.registrations : null); | |
+ this.registrations = dictionary['default'](options && options.registrations ? options.registrations : null); | |
- this._typeInjections = dictionary['default'](null); | |
- this._injections = dictionary['default'](null); | |
+ this._typeInjections = dictionary['default'](null); | |
+ this._injections = dictionary['default'](null); | |
this._factoryTypeInjections = dictionary['default'](null); | |
- this._factoryInjections = dictionary['default'](null); | |
+ this._factoryInjections = dictionary['default'](null); | |
- this._normalizeCache = dictionary['default'](null); | |
- this._resolveCache = dictionary['default'](null); | |
+ this._normalizeCache = dictionary['default'](null); | |
+ this._resolveCache = dictionary['default'](null); | |
- this._options = dictionary['default'](null); | |
- this._typeOptions = dictionary['default'](null); | |
+ this._options = dictionary['default'](null); | |
+ this._typeOptions = dictionary['default'](null); | |
} | |
Registry.prototype = { | |
/** | |
A backup registry for resolving registrations when no matches can be found. | |
- @property fallback | |
+ | |
+ @property fallback | |
@type Registry | |
*/ | |
fallback: null, | |
@@ -1518,65 +1552,75 @@ | |
/** | |
@private | |
- @property _typeInjections | |
+ | |
+ @property _typeInjections | |
@type InheritingDict | |
*/ | |
_typeInjections: null, | |
/** | |
@private | |
- @property _injections | |
+ | |
+ @property _injections | |
@type InheritingDict | |
*/ | |
_injections: null, | |
/** | |
@private | |
- @property _factoryTypeInjections | |
+ | |
+ @property _factoryTypeInjections | |
@type InheritingDict | |
*/ | |
_factoryTypeInjections: null, | |
/** | |
@private | |
- @property _factoryInjections | |
+ | |
+ @property _factoryInjections | |
@type InheritingDict | |
*/ | |
_factoryInjections: null, | |
/** | |
@private | |
- @property _normalizeCache | |
+ | |
+ @property _normalizeCache | |
@type InheritingDict | |
*/ | |
_normalizeCache: null, | |
/** | |
@private | |
- @property _resolveCache | |
+ | |
+ @property _resolveCache | |
@type InheritingDict | |
*/ | |
_resolveCache: null, | |
/** | |
@private | |
- @property _options | |
+ | |
+ @property _options | |
@type InheritingDict | |
*/ | |
_options: null, | |
/** | |
@private | |
- @property _typeOptions | |
+ | |
+ @property _typeOptions | |
@type InheritingDict | |
*/ | |
_typeOptions: null, | |
/** | |
The first container created for this registry. | |
- This allows deprecated access to `lookup` and `lookupFactory` to avoid | |
+ | |
+ This allows deprecated access to `lookup` and `lookupFactory` to avoid | |
breaking compatibility for Ember 1.x initializers. | |
- @private | |
+ | |
+ @private | |
@property _defaultContainer | |
@type Container | |
*/ | |
@@ -1584,11 +1628,12 @@ | |
/** | |
Creates a container based on this registry. | |
- @method container | |
+ | |
+ @method container | |
@param {Object} options | |
@return {Container} created container | |
*/ | |
- container: function (options) { | |
+ container: function(options) { | |
var container = new Container['default'](this, options); | |
// 2.0TODO - remove `registerContainer` | |
@@ -1601,11 +1646,13 @@ | |
Register the first container created for a registery to allow deprecated | |
access to its `lookup` and `lookupFactory` methods to avoid breaking | |
compatibility for Ember 1.x initializers. | |
- 2.0TODO: Remove this method. The bookkeeping is only needed to support | |
+ | |
+ 2.0TODO: Remove this method. The bookkeeping is only needed to support | |
deprecated behavior. | |
- @param {Container} newly created container | |
+ | |
+ @param {Container} newly created container | |
*/ | |
- registerContainer: function (container) { | |
+ registerContainer: function(container) { | |
if (!this._defaultContainer) { | |
this._defaultContainer = container; | |
} | |
@@ -1614,21 +1661,29 @@ | |
} | |
}, | |
- lookup: function (fullName, options) { | |
- Ember['default'].assert("Create a container on the registry (with `registry.container()`) before calling `lookup`.", this._defaultContainer); | |
+ lookup: function(fullName, options) { | |
+ Ember['default'].assert('Create a container on the registry (with `registry.container()`) before calling `lookup`.', this._defaultContainer); | |
if (instanceInitializersFeatureEnabled) { | |
- Ember['default'].deprecate("`lookup` was called on a Registry. The `initializer` API no longer receives a container, and you should use an `instanceInitializer` to look up objects from the container.", false, { url: "http://emberjs.com/guides/deprecations#toc_access-to-instances-in-initializers" }); | |
+ Ember['default'].deprecate( | |
+ '`lookup` was called on a Registry. The `initializer` API no longer receives a container, and you should use an `instanceInitializer` to look up objects from the container.', | |
+ false, | |
+ { url: "http://emberjs.com/guides/deprecations#toc_access-to-instances-in-initializers" } | |
+ ); | |
} | |
return this._defaultContainer.lookup(fullName, options); | |
}, | |
- lookupFactory: function (fullName) { | |
- Ember['default'].assert("Create a container on the registry (with `registry.container()`) before calling `lookupFactory`.", this._defaultContainer); | |
+ lookupFactory: function(fullName) { | |
+ Ember['default'].assert('Create a container on the registry (with `registry.container()`) before calling `lookupFactory`.', this._defaultContainer); | |
if (instanceInitializersFeatureEnabled) { | |
- Ember['default'].deprecate("`lookupFactory` was called on a Registry. The `initializer` API no longer receives a container, and you should use an `instanceInitializer` to look up objects from the container.", false, { url: "http://emberjs.com/guides/deprecations#toc_access-to-instances-in-initializers" }); | |
+ Ember['default'].deprecate( | |
+ '`lookupFactory` was called on a Registry. The `initializer` API no longer receives a container, and you should use an `instanceInitializer` to look up objects from the container.', | |
+ false, | |
+ { url: "http://emberjs.com/guides/deprecations#toc_access-to-instances-in-initializers" } | |
+ ); | |
} | |
return this._defaultContainer.lookupFactory(fullName); | |
@@ -1636,49 +1691,57 @@ | |
/** | |
Registers a factory for later injection. | |
- Example: | |
- ```javascript | |
+ | |
+ Example: | |
+ | |
+ ```javascript | |
var registry = new Registry(); | |
- registry.register('model:user', Person, {singleton: false }); | |
+ | |
+ registry.register('model:user', Person, {singleton: false }); | |
registry.register('fruit:favorite', Orange); | |
registry.register('communication:main', Email, {singleton: false}); | |
``` | |
- @method register | |
+ | |
+ @method register | |
@param {String} fullName | |
@param {Function} factory | |
@param {Object} options | |
*/ | |
- register: function (fullName, factory, options) { | |
- Ember['default'].assert("fullName must be a proper full name", this.validateFullName(fullName)); | |
+ register: function(fullName, factory, options) { | |
+ Ember['default'].assert('fullName must be a proper full name', this.validateFullName(fullName)); | |
if (factory === undefined) { | |
- throw new TypeError("Attempting to register an unknown factory: `" + fullName + "`"); | |
+ throw new TypeError('Attempting to register an unknown factory: `' + fullName + '`'); | |
} | |
var normalizedName = this.normalize(fullName); | |
if (this._resolveCache[normalizedName]) { | |
- throw new Error("Cannot re-register: `" + fullName + "`, as it has already been resolved."); | |
+ throw new Error('Cannot re-register: `' + fullName +'`, as it has already been resolved.'); | |
} | |
this.registrations[normalizedName] = factory; | |
- this._options[normalizedName] = options || {}; | |
+ this._options[normalizedName] = (options || {}); | |
}, | |
/** | |
Unregister a fullName | |
- ```javascript | |
+ | |
+ ```javascript | |
var registry = new Registry(); | |
registry.register('model:user', User); | |
- registry.resolve('model:user').create() instanceof User //=> true | |
- registry.unregister('model:user') | |
+ | |
+ registry.resolve('model:user').create() instanceof User //=> true | |
+ | |
+ registry.unregister('model:user') | |
registry.resolve('model:user') === undefined //=> true | |
``` | |
- @method unregister | |
+ | |
+ @method unregister | |
@param {String} fullName | |
*/ | |
- unregister: function (fullName) { | |
- Ember['default'].assert("fullName must be a proper full name", this.validateFullName(fullName)); | |
+ unregister: function(fullName) { | |
+ Ember['default'].assert('fullName must be a proper full name', this.validateFullName(fullName)); | |
var normalizedName = this.normalize(fullName); | |
@@ -1689,31 +1752,38 @@ | |
/** | |
Given a fullName return the corresponding factory. | |
- By default `resolve` will retrieve the factory from | |
+ | |
+ By default `resolve` will retrieve the factory from | |
the registry. | |
- ```javascript | |
+ | |
+ ```javascript | |
var registry = new Registry(); | |
registry.register('api:twitter', Twitter); | |
- registry.resolve('api:twitter') // => Twitter | |
+ | |
+ registry.resolve('api:twitter') // => Twitter | |
``` | |
- Optionally the registry can be provided with a custom resolver. | |
+ | |
+ Optionally the registry can be provided with a custom resolver. | |
If provided, `resolve` will first provide the custom resolver | |
the opportunity to resolve the fullName, otherwise it will fallback | |
to the registry. | |
- ```javascript | |
+ | |
+ ```javascript | |
var registry = new Registry(); | |
registry.resolver = function(fullName) { | |
// lookup via the module system of choice | |
}; | |
- // the twitter factory is added to the module system | |
+ | |
+ // the twitter factory is added to the module system | |
registry.resolve('api:twitter') // => Twitter | |
``` | |
- @method resolve | |
+ | |
+ @method resolve | |
@param {String} fullName | |
@return {Function} fullName's factory | |
*/ | |
- resolve: function (fullName) { | |
- Ember['default'].assert("fullName must be a proper full name", this.validateFullName(fullName)); | |
+ resolve: function(fullName) { | |
+ Ember['default'].assert('fullName must be a proper full name', this.validateFullName(fullName)); | |
var factory = resolve(this, this.normalize(fullName)); | |
if (factory === undefined && this.fallback) { | |
factory = this.fallback.resolve(fullName); | |
@@ -1724,84 +1794,100 @@ | |
/** | |
A hook that can be used to describe how the resolver will | |
attempt to find the factory. | |
- For example, the default Ember `.describe` returns the full | |
+ | |
+ For example, the default Ember `.describe` returns the full | |
class name (including namespace) where Ember's resolver expects | |
to find the `fullName`. | |
- @method describe | |
+ | |
+ @method describe | |
@param {String} fullName | |
@return {string} described fullName | |
*/ | |
- describe: function (fullName) { | |
+ describe: function(fullName) { | |
return fullName; | |
}, | |
/** | |
A hook to enable custom fullName normalization behaviour | |
- @method normalizeFullName | |
+ | |
+ @method normalizeFullName | |
@param {String} fullName | |
@return {string} normalized fullName | |
*/ | |
- normalizeFullName: function (fullName) { | |
+ normalizeFullName: function(fullName) { | |
return fullName; | |
}, | |
/** | |
normalize a fullName based on the applications conventions | |
- @method normalize | |
+ | |
+ @method normalize | |
@param {String} fullName | |
@return {string} normalized fullName | |
*/ | |
- normalize: function (fullName) { | |
- return this._normalizeCache[fullName] || (this._normalizeCache[fullName] = this.normalizeFullName(fullName)); | |
+ normalize: function(fullName) { | |
+ return this._normalizeCache[fullName] || ( | |
+ this._normalizeCache[fullName] = this.normalizeFullName(fullName) | |
+ ); | |
}, | |
/** | |
@method makeToString | |
- @param {any} factory | |
+ | |
+ @param {any} factory | |
@param {string} fullName | |
@return {function} toString function | |
*/ | |
- makeToString: function (factory, fullName) { | |
+ makeToString: function(factory, fullName) { | |
return factory.toString(); | |
}, | |
/** | |
Given a fullName check if the container is aware of its factory | |
or singleton instance. | |
- @method has | |
+ | |
+ @method has | |
@param {String} fullName | |
@return {Boolean} | |
*/ | |
- has: function (fullName) { | |
- Ember['default'].assert("fullName must be a proper full name", this.validateFullName(fullName)); | |
+ has: function(fullName) { | |
+ Ember['default'].assert('fullName must be a proper full name', this.validateFullName(fullName)); | |
return has(this, this.normalize(fullName)); | |
}, | |
/** | |
Allow registering options for all factories of a type. | |
- ```javascript | |
+ | |
+ ```javascript | |
var registry = new Registry(); | |
var container = registry.container(); | |
- // if all of type `connection` must not be singletons | |
+ | |
+ // if all of type `connection` must not be singletons | |
registry.optionsForType('connection', { singleton: false }); | |
- registry.register('connection:twitter', TwitterConnection); | |
+ | |
+ registry.register('connection:twitter', TwitterConnection); | |
registry.register('connection:facebook', FacebookConnection); | |
- var twitter = container.lookup('connection:twitter'); | |
+ | |
+ var twitter = container.lookup('connection:twitter'); | |
var twitter2 = container.lookup('connection:twitter'); | |
- twitter === twitter2; // => false | |
- var facebook = container.lookup('connection:facebook'); | |
+ | |
+ twitter === twitter2; // => false | |
+ | |
+ var facebook = container.lookup('connection:facebook'); | |
var facebook2 = container.lookup('connection:facebook'); | |
- facebook === facebook2; // => false | |
+ | |
+ facebook === facebook2; // => false | |
``` | |
- @method optionsForType | |
+ | |
+ @method optionsForType | |
@param {String} type | |
@param {Object} options | |
*/ | |
- optionsForType: function (type, options) { | |
+ optionsForType: function(type, options) { | |
this._typeOptions[type] = options; | |
}, | |
- getOptionsForType: function (type) { | |
+ getOptionsForType: function(type) { | |
var optionsForType = this._typeOptions[type]; | |
if (optionsForType === undefined && this.fallback) { | |
optionsForType = this.fallback.getOptionsForType(type); | |
@@ -1814,13 +1900,13 @@ | |
@param {String} fullName | |
@param {Object} options | |
*/ | |
- options: function (fullName, options) { | |
+ options: function(fullName, options) { | |
options = options || {}; | |
var normalizedName = this.normalize(fullName); | |
this._options[normalizedName] = options; | |
}, | |
- getOptions: function (fullName) { | |
+ getOptions: function(fullName) { | |
var normalizedName = this.normalize(fullName); | |
var options = this._options[normalizedName]; | |
if (options === undefined && this.fallback) { | |
@@ -1829,64 +1915,76 @@ | |
return options; | |
}, | |
- getOption: function (fullName, optionName) { | |
+ getOption: function(fullName, optionName) { | |
var options = this._options[fullName]; | |
if (options && options[optionName] !== undefined) { | |
return options[optionName]; | |
} | |
- var type = fullName.split(":")[0]; | |
+ var type = fullName.split(':')[0]; | |
options = this._typeOptions[type]; | |
if (options && options[optionName] !== undefined) { | |
return options[optionName]; | |
+ | |
} else if (this.fallback) { | |
return this.fallback.getOption(fullName, optionName); | |
} | |
}, | |
- option: function (fullName, optionName) { | |
- Ember['default'].deprecate("`Registry.option()` has been deprecated. Call `Registry.getOption()` instead."); | |
+ option: function(fullName, optionName) { | |
+ Ember['default'].deprecate('`Registry.option()` has been deprecated. Call `Registry.getOption()` instead.'); | |
return this.getOption(fullName, optionName); | |
}, | |
/** | |
Used only via `injection`. | |
- Provides a specialized form of injection, specifically enabling | |
+ | |
+ Provides a specialized form of injection, specifically enabling | |
all objects of one type to be injected with a reference to another | |
object. | |
- For example, provided each object of type `controller` needed a `router`. | |
+ | |
+ For example, provided each object of type `controller` needed a `router`. | |
one would do the following: | |
- ```javascript | |
+ | |
+ ```javascript | |
var registry = new Registry(); | |
var container = registry.container(); | |
- registry.register('router:main', Router); | |
+ | |
+ registry.register('router:main', Router); | |
registry.register('controller:user', UserController); | |
registry.register('controller:post', PostController); | |
- registry.typeInjection('controller', 'router', 'router:main'); | |
- var user = container.lookup('controller:user'); | |
+ | |
+ registry.typeInjection('controller', 'router', 'router:main'); | |
+ | |
+ var user = container.lookup('controller:user'); | |
var post = container.lookup('controller:post'); | |
- user.router instanceof Router; //=> true | |
+ | |
+ user.router instanceof Router; //=> true | |
post.router instanceof Router; //=> true | |
- // both controllers share the same router | |
+ | |
+ // both controllers share the same router | |
user.router === post.router; //=> true | |
``` | |
- @private | |
+ | |
+ @private | |
@method typeInjection | |
@param {String} type | |
@param {String} property | |
@param {String} fullName | |
*/ | |
- typeInjection: function (type, property, fullName) { | |
- Ember['default'].assert("fullName must be a proper full name", this.validateFullName(fullName)); | |
+ typeInjection: function(type, property, fullName) { | |
+ Ember['default'].assert('fullName must be a proper full name', this.validateFullName(fullName)); | |
- var fullNameType = fullName.split(":")[0]; | |
+ var fullNameType = fullName.split(':')[0]; | |
if (fullNameType === type) { | |
- throw new Error("Cannot inject a `" + fullName + "` on other " + type + "(s)."); | |
+ throw new Error('Cannot inject a `' + fullName + | |
+ '` on other ' + type + '(s).'); | |
} | |
- var injections = this._typeInjections[type] || (this._typeInjections[type] = []); | |
+ var injections = this._typeInjections[type] || | |
+ (this._typeInjections[type] = []); | |
injections.push({ | |
property: property, | |
@@ -1896,48 +1994,62 @@ | |
/** | |
Defines injection rules. | |
- These rules are used to inject dependencies onto objects when they | |
+ | |
+ These rules are used to inject dependencies onto objects when they | |
are instantiated. | |
- Two forms of injections are possible: | |
- * Injecting one fullName on another fullName | |
+ | |
+ Two forms of injections are possible: | |
+ | |
+ * Injecting one fullName on another fullName | |
* Injecting one fullName on a type | |
- Example: | |
- ```javascript | |
+ | |
+ Example: | |
+ | |
+ ```javascript | |
var registry = new Registry(); | |
var container = registry.container(); | |
- registry.register('source:main', Source); | |
+ | |
+ registry.register('source:main', Source); | |
registry.register('model:user', User); | |
registry.register('model:post', Post); | |
- // injecting one fullName on another fullName | |
+ | |
+ // injecting one fullName on another fullName | |
// eg. each user model gets a post model | |
registry.injection('model:user', 'post', 'model:post'); | |
- // injecting one fullName on another type | |
+ | |
+ // injecting one fullName on another type | |
registry.injection('model', 'source', 'source:main'); | |
- var user = container.lookup('model:user'); | |
+ | |
+ var user = container.lookup('model:user'); | |
var post = container.lookup('model:post'); | |
- user.source instanceof Source; //=> true | |
+ | |
+ user.source instanceof Source; //=> true | |
post.source instanceof Source; //=> true | |
- user.post instanceof Post; //=> true | |
- // and both models share the same source | |
+ | |
+ user.post instanceof Post; //=> true | |
+ | |
+ // and both models share the same source | |
user.source === post.source; //=> true | |
``` | |
- @method injection | |
+ | |
+ @method injection | |
@param {String} factoryName | |
@param {String} property | |
@param {String} injectionName | |
*/ | |
- injection: function (fullName, property, injectionName) { | |
+ injection: function(fullName, property, injectionName) { | |
this.validateFullName(injectionName); | |
var normalizedInjectionName = this.normalize(injectionName); | |
- if (fullName.indexOf(":") === -1) { | |
+ if (fullName.indexOf(':') === -1) { | |
return this.typeInjection(fullName, property, normalizedInjectionName); | |
} | |
- Ember['default'].assert("fullName must be a proper full name", this.validateFullName(fullName)); | |
+ Ember['default'].assert('fullName must be a proper full name', this.validateFullName(fullName)); | |
var normalizedName = this.normalize(fullName); | |
- var injections = this._injections[normalizedName] || (this._injections[normalizedName] = []); | |
+ var injections = this._injections[normalizedName] || | |
+ (this._injections[normalizedName] = []); | |
injections.push({ | |
property: property, | |
@@ -1945,29 +2057,39 @@ | |
}); | |
}, | |
+ | |
/** | |
Used only via `factoryInjection`. | |
- Provides a specialized form of injection, specifically enabling | |
+ | |
+ Provides a specialized form of injection, specifically enabling | |
all factory of one type to be injected with a reference to another | |
object. | |
- For example, provided each factory of type `model` needed a `store`. | |
+ | |
+ For example, provided each factory of type `model` needed a `store`. | |
one would do the following: | |
- ```javascript | |
+ | |
+ ```javascript | |
var registry = new Registry(); | |
- registry.register('store:main', SomeStore); | |
- registry.factoryTypeInjection('model', 'store', 'store:main'); | |
- var store = registry.lookup('store:main'); | |
+ | |
+ registry.register('store:main', SomeStore); | |
+ | |
+ registry.factoryTypeInjection('model', 'store', 'store:main'); | |
+ | |
+ var store = registry.lookup('store:main'); | |
var UserFactory = registry.lookupFactory('model:user'); | |
- UserFactory.store instanceof SomeStore; //=> true | |
+ | |
+ UserFactory.store instanceof SomeStore; //=> true | |
``` | |
- @private | |
+ | |
+ @private | |
@method factoryTypeInjection | |
@param {String} type | |
@param {String} property | |
@param {String} fullName | |
*/ | |
- factoryTypeInjection: function (type, property, fullName) { | |
- var injections = this._factoryTypeInjections[type] || (this._factoryTypeInjections[type] = []); | |
+ factoryTypeInjection: function(type, property, fullName) { | |
+ var injections = this._factoryTypeInjections[type] || | |
+ (this._factoryTypeInjections[type] = []); | |
injections.push({ | |
property: property, | |
@@ -1977,47 +2099,61 @@ | |
/** | |
Defines factory injection rules. | |
- Similar to regular injection rules, but are run against factories, via | |
+ | |
+ Similar to regular injection rules, but are run against factories, via | |
`Registry#lookupFactory`. | |
- These rules are used to inject objects onto factories when they | |
+ | |
+ These rules are used to inject objects onto factories when they | |
are looked up. | |
- Two forms of injections are possible: | |
- * Injecting one fullName on another fullName | |
+ | |
+ Two forms of injections are possible: | |
+ | |
+ * Injecting one fullName on another fullName | |
* Injecting one fullName on a type | |
- Example: | |
- ```javascript | |
+ | |
+ Example: | |
+ | |
+ ```javascript | |
var registry = new Registry(); | |
var container = registry.container(); | |
- registry.register('store:main', Store); | |
+ | |
+ registry.register('store:main', Store); | |
registry.register('store:secondary', OtherStore); | |
registry.register('model:user', User); | |
registry.register('model:post', Post); | |
- // injecting one fullName on another type | |
+ | |
+ // injecting one fullName on another type | |
registry.factoryInjection('model', 'store', 'store:main'); | |
- // injecting one fullName on another fullName | |
+ | |
+ // injecting one fullName on another fullName | |
registry.factoryInjection('model:post', 'secondaryStore', 'store:secondary'); | |
- var UserFactory = container.lookupFactory('model:user'); | |
+ | |
+ var UserFactory = container.lookupFactory('model:user'); | |
var PostFactory = container.lookupFactory('model:post'); | |
var store = container.lookup('store:main'); | |
- UserFactory.store instanceof Store; //=> true | |
+ | |
+ UserFactory.store instanceof Store; //=> true | |
UserFactory.secondaryStore instanceof OtherStore; //=> false | |
- PostFactory.store instanceof Store; //=> true | |
+ | |
+ PostFactory.store instanceof Store; //=> true | |
PostFactory.secondaryStore instanceof OtherStore; //=> true | |
- // and both models share the same source instance | |
+ | |
+ // and both models share the same source instance | |
UserFactory.store === PostFactory.store; //=> true | |
``` | |
- @method factoryInjection | |
+ | |
+ @method factoryInjection | |
@param {String} factoryName | |
@param {String} property | |
@param {String} injectionName | |
*/ | |
- factoryInjection: function (fullName, property, injectionName) { | |
+ factoryInjection: function(fullName, property, injectionName) { | |
var normalizedName = this.normalize(fullName); | |
var normalizedInjectionName = this.normalize(injectionName); | |
this.validateFullName(injectionName); | |
- if (fullName.indexOf(":") === -1) { | |
+ if (fullName.indexOf(':') === -1) { | |
return this.factoryTypeInjection(normalizedName, property, normalizedInjectionName); | |
} | |
@@ -2029,17 +2165,15 @@ | |
}); | |
}, | |
- validateFullName: function (fullName) { | |
+ validateFullName: function(fullName) { | |
if (!VALID_FULL_NAME_REGEXP.test(fullName)) { | |
- throw new TypeError("Invalid Fullname, expected: `type:name` got: " + fullName); | |
+ throw new TypeError('Invalid Fullname, expected: `type:name` got: ' + fullName); | |
} | |
return true; | |
}, | |
- validateInjections: function (injections) { | |
- if (!injections) { | |
- return; | |
- } | |
+ validateInjections: function(injections) { | |
+ if (!injections) { return; } | |
var fullName; | |
@@ -2047,12 +2181,12 @@ | |
fullName = injections[i].fullName; | |
if (!this.has(fullName)) { | |
- throw new Error("Attempting to inject an unknown injection: `" + fullName + "`"); | |
+ throw new Error('Attempting to inject an unknown injection: `' + fullName + '`'); | |
} | |
} | |
}, | |
- normalizeInjectionsHash: function (hash) { | |
+ normalizeInjectionsHash: function(hash) { | |
var injections = []; | |
for (var key in hash) { | |
@@ -2069,7 +2203,7 @@ | |
return injections; | |
}, | |
- getInjections: function (fullName) { | |
+ getInjections: function(fullName) { | |
var injections = this._injections[fullName] || []; | |
if (this.fallback) { | |
injections = injections.concat(this.fallback.getInjections(fullName)); | |
@@ -2077,7 +2211,7 @@ | |
return injections; | |
}, | |
- getTypeInjections: function (type) { | |
+ getTypeInjections: function(type) { | |
var injections = this._typeInjections[type] || []; | |
if (this.fallback) { | |
injections = injections.concat(this.fallback.getTypeInjections(type)); | |
@@ -2085,7 +2219,7 @@ | |
return injections; | |
}, | |
- getFactoryInjections: function (fullName) { | |
+ getFactoryInjections: function(fullName) { | |
var injections = this._factoryInjections[fullName] || []; | |
if (this.fallback) { | |
injections = injections.concat(this.fallback.getFactoryInjections(fullName)); | |
@@ -2093,7 +2227,7 @@ | |
return injections; | |
}, | |
- getFactoryTypeInjections: function (type) { | |
+ getFactoryTypeInjections: function(type) { | |
var injections = this._factoryTypeInjections[type] || []; | |
if (this.fallback) { | |
injections = injections.concat(this.fallback.getFactoryTypeInjections(type)); | |
@@ -2104,9 +2238,7 @@ | |
function resolve(registry, normalizedName) { | |
var cached = registry._resolveCache[normalizedName]; | |
- if (cached) { | |
- return cached; | |
- } | |
+ if (cached) { return cached; } | |
var resolved = registry.resolver(normalizedName) || registry.registrations[normalizedName]; | |
registry._resolveCache[normalizedName] = resolved; | |
@@ -3191,13 +3323,13 @@ | |
}); | |
enifed('ember-application', ['ember-metal/core', 'ember-runtime/system/lazy_load', 'ember-application/system/resolver', 'ember-application/system/application', 'ember-application/ext/controller'], function (Ember, lazy_load, resolver, Application) { | |
- 'use strict'; | |
+ 'use strict'; | |
- Ember['default'].Application = Application['default']; | |
- Ember['default'].Resolver = resolver.Resolver; | |
- Ember['default'].DefaultResolver = resolver.DefaultResolver; | |
+ Ember['default'].Application = Application['default']; | |
+ Ember['default'].Resolver = resolver.Resolver; | |
+ Ember['default'].DefaultResolver = resolver["default"]; | |
- lazy_load.runLoadHooks("Ember.Application", Application['default']); | |
+ lazy_load.runLoadHooks('Ember.Application', Application['default']); | |
}); | |
enifed('ember-application/ext/controller', ['exports', 'ember-metal/core', 'ember-metal/property_get', 'ember-metal/error', 'ember-metal/utils', 'ember-metal/computed', 'ember-runtime/mixins/controller', 'ember-routing/system/controller_for'], function (exports, Ember, property_get, EmberError, utils, computed, ControllerMixin, controllerFor) { | |
@@ -3213,12 +3345,13 @@ | |
var dependency, i, l; | |
var missing = []; | |
- for (i = 0, l = needs.length; i < l; i++) { | |
+ for (i=0, l=needs.length; i<l; i++) { | |
dependency = needs[i]; | |
- Ember['default'].assert(utils.inspect(controller) + "#needs must not specify dependencies with periods in their names (" + dependency + ")", dependency.indexOf(".") === -1); | |
+ Ember['default'].assert(utils.inspect(controller) + "#needs must not specify dependencies with periods in their names (" + | |
+ dependency + ")", dependency.indexOf('.') === -1); | |
- if (dependency.indexOf(":") === -1) { | |
+ if (dependency.indexOf(':') === -1) { | |
dependency = "controller:" + dependency; | |
} | |
@@ -3228,28 +3361,34 @@ | |
} | |
} | |
if (missing.length) { | |
- throw new EmberError['default'](utils.inspect(controller) + " needs [ " + missing.join(", ") + " ] but " + (missing.length > 1 ? "they" : "it") + " could not be found"); | |
+ throw new EmberError['default'](utils.inspect(controller) + " needs [ " + missing.join(', ') + | |
+ " ] but " + (missing.length > 1 ? 'they' : 'it') + " could not be found"); | |
} | |
} | |
- var defaultControllersComputedProperty = computed.computed(function () { | |
+ var defaultControllersComputedProperty = computed.computed(function() { | |
var controller = this; | |
return { | |
- needs: property_get.get(controller, "needs"), | |
- container: property_get.get(controller, "container"), | |
- unknownProperty: function (controllerName) { | |
+ needs: property_get.get(controller, 'needs'), | |
+ container: property_get.get(controller, 'container'), | |
+ unknownProperty: function(controllerName) { | |
var needs = this.needs; | |
var dependency, i, l; | |
- for (i = 0, l = needs.length; i < l; i++) { | |
+ for (i=0, l=needs.length; i<l; i++) { | |
dependency = needs[i]; | |
if (dependency === controllerName) { | |
- return this.container.lookup("controller:" + controllerName); | |
+ return this.container.lookup('controller:' + controllerName); | |
} | |
} | |
- var errorMessage = utils.inspect(controller) + "#needs does not include `" + controllerName + "`. To access the " + controllerName + " controller from " + utils.inspect(controller) + ", " + utils.inspect(controller) + " should have a `needs` property that is an array of the controllers it has access to."; | |
+ var errorMessage = utils.inspect(controller) + '#needs does not include `' + | |
+ controllerName + '`. To access the ' + | |
+ controllerName + ' controller from ' + | |
+ utils.inspect(controller) + ', ' + | |
+ utils.inspect(controller) + | |
+ ' should have a `needs` property that is an array of the controllers it has access to.'; | |
throw new ReferenceError(errorMessage); | |
}, | |
setUnknownProperty: function (key, value) { | |
@@ -3263,58 +3402,73 @@ | |
@namespace Ember | |
*/ | |
ControllerMixin['default'].reopen({ | |
- concatenatedProperties: ["needs"], | |
+ concatenatedProperties: ['needs'], | |
/** | |
An array of other controller objects available inside | |
instances of this controller via the `controllers` | |
property: | |
- For example, when you define a controller: | |
- ```javascript | |
+ | |
+ For example, when you define a controller: | |
+ | |
+ ```javascript | |
App.CommentsController = Ember.ArrayController.extend({ | |
needs: ['post'] | |
}); | |
``` | |
- The application's single instance of these other | |
+ | |
+ The application's single instance of these other | |
controllers are accessible by name through the | |
`controllers` property: | |
- ```javascript | |
+ | |
+ ```javascript | |
this.get('controllers.post'); // instance of App.PostController | |
``` | |
- Given that you have a nested controller (nested resource): | |
- ```javascript | |
+ | |
+ Given that you have a nested controller (nested resource): | |
+ | |
+ ```javascript | |
App.CommentsNewController = Ember.ObjectController.extend({ | |
}); | |
``` | |
- When you define a controller that requires access to a nested one: | |
- ```javascript | |
+ | |
+ When you define a controller that requires access to a nested one: | |
+ | |
+ ```javascript | |
App.IndexController = Ember.ObjectController.extend({ | |
needs: ['commentsNew'] | |
}); | |
``` | |
- You will be able to get access to it: | |
- ```javascript | |
+ | |
+ You will be able to get access to it: | |
+ | |
+ ```javascript | |
this.get('controllers.commentsNew'); // instance of App.CommentsNewController | |
``` | |
- This is only available for singleton controllers. | |
- @property {Array} needs | |
+ | |
+ This is only available for singleton controllers. | |
+ | |
+ @property {Array} needs | |
@default [] | |
*/ | |
needs: [], | |
- init: function () { | |
- var needs = property_get.get(this, "needs"); | |
- var length = property_get.get(needs, "length"); | |
+ init: function() { | |
+ var needs = property_get.get(this, 'needs'); | |
+ var length = property_get.get(needs, 'length'); | |
if (length > 0) { | |
- Ember['default'].assert(" `" + utils.inspect(this) + " specifies `needs`, but does " + "not have a container. Please ensure this controller was " + "instantiated with a container.", this.container || this.controllers !== defaultControllersComputedProperty); | |
+ Ember['default'].assert(' `' + utils.inspect(this) + ' specifies `needs`, but does ' + | |
+ "not have a container. Please ensure this controller was " + | |
+ "instantiated with a container.", | |
+ this.container || this.controllers !== defaultControllersComputedProperty); | |
if (this.container) { | |
verifyNeedsDependencies(this, this.container, needs); | |
} | |
// if needs then initialize controllers proxy | |
- property_get.get(this, "controllers"); | |
+ property_get.get(this, 'controllers'); | |
} | |
this._super.apply(this, arguments); | |
@@ -3325,16 +3479,17 @@ | |
@see {Ember.Route#controllerFor} | |
@deprecated Use `needs` instead | |
*/ | |
- controllerFor: function (controllerName) { | |
+ controllerFor: function(controllerName) { | |
Ember['default'].deprecate("Controller#controllerFor is deprecated, please use Controller#needs instead"); | |
- return controllerFor['default'](property_get.get(this, "container"), controllerName); | |
+ return controllerFor['default'](property_get.get(this, 'container'), controllerName); | |
}, | |
/** | |
Stores the instances of other controllers available from within | |
this controller. Any controller listed by name in the `needs` | |
property will be accessible by name through this property. | |
- ```javascript | |
+ | |
+ ```javascript | |
App.CommentsController = Ember.ArrayController.extend({ | |
needs: ['post'], | |
postTitle: function() { | |
@@ -3343,7 +3498,8 @@ | |
}.property('controllers.post.title') | |
}); | |
``` | |
- @see {Ember.ControllerMixin#needs} | |
+ | |
+ @see {Ember.ControllerMixin#needs} | |
@property {Object} controllers | |
@default null | |
*/ | |
@@ -3367,31 +3523,36 @@ | |
/** | |
The application instance's container. The container stores all of the | |
instance-specific state for this application run. | |
- @property {Ember.Container} container | |
+ | |
+ @property {Ember.Container} container | |
*/ | |
container: null, | |
/** | |
The application's registry. The registry contains the classes, templates, | |
and other code that makes up the application. | |
- @property {Ember.Registry} registry | |
+ | |
+ @property {Ember.Registry} registry | |
*/ | |
applicationRegistry: null, | |
/** | |
The registry for this application instance. It should use the | |
`applicationRegistry` as a fallback. | |
- @property {Ember.Registry} registry | |
+ | |
+ @property {Ember.Registry} registry | |
*/ | |
registry: null, | |
/** | |
The DOM events for which the event dispatcher should listen. | |
- By default, the application's `Ember.EventDispatcher` listens | |
+ | |
+ By default, the application's `Ember.EventDispatcher` listens | |
for a set of standard DOM events, such as `mousedown` and | |
`keyup`, and delegates them to your application's `Ember.View` | |
instances. | |
- @private | |
+ | |
+ @private | |
@property {Object} customEvents | |
*/ | |
customEvents: null, | |
@@ -3400,12 +3561,13 @@ | |
The root DOM element of the Application as an element or a | |
[jQuery-compatible selector | |
string](http://api.jquery.com/category/selectors/). | |
- @private | |
+ | |
+ @private | |
@property {String|DOMElement} rootElement | |
*/ | |
rootElement: null, | |
- init: function () { | |
+ init: function() { | |
this._super.apply(this, arguments); | |
// Create a per-instance registry that will use the application's registry | |
@@ -3427,7 +3589,7 @@ | |
// to notify us when it has created the root-most view. That view is then | |
// appended to the rootElement, in the case of apps, to the fixture harness | |
// in tests, or rendered to a string in the case of FastBoot. | |
- this.registry.register("-application-instance:main", this, { instantiate: false }); | |
+ this.registry.register('-application-instance:main', this, { instantiate: false }); | |
}, | |
/** | |
@@ -3435,16 +3597,15 @@ | |
location. This is useful for manually starting the app in FastBoot or | |
testing environments, where trying to modify the URL would be | |
inappropriate. | |
- @param options | |
+ | |
+ @param options | |
@private | |
*/ | |
- setupRouter: function (options) { | |
- var router = this.container.lookup("router:main"); | |
+ setupRouter: function(options) { | |
+ var router = this.container.lookup('router:main'); | |
var location = options.location; | |
- if (location) { | |
- property_set.set(router, "location", location); | |
- } | |
+ if (location) { property_set.set(router, 'location', location); } | |
router._setupLocation(); | |
router.setupRouter(true); | |
@@ -3454,13 +3615,15 @@ | |
This hook is called by the root-most Route (a.k.a. the ApplicationRoute) | |
when it has finished creating the root View. By default, we simply take the | |
view and append it to the `rootElement` specified on the Application. | |
- In cases like FastBoot and testing, we can override this hook and implement | |
+ | |
+ In cases like FastBoot and testing, we can override this hook and implement | |
custom behavior, such as serializing to a string and sending over an HTTP | |
socket rather than appending to DOM. | |
- @param view {Ember.View} the root-most view | |
+ | |
+ @param view {Ember.View} the root-most view | |
@private | |
*/ | |
- didCreateRootView: function (view) { | |
+ didCreateRootView: function(view) { | |
view.appendTo(this.rootElement); | |
}, | |
@@ -3468,15 +3631,15 @@ | |
Tells the router to start routing. The router will ask the location for the | |
current URL of the page to determine the initial URL to start routing to. | |
To start the app at a specific URL, call `handleURL` instead. | |
- Ensure that you have called `setupRouter()` on the instance before using | |
+ | |
+ Ensure that you have called `setupRouter()` on the instance before using | |
this method. | |
- @private | |
+ | |
+ @private | |
*/ | |
- startRouting: function () { | |
- var router = this.container.lookup("router:main"); | |
- if (!router) { | |
- return; | |
- } | |
+ startRouting: function() { | |
+ var router = this.container.lookup('router:main'); | |
+ if (!router) { return; } | |
var isModuleBasedResolver = !!this.registry.resolver.moduleBasedResolver; | |
router.startRouting(isModuleBasedResolver); | |
@@ -3486,11 +3649,12 @@ | |
Directs the router to route to a particular URL. This is useful in tests, | |
for example, to tell the app to start at a particular URL. Ensure that you | |
have called `setupRouter()` before calling this method. | |
- @param url {String} the URL the router should route to | |
+ | |
+ @param url {String} the URL the router should route to | |
@private | |
*/ | |
- handleURL: function (url) { | |
- var router = this.container.lookup("router:main"); | |
+ handleURL: function(url) { | |
+ var router = this.container.lookup('router:main'); | |
return router.handleURL(url); | |
}, | |
@@ -3498,8 +3662,8 @@ | |
/** | |
@private | |
*/ | |
- setupEventDispatcher: function () { | |
- var dispatcher = this.container.lookup("event_dispatcher:main"); | |
+ setupEventDispatcher: function() { | |
+ var dispatcher = this.container.lookup('event_dispatcher:main'); | |
dispatcher.setup(this.customEvents, this.rootElement); | |
@@ -3509,9 +3673,9 @@ | |
/** | |
@private | |
*/ | |
- willDestroy: function () { | |
+ willDestroy: function() { | |
this._super.apply(this, arguments); | |
- run['default'](this.container, "destroy"); | |
+ run['default'](this.container, 'destroy'); | |
} | |
}); | |
@@ -3684,23 +3848,28 @@ | |
The root DOM element of the Application. This can be specified as an | |
element or a | |
[jQuery-compatible selector string](http://api.jquery.com/category/selectors/). | |
- This is the element that will be passed to the Application's, | |
+ | |
+ This is the element that will be passed to the Application's, | |
`eventDispatcher`, which sets up the listeners for event delegation. Every | |
view in your application should be a child of the element you specify here. | |
- @property rootElement | |
+ | |
+ @property rootElement | |
@type DOMElement | |
@default 'body' | |
*/ | |
- rootElement: "body", | |
+ rootElement: 'body', | |
/** | |
The `Ember.EventDispatcher` responsible for delegating events to this | |
application's views. | |
- The event dispatcher is created by the application at initialization time | |
+ | |
+ The event dispatcher is created by the application at initialization time | |
and sets up event listeners on the DOM element described by the | |
application's `rootElement` property. | |
- See the documentation for `Ember.EventDispatcher` for more information. | |
- @property eventDispatcher | |
+ | |
+ See the documentation for `Ember.EventDispatcher` for more information. | |
+ | |
+ @property eventDispatcher | |
@type Ember.EventDispatcher | |
@default null | |
*/ | |
@@ -3708,15 +3877,18 @@ | |
/** | |
The DOM events for which the event dispatcher should listen. | |
- By default, the application's `Ember.EventDispatcher` listens | |
+ | |
+ By default, the application's `Ember.EventDispatcher` listens | |
for a set of standard DOM events, such as `mousedown` and | |
`keyup`, and delegates them to your application's `Ember.View` | |
instances. | |
- If you would like additional bubbling events to be delegated to your | |
+ | |
+ If you would like additional bubbling events to be delegated to your | |
views, set your `Ember.Application`'s `customEvents` property | |
to a hash containing the DOM event name as the key and the | |
corresponding view method name as the value. For example: | |
- ```javascript | |
+ | |
+ ```javascript | |
var App = Ember.Application.create({ | |
customEvents: { | |
// add support for the paste event | |
@@ -3724,7 +3896,8 @@ | |
} | |
}); | |
``` | |
- @property customEvents | |
+ | |
+ @property customEvents | |
@type Object | |
@default null | |
*/ | |
@@ -3736,14 +3909,15 @@ | |
other environments such as FastBoot or a testing harness can set this | |
property to `false` and control the precise timing and behavior of the boot | |
process. | |
- @property autoboot | |
+ | |
+ @property autoboot | |
@type Boolean | |
@default true | |
@private | |
*/ | |
autoboot: true, | |
- init: function () { | |
+ init: function() { | |
this._super.apply(this, arguments); | |
if (!this.$) { | |
@@ -3767,11 +3941,12 @@ | |
/** | |
Build and configure the registry for the current application. | |
- @private | |
+ | |
+ @private | |
@method buildRegistry | |
@return {Ember.Registry} the configured registry | |
*/ | |
- buildRegistry: function () { | |
+ buildRegistry: function() { | |
var registry = this.registry = Application.buildRegistry(this); | |
return registry; | |
@@ -3779,19 +3954,20 @@ | |
/** | |
Create a container for the current application's registry. | |
- @private | |
+ | |
+ @private | |
@method buildInstance | |
@return {Ember.Container} the configured container | |
*/ | |
- buildInstance: function () { | |
+ buildInstance: function() { | |
return ApplicationInstance['default'].create({ | |
- customEvents: property_get.get(this, "customEvents"), | |
- rootElement: property_get.get(this, "rootElement"), | |
+ customEvents: property_get.get(this, 'customEvents'), | |
+ rootElement: property_get.get(this, 'rootElement'), | |
applicationRegistry: this.registry | |
}); | |
}, | |
- buildDefaultInstance: function () { | |
+ buildDefaultInstance: function() { | |
var instance = this.buildInstance(); | |
// TODO2.0: Legacy support for App.__container__ | |
@@ -3806,43 +3982,52 @@ | |
/** | |
Automatically initialize the application once the DOM has | |
become ready. | |
- The initialization itself is scheduled on the actions queue | |
+ | |
+ The initialization itself is scheduled on the actions queue | |
which ensures that application loading finishes before | |
booting. | |
- If you are asynchronously loading code, you should call | |
+ | |
+ If you are asynchronously loading code, you should call | |
`deferReadiness()` to defer booting, and then call | |
`advanceReadiness()` once all of your code has finished | |
loading. | |
- @private | |
+ | |
+ @private | |
@method scheduleInitialize | |
*/ | |
- waitForDOMReady: function (_instance) { | |
+ waitForDOMReady: function(_instance) { | |
if (!this.$ || this.$.isReady) { | |
- run['default'].schedule("actions", this, "domReady", _instance); | |
+ run['default'].schedule('actions', this, 'domReady', _instance); | |
} else { | |
- this.$().ready(run['default'].bind(this, "domReady", _instance)); | |
+ this.$().ready(run['default'].bind(this, 'domReady', _instance)); | |
} | |
}, | |
/** | |
Use this to defer readiness until some condition is true. | |
- Example: | |
- ```javascript | |
+ | |
+ Example: | |
+ | |
+ ```javascript | |
var App = Ember.Application.create(); | |
- App.deferReadiness(); | |
+ | |
+ App.deferReadiness(); | |
// Ember.$ is a reference to the jQuery object/function | |
Ember.$.getJSON('/auth-token', function(token) { | |
App.token = token; | |
App.advanceReadiness(); | |
}); | |
``` | |
- This allows you to perform asynchronous setup logic and defer | |
+ | |
+ This allows you to perform asynchronous setup logic and defer | |
booting your application until the setup has finished. | |
- However, if the setup requires a loading UI, it might be better | |
+ | |
+ However, if the setup requires a loading UI, it might be better | |
to use the router for this purpose. | |
- @method deferReadiness | |
+ | |
+ @method deferReadiness | |
*/ | |
- deferReadiness: function () { | |
+ deferReadiness: function() { | |
Ember['default'].assert("You must call deferReadiness on an instance of Ember.Application", this instanceof Application); | |
Ember['default'].assert("You cannot defer readiness since the `ready()` hook has already been called.", this._readinessDeferrals > 0); | |
this._readinessDeferrals++; | |
@@ -3852,10 +4037,11 @@ | |
Call `advanceReadiness` after any asynchronous setup logic has completed. | |
Each call to `deferReadiness` must be matched by a call to `advanceReadiness` | |
or the application will never become ready and routing will not begin. | |
- @method advanceReadiness | |
+ | |
+ @method advanceReadiness | |
@see {Ember.Application#deferReadiness} | |
*/ | |
- advanceReadiness: function () { | |
+ advanceReadiness: function() { | |
Ember['default'].assert("You must call advanceReadiness on an instance of Ember.Application", this instanceof Application); | |
this._readinessDeferrals--; | |
@@ -3868,137 +4054,162 @@ | |
Registers a factory that can be used for dependency injection (with | |
`App.inject`) or for service lookup. Each factory is registered with | |
a full name including two parts: `type:name`. | |
- A simple example: | |
- ```javascript | |
+ | |
+ A simple example: | |
+ | |
+ ```javascript | |
var App = Ember.Application.create(); | |
- App.Orange = Ember.Object.extend(); | |
+ | |
+ App.Orange = Ember.Object.extend(); | |
App.register('fruit:favorite', App.Orange); | |
``` | |
- Ember will resolve factories from the `App` namespace automatically. | |
+ | |
+ Ember will resolve factories from the `App` namespace automatically. | |
For example `App.CarsController` will be discovered and returned if | |
an application requests `controller:cars`. | |
- An example of registering a controller with a non-standard name: | |
- ```javascript | |
+ | |
+ An example of registering a controller with a non-standard name: | |
+ | |
+ ```javascript | |
var App = Ember.Application.create(); | |
var Session = Ember.Controller.extend(); | |
- App.register('controller:session', Session); | |
- // The Session controller can now be treated like a normal controller, | |
+ | |
+ App.register('controller:session', Session); | |
+ | |
+ // The Session controller can now be treated like a normal controller, | |
// despite its non-standard name. | |
App.ApplicationController = Ember.Controller.extend({ | |
needs: ['session'] | |
}); | |
``` | |
- Registered factories are **instantiated** by having `create` | |
+ | |
+ Registered factories are **instantiated** by having `create` | |
called on them. Additionally they are **singletons**, each time | |
they are looked up they return the same instance. | |
- Some examples modifying that default behavior: | |
- ```javascript | |
+ | |
+ Some examples modifying that default behavior: | |
+ | |
+ ```javascript | |
var App = Ember.Application.create(); | |
- App.Person = Ember.Object.extend(); | |
+ | |
+ App.Person = Ember.Object.extend(); | |
App.Orange = Ember.Object.extend(); | |
App.Email = Ember.Object.extend(); | |
App.session = Ember.Object.create(); | |
- App.register('model:user', App.Person, { singleton: false }); | |
+ | |
+ App.register('model:user', App.Person, { singleton: false }); | |
App.register('fruit:favorite', App.Orange); | |
App.register('communication:main', App.Email, { singleton: false }); | |
App.register('session', App.session, { instantiate: false }); | |
``` | |
- @method register | |
+ | |
+ @method register | |
@param fullName {String} type:name (e.g., 'model:user') | |
@param factory {Function} (e.g., App.Person) | |
@param options {Object} (optional) disable instantiation or singleton usage | |
**/ | |
- register: function () { | |
+ register: function() { | |
this.registry.register.apply(this.registry, arguments); | |
}, | |
/** | |
Define a dependency injection onto a specific factory or all factories | |
of a type. | |
- When Ember instantiates a controller, view, or other framework component | |
+ | |
+ When Ember instantiates a controller, view, or other framework component | |
it can attach a dependency to that component. This is often used to | |
provide services to a set of framework components. | |
- An example of providing a session object to all controllers: | |
- ```javascript | |
+ | |
+ An example of providing a session object to all controllers: | |
+ | |
+ ```javascript | |
var App = Ember.Application.create(); | |
var Session = Ember.Object.extend({ isAuthenticated: false }); | |
- // A factory must be registered before it can be injected | |
+ | |
+ // A factory must be registered before it can be injected | |
App.register('session:main', Session); | |
- // Inject 'session:main' onto all factories of the type 'controller' | |
+ | |
+ // Inject 'session:main' onto all factories of the type 'controller' | |
// with the name 'session' | |
App.inject('controller', 'session', 'session:main'); | |
- App.IndexController = Ember.Controller.extend({ | |
+ | |
+ App.IndexController = Ember.Controller.extend({ | |
isLoggedIn: Ember.computed.alias('session.isAuthenticated') | |
}); | |
``` | |
- Injections can also be performed on specific factories. | |
- ```javascript | |
+ | |
+ Injections can also be performed on specific factories. | |
+ | |
+ ```javascript | |
App.inject(<full_name or type>, <property name>, <full_name>) | |
App.inject('route', 'source', 'source:main') | |
App.inject('route:application', 'email', 'model:email') | |
``` | |
- It is important to note that injections can only be performed on | |
+ | |
+ It is important to note that injections can only be performed on | |
classes that are instantiated by Ember itself. Instantiating a class | |
directly (via `create` or `new`) bypasses the dependency injection | |
system. | |
- **Note:** Ember-Data instantiates its models in a unique manner, and consequently | |
+ | |
+ **Note:** Ember-Data instantiates its models in a unique manner, and consequently | |
injections onto models (or all models) will not work as expected. Injections | |
on models can be enabled by setting `Ember.MODEL_FACTORY_INJECTIONS` | |
to `true`. | |
- @method inject | |
+ | |
+ @method inject | |
@param factoryNameOrType {String} | |
@param property {String} | |
@param injectionName {String} | |
**/ | |
- inject: function () { | |
+ inject: function() { | |
this.registry.injection.apply(this.registry, arguments); | |
}, | |
/** | |
Calling initialize manually is not supported. | |
- Please see Ember.Application#advanceReadiness and | |
+ | |
+ Please see Ember.Application#advanceReadiness and | |
Ember.Application#deferReadiness. | |
- @private | |
+ | |
+ @private | |
@deprecated | |
@method initialize | |
**/ | |
- initialize: function () { | |
- Ember['default'].deprecate("Calling initialize manually is not supported. Please see Ember.Application#advanceReadiness and Ember.Application#deferReadiness"); | |
+ initialize: function() { | |
+ Ember['default'].deprecate('Calling initialize manually is not supported. Please see Ember.Application#advanceReadiness and Ember.Application#deferReadiness'); | |
}, | |
/** | |
Initialize the application. This happens automatically. | |
- Run any initializers and run the application load hook. These hooks may | |
+ | |
+ Run any initializers and run the application load hook. These hooks may | |
choose to defer readiness. For example, an authentication hook might want | |
to defer readiness until the auth token has been retrieved. | |
- @private | |
+ | |
+ @private | |
@method _initialize | |
*/ | |
- domReady: function (_instance) { | |
- if (this.isDestroyed) { | |
- return; | |
- } | |
+ domReady: function(_instance) { | |
+ if (this.isDestroyed) { return; } | |
var app = this; | |
- this.boot().then(function () { | |
+ this.boot().then(function() { | |
app.runInstanceInitializers(_instance); | |
}); | |
return this; | |
}, | |
- boot: function () { | |
- if (this._bootPromise) { | |
- return this._bootPromise; | |
- } | |
+ boot: function() { | |
+ if (this._bootPromise) { return this._bootPromise; } | |
var defer = new Ember['default'].RSVP.defer(); | |
this._bootPromise = defer.promise; | |
this._bootResolver = defer; | |
this.runInitializers(this.registry); | |
- lazy_load.runLoadHooks("application", this); | |
+ lazy_load.runLoadHooks('application', this); | |
this.advanceReadiness(); | |
@@ -4008,38 +4219,50 @@ | |
/** | |
Reset the application. This is typically used only in tests. It cleans up | |
the application in the following order: | |
- 1. Deactivate existing routes | |
+ | |
+ 1. Deactivate existing routes | |
2. Destroy all objects in the container | |
3. Create a new application container | |
4. Re-route to the existing url | |
- Typical Example: | |
- ```javascript | |
+ | |
+ Typical Example: | |
+ | |
+ ```javascript | |
var App; | |
- run(function() { | |
+ | |
+ run(function() { | |
App = Ember.Application.create(); | |
}); | |
- module('acceptance test', { | |
+ | |
+ module('acceptance test', { | |
setup: function() { | |
App.reset(); | |
} | |
}); | |
- test('first test', function() { | |
+ | |
+ test('first test', function() { | |
// App is freshly reset | |
}); | |
- test('second test', function() { | |
+ | |
+ test('second test', function() { | |
// App is again freshly reset | |
}); | |
``` | |
- Advanced Example: | |
- Occasionally you may want to prevent the app from initializing during | |
+ | |
+ Advanced Example: | |
+ | |
+ Occasionally you may want to prevent the app from initializing during | |
setup. This could enable extra configuration, or enable asserting prior | |
to the app becoming ready. | |
- ```javascript | |
+ | |
+ ```javascript | |
var App; | |
- run(function() { | |
+ | |
+ run(function() { | |
App = Ember.Application.create(); | |
}); | |
- module('acceptance test', { | |
+ | |
+ module('acceptance test', { | |
setup: function() { | |
run(function() { | |
App.reset(); | |
@@ -4047,17 +4270,21 @@ | |
}); | |
} | |
}); | |
- test('first test', function() { | |
+ | |
+ test('first test', function() { | |
ok(true, 'something before app is initialized'); | |
- run(function() { | |
+ | |
+ run(function() { | |
App.advanceReadiness(); | |
}); | |
- ok(true, 'something after app is initialized'); | |
+ | |
+ ok(true, 'something after app is initialized'); | |
}); | |
``` | |
- @method reset | |
+ | |
+ @method reset | |
**/ | |
- reset: function () { | |
+ reset: function() { | |
var instance = this.__deprecatedInstance__; | |
this._readinessDeferrals = 1; | |
@@ -4065,11 +4292,11 @@ | |
this._bootResolver = null; | |
function handleReset() { | |
- run['default'](instance, "destroy"); | |
+ run['default'](instance, 'destroy'); | |
this.buildDefaultInstance(); | |
- run['default'].schedule("actions", this, "domReady"); | |
+ run['default'].schedule('actions', this, 'domReady'); | |
} | |
run['default'].join(this, handleReset); | |
@@ -4079,9 +4306,9 @@ | |
@private | |
@method runInitializers | |
*/ | |
- runInitializers: function (registry) { | |
+ runInitializers: function(registry) { | |
var App = this; | |
- this._runInitializer("initializers", function (name, initializer) { | |
+ this._runInitializer('initializers', function(name, initializer) { | |
Ember['default'].assert("No application initializer named '" + name + "'", !!initializer); | |
@@ -4091,14 +4318,14 @@ | |
}); | |
}, | |
- runInstanceInitializers: function (instance) { | |
- this._runInitializer("instanceInitializers", function (name, initializer) { | |
+ runInstanceInitializers: function(instance) { | |
+ this._runInitializer('instanceInitializers', function(name, initializer) { | |
Ember['default'].assert("No instance initializer named '" + name + "'", !!initializer); | |
initializer.initialize(instance); | |
}); | |
}, | |
- _runInitializer: function (bucketName, cb) { | |
+ _runInitializer: function(bucketName, cb) { | |
var initializersByName = property_get.get(this.constructor, bucketName); | |
var initializers = props(initializersByName); | |
var graph = new DAG['default'](); | |
@@ -4118,7 +4345,7 @@ | |
@private | |
@method didBecomeReady | |
*/ | |
- didBecomeReady: function () { | |
+ didBecomeReady: function() { | |
if (this.autoboot) { | |
if (environment['default'].hasDOM) { | |
this.__deprecatedInstance__.setupEventDispatcher(); | |
@@ -4142,34 +4369,36 @@ | |
/** | |
Called when the Application has become ready. | |
The call will be delayed until the DOM has become ready. | |
- @event ready | |
+ | |
+ @event ready | |
*/ | |
- ready: function () { | |
- return this; | |
- }, | |
+ ready: function() { return this; }, | |
/** | |
@deprecated Use 'Resolver' instead | |
Set this to provide an alternate class to `Ember.DefaultResolver` | |
- @property resolver | |
+ | |
+ | |
+ @property resolver | |
*/ | |
resolver: null, | |
/** | |
Set this to provide an alternate class to `Ember.DefaultResolver` | |
- @property resolver | |
+ | |
+ @property resolver | |
*/ | |
Resolver: null, | |
// This method must be moved to the application instance object | |
- willDestroy: function () { | |
+ willDestroy: function() { | |
Ember['default'].BOOTED = false; | |
this._bootPromise = null; | |
this._bootResolver = null; | |
this.__deprecatedInstance__.destroy(); | |
}, | |
- initializer: function (options) { | |
+ initializer: function(options) { | |
this.constructor.initializer(options); | |
}, | |
@@ -4178,8 +4407,12 @@ | |
@private | |
@deprecated | |
*/ | |
- then: function () { | |
- Ember['default'].deprecate("Do not use `.then` on an instance of Ember.Application. Please use the `.ready` hook instead.", false, { url: "http://emberjs.com/guides/deprecations/#toc_code-then-code-on-ember-application" }); | |
+ then: function() { | |
+ Ember['default'].deprecate( | |
+ 'Do not use `.then` on an instance of Ember.Application. Please use the `.ready` hook instead.', | |
+ false, | |
+ { url: 'http://emberjs.com/guides/deprecations/#toc_code-then-code-on-ember-application' } | |
+ ); | |
this._super.apply(this, arguments); | |
} | |
@@ -4195,102 +4428,133 @@ | |
Initializer receives an object which has the following attributes: | |
`name`, `before`, `after`, `initialize`. The only required attribute is | |
`initialize, all others are optional. | |
- * `name` allows you to specify under which name the initializer is registered. | |
+ | |
+ * `name` allows you to specify under which name the initializer is registered. | |
This must be a unique name, as trying to register two initializers with the | |
same name will result in an error. | |
- ```javascript | |
+ | |
+ ```javascript | |
Ember.Application.initializer({ | |
name: 'namedInitializer', | |
- initialize: function(container, application) { | |
+ | |
+ initialize: function(container, application) { | |
Ember.debug('Running namedInitializer!'); | |
} | |
}); | |
``` | |
- * `before` and `after` are used to ensure that this initializer is ran prior | |
+ | |
+ * `before` and `after` are used to ensure that this initializer is ran prior | |
or after the one identified by the value. This value can be a single string | |
or an array of strings, referencing the `name` of other initializers. | |
- An example of ordering initializers, we create an initializer named `first`: | |
- ```javascript | |
+ | |
+ An example of ordering initializers, we create an initializer named `first`: | |
+ | |
+ ```javascript | |
Ember.Application.initializer({ | |
name: 'first', | |
- initialize: function(container, application) { | |
+ | |
+ initialize: function(container, application) { | |
Ember.debug('First initializer!'); | |
} | |
}); | |
- // DEBUG: First initializer! | |
+ | |
+ // DEBUG: First initializer! | |
``` | |
- We add another initializer named `second`, specifying that it should run | |
+ | |
+ We add another initializer named `second`, specifying that it should run | |
after the initializer named `first`: | |
- ```javascript | |
+ | |
+ ```javascript | |
Ember.Application.initializer({ | |
name: 'second', | |
after: 'first', | |
- initialize: function(container, application) { | |
+ | |
+ initialize: function(container, application) { | |
Ember.debug('Second initializer!'); | |
} | |
}); | |
- // DEBUG: First initializer! | |
+ | |
+ // DEBUG: First initializer! | |
// DEBUG: Second initializer! | |
``` | |
- Afterwards we add a further initializer named `pre`, this time specifying | |
+ | |
+ Afterwards we add a further initializer named `pre`, this time specifying | |
that it should run before the initializer named `first`: | |
- ```javascript | |
+ | |
+ ```javascript | |
Ember.Application.initializer({ | |
name: 'pre', | |
before: 'first', | |
- initialize: function(container, application) { | |
+ | |
+ initialize: function(container, application) { | |
Ember.debug('Pre initializer!'); | |
} | |
}); | |
- // DEBUG: Pre initializer! | |
+ | |
+ // DEBUG: Pre initializer! | |
// DEBUG: First initializer! | |
// DEBUG: Second initializer! | |
``` | |
- Finally we add an initializer named `post`, specifying it should run after | |
+ | |
+ Finally we add an initializer named `post`, specifying it should run after | |
both the `first` and the `second` initializers: | |
- ```javascript | |
+ | |
+ ```javascript | |
Ember.Application.initializer({ | |
name: 'post', | |
after: ['first', 'second'], | |
- initialize: function(container, application) { | |
+ | |
+ initialize: function(container, application) { | |
Ember.debug('Post initializer!'); | |
} | |
}); | |
- // DEBUG: Pre initializer! | |
+ | |
+ // DEBUG: Pre initializer! | |
// DEBUG: First initializer! | |
// DEBUG: Second initializer! | |
// DEBUG: Post initializer! | |
``` | |
- * `initialize` is a callback function that receives two arguments, `container` | |
+ | |
+ * `initialize` is a callback function that receives two arguments, `container` | |
and `application` on which you can operate. | |
- Example of using `container` to preload data into the store: | |
- ```javascript | |
+ | |
+ Example of using `container` to preload data into the store: | |
+ | |
+ ```javascript | |
Ember.Application.initializer({ | |
name: 'preload-data', | |
- initialize: function(container, application) { | |
+ | |
+ initialize: function(container, application) { | |
var store = container.lookup('store:main'); | |
- store.pushPayload(preloadedData); | |
+ | |
+ store.pushPayload(preloadedData); | |
} | |
}); | |
``` | |
- Example of using `application` to register an adapter: | |
- ```javascript | |
+ | |
+ Example of using `application` to register an adapter: | |
+ | |
+ ```javascript | |
Ember.Application.initializer({ | |
name: 'api-adapter', | |
- initialize: function(container, application) { | |
+ | |
+ initialize: function(container, application) { | |
application.register('api-adapter:main', ApiAdapter); | |
} | |
}); | |
``` | |
- @method initializer | |
+ | |
+ @method initializer | |
@param initializer {Object} | |
*/ | |
- initializer: buildInitializerMethod("initializers", "initializer"), | |
+ initializer: buildInitializerMethod('initializers', 'initializer'), | |
/** | |
This creates a registry with the default Ember naming conventions. | |
- It also configures the registry: | |
- * registered views are created every time they are looked up (they are | |
+ | |
+ It also configures the registry: | |
+ | |
+ * registered views are created every time they are looked up (they are | |
not singletons) | |
* registered templates are not factories; the registered value is | |
returned directly. | |
@@ -4302,14 +4566,15 @@ | |
`controller` property | |
* the application view receives the application template as its | |
`defaultTemplate` property | |
- @private | |
+ | |
+ @private | |
@method buildRegistry | |
@static | |
@param {Ember.Application} namespace the application for which to | |
build the registry | |
@return {Ember.Registry} the built registry | |
*/ | |
- buildRegistry: function (namespace) { | |
+ buildRegistry: function(namespace) { | |
var registry = new Registry['default'](); | |
registry.set = property_set.set; | |
@@ -4318,57 +4583,55 @@ | |
registry.describe = registry.resolver.describe; | |
registry.makeToString = registry.resolver.makeToString; | |
- registry.optionsForType("component", { singleton: false }); | |
- registry.optionsForType("view", { singleton: false }); | |
- registry.optionsForType("template", { instantiate: false }); | |
- registry.optionsForType("helper", { instantiate: false }); | |
+ registry.optionsForType('component', { singleton: false }); | |
+ registry.optionsForType('view', { singleton: false }); | |
+ registry.optionsForType('template', { instantiate: false }); | |
+ registry.optionsForType('helper', { instantiate: false }); | |
- registry.register("application:main", namespace, { instantiate: false }); | |
+ registry.register('application:main', namespace, { instantiate: false }); | |
- registry.register("controller:basic", Controller['default'], { instantiate: false }); | |
- registry.register("controller:object", ObjectController['default'], { instantiate: false }); | |
- registry.register("controller:array", ArrayController['default'], { instantiate: false }); | |
+ registry.register('controller:basic', Controller['default'], { instantiate: false }); | |
+ registry.register('controller:object', ObjectController['default'], { instantiate: false }); | |
+ registry.register('controller:array', ArrayController['default'], { instantiate: false }); | |
- registry.register("renderer:-dom", { create: function () { | |
- return new Renderer['default'](new DOMHelper['default']()); | |
- } }); | |
+ registry.register('renderer:-dom', { create: function() { return new Renderer['default'](new DOMHelper['default']()); } }); | |
- registry.injection("view", "renderer", "renderer:-dom"); | |
- registry.register("view:select", SelectView['default']); | |
- registry.register("view:-outlet", outlet.OutletView); | |
+ registry.injection('view', 'renderer', 'renderer:-dom'); | |
+ registry.register('view:select', SelectView['default']); | |
+ registry.register('view:-outlet', outlet.OutletView); | |
- registry.register("view:default", _MetamorphView['default']); | |
- registry.register("view:toplevel", EmberView['default'].extend()); | |
+ registry.register('view:default', _MetamorphView['default']); | |
+ registry.register('view:toplevel', EmberView['default'].extend()); | |
- registry.register("route:basic", Route['default'], { instantiate: false }); | |
- registry.register("event_dispatcher:main", EventDispatcher['default']); | |
+ registry.register('route:basic', Route['default'], { instantiate: false }); | |
+ registry.register('event_dispatcher:main', EventDispatcher['default']); | |
- registry.injection("router:main", "namespace", "application:main"); | |
- registry.injection("view:-outlet", "namespace", "application:main"); | |
+ registry.injection('router:main', 'namespace', 'application:main'); | |
+ registry.injection('view:-outlet', 'namespace', 'application:main'); | |
- registry.register("location:auto", AutoLocation['default']); | |
- registry.register("location:hash", HashLocation['default']); | |
- registry.register("location:history", HistoryLocation['default']); | |
- registry.register("location:none", NoneLocation['default']); | |
+ registry.register('location:auto', AutoLocation['default']); | |
+ registry.register('location:hash', HashLocation['default']); | |
+ registry.register('location:history', HistoryLocation['default']); | |
+ registry.register('location:none', NoneLocation['default']); | |
- registry.injection("controller", "target", "router:main"); | |
- registry.injection("controller", "namespace", "application:main"); | |
+ registry.injection('controller', 'target', 'router:main'); | |
+ registry.injection('controller', 'namespace', 'application:main'); | |
- registry.register("-bucket-cache:main", BucketCache['default']); | |
- registry.injection("router", "_bucketCache", "-bucket-cache:main"); | |
- registry.injection("route", "_bucketCache", "-bucket-cache:main"); | |
- registry.injection("controller", "_bucketCache", "-bucket-cache:main"); | |
+ registry.register('-bucket-cache:main', BucketCache['default']); | |
+ registry.injection('router', '_bucketCache', '-bucket-cache:main'); | |
+ registry.injection('route', '_bucketCache', '-bucket-cache:main'); | |
+ registry.injection('controller', '_bucketCache', '-bucket-cache:main'); | |
- registry.injection("route", "router", "router:main"); | |
- registry.injection("location", "rootURL", "-location-setting:root-url"); | |
+ registry.injection('route', 'router', 'router:main'); | |
+ registry.injection('location', 'rootURL', '-location-setting:root-url'); | |
// DEBUGGING | |
- registry.register("resolver-for-debugging:main", registry.resolver.__resolver__, { instantiate: false }); | |
- registry.injection("container-debug-adapter:main", "resolver", "resolver-for-debugging:main"); | |
- registry.injection("data-adapter:main", "containerDebugAdapter", "container-debug-adapter:main"); | |
+ registry.register('resolver-for-debugging:main', registry.resolver.__resolver__, { instantiate: false }); | |
+ registry.injection('container-debug-adapter:main', 'resolver', 'resolver-for-debugging:main'); | |
+ registry.injection('data-adapter:main', 'containerDebugAdapter', 'container-debug-adapter:main'); | |
// Custom resolver authors may want to register their own ContainerDebugAdapter with this key | |
- registry.register("container-debug-adapter:main", ContainerDebugAdapter['default']); | |
+ registry.register('container-debug-adapter:main', ContainerDebugAdapter['default']); | |
return registry; | |
} | |
@@ -4391,9 +4654,12 @@ | |
@return {*} the resolved value for a given lookup | |
*/ | |
function resolverFor(namespace) { | |
- Ember['default'].deprecate("Application.resolver is deprecated in favor of Application.Resolver", !namespace.get("resolver")); | |
+ Ember['default'].deprecate( | |
+ 'Application.resolver is deprecated in favor of Application.Resolver', | |
+ !namespace.get('resolver') | |
+ ); | |
- var ResolverClass = namespace.get("resolver") || namespace.get("Resolver") || DefaultResolver['default']; | |
+ var ResolverClass = namespace.get('resolver') || namespace.get('Resolver') || DefaultResolver['default']; | |
var resolver = ResolverClass.create({ | |
namespace: namespace | |
}); | |
@@ -4402,19 +4668,19 @@ | |
return resolver.resolve(fullName); | |
} | |
- resolve.describe = function (fullName) { | |
+ resolve.describe = function(fullName) { | |
return resolver.lookupDescription(fullName); | |
}; | |
- resolve.makeToString = function (factory, fullName) { | |
+ resolve.makeToString = function(factory, fullName) { | |
return resolver.makeToString(factory, fullName); | |
}; | |
- resolve.normalize = function (fullName) { | |
+ resolve.normalize = function(fullName) { | |
if (resolver.normalize) { | |
return resolver.normalize(fullName); | |
} else { | |
- Ember['default'].deprecate("The Resolver should now provide a 'normalize' function"); | |
+ Ember['default'].deprecate('The Resolver should now provide a \'normalize\' function'); | |
return fullName; | |
} | |
}; | |
@@ -4429,7 +4695,7 @@ | |
librariesRegistered = true; | |
if (environment['default'].hasDOM) { | |
- Ember['default'].libraries.registerCoreLibrary("jQuery", jQuery['default']().jquery); | |
+ Ember['default'].libraries.registerCoreLibrary('jQuery', jQuery['default']().jquery); | |
} | |
} | |
} | |
@@ -4440,24 +4706,24 @@ | |
Ember['default'].LOG_VERSION = false; | |
var libs = Ember['default'].libraries._registry; | |
- var nameLengths = EnumerableUtils['default'].map(libs, function (item) { | |
- return property_get.get(item, "name.length"); | |
+ var nameLengths = EnumerableUtils['default'].map(libs, function(item) { | |
+ return property_get.get(item, 'name.length'); | |
}); | |
var maxNameLength = Math.max.apply(this, nameLengths); | |
- Ember['default'].debug("-------------------------------"); | |
+ Ember['default'].debug('-------------------------------'); | |
for (var i = 0, l = libs.length; i < l; i++) { | |
var lib = libs[i]; | |
- var spaces = new Array(maxNameLength - lib.name.length + 1).join(" "); | |
- Ember['default'].debug([lib.name, spaces, " : ", lib.version].join("")); | |
+ var spaces = new Array(maxNameLength - lib.name.length + 1).join(' '); | |
+ Ember['default'].debug([lib.name, spaces, ' : ', lib.version].join('')); | |
} | |
- Ember['default'].debug("-------------------------------"); | |
+ Ember['default'].debug('-------------------------------'); | |
} | |
} | |
function buildInitializerMethod(bucketName, humanName) { | |
- return function (initializer) { | |
+ return function(initializer) { | |
// If this is the first initializer being added to a subclass, we are going to reopen the class | |
// to make sure we have a new `initializers` object, which extends from the parent class' using | |
// prototypal inheritance. Without this, attempting to add initializers to the subclass would | |
@@ -4469,7 +4735,7 @@ | |
} | |
Ember['default'].assert("The " + humanName + " '" + initializer.name + "' has already been registered", !this[bucketName][initializer.name]); | |
- Ember['default'].assert("An " + humanName + " cannot be registered without an initialize function", utils.canInvoke(initializer, "initialize")); | |
+ Ember['default'].assert("An " + humanName + " cannot be registered without an initialize function", utils.canInvoke(initializer, 'initialize')); | |
Ember['default'].assert("An " + humanName + " cannot be registered without a name property", initializer.name !== undefined); | |
this[bucketName][initializer.name] = initializer; | |
@@ -4492,66 +4758,142 @@ | |
/** | |
This will be set to the Application instance when it is | |
created. | |
- @property namespace | |
+ | |
+ @property namespace | |
*/ | |
namespace: null, | |
- normalize: Ember['default'].required(Function), | |
- resolve: Ember['default'].required(Function), | |
- parseName: Ember['default'].required(Function), | |
+ normalize: Ember['default'].required(Function), | |
+ resolve: Ember['default'].required(Function), | |
+ parseName: Ember['default'].required(Function), | |
lookupDescription: Ember['default'].required(Function), | |
- makeToString: Ember['default'].required(Function), | |
- resolveOther: Ember['default'].required(Function), | |
- _logLookup: Ember['default'].required(Function) | |
+ makeToString: Ember['default'].required(Function), | |
+ resolveOther: Ember['default'].required(Function), | |
+ _logLookup: Ember['default'].required(Function) | |
}); | |
+ /** | |
+ The DefaultResolver defines the default lookup rules to resolve | |
+ container lookups before consulting the container for registered | |
+ items: | |
+ | |
+ * templates are looked up on `Ember.TEMPLATES` | |
+ * other names are looked up on the application after converting | |
+ the name. For example, `controller:post` looks up | |
+ `App.PostController` by default. | |
+ * there are some nuances (see examples below) | |
+ | |
+ ### How Resolving Works | |
+ | |
+ The container calls this object's `resolve` method with the | |
+ `fullName` argument. | |
+ | |
+ It first parses the fullName into an object using `parseName`. | |
+ | |
+ Then it checks for the presence of a type-specific instance | |
+ method of the form `resolve[Type]` and calls it if it exists. | |
+ For example if it was resolving 'template:post', it would call | |
+ the `resolveTemplate` method. | |
+ | |
+ Its last resort is to call the `resolveOther` method. | |
+ | |
+ The methods of this object are designed to be easy to override | |
+ in a subclass. For example, you could enhance how a template | |
+ is resolved like so: | |
+ | |
+ ```javascript | |
+ App = Ember.Application.create({ | |
+ Resolver: Ember.DefaultResolver.extend({ | |
+ resolveTemplate: function(parsedName) { | |
+ var resolvedTemplate = this._super(parsedName); | |
+ if (resolvedTemplate) { return resolvedTemplate; } | |
+ return Ember.TEMPLATES['not_found']; | |
+ } | |
+ }) | |
+ }); | |
+ ``` | |
+ | |
+ Some examples of how names are resolved: | |
+ | |
+ ``` | |
+ 'template:post' //=> Ember.TEMPLATES['post'] | |
+ 'template:posts/byline' //=> Ember.TEMPLATES['posts/byline'] | |
+ 'template:posts.byline' //=> Ember.TEMPLATES['posts/byline'] | |
+ 'template:blogPost' //=> Ember.TEMPLATES['blogPost'] | |
+ // OR | |
+ // Ember.TEMPLATES['blog_post'] | |
+ 'controller:post' //=> App.PostController | |
+ 'controller:posts.index' //=> App.PostsIndexController | |
+ 'controller:blog/post' //=> Blog.PostController | |
+ 'controller:basic' //=> Ember.Controller | |
+ 'route:post' //=> App.PostRoute | |
+ 'route:posts.index' //=> App.PostsIndexRoute | |
+ 'route:blog/post' //=> Blog.PostRoute | |
+ 'route:basic' //=> Ember.Route | |
+ 'view:post' //=> App.PostView | |
+ 'view:posts.index' //=> App.PostsIndexView | |
+ 'view:blog/post' //=> Blog.PostView | |
+ 'view:basic' //=> Ember.View | |
+ 'foo:post' //=> App.PostFoo | |
+ 'model:post' //=> App.Post | |
+ ``` | |
+ | |
+ @class DefaultResolver | |
+ @namespace Ember | |
+ @extends Ember.Object | |
+ */ | |
exports['default'] = EmberObject['default'].extend({ | |
/** | |
This will be set to the Application instance when it is | |
created. | |
- @property namespace | |
+ | |
+ @property namespace | |
*/ | |
namespace: null, | |
- init: function () { | |
+ init: function() { | |
this._parseNameCache = dictionary['default'](null); | |
}, | |
- normalize: function (fullName) { | |
- var split = fullName.split(":", 2); | |
+ normalize: function(fullName) { | |
+ var split = fullName.split(':', 2); | |
var type = split[0]; | |
var name = split[1]; | |
- Ember['default'].assert("Tried to normalize a container name without a colon (:) in it." + " You probably tried to lookup a name that did not contain a type," + " a colon, and a name. A proper lookup name would be `view:post`.", split.length === 2); | |
+ Ember['default'].assert("Tried to normalize a container name without a colon (:) in it." + | |
+ " You probably tried to lookup a name that did not contain a type," + | |
+ " a colon, and a name. A proper lookup name would be `view:post`.", split.length === 2); | |
- if (type !== "template") { | |
+ if (type !== 'template') { | |
var result = name; | |
- if (result.indexOf(".") > -1) { | |
- result = result.replace(/\.(.)/g, function (m) { | |
+ if (result.indexOf('.') > -1) { | |
+ result = result.replace(/\.(.)/g, function(m) { | |
return m.charAt(1).toUpperCase(); | |
}); | |
} | |
- if (name.indexOf("_") > -1) { | |
- result = result.replace(/_(.)/g, function (m) { | |
+ if (name.indexOf('_') > -1) { | |
+ result = result.replace(/_(.)/g, function(m) { | |
return m.charAt(1).toUpperCase(); | |
}); | |
} | |
- return type + ":" + result; | |
+ return type + ':' + result; | |
} else { | |
return fullName; | |
} | |
}, | |
+ | |
/** | |
This method is called via the container's resolver method. | |
It parses the provided `fullName` and then looks up and | |
returns the appropriate template or class. | |
- @method resolve | |
+ | |
+ @method resolve | |
@param {String} fullName the lookup string | |
@return {Object} the resolved factory | |
*/ | |
- resolve: function (fullName) { | |
+ resolve: function(fullName) { | |
var parsedName = this.parseName(fullName); | |
var resolveMethodName = parsedName.resolveMethodName; | |
var resolved; | |
@@ -4573,36 +4915,41 @@ | |
Convert the string name of the form 'type:name' to | |
a Javascript object with the parsed aspects of the name | |
broken out. | |
- @protected | |
+ | |
+ @protected | |
@param {String} fullName the lookup string | |
@method parseName | |
*/ | |
- parseName: function (fullName) { | |
- return this._parseNameCache[fullName] || (this._parseNameCache[fullName] = this._parseName(fullName)); | |
+ parseName: function(fullName) { | |
+ return this._parseNameCache[fullName] || ( | |
+ this._parseNameCache[fullName] = this._parseName(fullName) | |
+ ); | |
}, | |
- _parseName: function (fullName) { | |
- var nameParts = fullName.split(":"); | |
+ _parseName: function(fullName) { | |
+ var nameParts = fullName.split(':'); | |
var type = nameParts[0]; | |
var fullNameWithoutType = nameParts[1]; | |
var name = fullNameWithoutType; | |
- var namespace = property_get.get(this, "namespace"); | |
+ var namespace = property_get.get(this, 'namespace'); | |
var root = namespace; | |
- if (type !== "template" && name.indexOf("/") !== -1) { | |
- var parts = name.split("/"); | |
+ if (type !== 'template' && name.indexOf('/') !== -1) { | |
+ var parts = name.split('/'); | |
name = parts[parts.length - 1]; | |
- var namespaceName = string.capitalize(parts.slice(0, -1).join(".")); | |
+ var namespaceName = string.capitalize(parts.slice(0, -1).join('.')); | |
root = Namespace['default'].byName(namespaceName); | |
- Ember['default'].assert("You are looking for a " + name + " " + type + " in the " + namespaceName + " namespace, but the namespace could not be found", root); | |
+ Ember['default'].assert('You are looking for a ' + name + ' ' + type + | |
+ ' in the ' + namespaceName + | |
+ ' namespace, but the namespace could not be found', root); | |
} | |
- var resolveMethodName = fullNameWithoutType === "main" ? "Main" : string.classify(type); | |
+ var resolveMethodName = fullNameWithoutType === 'main' ? 'Main' : string.classify(type); | |
if (!(name && type)) { | |
- throw new TypeError("Invalid fullName: `" + fullName + "`, must be of the form `type:name` "); | |
+ throw new TypeError('Invalid fullName: `' + fullName + '`, must be of the form `type:name` '); | |
} | |
return { | |
@@ -4611,7 +4958,7 @@ | |
fullNameWithoutType: fullNameWithoutType, | |
name: name, | |
root: root, | |
- resolveMethodName: "resolve" + resolveMethodName | |
+ resolveMethodName: 'resolve' + resolveMethodName | |
}; | |
}, | |
@@ -4620,54 +4967,57 @@ | |
Application namespace in assertions to describe the | |
precise name of the class that Ember is looking for, rather than | |
container keys. | |
- @protected | |
+ | |
+ @protected | |
@param {String} fullName the lookup string | |
@method lookupDescription | |
*/ | |
- lookupDescription: function (fullName) { | |
+ lookupDescription: function(fullName) { | |
var parsedName = this.parseName(fullName); | |
var description; | |
- if (parsedName.type === "template") { | |
- return "template at " + parsedName.fullNameWithoutType.replace(/\./g, "/"); | |
+ if (parsedName.type === 'template') { | |
+ return 'template at ' + parsedName.fullNameWithoutType.replace(/\./g, '/'); | |
} | |
- description = parsedName.root + "." + string.classify(parsedName.name).replace(/\./g, ""); | |
+ description = parsedName.root + '.' + string.classify(parsedName.name).replace(/\./g, ''); | |
- if (parsedName.type !== "model") { | |
+ if (parsedName.type !== 'model') { | |
description += string.classify(parsedName.type); | |
} | |
return description; | |
}, | |
- makeToString: function (factory, fullName) { | |
+ makeToString: function(factory, fullName) { | |
return factory.toString(); | |
}, | |
/** | |
Given a parseName object (output from `parseName`), apply | |
the conventions expected by `Ember.Router` | |
- @protected | |
+ | |
+ @protected | |
@param {Object} parsedName a parseName object with the parsed | |
fullName lookup string | |
@method useRouterNaming | |
*/ | |
- useRouterNaming: function (parsedName) { | |
- parsedName.name = parsedName.name.replace(/\./g, "_"); | |
- if (parsedName.name === "basic") { | |
- parsedName.name = ""; | |
+ useRouterNaming: function(parsedName) { | |
+ parsedName.name = parsedName.name.replace(/\./g, '_'); | |
+ if (parsedName.name === 'basic') { | |
+ parsedName.name = ''; | |
} | |
}, | |
/** | |
Look up the template in Ember.TEMPLATES | |
- @protected | |
+ | |
+ @protected | |
@param {Object} parsedName a parseName object with the parsed | |
fullName lookup string | |
@method resolveTemplate | |
*/ | |
- resolveTemplate: function (parsedName) { | |
- var templateName = parsedName.fullNameWithoutType.replace(/\./g, "/"); | |
+ resolveTemplate: function(parsedName) { | |
+ var templateName = parsedName.fullNameWithoutType.replace(/\./g, '/'); | |
if (Ember['default'].TEMPLATES[templateName]) { | |
return Ember['default'].TEMPLATES[templateName]; | |
@@ -4681,82 +5031,84 @@ | |
/** | |
Lookup the view using `resolveOther` | |
- @protected | |
+ | |
+ @protected | |
@param {Object} parsedName a parseName object with the parsed | |
fullName lookup string | |
@method resolveView | |
*/ | |
- resolveView: function (parsedName) { | |
+ resolveView: function(parsedName) { | |
this.useRouterNaming(parsedName); | |
return this.resolveOther(parsedName); | |
}, | |
/** | |
Lookup the controller using `resolveOther` | |
- @protected | |
+ | |
+ @protected | |
@param {Object} parsedName a parseName object with the parsed | |
fullName lookup string | |
@method resolveController | |
*/ | |
- resolveController: function (parsedName) { | |
+ resolveController: function(parsedName) { | |
this.useRouterNaming(parsedName); | |
return this.resolveOther(parsedName); | |
}, | |
/** | |
Lookup the route using `resolveOther` | |
- @protected | |
+ | |
+ @protected | |
@param {Object} parsedName a parseName object with the parsed | |
fullName lookup string | |
@method resolveRoute | |
*/ | |
- resolveRoute: function (parsedName) { | |
+ resolveRoute: function(parsedName) { | |
this.useRouterNaming(parsedName); | |
return this.resolveOther(parsedName); | |
}, | |
/** | |
Lookup the model on the Application namespace | |
- @protected | |
+ | |
+ @protected | |
@param {Object} parsedName a parseName object with the parsed | |
fullName lookup string | |
@method resolveModel | |
*/ | |
- resolveModel: function (parsedName) { | |
+ resolveModel: function(parsedName) { | |
var className = string.classify(parsedName.name); | |
var factory = property_get.get(parsedName.root, className); | |
- if (factory) { | |
- return factory; | |
- } | |
+ if (factory) { return factory; } | |
}, | |
/** | |
Look up the specified object (from parsedName) on the appropriate | |
namespace (usually on the Application) | |
- @protected | |
+ | |
+ @protected | |
@param {Object} parsedName a parseName object with the parsed | |
fullName lookup string | |
@method resolveHelper | |
*/ | |
- resolveHelper: function (parsedName) { | |
+ resolveHelper: function(parsedName) { | |
return this.resolveOther(parsedName) || helpers['default'][parsedName.fullNameWithoutType]; | |
}, | |
/** | |
Look up the specified object (from parsedName) on the appropriate | |
namespace (usually on the Application) | |
- @protected | |
+ | |
+ @protected | |
@param {Object} parsedName a parseName object with the parsed | |
fullName lookup string | |
@method resolveOther | |
*/ | |
- resolveOther: function (parsedName) { | |
+ resolveOther: function(parsedName) { | |
var className = string.classify(parsedName.name) + string.classify(parsedName.type); | |
var factory = property_get.get(parsedName.root, className); | |
- if (factory) { | |
- return factory; | |
- } | |
+ if (factory) { return factory; } | |
}, | |
- resolveMain: function (parsedName) { | |
+ resolveMain: function(parsedName) { | |
var className = string.classify(parsedName.type); | |
return property_get.get(parsedName.root, className); | |
}, | |
@@ -4767,19 +5119,19 @@ | |
@param {Object} parsedName | |
@private | |
*/ | |
- _logLookup: function (found, parsedName) { | |
+ _logLookup: function(found, parsedName) { | |
var symbol, padding; | |
if (found) { | |
- symbol = "[✓]"; | |
+ symbol = '[✓]'; | |
} else { | |
- symbol = "[ ]"; | |
+ symbol = '[ ]'; | |
} | |
if (parsedName.fullName.length > 60) { | |
- padding = "."; | |
+ padding = '.'; | |
} else { | |
- padding = new Array(60 - parsedName.fullName.length).join("."); | |
+ padding = new Array(60 - parsedName.fullName.length).join('.'); | |
} | |
Logger['default'].info(symbol, parsedName.fullName, padding, this.lookupDescription(parsedName.fullName)); | |
@@ -4795,20 +5147,12 @@ | |
exports._warnIfUsingStrippedFeatureFlags = _warnIfUsingStrippedFeatureFlags; | |
- /** | |
- Will call `Ember.warn()` if ENABLE_ALL_FEATURES, ENABLE_OPTIONAL_FEATURES, or | |
- any specific FEATURES flag is truthy. | |
- | |
- This method is called automatically in debug canary builds. | |
+ /*global __fail__*/ | |
- @private | |
- @method _warnIfUsingStrippedFeatureFlags | |
- @return {void} | |
- */ | |
- Ember['default'].assert = function (desc, test) { | |
+ Ember['default'].assert = function(desc, test) { | |
var throwAssertion; | |
- if (Ember['default'].typeOf(test) === "function") { | |
+ if (Ember['default'].typeOf(test) === 'function') { | |
throwAssertion = !test(); | |
} else { | |
throwAssertion = !test; | |
@@ -4819,6 +5163,7 @@ | |
} | |
}; | |
+ | |
/** | |
Display a warning with the provided message. Ember build tools will | |
remove any calls to `Ember.warn()` when doing a production build. | |
@@ -4828,10 +5173,10 @@ | |
@param {Boolean} test An optional boolean. If falsy, the warning | |
will be displayed. | |
*/ | |
- Ember['default'].warn = function (message, test) { | |
+ Ember['default'].warn = function(message, test) { | |
if (!test) { | |
- Logger['default'].warn("WARNING: " + message); | |
- if ("trace" in Logger['default']) { | |
+ Logger['default'].warn("WARNING: "+message); | |
+ if ('trace' in Logger['default']) { | |
Logger['default'].trace(); | |
} | |
} | |
@@ -4848,8 +5193,8 @@ | |
@method debug | |
@param {String} message A debug message to display. | |
*/ | |
- Ember['default'].debug = function (message) { | |
- Logger['default'].debug("DEBUG: " + message); | |
+ Ember['default'].debug = function(message) { | |
+ Logger['default'].debug("DEBUG: "+message); | |
}; | |
/** | |
@@ -4864,59 +5209,56 @@ | |
@param {Object} options An optional object that can be used to pass | |
in a `url` to the transition guide on the emberjs.com website. | |
*/ | |
- Ember['default'].deprecate = function (message, test, options) { | |
+ Ember['default'].deprecate = function(message, test, options) { | |
var noDeprecation; | |
- if (typeof test === "function") { | |
+ if (typeof test === 'function') { | |
noDeprecation = test(); | |
} else { | |
noDeprecation = test; | |
} | |
- if (noDeprecation) { | |
- return; | |
- } | |
+ if (noDeprecation) { return; } | |
- if (Ember['default'].ENV.RAISE_ON_DEPRECATION) { | |
- throw new EmberError['default'](message); | |
- } | |
+ if (Ember['default'].ENV.RAISE_ON_DEPRECATION) { throw new EmberError['default'](message); } | |
var error; | |
// When using new Error, we can't do the arguments check for Chrome. Alternatives are welcome | |
- try { | |
- __fail__.fail(); | |
- } catch (e) { | |
- error = e; | |
- } | |
+ try { __fail__.fail(); } catch (e) { error = e; } | |
if (arguments.length === 3) { | |
- Ember['default'].assert("options argument to Ember.deprecate should be an object", options && typeof options === "object"); | |
+ Ember['default'].assert('options argument to Ember.deprecate should be an object', options && typeof options === 'object'); | |
if (options.url) { | |
- message += " See " + options.url + " for more details."; | |
+ message += ' See ' + options.url + ' for more details.'; | |
} | |
} | |
if (Ember['default'].LOG_STACKTRACE_ON_DEPRECATION && error.stack) { | |
var stack; | |
- var stackStr = ""; | |
+ var stackStr = ''; | |
- if (error["arguments"]) { | |
+ if (error['arguments']) { | |
// Chrome | |
- stack = error.stack.replace(/^\s+at\s+/gm, "").replace(/^([^\(]+?)([\n$])/gm, "{anonymous}($1)$2").replace(/^Object.<anonymous>\s*\(([^\)]+)\)/gm, "{anonymous}($1)").split("\n"); | |
+ stack = error.stack.replace(/^\s+at\s+/gm, ''). | |
+ replace(/^([^\(]+?)([\n$])/gm, '{anonymous}($1)$2'). | |
+ replace(/^Object.<anonymous>\s*\(([^\)]+)\)/gm, '{anonymous}($1)').split('\n'); | |
stack.shift(); | |
} else { | |
// Firefox | |
- stack = error.stack.replace(/(?:\n@:0)?\s+$/m, "").replace(/^\(/gm, "{anonymous}(").split("\n"); | |
+ stack = error.stack.replace(/(?:\n@:0)?\s+$/m, ''). | |
+ replace(/^\(/gm, '{anonymous}(').split('\n'); | |
} | |
stackStr = "\n " + stack.slice(2).join("\n "); | |
message = message + stackStr; | |
} | |
- Logger['default'].warn("DEPRECATION: " + message); | |
+ Logger['default'].warn("DEPRECATION: "+message); | |
}; | |
+ | |
+ | |
/** | |
Alias an old, deprecated method with its new counterpart. | |
@@ -4935,13 +5277,14 @@ | |
@param {Function} func The new function called to replace its deprecated counterpart. | |
@return {Function} a new function that wrapped the original function with a deprecation warning | |
*/ | |
- Ember['default'].deprecateFunc = function (message, func) { | |
- return function () { | |
+ Ember['default'].deprecateFunc = function(message, func) { | |
+ return function() { | |
Ember['default'].deprecate(message); | |
return func.apply(this, arguments); | |
}; | |
}; | |
+ | |
/** | |
Run a function meant for debugging. Ember build tools will remove any calls to | |
`Ember.runInDebug()` when doing a production build. | |
@@ -4960,17 +5303,28 @@ | |
@param {Function} func The function to be executed. | |
@since 1.5.0 | |
*/ | |
- Ember['default'].runInDebug = function (func) { | |
+ Ember['default'].runInDebug = function(func) { | |
func(); | |
}; | |
+ | |
+ /** | |
+ Will call `Ember.warn()` if ENABLE_ALL_FEATURES, ENABLE_OPTIONAL_FEATURES, or | |
+ any specific FEATURES flag is truthy. | |
+ | |
+ This method is called automatically in debug canary builds. | |
+ | |
+ @private | |
+ @method _warnIfUsingStrippedFeatureFlags | |
+ @return {void} | |
+ */ | |
function _warnIfUsingStrippedFeatureFlags(FEATURES, featuresWereStripped) { | |
if (featuresWereStripped) { | |
- Ember['default'].warn("Ember.ENV.ENABLE_ALL_FEATURES is only available in canary builds.", !Ember['default'].ENV.ENABLE_ALL_FEATURES); | |
- Ember['default'].warn("Ember.ENV.ENABLE_OPTIONAL_FEATURES is only available in canary builds.", !Ember['default'].ENV.ENABLE_OPTIONAL_FEATURES); | |
+ Ember['default'].warn('Ember.ENV.ENABLE_ALL_FEATURES is only available in canary builds.', !Ember['default'].ENV.ENABLE_ALL_FEATURES); | |
+ Ember['default'].warn('Ember.ENV.ENABLE_OPTIONAL_FEATURES is only available in canary builds.', !Ember['default'].ENV.ENABLE_OPTIONAL_FEATURES); | |
for (var key in FEATURES) { | |
- if (FEATURES.hasOwnProperty(key) && key !== "isEnabled") { | |
- Ember['default'].warn("FEATURE[\"" + key + "\"] is set as enabled, but FEATURE flags are only available in canary builds.", !FEATURES[key]); | |
+ if (FEATURES.hasOwnProperty(key) && key !== 'isEnabled') { | |
+ Ember['default'].warn('FEATURE["' + key + '"] is set as enabled, but FEATURE flags are only available in canary builds.', !FEATURES[key]); | |
} | |
} | |
} | |
@@ -4978,29 +5332,29 @@ | |
if (!Ember['default'].testing) { | |
// Complain if they're using FEATURE flags in builds other than canary | |
- Ember['default'].FEATURES["features-stripped-test"] = true; | |
+ Ember['default'].FEATURES['features-stripped-test'] = true; | |
var featuresWereStripped = true; | |
- delete Ember['default'].FEATURES["features-stripped-test"]; | |
+ delete Ember['default'].FEATURES['features-stripped-test']; | |
_warnIfUsingStrippedFeatureFlags(Ember['default'].ENV.FEATURES, featuresWereStripped); | |
// Inform the developer about the Ember Inspector if not installed. | |
- var isFirefox = typeof InstallTrigger !== "undefined"; | |
+ var isFirefox = typeof InstallTrigger !== 'undefined'; | |
var isChrome = environment['default'].isChrome; | |
- if (typeof window !== "undefined" && (isFirefox || isChrome) && window.addEventListener) { | |
- window.addEventListener("load", function () { | |
+ if (typeof window !== 'undefined' && (isFirefox || isChrome) && window.addEventListener) { | |
+ window.addEventListener("load", function() { | |
if (document.documentElement && document.documentElement.dataset && !document.documentElement.dataset.emberExtension) { | |
var downloadURL; | |
if (isChrome) { | |
- downloadURL = "https://chrome.google.com/webstore/detail/ember-inspector/bmdblncegkenkacieihfhpjfppoconhi"; | |
+ downloadURL = 'https://chrome.google.com/webstore/detail/ember-inspector/bmdblncegkenkacieihfhpjfppoconhi'; | |
} else if (isFirefox) { | |
- downloadURL = "https://addons.mozilla.org/en-US/firefox/addon/ember-inspector/"; | |
+ downloadURL = 'https://addons.mozilla.org/en-US/firefox/addon/ember-inspector/'; | |
} | |
- Ember['default'].debug("For more advanced debugging, install the Ember Inspector from " + downloadURL); | |
+ Ember['default'].debug('For more advanced debugging, install the Ember Inspector from ' + downloadURL); | |
} | |
}, false); | |
} | |
@@ -5016,7 +5370,7 @@ | |
*/ | |
var runningNonEmberDebugJS = false; | |
if (runningNonEmberDebugJS) { | |
- Ember['default'].warn("Please use `ember.debug.js` instead of `ember.js` for development and debugging."); | |
+ Ember['default'].warn('Please use `ember.debug.js` instead of `ember.js` for development and debugging.'); | |
} | |
exports.runningNonEmberDebugJS = runningNonEmberDebugJS; | |
@@ -5047,7 +5401,8 @@ | |
The container of the application being debugged. | |
This property will be injected | |
on creation. | |
- @property container | |
+ | |
+ @property container | |
@default null | |
*/ | |
container: null, | |
@@ -5056,7 +5411,8 @@ | |
The resolver instance of the application | |
being debugged. This property will be injected | |
on creation. | |
- @property resolver | |
+ | |
+ @property resolver | |
@default null | |
*/ | |
resolver: null, | |
@@ -5064,12 +5420,13 @@ | |
/** | |
Returns true if it is possible to catalog a list of available | |
classes in the resolver for a given type. | |
- @method canCatalogEntriesByType | |
+ | |
+ @method canCatalogEntriesByType | |
@param {String} type The type. e.g. "model", "controller", "route" | |
@return {boolean} whether a list is available for this type. | |
*/ | |
- canCatalogEntriesByType: function (type) { | |
- if (type === "model" || type === "template") { | |
+ canCatalogEntriesByType: function(type) { | |
+ if (type === 'model' || type === 'template') { | |
return false; | |
} | |
@@ -5078,25 +5435,24 @@ | |
/** | |
Returns the available classes a given type. | |
- @method catalogEntriesByType | |
+ | |
+ @method catalogEntriesByType | |
@param {String} type The type. e.g. "model", "controller", "route" | |
@return {Array} An array of strings. | |
*/ | |
- catalogEntriesByType: function (type) { | |
+ catalogEntriesByType: function(type) { | |
var namespaces = native_array.A(Namespace['default'].NAMESPACES); | |
var types = native_array.A(); | |
var typeSuffixRegex = new RegExp(string.classify(type) + "$"); | |
- namespaces.forEach(function (namespace) { | |
+ namespaces.forEach(function(namespace) { | |
if (namespace !== Ember['default']) { | |
for (var key in namespace) { | |
- if (!namespace.hasOwnProperty(key)) { | |
- continue; | |
- } | |
+ if (!namespace.hasOwnProperty(key)) { continue; } | |
if (typeSuffixRegex.test(key)) { | |
var klass = namespace[key]; | |
- if (utils.typeOf(klass) === "class") { | |
- types.push(string.dasherize(key.replace(typeSuffixRegex, ""))); | |
+ if (utils.typeOf(klass) === 'class') { | |
+ types.push(string.dasherize(key.replace(typeSuffixRegex, ''))); | |
} | |
} | |
} | |
@@ -5112,7 +5468,7 @@ | |
'use strict'; | |
exports['default'] = EmberObject['default'].extend({ | |
- init: function () { | |
+ init: function() { | |
this._super.apply(this, arguments); | |
this.releaseMethods = native_array.A(); | |
}, | |
@@ -5121,16 +5477,19 @@ | |
The container of the application being debugged. | |
This property will be injected | |
on creation. | |
- @property container | |
+ | |
+ @property container | |
@default null | |
@since 1.3.0 | |
*/ | |
container: null, | |
+ | |
/** | |
The container-debug-adapter which is used | |
to list all models. | |
- @property containerDebugAdapter | |
+ | |
+ @property containerDebugAdapter | |
@default undefined | |
@since 1.5.0 | |
**/ | |
@@ -5140,7 +5499,8 @@ | |
Number of attributes to send | |
as columns. (Enough to make the record | |
identifiable). | |
- @private | |
+ | |
+ @private | |
@property attributeLimit | |
@default 3 | |
@since 1.3.0 | |
@@ -5150,7 +5510,8 @@ | |
/** | |
Stores all methods that clear observers. | |
These methods will be called on destruction. | |
- @private | |
+ | |
+ @private | |
@property releaseMethods | |
@since 1.3.0 | |
*/ | |
@@ -5160,32 +5521,37 @@ | |
Specifies how records can be filtered. | |
Records returned will need to have a `filterValues` | |
property with a key for every name in the returned array. | |
- @public | |
+ | |
+ @public | |
@method getFilters | |
@return {Array} List of objects defining filters. | |
The object should have a `name` and `desc` property. | |
*/ | |
- getFilters: function () { | |
+ getFilters: function() { | |
return native_array.A(); | |
}, | |
/** | |
Fetch the model types and observe them for changes. | |
- @public | |
+ | |
+ @public | |
@method watchModelTypes | |
- @param {Function} typesAdded Callback to call to add types. | |
+ | |
+ @param {Function} typesAdded Callback to call to add types. | |
Takes an array of objects containing wrapped types (returned from `wrapModelType`). | |
- @param {Function} typesUpdated Callback to call when a type has changed. | |
+ | |
+ @param {Function} typesUpdated Callback to call when a type has changed. | |
Takes an array of objects containing wrapped types. | |
- @return {Function} Method to call to remove all observers | |
+ | |
+ @return {Function} Method to call to remove all observers | |
*/ | |
- watchModelTypes: function (typesAdded, typesUpdated) { | |
+ watchModelTypes: function(typesAdded, typesUpdated) { | |
var modelTypes = this.getModelTypes(); | |
var self = this; | |
var releaseMethods = native_array.A(); | |
var typesToSend; | |
- typesToSend = modelTypes.map(function (type) { | |
+ typesToSend = modelTypes.map(function(type) { | |
var klass = type.klass; | |
var wrapped = self.wrapModelType(klass, type.name); | |
releaseMethods.push(self.observeModelType(klass, typesUpdated)); | |
@@ -5194,56 +5560,60 @@ | |
typesAdded(typesToSend); | |
- var release = function () { | |
- releaseMethods.forEach(function (fn) { | |
- fn(); | |
- }); | |
+ var release = function() { | |
+ releaseMethods.forEach(function(fn) { fn(); }); | |
self.releaseMethods.removeObject(release); | |
}; | |
this.releaseMethods.pushObject(release); | |
return release; | |
}, | |
- _nameToClass: function (type) { | |
- if (typeof type === "string") { | |
- type = this.container.lookupFactory("model:" + type); | |
+ _nameToClass: function(type) { | |
+ if (typeof type === 'string') { | |
+ type = this.container.lookupFactory('model:' + type); | |
} | |
return type; | |
}, | |
/** | |
Fetch the records of a given type and observe them for changes. | |
- @public | |
+ | |
+ @public | |
@method watchRecords | |
- @param {Function} recordsAdded Callback to call to add records. | |
+ | |
+ @param {Function} recordsAdded Callback to call to add records. | |
Takes an array of objects containing wrapped records. | |
The object should have the following properties: | |
columnValues: {Object} key and value of a table cell | |
object: {Object} the actual record object | |
- @param {Function} recordsUpdated Callback to call when a record has changed. | |
+ | |
+ @param {Function} recordsUpdated Callback to call when a record has changed. | |
Takes an array of objects containing wrapped records. | |
- @param {Function} recordsRemoved Callback to call when a record has removed. | |
+ | |
+ @param {Function} recordsRemoved Callback to call when a record has removed. | |
Takes the following parameters: | |
index: the array index where the records were removed | |
count: the number of records removed | |
- @return {Function} Method to call to remove all observers | |
+ | |
+ @return {Function} Method to call to remove all observers | |
*/ | |
- watchRecords: function (type, recordsAdded, recordsUpdated, recordsRemoved) { | |
+ watchRecords: function(type, recordsAdded, recordsUpdated, recordsRemoved) { | |
var self = this; | |
var releaseMethods = native_array.A(); | |
var records = this.getRecords(type); | |
var release; | |
- var recordUpdated = function (updatedRecord) { | |
+ var recordUpdated = function(updatedRecord) { | |
recordsUpdated([updatedRecord]); | |
}; | |
- var recordsToSend = records.map(function (record) { | |
+ var recordsToSend = records.map(function(record) { | |
releaseMethods.push(self.observeRecord(record, recordUpdated)); | |
return self.wrapRecord(record); | |
}); | |
- var contentDidChange = function (array, idx, removedCount, addedCount) { | |
+ | |
+ var contentDidChange = function(array, idx, removedCount, addedCount) { | |
for (var i = idx; i < idx + addedCount; i++) { | |
var record = array.objectAt(i); | |
var wrapped = self.wrapRecord(record); | |
@@ -5256,15 +5626,11 @@ | |
} | |
}; | |
- var observer = { didChange: contentDidChange, willChange: function () { | |
- return this; | |
- } }; | |
+ var observer = { didChange: contentDidChange, willChange: function() { return this; } }; | |
records.addArrayObserver(self, observer); | |
- release = function () { | |
- releaseMethods.forEach(function (fn) { | |
- fn(); | |
- }); | |
+ release = function() { | |
+ releaseMethods.forEach(function(fn) { fn(); }); | |
records.removeArrayObserver(self, observer); | |
self.releaseMethods.removeObject(release); | |
}; | |
@@ -5280,76 +5646,80 @@ | |
@private | |
@method willDestroy | |
*/ | |
- willDestroy: function () { | |
+ willDestroy: function() { | |
this._super.apply(this, arguments); | |
- this.releaseMethods.forEach(function (fn) { | |
+ this.releaseMethods.forEach(function(fn) { | |
fn(); | |
}); | |
}, | |
/** | |
Detect whether a class is a model. | |
- Test that against the model class | |
+ | |
+ Test that against the model class | |
of your persistence library | |
- @private | |
+ | |
+ @private | |
@method detect | |
@param {Class} klass The class to test | |
@return boolean Whether the class is a model class or not | |
*/ | |
- detect: function (klass) { | |
+ detect: function(klass) { | |
return false; | |
}, | |
/** | |
Get the columns for a given model type. | |
- @private | |
+ | |
+ @private | |
@method columnsForType | |
@param {Class} type The model type | |
@return {Array} An array of columns of the following format: | |
name: {String} name of the column | |
desc: {String} Humanized description (what would show in a table column name) | |
*/ | |
- columnsForType: function (type) { | |
+ columnsForType: function(type) { | |
return native_array.A(); | |
}, | |
/** | |
Adds observers to a model type class. | |
- @private | |
+ | |
+ @private | |
@method observeModelType | |
@param {Class} type The model type class | |
@param {Function} typesUpdated Called when a type is modified. | |
@return {Function} The function to call to remove observers | |
*/ | |
- observeModelType: function (type, typesUpdated) { | |
+ observeModelType: function(type, typesUpdated) { | |
var self = this; | |
var records = this.getRecords(type); | |
- var onChange = function () { | |
+ var onChange = function() { | |
typesUpdated([self.wrapModelType(type)]); | |
}; | |
var observer = { | |
- didChange: function () { | |
- run['default'].scheduleOnce("actions", this, onChange); | |
+ didChange: function() { | |
+ run['default'].scheduleOnce('actions', this, onChange); | |
}, | |
- willChange: function () { | |
- return this; | |
- } | |
+ willChange: function() { return this; } | |
}; | |
records.addArrayObserver(this, observer); | |
- var release = function () { | |
+ var release = function() { | |
records.removeArrayObserver(self, observer); | |
}; | |
return release; | |
}, | |
+ | |
/** | |
Wraps a given model type and observes changes to it. | |
- @private | |
+ | |
+ @private | |
@method wrapModelType | |
@param {Class} type A model class | |
@param {String} Optional name of the class | |
@@ -5363,45 +5733,48 @@ | |
object: {Class} the actual Model type class | |
release: {Function} The function to remove observers | |
*/ | |
- wrapModelType: function (type, name) { | |
+ wrapModelType: function(type, name) { | |
var records = this.getRecords(type); | |
var typeToSend; | |
typeToSend = { | |
name: name || type.toString(), | |
- count: property_get.get(records, "length"), | |
+ count: property_get.get(records, 'length'), | |
columns: this.columnsForType(type), | |
object: type | |
}; | |
+ | |
return typeToSend; | |
}, | |
+ | |
/** | |
Fetches all models defined in the application. | |
- @private | |
+ | |
+ @private | |
@method getModelTypes | |
@return {Array} Array of model types | |
*/ | |
- getModelTypes: function () { | |
+ getModelTypes: function() { | |
var self = this; | |
- var containerDebugAdapter = this.get("containerDebugAdapter"); | |
+ var containerDebugAdapter = this.get('containerDebugAdapter'); | |
var types; | |
- if (containerDebugAdapter.canCatalogEntriesByType("model")) { | |
- types = containerDebugAdapter.catalogEntriesByType("model"); | |
+ if (containerDebugAdapter.canCatalogEntriesByType('model')) { | |
+ types = containerDebugAdapter.catalogEntriesByType('model'); | |
} else { | |
types = this._getObjectsOnNamespaces(); | |
} | |
// New adapters return strings instead of classes | |
- types = native_array.A(types).map(function (name) { | |
+ types = native_array.A(types).map(function(name) { | |
return { | |
klass: self._nameToClass(name), | |
name: name | |
}; | |
}); | |
- types = native_array.A(types).filter(function (type) { | |
+ types = native_array.A(types).filter(function(type) { | |
return self.detect(type.klass); | |
}); | |
@@ -5411,29 +5784,26 @@ | |
/** | |
Loops over all namespaces and all objects | |
attached to them | |
- @private | |
+ | |
+ @private | |
@method _getObjectsOnNamespaces | |
@return {Array} Array of model type strings | |
*/ | |
- _getObjectsOnNamespaces: function () { | |
+ _getObjectsOnNamespaces: function() { | |
var namespaces = native_array.A(Namespace['default'].NAMESPACES); | |
var types = native_array.A(); | |
var self = this; | |
- namespaces.forEach(function (namespace) { | |
+ namespaces.forEach(function(namespace) { | |
for (var key in namespace) { | |
- if (!namespace.hasOwnProperty(key)) { | |
- continue; | |
- } | |
+ if (!namespace.hasOwnProperty(key)) { continue; } | |
// Even though we will filter again in `getModelTypes`, | |
// we should not call `lookupContainer` on non-models | |
// (especially when `Ember.MODEL_FACTORY_INJECTIONS` is `true`) | |
- if (!self.detect(namespace[key])) { | |
- continue; | |
- } | |
+ if (!self.detect(namespace[key])) { continue; } | |
var name = string.dasherize(key); | |
if (!(namespace instanceof Application['default']) && namespace.toString()) { | |
- name = namespace + "/" + name; | |
+ name = namespace + '/' + name; | |
} | |
types.push(name); | |
} | |
@@ -5443,26 +5813,28 @@ | |
/** | |
Fetches all loaded records for a given type. | |
- @private | |
+ | |
+ @private | |
@method getRecords | |
@return {Array} An array of records. | |
This array will be observed for changes, | |
so it should update when new records are added/removed. | |
*/ | |
- getRecords: function (type) { | |
+ getRecords: function(type) { | |
return native_array.A(); | |
}, | |
/** | |
Wraps a record and observers changes to it. | |
- @private | |
+ | |
+ @private | |
@method wrapRecord | |
@param {Object} record The record instance. | |
@return {Object} The wrapped record. Format: | |
columnValues: {Array} | |
searchKeywords: {Array} | |
*/ | |
- wrapRecord: function (record) { | |
+ wrapRecord: function(record) { | |
var recordToSend = { object: record }; | |
recordToSend.columnValues = this.getRecordColumnValues(record); | |
@@ -5475,59 +5847,64 @@ | |
/** | |
Gets the values for each column. | |
- @private | |
+ | |
+ @private | |
@method getRecordColumnValues | |
@return {Object} Keys should match column names defined | |
by the model type. | |
*/ | |
- getRecordColumnValues: function (record) { | |
+ getRecordColumnValues: function(record) { | |
return {}; | |
}, | |
/** | |
Returns keywords to match when searching records. | |
- @private | |
+ | |
+ @private | |
@method getRecordKeywords | |
@return {Array} Relevant keywords for search. | |
*/ | |
- getRecordKeywords: function (record) { | |
+ getRecordKeywords: function(record) { | |
return native_array.A(); | |
}, | |
/** | |
Returns the values of filters defined by `getFilters`. | |
- @private | |
+ | |
+ @private | |
@method getRecordFilterValues | |
@param {Object} record The record instance | |
@return {Object} The filter values | |
*/ | |
- getRecordFilterValues: function (record) { | |
+ getRecordFilterValues: function(record) { | |
return {}; | |
}, | |
/** | |
Each record can have a color that represents its state. | |
- @private | |
+ | |
+ @private | |
@method getRecordColor | |
@param {Object} record The record instance | |
@return {String} The record's color | |
Possible options: black, red, blue, green | |
*/ | |
- getRecordColor: function (record) { | |
+ getRecordColor: function(record) { | |
return null; | |
}, | |
/** | |
Observes all relevant properties and re-sends the wrapped record | |
when a change occurs. | |
- @private | |
+ | |
+ @private | |
@method observerRecord | |
@param {Object} record The record instance | |
@param {Function} recordUpdated The callback to call when a record is updated. | |
@return {Function} The function to call to remove all observers. | |
*/ | |
- observeRecord: function (record, recordUpdated) { | |
- return function () {}; | |
+ observeRecord: function(record, recordUpdated) { | |
+ return function() {}; | |
} | |
}); | |
@@ -5536,26 +5913,26 @@ | |
'use strict'; | |
- helpers.registerHelper("view", view.viewHelper); | |
+ helpers.registerHelper('view', view.viewHelper); | |
- helpers.registerHelper("component", component.componentHelper); | |
+ helpers.registerHelper('component', component.componentHelper); | |
- helpers.registerHelper("yield", _yield.yieldHelper); | |
- helpers.registerHelper("with", _with.withHelper); | |
- helpers.registerHelper("if", if_unless.ifHelper); | |
- helpers.registerHelper("unless", if_unless.unlessHelper); | |
- helpers.registerHelper("log", log.logHelper); | |
- helpers.registerHelper("debugger", _debugger.debuggerHelper); | |
- helpers.registerHelper("loc", loc.locHelper); | |
- helpers.registerHelper("partial", partial.partialHelper); | |
- helpers.registerHelper("template", template.templateHelper); | |
- helpers.registerHelper("bind-attr", bind_attr.bindAttrHelper); | |
- helpers.registerHelper("bindAttr", bind_attr.bindAttrHelperDeprecated); | |
- helpers.registerHelper("input", input.inputHelper); | |
- helpers.registerHelper("textarea", text_area.textareaHelper); | |
- helpers.registerHelper("collection", collection.collectionHelper); | |
- helpers.registerHelper("each", each.eachHelper); | |
- helpers.registerHelper("unbound", unbound.unboundHelper); | |
+ helpers.registerHelper('yield', _yield.yieldHelper); | |
+ helpers.registerHelper('with', _with.withHelper); | |
+ helpers.registerHelper('if', if_unless.ifHelper); | |
+ helpers.registerHelper('unless', if_unless.unlessHelper); | |
+ helpers.registerHelper('log', log.logHelper); | |
+ helpers.registerHelper('debugger', _debugger.debuggerHelper); | |
+ helpers.registerHelper('loc', loc.locHelper); | |
+ helpers.registerHelper('partial', partial.partialHelper); | |
+ helpers.registerHelper('template', template.templateHelper); | |
+ helpers.registerHelper('bind-attr', bind_attr.bindAttrHelper); | |
+ helpers.registerHelper('bindAttr', bind_attr.bindAttrHelperDeprecated); | |
+ helpers.registerHelper('input', input.inputHelper); | |
+ helpers.registerHelper('textarea', text_area.textareaHelper); | |
+ helpers.registerHelper('collection', collection.collectionHelper); | |
+ helpers.registerHelper('each', each.eachHelper); | |
+ helpers.registerHelper('unbound', unbound.unboundHelper); | |
Ember['default'].HTMLBars = { | |
_registerHelper: helpers.registerHelper, | |
@@ -5582,7 +5959,7 @@ | |
EmberHandlebars.makeViewHelper = makeViewHelper['default']; | |
EmberHandlebars.SafeString = string.SafeString; | |
- EmberHandlebars.Utils = { | |
+ EmberHandlebars.Utils = { | |
escapeExpression: string.escapeExpression | |
}; | |
@@ -5610,13 +5987,12 @@ | |
@param {Object} options The template's option hash | |
@deprecated | |
*/ | |
- exports['default'] = handlebarsGet; | |
- | |
function handlebarsGet(root, path, options) { | |
- Ember.deprecate("Usage of Ember.Handlebars.get is deprecated, use a Component or Ember.Handlebars.makeBoundHelper instead."); | |
+ Ember.deprecate('Usage of Ember.Handlebars.get is deprecated, use a Component or Ember.Handlebars.makeBoundHelper instead.'); | |
return options.data.view.getStream(path).value(); | |
} | |
+ exports['default'] = handlebarsGet; | |
}); | |
enifed('ember-htmlbars/compat/helper', ['exports', 'ember-metal/merge', 'ember-htmlbars/helpers', 'ember-views/views/view', 'ember-views/views/component', 'ember-htmlbars/system/make-view-helper', 'ember-htmlbars/compat/make-bound-helper', 'ember-metal/streams/utils'], function (exports, merge, helpers, View, Component, makeViewHelper, makeBoundHelper, utils) { | |
@@ -5626,11 +6002,16 @@ | |
exports.registerHandlebarsCompatibleHelper = registerHandlebarsCompatibleHelper; | |
exports.handlebarsHelper = handlebarsHelper; | |
+ /** | |
+ @module ember | |
+ @submodule ember-htmlbars | |
+ */ | |
+ | |
var slice = [].slice; | |
function calculateCompatType(item) { | |
if (utils.isStream(item)) { | |
- return "ID"; | |
+ return 'ID'; | |
} else { | |
var itemType = typeof item; | |
@@ -5650,9 +6031,9 @@ | |
var param, blockResult, fnResult; | |
var context = env.data.view; | |
var handlebarsOptions = { | |
- hash: {}, | |
+ hash: { }, | |
types: new Array(params.length), | |
- hashTypes: {} | |
+ hashTypes: { } | |
}; | |
merge['default'](handlebarsOptions, options); | |
@@ -5661,12 +6042,12 @@ | |
handlebarsOptions.hash = {}; | |
if (options.isBlock) { | |
- handlebarsOptions.fn = function () { | |
+ handlebarsOptions.fn = function() { | |
blockResult = options.template.render(context, env, options.morph.contextualElement); | |
}; | |
if (options.inverse) { | |
- handlebarsOptions.inverse = function () { | |
+ handlebarsOptions.inverse = function() { | |
blockResult = options.inverse.render(context, env, options.morph.contextualElement); | |
}; | |
} | |
@@ -5707,8 +6088,9 @@ | |
} | |
HandlebarsCompatibleHelper.prototype = { | |
- preprocessArguments: function () {} | |
+ preprocessArguments: function() { } | |
}; | |
+ | |
function registerHandlebarsCompatibleHelper(name, value) { | |
var helper; | |
@@ -5722,7 +6104,8 @@ | |
} | |
function handlebarsHelper(name, value) { | |
- Ember.assert("You tried to register a component named '" + name + "', but component names must include a '-'", !Component['default'].detect(value) || name.match(/-/)); | |
+ Ember.assert("You tried to register a component named '" + name + | |
+ "', but component names must include a '-'", !Component['default'].detect(value) || name.match(/-/)); | |
if (View['default'].detect(value)) { | |
helpers['default'][name] = makeViewHelper['default'](value); | |
@@ -5741,35 +6124,6 @@ | |
'use strict'; | |
- | |
- | |
- /** | |
- A helper function used by `registerBoundHelper`. Takes the | |
- provided Handlebars helper function fn and returns it in wrapped | |
- bound helper form. | |
- | |
- The main use case for using this outside of `registerBoundHelper` | |
- is for registering helpers on the container: | |
- | |
- ```js | |
- var boundHelperFn = Ember.Handlebars.makeBoundHelper(function(word) { | |
- return word.toUpperCase(); | |
- }); | |
- | |
- container.register('helper:my-bound-helper', boundHelperFn); | |
- ``` | |
- | |
- In the above example, if the helper function hadn't been wrapped in | |
- `makeBoundHelper`, the registered helper would be unbound. | |
- | |
- @method makeBoundHelper | |
- @for Ember.Handlebars | |
- @param {Function} function | |
- @param {String} dependentKeys* | |
- @since 1.2.0 | |
- @deprecated | |
- */ | |
- exports['default'] = makeBoundHelper; | |
/** | |
@module ember | |
@submodule ember-htmlbars | |
@@ -5860,13 +6214,19 @@ | |
return new Helper['default'](helperFunc); | |
} | |
+ exports['default'] = makeBoundHelper; | |
}); | |
enifed('ember-htmlbars/compat/register-bound-helper', ['exports', 'ember-htmlbars/helpers', 'ember-htmlbars/compat/make-bound-helper'], function (exports, helpers, makeBoundHelper) { | |
'use strict'; | |
+ /** | |
+ @module ember | |
+ @submodule ember-htmlbars | |
+ */ | |
+ var slice = [].slice; | |
/** | |
Register a bound handlebars helper. Bound helpers behave similarly to regular | |
@@ -5977,19 +6337,13 @@ | |
@param {Function} function | |
@param {String} dependentKeys* | |
*/ | |
- exports['default'] = registerBoundHelper; | |
- /** | |
- @module ember | |
- @submodule ember-htmlbars | |
- */ | |
- | |
- var slice = [].slice; | |
function registerBoundHelper(name, fn) { | |
var boundHelperArgs = slice.call(arguments, 1); | |
var boundFn = makeBoundHelper['default'].apply(this, boundHelperArgs); | |
helpers['default'][name] = boundFn; | |
} | |
+ exports['default'] = registerBoundHelper; | |
}); | |
enifed('ember-htmlbars/env', ['exports', 'ember-metal/environment', 'dom-helper', 'ember-htmlbars/hooks/inline', 'ember-htmlbars/hooks/content', 'ember-htmlbars/hooks/component', 'ember-htmlbars/hooks/block', 'ember-htmlbars/hooks/element', 'ember-htmlbars/hooks/subexpr', 'ember-htmlbars/hooks/attribute', 'ember-htmlbars/hooks/concat', 'ember-htmlbars/hooks/get', 'ember-htmlbars/hooks/set', 'ember-htmlbars/helpers'], function (exports, environment, DOMHelper, inline, content, component, block, element, subexpr, attribute, concat, get, set, helpers) { | |
@@ -6027,12 +6381,10 @@ | |
exports.registerHelper = registerHelper; | |
/** | |
- @private | |
- @method _registerHelper | |
- @for Ember.HTMLBars | |
- @param {String} name | |
- @param {Object|Function} helperFunc the helper function to add | |
+ @module ember | |
+ @submodule ember-htmlbars | |
*/ | |
+ | |
var helpers = o_create['default'](null); | |
/** | |
@@ -6075,16 +6427,20 @@ | |
var view = env.data.view; | |
// Handle classes differently, as we can bind multiple classes | |
- var classNameBindings = hash["class"]; | |
+ var classNameBindings = hash['class']; | |
if (classNameBindings !== null && classNameBindings !== undefined) { | |
if (!utils.isStream(classNameBindings)) { | |
classNameBindings = applyClassNameBindings(classNameBindings, view); | |
} | |
- var classView = new AttrNode['default']("class", classNameBindings); | |
- classView._morph = env.dom.createAttrMorph(element, "class"); | |
+ var classView = new AttrNode['default']('class', classNameBindings); | |
+ classView._morph = env.dom.createAttrMorph(element, 'class'); | |
- Ember['default'].assert("You cannot set `class` manually and via `{{bind-attr}}` helper on the same element. " + "Please use `{{bind-attr}}`'s `:static-class` syntax instead.", !element.getAttribute("class")); | |
+ Ember['default'].assert( | |
+ 'You cannot set `class` manually and via `{{bind-attr}}` helper on the same element. ' + | |
+ 'Please use `{{bind-attr}}`\'s `:static-class` syntax instead.', | |
+ !element.getAttribute('class') | |
+ ); | |
view.appendChild(classView); | |
} | |
@@ -6092,34 +6448,41 @@ | |
var attrKeys = keys['default'](hash); | |
var attr, path, lazyValue, attrView; | |
- for (var i = 0, l = attrKeys.length; i < l; i++) { | |
+ for (var i=0, l=attrKeys.length;i<l;i++) { | |
attr = attrKeys[i]; | |
- if (attr === "class") { | |
+ if (attr === 'class') { | |
continue; | |
} | |
path = hash[attr]; | |
if (utils.isStream(path)) { | |
lazyValue = path; | |
} else { | |
- Ember['default'].assert(string.fmt("You must provide an expression as the value of bound attribute." + " You specified: %@=%@", [attr, path]), typeof path === "string"); | |
+ Ember['default'].assert( | |
+ string.fmt("You must provide an expression as the value of bound attribute." + | |
+ " You specified: %@=%@", [attr, path]), | |
+ typeof path === 'string' | |
+ ); | |
lazyValue = view.getStream(path); | |
} | |
attrView = new LegacyBindAttrNode['default'](attr, lazyValue); | |
attrView._morph = env.dom.createAttrMorph(element, attr); | |
- Ember['default'].assert("You cannot set `" + attr + "` manually and via `{{bind-attr}}` helper on the same element.", !element.getAttribute(attr)); | |
+ Ember['default'].assert( | |
+ 'You cannot set `' + attr + '` manually and via `{{bind-attr}}` helper on the same element.', | |
+ !element.getAttribute(attr) | |
+ ); | |
view.appendChild(attrView); | |
} | |
} | |
function applyClassNameBindings(classNameBindings, view) { | |
- var arrayOfClassNameBindings = classNameBindings.split(" "); | |
- var boundClassNameBindings = enumerable_utils.map(arrayOfClassNameBindings, function (classNameBinding) { | |
+ var arrayOfClassNameBindings = classNameBindings.split(' '); | |
+ var boundClassNameBindings = enumerable_utils.map(arrayOfClassNameBindings, function(classNameBinding) { | |
return class_name_binding.streamifyClassNameBinding(view, classNameBinding); | |
}); | |
- var concatenatedClassNames = utils.concat(boundClassNameBindings, " "); | |
+ var concatenatedClassNames = utils.concat(boundClassNameBindings, ' '); | |
return concatenatedClassNames; | |
} | |
@@ -6136,7 +6499,7 @@ | |
function bindAttrHelperDeprecated() { | |
Ember['default'].deprecate("The 'bindAttr' view helper is deprecated in favor of 'bind-attr'"); | |
- return helpers['default']["bind-attr"].helperFunction.apply(this, arguments); | |
+ return helpers['default']['bind-attr'].helperFunction.apply(this, arguments); | |
} | |
exports['default'] = bindAttrHelper; | |
@@ -6149,144 +6512,30 @@ | |
exports.collectionHelper = collectionHelper; | |
/** | |
- `{{collection}}` is a `Ember.Handlebars` helper for adding instances of | |
- `Ember.CollectionView` to a template. See [Ember.CollectionView](/api/classes/Ember.CollectionView.html) | |
- for additional information on how a `CollectionView` functions. | |
- | |
- `{{collection}}`'s primary use is as a block helper with a `contentBinding` | |
- option pointing towards an `Ember.Array`-compatible object. An `Ember.View` | |
- instance will be created for each item in its `content` property. Each view | |
- will have its own `content` property set to the appropriate item in the | |
- collection. | |
- | |
- The provided block will be applied as the template for each item's view. | |
- | |
- Given an empty `<body>` the following template: | |
- | |
- ```handlebars | |
- {{! application.hbs }} | |
- {{#collection content=model}} | |
- Hi {{view.content.name}} | |
- {{/collection}} | |
- ``` | |
- | |
- And the following application code | |
- | |
- ```javascript | |
- App = Ember.Application.create(); | |
- App.ApplicationRoute = Ember.Route.extend({ | |
- model: function() { | |
- return [{name: 'Yehuda'},{name: 'Tom'},{name: 'Peter'}]; | |
- } | |
- }); | |
- ``` | |
- | |
- The following HTML will result: | |
- | |
- ```html | |
- <div class="ember-view"> | |
- <div class="ember-view">Hi Yehuda</div> | |
- <div class="ember-view">Hi Tom</div> | |
- <div class="ember-view">Hi Peter</div> | |
- </div> | |
- ``` | |
- | |
- ### Non-block version of collection | |
- | |
- If you provide an `itemViewClass` option that has its own `template` you may | |
- omit the block. | |
- | |
- The following template: | |
- | |
- ```handlebars | |
- {{! application.hbs }} | |
- {{collection content=model itemViewClass="an-item"}} | |
- ``` | |
- | |
- And application code | |
- | |
- ```javascript | |
- App = Ember.Application.create(); | |
- App.ApplicationRoute = Ember.Route.extend({ | |
- model: function() { | |
- return [{name: 'Yehuda'},{name: 'Tom'},{name: 'Peter'}]; | |
- } | |
- }); | |
- | |
- App.AnItemView = Ember.View.extend({ | |
- template: Ember.Handlebars.compile("Greetings {{view.content.name}}") | |
- }); | |
- ``` | |
- | |
- Will result in the HTML structure below | |
- | |
- ```html | |
- <div class="ember-view"> | |
- <div class="ember-view">Greetings Yehuda</div> | |
- <div class="ember-view">Greetings Tom</div> | |
- <div class="ember-view">Greetings Peter</div> | |
- </div> | |
- ``` | |
- | |
- ### Specifying a CollectionView subclass | |
- | |
- By default the `{{collection}}` helper will create an instance of | |
- `Ember.CollectionView`. You can supply a `Ember.CollectionView` subclass to | |
- the helper by passing it as the first argument: | |
- | |
- ```handlebars | |
- {{#collection "my-custom-collection" content=model}} | |
- Hi {{view.content.name}} | |
- {{/collection}} | |
- ``` | |
- | |
- This example would look for the class `App.MyCustomCollection`. | |
- | |
- ### Forwarded `item.*`-named Options | |
- | |
- As with the `{{view}}`, helper options passed to the `{{collection}}` will be | |
- set on the resulting `Ember.CollectionView` as properties. Additionally, | |
- options prefixed with `item` will be applied to the views rendered for each | |
- item (note the camelcasing): | |
- | |
- ```handlebars | |
- {{#collection content=model | |
- itemTagName="p" | |
- itemClassNames="greeting"}} | |
- Howdy {{view.content.name}} | |
- {{/collection}} | |
- ``` | |
- | |
- Will result in the following HTML structure: | |
- | |
- ```html | |
- <div class="ember-view"> | |
- <p class="ember-view greeting">Howdy Yehuda</p> | |
- <p class="ember-view greeting">Howdy Tom</p> | |
- <p class="ember-view greeting">Howdy Peter</p> | |
- </div> | |
- ``` | |
- | |
- @method collection | |
- @for Ember.Handlebars.helpers | |
- @deprecated Use `{{each}}` helper instead. | |
+ @module ember | |
+ @submodule ember-htmlbars | |
*/ | |
+ | |
function collectionHelper(params, hash, options, env) { | |
var path = params[0]; | |
- Ember['default'].deprecate("Using the {{collection}} helper without specifying a class has been" + " deprecated as the {{each}} helper now supports the same functionality.", path !== "collection"); | |
+ Ember['default'].deprecate( | |
+ "Using the {{collection}} helper without specifying a class has been" + | |
+ " deprecated as the {{each}} helper now supports the same functionality.", | |
+ path !== 'collection' | |
+ ); | |
Ember['default'].assert("You cannot pass more than one argument to the collection helper", params.length <= 1); | |
- var data = env.data; | |
+ var data = env.data; | |
var template = options.template; | |
- var inverse = options.inverse; | |
- var view = data.view; | |
+ var inverse = options.inverse; | |
+ var view = data.view; | |
// This should be deterministic, and should probably come from a | |
// parent view and not the controller. | |
- var controller = property_get.get(view, "controller"); | |
- var container = controller && controller.container ? controller.container : view.container; | |
+ var controller = property_get.get(view, 'controller'); | |
+ var container = (controller && controller.container ? controller.container : view.container); | |
// If passed a path string, convert that into an object. | |
// Otherwise, just default to the standard class. | |
@@ -6313,8 +6562,8 @@ | |
itemViewClass = collectionPrototype.itemViewClass; | |
} | |
- if (typeof itemViewClass === "string") { | |
- itemViewClass = container.lookupFactory("view:" + itemViewClass); | |
+ if (typeof itemViewClass === 'string') { | |
+ itemViewClass = container.lookupFactory('view:'+itemViewClass); | |
} | |
Ember['default'].assert(string.fmt("%@ #collection: Could not find itemViewClass %@", [data.view, itemViewClass]), !!itemViewClass); | |
@@ -6325,7 +6574,7 @@ | |
// Go through options passed to the {{collection}} helper and extract options | |
// that configure item views instead of the collection itself. | |
for (var prop in hash) { | |
- if (prop === "itemController" || prop === "itemClassBinding") { | |
+ if (prop === 'itemController' || prop === 'itemClassBinding') { | |
continue; | |
} | |
if (hash.hasOwnProperty(prop)) { | |
@@ -6350,7 +6599,7 @@ | |
var emptyViewClass; | |
if (inverse) { | |
- emptyViewClass = property_get.get(collectionPrototype, "emptyViewClass"); | |
+ emptyViewClass = property_get.get(collectionPrototype, 'emptyViewClass'); | |
emptyViewClass = emptyViewClass.extend({ | |
template: inverse, | |
tagName: itemHash.tagName | |
@@ -6358,15 +6607,13 @@ | |
} else if (hash.emptyViewClass) { | |
emptyViewClass = utils.readViewFactory(hash.emptyViewClass, container); | |
} | |
- if (emptyViewClass) { | |
- hash.emptyView = emptyViewClass; | |
- } | |
+ if (emptyViewClass) { hash.emptyView = emptyViewClass; } | |
var viewOptions = mergeViewBindings['default'](view, {}, itemHash); | |
if (hash.itemClassBinding) { | |
- var itemClassBindings = hash.itemClassBinding.split(" "); | |
- viewOptions.classNameBindings = enumerable_utils.map(itemClassBindings, function (classBinding) { | |
+ var itemClassBindings = hash.itemClassBinding.split(' '); | |
+ viewOptions.classNameBindings = enumerable_utils.map(itemClassBindings, function(classBinding) { | |
return class_name_binding.streamifyClassNameBinding(view, classBinding); | |
}); | |
} | |
@@ -6374,7 +6621,7 @@ | |
hash.itemViewClass = itemViewClass; | |
hash._itemViewProps = viewOptions; | |
- options.helperName = options.helperName || "collection"; | |
+ options.helperName = options.helperName || 'collection'; | |
return env.helpers.view.helperFunction.call(this, [collectionClass], hash, options, env); | |
} | |
@@ -6387,64 +6634,21 @@ | |
exports.componentHelper = componentHelper; | |
/** | |
- The `{{component}}` helper lets you add instances of `Ember.Component` to a | |
- template. See [Ember.Component](/api/classes/Ember.Component.html) for | |
- additional information on how a `Component` functions. | |
- | |
- `{{component}}`'s primary use is for cases where you want to dynamically | |
- change which type of component is rendered as the state of your application | |
- changes. | |
- | |
- The provided block will be applied as the template for the component. | |
- | |
- Given an empty `<body>` the following template: | |
- | |
- ```handlebars | |
- {{! application.hbs }} | |
- {{component infographicComponentName}} | |
- ``` | |
- | |
- And the following application code | |
- | |
- ```javascript | |
- App = Ember.Application.create(); | |
- App.ApplicationController = Ember.Controller.extend({ | |
- infographicComponentName: function() { | |
- if (this.get('isMarketOpen')) { | |
- return "live-updating-chart"; | |
- } else { | |
- return "market-close-summary"; | |
- } | |
- }.property('isMarketOpen') | |
- }); | |
- ``` | |
- | |
- The `live-updating-chart` component will be appended when `isMarketOpen` is | |
- `true`, and the `market-close-summary` component will be appended when | |
- `isMarketOpen` is `false`. If the value changes while the app is running, | |
- the component will be automatically swapped out accordingly. | |
- | |
- Note: You should not use this helper when you are consistently rendering the same | |
- component. In that case, use standard component syntax, for example: | |
- | |
- ```handlebars | |
- {{! application.hbs }} | |
- {{live-updating-chart}} | |
- ``` | |
- | |
- @method component | |
- @since 1.11.0 | |
- @for Ember.Handlebars.helpers | |
+ @module ember | |
+ @submodule ember-htmlbars | |
*/ | |
function componentHelper(params, hash, options, env) { | |
- Ember['default'].assert("The `component` helper expects exactly one argument, plus name/property values.", params.length === 1); | |
+ Ember['default'].assert( | |
+ "The `component` helper expects exactly one argument, plus name/property values.", | |
+ params.length === 1 | |
+ ); | |
var view = env.data.view; | |
var componentNameParam = params[0]; | |
var container = view.container || utils.read(view._keywords.view).container; | |
var props = { | |
- helperName: options.helperName || "component" | |
+ helperName: options.helperName || 'component' | |
}; | |
if (options.template) { | |
props.template = options.template; | |
@@ -6458,7 +6662,7 @@ | |
} else { | |
viewClass = streams__utils.readComponentFactory(componentNameParam, container); | |
if (!viewClass) { | |
- throw new EmberError['default']("HTMLBars error: Could not find component named \"" + componentNameParam + "\"."); | |
+ throw new EmberError['default']('HTMLBars error: Could not find component named "' + componentNameParam + '".'); | |
} | |
mergeViewBindings['default'](view, props, hash); | |
} | |
@@ -6473,48 +6677,11 @@ | |
exports.debuggerHelper = debuggerHelper; | |
- /** | |
- Execute the `debugger` statement in the current template's context. | |
- | |
- ```handlebars | |
- {{debugger}} | |
- ``` | |
- | |
- When using the debugger helper you will have access to a `get` function. This | |
- function retrieves values available in the context of the template. | |
- | |
- For example, if you're wondering why a value `{{foo}}` isn't rendering as | |
- expected within a template, you could place a `{{debugger}}` statement and, | |
- when the `debugger;` breakpoint is hit, you can attempt to retrieve this value: | |
+ /*jshint debug:true*/ | |
- ``` | |
- > get('foo') | |
- ``` | |
- | |
- `get` is also aware of keywords. So in this situation | |
- | |
- ```handlebars | |
- {{#each items as |item|}} | |
- {{debugger}} | |
- {{/each}} | |
- ``` | |
- | |
- you'll be able to get values from the current item: | |
- | |
- ``` | |
- > get('item.name') | |
- ``` | |
- | |
- You can also access the context of the view to make sure it is the object that | |
- you expect: | |
- | |
- ``` | |
- > context | |
- ``` | |
- | |
- @method debugger | |
- @for Ember.Handlebars.helpers | |
- @param {String} property | |
+ /** | |
+ @module ember | |
+ @submodule ember-htmlbars | |
*/ | |
function debuggerHelper(params, hash, options, env) { | |
@@ -6522,14 +6689,14 @@ | |
var view = env.data.view; | |
/* jshint unused: false */ | |
- var context = view.get("context"); | |
+ var context = view.get('context'); | |
/* jshint unused: false */ | |
function get(path) { | |
return view.getStream(path).value(); | |
} | |
- Logger['default'].info("Use `view`, `context`, and `get(<path>)` to debug this template."); | |
+ Logger['default'].info('Use `view`, `context`, and `get(<path>)` to debug this template.'); | |
debugger; | |
} | |
@@ -6547,10 +6714,14 @@ | |
*/ | |
function eachHelper(params, hash, options, env) { | |
var view = env.data.view; | |
- var helperName = "each"; | |
- var path = params[0] || view.getStream(""); | |
+ var helperName = 'each'; | |
+ var path = params[0] || view.getStream(''); | |
- Ember['default'].assert("If you pass more than one argument to the each helper, " + "it must be in the form #each foo in bar", params.length <= 1); | |
+ Ember['default'].assert( | |
+ "If you pass more than one argument to the each helper, " + | |
+ "it must be in the form #each foo in bar", | |
+ params.length <= 1 | |
+ ); | |
var blockParams = options.template && options.template.blockParams; | |
@@ -6559,7 +6730,12 @@ | |
hash.blockParams = blockParams; | |
} | |
- Ember['default'].deprecate("Using the context switching form of {{each}} is deprecated. " + "Please use the keyword form (`{{#each foo in bar}}`) instead.", hash.keyword === true || typeof hash.keyword === "string", { url: "http://emberjs.com/guides/deprecations/#toc_more-consistent-handlebars-scope" }); | |
+ Ember['default'].deprecate( | |
+ "Using the context switching form of {{each}} is deprecated. " + | |
+ "Please use the keyword form (`{{#each foo in bar}}`) instead.", | |
+ hash.keyword === true || typeof hash.keyword === 'string', | |
+ { url: 'http://emberjs.com/guides/deprecations/#toc_more-consistent-handlebars-scope' } | |
+ ); | |
hash.dataSource = path; | |
options.helperName = options.helperName || helperName; | |
@@ -6583,7 +6759,7 @@ | |
*/ | |
function ifHelper(params, hash, options, env) { | |
- var helperName = options.helperName || "if"; | |
+ var helperName = options.helperName || 'if'; | |
return appendConditional(false, helperName, params, hash, options, env); | |
} | |
@@ -6592,12 +6768,16 @@ | |
@for Ember.Handlebars.helpers | |
*/ | |
function unlessHelper(params, hash, options, env) { | |
- var helperName = options.helperName || "unless"; | |
+ var helperName = options.helperName || 'unless'; | |
return appendConditional(true, helperName, params, hash, options, env); | |
} | |
+ | |
function assertInlineIfNotEnabled() { | |
- Ember['default'].assert("To use the inline forms of the `if` and `unless` helpers you must " + "enable the `ember-htmlbars-inline-if-helper` feature flag."); | |
+ Ember['default'].assert( | |
+ "To use the inline forms of the `if` and `unless` helpers you must " + | |
+ "enable the `ember-htmlbars-inline-if-helper` feature flag." | |
+ ); | |
} | |
function appendConditional(inverted, helperName, params, hash, options, env) { | |
@@ -6612,7 +6792,11 @@ | |
} | |
function appendBlockConditional(view, inverted, helperName, params, hash, options, env) { | |
- Ember['default'].assert("The block form of the `if` and `unless` helpers expect exactly one " + "argument, e.g. `{{#if newMessages}} You have new messages. {{/if}}.`", params.length === 1); | |
+ Ember['default'].assert( | |
+ "The block form of the `if` and `unless` helpers expect exactly one " + | |
+ "argument, e.g. `{{#if newMessages}} You have new messages. {{/if}}.`", | |
+ params.length === 1 | |
+ ); | |
var condition = shouldDisplay['default'](params[0]); | |
var truthyTemplate = (inverted ? options.inverse : options.template) || emptyTemplate['default']; | |
@@ -6621,7 +6805,7 @@ | |
if (utils.isStream(condition)) { | |
view.appendChild(BoundIfView['default'], { | |
_morph: options.morph, | |
- _context: property_get.get(view, "context"), | |
+ _context: property_get.get(view, 'context'), | |
conditionStream: condition, | |
truthyTemplate: truthyTemplate, | |
falsyTemplate: falsyTemplate, | |
@@ -6636,9 +6820,18 @@ | |
} | |
function appendInlineConditional(view, inverted, helperName, params) { | |
- Ember['default'].assert("The inline form of the `if` and `unless` helpers expect two or " + "three arguments, e.g. `{{if trialExpired 'Expired' expiryDate}}` " + "or `{{unless isFirstLogin 'Welcome back!'}}`.", params.length === 2 || params.length === 3); | |
- | |
- return conditional['default'](shouldDisplay['default'](params[0]), inverted ? params[2] : params[1], inverted ? params[1] : params[2]); | |
+ Ember['default'].assert( | |
+ "The inline form of the `if` and `unless` helpers expect two or " + | |
+ "three arguments, e.g. `{{if trialExpired 'Expired' expiryDate}}` " + | |
+ "or `{{unless isFirstLogin 'Welcome back!'}}`.", | |
+ params.length === 2 || params.length === 3 | |
+ ); | |
+ | |
+ return conditional['default']( | |
+ shouldDisplay['default'](params[0]), | |
+ inverted ? params[2] : params[1], | |
+ inverted ? params[1] : params[2] | |
+ ); | |
} | |
}); | |
@@ -6648,207 +6841,25 @@ | |
exports.inputHelper = inputHelper; | |
- // Ember.assert | |
- | |
- /** | |
- @module ember | |
- @submodule ember-htmlbars | |
- */ | |
- | |
- /** | |
- | |
- The `{{input}}` helper inserts an HTML `<input>` tag into the template, | |
- with a `type` value of either `text` or `checkbox`. If no `type` is provided, | |
- `text` will be the default value applied. The attributes of `{{input}}` | |
- match those of the native HTML tag as closely as possible for these two types. | |
- | |
- ## Use as text field | |
- An `{{input}}` with no `type` or a `type` of `text` will render an HTML text input. | |
- The following HTML attributes can be set via the helper: | |
- | |
- <table> | |
- <tr><td>`readonly`</td><td>`required`</td><td>`autofocus`</td></tr> | |
- <tr><td>`value`</td><td>`placeholder`</td><td>`disabled`</td></tr> | |
- <tr><td>`size`</td><td>`tabindex`</td><td>`maxlength`</td></tr> | |
- <tr><td>`name`</td><td>`min`</td><td>`max`</td></tr> | |
- <tr><td>`pattern`</td><td>`accept`</td><td>`autocomplete`</td></tr> | |
- <tr><td>`autosave`</td><td>`formaction`</td><td>`formenctype`</td></tr> | |
- <tr><td>`formmethod`</td><td>`formnovalidate`</td><td>`formtarget`</td></tr> | |
- <tr><td>`height`</td><td>`inputmode`</td><td>`multiple`</td></tr> | |
- <tr><td>`step`</td><td>`width`</td><td>`form`</td></tr> | |
- <tr><td>`selectionDirection`</td><td>`spellcheck`</td><td> </td></tr> | |
- </table> | |
- | |
- | |
- When set to a quoted string, these values will be directly applied to the HTML | |
- element. When left unquoted, these values will be bound to a property on the | |
- template's current rendering context (most typically a controller instance). | |
- | |
- ## Unbound: | |
- | |
- ```handlebars | |
- {{input value="http://www.facebook.com"}} | |
- ``` | |
- | |
- | |
- ```html | |
- <input type="text" value="http://www.facebook.com"/> | |
- ``` | |
- | |
- ## Bound: | |
- | |
- ```javascript | |
- App.ApplicationController = Ember.Controller.extend({ | |
- firstName: "Stanley", | |
- entryNotAllowed: true | |
- }); | |
- ``` | |
- | |
- | |
- ```handlebars | |
- {{input type="text" value=firstName disabled=entryNotAllowed size="50"}} | |
- ``` | |
- | |
- | |
- ```html | |
- <input type="text" value="Stanley" disabled="disabled" size="50"/> | |
- ``` | |
- | |
- ## Actions | |
- | |
- The helper can send multiple actions based on user events. | |
- | |
- The action property defines the action which is sent when | |
- the user presses the return key. | |
- | |
- ```handlebars | |
- {{input action="submit"}} | |
- ``` | |
- | |
- The helper allows some user events to send actions. | |
- | |
- * `enter` | |
- * `insert-newline` | |
- * `escape-press` | |
- * `focus-in` | |
- * `focus-out` | |
- * `key-press` | |
- | |
- | |
- For example, if you desire an action to be sent when the input is blurred, | |
- you only need to setup the action name to the event name property. | |
- | |
- ```handlebars | |
- {{input focus-in="alertMessage"}} | |
- ``` | |
- | |
- See more about [Text Support Actions](/api/classes/Ember.TextField.html) | |
- | |
- ## Extension | |
- | |
- Internally, `{{input type="text"}}` creates an instance of `Ember.TextField`, passing | |
- arguments from the helper to `Ember.TextField`'s `create` method. You can extend the | |
- capabilities of text inputs in your applications by reopening this class. For example, | |
- if you are building a Bootstrap project where `data-*` attributes are used, you | |
- can add one to the `TextField`'s `attributeBindings` property: | |
- | |
- | |
- ```javascript | |
- Ember.TextField.reopen({ | |
- attributeBindings: ['data-error'] | |
- }); | |
- ``` | |
- | |
- Keep in mind when writing `Ember.TextField` subclasses that `Ember.TextField` | |
- itself extends `Ember.Component`, meaning that it does NOT inherit | |
- the `controller` of the parent view. | |
- | |
- See more about [Ember components](/api/classes/Ember.Component.html) | |
- | |
- | |
- ## Use as checkbox | |
- | |
- An `{{input}}` with a `type` of `checkbox` will render an HTML checkbox input. | |
- The following HTML attributes can be set via the helper: | |
- | |
- * `checked` | |
- * `disabled` | |
- * `tabindex` | |
- * `indeterminate` | |
- * `name` | |
- * `autofocus` | |
- * `form` | |
- | |
- | |
- When set to a quoted string, these values will be directly applied to the HTML | |
- element. When left unquoted, these values will be bound to a property on the | |
- template's current rendering context (most typically a controller instance). | |
- | |
- ## Unbound: | |
- | |
- ```handlebars | |
- {{input type="checkbox" name="isAdmin"}} | |
- ``` | |
- | |
- ```html | |
- <input type="checkbox" name="isAdmin" /> | |
- ``` | |
- | |
- ## Bound: | |
- | |
- ```javascript | |
- App.ApplicationController = Ember.Controller.extend({ | |
- isAdmin: true | |
- }); | |
- ``` | |
- | |
- | |
- ```handlebars | |
- {{input type="checkbox" checked=isAdmin }} | |
- ``` | |
- | |
- | |
- ```html | |
- <input type="checkbox" checked="checked" /> | |
- ``` | |
- | |
- ## Extension | |
- | |
- Internally, `{{input type="checkbox"}}` creates an instance of `Ember.Checkbox`, passing | |
- arguments from the helper to `Ember.Checkbox`'s `create` method. You can extend the | |
- capablilties of checkbox inputs in your applications by reopening this class. For example, | |
- if you wanted to add a css class to all checkboxes in your application: | |
- | |
- | |
- ```javascript | |
- Ember.Checkbox.reopen({ | |
- classNames: ['my-app-checkbox'] | |
- }); | |
- ``` | |
- | |
- | |
- @method input | |
- @for Ember.Handlebars.helpers | |
- @param {Hash} options | |
- */ | |
function inputHelper(params, hash, options, env) { | |
- Ember['default'].assert("You can only pass attributes to the `input` helper, not arguments", params.length === 0); | |
+ Ember['default'].assert('You can only pass attributes to the `input` helper, not arguments', params.length === 0); | |
var onEvent = hash.on; | |
var inputType; | |
inputType = utils.read(hash.type); | |
- if (inputType === "checkbox") { | |
+ if (inputType === 'checkbox') { | |
delete hash.type; | |
- Ember['default'].assert("{{input type='checkbox'}} does not support setting `value=someBooleanValue`;" + " you must use `checked=someBooleanValue` instead.", !hash.hasOwnProperty("value")); | |
+ Ember['default'].assert("{{input type='checkbox'}} does not support setting `value=someBooleanValue`;" + | |
+ " you must use `checked=someBooleanValue` instead.", !hash.hasOwnProperty('value')); | |
env.helpers.view.helperFunction.call(this, [Checkbox['default']], hash, options, env); | |
} else { | |
delete hash.on; | |
- hash.onEvent = onEvent || "enter"; | |
+ hash.onEvent = onEvent || 'enter'; | |
env.helpers.view.helperFunction.call(this, [TextField['default']], hash, options, env); | |
} | |
} | |
@@ -6860,45 +6871,8 @@ | |
exports.locHelper = locHelper; | |
- /** | |
- @module ember | |
- @submodule ember-htmlbars | |
- */ | |
- | |
- /** | |
- Calls [Ember.String.loc](/api/classes/Ember.String.html#method_loc) with the | |
- provided string. | |
- | |
- This is a convenient way to localize text within a template: | |
- | |
- ```javascript | |
- Ember.STRINGS = { | |
- '_welcome_': 'Bonjour' | |
- }; | |
- ``` | |
- | |
- ```handlebars | |
- <div class='message'> | |
- {{loc '_welcome_'}} | |
- </div> | |
- ``` | |
- | |
- ```html | |
- <div class='message'> | |
- Bonjour | |
- </div> | |
- ``` | |
- | |
- See [Ember.String.loc](/api/classes/Ember.String.html#method_loc) for how to | |
- set up localized string references. | |
- | |
- @method loc | |
- @for Ember.Handlebars.helpers | |
- @param {String} str The string to format | |
- @see {Ember.String#loc} | |
- */ | |
function locHelper(params, hash, options, env) { | |
- Ember['default'].assert("You cannot pass bindings to `loc` helper", (function ifParamsContainBindings() { | |
+ Ember['default'].assert('You cannot pass bindings to `loc` helper', (function ifParamsContainBindings() { | |
for (var i = 0, l = params.length; i < l; i++) { | |
if (utils.isStream(params[i])) { | |
return false; | |
@@ -6918,16 +6892,8 @@ | |
exports.logHelper = logHelper; | |
/** | |
- `log` allows you to output the value of variables in the current rendering | |
- context. `log` also accepts primitive types such as strings or numbers. | |
- | |
- ```handlebars | |
- {{log "myVariable:" myVariable }} | |
- ``` | |
- | |
- @method log | |
- @for Ember.Handlebars.helpers | |
- @param {String} property | |
+ @module ember | |
+ @submodule ember-htmlbars | |
*/ | |
function logHelper(params, hash, options, env) { | |
var logger = Logger['default'].log; | |
@@ -6947,51 +6913,6 @@ | |
exports.partialHelper = partialHelper; | |
- /** | |
- @module ember | |
- @submodule ember-htmlbars | |
- */ | |
- | |
- /** | |
- The `partial` helper renders another template without | |
- changing the template context: | |
- | |
- ```handlebars | |
- {{foo}} | |
- {{partial "nav"}} | |
- ``` | |
- | |
- The above example template will render a template named | |
- "_nav", which has the same context as the parent template | |
- it's rendered into, so if the "_nav" template also referenced | |
- `{{foo}}`, it would print the same thing as the `{{foo}}` | |
- in the above example. | |
- | |
- If a "_nav" template isn't found, the `partial` helper will | |
- fall back to a template named "nav". | |
- | |
- ## Bound template names | |
- | |
- The parameter supplied to `partial` can also be a path | |
- to a property containing a template name, e.g.: | |
- | |
- ```handlebars | |
- {{partial someTemplateName}} | |
- ``` | |
- | |
- The above example will look up the value of `someTemplateName` | |
- on the template context (e.g. a controller) and use that | |
- value as the name of the template to render. If the resolved | |
- value is falsy, nothing will be rendered. If `someTemplateName` | |
- changes, the partial will be re-rendered using the new template | |
- name. | |
- | |
- | |
- @method partial | |
- @for Ember.Handlebars.helpers | |
- @param {String} partialName the name of the template to render minus the leading underscore | |
- */ | |
- | |
function partialHelper(params, hash, options, env) { | |
var view = env.data.view; | |
var templateName = params[0]; | |
@@ -6999,9 +6920,9 @@ | |
if (utils.isStream(templateName)) { | |
view.appendChild(BoundPartialView['default'], { | |
_morph: options.morph, | |
- _context: property_get.get(view, "context"), | |
+ _context: property_get.get(view, 'context'), | |
templateNameStream: templateName, | |
- helperName: options.helperName || "partial" | |
+ helperName: options.helperName || 'partial' | |
}); | |
} else { | |
var template = lookupPartial['default'](view, templateName); | |
@@ -7016,23 +6937,13 @@ | |
exports.templateHelper = templateHelper; | |
- // Ember.deprecate; | |
- | |
- /** | |
- @module ember | |
- @submodule ember-htmlbars | |
- */ | |
- | |
- /** | |
- @deprecated | |
- @method template | |
- @for Ember.Handlebars.helpers | |
- @param {String} templateName the template to render | |
- */ | |
function templateHelper(params, hash, options, env) { | |
- Ember['default'].deprecate("The `template` helper has been deprecated in favor of the `partial` helper." + " Please use `partial` instead, which will work the same way."); | |
+ Ember['default'].deprecate( | |
+ "The `template` helper has been deprecated in favor of the `partial` helper." + | |
+ " Please use `partial` instead, which will work the same way." | |
+ ); | |
- options.helperName = options.helperName || "template"; | |
+ options.helperName = options.helperName || 'template'; | |
return env.helpers.partial.helperFunction.call(this, params, hash, options, env); | |
} | |
@@ -7045,192 +6956,12 @@ | |
exports.textareaHelper = textareaHelper; | |
/** | |
- `{{textarea}}` inserts a new instance of `<textarea>` tag into the template. | |
- The attributes of `{{textarea}}` match those of the native HTML tags as | |
- closely as possible. | |
- | |
- The following HTML attributes can be set: | |
- | |
- * `value` | |
- * `name` | |
- * `rows` | |
- * `cols` | |
- * `placeholder` | |
- * `disabled` | |
- * `maxlength` | |
- * `tabindex` | |
- * `selectionEnd` | |
- * `selectionStart` | |
- * `selectionDirection` | |
- * `wrap` | |
- * `readonly` | |
- * `autofocus` | |
- * `form` | |
- * `spellcheck` | |
- * `required` | |
- | |
- When set to a quoted string, these value will be directly applied to the HTML | |
- element. When left unquoted, these values will be bound to a property on the | |
- template's current rendering context (most typically a controller instance). | |
- | |
- Unbound: | |
- | |
- ```handlebars | |
- {{textarea value="Lots of static text that ISN'T bound"}} | |
- ``` | |
- | |
- Would result in the following HTML: | |
- | |
- ```html | |
- <textarea class="ember-text-area"> | |
- Lots of static text that ISN'T bound | |
- </textarea> | |
- ``` | |
- | |
- Bound: | |
- | |
- In the following example, the `writtenWords` property on `App.ApplicationController` | |
- will be updated live as the user types 'Lots of text that IS bound' into | |
- the text area of their browser's window. | |
- | |
- ```javascript | |
- App.ApplicationController = Ember.Controller.extend({ | |
- writtenWords: "Lots of text that IS bound" | |
- }); | |
- ``` | |
- | |
- ```handlebars | |
- {{textarea value=writtenWords}} | |
- ``` | |
- | |
- Would result in the following HTML: | |
- | |
- ```html | |
- <textarea class="ember-text-area"> | |
- Lots of text that IS bound | |
- </textarea> | |
- ``` | |
- | |
- If you wanted a one way binding between the text area and a div tag | |
- somewhere else on your screen, you could use `Ember.computed.oneWay`: | |
- | |
- ```javascript | |
- App.ApplicationController = Ember.Controller.extend({ | |
- writtenWords: "Lots of text that IS bound", | |
- outputWrittenWords: Ember.computed.oneWay("writtenWords") | |
- }); | |
- ``` | |
- | |
- ```handlebars | |
- {{textarea value=writtenWords}} | |
- | |
- <div> | |
- {{outputWrittenWords}} | |
- </div> | |
- ``` | |
- | |
- Would result in the following HTML: | |
- | |
- ```html | |
- <textarea class="ember-text-area"> | |
- Lots of text that IS bound | |
- </textarea> | |
- | |
- <-- the following div will be updated in real time as you type --> | |
- | |
- <div> | |
- Lots of text that IS bound | |
- </div> | |
- ``` | |
- | |
- Finally, this example really shows the power and ease of Ember when two | |
- properties are bound to eachother via `Ember.computed.alias`. Type into | |
- either text area box and they'll both stay in sync. Note that | |
- `Ember.computed.alias` costs more in terms of performance, so only use it when | |
- your really binding in both directions: | |
- | |
- ```javascript | |
- App.ApplicationController = Ember.Controller.extend({ | |
- writtenWords: "Lots of text that IS bound", | |
- twoWayWrittenWords: Ember.computed.alias("writtenWords") | |
- }); | |
- ``` | |
- | |
- ```handlebars | |
- {{textarea value=writtenWords}} | |
- {{textarea value=twoWayWrittenWords}} | |
- ``` | |
- | |
- ```html | |
- <textarea id="ember1" class="ember-text-area"> | |
- Lots of text that IS bound | |
- </textarea> | |
- | |
- <-- both updated in real time --> | |
- | |
- <textarea id="ember2" class="ember-text-area"> | |
- Lots of text that IS bound | |
- </textarea> | |
- ``` | |
- | |
- ## Actions | |
- | |
- The helper can send multiple actions based on user events. | |
- | |
- The action property defines the action which is send when | |
- the user presses the return key. | |
- | |
- ```handlebars | |
- {{input action="submit"}} | |
- ``` | |
- | |
- The helper allows some user events to send actions. | |
- | |
- * `enter` | |
- * `insert-newline` | |
- * `escape-press` | |
- * `focus-in` | |
- * `focus-out` | |
- * `key-press` | |
- | |
- For example, if you desire an action to be sent when the input is blurred, | |
- you only need to setup the action name to the event name property. | |
- | |
- ```handlebars | |
- {{textarea focus-in="alertMessage"}} | |
- ``` | |
- | |
- See more about [Text Support Actions](/api/classes/Ember.TextArea.html) | |
- | |
- ## Extension | |
- | |
- Internally, `{{textarea}}` creates an instance of `Ember.TextArea`, passing | |
- arguments from the helper to `Ember.TextArea`'s `create` method. You can | |
- extend the capabilities of text areas in your application by reopening this | |
- class. For example, if you are building a Bootstrap project where `data-*` | |
- attributes are used, you can globally add support for a `data-*` attribute | |
- on all `{{textarea}}`s' in your app by reopening `Ember.TextArea` or | |
- `Ember.TextSupport` and adding it to the `attributeBindings` concatenated | |
- property: | |
- | |
- ```javascript | |
- Ember.TextArea.reopen({ | |
- attributeBindings: ['data-error'] | |
- }); | |
- ``` | |
- | |
- Keep in mind when writing `Ember.TextArea` subclasses that `Ember.TextArea` | |
- itself extends `Ember.Component`, meaning that it does NOT inherit | |
- the `controller` of the parent view. | |
- | |
- See more about [Ember components](/api/classes/Ember.Component.html) | |
- | |
- @method textarea | |
- @for Ember.Handlebars.helpers | |
- @param {Hash} options | |
+ @module ember | |
+ @submodule ember-htmlbars | |
*/ | |
+ | |
function textareaHelper(params, hash, options, env) { | |
- Ember['default'].assert("You can only pass attributes to the `textarea` helper, not arguments", params.length === 0); | |
+ Ember['default'].assert('You can only pass attributes to the `textarea` helper, not arguments', params.length === 0); | |
return env.helpers.view.helperFunction.call(this, [TextArea['default']], hash, options, env); | |
} | |
@@ -7242,45 +6973,24 @@ | |
exports.unboundHelper = unboundHelper; | |
- /** | |
- @module ember | |
- @submodule ember-htmlbars | |
- */ | |
- | |
- /** | |
- `unbound` allows you to output a property without binding. *Important:* The | |
- output will not be updated if the property changes. Use with caution. | |
- | |
- ```handlebars | |
- <div>{{unbound somePropertyThatDoesntChange}}</div> | |
- ``` | |
- | |
- `unbound` can also be used in conjunction with a bound helper to | |
- render it in its unbound form: | |
- | |
- ```handlebars | |
- <div>{{unbound helperName somePropertyThatDoesntChange}}</div> | |
- ``` | |
- | |
- @method unbound | |
- @for Ember.Handlebars.helpers | |
- @param {String} property | |
- @return {String} HTML string | |
- */ | |
function unboundHelper(params, hash, options, env) { | |
- Ember.assert("The `unbound` helper expects at least one argument, " + "e.g. `{{unbound user.name}}`.", params.length > 0); | |
+ Ember.assert( | |
+ "The `unbound` helper expects at least one argument, " + | |
+ "e.g. `{{unbound user.name}}`.", | |
+ params.length > 0 | |
+ ); | |
if (params.length === 1) { | |
return utils.read(params[0]); | |
} else { | |
- options.helperName = options.helperName || "unbound"; | |
+ options.helperName = options.helperName || 'unbound'; | |
var view = env.data.view; | |
var helperName = params[0]._label; | |
var helper = lookupHelper['default'](helperName, view, env); | |
if (!helper) { | |
- throw new EmberError['default']("HTMLBars error: Could not find component or helper named " + helperName + "."); | |
+ throw new EmberError['default']('HTMLBars error: Could not find component or helper named ' + helperName + '.'); | |
} | |
return helper.helperFunction.call(this, readParams(params), readHash(hash, view), options, env); | |
@@ -7292,7 +7002,7 @@ | |
var unboundParams = new Array(l - 1); | |
for (var i = 1; i < l; i++) { | |
- unboundParams[i - 1] = utils.read(params[i]); | |
+ unboundParams[i-1] = utils.read(params[i]); | |
} | |
return unboundParams; | |
@@ -7304,7 +7014,7 @@ | |
for (var prop in hash) { | |
if (mixin.IS_BINDING.test(prop)) { | |
var value = hash[prop]; | |
- if (typeof value === "string") { | |
+ if (typeof value === 'string') { | |
value = view.getStream(value); | |
} | |
@@ -7325,189 +7035,22 @@ | |
exports.viewHelper = viewHelper; | |
/** | |
- `{{view}}` inserts a new instance of an `Ember.View` into a template passing its | |
- options to the `Ember.View`'s `create` method and using the supplied block as | |
- the view's own template. | |
- | |
- An empty `<body>` and the following template: | |
- | |
- ```handlebars | |
- A span: | |
- {{#view tagName="span"}} | |
- hello. | |
- {{/view}} | |
- ``` | |
- | |
- Will result in HTML structure: | |
- | |
- ```html | |
- <body> | |
- <!-- Note: the handlebars template script | |
- also results in a rendered Ember.View | |
- which is the outer <div> here --> | |
- | |
- <div class="ember-view"> | |
- A span: | |
- <span id="ember1" class="ember-view"> | |
- Hello. | |
- </span> | |
- </div> | |
- </body> | |
- ``` | |
- | |
- ### `parentView` setting | |
- | |
- The `parentView` property of the new `Ember.View` instance created through | |
- `{{view}}` will be set to the `Ember.View` instance of the template where | |
- `{{view}}` was called. | |
- | |
- ```javascript | |
- aView = Ember.View.create({ | |
- template: Ember.Handlebars.compile("{{#view}} my parent: {{parentView.elementId}} {{/view}}") | |
- }); | |
- | |
- aView.appendTo('body'); | |
- ``` | |
- | |
- Will result in HTML structure: | |
- | |
- ```html | |
- <div id="ember1" class="ember-view"> | |
- <div id="ember2" class="ember-view"> | |
- my parent: ember1 | |
- </div> | |
- </div> | |
- ``` | |
- | |
- ### Setting CSS id and class attributes | |
- | |
- The HTML `id` attribute can be set on the `{{view}}`'s resulting element with | |
- the `id` option. This option will _not_ be passed to `Ember.View.create`. | |
- | |
- ```handlebars | |
- {{#view tagName="span" id="a-custom-id"}} | |
- hello. | |
- {{/view}} | |
- ``` | |
- | |
- Results in the following HTML structure: | |
- | |
- ```html | |
- <div class="ember-view"> | |
- <span id="a-custom-id" class="ember-view"> | |
- hello. | |
- </span> | |
- </div> | |
- ``` | |
- | |
- The HTML `class` attribute can be set on the `{{view}}`'s resulting element | |
- with the `class` or `classNameBindings` options. The `class` option will | |
- directly set the CSS `class` attribute and will not be passed to | |
- `Ember.View.create`. `classNameBindings` will be passed to `create` and use | |
- `Ember.View`'s class name binding functionality: | |
- | |
- ```handlebars | |
- {{#view tagName="span" class="a-custom-class"}} | |
- hello. | |
- {{/view}} | |
- ``` | |
- | |
- Results in the following HTML structure: | |
- | |
- ```html | |
- <div class="ember-view"> | |
- <span id="ember2" class="ember-view a-custom-class"> | |
- hello. | |
- </span> | |
- </div> | |
- ``` | |
- | |
- ### Supplying a different view class | |
- | |
- `{{view}}` can take an optional first argument before its supplied options to | |
- specify a path to a custom view class. | |
- | |
- ```handlebars | |
- {{#view "custom"}}{{! will look up App.CustomView }} | |
- hello. | |
- {{/view}} | |
- ``` | |
- | |
- The first argument can also be a relative path accessible from the current | |
- context. | |
- | |
- ```javascript | |
- MyApp = Ember.Application.create({}); | |
- MyApp.OuterView = Ember.View.extend({ | |
- innerViewClass: Ember.View.extend({ | |
- classNames: ['a-custom-view-class-as-property'] | |
- }), | |
- template: Ember.Handlebars.compile('{{#view view.innerViewClass}} hi {{/view}}') | |
- }); | |
- | |
- MyApp.OuterView.create().appendTo('body'); | |
- ``` | |
- | |
- Will result in the following HTML: | |
- | |
- ```html | |
- <div id="ember1" class="ember-view"> | |
- <div id="ember2" class="ember-view a-custom-view-class-as-property"> | |
- hi | |
- </div> | |
- </div> | |
- ``` | |
- | |
- ### Blockless use | |
- | |
- If you supply a custom `Ember.View` subclass that specifies its own template | |
- or provide a `templateName` option to `{{view}}` it can be used without | |
- supplying a block. Attempts to use both a `templateName` option and supply a | |
- block will throw an error. | |
- | |
- ```javascript | |
- var App = Ember.Application.create(); | |
- App.WithTemplateDefinedView = Ember.View.extend({ | |
- templateName: 'defined-template' | |
- }); | |
- ``` | |
- | |
- ```handlebars | |
- {{! application.hbs }} | |
- {{view 'with-template-defined'}} | |
- ``` | |
- | |
- ```handlebars | |
- {{! defined-template.hbs }} | |
- Some content for the defined template view. | |
- ``` | |
- | |
- ### `viewName` property | |
- | |
- You can supply a `viewName` option to `{{view}}`. The `Ember.View` instance | |
- will be referenced as a property of its parent view by this name. | |
- | |
- ```javascript | |
- aView = Ember.View.create({ | |
- template: Ember.Handlebars.compile('{{#view viewName="aChildByName"}} hi {{/view}}') | |
- }); | |
- | |
- aView.appendTo('body'); | |
- aView.get('aChildByName') // the instance of Ember.View created by {{view}} helper | |
- ``` | |
- | |
- @method view | |
- @for Ember.Handlebars.helpers | |
+ @module ember | |
+ @submodule ember-htmlbars | |
*/ | |
+ | |
function viewHelper(params, hash, options, env) { | |
- Ember['default'].assert("The `view` helper expects zero or one arguments.", params.length <= 2); | |
+ Ember['default'].assert( | |
+ "The `view` helper expects zero or one arguments.", | |
+ params.length <= 2 | |
+ ); | |
var view = env.data.view; | |
var container = view.container || utils.read(view._keywords.view).container; | |
var viewClassOrInstance; | |
if (params.length === 0) { | |
if (container) { | |
- viewClassOrInstance = container.lookupFactory("view:toplevel"); | |
+ viewClassOrInstance = container.lookupFactory('view:toplevel'); | |
} else { | |
viewClassOrInstance = View['default']; | |
} | |
@@ -7516,7 +7059,7 @@ | |
} | |
var props = { | |
- helperName: options.helperName || "view" | |
+ helperName: options.helperName || 'view' | |
}; | |
if (options.template) { | |
@@ -7535,56 +7078,21 @@ | |
exports.withHelper = withHelper; | |
/** | |
- Use the `{{with}}` helper when you want to aliases the to a new name. It's helpful | |
- for semantic clarity and to retain default scope or to reference from another | |
- `{{with}}` block. | |
- | |
- ```handlebars | |
- // posts might not be | |
- {{#with user.posts as blogPosts}} | |
- <div class="notice"> | |
- There are {{blogPosts.length}} blog posts written by {{user.name}}. | |
- </div> | |
- | |
- {{#each post in blogPosts}} | |
- <li>{{post.title}}</li> | |
- {{/each}} | |
- {{/with}} | |
- ``` | |
- | |
- Without the `as` operator, it would be impossible to reference `user.name` in the example above. | |
- | |
- NOTE: The alias should not reuse a name from the bound property path. | |
- For example: `{{#with foo.bar as foo}}` is not supported because it attempts to alias using | |
- the first part of the property path, `foo`. Instead, use `{{#with foo.bar as baz}}`. | |
- | |
- ### `controller` option | |
- | |
- Adding `controller='something'` instructs the `{{with}}` helper to create and use an instance of | |
- the specified controller wrapping the aliased keyword. | |
- | |
- This is very similar to using an `itemController` option with the `{{each}}` helper. | |
- | |
- ```handlebars | |
- {{#with users.posts as posts controller='userBlogPosts'}} | |
- {{!- `posts` is wrapped in our controller instance }} | |
- {{/with}} | |
- ``` | |
- | |
- In the above example, the `posts` keyword is now wrapped in the `userBlogPost` controller, | |
- which provides an elegant way to decorate the context with custom | |
- functions/properties. | |
- | |
- @method with | |
- @for Ember.Handlebars.helpers | |
- @param {Function} context | |
- @param {Hash} options | |
- @return {String} HTML string | |
+ @module ember | |
+ @submodule ember-htmlbars | |
*/ | |
- function withHelper(params, hash, options, env) { | |
- Ember['default'].assert("{{#with foo}} must be called with a single argument or the use the " + "{{#with foo as bar}} syntax", params.length === 1); | |
- Ember['default'].assert("The {{#with}} helper must be called with a block", !!options.template); | |
+ function withHelper(params, hash, options, env) { | |
+ Ember['default'].assert( | |
+ "{{#with foo}} must be called with a single argument or the use the " + | |
+ "{{#with foo as bar}} syntax", | |
+ params.length === 1 | |
+ ); | |
+ | |
+ Ember['default'].assert( | |
+ "The {{#with}} helper must be called with a block", | |
+ !!options.template | |
+ ); | |
var view = env.data.view; | |
var preserveContext; | |
@@ -7592,7 +7100,12 @@ | |
if (options.template.blockParams) { | |
preserveContext = true; | |
} else { | |
- Ember['default'].deprecate("Using the context switching form of `{{with}}` is deprecated. " + "Please use the keyword form (`{{with foo as bar}}`) instead.", false, { url: "http://emberjs.com/guides/deprecations/#toc_more-consistent-handlebars-scope" }); | |
+ Ember['default'].deprecate( | |
+ "Using the context switching form of `{{with}}` is deprecated. " + | |
+ "Please use the keyword form (`{{with foo as bar}}`) instead.", | |
+ false, | |
+ { url: 'http://emberjs.com/guides/deprecations/#toc_more-consistent-handlebars-scope' } | |
+ ); | |
preserveContext = false; | |
} | |
@@ -7600,11 +7113,11 @@ | |
_morph: options.morph, | |
withValue: params[0], | |
preserveContext: preserveContext, | |
- previousContext: view.get("context"), | |
+ previousContext: view.get('context'), | |
controllerName: hash.controller, | |
mainTemplate: options.template, | |
inverseTemplate: options.inverse, | |
- helperName: options.helperName || "with" | |
+ helperName: options.helperName || 'with' | |
}); | |
} | |
@@ -7616,93 +7129,16 @@ | |
exports.yieldHelper = yieldHelper; | |
/** | |
- `{{yield}}` denotes an area of a template that will be rendered inside | |
- of another template. It has two main uses: | |
- | |
- ### Use with `layout` | |
- When used in a Handlebars template that is assigned to an `Ember.View` | |
- instance's `layout` property Ember will render the layout template first, | |
- inserting the view's own rendered output at the `{{yield}}` location. | |
- | |
- An empty `<body>` and the following application code: | |
- | |
- ```javascript | |
- AView = Ember.View.extend({ | |
- classNames: ['a-view-with-layout'], | |
- layout: Ember.Handlebars.compile('<div class="wrapper">{{yield}}</div>'), | |
- template: Ember.Handlebars.compile('<span>I am wrapped</span>') | |
- }); | |
- | |
- aView = AView.create(); | |
- aView.appendTo('body'); | |
- ``` | |
- | |
- Will result in the following HTML output: | |
- | |
- ```html | |
- <body> | |
- <div class='ember-view a-view-with-layout'> | |
- <div class="wrapper"> | |
- <span>I am wrapped</span> | |
- </div> | |
- </div> | |
- </body> | |
- ``` | |
- | |
- The `yield` helper cannot be used outside of a template assigned to an | |
- `Ember.View`'s `layout` property and will throw an error if attempted. | |
- | |
- ```javascript | |
- BView = Ember.View.extend({ | |
- classNames: ['a-view-with-layout'], | |
- template: Ember.Handlebars.compile('{{yield}}') | |
- }); | |
- | |
- bView = BView.create(); | |
- bView.appendTo('body'); | |
- | |
- // throws | |
- // Uncaught Error: assertion failed: | |
- // You called yield in a template that was not a layout | |
- ``` | |
- | |
- ### Use with Ember.Component | |
- When designing components `{{yield}}` is used to denote where, inside the component's | |
- template, an optional block passed to the component should render: | |
- | |
- ```handlebars | |
- <!-- application.hbs --> | |
- {{#labeled-textfield value=someProperty}} | |
- First name: | |
- {{/labeled-textfield}} | |
- ``` | |
- | |
- ```handlebars | |
- <!-- components/labeled-textfield.hbs --> | |
- <label> | |
- {{yield}} {{input value=value}} | |
- </label> | |
- ``` | |
- | |
- Result: | |
- | |
- ```html | |
- <label> | |
- First name: <input type="text" /> | |
- </label> | |
- ``` | |
- | |
- @method yield | |
- @for Ember.Handlebars.helpers | |
- @param {Hash} options | |
- @return {String} HTML string | |
+ @module ember | |
+ @submodule ember-htmlbars | |
*/ | |
+ | |
function yieldHelper(params, hash, options, env) { | |
var view = env.data.view; | |
var layoutView = view; | |
// Yea gods | |
- while (layoutView && !property_get.get(layoutView, "layout")) { | |
+ while (layoutView && !property_get.get(layoutView, 'layout')) { | |
if (layoutView._contextView) { | |
layoutView = layoutView._contextView; | |
} else { | |
@@ -7720,9 +7156,6 @@ | |
'use strict'; | |
- | |
- | |
- exports['default'] = attribute; | |
/** | |
@module ember | |
@submodule ember-htmlbars | |
@@ -7733,6 +7166,7 @@ | |
boundAttributesEnabled = true; | |
+ | |
function attribute(env, morph, element, attrName, attrValue) { | |
if (boundAttributesEnabled) { | |
var attrNode = new AttrNode['default'](attrName, attrValue); | |
@@ -7740,22 +7174,20 @@ | |
env.data.view.appendChild(attrNode); | |
} else { | |
if (utils.isStream(attrValue)) { | |
- throw new EmberError['default']("Bound attributes are not yet supported in Ember.js"); | |
+ throw new EmberError['default']('Bound attributes are not yet supported in Ember.js'); | |
} else { | |
var sanitizedValue = sanitizeAttributeValue['default'](env.dom, element, attrName, attrValue); | |
env.dom.setProperty(element, attrName, sanitizedValue); | |
} | |
} | |
} | |
+ exports['default'] = attribute; | |
}); | |
enifed('ember-htmlbars/hooks/block', ['exports', 'ember-views/views/simple_bound_view', 'ember-metal/streams/utils', 'ember-htmlbars/system/lookup-helper'], function (exports, simple_bound_view, utils, lookupHelper) { | |
'use strict'; | |
- | |
- | |
- exports['default'] = block; | |
/** | |
@module ember | |
@submodule ember-htmlbars | |
@@ -7764,7 +7196,7 @@ | |
function block(env, morph, view, path, params, hash, template, inverse) { | |
var helper = lookupHelper['default'](path, view, env); | |
- Ember.assert("A helper named `" + path + "` could not be found", helper); | |
+ Ember.assert("A helper named `"+path+"` could not be found", helper); | |
var options = { | |
morph: morph, | |
@@ -7780,15 +7212,13 @@ | |
morph.setContent(result); | |
} | |
} | |
+ exports['default'] = block; | |
}); | |
enifed('ember-htmlbars/hooks/component', ['exports', 'ember-metal/core', 'ember-htmlbars/system/lookup-helper'], function (exports, Ember, lookupHelper) { | |
'use strict'; | |
- | |
- | |
- exports['default'] = component; | |
/** | |
@module ember | |
@submodule ember-htmlbars | |
@@ -7797,36 +7227,32 @@ | |
function component(env, morph, view, tagName, attrs, template) { | |
var helper = lookupHelper['default'](tagName, view, env); | |
- Ember['default'].assert("You specified `" + tagName + "` in your template, but a component for `" + tagName + "` could not be found.", !!helper); | |
+ Ember['default'].assert('You specified `' + tagName + '` in your template, but a component for `' + tagName + '` could not be found.', !!helper); | |
return helper.helperFunction.call(undefined, [], attrs, { morph: morph, template: template }, env); | |
} | |
+ exports['default'] = component; | |
}); | |
enifed('ember-htmlbars/hooks/concat', ['exports', 'ember-metal/streams/utils'], function (exports, utils) { | |
'use strict'; | |
- | |
- | |
- exports['default'] = concat; | |
/** | |
@module ember | |
@submodule ember-htmlbars | |
*/ | |
function concat(env, parts) { | |
- return utils.concat(parts, ""); | |
+ return utils.concat(parts, ''); | |
} | |
+ exports['default'] = concat; | |
}); | |
enifed('ember-htmlbars/hooks/content', ['exports', 'ember-views/views/simple_bound_view', 'ember-metal/streams/utils', 'ember-htmlbars/system/lookup-helper'], function (exports, simple_bound_view, utils, lookupHelper) { | |
'use strict'; | |
- | |
- | |
- exports['default'] = content; | |
/** | |
@module ember | |
@submodule ember-htmlbars | |
@@ -7852,22 +7278,19 @@ | |
morph.setContent(result); | |
} | |
} | |
+ exports['default'] = content; | |
}); | |
enifed('ember-htmlbars/hooks/element', ['exports', 'ember-metal/core', 'ember-metal/streams/utils', 'ember-htmlbars/system/lookup-helper'], function (exports, Ember, utils, lookupHelper) { | |
'use strict'; | |
- | |
- | |
- exports['default'] = element; | |
/** | |
@module ember | |
@submodule ember-htmlbars | |
*/ | |
- function element(env, domElement, view, path, params, hash) { | |
- //jshint ignore:line | |
+ function element(env, domElement, view, path, params, hash) { //jshint ignore:line | |
var helper = lookupHelper['default'](path, view, env); | |
var valueOrLazyValue; | |
@@ -7882,20 +7305,21 @@ | |
var value = utils.read(valueOrLazyValue); | |
if (value) { | |
- Ember['default'].deprecate("Returning a string of attributes from a helper inside an element is deprecated."); | |
+ Ember['default'].deprecate('Returning a string of attributes from a helper inside an element is deprecated.'); | |
var parts = value.toString().split(/\s+/); | |
for (var i = 0, l = parts.length; i < l; i++) { | |
- var attrParts = parts[i].split("="); | |
+ var attrParts = parts[i].split('='); | |
var attrName = attrParts[0]; | |
var attrValue = attrParts[1]; | |
- attrValue = attrValue.replace(/^['"]/, "").replace(/['"]$/, ""); | |
+ attrValue = attrValue.replace(/^['"]/, '').replace(/['"]$/, ''); | |
env.dom.setAttribute(domElement, attrName, attrValue); | |
} | |
} | |
} | |
+ exports['default'] = element; | |
}); | |
enifed('ember-htmlbars/hooks/get', ['exports'], function (exports) { | |
@@ -7907,20 +7331,16 @@ | |
@submodule ember-htmlbars | |
*/ | |
- exports['default'] = get; | |
- | |
function get(env, view, path) { | |
return view.getStream(path); | |
} | |
+ exports['default'] = get; | |
}); | |
enifed('ember-htmlbars/hooks/inline', ['exports', 'ember-views/views/simple_bound_view', 'ember-metal/streams/utils', 'ember-htmlbars/system/lookup-helper'], function (exports, simple_bound_view, utils, lookupHelper) { | |
'use strict'; | |
- | |
- | |
- exports['default'] = inline; | |
/** | |
@module ember | |
@submodule ember-htmlbars | |
@@ -7929,7 +7349,7 @@ | |
function inline(env, morph, view, path, params, hash) { | |
var helper = lookupHelper['default'](path, view, env); | |
- Ember.assert("A helper named '" + path + "' could not be found", helper); | |
+ Ember.assert("A helper named '"+path+"' could not be found", helper); | |
var result = helper.helperFunction.call(undefined, params, hash, { morph: morph }, env); | |
@@ -7939,6 +7359,7 @@ | |
morph.setContent(result); | |
} | |
} | |
+ exports['default'] = inline; | |
}); | |
enifed('ember-htmlbars/hooks/set', ['exports'], function (exports) { | |
@@ -7950,20 +7371,16 @@ | |
@submodule ember-htmlbars | |
*/ | |
- exports['default'] = set; | |
- | |
function set(env, view, name, value) { | |
view._keywords[name] = value; | |
} | |
+ exports['default'] = set; | |
}); | |
enifed('ember-htmlbars/hooks/subexpr', ['exports', 'ember-htmlbars/system/lookup-helper'], function (exports, lookupHelper) { | |
'use strict'; | |
- | |
- | |
- exports['default'] = subexpr; | |
/** | |
@module ember | |
@submodule ember-htmlbars | |
@@ -7972,22 +7389,20 @@ | |
function subexpr(env, view, path, params, hash) { | |
var helper = lookupHelper['default'](path, view, env); | |
- Ember.assert("A helper named '" + path + "' could not be found", helper); | |
+ Ember.assert("A helper named '"+path+"' could not be found", helper); | |
var options = { | |
isInline: true | |
}; | |
return helper.helperFunction.call(undefined, params, hash, options, env); | |
} | |
+ exports['default'] = subexpr; | |
}); | |
enifed('ember-htmlbars/system/append-templated-view', ['exports', 'ember-metal/core', 'ember-metal/property_get', 'ember-views/views/view'], function (exports, Ember, property_get, View) { | |
'use strict'; | |
- | |
- | |
- exports['default'] = appendTemplatedView; | |
/** | |
@module ember | |
@submodule ember-htmlbars | |
@@ -8001,23 +7416,28 @@ | |
viewProto = viewClassOrInstance.proto(); | |
} | |
- Ember['default'].assert("You cannot provide a template block if you also specified a templateName", !props.template || !property_get.get(props, "templateName") && !property_get.get(viewProto, "templateName")); | |
+ Ember['default'].assert( | |
+ "You cannot provide a template block if you also specified a templateName", | |
+ !props.template || (!property_get.get(props, 'templateName') && !property_get.get(viewProto, 'templateName')) | |
+ ); | |
// We only want to override the `_context` computed property if there is | |
// no specified controller. See View#_context for more information. | |
var noControllerInProto = !viewProto.controller; | |
- if (viewProto.controller && viewProto.controller.isDescriptor) { | |
- noControllerInProto = true; | |
- } | |
- if (noControllerInProto && !viewProto.controllerBinding && !props.controller && !props.controllerBinding) { | |
- props._context = property_get.get(parentView, "context"); // TODO: is this right?! | |
+ if (viewProto.controller && viewProto.controller.isDescriptor) { noControllerInProto = true; } | |
+ if (noControllerInProto && | |
+ !viewProto.controllerBinding && | |
+ !props.controller && | |
+ !props.controllerBinding) { | |
+ props._context = property_get.get(parentView, 'context'); // TODO: is this right?! | |
} | |
props._morph = morph; | |
return parentView.appendChild(viewClassOrInstance, props); | |
} | |
+ exports['default'] = appendTemplatedView; | |
}); | |
enifed('ember-htmlbars/system/bootstrap', ['exports', 'ember-metal/core', 'ember-views/component_lookup', 'ember-views/system/jquery', 'ember-metal/error', 'ember-runtime/system/lazy_load', 'ember-template-compiler/system/compile', 'ember-metal/environment'], function (exports, Ember, ComponentLookup, jQuery, EmberError, lazy_load, htmlbarsCompile, environment) { | |
@@ -8032,22 +7452,25 @@ | |
*/ | |
function bootstrap(ctx) { | |
- var selectors = "script[type=\"text/x-handlebars\"], script[type=\"text/x-raw-handlebars\"]"; | |
+ var selectors = 'script[type="text/x-handlebars"], script[type="text/x-raw-handlebars"]'; | |
- jQuery['default'](selectors, ctx).each(function () { | |
+ jQuery['default'](selectors, ctx) | |
+ .each(function() { | |
// Get a reference to the script tag | |
var script = jQuery['default'](this); | |
- var compile = script.attr("type") === "text/x-raw-handlebars" ? jQuery['default'].proxy(Handlebars.compile, Handlebars) : htmlbarsCompile['default']; | |
+ var compile = (script.attr('type') === 'text/x-raw-handlebars') ? | |
+ jQuery['default'].proxy(Handlebars.compile, Handlebars) : | |
+ htmlbarsCompile['default']; | |
// Get the name of the script, used by Ember.View's templateName property. | |
// First look for data-template-name attribute, then fall back to its | |
// id if no name is found. | |
- var templateName = script.attr("data-template-name") || script.attr("id") || "application"; | |
+ var templateName = script.attr('data-template-name') || script.attr('id') || 'application'; | |
var template = compile(script.html()); | |
// Check if template of same name already exists | |
if (Ember['default'].TEMPLATES[templateName] !== undefined) { | |
- throw new EmberError['default']("Template named \"" + templateName + "\" already exists."); | |
+ throw new EmberError['default']('Template named "' + templateName + '" already exists.'); | |
} | |
// For templates which have a name, we save them and then remove them from the DOM | |
@@ -8063,7 +7486,7 @@ | |
} | |
function registerComponentLookup(registry) { | |
- registry.register("component-lookup:main", ComponentLookup['default']); | |
+ registry.register('component-lookup:main', ComponentLookup['default']); | |
} | |
/* | |
@@ -8077,15 +7500,15 @@ | |
from the DOM after processing. | |
*/ | |
- lazy_load.onLoad("Ember.Application", function (Application) { | |
+ lazy_load.onLoad('Ember.Application', function(Application) { | |
Application.initializer({ | |
- name: "domTemplates", | |
- initialize: environment['default'].hasDOM ? _bootstrap : function () {} | |
+ name: 'domTemplates', | |
+ initialize: environment['default'].hasDOM ? _bootstrap : function() { } | |
}); | |
Application.initializer({ | |
- name: "registerComponentLookup", | |
- after: "domTemplates", | |
+ name: 'registerComponentLookup', | |
+ after: 'domTemplates', | |
initialize: registerComponentLookup | |
}); | |
}); | |
@@ -8121,6 +7544,15 @@ | |
'use strict'; | |
/** | |
+ @module ember | |
+ @submodule ember-htmlbars | |
+ */ | |
+ | |
+ var ISNT_HELPER_CACHE = new Cache['default'](1000, function(key) { | |
+ return key.indexOf('-') === -1; | |
+ }); | |
+ | |
+ /** | |
Used to lookup/resolve handlebars helpers. The lookup order is: | |
* Look for a registered helper | |
@@ -8135,15 +7567,7 @@ | |
@param {String} name the name of the helper to lookup | |
@return {Handlebars Helper} | |
*/ | |
- exports['default'] = lookupHelper; | |
- /** | |
- @module ember | |
- @submodule ember-htmlbars | |
- */ | |
- | |
- var ISNT_HELPER_CACHE = new Cache['default'](1000, function (key) { | |
- return key.indexOf("-") === -1; | |
- });function lookupHelper(name, view, env) { | |
+ function lookupHelper(name, view, env) { | |
var helper = env.helpers[name]; | |
if (helper) { | |
return helper; | |
@@ -8155,11 +7579,12 @@ | |
return; | |
} | |
- var helperName = "helper:" + name; | |
+ var helperName = 'helper:' + name; | |
helper = container.lookup(helperName); | |
if (!helper) { | |
- var componentLookup = container.lookup("component-lookup:main"); | |
- Ember['default'].assert("Could not find 'component-lookup:main' on the provided container," + " which is necessary for performing component lookups", componentLookup); | |
+ var componentLookup = container.lookup('component-lookup:main'); | |
+ Ember['default'].assert("Could not find 'component-lookup:main' on the provided container," + | |
+ " which is necessary for performing component lookups", componentLookup); | |
var Component = componentLookup.lookupFactory(name, container); | |
if (Component) { | |
@@ -8176,6 +7601,7 @@ | |
return helper; | |
} | |
+ exports['default'] = lookupHelper; | |
exports.ISNT_HELPER_CACHE = ISNT_HELPER_CACHE; | |
@@ -8184,20 +7610,6 @@ | |
'use strict'; | |
- | |
- | |
- /** | |
- Returns a helper function that renders the provided ViewClass. | |
- | |
- Used internally by Ember.Handlebars.helper and other methods | |
- involving helper/component registration. | |
- | |
- @private | |
- @method makeViewHelper | |
- @param {Function} ViewClass view class constructor | |
- @since 1.2.0 | |
- */ | |
- exports['default'] = makeViewHelper; | |
/** | |
@module ember | |
@submodule ember-htmlbars | |
@@ -8205,65 +7617,21 @@ | |
function makeViewHelper(ViewClass) { | |
function helperFunc(params, hash, options, env) { | |
- Ember['default'].assert("You can only pass attributes (such as name=value) not bare " + "values to a helper for a View found in '" + ViewClass.toString() + "'", params.length === 0); | |
+ Ember['default'].assert("You can only pass attributes (such as name=value) not bare " + | |
+ "values to a helper for a View found in '" + ViewClass.toString() + "'", params.length === 0); | |
return env.helpers.view.helperFunction.call(this, [ViewClass], hash, options, env); | |
} | |
return new Helper['default'](helperFunc); | |
} | |
+ exports['default'] = makeViewHelper; | |
}); | |
enifed('ember-htmlbars/system/make_bound_helper', ['exports', 'ember-metal/core', 'ember-htmlbars/system/helper', 'ember-metal/streams/stream', 'ember-metal/streams/utils'], function (exports, Ember, Helper, Stream, utils) { | |
'use strict'; | |
- | |
- | |
- /** | |
- Create a bound helper. Accepts a function that receives the ordered and hash parameters | |
- from the template. If a bound property was provided in the template it will be resolved to its | |
- value and any changes to the bound property cause the helper function to be re-run with the updated | |
- values. | |
- | |
- * `params` - An array of resolved ordered parameters. | |
- * `hash` - An object containing the hash parameters. | |
- | |
- For example: | |
- | |
- * With an unquoted ordered parameter: | |
- | |
- ```javascript | |
- {{x-capitalize foo}} | |
- ``` | |
- | |
- Assuming `foo` was set to `"bar"`, the bound helper would receive `["bar"]` as its first argument, and | |
- an empty hash as its second. | |
- | |
- * With a quoted ordered parameter: | |
- | |
- ```javascript | |
- {{x-capitalize "foo"}} | |
- ``` | |
- | |
- The bound helper would receive `["foo"]` as its first argument, and an empty hash as its second. | |
- | |
- * With an unquoted hash parameter: | |
- | |
- ```javascript | |
- {{x-repeat "foo" count=repeatCount}} | |
- ``` | |
- | |
- Assuming that `repeatCount` resolved to 2, the bound helper would receive `["foo"]` as its first argument, | |
- and { count: 2 } as its second. | |
- | |
- @private | |
- @method makeBoundHelper | |
- @for Ember.HTMLBars | |
- @param {Function} function | |
- @since 1.10.0 | |
- */ | |
- exports['default'] = makeBoundHelper; | |
/** | |
@module ember | |
@submodule ember-htmlbars | |
@@ -8305,38 +7673,51 @@ | |
return new Helper['default'](helperFunc); | |
} | |
+ exports['default'] = makeBoundHelper; | |
}); | |
enifed('ember-htmlbars/system/merge-view-bindings', ['exports', 'ember-metal/core', 'ember-metal/mixin', 'ember-metal/streams/simple', 'ember-metal/streams/utils', 'ember-views/streams/class_name_binding'], function (exports, Ember, mixin, SimpleStream, utils, class_name_binding) { | |
'use strict'; | |
- | |
- | |
- exports['default'] = mergeViewBindings; | |
- | |
var a_push = Array.prototype.push; | |
+ | |
function mergeViewBindings(view, props, hash) { | |
mergeGenericViewBindings(view, props, hash); | |
mergeDOMViewBindings(view, props, hash); | |
return props; | |
} | |
+ exports['default'] = mergeViewBindings; | |
function mergeGenericViewBindings(view, props, hash) { | |
for (var key in hash) { | |
- if (key === "id" || key === "tag" || key === "class" || key === "classBinding" || key === "classNameBindings" || key === "attributeBindings") { | |
+ if (key === 'id' || | |
+ key === 'tag' || | |
+ key === 'class' || | |
+ key === 'classBinding' || | |
+ key === 'classNameBindings' || | |
+ key === 'attributeBindings') { | |
continue; | |
} | |
var value = hash[key]; | |
if (mixin.IS_BINDING.test(key)) { | |
- if (typeof value === "string") { | |
- Ember['default'].deprecate("You're attempting to render a view by passing " + key + " " + "to a view helper, but this syntax is deprecated. You should use `" + key.slice(0, -7) + "=someValue` instead."); | |
+ if (typeof value === 'string') { | |
+ Ember['default'].deprecate( | |
+ "You're attempting to render a view by passing " + key + " " + | |
+ "to a view helper, but this syntax is deprecated. You should use `" + | |
+ key.slice(0, -7) + "=someValue` instead." | |
+ ); | |
props[key] = view._getBindingForStream(value); | |
} else if (utils.isStream(value)) { | |
- Ember['default'].deprecate("You're attempting to render a view by passing " + key + " " + "to a view helper without a quoted value, but this syntax is " + "ambiguous. You should either surround " + key + "'s value in " + "quotes or remove `Binding` from " + key + "."); | |
+ Ember['default'].deprecate( | |
+ "You're attempting to render a view by passing " + key + " " + | |
+ "to a view helper without a quoted value, but this syntax is " + | |
+ "ambiguous. You should either surround " + key + "'s value in " + | |
+ "quotes or remove `Binding` from " + key + "." | |
+ ); | |
props[key] = view._getBindingForStream(value); | |
} else { | |
@@ -8344,7 +7725,7 @@ | |
} | |
} else { | |
if (utils.isStream(value)) { | |
- props[key + "Binding"] = view._getBindingForStream(value); | |
+ props[key + 'Binding'] = view._getBindingForStream(value); | |
} else { | |
props[key] = value; | |
} | |
@@ -8353,7 +7734,11 @@ | |
} | |
function mergeDOMViewBindings(view, props, hash) { | |
- Ember['default'].assert("Setting 'attributeBindings' via template helpers is not allowed. " + "Please subclass Ember.View and set it there instead.", !hash.attributeBindings); | |
+ Ember['default'].assert( | |
+ "Setting 'attributeBindings' via template helpers is not allowed. " + | |
+ "Please subclass Ember.View and set it there instead.", | |
+ !hash.attributeBindings | |
+ ); | |
if (hash.id) { | |
props.id = props.elementId = utils.read(hash.id); | |
@@ -8365,27 +7750,27 @@ | |
var classBindings = []; | |
- if (hash["class"]) { | |
- if (typeof hash["class"] === "string") { | |
- props.classNames = hash["class"].split(" "); | |
- } else if (hash["class"]._label) { | |
+ if (hash['class']) { | |
+ if (typeof hash['class'] === 'string') { | |
+ props.classNames = hash['class'].split(' '); | |
+ } else if (hash['class']._label) { | |
// label exists for via property paths in the template | |
// but not for streams with nested sub-expressions | |
- classBindings.push(hash["class"]._label); | |
+ classBindings.push(hash['class']._label); | |
} else { | |
// this stream did not have a label which means that | |
// it is not a simple property path type stream (likely | |
// the result of a sub-expression) | |
- classBindings.push(hash["class"]); | |
+ classBindings.push(hash['class']); | |
} | |
} | |
if (hash.classBinding) { | |
- a_push.apply(classBindings, hash.classBinding.split(" ")); | |
+ a_push.apply(classBindings, hash.classBinding.split(' ')); | |
} | |
if (hash.classNameBindings) { | |
- a_push.apply(classBindings, hash.classNameBindings.split(" ")); | |
+ a_push.apply(classBindings, hash.classNameBindings.split(' ')); | |
} | |
if (classBindings.length > 0) { | |
@@ -8415,10 +7800,6 @@ | |
'use strict'; | |
- | |
- | |
- exports['default'] = renderView; | |
- | |
function renderView(view, buffer, template) { | |
if (!template) { | |
return; | |
@@ -8427,10 +7808,10 @@ | |
var output; | |
if (template.isHTMLBars) { | |
- Ember['default'].assert("template must be an object. Did you mean to call Ember.Handlebars.compile(\"...\") or specify templateName instead?", typeof template === "object"); | |
+ Ember['default'].assert('template must be an object. Did you mean to call Ember.Handlebars.compile("...") or specify templateName instead?', typeof template === 'object'); | |
output = renderHTMLBarsTemplate(view, buffer, template); | |
} else { | |
- Ember['default'].assert("template must be a function. Did you mean to call Ember.Handlebars.compile(\"...\") or specify templateName instead?", typeof template === "function"); | |
+ Ember['default'].assert('template must be a function. Did you mean to call Ember.Handlebars.compile("...") or specify templateName instead?', typeof template === 'function'); | |
output = renderLegacyTemplate(view, buffer, template); | |
} | |
@@ -8438,9 +7819,14 @@ | |
buffer.push(output); | |
} | |
} | |
+ exports['default'] = renderView; | |
function renderHTMLBarsTemplate(view, buffer, template) { | |
- Ember['default'].assert("The template being rendered by `" + view + "` was compiled with `" + template.revision + "` which does not match `[email protected]` (this revision).", template.revision === "[email protected]"); | |
+ Ember['default'].assert( | |
+ 'The template being rendered by `' + view + '` was compiled with `' + template.revision + | |
+ '` which does not match `[email protected]` (this revision).', | |
+ template.revision === '[email protected]' | |
+ ); | |
var contextualElement = buffer.innerContextualElement(); | |
var args = view._blockArguments; | |
@@ -8460,7 +7846,7 @@ | |
} | |
function renderLegacyTemplate(view, buffer, template) { | |
- var context = property_get.get(view, "context"); | |
+ var context = property_get.get(view, 'context'); | |
var options = { | |
data: { | |
view: view, | |
@@ -8476,7 +7862,7 @@ | |
'use strict'; | |
- exports['default'] = template['default']((function () { | |
+ exports['default'] = template['default']((function() { | |
return { | |
isHTMLBars: true, | |
revision: "[email protected]", | |
@@ -8491,8 +7877,7 @@ | |
}, | |
render: function render(context, env, contextualElement) { | |
var dom = env.dom; | |
- var hooks = env.hooks, | |
- content = hooks.content; | |
+ var hooks = env.hooks, content = hooks.content; | |
dom.detectNamespace(contextualElement); | |
var fragment; | |
if (env.useFragmentCache && dom.canClone) { | |
@@ -8510,21 +7895,21 @@ | |
} else { | |
fragment = this.build(dom); | |
} | |
- var morph0 = dom.createMorphAt(fragment, 0, 0, contextualElement); | |
+ var morph0 = dom.createMorphAt(fragment,0,0,contextualElement); | |
dom.insertBoundary(fragment, null); | |
dom.insertBoundary(fragment, 0); | |
content(env, morph0, context, "yield"); | |
return fragment; | |
} | |
}; | |
- })()); | |
+ }())); | |
}); | |
enifed('ember-htmlbars/templates/empty', ['exports', 'ember-template-compiler/system/template'], function (exports, template) { | |
'use strict'; | |
- exports['default'] = template['default']((function () { | |
+ exports['default'] = template['default']((function() { | |
return { | |
isHTMLBars: true, | |
revision: "[email protected]", | |
@@ -8557,14 +7942,14 @@ | |
return fragment; | |
} | |
}; | |
- })()); | |
+ }())); | |
}); | |
enifed('ember-htmlbars/templates/link-to-escaped', ['exports', 'ember-template-compiler/system/template'], function (exports, template) { | |
'use strict'; | |
- exports['default'] = template['default']((function () { | |
+ exports['default'] = template['default']((function() { | |
return { | |
isHTMLBars: true, | |
revision: "[email protected]", | |
@@ -8579,8 +7964,7 @@ | |
}, | |
render: function render(context, env, contextualElement) { | |
var dom = env.dom; | |
- var hooks = env.hooks, | |
- content = hooks.content; | |
+ var hooks = env.hooks, content = hooks.content; | |
dom.detectNamespace(contextualElement); | |
var fragment; | |
if (env.useFragmentCache && dom.canClone) { | |
@@ -8598,21 +7982,21 @@ | |
} else { | |
fragment = this.build(dom); | |
} | |
- var morph0 = dom.createMorphAt(fragment, 0, 0, contextualElement); | |
+ var morph0 = dom.createMorphAt(fragment,0,0,contextualElement); | |
dom.insertBoundary(fragment, null); | |
dom.insertBoundary(fragment, 0); | |
content(env, morph0, context, "linkTitle"); | |
return fragment; | |
} | |
}; | |
- })()); | |
+ }())); | |
}); | |
enifed('ember-htmlbars/templates/link-to-unescaped', ['exports', 'ember-template-compiler/system/template'], function (exports, template) { | |
'use strict'; | |
- exports['default'] = template['default']((function () { | |
+ exports['default'] = template['default']((function() { | |
return { | |
isHTMLBars: true, | |
revision: "[email protected]", | |
@@ -8627,8 +8011,7 @@ | |
}, | |
render: function render(context, env, contextualElement) { | |
var dom = env.dom; | |
- var hooks = env.hooks, | |
- content = hooks.content; | |
+ var hooks = env.hooks, content = hooks.content; | |
dom.detectNamespace(contextualElement); | |
var fragment; | |
if (env.useFragmentCache && dom.canClone) { | |
@@ -8646,21 +8029,21 @@ | |
} else { | |
fragment = this.build(dom); | |
} | |
- var morph0 = dom.createUnsafeMorphAt(fragment, 0, 0, contextualElement); | |
+ var morph0 = dom.createUnsafeMorphAt(fragment,0,0,contextualElement); | |
dom.insertBoundary(fragment, null); | |
dom.insertBoundary(fragment, 0); | |
content(env, morph0, context, "linkTitle"); | |
return fragment; | |
} | |
}; | |
- })()); | |
+ }())); | |
}); | |
enifed('ember-htmlbars/templates/select-option', ['exports', 'ember-template-compiler/system/template'], function (exports, template) { | |
'use strict'; | |
- exports['default'] = template['default']((function () { | |
+ exports['default'] = template['default']((function() { | |
return { | |
isHTMLBars: true, | |
revision: "[email protected]", | |
@@ -8675,8 +8058,7 @@ | |
}, | |
render: function render(context, env, contextualElement) { | |
var dom = env.dom; | |
- var hooks = env.hooks, | |
- content = hooks.content; | |
+ var hooks = env.hooks, content = hooks.content; | |
dom.detectNamespace(contextualElement); | |
var fragment; | |
if (env.useFragmentCache && dom.canClone) { | |
@@ -8694,22 +8076,22 @@ | |
} else { | |
fragment = this.build(dom); | |
} | |
- var morph0 = dom.createMorphAt(fragment, 0, 0, contextualElement); | |
+ var morph0 = dom.createMorphAt(fragment,0,0,contextualElement); | |
dom.insertBoundary(fragment, null); | |
dom.insertBoundary(fragment, 0); | |
content(env, morph0, context, "view.label"); | |
return fragment; | |
} | |
}; | |
- })()); | |
+ }())); | |
}); | |
enifed('ember-htmlbars/templates/select', ['exports', 'ember-template-compiler/system/template'], function (exports, template) { | |
'use strict'; | |
- exports['default'] = template['default']((function () { | |
- var child0 = (function () { | |
+ exports['default'] = template['default']((function() { | |
+ var child0 = (function() { | |
return { | |
isHTMLBars: true, | |
revision: "[email protected]", | |
@@ -8719,7 +8101,7 @@ | |
build: function build(dom) { | |
var el0 = dom.createDocumentFragment(); | |
var el1 = dom.createElement("option"); | |
- dom.setAttribute(el1, "value", ""); | |
+ dom.setAttribute(el1,"value",""); | |
var el2 = dom.createComment(""); | |
dom.appendChild(el1, el2); | |
dom.appendChild(el0, el1); | |
@@ -8727,8 +8109,7 @@ | |
}, | |
render: function render(context, env, contextualElement) { | |
var dom = env.dom; | |
- var hooks = env.hooks, | |
- content = hooks.content; | |
+ var hooks = env.hooks, content = hooks.content; | |
dom.detectNamespace(contextualElement); | |
var fragment; | |
if (env.useFragmentCache && dom.canClone) { | |
@@ -8746,14 +8127,14 @@ | |
} else { | |
fragment = this.build(dom); | |
} | |
- var morph0 = dom.createMorphAt(dom.childAt(fragment, [0]), 0, 0); | |
+ var morph0 = dom.createMorphAt(dom.childAt(fragment, [0]),0,0); | |
content(env, morph0, context, "view.prompt"); | |
return fragment; | |
} | |
}; | |
- })(); | |
- var child1 = (function () { | |
- var child0 = (function () { | |
+ }()); | |
+ var child1 = (function() { | |
+ var child0 = (function() { | |
return { | |
isHTMLBars: true, | |
revision: "[email protected]", | |
@@ -8768,9 +8149,7 @@ | |
}, | |
render: function render(context, env, contextualElement) { | |
var dom = env.dom; | |
- var hooks = env.hooks, | |
- get = hooks.get, | |
- inline = hooks.inline; | |
+ var hooks = env.hooks, get = hooks.get, inline = hooks.inline; | |
dom.detectNamespace(contextualElement); | |
var fragment; | |
if (env.useFragmentCache && dom.canClone) { | |
@@ -8788,14 +8167,14 @@ | |
} else { | |
fragment = this.build(dom); | |
} | |
- var morph0 = dom.createMorphAt(fragment, 0, 0, contextualElement); | |
+ var morph0 = dom.createMorphAt(fragment,0,0,contextualElement); | |
dom.insertBoundary(fragment, null); | |
dom.insertBoundary(fragment, 0); | |
- inline(env, morph0, context, "view", [get(env, context, "view.groupView")], { "content": get(env, context, "group.content"), "label": get(env, context, "group.label") }); | |
+ inline(env, morph0, context, "view", [get(env, context, "view.groupView")], {"content": get(env, context, "group.content"), "label": get(env, context, "group.label")}); | |
return fragment; | |
} | |
}; | |
- })(); | |
+ }()); | |
return { | |
isHTMLBars: true, | |
revision: "[email protected]", | |
@@ -8810,9 +8189,7 @@ | |
}, | |
render: function render(context, env, contextualElement) { | |
var dom = env.dom; | |
- var hooks = env.hooks, | |
- get = hooks.get, | |
- block = hooks.block; | |
+ var hooks = env.hooks, get = hooks.get, block = hooks.block; | |
dom.detectNamespace(contextualElement); | |
var fragment; | |
if (env.useFragmentCache && dom.canClone) { | |
@@ -8830,16 +8207,16 @@ | |
} else { | |
fragment = this.build(dom); | |
} | |
- var morph0 = dom.createMorphAt(fragment, 0, 0, contextualElement); | |
+ var morph0 = dom.createMorphAt(fragment,0,0,contextualElement); | |
dom.insertBoundary(fragment, null); | |
dom.insertBoundary(fragment, 0); | |
- block(env, morph0, context, "each", [get(env, context, "view.groupedContent")], { "keyword": "group" }, child0, null); | |
+ block(env, morph0, context, "each", [get(env, context, "view.groupedContent")], {"keyword": "group"}, child0, null); | |
return fragment; | |
} | |
}; | |
- })(); | |
- var child2 = (function () { | |
- var child0 = (function () { | |
+ }()); | |
+ var child2 = (function() { | |
+ var child0 = (function() { | |
return { | |
isHTMLBars: true, | |
revision: "[email protected]", | |
@@ -8854,9 +8231,7 @@ | |
}, | |
render: function render(context, env, contextualElement) { | |
var dom = env.dom; | |
- var hooks = env.hooks, | |
- get = hooks.get, | |
- inline = hooks.inline; | |
+ var hooks = env.hooks, get = hooks.get, inline = hooks.inline; | |
dom.detectNamespace(contextualElement); | |
var fragment; | |
if (env.useFragmentCache && dom.canClone) { | |
@@ -8874,14 +8249,14 @@ | |
} else { | |
fragment = this.build(dom); | |
} | |
- var morph0 = dom.createMorphAt(fragment, 0, 0, contextualElement); | |
+ var morph0 = dom.createMorphAt(fragment,0,0,contextualElement); | |
dom.insertBoundary(fragment, null); | |
dom.insertBoundary(fragment, 0); | |
- inline(env, morph0, context, "view", [get(env, context, "view.optionView")], { "content": get(env, context, "item") }); | |
+ inline(env, morph0, context, "view", [get(env, context, "view.optionView")], {"content": get(env, context, "item")}); | |
return fragment; | |
} | |
}; | |
- })(); | |
+ }()); | |
return { | |
isHTMLBars: true, | |
revision: "[email protected]", | |
@@ -8896,9 +8271,7 @@ | |
}, | |
render: function render(context, env, contextualElement) { | |
var dom = env.dom; | |
- var hooks = env.hooks, | |
- get = hooks.get, | |
- block = hooks.block; | |
+ var hooks = env.hooks, get = hooks.get, block = hooks.block; | |
dom.detectNamespace(contextualElement); | |
var fragment; | |
if (env.useFragmentCache && dom.canClone) { | |
@@ -8916,14 +8289,14 @@ | |
} else { | |
fragment = this.build(dom); | |
} | |
- var morph0 = dom.createMorphAt(fragment, 0, 0, contextualElement); | |
+ var morph0 = dom.createMorphAt(fragment,0,0,contextualElement); | |
dom.insertBoundary(fragment, null); | |
dom.insertBoundary(fragment, 0); | |
- block(env, morph0, context, "each", [get(env, context, "view.content")], { "keyword": "item" }, child0, null); | |
+ block(env, morph0, context, "each", [get(env, context, "view.content")], {"keyword": "item"}, child0, null); | |
return fragment; | |
} | |
}; | |
- })(); | |
+ }()); | |
return { | |
isHTMLBars: true, | |
revision: "[email protected]", | |
@@ -8942,9 +8315,7 @@ | |
}, | |
render: function render(context, env, contextualElement) { | |
var dom = env.dom; | |
- var hooks = env.hooks, | |
- get = hooks.get, | |
- block = hooks.block; | |
+ var hooks = env.hooks, get = hooks.get, block = hooks.block; | |
dom.detectNamespace(contextualElement); | |
var fragment; | |
if (env.useFragmentCache && dom.canClone) { | |
@@ -8962,15 +8333,15 @@ | |
} else { | |
fragment = this.build(dom); | |
} | |
- var morph0 = dom.createMorphAt(fragment, 0, 0, contextualElement); | |
- var morph1 = dom.createMorphAt(fragment, 1, 1, contextualElement); | |
+ var morph0 = dom.createMorphAt(fragment,0,0,contextualElement); | |
+ var morph1 = dom.createMorphAt(fragment,1,1,contextualElement); | |
dom.insertBoundary(fragment, 0); | |
block(env, morph0, context, "if", [get(env, context, "view.prompt")], {}, child0, null); | |
block(env, morph1, context, "if", [get(env, context, "view.optionGroupPath")], {}, child1, child2); | |
return fragment; | |
} | |
}; | |
- })()); | |
+ }())); | |
}); | |
enifed('ember-htmlbars/utils/string', ['exports', 'htmlbars-util', 'ember-runtime/system/string'], function (exports, htmlbars_util, EmberStringUtils) { | |
@@ -8990,8 +8361,8 @@ | |
return ""; | |
} | |
- if (typeof str !== "string") { | |
- str = "" + str; | |
+ if (typeof str !== 'string') { | |
+ str = ''+str; | |
} | |
return new htmlbars_util.SafeString(str); | |
} | |
@@ -9001,15 +8372,18 @@ | |
/** | |
Mark a string as being safe for unescaped output with Handlebars. | |
- ```javascript | |
+ | |
+ ```javascript | |
'<div>someString</div>'.htmlSafe() | |
``` | |
- See [Ember.String.htmlSafe](/api/classes/Ember.String.html#method_htmlSafe). | |
- @method htmlSafe | |
+ | |
+ See [Ember.String.htmlSafe](/api/classes/Ember.String.html#method_htmlSafe). | |
+ | |
+ @method htmlSafe | |
@for String | |
@return {Handlebars.SafeString} a string that will not be html escaped by Handlebars | |
*/ | |
- String.prototype.htmlSafe = function () { | |
+ String.prototype.htmlSafe = function() { | |
return htmlSafe(this); | |
}; | |
} | |
@@ -9039,8 +8413,8 @@ | |
// These sizes and values are somewhat arbitrary (but sensible) | |
// pre-allocation defaults. | |
this._views = new Array(2000); | |
- this._queue = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]; | |
- this._parents = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]; | |
+ this._queue = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]; | |
+ this._parents = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]; | |
this._elements = new Array(17); | |
this._inserts = {}; | |
this._dom = _helper || domHelper; | |
@@ -9052,7 +8426,7 @@ | |
views[0] = _view; | |
var index = 0; | |
var total = 1; | |
- var levelBase = _parentView ? _parentView._level + 1 : 0; | |
+ var levelBase = _parentView ? _parentView._level+1 : 0; | |
var root = _parentView == null ? _view : _parentView._root; | |
@@ -9103,7 +8477,7 @@ | |
// should work fine, because it essentially re-emits the original markup | |
// as a String, which will then be parsed again by the browser, which will | |
// apply the appropriate parsing rules. | |
- contextualElement = typeof document !== "undefined" ? document.body : null; | |
+ contextualElement = typeof document !== 'undefined' ? document.body : null; | |
} | |
element = this.createElement(view, contextualElement); | |
@@ -9116,7 +8490,7 @@ | |
// enqueue children | |
children = this.childViews(view); | |
if (children) { | |
- for (i = children.length - 1; i >= 0; i--) { | |
+ for (i=children.length-1;i>=0;i--) { | |
child = children[i]; | |
index = total++; | |
views[index] = child; | |
@@ -9153,7 +8527,7 @@ | |
this.insertElement(view, _parentView, element, _refMorph); | |
- for (i = total - 1; i >= 0; i--) { | |
+ for (i=total-1; i>=0; i--) { | |
if (willInsert) { | |
views[i]._elementInserted = true; | |
this.didInsertElement(views[i]); | |
@@ -9172,38 +8546,42 @@ | |
return view._uuid; | |
}; | |
- Renderer.prototype.scheduleInsert = function Renderer_scheduleInsert(view, morph) { | |
- if (view._morph || view._elementCreated) { | |
- throw new Error("You cannot insert a View that has already been rendered"); | |
- } | |
- Ember.assert("You cannot insert a View without a morph", morph); | |
- view._morph = morph; | |
- var viewId = this.uuid(view); | |
- this._inserts[viewId] = this.scheduleRender(this, function scheduledRenderTree() { | |
- this._inserts[viewId] = null; | |
- this.renderTree(view); | |
- }); | |
- }; | |
+ Renderer.prototype.scheduleInsert = | |
+ function Renderer_scheduleInsert(view, morph) { | |
+ if (view._morph || view._elementCreated) { | |
+ throw new Error("You cannot insert a View that has already been rendered"); | |
+ } | |
+ Ember.assert("You cannot insert a View without a morph", morph); | |
+ view._morph = morph; | |
+ var viewId = this.uuid(view); | |
+ this._inserts[viewId] = this.scheduleRender(this, function scheduledRenderTree() { | |
+ this._inserts[viewId] = null; | |
+ this.renderTree(view); | |
+ }); | |
+ }; | |
- Renderer.prototype.appendTo = function Renderer_appendTo(view, target) { | |
- var morph = this._dom.appendMorph(target); | |
- this.scheduleInsert(view, morph); | |
- }; | |
+ Renderer.prototype.appendTo = | |
+ function Renderer_appendTo(view, target) { | |
+ var morph = this._dom.appendMorph(target); | |
+ this.scheduleInsert(view, morph); | |
+ }; | |
- Renderer.prototype.appendAttrTo = function Renderer_appendAttrTo(view, target, attrName) { | |
- var morph = this._dom.createAttrMorph(target, attrName); | |
- this.scheduleInsert(view, morph); | |
- }; | |
+ Renderer.prototype.appendAttrTo = | |
+ function Renderer_appendAttrTo(view, target, attrName) { | |
+ var morph = this._dom.createAttrMorph(target, attrName); | |
+ this.scheduleInsert(view, morph); | |
+ }; | |
- Renderer.prototype.replaceIn = function Renderer_replaceIn(view, target) { | |
- var morph; | |
- if (target.firstNode) { | |
- morph = this._dom.createMorph(target, target.firstNode, target.lastNode); | |
- } else { | |
- morph = this._dom.appendMorph(target); | |
- } | |
- this.scheduleInsert(view, morph); | |
- }; | |
+ Renderer.prototype.replaceIn = | |
+ function Renderer_replaceIn(view, target) { | |
+ var morph; | |
+ if (target.firstNode) { | |
+ morph = this._dom.createMorph(target, target.firstNode, target.lastNode); | |
+ } else { | |
+ morph = this._dom.appendMorph(target); | |
+ } | |
+ this.scheduleInsert(view, morph); | |
+ }; | |
function Renderer_remove(_view, shouldDestroy, reset) { | |
var viewId = this.uuid(_view); | |
@@ -9224,7 +8602,7 @@ | |
removeQueue.push(_view); | |
- for (idx = 0; idx < removeQueue.length; idx++) { | |
+ for (idx=0; idx<removeQueue.length; idx++) { | |
view = removeQueue[idx]; | |
if (!shouldDestroy && view._childViewsMorph) { | |
@@ -9237,20 +8615,20 @@ | |
childViews = this.childViews(view); | |
if (childViews) { | |
- for (i = 0, l = childViews.length; i < l; i++) { | |
+ for (i=0,l=childViews.length; i<l; i++) { | |
queue.push(childViews[i]); | |
} | |
} | |
} | |
- for (idx = 0; idx < destroyQueue.length; idx++) { | |
+ for (idx=0; idx<destroyQueue.length; idx++) { | |
view = destroyQueue[idx]; | |
this.beforeRemove(destroyQueue[idx]); | |
childViews = this.childViews(view); | |
if (childViews) { | |
- for (i = 0, l = childViews.length; i < l; i++) { | |
+ for (i=0,l=childViews.length; i<l; i++) { | |
destroyQueue.push(childViews[i]); | |
} | |
} | |
@@ -9261,11 +8639,11 @@ | |
morph.destroy(); | |
} | |
- for (idx = 0, len = removeQueue.length; idx < len; idx++) { | |
+ for (idx=0, len=removeQueue.length; idx < len; idx++) { | |
this.afterRemove(removeQueue[idx], false); | |
} | |
- for (idx = 0, len = destroyQueue.length; idx < len; idx++) { | |
+ for (idx=0, len=destroyQueue.length; idx < len; idx++) { | |
this.afterRemove(destroyQueue[idx], true); | |
} | |
@@ -9373,18 +8751,18 @@ | |
EmberInstrumentation.instrument = instrumentation.instrument; | |
EmberInstrumentation.subscribe = instrumentation.subscribe; | |
EmberInstrumentation.unsubscribe = instrumentation.unsubscribe; | |
- EmberInstrumentation.reset = instrumentation.reset; | |
+ EmberInstrumentation.reset = instrumentation.reset; | |
Ember['default'].instrument = instrumentation.instrument; | |
Ember['default'].subscribe = instrumentation.subscribe; | |
Ember['default']._Cache = Cache['default']; | |
- Ember['default'].generateGuid = utils.generateGuid; | |
- Ember['default'].GUID_KEY = utils.GUID_KEY; | |
- Ember['default'].create = create['default']; | |
- Ember['default'].keys = keys['default']; | |
- Ember['default'].platform = { | |
+ Ember['default'].generateGuid = utils.generateGuid; | |
+ Ember['default'].GUID_KEY = utils.GUID_KEY; | |
+ Ember['default'].create = create['default']; | |
+ Ember['default'].keys = keys['default']; | |
+ Ember['default'].platform = { | |
defineProperty: properties.defineProperty, | |
hasPropertyAccessors: define_property.hasPropertyAccessors | |
}; | |
@@ -9396,45 +8774,45 @@ | |
EmberArrayPolyfills.filter = array.filter; | |
EmberArrayPolyfills.indexOf = array.indexOf; | |
- Ember['default'].Error = EmberError['default']; | |
- Ember['default'].guidFor = utils.guidFor; | |
- Ember['default'].META_DESC = utils.META_DESC; | |
- Ember['default'].EMPTY_META = utils.EMPTY_META; | |
- Ember['default'].meta = utils.meta; | |
- Ember['default'].getMeta = utils.getMeta; | |
- Ember['default'].setMeta = utils.setMeta; | |
- Ember['default'].metaPath = utils.metaPath; | |
- Ember['default'].inspect = utils.inspect; | |
- Ember['default'].typeOf = utils.typeOf; | |
+ Ember['default'].Error = EmberError['default']; | |
+ Ember['default'].guidFor = utils.guidFor; | |
+ Ember['default'].META_DESC = utils.META_DESC; | |
+ Ember['default'].EMPTY_META = utils.EMPTY_META; | |
+ Ember['default'].meta = utils.meta; | |
+ Ember['default'].getMeta = utils.getMeta; | |
+ Ember['default'].setMeta = utils.setMeta; | |
+ Ember['default'].metaPath = utils.metaPath; | |
+ Ember['default'].inspect = utils.inspect; | |
+ Ember['default'].typeOf = utils.typeOf; | |
Ember['default'].tryCatchFinally = utils.tryCatchFinally; | |
- Ember['default'].isArray = utils.isArray; | |
- Ember['default'].makeArray = utils.makeArray; | |
- Ember['default'].canInvoke = utils.canInvoke; | |
- Ember['default'].tryInvoke = utils.tryInvoke; | |
- Ember['default'].tryFinally = utils.tryFinally; | |
- Ember['default'].wrap = utils.wrap; | |
- Ember['default'].apply = utils.apply; | |
- Ember['default'].applyStr = utils.applyStr; | |
- Ember['default'].uuid = utils.uuid; | |
+ Ember['default'].isArray = utils.isArray; | |
+ Ember['default'].makeArray = utils.makeArray; | |
+ Ember['default'].canInvoke = utils.canInvoke; | |
+ Ember['default'].tryInvoke = utils.tryInvoke; | |
+ Ember['default'].tryFinally = utils.tryFinally; | |
+ Ember['default'].wrap = utils.wrap; | |
+ Ember['default'].apply = utils.apply; | |
+ Ember['default'].applyStr = utils.applyStr; | |
+ Ember['default'].uuid = utils.uuid; | |
Ember['default'].Logger = Logger['default']; | |
- Ember['default'].get = property_get.get; | |
+ Ember['default'].get = property_get.get; | |
Ember['default'].getWithDefault = property_get.getWithDefault; | |
Ember['default'].normalizeTuple = property_get.normalizeTuple; | |
- Ember['default']._getPath = property_get._getPath; | |
+ Ember['default']._getPath = property_get._getPath; | |
Ember['default'].EnumerableUtils = EnumerableUtils['default']; | |
- Ember['default'].on = events.on; | |
- Ember['default'].addListener = events.addListener; | |
- Ember['default'].removeListener = events.removeListener; | |
- Ember['default']._suspendListener = events.suspendListener; | |
- Ember['default']._suspendListeners = events.suspendListeners; | |
- Ember['default'].sendEvent = events.sendEvent; | |
- Ember['default'].hasListeners = events.hasListeners; | |
- Ember['default'].watchedEvents = events.watchedEvents; | |
- Ember['default'].listenersFor = events.listenersFor; | |
+ Ember['default'].on = events.on; | |
+ Ember['default'].addListener = events.addListener; | |
+ Ember['default'].removeListener = events.removeListener; | |
+ Ember['default']._suspendListener = events.suspendListener; | |
+ Ember['default']._suspendListeners = events.suspendListeners; | |
+ Ember['default'].sendEvent = events.sendEvent; | |
+ Ember['default'].hasListeners = events.hasListeners; | |
+ Ember['default'].watchedEvents = events.watchedEvents; | |
+ Ember['default'].listenersFor = events.listenersFor; | |
Ember['default'].accumulateListeners = events.accumulateListeners; | |
Ember['default']._ObserverSet = ObserverSet['default']; | |
@@ -9446,10 +8824,10 @@ | |
Ember['default'].endPropertyChanges = property_events.endPropertyChanges; | |
Ember['default'].changeProperties = property_events.changeProperties; | |
- Ember['default'].Descriptor = properties.Descriptor; | |
+ Ember['default'].Descriptor = properties.Descriptor; | |
Ember['default'].defineProperty = properties.defineProperty; | |
- Ember['default'].set = property_set.set; | |
+ Ember['default'].set = property_set.set; | |
Ember['default'].trySet = property_set.trySet; | |
Ember['default'].OrderedSet = map.OrderedSet; | |
@@ -9459,7 +8837,7 @@ | |
Ember['default'].getProperties = getProperties['default']; | |
Ember['default'].setProperties = setProperties['default']; | |
- Ember['default'].watchKey = watch_key.watchKey; | |
+ Ember['default'].watchKey = watch_key.watchKey; | |
Ember['default'].unwatchKey = watch_key.unwatchKey; | |
Ember['default'].flushPendingChains = chains.flushPendingChains; | |
@@ -9517,7 +8895,7 @@ | |
Ember['default'].Backburner = Backburner['default']; | |
Ember['default'].libraries = new Libraries['default'](); | |
- Ember['default'].libraries.registerCoreLibrary("Ember", Ember['default'].VERSION); | |
+ Ember['default'].libraries.registerCoreLibrary('Ember', Ember['default'].VERSION); | |
Ember['default'].isNone = isNone['default']; | |
Ember['default'].isEmpty = isEmpty['default']; | |
@@ -9552,8 +8930,8 @@ | |
// do this for side-effects of updating Ember.assert, warn, etc when | |
// ember-debug is present | |
- if (Ember['default'].__loader.registry["ember-debug"]) { | |
- requireModule("ember-debug"); | |
+ if (Ember['default'].__loader.registry['ember-debug']) { | |
+ requireModule('ember-debug'); | |
} | |
exports['default'] = Ember['default']; | |
@@ -9565,11 +8943,10 @@ | |
exports.AliasedProperty = AliasedProperty; | |
- exports['default'] = alias; | |
- | |
function alias(altKey) { | |
return new AliasedProperty(altKey); | |
} | |
+ exports['default'] = alias; | |
function AliasedProperty(altKey) { | |
this.isDescriptor = true; | |
@@ -9587,15 +8964,15 @@ | |
return property_set.set(obj, this.altKey, value); | |
}; | |
- AliasedProperty.prototype.willWatch = function (obj, keyName) { | |
+ AliasedProperty.prototype.willWatch = function(obj, keyName) { | |
dependent_keys.addDependentKeys(this, obj, keyName, utils.meta(obj)); | |
}; | |
- AliasedProperty.prototype.didUnwatch = function (obj, keyName) { | |
+ AliasedProperty.prototype.didUnwatch = function(obj, keyName) { | |
dependent_keys.removeDependentKeys(this, obj, keyName, utils.meta(obj)); | |
}; | |
- AliasedProperty.prototype.setup = function (obj, keyName) { | |
+ AliasedProperty.prototype.setup = function(obj, keyName) { | |
Ember['default'].assert("Setting alias '" + keyName + "' on self", this.altKey !== keyName); | |
var m = utils.meta(obj); | |
if (m.watching[keyName]) { | |
@@ -9603,23 +8980,23 @@ | |
} | |
}; | |
- AliasedProperty.prototype.teardown = function (obj, keyName) { | |
+ AliasedProperty.prototype.teardown = function(obj, keyName) { | |
var m = utils.meta(obj); | |
if (m.watching[keyName]) { | |
dependent_keys.removeDependentKeys(this, obj, keyName, m); | |
} | |
}; | |
- AliasedProperty.prototype.readOnly = function () { | |
+ AliasedProperty.prototype.readOnly = function() { | |
this.set = AliasedProperty_readOnlySet; | |
return this; | |
}; | |
function AliasedProperty_readOnlySet(obj, keyName, value) { | |
- throw new EmberError['default']("Cannot set read-only property \"" + keyName + "\" on object: " + utils.inspect(obj)); | |
+ throw new EmberError['default']('Cannot set read-only property "' + keyName + '" on object: ' + utils.inspect(obj)); | |
} | |
- AliasedProperty.prototype.oneWay = function () { | |
+ AliasedProperty.prototype.oneWay = function() { | |
this.set = AliasedProperty_oneWaySet; | |
return this; | |
}; | |
@@ -9646,12 +9023,12 @@ | |
// Testing this is not ideal, but we want to use native functions | |
// if available, but not to use versions created by libraries like Prototype | |
- var isNativeFunc = function (func) { | |
+ var isNativeFunc = function(func) { | |
// This should probably work in all browsers likely to have ES5 array methods | |
- return func && Function.prototype.toString.call(func).indexOf("[native code]") > -1; | |
+ return func && Function.prototype.toString.call(func).indexOf('[native code]') > -1; | |
}; | |
- var defineNativeShim = function (nativeFunc, shim) { | |
+ var defineNativeShim = function(nativeFunc, shim) { | |
if (isNativeFunc(nativeFunc)) { | |
return nativeFunc; | |
} | |
@@ -9659,7 +9036,7 @@ | |
}; | |
// From: https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/array/map | |
- var map = defineNativeShim(ArrayPrototype.map, function (fun /*, thisp */) { | |
+ var map = defineNativeShim(ArrayPrototype.map, function(fun /*, thisp */) { | |
//"use strict"; | |
if (this === void 0 || this === null || typeof fun !== "function") { | |
@@ -9681,7 +9058,7 @@ | |
}); | |
// From: https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/array/foreach | |
- var forEach = defineNativeShim(ArrayPrototype.forEach, function (fun /*, thisp */) { | |
+ var forEach = defineNativeShim(ArrayPrototype.forEach, function(fun /*, thisp */) { | |
//"use strict"; | |
if (this === void 0 || this === null || typeof fun !== "function") { | |
@@ -9714,14 +9091,14 @@ | |
return -1; | |
}); | |
- var lastIndexOf = defineNativeShim(ArrayPrototype.lastIndexOf, function (obj, fromIndex) { | |
+ var lastIndexOf = defineNativeShim(ArrayPrototype.lastIndexOf, function(obj, fromIndex) { | |
var len = this.length; | |
var idx; | |
if (fromIndex === undefined) { | |
- fromIndex = len - 1; | |
+ fromIndex = len-1; | |
} else { | |
- fromIndex = fromIndex < 0 ? Math.ceil(fromIndex) : Math.floor(fromIndex); | |
+ fromIndex = (fromIndex < 0) ? Math.ceil(fromIndex) : Math.floor(fromIndex); | |
} | |
if (fromIndex < 0) { | |
@@ -9732,200 +9109,56 @@ | |
if (this[idx] === obj) { | |
return idx; | |
} | |
- } | |
- return -1; | |
- }); | |
- | |
- var filter = defineNativeShim(ArrayPrototype.filter, function (fn, context) { | |
- var i, value; | |
- var result = []; | |
- var length = this.length; | |
- | |
- for (i = 0; i < length; i++) { | |
- if (this.hasOwnProperty(i)) { | |
- value = this[i]; | |
- if (fn.call(context, value, i, this)) { | |
- result.push(value); | |
- } | |
- } | |
- } | |
- return result; | |
- }); | |
- | |
- if (Ember.SHIM_ES5) { | |
- ArrayPrototype.map = ArrayPrototype.map || map; | |
- ArrayPrototype.forEach = ArrayPrototype.forEach || forEach; | |
- ArrayPrototype.filter = ArrayPrototype.filter || filter; | |
- ArrayPrototype.indexOf = ArrayPrototype.indexOf || indexOf; | |
- ArrayPrototype.lastIndexOf = ArrayPrototype.lastIndexOf || lastIndexOf; | |
- } | |
- | |
- /** | |
- Array polyfills to support ES5 features in older browsers. | |
- | |
- @namespace Ember | |
- @property ArrayPolyfills | |
- */ | |
- | |
- exports.map = map; | |
- exports.forEach = forEach; | |
- exports.filter = filter; | |
- exports.indexOf = indexOf; | |
- exports.lastIndexOf = lastIndexOf; | |
- | |
-}); | |
-enifed('ember-metal/binding', ['exports', 'ember-metal/core', 'ember-metal/property_get', 'ember-metal/property_set', 'ember-metal/utils', 'ember-metal/observer', 'ember-metal/run_loop', 'ember-metal/path_cache'], function (exports, Ember, property_get, property_set, utils, observer, run, path_cache) { | |
- | |
- 'use strict'; | |
- | |
- exports.bind = bind; | |
- exports.oneWay = oneWay; | |
- exports.Binding = Binding; | |
- | |
- /** | |
- An `Ember.Binding` connects the properties of two objects so that whenever | |
- the value of one property changes, the other property will be changed also. | |
- | |
- ## Automatic Creation of Bindings with `/^*Binding/`-named Properties | |
- | |
- You do not usually create Binding objects directly but instead describe | |
- bindings in your class or object definition using automatic binding | |
- detection. | |
- | |
- Properties ending in a `Binding` suffix will be converted to `Ember.Binding` | |
- instances. The value of this property should be a string representing a path | |
- to another object or a custom binding instance created using Binding helpers | |
- (see "One Way Bindings"): | |
- | |
- ``` | |
- valueBinding: "MyApp.someController.title" | |
- ``` | |
- | |
- This will create a binding from `MyApp.someController.title` to the `value` | |
- property of your object instance automatically. Now the two values will be | |
- kept in sync. | |
- | |
- ## One Way Bindings | |
- | |
- One especially useful binding customization you can use is the `oneWay()` | |
- helper. This helper tells Ember that you are only interested in | |
- receiving changes on the object you are binding from. For example, if you | |
- are binding to a preference and you want to be notified if the preference | |
- has changed, but your object will not be changing the preference itself, you | |
- could do: | |
- | |
- ``` | |
- bigTitlesBinding: Ember.Binding.oneWay("MyApp.preferencesController.bigTitles") | |
- ``` | |
- | |
- This way if the value of `MyApp.preferencesController.bigTitles` changes the | |
- `bigTitles` property of your object will change also. However, if you | |
- change the value of your `bigTitles` property, it will not update the | |
- `preferencesController`. | |
- | |
- One way bindings are almost twice as fast to setup and twice as fast to | |
- execute because the binding only has to worry about changes to one side. | |
- | |
- You should consider using one way bindings anytime you have an object that | |
- may be created frequently and you do not intend to change a property; only | |
- to monitor it for changes (such as in the example above). | |
- | |
- ## Adding Bindings Manually | |
- | |
- All of the examples above show you how to configure a custom binding, but the | |
- result of these customizations will be a binding template, not a fully active | |
- Binding instance. The binding will actually become active only when you | |
- instantiate the object the binding belongs to. It is useful however, to | |
- understand what actually happens when the binding is activated. | |
- | |
- For a binding to function it must have at least a `from` property and a `to` | |
- property. The `from` property path points to the object/key that you want to | |
- bind from while the `to` path points to the object/key you want to bind to. | |
- | |
- When you define a custom binding, you are usually describing the property | |
- you want to bind from (such as `MyApp.someController.value` in the examples | |
- above). When your object is created, it will automatically assign the value | |
- you want to bind `to` based on the name of your binding key. In the | |
- examples above, during init, Ember objects will effectively call | |
- something like this on your binding: | |
- | |
- ```javascript | |
- binding = Ember.Binding.from("valueBinding").to("value"); | |
- ``` | |
- | |
- This creates a new binding instance based on the template you provide, and | |
- sets the to path to the `value` property of the new object. Now that the | |
- binding is fully configured with a `from` and a `to`, it simply needs to be | |
- connected to become active. This is done through the `connect()` method: | |
- | |
- ```javascript | |
- binding.connect(this); | |
- ``` | |
- | |
- Note that when you connect a binding you pass the object you want it to be | |
- connected to. This object will be used as the root for both the from and | |
- to side of the binding when inspecting relative paths. This allows the | |
- binding to be automatically inherited by subclassed objects as well. | |
- | |
- This also allows you to bind between objects using the paths you declare in | |
- `from` and `to`: | |
- | |
- ```javascript | |
- // Example 1 | |
- binding = Ember.Binding.from("App.someObject.value").to("value"); | |
- binding.connect(this); | |
- | |
- // Example 2 | |
- binding = Ember.Binding.from("parentView.value").to("App.someObject.value"); | |
- binding.connect(this); | |
- ``` | |
- | |
- Now that the binding is connected, it will observe both the from and to side | |
- and relay changes. | |
- | |
- If you ever needed to do so (you almost never will, but it is useful to | |
- understand this anyway), you could manually create an active binding by | |
- using the `Ember.bind()` helper method. (This is the same method used by | |
- to setup your bindings on objects): | |
- | |
- ```javascript | |
- Ember.bind(MyApp.anotherObject, "value", "MyApp.someController.value"); | |
- ``` | |
+ } | |
+ return -1; | |
+ }); | |
- Both of these code fragments have the same effect as doing the most friendly | |
- form of binding creation like so: | |
+ var filter = defineNativeShim(ArrayPrototype.filter, function (fn, context) { | |
+ var i, value; | |
+ var result = []; | |
+ var length = this.length; | |
- ```javascript | |
- MyApp.anotherObject = Ember.Object.create({ | |
- valueBinding: "MyApp.someController.value", | |
+ for (i = 0; i < length; i++) { | |
+ if (this.hasOwnProperty(i)) { | |
+ value = this[i]; | |
+ if (fn.call(context, value, i, this)) { | |
+ result.push(value); | |
+ } | |
+ } | |
+ } | |
+ return result; | |
+ }); | |
- // OTHER CODE FOR THIS OBJECT... | |
- }); | |
- ``` | |
+ if (Ember.SHIM_ES5) { | |
+ ArrayPrototype.map = ArrayPrototype.map || map; | |
+ ArrayPrototype.forEach = ArrayPrototype.forEach || forEach; | |
+ ArrayPrototype.filter = ArrayPrototype.filter || filter; | |
+ ArrayPrototype.indexOf = ArrayPrototype.indexOf || indexOf; | |
+ ArrayPrototype.lastIndexOf = ArrayPrototype.lastIndexOf || lastIndexOf; | |
+ } | |
- Ember's built in binding creation method makes it easy to automatically | |
- create bindings for you. You should always use the highest-level APIs | |
- available, even if you understand how it works underneath. | |
+ /** | |
+ Array polyfills to support ES5 features in older browsers. | |
- @class Binding | |
@namespace Ember | |
- @since Ember 0.9 | |
+ @property ArrayPolyfills | |
*/ | |
- // Ember.Binding = Binding; ES6TODO: where to put this? | |
- /** | |
- Global helper method to create a new binding. Just pass the root object | |
- along with a `to` and `from` path to create and connect the binding. | |
+ exports.map = map; | |
+ exports.forEach = forEach; | |
+ exports.filter = filter; | |
+ exports.indexOf = indexOf; | |
+ exports.lastIndexOf = lastIndexOf; | |
+ | |
+}); | |
+enifed('ember-metal/binding', ['exports', 'ember-metal/core', 'ember-metal/property_get', 'ember-metal/property_set', 'ember-metal/utils', 'ember-metal/observer', 'ember-metal/run_loop', 'ember-metal/path_cache'], function (exports, Ember, property_get, property_set, utils, observer, run, path_cache) { | |
+ | |
+ 'use strict'; | |
+ | |
+ exports.bind = bind; | |
+ exports.oneWay = oneWay; | |
+ exports.Binding = Binding; | |
- @method bind | |
- @for Ember | |
- @param {Object} obj The root object of the transform. | |
- @param {String} to The path to the 'to' side of the binding. | |
- Must be relative to obj. | |
- @param {String} from The path to the 'from' side of the binding. | |
- Must be relative to obj or a global path. | |
- @return {Ember.Binding} binding instance | |
- */ | |
Ember['default'].LOG_BINDINGS = false || !!Ember['default'].ENV.LOG_BINDINGS; | |
/** | |
@@ -9950,7 +9183,7 @@ | |
function Binding(toPath, fromPath) { | |
this._direction = undefined; | |
this._from = fromPath; | |
- this._to = toPath; | |
+ this._to = toPath; | |
this._readyToSync = undefined; | |
this._oneWay = undefined; | |
} | |
@@ -9963,14 +9196,13 @@ | |
Binding.prototype = { | |
/** | |
This copies the Binding so it can be connected to another object. | |
- @method copy | |
+ | |
+ @method copy | |
@return {Ember.Binding} `this` | |
*/ | |
copy: function () { | |
var copy = new Binding(this._to, this._from); | |
- if (this._oneWay) { | |
- copy._oneWay = true; | |
- } | |
+ if (this._oneWay) { copy._oneWay = true; } | |
return copy; | |
}, | |
@@ -9982,14 +9214,16 @@ | |
This will set `from` property path to the specified value. It will not | |
attempt to resolve this property path to an actual object until you | |
connect the binding. | |
- The binding will search for the property path starting at the root object | |
+ | |
+ The binding will search for the property path starting at the root object | |
you pass when you `connect()` the binding. It follows the same rules as | |
`get()` - see that method for more information. | |
- @method from | |
+ | |
+ @method from | |
@param {String} path the property path to connect to | |
@return {Ember.Binding} `this` | |
*/ | |
- from: function (path) { | |
+ from: function(path) { | |
this._from = path; | |
return this; | |
}, | |
@@ -9998,14 +9232,16 @@ | |
This will set the `to` property path to the specified value. It will not | |
attempt to resolve this property path to an actual object until you | |
connect the binding. | |
- The binding will search for the property path starting at the root object | |
+ | |
+ The binding will search for the property path starting at the root object | |
you pass when you `connect()` the binding. It follows the same rules as | |
`get()` - see that method for more information. | |
- @method to | |
+ | |
+ @method to | |
@param {String|Tuple} path A property path or tuple | |
@return {Ember.Binding} `this` | |
*/ | |
- to: function (path) { | |
+ to: function(path) { | |
this._to = path; | |
return this; | |
}, | |
@@ -10015,10 +9251,11 @@ | |
on the `from` side to the `to` side, but not the other way around. This | |
means that if you change the `to` side directly, the `from` side may have | |
a different value. | |
- @method oneWay | |
+ | |
+ @method oneWay | |
@return {Ember.Binding} `this` | |
*/ | |
- oneWay: function () { | |
+ oneWay: function() { | |
this._oneWay = true; | |
return this; | |
}, | |
@@ -10027,8 +9264,8 @@ | |
@method toString | |
@return {String} string representation of binding | |
*/ | |
- toString: function () { | |
- var oneWay = this._oneWay ? "[oneWay]" : ""; | |
+ toString: function() { | |
+ var oneWay = this._oneWay ? '[oneWay]' : ''; | |
return "Ember.Binding<" + utils.guidFor(this) + ">(" + this._from + " -> " + this._to + ")" + oneWay; | |
}, | |
@@ -10040,12 +9277,13 @@ | |
Attempts to connect this binding instance so that it can receive and relay | |
changes. This method will raise an exception if you have not set the | |
from/to properties yet. | |
- @method connect | |
+ | |
+ @method connect | |
@param {Object} obj The root object for this binding. | |
@return {Ember.Binding} `this` | |
*/ | |
- connect: function (obj) { | |
- Ember['default'].assert("Must pass a valid object to Ember.Binding.connect()", !!obj); | |
+ connect: function(obj) { | |
+ Ember['default'].assert('Must pass a valid object to Ember.Binding.connect()', !!obj); | |
var fromPath = this._from; | |
var toPath = this._to; | |
@@ -10067,12 +9305,13 @@ | |
/** | |
Disconnects the binding instance. Changes will no longer be relayed. You | |
will not usually need to call this method. | |
- @method disconnect | |
+ | |
+ @method disconnect | |
@param {Object} obj The root object you passed when connecting the binding. | |
@return {Ember.Binding} `this` | |
*/ | |
- disconnect: function (obj) { | |
- Ember['default'].assert("Must pass a valid object to Ember.Binding.disconnect()", !!obj); | |
+ disconnect: function(obj) { | |
+ Ember['default'].assert('Must pass a valid object to Ember.Binding.disconnect()', !!obj); | |
var twoWay = !this._oneWay; | |
@@ -10094,38 +9333,36 @@ | |
// | |
/* called when the from side changes */ | |
- fromDidChange: function (target) { | |
- this._scheduleSync(target, "fwd"); | |
+ fromDidChange: function(target) { | |
+ this._scheduleSync(target, 'fwd'); | |
}, | |
/* called when the to side changes */ | |
- toDidChange: function (target) { | |
- this._scheduleSync(target, "back"); | |
+ toDidChange: function(target) { | |
+ this._scheduleSync(target, 'back'); | |
}, | |
- _scheduleSync: function (obj, dir) { | |
+ _scheduleSync: function(obj, dir) { | |
var existingDir = this._direction; | |
// if we haven't scheduled the binding yet, schedule it | |
if (existingDir === undefined) { | |
- run['default'].schedule("sync", this, this._sync, obj); | |
- this._direction = dir; | |
+ run['default'].schedule('sync', this, this._sync, obj); | |
+ this._direction = dir; | |
} | |
// If both a 'back' and 'fwd' sync have been scheduled on the same object, | |
// default to a 'fwd' sync so that it remains deterministic. | |
- if (existingDir === "back" && dir === "fwd") { | |
- this._direction = "fwd"; | |
+ if (existingDir === 'back' && dir === 'fwd') { | |
+ this._direction = 'fwd'; | |
} | |
}, | |
- _sync: function (obj) { | |
+ _sync: function(obj) { | |
var log = Ember['default'].LOG_BINDINGS; | |
// don't synchronize destroyed objects or disconnected bindings | |
- if (obj.isDestroyed || !this._readyToSync) { | |
- return; | |
- } | |
+ if (obj.isDestroyed || !this._readyToSync) { return; } | |
// get the direction of the binding for the object we are | |
// synchronizing from | |
@@ -10137,10 +9374,10 @@ | |
this._direction = undefined; | |
// if we're synchronizing from the remote object... | |
- if (direction === "fwd") { | |
+ if (direction === 'fwd') { | |
var fromValue = getWithGlobals(obj, this._from); | |
if (log) { | |
- Ember['default'].Logger.log(" ", this.toString(), "->", fromValue, obj); | |
+ Ember['default'].Logger.log(' ', this.toString(), '->', fromValue, obj); | |
} | |
if (this._oneWay) { | |
property_set.trySet(obj, toPath, fromValue); | |
@@ -10149,11 +9386,11 @@ | |
property_set.trySet(obj, toPath, fromValue); | |
}); | |
} | |
- // if we're synchronizing *to* the remote object | |
- } else if (direction === "back") { | |
+ // if we're synchronizing *to* the remote object | |
+ } else if (direction === 'back') { | |
var toValue = property_get.get(obj, this._to); | |
if (log) { | |
- Ember['default'].Logger.log(" ", this.toString(), "<-", toValue, obj); | |
+ Ember['default'].Logger.log(' ', this.toString(), '<-', toValue, obj); | |
} | |
observer._suspendObserver(obj, fromPath, this, this.fromDidChange, function () { | |
property_set.trySet(path_cache.isGlobal(fromPath) ? Ember['default'].lookup : obj, fromPath, toValue); | |
@@ -10175,20 +9412,22 @@ | |
/* | |
See `Ember.Binding.from`. | |
- @method from | |
+ | |
+ @method from | |
@static | |
*/ | |
- from: function (from) { | |
+ from: function(from) { | |
var C = this; | |
return new C(undefined, from); | |
}, | |
/* | |
See `Ember.Binding.to`. | |
- @method to | |
+ | |
+ @method to | |
@static | |
*/ | |
- to: function (to) { | |
+ to: function(to) { | |
var C = this; | |
return new C(to, undefined); | |
}, | |
@@ -10199,24 +9438,181 @@ | |
as the `from` argument) the `to` side, but not the other way around. | |
This means that if you change the "to" side directly, the "from" side may have | |
a different value. | |
- See `Binding.oneWay`. | |
- @method oneWay | |
+ | |
+ See `Binding.oneWay`. | |
+ | |
+ @method oneWay | |
@param {String} from from path. | |
@param {Boolean} [flag] (Optional) passing nothing here will make the | |
binding `oneWay`. You can instead pass `false` to disable `oneWay`, making the | |
binding two way again. | |
@return {Ember.Binding} `this` | |
*/ | |
- oneWay: function (from, flag) { | |
+ oneWay: function(from, flag) { | |
var C = this; | |
return new C(undefined, from).oneWay(flag); | |
} | |
}); | |
+ /** | |
+ An `Ember.Binding` connects the properties of two objects so that whenever | |
+ the value of one property changes, the other property will be changed also. | |
+ | |
+ ## Automatic Creation of Bindings with `/^*Binding/`-named Properties | |
+ | |
+ You do not usually create Binding objects directly but instead describe | |
+ bindings in your class or object definition using automatic binding | |
+ detection. | |
+ | |
+ Properties ending in a `Binding` suffix will be converted to `Ember.Binding` | |
+ instances. The value of this property should be a string representing a path | |
+ to another object or a custom binding instance created using Binding helpers | |
+ (see "One Way Bindings"): | |
+ | |
+ ``` | |
+ valueBinding: "MyApp.someController.title" | |
+ ``` | |
+ | |
+ This will create a binding from `MyApp.someController.title` to the `value` | |
+ property of your object instance automatically. Now the two values will be | |
+ kept in sync. | |
+ | |
+ ## One Way Bindings | |
+ | |
+ One especially useful binding customization you can use is the `oneWay()` | |
+ helper. This helper tells Ember that you are only interested in | |
+ receiving changes on the object you are binding from. For example, if you | |
+ are binding to a preference and you want to be notified if the preference | |
+ has changed, but your object will not be changing the preference itself, you | |
+ could do: | |
+ | |
+ ``` | |
+ bigTitlesBinding: Ember.Binding.oneWay("MyApp.preferencesController.bigTitles") | |
+ ``` | |
+ | |
+ This way if the value of `MyApp.preferencesController.bigTitles` changes the | |
+ `bigTitles` property of your object will change also. However, if you | |
+ change the value of your `bigTitles` property, it will not update the | |
+ `preferencesController`. | |
+ | |
+ One way bindings are almost twice as fast to setup and twice as fast to | |
+ execute because the binding only has to worry about changes to one side. | |
+ | |
+ You should consider using one way bindings anytime you have an object that | |
+ may be created frequently and you do not intend to change a property; only | |
+ to monitor it for changes (such as in the example above). | |
+ | |
+ ## Adding Bindings Manually | |
+ | |
+ All of the examples above show you how to configure a custom binding, but the | |
+ result of these customizations will be a binding template, not a fully active | |
+ Binding instance. The binding will actually become active only when you | |
+ instantiate the object the binding belongs to. It is useful however, to | |
+ understand what actually happens when the binding is activated. | |
+ | |
+ For a binding to function it must have at least a `from` property and a `to` | |
+ property. The `from` property path points to the object/key that you want to | |
+ bind from while the `to` path points to the object/key you want to bind to. | |
+ | |
+ When you define a custom binding, you are usually describing the property | |
+ you want to bind from (such as `MyApp.someController.value` in the examples | |
+ above). When your object is created, it will automatically assign the value | |
+ you want to bind `to` based on the name of your binding key. In the | |
+ examples above, during init, Ember objects will effectively call | |
+ something like this on your binding: | |
+ | |
+ ```javascript | |
+ binding = Ember.Binding.from("valueBinding").to("value"); | |
+ ``` | |
+ | |
+ This creates a new binding instance based on the template you provide, and | |
+ sets the to path to the `value` property of the new object. Now that the | |
+ binding is fully configured with a `from` and a `to`, it simply needs to be | |
+ connected to become active. This is done through the `connect()` method: | |
+ | |
+ ```javascript | |
+ binding.connect(this); | |
+ ``` | |
+ | |
+ Note that when you connect a binding you pass the object you want it to be | |
+ connected to. This object will be used as the root for both the from and | |
+ to side of the binding when inspecting relative paths. This allows the | |
+ binding to be automatically inherited by subclassed objects as well. | |
+ | |
+ This also allows you to bind between objects using the paths you declare in | |
+ `from` and `to`: | |
+ | |
+ ```javascript | |
+ // Example 1 | |
+ binding = Ember.Binding.from("App.someObject.value").to("value"); | |
+ binding.connect(this); | |
+ | |
+ // Example 2 | |
+ binding = Ember.Binding.from("parentView.value").to("App.someObject.value"); | |
+ binding.connect(this); | |
+ ``` | |
+ | |
+ Now that the binding is connected, it will observe both the from and to side | |
+ and relay changes. | |
+ | |
+ If you ever needed to do so (you almost never will, but it is useful to | |
+ understand this anyway), you could manually create an active binding by | |
+ using the `Ember.bind()` helper method. (This is the same method used by | |
+ to setup your bindings on objects): | |
+ | |
+ ```javascript | |
+ Ember.bind(MyApp.anotherObject, "value", "MyApp.someController.value"); | |
+ ``` | |
+ | |
+ Both of these code fragments have the same effect as doing the most friendly | |
+ form of binding creation like so: | |
+ | |
+ ```javascript | |
+ MyApp.anotherObject = Ember.Object.create({ | |
+ valueBinding: "MyApp.someController.value", | |
+ | |
+ // OTHER CODE FOR THIS OBJECT... | |
+ }); | |
+ ``` | |
+ | |
+ Ember's built in binding creation method makes it easy to automatically | |
+ create bindings for you. You should always use the highest-level APIs | |
+ available, even if you understand how it works underneath. | |
+ | |
+ @class Binding | |
+ @namespace Ember | |
+ @since Ember 0.9 | |
+ */ | |
+ // Ember.Binding = Binding; ES6TODO: where to put this? | |
+ | |
+ | |
+ /** | |
+ Global helper method to create a new binding. Just pass the root object | |
+ along with a `to` and `from` path to create and connect the binding. | |
+ | |
+ @method bind | |
+ @for Ember | |
+ @param {Object} obj The root object of the transform. | |
+ @param {String} to The path to the 'to' side of the binding. | |
+ Must be relative to obj. | |
+ @param {String} from The path to the 'from' side of the binding. | |
+ Must be relative to obj or a global path. | |
+ @return {Ember.Binding} binding instance | |
+ */ | |
function bind(obj, to, from) { | |
return new Binding(to, from).connect(obj); | |
} | |
+ /** | |
+ @method oneWay | |
+ @for Ember | |
+ @param {Object} obj The root object of the transform. | |
+ @param {String} to The path to the 'to' side of the binding. | |
+ Must be relative to obj. | |
+ @param {String} from The path to the 'from' side of the binding. | |
+ Must be relative to obj or a global path. | |
+ @return {Ember.Binding} binding instance | |
+ */ | |
function oneWay(obj, to, from) { | |
return new Binding(to, from).oneWay().connect(obj); | |
} | |
@@ -10231,20 +9627,20 @@ | |
exports['default'] = Cache; | |
function Cache(limit, func) { | |
- this.store = dictionary['default'](null); | |
- this.size = 0; | |
+ this.store = dictionary['default'](null); | |
+ this.size = 0; | |
this.misses = 0; | |
- this.hits = 0; | |
- this.limit = limit; | |
- this.func = func; | |
+ this.hits = 0; | |
+ this.limit = limit; | |
+ this.func = func; | |
} | |
- var UNDEFINED = function () {}; | |
+ var UNDEFINED = function() { }; | |
Cache.prototype = { | |
- set: function (key, value) { | |
+ set: function(key, value) { | |
if (this.limit > this.size) { | |
- this.size++; | |
+ this.size ++; | |
if (value === undefined) { | |
this.store[key] = UNDEFINED; | |
} else { | |
@@ -10255,27 +9651,27 @@ | |
return value; | |
}, | |
- get: function (key) { | |
+ get: function(key) { | |
var value = this.store[key]; | |
if (value === undefined) { | |
- this.misses++; | |
+ this.misses ++; | |
value = this.set(key, this.func(key)); | |
} else if (value === UNDEFINED) { | |
- this.hits++; | |
+ this.hits ++; | |
value = undefined; | |
} else { | |
- this.hits++; | |
+ this.hits ++; | |
// nothing to translate | |
} | |
return value; | |
}, | |
- purge: function () { | |
- this.store = dictionary['default'](null); | |
- this.size = 0; | |
- this.hits = 0; | |
+ purge: function() { | |
+ this.store = dictionary['default'](null); | |
+ this.size = 0; | |
+ this.hits = 0; | |
this.misses = 0; | |
} | |
}; | |
@@ -10290,9 +9686,6 @@ | |
exports.removeChainWatcher = removeChainWatcher; | |
exports.ChainNode = ChainNode; | |
- // attempts to add the pendingQueue chains again. If some of them end up | |
- // back in the queue and reschedule is true, schedules a timeout to try | |
- // again. | |
var warn = Ember['default'].warn; | |
var FIRST_KEY = /^([^\.]+)/; | |
@@ -10301,31 +9694,31 @@ | |
} | |
var pendingQueue = []; | |
+ | |
+ // attempts to add the pendingQueue chains again. If some of them end up | |
+ // back in the queue and reschedule is true, schedules a timeout to try | |
+ // again. | |
function flushPendingChains() { | |
- if (pendingQueue.length === 0) { | |
- return; | |
- } // nothing to do | |
+ if (pendingQueue.length === 0) { return; } // nothing to do | |
var queue = pendingQueue; | |
pendingQueue = []; | |
- array.forEach.call(queue, function (q) { | |
+ array.forEach.call(queue, function(q) { | |
q[0].add(q[1]); | |
}); | |
- warn("Watching an undefined global, Ember expects watched globals to be" + " setup by the time the run loop is flushed, check for typos", pendingQueue.length === 0); | |
+ warn('Watching an undefined global, Ember expects watched globals to be' + | |
+ ' setup by the time the run loop is flushed, check for typos', pendingQueue.length === 0); | |
} | |
function addChainWatcher(obj, keyName, node) { | |
- if (!obj || "object" !== typeof obj) { | |
- return; | |
- } // nothing to do | |
+ if (!obj || ('object' !== typeof obj)) { return; } // nothing to do | |
var m = utils.meta(obj); | |
var nodes = m.chainWatchers; | |
- if (!m.hasOwnProperty("chainWatchers")) { | |
- // FIXME?! | |
+ if (!m.hasOwnProperty('chainWatchers')) { // FIXME?! | |
nodes = m.chainWatchers = {}; | |
} | |
@@ -10337,14 +9730,10 @@ | |
} | |
function removeChainWatcher(obj, keyName, node) { | |
- if (!obj || "object" !== typeof obj) { | |
- return; | |
- } // nothing to do | |
+ if (!obj || 'object' !== typeof obj) { return; } // nothing to do | |
- var m = obj["__ember_meta__"]; | |
- if (m && !m.hasOwnProperty("chainWatchers")) { | |
- return; | |
- } // nothing to do | |
+ var m = obj['__ember_meta__']; | |
+ if (m && !m.hasOwnProperty('chainWatchers')) { return; } // nothing to do | |
var nodes = m && m.chainWatchers; | |
@@ -10365,7 +9754,7 @@ | |
// pass null for parent and key and object for value. | |
function ChainNode(parent, key, value) { | |
this._parent = parent; | |
- this._key = key; | |
+ this._key = key; | |
// _watching is true when calling get(this._parent, this._key) will | |
// return the value of this node. | |
@@ -10373,9 +9762,9 @@ | |
// It is false for the root of a chain (because we have no parent) | |
// and for global paths (because the parent node is the object with | |
// the observer on it) | |
- this._watching = value === undefined; | |
+ this._watching = value===undefined; | |
- this._value = value; | |
+ this._value = value; | |
this._paths = {}; | |
if (this._watching) { | |
this._object = parent.value(); | |
@@ -10389,7 +9778,7 @@ | |
// | |
// TODO: Replace this with an efficient callback that the EachProxy | |
// can implement. | |
- if (this._parent && this._parent._key === "@each") { | |
+ if (this._parent && this._parent._key === '@each') { | |
this.value(); | |
} | |
} | |
@@ -10401,7 +9790,7 @@ | |
return undefined; | |
} | |
- var meta = obj["__ember_meta__"]; | |
+ var meta = obj['__ember_meta__']; | |
// check if object meant only to be a prototype | |
if (meta && meta.proto === obj) { | |
return undefined; | |
@@ -10413,7 +9802,7 @@ | |
// if a CP only return cached value | |
var possibleDesc = obj[key]; | |
- var desc = possibleDesc !== null && typeof possibleDesc === "object" && possibleDesc.isDescriptor ? possibleDesc : undefined; | |
+ var desc = (possibleDesc !== null && typeof possibleDesc === 'object' && possibleDesc.isDescriptor) ? possibleDesc : undefined; | |
if (desc && desc._cacheable) { | |
if (meta.cache && key in meta.cache) { | |
return meta.cache[key]; | |
@@ -10425,7 +9814,7 @@ | |
return property_get.get(obj, key); | |
} | |
- ChainNodePrototype.value = function () { | |
+ ChainNodePrototype.value = function() { | |
if (this._value === undefined && this._watching) { | |
var obj = this._parent.value(); | |
this._value = lazyGet(obj, this._key); | |
@@ -10433,7 +9822,7 @@ | |
return this._value; | |
}; | |
- ChainNodePrototype.destroy = function () { | |
+ ChainNodePrototype.destroy = function() { | |
if (this._watching) { | |
var obj = this._object; | |
if (obj) { | |
@@ -10444,7 +9833,7 @@ | |
}; | |
// copies a top level object only | |
- ChainNodePrototype.copy = function (obj) { | |
+ ChainNodePrototype.copy = function(obj) { | |
var ret = new ChainNode(null, null, obj); | |
var paths = this._paths; | |
var path; | |
@@ -10461,7 +9850,7 @@ | |
// called on the root node of a chain to setup watchers on the specified | |
// path. | |
- ChainNodePrototype.add = function (path) { | |
+ ChainNodePrototype.add = function(path) { | |
var obj, tuple, key, src, paths; | |
paths = this._paths; | |
@@ -10473,20 +9862,20 @@ | |
// the path was a local path | |
if (tuple[0] && tuple[0] === obj) { | |
path = tuple[1]; | |
- key = firstKey(path); | |
- path = path.slice(key.length + 1); | |
+ key = firstKey(path); | |
+ path = path.slice(key.length+1); | |
- // global path, but object does not exist yet. | |
- // put into a queue and try to connect later. | |
+ // global path, but object does not exist yet. | |
+ // put into a queue and try to connect later. | |
} else if (!tuple[0]) { | |
pendingQueue.push([this, path]); | |
tuple.length = 0; | |
return; | |
- // global path, and object already exists | |
+ // global path, and object already exists | |
} else { | |
- src = tuple[0]; | |
- key = path.slice(0, 0 - (tuple[1].length + 1)); | |
+ src = tuple[0]; | |
+ key = path.slice(0, 0-(tuple[1].length+1)); | |
path = tuple[1]; | |
} | |
@@ -10496,7 +9885,7 @@ | |
// called on the root node of a chain to teardown watcher on the specified | |
// path | |
- ChainNodePrototype.remove = function (path) { | |
+ ChainNodePrototype.remove = function(path) { | |
var obj, tuple, key, src, paths; | |
paths = this._paths; | |
@@ -10508,11 +9897,11 @@ | |
tuple = property_get.normalizeTuple(obj, path); | |
if (tuple[0] === obj) { | |
path = tuple[1]; | |
- key = firstKey(path); | |
- path = path.slice(key.length + 1); | |
+ key = firstKey(path); | |
+ path = path.slice(key.length+1); | |
} else { | |
- src = tuple[0]; | |
- key = path.slice(0, 0 - (tuple[1].length + 1)); | |
+ src = tuple[0]; | |
+ key = path.slice(0, 0-(tuple[1].length+1)); | |
path = tuple[1]; | |
} | |
@@ -10522,7 +9911,7 @@ | |
ChainNodePrototype.count = 0; | |
- ChainNodePrototype.chain = function (key, path, src) { | |
+ ChainNodePrototype.chain = function(key, path, src) { | |
var chains = this._chains; | |
var node; | |
if (!chains) { | |
@@ -10538,31 +9927,32 @@ | |
// chain rest of path if there is one | |
if (path) { | |
key = firstKey(path); | |
- path = path.slice(key.length + 1); | |
+ path = path.slice(key.length+1); | |
node.chain(key, path); // NOTE: no src means it will observe changes... | |
} | |
}; | |
- ChainNodePrototype.unchain = function (key, path) { | |
+ ChainNodePrototype.unchain = function(key, path) { | |
var chains = this._chains; | |
var node = chains[key]; | |
// unchain rest of path first... | |
if (path && path.length > 1) { | |
- var nextKey = firstKey(path); | |
+ var nextKey = firstKey(path); | |
var nextPath = path.slice(nextKey.length + 1); | |
node.unchain(nextKey, nextPath); | |
} | |
// delete node if needed. | |
node.count--; | |
- if (node.count <= 0) { | |
+ if (node.count<=0) { | |
delete chains[node._key]; | |
node.destroy(); | |
} | |
+ | |
}; | |
- ChainNodePrototype.willChange = function (events) { | |
+ ChainNodePrototype.willChange = function(events) { | |
var chains = this._chains; | |
if (chains) { | |
for (var key in chains) { | |
@@ -10578,43 +9968,43 @@ | |
} | |
}; | |
- ChainNodePrototype.chainWillChange = function (chain, path, depth, events) { | |
+ ChainNodePrototype.chainWillChange = function(chain, path, depth, events) { | |
if (this._key) { | |
- path = this._key + "." + path; | |
+ path = this._key + '.' + path; | |
} | |
if (this._parent) { | |
- this._parent.chainWillChange(this, path, depth + 1, events); | |
+ this._parent.chainWillChange(this, path, depth+1, events); | |
} else { | |
if (depth > 1) { | |
events.push(this.value(), path); | |
} | |
- path = "this." + path; | |
+ path = 'this.' + path; | |
if (this._paths[path] > 0) { | |
events.push(this.value(), path); | |
} | |
} | |
}; | |
- ChainNodePrototype.chainDidChange = function (chain, path, depth, events) { | |
+ ChainNodePrototype.chainDidChange = function(chain, path, depth, events) { | |
if (this._key) { | |
- path = this._key + "." + path; | |
+ path = this._key + '.' + path; | |
} | |
if (this._parent) { | |
- this._parent.chainDidChange(this, path, depth + 1, events); | |
+ this._parent.chainDidChange(this, path, depth+1, events); | |
} else { | |
if (depth > 1) { | |
events.push(this.value(), path); | |
} | |
- path = "this." + path; | |
+ path = 'this.' + path; | |
if (this._paths[path] > 0) { | |
events.push(this.value(), path); | |
} | |
} | |
}; | |
- ChainNodePrototype.didChange = function (events) { | |
+ ChainNodePrototype.didChange = function(events) { | |
// invalidate my own value first. | |
if (this._watching) { | |
var obj = this._parent.value(); | |
@@ -10623,11 +10013,11 @@ | |
this._object = obj; | |
addChainWatcher(obj, this._key, this); | |
} | |
- this._value = undefined; | |
+ this._value = undefined; | |
// Special-case: the EachProxy relies on immediate evaluation to | |
// establish its observers. | |
- if (this._parent && this._parent._key === "@each") { | |
+ if (this._parent && this._parent._key === '@each') { | |
this.value(); | |
} | |
} | |
@@ -10636,9 +10026,7 @@ | |
var chains = this._chains; | |
if (chains) { | |
for (var key in chains) { | |
- if (!chains.hasOwnProperty(key)) { | |
- continue; | |
- } | |
+ if (!chains.hasOwnProperty(key)) { continue; } | |
chains[key].didChange(events); | |
} | |
} | |
@@ -10653,9 +10041,10 @@ | |
this._parent.chainDidChange(this, this._key, 1, events); | |
} | |
}; | |
+ | |
function finishChains(obj) { | |
// We only create meta if we really have to | |
- var m = obj["__ember_meta__"]; | |
+ var m = obj['__ember_meta__']; | |
var chains, chainWatchers, chainNodes; | |
if (m) { | |
@@ -10669,7 +10058,7 @@ | |
chainNodes = chainWatchers[key]; | |
if (chainNodes) { | |
- for (var i = 0, l = chainNodes.length; i < l; i++) { | |
+ for (var i=0,l=chainNodes.length;i<l;i++) { | |
chainNodes[i].didChange(null); | |
} | |
} | |
@@ -10695,7 +10084,7 @@ | |
var metaFor = utils.meta; | |
var a_slice = [].slice; | |
- function UNDEFINED() {} | |
+ function UNDEFINED() { } | |
// .......................................................... | |
// COMPUTED PROPERTY | |
@@ -10796,10 +10185,10 @@ | |
this._suspended = undefined; | |
this._meta = undefined; | |
- Ember.deprecate("Passing opts.cacheable to the CP constructor is deprecated. Invoke `volatile()` on the CP instead.", !opts || !opts.hasOwnProperty("cacheable")); | |
- this._cacheable = opts && opts.cacheable !== undefined ? opts.cacheable : true; // TODO: Set always to `true` once this deprecation is gone. | |
+ Ember.deprecate("Passing opts.cacheable to the CP constructor is deprecated. Invoke `volatile()` on the CP instead.", !opts || !opts.hasOwnProperty('cacheable')); | |
+ this._cacheable = (opts && opts.cacheable !== undefined) ? opts.cacheable : true; // TODO: Set always to `true` once this deprecation is gone. | |
this._dependentKeys = opts && opts.dependentKeys; | |
- Ember.deprecate("Passing opts.readOnly to the CP constructor is deprecated. All CPs are writable by default. Yo can invoke `readOnly()` on the CP to change this.", !opts || !opts.hasOwnProperty("readOnly")); | |
+ Ember.deprecate("Passing opts.readOnly to the CP constructor is deprecated. All CPs are writable by default. Yo can invoke `readOnly()` on the CP to change this.", !opts || !opts.hasOwnProperty('readOnly')); | |
this._readOnly = opts && (opts.readOnly !== undefined || !!opts.readOnly) || false; // TODO: Set always to `false` once this deprecation is gone. | |
} | |
@@ -10823,8 +10212,8 @@ | |
@chainable | |
@deprecated All computed properties are cacheble by default. Use `volatile()` instead to opt-out to caching. | |
*/ | |
- ComputedPropertyPrototype.cacheable = function (aFlag) { | |
- Ember.deprecate("ComputedProperty.cacheable() is deprecated. All computed properties are cacheable by default."); | |
+ ComputedPropertyPrototype.cacheable = function(aFlag) { | |
+ Ember.deprecate('ComputedProperty.cacheable() is deprecated. All computed properties are cacheable by default.'); | |
this._cacheable = aFlag !== false; | |
return this; | |
}; | |
@@ -10845,7 +10234,7 @@ | |
@return {Ember.ComputedProperty} this | |
@chainable | |
*/ | |
- ComputedPropertyPrototype["volatile"] = function () { | |
+ ComputedPropertyPrototype["volatile"] = function() { | |
this._cacheable = false; | |
return this; | |
}; | |
@@ -10870,8 +10259,8 @@ | |
@return {Ember.ComputedProperty} this | |
@chainable | |
*/ | |
- ComputedPropertyPrototype.readOnly = function (readOnly) { | |
- Ember.deprecate("Passing arguments to ComputedProperty.readOnly() is deprecated.", arguments.length === 0); | |
+ ComputedPropertyPrototype.readOnly = function(readOnly) { | |
+ Ember.deprecate('Passing arguments to ComputedProperty.readOnly() is deprecated.', arguments.length === 0); | |
this._readOnly = readOnly === undefined || !!readOnly; // Force to true once this deprecation is gone | |
return this; | |
}; | |
@@ -10903,7 +10292,7 @@ | |
@return {Ember.ComputedProperty} this | |
@chainable | |
*/ | |
- ComputedPropertyPrototype.property = function () { | |
+ ComputedPropertyPrototype.property = function() { | |
var args; | |
var addArg = function (property) { | |
@@ -10944,7 +10333,7 @@ | |
@chainable | |
*/ | |
- ComputedPropertyPrototype.meta = function (meta) { | |
+ ComputedPropertyPrototype.meta = function(meta) { | |
if (arguments.length === 0) { | |
return this._meta || {}; | |
} else { | |
@@ -10954,7 +10343,7 @@ | |
}; | |
/* impl descriptor API */ | |
- ComputedPropertyPrototype.didChange = function (obj, keyName) { | |
+ ComputedPropertyPrototype.didChange = function(obj, keyName) { | |
// _suspended is set via a CP.set to ensure we don't clear | |
// the cached value set by the setter | |
if (this._cacheable && this._suspended !== obj) { | |
@@ -10967,7 +10356,7 @@ | |
}; | |
function finishChains(chainNodes) { | |
- for (var i = 0, l = chainNodes.length; i < l; i++) { | |
+ for (var i=0, l=chainNodes.length; i<l; i++) { | |
chainNodes[i].didChange(null); | |
} | |
} | |
@@ -10998,7 +10387,7 @@ | |
@param {String} keyName The key being accessed. | |
@return {Object} The return value of the function backing the CP. | |
*/ | |
- ComputedPropertyPrototype.get = function (obj, keyName) { | |
+ ComputedPropertyPrototype.get = function(obj, keyName) { | |
var ret, cache, meta, chainNodes; | |
if (this._cacheable) { | |
meta = metaFor(obj); | |
@@ -11095,16 +10484,16 @@ | |
}; | |
ComputedPropertyPrototype._set = function computedPropertySet(obj, keyName, value) { | |
- var cacheable = this._cacheable; | |
- var setter = this._setter; | |
- var meta = metaFor(obj, cacheable); | |
- var cache = meta.cache; | |
+ var cacheable = this._cacheable; | |
+ var setter = this._setter; | |
+ var meta = metaFor(obj, cacheable); | |
+ var cache = meta.cache; | |
var hadCachedValue = false; | |
var cachedValue, ret; | |
if (this._readOnly) { | |
- throw new EmberError['default']("Cannot set read-only property \"" + keyName + "\" on object: " + utils.inspect(obj)); | |
+ throw new EmberError['default']('Cannot set read-only property "' + keyName + '" on object: ' + utils.inspect(obj)); | |
} | |
if (cacheable && cache && cache[keyName] !== undefined) { | |
@@ -11127,9 +10516,7 @@ | |
ret = setter.call(obj, keyName, value, cachedValue); | |
} | |
- if (hadCachedValue && cachedValue === ret) { | |
- return; | |
- } | |
+ if (hadCachedValue && cachedValue === ret) { return; } | |
var watched = meta.watching[keyName]; | |
if (watched) { | |
@@ -11162,7 +10549,7 @@ | |
}; | |
/* called before property is overridden */ | |
- ComputedPropertyPrototype.teardown = function (obj, keyName) { | |
+ ComputedPropertyPrototype.teardown = function(obj, keyName) { | |
var meta = metaFor(obj); | |
if (meta.cache) { | |
@@ -11170,14 +10557,13 @@ | |
dependent_keys.removeDependentKeys(this, obj, keyName, meta); | |
} | |
- if (this._cacheable) { | |
- delete meta.cache[keyName]; | |
- } | |
+ if (this._cacheable) { delete meta.cache[keyName]; } | |
} | |
return null; // no value to restore | |
}; | |
+ | |
/** | |
This helper returns a new property descriptor that wraps the passed | |
computed property function. You can use this helper to define properties | |
@@ -11269,7 +10655,7 @@ | |
@return {Object} the cached value | |
*/ | |
function cacheFor(obj, key) { | |
- var meta = obj["__ember_meta__"]; | |
+ var meta = obj['__ember_meta__']; | |
var cache = meta && meta.cache; | |
var ret = cache && cache[key]; | |
@@ -11279,7 +10665,7 @@ | |
return ret; | |
} | |
- cacheFor.set = function (cache, key, value) { | |
+ cacheFor.set = function(cache, key, value) { | |
if (value === undefined) { | |
cache[key] = UNDEFINED; | |
} else { | |
@@ -11287,7 +10673,7 @@ | |
} | |
}; | |
- cacheFor.get = function (cache, key) { | |
+ cacheFor.get = function(cache, key) { | |
var ret = cache[key]; | |
if (ret === UNDEFINED) { | |
return undefined; | |
@@ -11295,7 +10681,7 @@ | |
return ret; | |
}; | |
- cacheFor.remove = function (cache, key) { | |
+ cacheFor.remove = function(cache, key) { | |
cache[key] = undefined; | |
}; | |
@@ -11320,6 +10706,28 @@ | |
exports.defaultTo = defaultTo; | |
exports.deprecatingAlias = deprecatingAlias; | |
+ var a_slice = [].slice; | |
+ | |
+ function getProperties(self, propertyNames) { | |
+ var ret = {}; | |
+ for (var i = 0; i < propertyNames.length; i++) { | |
+ ret[propertyNames[i]] = property_get.get(self, propertyNames[i]); | |
+ } | |
+ return ret; | |
+ } | |
+ | |
+ function generateComputedWithProperties(macro) { | |
+ return function() { | |
+ var properties = a_slice.call(arguments); | |
+ | |
+ var computedFunc = computed.computed(function() { | |
+ return macro.apply(this, [getProperties(this, properties)]); | |
+ }); | |
+ | |
+ return computedFunc.property.apply(computedFunc, properties); | |
+ }; | |
+ } | |
+ | |
/** | |
A computed property that returns true if the value of the dependent | |
property is null, an empty string, empty array, or empty function. | |
@@ -11347,89 +10755,332 @@ | |
@return {Ember.ComputedProperty} computed property which negate | |
the original value for property | |
*/ | |
- var a_slice = [].slice; | |
- | |
- function getProperties(self, propertyNames) { | |
- var ret = {}; | |
- for (var i = 0; i < propertyNames.length; i++) { | |
- ret[propertyNames[i]] = property_get.get(self, propertyNames[i]); | |
- } | |
- return ret; | |
+ function empty(dependentKey) { | |
+ return computed.computed(dependentKey + '.length', function () { | |
+ return isEmpty['default'](property_get.get(this, dependentKey)); | |
+ }); | |
} | |
- function generateComputedWithProperties(macro) { | |
- return function () { | |
- var properties = a_slice.call(arguments); | |
+ /** | |
+ A computed property that returns true if the value of the dependent | |
+ property is NOT null, an empty string, empty array, or empty function. | |
- var computedFunc = computed.computed(function () { | |
- return macro.apply(this, [getProperties(this, properties)]); | |
- }); | |
+ Example | |
- return computedFunc.property.apply(computedFunc, properties); | |
- }; | |
- } | |
- function empty(dependentKey) { | |
- return computed.computed(dependentKey + ".length", function () { | |
- return isEmpty['default'](property_get.get(this, dependentKey)); | |
+ ```javascript | |
+ var Hamster = Ember.Object.extend({ | |
+ hasStuff: Ember.computed.notEmpty('backpack') | |
}); | |
- } | |
+ var hamster = Hamster.create({ backpack: ['Food', 'Sleeping Bag', 'Tent'] }); | |
+ | |
+ hamster.get('hasStuff'); // true | |
+ hamster.get('backpack').clear(); // [] | |
+ hamster.get('hasStuff'); // false | |
+ ``` | |
+ | |
+ @method notEmpty | |
+ @for Ember.computed | |
+ @param {String} dependentKey | |
+ @return {Ember.ComputedProperty} computed property which returns true if | |
+ original value for property is not empty. | |
+ */ | |
function notEmpty(dependentKey) { | |
- return computed.computed(dependentKey + ".length", function () { | |
+ return computed.computed(dependentKey + '.length', function () { | |
return !isEmpty['default'](property_get.get(this, dependentKey)); | |
}); | |
} | |
+ /** | |
+ A computed property that returns true if the value of the dependent | |
+ property is null or undefined. This avoids errors from JSLint complaining | |
+ about use of ==, which can be technically confusing. | |
+ | |
+ Example | |
+ | |
+ ```javascript | |
+ var Hamster = Ember.Object.extend({ | |
+ isHungry: Ember.computed.none('food') | |
+ }); | |
+ | |
+ var hamster = Hamster.create(); | |
+ | |
+ hamster.get('isHungry'); // true | |
+ hamster.set('food', 'Banana'); | |
+ hamster.get('isHungry'); // false | |
+ hamster.set('food', null); | |
+ hamster.get('isHungry'); // true | |
+ ``` | |
+ | |
+ @method none | |
+ @for Ember.computed | |
+ @param {String} dependentKey | |
+ @return {Ember.ComputedProperty} computed property which | |
+ returns true if original value for property is null or undefined. | |
+ */ | |
function none(dependentKey) { | |
return computed.computed(dependentKey, function () { | |
return isNone['default'](property_get.get(this, dependentKey)); | |
}); | |
} | |
+ /** | |
+ A computed property that returns the inverse boolean value | |
+ of the original value for the dependent property. | |
+ | |
+ Example | |
+ | |
+ ```javascript | |
+ var User = Ember.Object.extend({ | |
+ isAnonymous: Ember.computed.not('loggedIn') | |
+ }); | |
+ | |
+ var user = User.create({loggedIn: false}); | |
+ | |
+ user.get('isAnonymous'); // true | |
+ user.set('loggedIn', true); | |
+ user.get('isAnonymous'); // false | |
+ ``` | |
+ | |
+ @method not | |
+ @for Ember.computed | |
+ @param {String} dependentKey | |
+ @return {Ember.ComputedProperty} computed property which returns | |
+ inverse of the original value for property | |
+ */ | |
function not(dependentKey) { | |
return computed.computed(dependentKey, function () { | |
return !property_get.get(this, dependentKey); | |
}); | |
} | |
+ /** | |
+ A computed property that converts the provided dependent property | |
+ into a boolean value. | |
+ | |
+ ```javascript | |
+ var Hamster = Ember.Object.extend({ | |
+ hasBananas: Ember.computed.bool('numBananas') | |
+ }); | |
+ | |
+ var hamster = Hamster.create(); | |
+ | |
+ hamster.get('hasBananas'); // false | |
+ hamster.set('numBananas', 0); | |
+ hamster.get('hasBananas'); // false | |
+ hamster.set('numBananas', 1); | |
+ hamster.get('hasBananas'); // true | |
+ hamster.set('numBananas', null); | |
+ hamster.get('hasBananas'); // false | |
+ ``` | |
+ | |
+ @method bool | |
+ @for Ember.computed | |
+ @param {String} dependentKey | |
+ @return {Ember.ComputedProperty} computed property which converts | |
+ to boolean the original value for property | |
+ */ | |
function bool(dependentKey) { | |
return computed.computed(dependentKey, function () { | |
return !!property_get.get(this, dependentKey); | |
}); | |
} | |
+ /** | |
+ A computed property which matches the original value for the | |
+ dependent property against a given RegExp, returning `true` | |
+ if they values matches the RegExp and `false` if it does not. | |
+ | |
+ Example | |
+ | |
+ ```javascript | |
+ var User = Ember.Object.extend({ | |
+ hasValidEmail: Ember.computed.match('email', /^.+@.+\..+$/) | |
+ }); | |
+ | |
+ var user = User.create({loggedIn: false}); | |
+ | |
+ user.get('hasValidEmail'); // false | |
+ user.set('email', ''); | |
+ user.get('hasValidEmail'); // false | |
+ user.set('email', '[email protected]'); | |
+ user.get('hasValidEmail'); // true | |
+ ``` | |
+ | |
+ @method match | |
+ @for Ember.computed | |
+ @param {String} dependentKey | |
+ @param {RegExp} regexp | |
+ @return {Ember.ComputedProperty} computed property which match | |
+ the original value for property against a given RegExp | |
+ */ | |
function match(dependentKey, regexp) { | |
return computed.computed(dependentKey, function () { | |
var value = property_get.get(this, dependentKey); | |
- return typeof value === "string" ? regexp.test(value) : false; | |
+ return typeof value === 'string' ? regexp.test(value) : false; | |
}); | |
} | |
+ /** | |
+ A computed property that returns true if the provided dependent property | |
+ is equal to the given value. | |
+ | |
+ Example | |
+ | |
+ ```javascript | |
+ var Hamster = Ember.Object.extend({ | |
+ napTime: Ember.computed.equal('state', 'sleepy') | |
+ }); | |
+ | |
+ var hamster = Hamster.create(); | |
+ | |
+ hamster.get('napTime'); // false | |
+ hamster.set('state', 'sleepy'); | |
+ hamster.get('napTime'); // true | |
+ hamster.set('state', 'hungry'); | |
+ hamster.get('napTime'); // false | |
+ ``` | |
+ | |
+ @method equal | |
+ @for Ember.computed | |
+ @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. | |
+ */ | |
function equal(dependentKey, value) { | |
return computed.computed(dependentKey, function () { | |
return property_get.get(this, dependentKey) === value; | |
}); | |
} | |
+ /** | |
+ A computed property that returns true if the provided dependent property | |
+ is greater than the provided value. | |
+ | |
+ Example | |
+ | |
+ ```javascript | |
+ var Hamster = Ember.Object.extend({ | |
+ hasTooManyBananas: Ember.computed.gt('numBananas', 10) | |
+ }); | |
+ | |
+ var hamster = Hamster.create(); | |
+ | |
+ hamster.get('hasTooManyBananas'); // false | |
+ hamster.set('numBananas', 3); | |
+ hamster.get('hasTooManyBananas'); // false | |
+ hamster.set('numBananas', 11); | |
+ hamster.get('hasTooManyBananas'); // true | |
+ ``` | |
+ | |
+ @method gt | |
+ @for Ember.computed | |
+ @param {String} dependentKey | |
+ @param {Number} value | |
+ @return {Ember.ComputedProperty} computed property which returns true if | |
+ the original value for property is greater than given value. | |
+ */ | |
function gt(dependentKey, value) { | |
return computed.computed(dependentKey, function () { | |
return property_get.get(this, dependentKey) > value; | |
}); | |
} | |
+ /** | |
+ A computed property that returns true if the provided dependent property | |
+ is greater than or equal to the provided value. | |
+ | |
+ Example | |
+ | |
+ ```javascript | |
+ var Hamster = Ember.Object.extend({ | |
+ hasTooManyBananas: Ember.computed.gte('numBananas', 10) | |
+ }); | |
+ | |
+ var hamster = Hamster.create(); | |
+ | |
+ hamster.get('hasTooManyBananas'); // false | |
+ hamster.set('numBananas', 3); | |
+ hamster.get('hasTooManyBananas'); // false | |
+ hamster.set('numBananas', 10); | |
+ hamster.get('hasTooManyBananas'); // true | |
+ ``` | |
+ | |
+ @method gte | |
+ @for Ember.computed | |
+ @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. | |
+ */ | |
function gte(dependentKey, value) { | |
return computed.computed(dependentKey, function () { | |
return property_get.get(this, dependentKey) >= value; | |
}); | |
} | |
+ /** | |
+ A computed property that returns true if the provided dependent property | |
+ is less than the provided value. | |
+ | |
+ Example | |
+ | |
+ ```javascript | |
+ var Hamster = Ember.Object.extend({ | |
+ needsMoreBananas: Ember.computed.lt('numBananas', 3) | |
+ }); | |
+ | |
+ var hamster = Hamster.create(); | |
+ | |
+ hamster.get('needsMoreBananas'); // true | |
+ hamster.set('numBananas', 3); | |
+ hamster.get('needsMoreBananas'); // false | |
+ hamster.set('numBananas', 2); | |
+ hamster.get('needsMoreBananas'); // true | |
+ ``` | |
+ | |
+ @method lt | |
+ @for Ember.computed | |
+ @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. | |
+ */ | |
function lt(dependentKey, value) { | |
return computed.computed(dependentKey, function () { | |
return property_get.get(this, dependentKey) < value; | |
}); | |
} | |
+ /** | |
+ A computed property that returns true if the provided dependent property | |
+ is less than or equal to the provided value. | |
+ | |
+ Example | |
+ | |
+ ```javascript | |
+ var Hamster = Ember.Object.extend({ | |
+ needsMoreBananas: Ember.computed.lte('numBananas', 3) | |
+ }); | |
+ | |
+ var hamster = Hamster.create(); | |
+ | |
+ hamster.get('needsMoreBananas'); // true | |
+ hamster.set('numBananas', 5); | |
+ hamster.get('needsMoreBananas'); // false | |
+ hamster.set('numBananas', 3); | |
+ hamster.get('needsMoreBananas'); // true | |
+ ``` | |
+ | |
+ @method lte | |
+ @for Ember.computed | |
+ @param {String} dependentKey | |
+ @param {Number} value | |
+ @return {Ember.ComputedProperty} computed property which returns true if | |
+ the original value for property is less or equal than given value. | |
+ */ | |
function lte(dependentKey, value) { | |
return computed.computed(dependentKey, function () { | |
return property_get.get(this, dependentKey) <= value; | |
@@ -11464,7 +11115,7 @@ | |
@return {Ember.ComputedProperty} computed property which performs | |
a logical `and` on the values of all the original values for properties. | |
*/ | |
- var and = generateComputedWithProperties(function (properties) { | |
+ var and = generateComputedWithProperties(function(properties) { | |
var value; | |
for (var key in properties) { | |
value = properties[key]; | |
@@ -11475,7 +11126,33 @@ | |
return value; | |
}); | |
- var or = generateComputedWithProperties(function (properties) { | |
+ /** | |
+ A computed property which performs a logical `or` on the | |
+ original values for the provided dependent properties. | |
+ | |
+ Example | |
+ | |
+ ```javascript | |
+ var Hamster = Ember.Object.extend({ | |
+ readyForRain: Ember.computed.or('hasJacket', 'hasUmbrella') | |
+ }); | |
+ | |
+ var hamster = Hamster.create(); | |
+ | |
+ hamster.get('readyForRain'); // false | |
+ hamster.set('hasUmbrella', true); | |
+ hamster.get('readyForRain'); // true | |
+ hamster.set('hasJacket', 'Yes'); | |
+ hamster.get('readyForRain'); // 'Yes' | |
+ ``` | |
+ | |
+ @method or | |
+ @for Ember.computed | |
+ @param {String} dependentKey* | |
+ @return {Ember.ComputedProperty} computed property which performs | |
+ a logical `or` on the values of all the original values for properties. | |
+ */ | |
+ var or = generateComputedWithProperties(function(properties) { | |
for (var key in properties) { | |
if (properties.hasOwnProperty(key) && properties[key]) { | |
return properties[key]; | |
@@ -11484,7 +11161,32 @@ | |
return false; | |
}); | |
- var any = generateComputedWithProperties(function (properties) { | |
+ /** | |
+ A computed property that returns the first truthy value | |
+ from a list of dependent properties. | |
+ | |
+ Example | |
+ | |
+ ```javascript | |
+ var Hamster = Ember.Object.extend({ | |
+ hasClothes: Ember.computed.any('hat', 'shirt') | |
+ }); | |
+ | |
+ var hamster = Hamster.create(); | |
+ | |
+ hamster.get('hasClothes'); // null | |
+ hamster.set('shirt', 'Hawaiian Shirt'); | |
+ hamster.get('hasClothes'); // 'Hawaiian Shirt' | |
+ ``` | |
+ | |
+ @method any | |
+ @for Ember.computed | |
+ @param {String} dependentKey* | |
+ @return {Ember.ComputedProperty} computed property which returns | |
+ the first truthy value of given list of properties. | |
+ @deprecated Use `Ember.computed.or` instead. | |
+ */ | |
+ var any = generateComputedWithProperties(function(properties) { | |
for (var key in properties) { | |
if (properties.hasOwnProperty(key) && properties[key]) { | |
return properties[key]; | |
@@ -11493,7 +11195,32 @@ | |
return null; | |
}); | |
- var collect = generateComputedWithProperties(function (properties) { | |
+ /** | |
+ A computed property that returns the array of values | |
+ for the provided dependent properties. | |
+ | |
+ Example | |
+ | |
+ ```javascript | |
+ var Hamster = Ember.Object.extend({ | |
+ clothes: Ember.computed.collect('hat', 'shirt') | |
+ }); | |
+ | |
+ var hamster = Hamster.create(); | |
+ | |
+ hamster.get('clothes'); // [null, null] | |
+ hamster.set('hat', 'Camp Hat'); | |
+ hamster.set('shirt', 'Camp Shirt'); | |
+ hamster.get('clothes'); // ['Camp Hat', 'Camp Shirt'] | |
+ ``` | |
+ | |
+ @method collect | |
+ @for Ember.computed | |
+ @param {String} dependentKey* | |
+ @return {Ember.ComputedProperty} computed property which maps | |
+ values of all passed in properties to an array. | |
+ */ | |
+ var collect = generateComputedWithProperties(function(properties) { | |
var res = Ember['default'].A(); | |
for (var key in properties) { | |
if (properties.hasOwnProperty(key)) { | |
@@ -11505,17 +11232,150 @@ | |
} | |
} | |
return res; | |
- });function oneWay(dependentKey) { | |
+ }); | |
+ | |
+ /** | |
+ Creates a new property that is an alias for another property | |
+ on an object. Calls to `get` or `set` this property behave as | |
+ though they were called on the original property. | |
+ | |
+ ```javascript | |
+ var Person = Ember.Object.extend({ | |
+ name: 'Alex Matchneer', | |
+ nomen: Ember.computed.alias('name') | |
+ }); | |
+ | |
+ var alex = Person.create(); | |
+ | |
+ alex.get('nomen'); // 'Alex Matchneer' | |
+ alex.get('name'); // 'Alex Matchneer' | |
+ | |
+ alex.set('nomen', '@machty'); | |
+ alex.get('name'); // '@machty' | |
+ ``` | |
+ | |
+ @method alias | |
+ @for Ember.computed | |
+ @param {String} dependentKey | |
+ @return {Ember.ComputedProperty} computed property which creates an | |
+ alias to the original value for property. | |
+ */ | |
+ | |
+ /** | |
+ Where `computed.alias` aliases `get` and `set`, and allows for bidirectional | |
+ data flow, `computed.oneWay` only provides an aliased `get`. The `set` will | |
+ not mutate the upstream property, rather causes the current property to | |
+ become the value set. This causes the downstream property to permanently | |
+ diverge from the upstream property. | |
+ | |
+ Example | |
+ | |
+ ```javascript | |
+ var User = Ember.Object.extend({ | |
+ firstName: null, | |
+ lastName: null, | |
+ nickName: Ember.computed.oneWay('firstName') | |
+ }); | |
+ | |
+ var teddy = User.create({ | |
+ firstName: 'Teddy', | |
+ lastName: 'Zeenny' | |
+ }); | |
+ | |
+ teddy.get('nickName'); // 'Teddy' | |
+ teddy.set('nickName', 'TeddyBear'); // 'TeddyBear' | |
+ teddy.get('firstName'); // 'Teddy' | |
+ ``` | |
+ | |
+ @method oneWay | |
+ @for Ember.computed | |
+ @param {String} dependentKey | |
+ @return {Ember.ComputedProperty} computed property which creates a | |
+ one way computed property to the original value for property. | |
+ */ | |
+ function oneWay(dependentKey) { | |
return alias['default'](dependentKey).oneWay(); | |
} | |
+ /** | |
+ This is a more semantically meaningful alias of `computed.oneWay`, | |
+ whose name is somewhat ambiguous as to which direction the data flows. | |
+ | |
+ @method reads | |
+ @for Ember.computed | |
+ @param {String} dependentKey | |
+ @return {Ember.ComputedProperty} computed property which creates a | |
+ one way computed property to the original value for property. | |
+ */ | |
+ | |
+ /** | |
+ Where `computed.oneWay` provides oneWay bindings, `computed.readOnly` provides | |
+ a readOnly one way binding. Very often when using `computed.oneWay` one does | |
+ not also want changes to propagate back up, as they will replace the value. | |
+ | |
+ This prevents the reverse flow, and also throws an exception when it occurs. | |
+ | |
+ Example | |
+ | |
+ ```javascript | |
+ var User = Ember.Object.extend({ | |
+ firstName: null, | |
+ lastName: null, | |
+ nickName: Ember.computed.readOnly('firstName') | |
+ }); | |
+ | |
+ var teddy = User.create({ | |
+ firstName: 'Teddy', | |
+ lastName: 'Zeenny' | |
+ }); | |
+ | |
+ teddy.get('nickName'); // 'Teddy' | |
+ teddy.set('nickName', 'TeddyBear'); // throws Exception | |
+ // throw new Ember.Error('Cannot Set: nickName on: <User:ember27288>' );` | |
+ teddy.get('firstName'); // 'Teddy' | |
+ ``` | |
+ | |
+ @method readOnly | |
+ @for Ember.computed | |
+ @param {String} dependentKey | |
+ @return {Ember.ComputedProperty} computed property which creates a | |
+ one way computed property to the original value for property. | |
+ @since 1.5.0 | |
+ */ | |
function readOnly(dependentKey) { | |
return alias['default'](dependentKey).readOnly(); | |
} | |
+ /** | |
+ A computed property that acts like a standard getter and setter, | |
+ but returns the value at the provided `defaultPath` if the | |
+ property itself has not been set to a value | |
+ | |
+ Example | |
+ | |
+ ```javascript | |
+ var Hamster = Ember.Object.extend({ | |
+ wishList: Ember.computed.defaultTo('favoriteFood') | |
+ }); | |
+ | |
+ var hamster = Hamster.create({ favoriteFood: 'Banana' }); | |
+ | |
+ hamster.get('wishList'); // 'Banana' | |
+ hamster.set('wishList', 'More Unit Tests'); | |
+ hamster.get('wishList'); // 'More Unit Tests' | |
+ hamster.get('favoriteFood'); // 'Banana' | |
+ ``` | |
+ | |
+ @method defaultTo | |
+ @for Ember.computed | |
+ @param {String} defaultPath | |
+ @return {Ember.ComputedProperty} computed property which acts like | |
+ a standard getter and setter, but defaults to the value from `defaultPath`. | |
+ @deprecated Use `Ember.computed.oneWay` or custom CP with default instead. | |
+ */ | |
function defaultTo(defaultPath) { | |
- return computed.computed(function (key, newValue, cachedValue) { | |
- Ember['default'].deprecate("Usage of Ember.computed.defaultTo is deprecated, use `Ember.computed.oneWay` instead."); | |
+ return computed.computed(function(key, newValue, cachedValue) { | |
+ Ember['default'].deprecate('Usage of Ember.computed.defaultTo is deprecated, use `Ember.computed.oneWay` instead.'); | |
if (arguments.length === 1) { | |
return property_get.get(this, defaultPath); | |
@@ -11524,9 +11384,22 @@ | |
}); | |
} | |
+ /** | |
+ Creates a new property that is an alias for another property | |
+ on an object. Calls to `get` or `set` this property behave as | |
+ though they were called on the original property, but also | |
+ print a deprecation warning. | |
+ | |
+ @method deprecatingAlias | |
+ @for Ember.computed | |
+ @param {String} dependentKey | |
+ @return {Ember.ComputedProperty} computed property which creates an | |
+ alias with a deprecation to the original value for property. | |
+ @since 1.7.0 | |
+ */ | |
function deprecatingAlias(dependentKey) { | |
- return computed.computed(dependentKey, function (key, value) { | |
- Ember['default'].deprecate("Usage of `" + key + "` is deprecated, use `" + dependentKey + "` instead."); | |
+ return computed.computed(dependentKey, function(key, value) { | |
+ Ember['default'].deprecate('Usage of `' + key + '` is deprecated, use `' + dependentKey + '` instead.'); | |
if (arguments.length > 1) { | |
property_set.set(this, dependentKey, value); | |
@@ -11576,7 +11449,7 @@ | |
@version 1.11.3 | |
*/ | |
- if ("undefined" === typeof Ember) { | |
+ if ('undefined' === typeof Ember) { | |
// Create core object. Make it act like an instance of Ember.Namespace so that | |
// objects assigned to it are given a sane string representation. | |
Ember = {}; | |
@@ -11585,8 +11458,8 @@ | |
// Default imports, exports and lookup to the global object; | |
var global = mainContext || {}; // jshint ignore:line | |
Ember.imports = Ember.imports || global; | |
- Ember.lookup = Ember.lookup || global; | |
- var emExports = Ember.exports = Ember.exports || global; | |
+ Ember.lookup = Ember.lookup || global; | |
+ var emExports = Ember.exports = Ember.exports || global; | |
// aliases needed to keep minifiers from removing the global context | |
emExports.Em = emExports.Ember = Ember; | |
@@ -11595,9 +11468,8 @@ | |
Ember.isNamespace = true; | |
- Ember.toString = function () { | |
- return "Ember"; | |
- }; | |
+ Ember.toString = function() { return "Ember"; }; | |
+ | |
/** | |
@property VERSION | |
@@ -11605,7 +11477,7 @@ | |
@default '1.11.3' | |
@static | |
*/ | |
- Ember.VERSION = "1.11.3"; | |
+ Ember.VERSION = '1.11.3'; | |
/** | |
Standard environmental variables. You can define these in a global `EmberENV` | |
@@ -11620,10 +11492,10 @@ | |
if (Ember.ENV) { | |
// do nothing if Ember.ENV is already setup | |
- Ember.assert("Ember.ENV should be an object.", "object" !== typeof Ember.ENV); | |
- } else if ("undefined" !== typeof EmberENV) { | |
+ Ember.assert('Ember.ENV should be an object.', 'object' !== typeof Ember.ENV); | |
+ } else if ('undefined' !== typeof EmberENV) { | |
Ember.ENV = EmberENV; | |
- } else if ("undefined" !== typeof ENV) { | |
+ } else if ('undefined' !== typeof ENV) { | |
Ember.ENV = ENV; | |
} else { | |
Ember.ENV = {}; | |
@@ -11632,7 +11504,7 @@ | |
Ember.config = Ember.config || {}; | |
// We disable the RANGE API by default for performance reasons | |
- if ("undefined" === typeof Ember.ENV.DISABLE_RANGE_API) { | |
+ if ('undefined' === typeof Ember.ENV.DISABLE_RANGE_API) { | |
Ember.ENV.DISABLE_RANGE_API = true; | |
} | |
@@ -11670,7 +11542,7 @@ | |
@since 1.1.0 | |
*/ | |
- Ember.FEATURES.isEnabled = function (feature) { | |
+ Ember.FEATURES.isEnabled = function(feature) { | |
var featureValue = Ember.FEATURES[feature]; | |
if (Ember.ENV.ENABLE_ALL_FEATURES) { | |
@@ -11705,7 +11577,7 @@ | |
*/ | |
Ember.EXTEND_PROTOTYPES = Ember.ENV.EXTEND_PROTOTYPES; | |
- if (typeof Ember.EXTEND_PROTOTYPES === "undefined") { | |
+ if (typeof Ember.EXTEND_PROTOTYPES === 'undefined') { | |
Ember.EXTEND_PROTOTYPES = true; | |
} | |
@@ -11716,7 +11588,7 @@ | |
@type Boolean | |
@default true | |
*/ | |
- Ember.LOG_STACKTRACE_ON_DEPRECATION = Ember.ENV.LOG_STACKTRACE_ON_DEPRECATION !== false; | |
+ Ember.LOG_STACKTRACE_ON_DEPRECATION = (Ember.ENV.LOG_STACKTRACE_ON_DEPRECATION !== false); | |
/** | |
Determines whether Ember should add ECMAScript 5 Array shims to older browsers. | |
@@ -11725,7 +11597,7 @@ | |
@type Boolean | |
@default Ember.EXTEND_PROTOTYPES | |
*/ | |
- Ember.SHIM_ES5 = Ember.ENV.SHIM_ES5 === false ? false : Ember.EXTEND_PROTOTYPES; | |
+ Ember.SHIM_ES5 = (Ember.ENV.SHIM_ES5 === false) ? false : Ember.EXTEND_PROTOTYPES; | |
/** | |
Determines whether Ember logs info about version of used libraries | |
@@ -11734,7 +11606,7 @@ | |
@type Boolean | |
@default true | |
*/ | |
- Ember.LOG_VERSION = Ember.ENV.LOG_VERSION === false ? false : true; | |
+ Ember.LOG_VERSION = (Ember.ENV.LOG_VERSION === false) ? false : true; | |
/** | |
Empty function. Useful for some operations. Always returns `this`. | |
@@ -11743,33 +11615,19 @@ | |
@private | |
@return {Object} | |
*/ | |
- function K() { | |
- return this; | |
- } | |
+ function K() { return this; } | |
Ember.K = K; | |
//TODO: ES6 GLOBAL TODO | |
// Stub out the methods defined by the ember-debug package in case it's not loaded | |
- if ("undefined" === typeof Ember.assert) { | |
- Ember.assert = K; | |
- } | |
- if ("undefined" === typeof Ember.warn) { | |
- Ember.warn = K; | |
- } | |
- if ("undefined" === typeof Ember.debug) { | |
- Ember.debug = K; | |
- } | |
- if ("undefined" === typeof Ember.runInDebug) { | |
- Ember.runInDebug = K; | |
- } | |
- if ("undefined" === typeof Ember.deprecate) { | |
- Ember.deprecate = K; | |
- } | |
- if ("undefined" === typeof Ember.deprecateFunc) { | |
- Ember.deprecateFunc = function (_, func) { | |
- return func; | |
- }; | |
+ if ('undefined' === typeof Ember.assert) { Ember.assert = K; } | |
+ if ('undefined' === typeof Ember.warn) { Ember.warn = K; } | |
+ if ('undefined' === typeof Ember.debug) { Ember.debug = K; } | |
+ if ('undefined' === typeof Ember.runInDebug) { Ember.runInDebug = K; } | |
+ if ('undefined' === typeof Ember.deprecate) { Ember.deprecate = K; } | |
+ if ('undefined' === typeof Ember.deprecateFunc) { | |
+ Ember.deprecateFunc = function(_, func) { return func; }; | |
} | |
exports['default'] = Ember; | |
@@ -11801,8 +11659,9 @@ | |
} | |
function metaForDeps(meta) { | |
- return keysForDep(meta, "deps"); | |
+ return keysForDep(meta, 'deps'); | |
} | |
+ | |
function addDependentKeys(desc, obj, keyName, meta) { | |
// the descriptor has a list of dependent keys, so | |
// add all of its dependent keys. | |
@@ -11855,31 +11714,23 @@ | |
exports.deprecateProperty = deprecateProperty; | |
/** | |
- Used internally to allow changing properties in a backwards compatible way, and print a helpful | |
- deprecation warning. | |
- | |
- @method deprecateProperty | |
- @param {Object} object The object to add the deprecated property to. | |
- @param {String} deprecatedKey The property to add (and print deprecation warnings upon accessing). | |
- @param {String} newKey The property that will be aliased. | |
- @private | |
- @since 1.7.0 | |
+ @module ember-metal | |
*/ | |
function deprecateProperty(object, deprecatedKey, newKey) { | |
function deprecate() { | |
- Ember['default'].deprecate("Usage of `" + deprecatedKey + "` is deprecated, use `" + newKey + "` instead."); | |
+ Ember['default'].deprecate('Usage of `' + deprecatedKey + '` is deprecated, use `' + newKey + '` instead.'); | |
} | |
if (define_property.hasPropertyAccessors) { | |
properties.defineProperty(object, deprecatedKey, { | |
configurable: true, | |
enumerable: false, | |
- set: function (value) { | |
+ set: function(value) { | |
deprecate(); | |
property_set.set(this, newKey, value); | |
}, | |
- get: function () { | |
+ get: function() { | |
deprecate(); | |
return property_get.get(this, newKey); | |
} | |
@@ -11892,20 +11743,13 @@ | |
'use strict'; | |
- | |
- | |
- // the delete is meant to hint at runtimes that this object should remain in | |
- // dictionary mode. This is clearly a runtime specific hack, but currently it | |
- // appears worthwhile in some usecases. Please note, these deletes do increase | |
- // the cost of creation dramatically over a plain Object.create. And as this | |
- // only makes sense for long-lived dictionaries that aren't instantiated often. | |
- exports['default'] = makeDictionary; | |
function makeDictionary(parent) { | |
var dict = create['default'](parent); | |
- dict["_dict"] = null; | |
- delete dict["_dict"]; | |
+ dict['_dict'] = null; | |
+ delete dict['_dict']; | |
return dict; | |
} | |
+ exports['default'] = makeDictionary; | |
}); | |
enifed('ember-metal/enumerable_utils', ['exports', 'ember-metal/array'], function (exports, array) { | |
@@ -11923,6 +11767,8 @@ | |
exports.replace = replace; | |
exports.intersection = intersection; | |
+ var splice = Array.prototype.splice; | |
+ | |
/** | |
* Defines some convenience methods for working with Enumerables. | |
* `Ember.EnumerableUtils` uses `Ember.ArrayPolyfills` when necessary. | |
@@ -11943,41 +11789,107 @@ | |
* | |
* @return {Array} An array of mapped values. | |
*/ | |
- var splice = Array.prototype.splice; | |
function map(obj, callback, thisArg) { | |
return obj.map ? obj.map(callback, thisArg) : array.map.call(obj, callback, thisArg); | |
} | |
+ /** | |
+ * Calls the forEach function on the passed object with a specified callback. This | |
+ * uses `Ember.ArrayPolyfill`'s-forEach method when necessary. | |
+ * | |
+ * @method forEach | |
+ * @param {Object} obj The object to call forEach on | |
+ * @param {Function} callback The callback to execute | |
+ * @param {Object} thisArg Value to use as this when executing *callback* | |
+ * | |
+ */ | |
function forEach(obj, callback, thisArg) { | |
return obj.forEach ? obj.forEach(callback, thisArg) : array.forEach.call(obj, callback, thisArg); | |
} | |
+ /** | |
+ * Calls the filter function on the passed object with a specified callback. This | |
+ * uses `Ember.ArrayPolyfill`'s-filter method when necessary. | |
+ * | |
+ * @method filter | |
+ * @param {Object} obj The object to call filter on | |
+ * @param {Function} callback The callback to execute | |
+ * @param {Object} thisArg Value to use as this when executing *callback* | |
+ * | |
+ * @return {Array} An array containing the filtered values | |
+ * @since 1.4.0 | |
+ */ | |
function filter(obj, callback, thisArg) { | |
return obj.filter ? obj.filter(callback, thisArg) : array.filter.call(obj, callback, thisArg); | |
} | |
+ /** | |
+ * Calls the indexOf function on the passed object with a specified callback. This | |
+ * uses `Ember.ArrayPolyfill`'s-indexOf method when necessary. | |
+ * | |
+ * @method indexOf | |
+ * @param {Object} obj The object to call indexOn on | |
+ * @param {Function} callback The callback to execute | |
+ * @param {Object} index The index to start searching from | |
+ * | |
+ */ | |
function indexOf(obj, element, index) { | |
return obj.indexOf ? obj.indexOf(element, index) : array.indexOf.call(obj, element, index); | |
} | |
+ /** | |
+ * Returns an array of indexes of the first occurrences of the passed elements | |
+ * on the passed object. | |
+ * | |
+ * ```javascript | |
+ * var array = [1, 2, 3, 4, 5]; | |
+ * Ember.EnumerableUtils.indexesOf(array, [2, 5]); // [1, 4] | |
+ * | |
+ * var fubar = "Fubarr"; | |
+ * Ember.EnumerableUtils.indexesOf(fubar, ['b', 'r']); // [2, 4] | |
+ * ``` | |
+ * | |
+ * @method indexesOf | |
+ * @param {Object} obj The object to check for element indexes | |
+ * @param {Array} elements The elements to search for on *obj* | |
+ * | |
+ * @return {Array} An array of indexes. | |
+ * | |
+ */ | |
function indexesOf(obj, elements) { | |
- return elements === undefined ? [] : map(elements, function (item) { | |
+ return elements === undefined ? [] : map(elements, function(item) { | |
return indexOf(obj, item); | |
}); | |
} | |
+ /** | |
+ * Adds an object to an array. If the array already includes the object this | |
+ * method has no effect. | |
+ * | |
+ * @method addObject | |
+ * @param {Array} array The array the passed item should be added to | |
+ * @param {Object} item The item to add to the passed array | |
+ * | |
+ * @return 'undefined' | |
+ */ | |
function addObject(array, item) { | |
var index = indexOf(array, item); | |
- if (index === -1) { | |
- array.push(item); | |
- } | |
+ if (index === -1) { array.push(item); } | |
} | |
+ /** | |
+ * Removes an object from an array. If the array does not contain the passed | |
+ * object this method has no effect. | |
+ * | |
+ * @method removeObject | |
+ * @param {Array} array The array to remove the item from. | |
+ * @param {Object} item The item to remove from the passed array. | |
+ * | |
+ * @return 'undefined' | |
+ */ | |
function removeObject(array, item) { | |
var index = indexOf(array, item); | |
- if (index !== -1) { | |
- array.splice(index, 1); | |
- } | |
+ if (index !== -1) { array.splice(index, 1); } | |
} | |
function _replace(array, idx, amt, objects) { | |
@@ -11991,9 +11903,7 @@ | |
while (args.length) { | |
count = ends > size ? size : ends; | |
- if (count <= 0) { | |
- count = 0; | |
- } | |
+ if (count <= 0) { count = 0; } | |
chunk = args.splice(0, size); | |
chunk = [start, count].concat(chunk); | |
@@ -12006,6 +11916,31 @@ | |
return ret; | |
} | |
+ /** | |
+ * Replaces objects in an array with the passed objects. | |
+ * | |
+ * ```javascript | |
+ * var array = [1,2,3]; | |
+ * Ember.EnumerableUtils.replace(array, 1, 2, [4, 5]); // [1, 4, 5] | |
+ * | |
+ * var array = [1,2,3]; | |
+ * Ember.EnumerableUtils.replace(array, 1, 1, [4, 5]); // [1, 4, 5, 3] | |
+ * | |
+ * var array = [1,2,3]; | |
+ * Ember.EnumerableUtils.replace(array, 10, 1, [4, 5]); // [1, 2, 3, 4, 5] | |
+ * ``` | |
+ * | |
+ * @method replace | |
+ * @param {Array} array The array the objects should be inserted into. | |
+ * @param {Number} idx Starting index in the array to replace. If *idx* >= | |
+ * length, then append to the end of the array. | |
+ * @param {Number} amt Number of elements that should be removed from the array, | |
+ * starting at *idx* | |
+ * @param {Array} objects An array of zero or more objects that should be | |
+ * inserted into the array at *idx* | |
+ * | |
+ * @return {Array} The modified array. | |
+ */ | |
function replace(array, idx, amt, objects) { | |
if (array.replace) { | |
return array.replace(idx, amt, objects); | |
@@ -12014,9 +11949,32 @@ | |
} | |
} | |
+ /** | |
+ * Calculates the intersection of two arrays. This method returns a new array | |
+ * filled with the records that the two passed arrays share with each other. | |
+ * If there is no intersection, an empty array will be returned. | |
+ * | |
+ * ```javascript | |
+ * var array1 = [1, 2, 3, 4, 5]; | |
+ * var array2 = [1, 3, 5, 6, 7]; | |
+ * | |
+ * Ember.EnumerableUtils.intersection(array1, array2); // [1, 3, 5] | |
+ * | |
+ * var array1 = [1, 2, 3]; | |
+ * var array2 = [4, 5, 6]; | |
+ * | |
+ * Ember.EnumerableUtils.intersection(array1, array2); // [] | |
+ * ``` | |
+ * | |
+ * @method intersection | |
+ * @param {Array} array1 The first array | |
+ * @param {Array} array2 The second array | |
+ * | |
+ * @return {Array} The intersection of the two passed arrays. | |
+ */ | |
function intersection(array1, array2) { | |
var result = []; | |
- forEach(array1, function (element) { | |
+ forEach(array1, function(element) { | |
if (indexOf(array2, element) >= 0) { | |
result.push(element); | |
} | |
@@ -12051,7 +12009,10 @@ | |
// by searching for window and document.createElement. An environment | |
// with DOM may disable the DOM functionality of Ember explicitly by | |
// defining a `disableBrowserEnvironment` ENV. | |
- var hasDOM = typeof window !== "undefined" && typeof document !== "undefined" && typeof document.createElement !== "undefined" && !Ember['default'].ENV.disableBrowserEnvironment; | |
+ var hasDOM = typeof window !== 'undefined' && | |
+ typeof document !== 'undefined' && | |
+ typeof document.createElement !== 'undefined' && | |
+ !Ember['default'].ENV.disableBrowserEnvironment; | |
if (hasDOM) { | |
environment = { | |
@@ -12078,7 +12039,15 @@ | |
'use strict'; | |
- var errorProps = ["description", "fileName", "lineNumber", "message", "name", "number", "stack"]; | |
+ var errorProps = [ | |
+ 'description', | |
+ 'fileName', | |
+ 'lineNumber', | |
+ 'message', | |
+ 'name', | |
+ 'number', | |
+ 'stack' | |
+ ]; | |
/** | |
A subclass of the JavaScript Error object for use in Ember. | |
@@ -12131,12 +12100,16 @@ | |
// | |
"REMOVE_USE_STRICT: true"; | |
+ /** | |
+ @module ember-metal | |
+ */ | |
var a_slice = [].slice; | |
/* listener flags */ | |
var ONCE = 1; | |
var SUSPENDED = 2; | |
+ | |
/* | |
The event system uses a series of nested hashes to store listeners on an | |
object. When a listener is registered, or when an event arrives, these | |
@@ -12160,7 +12133,7 @@ | |
// hashes are added to the end of the event array | |
// so it makes sense to start searching at the end | |
// of the array and search in reverse | |
- for (var i = array.length - 3; i >= 0; i -= 3) { | |
+ for (var i = array.length - 3 ; i >=0; i -= 3) { | |
if (target === array[i] && method === array[i + 1]) { | |
index = i; | |
break; | |
@@ -12196,20 +12169,19 @@ | |
return actions; | |
} | |
+ | |
function accumulateListeners(obj, eventName, otherActions) { | |
- var meta = obj["__ember_meta__"]; | |
+ var meta = obj['__ember_meta__']; | |
var actions = meta && meta.listeners && meta.listeners[eventName]; | |
- if (!actions) { | |
- return; | |
- } | |
+ if (!actions) { return; } | |
var newActions = []; | |
for (var i = actions.length - 3; i >= 0; i -= 3) { | |
var target = actions[i]; | |
- var method = actions[i + 1]; | |
- var flags = actions[i + 2]; | |
+ var method = actions[i+1]; | |
+ var flags = actions[i+2]; | |
var actionIndex = indexOf(otherActions, target, method); | |
if (actionIndex === -1) { | |
@@ -12221,10 +12193,21 @@ | |
return newActions; | |
} | |
+ /** | |
+ Add an event listener | |
+ | |
+ @method addListener | |
+ @for Ember | |
+ @param obj | |
+ @param {String} eventName | |
+ @param {Object|Function} target A target object or a function | |
+ @param {Function|String} method A function or the name of a function to be called on `target` | |
+ @param {Boolean} once A flag whether a function should only be called once | |
+ */ | |
function addListener(obj, eventName, target, method, once) { | |
Ember['default'].assert("You must pass at least an object and event name to Ember.addListener", !!obj && !!eventName); | |
- if (!method && "function" === typeof target) { | |
+ if (!method && 'function' === typeof target) { | |
method = target; | |
target = null; | |
} | |
@@ -12243,7 +12226,7 @@ | |
actions.push(target, method, flags); | |
- if ("function" === typeof obj.didAddListener) { | |
+ if ('function' === typeof obj.didAddListener) { | |
obj.didAddListener(eventName, target, method); | |
} | |
} | |
@@ -12263,7 +12246,7 @@ | |
function removeListener(obj, eventName, target, method) { | |
Ember['default'].assert("You must pass at least an object and event name to Ember.removeListener", !!obj && !!eventName); | |
- if (!method && "function" === typeof target) { | |
+ if (!method && 'function' === typeof target) { | |
method = target; | |
target = null; | |
} | |
@@ -12273,13 +12256,11 @@ | |
var actionIndex = indexOf(actions, target, method); | |
// action doesn't exist, give up silently | |
- if (actionIndex === -1) { | |
- return; | |
- } | |
+ if (actionIndex === -1) { return; } | |
actions.splice(actionIndex, 3); | |
- if ("function" === typeof obj.didRemoveListener) { | |
+ if ('function' === typeof obj.didRemoveListener) { | |
obj.didRemoveListener(eventName, target, method); | |
} | |
} | |
@@ -12287,19 +12268,36 @@ | |
if (method) { | |
_removeListener(target, method); | |
} else { | |
- var meta = obj["__ember_meta__"]; | |
+ var meta = obj['__ember_meta__']; | |
var actions = meta && meta.listeners && meta.listeners[eventName]; | |
- if (!actions) { | |
- return; | |
- } | |
+ if (!actions) { return; } | |
for (var i = actions.length - 3; i >= 0; i -= 3) { | |
- _removeListener(actions[i], actions[i + 1]); | |
+ _removeListener(actions[i], actions[i+1]); | |
} | |
} | |
} | |
+ | |
+ /** | |
+ Suspend listener during callback. | |
+ | |
+ This should only be used by the target of the event listener | |
+ when it is taking an action that would cause the event, e.g. | |
+ an object might suspend its property change listener while it is | |
+ setting that property. | |
+ | |
+ @method suspendListener | |
+ @for Ember | |
+ | |
+ @private | |
+ @param obj | |
+ @param {String} eventName | |
+ @param {Object|Function} target A target object or a function | |
+ @param {Function|String} method A function or the name of a function to be called on `target` | |
+ @param {Function} callback | |
+ */ | |
function suspendListener(obj, eventName, target, method, callback) { | |
- if (!method && "function" === typeof target) { | |
+ if (!method && 'function' === typeof target) { | |
method = target; | |
target = null; | |
} | |
@@ -12308,23 +12306,30 @@ | |
var actionIndex = indexOf(actions, target, method); | |
if (actionIndex !== -1) { | |
- actions[actionIndex + 2] |= SUSPENDED; // mark the action as suspended | |
+ actions[actionIndex+2] |= SUSPENDED; // mark the action as suspended | |
} | |
- function tryable() { | |
- return callback.call(target); | |
- } | |
- function finalizer() { | |
- if (actionIndex !== -1) { | |
- actions[actionIndex + 2] &= ~SUSPENDED; | |
- } | |
- } | |
+ function tryable() { return callback.call(target); } | |
+ function finalizer() { if (actionIndex !== -1) { actions[actionIndex+2] &= ~SUSPENDED; } } | |
return utils.tryFinally(tryable, finalizer); | |
} | |
+ /** | |
+ Suspends multiple listeners during a callback. | |
+ | |
+ @method suspendListeners | |
+ @for Ember | |
+ | |
+ @private | |
+ @param obj | |
+ @param {Array} eventNames Array of event names | |
+ @param {Object|Function} target A target object or a function | |
+ @param {Function|String} method A function or the name of a function to be called on `target` | |
+ @param {Function} callback | |
+ */ | |
function suspendListeners(obj, eventNames, target, method, callback) { | |
- if (!method && "function" === typeof target) { | |
+ if (!method && 'function' === typeof target) { | |
method = target; | |
target = null; | |
} | |
@@ -12333,39 +12338,46 @@ | |
var actionsList = []; | |
var eventName, actions, i, l; | |
- for (i = 0, l = eventNames.length; i < l; i++) { | |
+ for (i=0, l=eventNames.length; i<l; i++) { | |
eventName = eventNames[i]; | |
actions = actionsFor(obj, eventName); | |
var actionIndex = indexOf(actions, target, method); | |
if (actionIndex !== -1) { | |
- actions[actionIndex + 2] |= SUSPENDED; | |
+ actions[actionIndex+2] |= SUSPENDED; | |
suspendedActions.push(actionIndex); | |
actionsList.push(actions); | |
} | |
} | |
- function tryable() { | |
- return callback.call(target); | |
- } | |
+ function tryable() { return callback.call(target); } | |
function finalizer() { | |
for (var i = 0, l = suspendedActions.length; i < l; i++) { | |
var actionIndex = suspendedActions[i]; | |
- actionsList[i][actionIndex + 2] &= ~SUSPENDED; | |
+ actionsList[i][actionIndex+2] &= ~SUSPENDED; | |
} | |
} | |
return utils.tryFinally(tryable, finalizer); | |
} | |
+ /** | |
+ Return a list of currently watched events | |
+ | |
+ @private | |
+ @method watchedEvents | |
+ @for Ember | |
+ @param obj | |
+ */ | |
function watchedEvents(obj) { | |
- var listeners = obj["__ember_meta__"].listeners; | |
+ var listeners = obj['__ember_meta__'].listeners; | |
var ret = []; | |
if (listeners) { | |
for (var eventName in listeners) { | |
- if (eventName !== "__source__" && listeners[eventName]) { | |
+ if (eventName !== '__source__' && | |
+ listeners[eventName]) { | |
ret.push(eventName); | |
} | |
} | |
@@ -12373,40 +12385,43 @@ | |
return ret; | |
} | |
+ /** | |
+ Send an event. The execution of suspended listeners | |
+ is skipped, and once listeners are removed. A listener without | |
+ a target is executed on the passed object. If an array of actions | |
+ is not passed, the actions stored on the passed object are invoked. | |
+ | |
+ @method sendEvent | |
+ @for Ember | |
+ @param obj | |
+ @param {String} eventName | |
+ @param {Array} params Optional parameters for each listener. | |
+ @param {Array} actions Optional array of actions (listeners). | |
+ @return true | |
+ */ | |
function sendEvent(obj, eventName, params, actions) { | |
// first give object a chance to handle it | |
- if (obj !== Ember['default'] && "function" === typeof obj.sendEvent) { | |
+ if (obj !== Ember['default'] && 'function' === typeof obj.sendEvent) { | |
obj.sendEvent(eventName, params); | |
} | |
if (!actions) { | |
- var meta = obj["__ember_meta__"]; | |
+ var meta = obj['__ember_meta__']; | |
actions = meta && meta.listeners && meta.listeners[eventName]; | |
} | |
- if (!actions) { | |
- return; | |
- } | |
+ if (!actions) { return; } | |
- for (var i = actions.length - 3; i >= 0; i -= 3) { | |
- // looping in reverse for once listeners | |
+ for (var i = actions.length - 3; i >= 0; i -= 3) { // looping in reverse for once listeners | |
var target = actions[i]; | |
- var method = actions[i + 1]; | |
- var flags = actions[i + 2]; | |
+ var method = actions[i+1]; | |
+ var flags = actions[i+2]; | |
- if (!method) { | |
- continue; | |
- } | |
- if (flags & SUSPENDED) { | |
- continue; | |
- } | |
- if (flags & ONCE) { | |
- removeListener(obj, eventName, target, method); | |
- } | |
- if (!target) { | |
- target = obj; | |
- } | |
- if ("string" === typeof method) { | |
+ if (!method) { continue; } | |
+ if (flags & SUSPENDED) { continue; } | |
+ if (flags & ONCE) { removeListener(obj, eventName, target, method); } | |
+ if (!target) { target = obj; } | |
+ if ('string' === typeof method) { | |
if (params) { | |
utils.applyStr(target, method, params); | |
} else { | |
@@ -12423,31 +12438,66 @@ | |
return true; | |
} | |
+ /** | |
+ @private | |
+ @method hasListeners | |
+ @for Ember | |
+ @param obj | |
+ @param {String} eventName | |
+ */ | |
function hasListeners(obj, eventName) { | |
- var meta = obj["__ember_meta__"]; | |
+ var meta = obj['__ember_meta__']; | |
var actions = meta && meta.listeners && meta.listeners[eventName]; | |
return !!(actions && actions.length); | |
} | |
+ /** | |
+ @private | |
+ @method listenersFor | |
+ @for Ember | |
+ @param obj | |
+ @param {String} eventName | |
+ */ | |
function listenersFor(obj, eventName) { | |
var ret = []; | |
- var meta = obj["__ember_meta__"]; | |
+ var meta = obj['__ember_meta__']; | |
var actions = meta && meta.listeners && meta.listeners[eventName]; | |
- if (!actions) { | |
- return ret; | |
- } | |
+ if (!actions) { return ret; } | |
for (var i = 0, l = actions.length; i < l; i += 3) { | |
var target = actions[i]; | |
- var method = actions[i + 1]; | |
+ var method = actions[i+1]; | |
ret.push([target, method]); | |
} | |
return ret; | |
} | |
+ /** | |
+ Define a property as a function that should be executed when | |
+ a specified event or events are triggered. | |
+ | |
+ | |
+ ``` javascript | |
+ var Job = Ember.Object.extend({ | |
+ logCompleted: Ember.on('completed', function() { | |
+ console.log('Job completed!'); | |
+ }) | |
+ }); | |
+ | |
+ var job = Job.create(); | |
+ | |
+ Ember.sendEvent(job, 'completed'); // Logs 'Job completed!' | |
+ ``` | |
+ | |
+ @method on | |
+ @for Ember | |
+ @param {String} eventNames* | |
+ @param {Function} func | |
+ @return func | |
+ */ | |
function on() { | |
var func = a_slice.call(arguments, -1)[0]; | |
var events = a_slice.call(arguments, 0, -1); | |
@@ -12460,7 +12510,7 @@ | |
'use strict'; | |
- | |
+ var SPLIT_REGEX = /\{|\}/; | |
/** | |
Expands `pattern`, invoking `callback` for each expansion. | |
@@ -12488,37 +12538,36 @@ | |
@param {Function} callback The callback to invoke. It is invoked once per | |
expansion, and is passed the expansion. | |
*/ | |
- exports['default'] = expandProperties; | |
- | |
- var SPLIT_REGEX = /\{|\}/; | |
function expandProperties(pattern, callback) { | |
- if (pattern.indexOf(" ") > -1) { | |
- throw new EmberError['default']("Brace expanded properties cannot contain spaces, " + "e.g. `user.{firstName, lastName}` should be `user.{firstName,lastName}`"); | |
+ if (pattern.indexOf(' ') > -1) { | |
+ throw new EmberError['default']('Brace expanded properties cannot contain spaces, ' + | |
+ 'e.g. `user.{firstName, lastName}` should be `user.{firstName,lastName}`'); | |
} | |
- if ("string" === utils.typeOf(pattern)) { | |
+ if ('string' === utils.typeOf(pattern)) { | |
var parts = pattern.split(SPLIT_REGEX); | |
var properties = [parts]; | |
- enumerable_utils.forEach(parts, function (part, index) { | |
- if (part.indexOf(",") >= 0) { | |
- properties = duplicateAndReplace(properties, part.split(","), index); | |
+ enumerable_utils.forEach(parts, function(part, index) { | |
+ if (part.indexOf(',') >= 0) { | |
+ properties = duplicateAndReplace(properties, part.split(','), index); | |
} | |
}); | |
- enumerable_utils.forEach(properties, function (property) { | |
- callback(property.join("")); | |
+ enumerable_utils.forEach(properties, function(property) { | |
+ callback(property.join('')); | |
}); | |
} else { | |
callback(pattern); | |
} | |
} | |
+ exports['default'] = expandProperties; | |
function duplicateAndReplace(properties, currentParts, index) { | |
var all = []; | |
- enumerable_utils.forEach(properties, function (property) { | |
- enumerable_utils.forEach(currentParts, function (part) { | |
+ enumerable_utils.forEach(properties, function(property) { | |
+ enumerable_utils.forEach(currentParts, function(part) { | |
var current = property.slice(0); | |
current[index] = part; | |
all.push(current); | |
@@ -12533,37 +12582,12 @@ | |
'use strict'; | |
- | |
- | |
- /** | |
- To get multiple properties at once, call `Ember.getProperties` | |
- with an object followed by a list of strings or an array: | |
- | |
- ```javascript | |
- Ember.getProperties(record, 'firstName', 'lastName', 'zipCode'); | |
- // { firstName: 'John', lastName: 'Doe', zipCode: '10011' } | |
- ``` | |
- | |
- is equivalent to: | |
- | |
- ```javascript | |
- Ember.getProperties(record, ['firstName', 'lastName', 'zipCode']); | |
- // { firstName: 'John', lastName: 'Doe', zipCode: '10011' } | |
- ``` | |
- | |
- @method getProperties | |
- @for Ember | |
- @param {Object} obj | |
- @param {String...|Array} list of keys to get | |
- @return {Object} | |
- */ | |
- exports['default'] = getProperties; | |
function getProperties(obj) { | |
var ret = {}; | |
var propertyNames = arguments; | |
var i = 1; | |
- if (arguments.length === 2 && utils.typeOf(arguments[1]) === "array") { | |
+ if (arguments.length === 2 && utils.typeOf(arguments[1]) === 'array') { | |
i = 0; | |
propertyNames = arguments[1]; | |
} | |
@@ -12572,6 +12596,7 @@ | |
} | |
return ret; | |
} | |
+ exports['default'] = getProperties; | |
}); | |
enifed('ember-metal/injected_property', ['exports', 'ember-metal/core', 'ember-metal/computed', 'ember-metal/alias', 'ember-metal/properties', 'ember-metal/platform/create'], function (exports, Ember, computed, alias, properties, create) { | |
@@ -12588,11 +12613,13 @@ | |
function injectedPropertyGet(keyName) { | |
var possibleDesc = this[keyName]; | |
- var desc = possibleDesc !== null && typeof possibleDesc === "object" && possibleDesc.isDescriptor ? possibleDesc : undefined; | |
+ var desc = (possibleDesc !== null && typeof possibleDesc === 'object' && possibleDesc.isDescriptor) ? possibleDesc : undefined; | |
- Ember['default'].assert("Attempting to lookup an injected property on an object " + "without a container, ensure that the object was " + "instantiated via a container.", this.container); | |
+ Ember['default'].assert("Attempting to lookup an injected property on an object " + | |
+ "without a container, ensure that the object was " + | |
+ "instantiated via a container.", this.container); | |
- return this.container.lookup(desc.type + ":" + (desc.name || keyName)); | |
+ return this.container.lookup(desc.type + ':' + (desc.name || keyName)); | |
} | |
InjectedProperty.prototype = create['default'](properties.Descriptor.prototype); | |
@@ -12621,25 +12648,14 @@ | |
exports.unsubscribe = unsubscribe; | |
exports.reset = reset; | |
- /** | |
- Notifies event's subscribers, calls `before` and `after` hooks. | |
- | |
- @method instrument | |
- @namespace Ember.Instrumentation | |
- | |
- @param {String} [name] Namespaced event name. | |
- @param {Object} payload | |
- @param {Function} callback Function that you're instrumenting. | |
- @param {Object} binding Context that instrument function is called with. | |
- */ | |
var subscribers = []; | |
var cache = {}; | |
- var populateListeners = function (name) { | |
+ var populateListeners = function(name) { | |
var listeners = []; | |
var subscriber; | |
- for (var i = 0, l = subscribers.length; i < l; i++) { | |
+ for (var i=0, l=subscribers.length; i<l; i++) { | |
subscriber = subscribers[i]; | |
if (subscriber.regex.test(name)) { | |
listeners.push(subscriber.object); | |
@@ -12650,16 +12666,26 @@ | |
return listeners; | |
}; | |
- var time = (function () { | |
- var perf = "undefined" !== typeof window ? window.performance || {} : {}; | |
+ var time = (function() { | |
+ var perf = 'undefined' !== typeof window ? window.performance || {} : {}; | |
var fn = perf.now || perf.mozNow || perf.webkitNow || perf.msNow || perf.oNow; | |
// fn.bind will be available in all the browsers that support the advanced window.performance... ;-) | |
- return fn ? fn.bind(perf) : function () { | |
- return +new Date(); | |
- }; | |
+ return fn ? fn.bind(perf) : function() { return +new Date(); }; | |
})(); | |
+ | |
+ /** | |
+ Notifies event's subscribers, calls `before` and `after` hooks. | |
+ | |
+ @method instrument | |
+ @namespace Ember.Instrumentation | |
+ | |
+ @param {String} [name] Namespaced event name. | |
+ @param {Object} payload | |
+ @param {Function} callback Function that you're instrumenting. | |
+ @param {Object} binding Context that instrument function is called with. | |
+ */ | |
function instrument(name, _payload, callback, binding) { | |
- if (arguments.length <= 3 && typeof _payload === "function") { | |
+ if (arguments.length <= 3 && typeof _payload === 'function') { | |
binding = callback; | |
callback = _payload; | |
_payload = undefined; | |
@@ -12684,6 +12710,7 @@ | |
} | |
} | |
+ // private for now | |
function _instrumentStart(name, _payload) { | |
var listeners = cache[name]; | |
@@ -12708,7 +12735,7 @@ | |
var beforeValues = new Array(l); | |
var i, listener; | |
var timestamp = time(); | |
- for (i = 0; i < l; i++) { | |
+ for (i=0; i<l; i++) { | |
listener = listeners[i]; | |
beforeValues[i] = listener.before(name, timestamp, payload); | |
} | |
@@ -12716,7 +12743,7 @@ | |
return function _instrumentEnd() { | |
var i, l, listener; | |
var timestamp = time(); | |
- for (i = 0, l = listeners.length; i < l; i++) { | |
+ for (i=0, l=listeners.length; i<l; i++) { | |
listener = listeners[i]; | |
listener.after(name, timestamp, payload, beforeValues[i]); | |
} | |
@@ -12727,12 +12754,23 @@ | |
}; | |
} | |
+ /** | |
+ Subscribes to a particular event or instrumented block of code. | |
+ | |
+ @method subscribe | |
+ @namespace Ember.Instrumentation | |
+ | |
+ @param {String} [pattern] Namespaced event name. | |
+ @param {Object} [object] Before and After hooks. | |
+ | |
+ @return {Subscriber} | |
+ */ | |
function subscribe(pattern, object) { | |
var paths = pattern.split("."); | |
var path; | |
var regex = []; | |
- for (var i = 0, l = paths.length; i < l; i++) { | |
+ for (var i=0, l=paths.length; i<l; i++) { | |
path = paths[i]; | |
if (path === "*") { | |
regex.push("[^\\.]*"); | |
@@ -12756,10 +12794,18 @@ | |
return subscriber; | |
} | |
+ /** | |
+ Unsubscribes from a particular event or instrumented block of code. | |
+ | |
+ @method unsubscribe | |
+ @namespace Ember.Instrumentation | |
+ | |
+ @param {Object} [subscriber] | |
+ */ | |
function unsubscribe(subscriber) { | |
var index; | |
- for (var i = 0, l = subscribers.length; i < l; i++) { | |
+ for (var i=0, l=subscribers.length; i<l; i++) { | |
if (subscribers[i] === subscriber) { | |
index = i; | |
} | |
@@ -12769,6 +12815,12 @@ | |
cache = {}; | |
} | |
+ /** | |
+ Resets `Ember.Instrumentation` by flushing list of subscribers. | |
+ | |
+ @method reset | |
+ @namespace Ember.Instrumentation | |
+ */ | |
function reset() { | |
subscribers.length = 0; | |
cache = {}; | |
@@ -12781,35 +12833,10 @@ | |
'use strict'; | |
- | |
- | |
- /** | |
- A value is blank if it is empty or a whitespace string. | |
- | |
- ```javascript | |
- Ember.isBlank(); // true | |
- Ember.isBlank(null); // true | |
- Ember.isBlank(undefined); // true | |
- Ember.isBlank(''); // true | |
- Ember.isBlank([]); // true | |
- Ember.isBlank('\n\t'); // true | |
- Ember.isBlank(' '); // true | |
- Ember.isBlank({}); // false | |
- Ember.isBlank('\n\t Hello'); // false | |
- Ember.isBlank('Hello world'); // false | |
- Ember.isBlank([1,2,3]); // false | |
- ``` | |
- | |
- @method isBlank | |
- @for Ember | |
- @param {Object} obj Value to test | |
- @return {Boolean} | |
- @since 1.5.0 | |
- */ | |
- exports['default'] = isBlank; | |
function isBlank(obj) { | |
- return isEmpty['default'](obj) || typeof obj === "string" && obj.match(/\S/) === null; | |
+ return isEmpty['default'](obj) || (typeof obj === 'string' && obj.match(/\S/) === null); | |
} | |
+ exports['default'] = isBlank; | |
}); | |
enifed('ember-metal/is_empty', ['exports', 'ember-metal/property_get', 'ember-metal/is_none'], function (exports, property_get, isNone) { | |
@@ -12822,26 +12849,26 @@ | |
return none; | |
} | |
- if (typeof obj.size === "number") { | |
+ if (typeof obj.size === 'number') { | |
return !obj.size; | |
} | |
var objectType = typeof obj; | |
- if (objectType === "object") { | |
- var size = property_get.get(obj, "size"); | |
- if (typeof size === "number") { | |
+ if (objectType === 'object') { | |
+ var size = property_get.get(obj, 'size'); | |
+ if (typeof size === 'number') { | |
return !size; | |
} | |
} | |
- if (typeof obj.length === "number" && objectType !== "function") { | |
+ if (typeof obj.length === 'number' && objectType !== 'function') { | |
return !obj.length; | |
} | |
- if (objectType === "object") { | |
- var length = property_get.get(obj, "length"); | |
- if (typeof length === "number") { | |
+ if (objectType === 'object') { | |
+ var length = property_get.get(obj, 'length'); | |
+ if (typeof length === 'number') { | |
return !length; | |
} | |
} | |
@@ -12886,35 +12913,10 @@ | |
'use strict'; | |
- | |
- | |
- /** | |
- A value is present if it not `isBlank`. | |
- | |
- ```javascript | |
- Ember.isPresent(); // false | |
- Ember.isPresent(null); // false | |
- Ember.isPresent(undefined); // false | |
- Ember.isPresent(''); // false | |
- Ember.isPresent([]); // false | |
- Ember.isPresent('\n\t'); // false | |
- Ember.isPresent(' '); // false | |
- Ember.isPresent({}); // true | |
- Ember.isPresent('\n\t Hello'); // true | |
- Ember.isPresent('Hello world'); // true | |
- Ember.isPresent([1,2,3]); // true | |
- ``` | |
- | |
- @method isPresent | |
- @for Ember | |
- @param {Object} obj Value to test | |
- @return {Boolean} | |
- @since 1.8.0 | |
- */ | |
- exports['default'] = isPresent; | |
function isPresent(obj) { | |
return !isBlank['default'](obj); | |
} | |
+ exports['default'] = isPresent; | |
}); | |
enifed('ember-metal/keys', ['exports', 'ember-metal/platform/define_property'], function (exports, define_property) { | |
@@ -12928,20 +12930,30 @@ | |
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/keys | |
keys = (function () { | |
var hasOwnProperty = Object.prototype.hasOwnProperty; | |
- var hasDontEnumBug = !({ toString: null }).propertyIsEnumerable("toString"); | |
- var dontEnums = ["toString", "toLocaleString", "valueOf", "hasOwnProperty", "isPrototypeOf", "propertyIsEnumerable", "constructor"]; | |
+ var hasDontEnumBug = !({ toString: null }).propertyIsEnumerable('toString'); | |
+ var dontEnums = [ | |
+ 'toString', | |
+ 'toLocaleString', | |
+ 'valueOf', | |
+ 'hasOwnProperty', | |
+ 'isPrototypeOf', | |
+ 'propertyIsEnumerable', | |
+ 'constructor' | |
+ ]; | |
var dontEnumsLength = dontEnums.length; | |
return function keys(obj) { | |
- if (typeof obj !== "object" && (typeof obj !== "function" || obj === null)) { | |
- throw new TypeError("Object.keys called on non-object"); | |
+ if (typeof obj !== 'object' && (typeof obj !== 'function' || obj === null)) { | |
+ throw new TypeError('Object.keys called on non-object'); | |
} | |
var result = []; | |
var prop, i; | |
for (prop in obj) { | |
- if (prop !== "_super" && prop.lastIndexOf("__", 0) !== 0 && hasOwnProperty.call(obj, prop)) { | |
+ if (prop !== '_super' && | |
+ prop.lastIndexOf('__', 0) !== 0 && | |
+ hasOwnProperty.call(obj, prop)) { | |
result.push(prop); | |
} | |
} | |
@@ -12955,7 +12967,7 @@ | |
} | |
return result; | |
}; | |
- })(); | |
+ }()); | |
} | |
exports['default'] = keys; | |
@@ -12973,7 +12985,7 @@ | |
Libraries.prototype = { | |
constructor: Libraries, | |
- _getLibraryByName: function (name) { | |
+ _getLibraryByName: function(name) { | |
var libs = this._registry; | |
var count = libs.length; | |
@@ -12984,7 +12996,7 @@ | |
} | |
}, | |
- register: function (name, version, isCoreLibrary) { | |
+ register: function(name, version, isCoreLibrary) { | |
var index = this._registry.length; | |
if (!this._getLibraryByName(name)) { | |
@@ -12993,15 +13005,15 @@ | |
} | |
this._registry.splice(index, 0, { name: name, version: version }); | |
} else { | |
- Ember['default'].warn("Library \"" + name + "\" is already registered with Ember."); | |
+ Ember['default'].warn('Library "' + name + '" is already registered with Ember.'); | |
} | |
}, | |
- registerCoreLibrary: function (name, version) { | |
+ registerCoreLibrary: function(name, version) { | |
this.register(name, version, true); | |
}, | |
- deRegister: function (name) { | |
+ deRegister: function(name) { | |
var lib = this._getLibraryByName(name); | |
var index; | |
@@ -13011,9 +13023,9 @@ | |
} | |
}, | |
- each: function (callback) { | |
- Ember['default'].deprecate("Using Ember.libraries.each() is deprecated. Access to a list of registered libraries is currently a private API. If you are not knowingly accessing this method, your out-of-date Ember Inspector may be doing so."); | |
- enumerable_utils.forEach(this._registry, function (lib) { | |
+ each: function(callback) { | |
+ Ember['default'].deprecate('Using Ember.libraries.each() is deprecated. Access to a list of registered libraries is currently a private API. If you are not knowingly accessing this method, your out-of-date Ember Inspector may be doing so.'); | |
+ enumerable_utils.forEach(this._registry, function(lib) { | |
callback(lib.name, lib.version); | |
}); | |
} | |
@@ -13026,35 +13038,33 @@ | |
'use strict'; | |
- function K() { | |
- return this; | |
- } | |
+ function K() { return this; } | |
function consoleMethod(name) { | |
var consoleObj, logToConsole; | |
if (Ember['default'].imports.console) { | |
consoleObj = Ember['default'].imports.console; | |
- } else if (typeof console !== "undefined") { | |
+ } else if (typeof console !== 'undefined') { | |
consoleObj = console; | |
} | |
- var method = typeof consoleObj === "object" ? consoleObj[name] : null; | |
+ var method = typeof consoleObj === 'object' ? consoleObj[name] : null; | |
if (method) { | |
// Older IE doesn't support bind, but Chrome needs it | |
- if (typeof method.bind === "function") { | |
+ if (typeof method.bind === 'function') { | |
logToConsole = method.bind(consoleObj); | |
- logToConsole.displayName = "console." + name; | |
+ logToConsole.displayName = 'console.' + name; | |
return logToConsole; | |
- } else if (typeof method.apply === "function") { | |
- logToConsole = function () { | |
+ } else if (typeof method.apply === 'function') { | |
+ logToConsole = function() { | |
method.apply(consoleObj, arguments); | |
}; | |
- logToConsole.displayName = "console." + name; | |
+ logToConsole.displayName = 'console.' + name; | |
return logToConsole; | |
} else { | |
- return function () { | |
- var message = Array.prototype.join.call(arguments, ", "); | |
+ return function() { | |
+ var message = Array.prototype.join.call(arguments, ', '); | |
method(message); | |
}; | |
} | |
@@ -13066,8 +13076,8 @@ | |
try { | |
// attempt to preserve the stack | |
throw new EmberError['default']("assertion failed: " + message); | |
- } catch (error) { | |
- setTimeout(function () { | |
+ } catch(error) { | |
+ setTimeout(function() { | |
throw error; | |
}, 0); | |
} | |
@@ -13085,82 +13095,94 @@ | |
/** | |
Logs the arguments to the console. | |
You can pass as many arguments as you want and they will be joined together with a space. | |
- ```javascript | |
+ | |
+ ```javascript | |
var foo = 1; | |
Ember.Logger.log('log value of foo:', foo); | |
// "log value of foo: 1" will be printed to the console | |
``` | |
- @method log | |
+ | |
+ @method log | |
@for Ember.Logger | |
@param {*} arguments | |
*/ | |
- log: consoleMethod("log") || K, | |
+ log: consoleMethod('log') || K, | |
/** | |
Prints the arguments to the console with a warning icon. | |
You can pass as many arguments as you want and they will be joined together with a space. | |
- ```javascript | |
+ | |
+ ```javascript | |
Ember.Logger.warn('Something happened!'); | |
// "Something happened!" will be printed to the console with a warning icon. | |
``` | |
- @method warn | |
+ | |
+ @method warn | |
@for Ember.Logger | |
@param {*} arguments | |
*/ | |
- warn: consoleMethod("warn") || K, | |
+ warn: consoleMethod('warn') || K, | |
/** | |
Prints the arguments to the console with an error icon, red text and a stack trace. | |
You can pass as many arguments as you want and they will be joined together with a space. | |
- ```javascript | |
+ | |
+ ```javascript | |
Ember.Logger.error('Danger! Danger!'); | |
// "Danger! Danger!" will be printed to the console in red text. | |
``` | |
- @method error | |
+ | |
+ @method error | |
@for Ember.Logger | |
@param {*} arguments | |
*/ | |
- error: consoleMethod("error") || K, | |
+ error: consoleMethod('error') || K, | |
/** | |
Logs the arguments to the console. | |
You can pass as many arguments as you want and they will be joined together with a space. | |
- ```javascript | |
+ | |
+ ```javascript | |
var foo = 1; | |
Ember.Logger.info('log value of foo:', foo); | |
// "log value of foo: 1" will be printed to the console | |
``` | |
- @method info | |
+ | |
+ @method info | |
@for Ember.Logger | |
@param {*} arguments | |
*/ | |
- info: consoleMethod("info") || K, | |
+ info: consoleMethod('info') || K, | |
/** | |
Logs the arguments to the console in blue text. | |
You can pass as many arguments as you want and they will be joined together with a space. | |
- ```javascript | |
+ | |
+ ```javascript | |
var foo = 1; | |
Ember.Logger.debug('log value of foo:', foo); | |
// "log value of foo: 1" will be printed to the console | |
``` | |
- @method debug | |
+ | |
+ @method debug | |
@for Ember.Logger | |
@param {*} arguments | |
*/ | |
- debug: consoleMethod("debug") || consoleMethod("info") || K, | |
+ debug: consoleMethod('debug') || consoleMethod('info') || K, | |
/** | |
If the value passed into `Ember.Logger.assert` is not truthy it will throw an error with a stack trace. | |
- ```javascript | |
+ | |
+ ```javascript | |
Ember.Logger.assert(true); // undefined | |
Ember.Logger.assert(true === false); // Throws an Assertion failed error. | |
``` | |
- @method assert | |
+ | |
+ @method assert | |
@for Ember.Logger | |
@param {Boolean} bool Value to test | |
*/ | |
- assert: consoleMethod("assert") || assertPolyfill | |
+ assert: consoleMethod('assert') || assertPolyfill | |
}; | |
}); | |
@@ -13195,7 +13217,7 @@ | |
*/ | |
function missingFunction(fn) { | |
- throw new TypeError("" + Object.prototype.toString.call(fn) + " is not a function"); | |
+ throw new TypeError('' + Object.prototype.toString.call(fn) + " is not a function"); | |
} | |
function missingNew(name) { | |
@@ -13249,7 +13271,7 @@ | |
@static | |
@return {Ember.OrderedSet} | |
*/ | |
- OrderedSet.create = function () { | |
+ OrderedSet.create = function() { | |
var Constructor = this; | |
return new Constructor(); | |
@@ -13260,7 +13282,7 @@ | |
/** | |
@method clear | |
*/ | |
- clear: function () { | |
+ clear: function() { | |
this.presenceSet = create['default'](null); | |
this.list = []; | |
this.size = 0; | |
@@ -13272,7 +13294,7 @@ | |
@param guid (optional, and for internal use) | |
@return {Ember.OrderedSet} | |
*/ | |
- add: function (obj, _guid) { | |
+ add: function(obj, _guid) { | |
var guid = _guid || utils.guidFor(obj); | |
var presenceSet = this.presenceSet; | |
var list = this.list; | |
@@ -13287,13 +13309,17 @@ | |
/** | |
@deprecated | |
- @method remove | |
+ | |
+ @method remove | |
@param obj | |
@param _guid (optional and for internal use only) | |
@return {Boolean} | |
*/ | |
- remove: function (obj, _guid) { | |
- Ember.deprecate("Calling `OrderedSet.prototype.remove` has been deprecated, please use `OrderedSet.prototype.delete` instead.", this._silenceRemoveDeprecation); | |
+ remove: function(obj, _guid) { | |
+ Ember.deprecate( | |
+ 'Calling `OrderedSet.prototype.remove` has been deprecated, please use `OrderedSet.prototype.delete` instead.', | |
+ this._silenceRemoveDeprecation | |
+ ); | |
return this["delete"](obj, _guid); | |
}, | |
@@ -13305,7 +13331,7 @@ | |
@param _guid (optional and for internal use only) | |
@return {Boolean} | |
*/ | |
- "delete": function (obj, _guid) { | |
+ "delete": function(obj, _guid) { | |
var guid = _guid || utils.guidFor(obj); | |
var presenceSet = this.presenceSet; | |
var list = this.list; | |
@@ -13327,7 +13353,7 @@ | |
@method isEmpty | |
@return {Boolean} | |
*/ | |
- isEmpty: function () { | |
+ isEmpty: function() { | |
return this.size === 0; | |
}, | |
@@ -13336,10 +13362,8 @@ | |
@param obj | |
@return {Boolean} | |
*/ | |
- has: function (obj) { | |
- if (this.size === 0) { | |
- return false; | |
- } | |
+ has: function(obj) { | |
+ if (this.size === 0) { return false; } | |
var guid = utils.guidFor(obj); | |
var presenceSet = this.presenceSet; | |
@@ -13352,14 +13376,12 @@ | |
@param {Function} fn | |
@param self | |
*/ | |
- forEach: function (fn /*, thisArg*/) { | |
- if (typeof fn !== "function") { | |
+ forEach: function(fn /*, thisArg*/) { | |
+ if (typeof fn !== 'function') { | |
missingFunction(fn); | |
} | |
- if (this.size === 0) { | |
- return; | |
- } | |
+ if (this.size === 0) { return; } | |
var list = this.list; | |
var length = arguments.length; | |
@@ -13380,7 +13402,7 @@ | |
@method toArray | |
@return {Array} | |
*/ | |
- toArray: function () { | |
+ toArray: function() { | |
return this.list.slice(); | |
}, | |
@@ -13388,7 +13410,7 @@ | |
@method copy | |
@return {Ember.OrderedSet} | |
*/ | |
- copy: function () { | |
+ copy: function() { | |
var Constructor = this.constructor; | |
var set = new Constructor(); | |
@@ -13401,7 +13423,7 @@ | |
} | |
}; | |
- deprecate_property.deprecateProperty(OrderedSet.prototype, "length", "size"); | |
+ deprecate_property.deprecateProperty(OrderedSet.prototype, 'length', 'size'); | |
/** | |
A Map stores values indexed by keys. Unlike JavaScript's | |
@@ -13440,7 +13462,7 @@ | |
@method create | |
@static | |
*/ | |
- Map.create = function () { | |
+ Map.create = function() { | |
var Constructor = this; | |
return new Constructor(); | |
}; | |
@@ -13450,7 +13472,8 @@ | |
/** | |
This property will change as the number of objects in the map changes. | |
- @since 1.8.0 | |
+ | |
+ @since 1.8.0 | |
@property size | |
@type number | |
@default 0 | |
@@ -13459,14 +13482,13 @@ | |
/** | |
Retrieve the value associated with a given key. | |
- @method get | |
+ | |
+ @method get | |
@param {*} key | |
@return {*} the value associated with the key, or `undefined` | |
*/ | |
- get: function (key) { | |
- if (this.size === 0) { | |
- return; | |
- } | |
+ get: function(key) { | |
+ if (this.size === 0) { return; } | |
var values = this._values; | |
var guid = utils.guidFor(key); | |
@@ -13477,12 +13499,13 @@ | |
/** | |
Adds a value to the map. If a value for the given key has already been | |
provided, the new value will replace the old value. | |
- @method set | |
+ | |
+ @method set | |
@param {*} key | |
@param {*} value | |
@return {Ember.Map} | |
*/ | |
- set: function (key, value) { | |
+ set: function(key, value) { | |
var keys = this._keys; | |
var values = this._values; | |
var guid = utils.guidFor(key); | |
@@ -13502,27 +13525,27 @@ | |
/** | |
@deprecated see delete | |
Removes a value from the map for an associated key. | |
- @method remove | |
+ | |
+ @method remove | |
@param {*} key | |
@return {Boolean} true if an item was removed, false otherwise | |
*/ | |
- remove: function (key) { | |
- Ember.deprecate("Calling `Map.prototype.remove` has been deprecated, please use `Map.prototype.delete` instead."); | |
+ remove: function(key) { | |
+ Ember.deprecate('Calling `Map.prototype.remove` has been deprecated, please use `Map.prototype.delete` instead.'); | |
return this["delete"](key); | |
}, | |
/** | |
Removes a value from the map for an associated key. | |
- @since 1.8.0 | |
+ | |
+ @since 1.8.0 | |
@method delete | |
@param {*} key | |
@return {Boolean} true if an item was removed, false otherwise | |
*/ | |
- "delete": function (key) { | |
- if (this.size === 0) { | |
- return false; | |
- } | |
+ "delete": function(key) { | |
+ if (this.size === 0) { return false; } | |
// don't use ES6 "delete" because it will be annoying | |
// to use in browsers that are not ES6 friendly; | |
var keys = this._keys; | |
@@ -13540,11 +13563,12 @@ | |
/** | |
Check whether a key is present. | |
- @method has | |
+ | |
+ @method has | |
@param {*} key | |
@return {Boolean} true if the item was present, false otherwise | |
*/ | |
- has: function (key) { | |
+ has: function(key) { | |
return this._keys.has(key); | |
}, | |
@@ -13552,20 +13576,20 @@ | |
Iterate over all the keys and values. Calls the function once | |
for each key, passing in value, key, and the map being iterated over, | |
in that order. | |
- The keys are guaranteed to be iterated over in insertion order. | |
- @method forEach | |
+ | |
+ The keys are guaranteed to be iterated over in insertion order. | |
+ | |
+ @method forEach | |
@param {Function} callback | |
@param {*} self if passed, the `this` value inside the | |
callback. By default, `this` is the map. | |
*/ | |
- forEach: function (callback /*, thisArg*/) { | |
- if (typeof callback !== "function") { | |
+ forEach: function(callback /*, thisArg*/) { | |
+ if (typeof callback !== 'function') { | |
missingFunction(callback); | |
} | |
- if (this.size === 0) { | |
- return; | |
- } | |
+ if (this.size === 0) { return; } | |
var length = arguments.length; | |
var map = this; | |
@@ -13573,11 +13597,11 @@ | |
if (length === 2) { | |
thisArg = arguments[1]; | |
- cb = function (key) { | |
+ cb = function(key) { | |
callback.call(thisArg, map.get(key), key, map); | |
}; | |
} else { | |
- cb = function (key) { | |
+ cb = function(key) { | |
callback(map.get(key), key, map); | |
}; | |
} | |
@@ -13588,7 +13612,7 @@ | |
/** | |
@method clear | |
*/ | |
- clear: function () { | |
+ clear: function() { | |
this._keys.clear(); | |
this._values = create['default'](null); | |
this.size = 0; | |
@@ -13598,12 +13622,12 @@ | |
@method copy | |
@return {Ember.Map} | |
*/ | |
- copy: function () { | |
+ copy: function() { | |
return copyMap(this, new Map()); | |
} | |
}; | |
- deprecate_property.deprecateProperty(Map.prototype, "length", "size"); | |
+ deprecate_property.deprecateProperty(Map.prototype, 'length', 'size'); | |
/** | |
@class MapWithDefault | |
@@ -13627,7 +13651,7 @@ | |
@return {Ember.MapWithDefault|Ember.Map} If options are passed, returns | |
`Ember.MapWithDefault` otherwise returns `Ember.Map` | |
*/ | |
- MapWithDefault.create = function (options) { | |
+ MapWithDefault.create = function(options) { | |
if (options) { | |
return new MapWithDefault(options); | |
} else { | |
@@ -13647,7 +13671,7 @@ | |
@param {*} key | |
@return {*} the value associated with the key, or the default value | |
*/ | |
- MapWithDefault.prototype.get = function (key) { | |
+ MapWithDefault.prototype.get = function(key) { | |
var hasValue = this.has(key); | |
if (hasValue) { | |
@@ -13663,7 +13687,7 @@ | |
@method copy | |
@return {Ember.MapWithDefault} | |
*/ | |
- MapWithDefault.prototype.copy = function () { | |
+ MapWithDefault.prototype.copy = function() { | |
var Constructor = this.constructor; | |
return copyMap(this, new Constructor({ | |
defaultValue: this.defaultValue | |
@@ -13677,27 +13701,8 @@ | |
'use strict'; | |
- | |
- | |
- /** | |
- Merge the contents of two objects together into the first object. | |
- | |
- ```javascript | |
- Ember.merge({first: 'Tom'}, {last: 'Dale'}); // {first: 'Tom', last: 'Dale'} | |
- var a = {first: 'Yehuda'}; | |
- var b = {last: 'Katz'}; | |
- Ember.merge(a, b); // a == {first: 'Yehuda', last: 'Katz'}, b == {last: 'Katz'} | |
- ``` | |
- | |
- @method merge | |
- @for Ember | |
- @param {Object} original The object to merge into | |
- @param {Object} updates The object to copy properties from | |
- @return {Object} | |
- */ | |
- exports['default'] = merge; | |
function merge(original, updates) { | |
- if (!updates || typeof updates !== "object") { | |
+ if (!updates || typeof updates !== 'object') { | |
return original; | |
} | |
@@ -13712,6 +13717,7 @@ | |
return original; | |
} | |
+ exports['default'] = merge; | |
}); | |
enifed('ember-metal/mixin', ['exports', 'ember-metal/core', 'ember-metal/merge', 'ember-metal/array', 'ember-metal/platform/create', 'ember-metal/property_get', 'ember-metal/property_set', 'ember-metal/utils', 'ember-metal/expand_properties', 'ember-metal/properties', 'ember-metal/computed', 'ember-metal/binding', 'ember-metal/observer', 'ember-metal/events', 'ember-metal/streams/utils'], function (exports, Ember, merge, array, o_create, property_get, property_set, utils, expandProperties, properties, computed, ember_metal__binding, ember_metal__observer, events, streams__utils) { | |
@@ -13731,12 +13737,10 @@ | |
"REMOVE_USE_STRICT: true"; | |
/** | |
- @method mixin | |
- @for Ember | |
- @param obj | |
- @param mixins* | |
- @return obj | |
+ @module ember | |
+ @submodule ember-metal | |
*/ | |
+ | |
var REQUIRED; | |
var a_slice = [].slice; | |
@@ -13764,7 +13768,7 @@ | |
// ensure we prime superFunction to mitigate | |
// v8 bug potentially incorrectly deopts this function: https://code.google.com/p/v8/issues/detail?id=3709 | |
var primer = { | |
- __nextSuper: function (a, b, c, d) {} | |
+ __nextSuper: function(a, b, c, d ) { } | |
}; | |
superFunction.call(primer); | |
@@ -13777,14 +13781,21 @@ | |
var ret = m.mixins; | |
if (!ret) { | |
ret = m.mixins = {}; | |
- } else if (!m.hasOwnProperty("mixins")) { | |
+ } else if (!m.hasOwnProperty('mixins')) { | |
ret = m.mixins = o_create['default'](ret); | |
} | |
return ret; | |
} | |
function isMethod(obj) { | |
- return "function" === typeof obj && obj.isMethod !== false && obj !== Boolean && obj !== Object && obj !== Number && obj !== Array && obj !== Date && obj !== String; | |
+ return 'function' === typeof obj && | |
+ obj.isMethod !== false && | |
+ obj !== Boolean && | |
+ obj !== Object && | |
+ obj !== Number && | |
+ obj !== Array && | |
+ obj !== Date && | |
+ obj !== String; | |
} | |
var CONTINUE = {}; | |
@@ -13794,9 +13805,7 @@ | |
if (mixin instanceof Mixin) { | |
guid = utils.guidFor(mixin); | |
- if (mixinsMeta[guid]) { | |
- return CONTINUE; | |
- } | |
+ if (mixinsMeta[guid]) { return CONTINUE; } | |
mixinsMeta[guid] = mixin; | |
return mixin.properties; | |
} else { | |
@@ -13829,7 +13838,7 @@ | |
// it on the original object. | |
if (!superProperty) { | |
var possibleDesc = base[key]; | |
- var superDesc = possibleDesc !== null && typeof possibleDesc === "object" && possibleDesc.isDescriptor ? possibleDesc : undefined; | |
+ var superDesc = (possibleDesc !== null && typeof possibleDesc === 'object' && possibleDesc.isDescriptor) ? possibleDesc : undefined; | |
superProperty = superDesc; | |
} | |
@@ -13854,9 +13863,9 @@ | |
return property; | |
} | |
- var sourceAvailable = (function () { | |
+ var sourceAvailable = (function() { | |
return this; | |
- }).toString().indexOf("return this;") > -1; | |
+ }).toString().indexOf('return this;') > -1; | |
function giveMethodSuper(obj, key, method, values, descs) { | |
var superMethod; | |
@@ -13872,7 +13881,7 @@ | |
superMethod = superMethod || obj[key]; | |
// Only wrap the new method if the original method was a function | |
- if (superMethod === undefined || "function" !== typeof superMethod) { | |
+ if (superMethod === undefined || 'function' !== typeof superMethod) { | |
return method; | |
} | |
@@ -13881,7 +13890,7 @@ | |
hasSuper = method.__hasSuper; | |
if (hasSuper === undefined) { | |
- hasSuper = method.toString().indexOf("_super") > -1; | |
+ hasSuper = method.toString().indexOf('_super') > -1; | |
method.__hasSuper = hasSuper; | |
} | |
} | |
@@ -13897,7 +13906,7 @@ | |
var baseValue = values[key] || obj[key]; | |
if (baseValue) { | |
- if ("function" === typeof baseValue.concat) { | |
+ if ('function' === typeof baseValue.concat) { | |
if (value === null || value === undefined) { | |
return baseValue; | |
} else { | |
@@ -13914,19 +13923,16 @@ | |
function applyMergedProperties(obj, key, value, values) { | |
var baseValue = values[key] || obj[key]; | |
- Ember['default'].assert("You passed in `" + JSON.stringify(value) + "` as the value for `" + key + "` but `" + key + "` cannot be an Array", !utils.isArray(value)); | |
+ Ember['default'].assert("You passed in `" + JSON.stringify(value) + "` as the value for `" + key + | |
+ "` but `" + key + "` cannot be an Array", !utils.isArray(value)); | |
- if (!baseValue) { | |
- return value; | |
- } | |
+ if (!baseValue) { return value; } | |
var newBase = merge['default']({}, baseValue); | |
var hasFunction = false; | |
for (var prop in value) { | |
- if (!value.hasOwnProperty(prop)) { | |
- continue; | |
- } | |
+ if (!value.hasOwnProperty(prop)) { continue; } | |
var propValue = value[prop]; | |
if (isMethod(propValue)) { | |
@@ -13947,9 +13953,7 @@ | |
function addNormalizedProperty(base, key, value, meta, descs, values, concats, mergings) { | |
if (value instanceof properties.Descriptor) { | |
- if (value === REQUIRED && descs[key]) { | |
- return CONTINUE; | |
- } | |
+ if (value === REQUIRED && descs[key]) { return CONTINUE; } | |
// Wrap descriptor function to implement | |
// __nextSuper() if needed | |
@@ -13957,12 +13961,14 @@ | |
value = giveDescriptorSuper(meta, key, value, values, descs, base); | |
} | |
- descs[key] = value; | |
+ descs[key] = value; | |
values[key] = undefined; | |
} else { | |
- if (concats && array.indexOf.call(concats, key) >= 0 || key === "concatenatedProperties" || key === "mergedProperties") { | |
+ if ((concats && array.indexOf.call(concats, key) >= 0) || | |
+ key === 'concatenatedProperties' || | |
+ key === 'mergedProperties') { | |
value = applyConcatenatedProperties(base, key, value, values); | |
- } else if (mergings && array.indexOf.call(mergings, key) >= 0) { | |
+ } else if ((mergings && array.indexOf.call(mergings, key) >= 0)) { | |
value = applyMergedProperties(base, key, value, values); | |
} else if (isMethod(value)) { | |
value = giveMethodSuper(base, key, value, values, descs); | |
@@ -13981,40 +13987,31 @@ | |
delete values[keyName]; | |
} | |
- for (var i = 0, l = mixins.length; i < l; i++) { | |
+ for (var i=0, l=mixins.length; i<l; i++) { | |
currentMixin = mixins[i]; | |
- Ember['default'].assert("Expected hash or Mixin instance, got " + Object.prototype.toString.call(currentMixin), typeof currentMixin === "object" && currentMixin !== null && Object.prototype.toString.call(currentMixin) !== "[object Array]"); | |
+ Ember['default'].assert('Expected hash or Mixin instance, got ' + Object.prototype.toString.call(currentMixin), | |
+ typeof currentMixin === 'object' && currentMixin !== null && Object.prototype.toString.call(currentMixin) !== '[object Array]'); | |
props = mixinProperties(m, currentMixin); | |
- if (props === CONTINUE) { | |
- continue; | |
- } | |
+ if (props === CONTINUE) { continue; } | |
if (props) { | |
meta = utils.meta(base); | |
- if (base.willMergeMixin) { | |
- base.willMergeMixin(props); | |
- } | |
- concats = concatenatedMixinProperties("concatenatedProperties", props, values, base); | |
- mergings = concatenatedMixinProperties("mergedProperties", props, values, base); | |
+ if (base.willMergeMixin) { base.willMergeMixin(props); } | |
+ concats = concatenatedMixinProperties('concatenatedProperties', props, values, base); | |
+ mergings = concatenatedMixinProperties('mergedProperties', props, values, base); | |
for (key in props) { | |
- if (!props.hasOwnProperty(key)) { | |
- continue; | |
- } | |
+ if (!props.hasOwnProperty(key)) { continue; } | |
keys.push(key); | |
addNormalizedProperty(base, key, props[key], meta, descs, values, concats, mergings); | |
} | |
// manually copy toString() because some JS engines do not enumerate it | |
- if (props.hasOwnProperty("toString")) { | |
- base.toString = props.toString; | |
- } | |
+ if (props.hasOwnProperty('toString')) { base.toString = props.toString; } | |
} else if (currentMixin.mixins) { | |
mergeMixins(currentMixin.mixins, m, descs, values, base, keys); | |
- if (currentMixin._without) { | |
- array.forEach.call(currentMixin._without, removeKeys); | |
- } | |
+ if (currentMixin._without) { array.forEach.call(currentMixin._without, removeKeys); } | |
} | |
} | |
} | |
@@ -14026,7 +14023,7 @@ | |
var bindings = m.bindings; | |
if (!bindings) { | |
bindings = m.bindings = {}; | |
- } else if (!m.hasOwnProperty("bindings")) { | |
+ } else if (!m.hasOwnProperty('bindings')) { | |
bindings = m.bindings = o_create['default'](m.bindings); | |
} | |
bindings[key] = value; | |
@@ -14034,13 +14031,13 @@ | |
} | |
function connectStreamBinding(obj, key, stream) { | |
- var onNotify = function (stream) { | |
- ember_metal__observer._suspendObserver(obj, key, null, didChange, function () { | |
+ var onNotify = function(stream) { | |
+ ember_metal__observer._suspendObserver(obj, key, null, didChange, function() { | |
property_set.trySet(obj, key, stream.value()); | |
}); | |
}; | |
- var didChange = function () { | |
+ var didChange = function() { | |
stream.setValue(property_get.get(obj, key), onNotify); | |
}; | |
@@ -14073,8 +14070,7 @@ | |
} else if (binding instanceof ember_metal__binding.Binding) { | |
binding = binding.copy(); // copy prototypes' instance | |
binding.to(to); | |
- } else { | |
- // binding is string path | |
+ } else { // binding is string path | |
binding = new ember_metal__binding.Binding(to, binding); | |
} | |
binding.connect(obj); | |
@@ -14097,9 +14093,9 @@ | |
var possibleDesc; | |
if (descs[altKey] || values[altKey]) { | |
value = values[altKey]; | |
- desc = descs[altKey]; | |
- } else if ((possibleDesc = obj[altKey]) && possibleDesc !== null && typeof possibleDesc === "object" && possibleDesc.isDescriptor) { | |
- desc = possibleDesc; | |
+ desc = descs[altKey]; | |
+ } else if ((possibleDesc = obj[altKey]) && possibleDesc !== null && typeof possibleDesc === 'object' && possibleDesc.isDescriptor) { | |
+ desc = possibleDesc; | |
value = undefined; | |
} else { | |
desc = undefined; | |
@@ -14113,7 +14109,7 @@ | |
var paths = observerOrListener[pathsKey]; | |
if (paths) { | |
- for (var i = 0, l = paths.length; i < l; i++) { | |
+ for (var i=0, l=paths.length; i<l; i++) { | |
updateMethod(obj, paths[i], null, key); | |
} | |
} | |
@@ -14122,16 +14118,16 @@ | |
function replaceObserversAndListeners(obj, key, observerOrListener) { | |
var prev = obj[key]; | |
- if ("function" === typeof prev) { | |
- updateObserversAndListeners(obj, key, prev, "__ember_observesBefore__", ember_metal__observer.removeBeforeObserver); | |
- updateObserversAndListeners(obj, key, prev, "__ember_observes__", ember_metal__observer.removeObserver); | |
- updateObserversAndListeners(obj, key, prev, "__ember_listens__", events.removeListener); | |
+ if ('function' === typeof prev) { | |
+ updateObserversAndListeners(obj, key, prev, '__ember_observesBefore__', ember_metal__observer.removeBeforeObserver); | |
+ updateObserversAndListeners(obj, key, prev, '__ember_observes__', ember_metal__observer.removeObserver); | |
+ updateObserversAndListeners(obj, key, prev, '__ember_listens__', events.removeListener); | |
} | |
- if ("function" === typeof observerOrListener) { | |
- updateObserversAndListeners(obj, key, observerOrListener, "__ember_observesBefore__", ember_metal__observer.addBeforeObserver); | |
- updateObserversAndListeners(obj, key, observerOrListener, "__ember_observes__", ember_metal__observer.addObserver); | |
- updateObserversAndListeners(obj, key, observerOrListener, "__ember_listens__", events.addListener); | |
+ if ('function' === typeof observerOrListener) { | |
+ updateObserversAndListeners(obj, key, observerOrListener, '__ember_observesBefore__', ember_metal__observer.addBeforeObserver); | |
+ updateObserversAndListeners(obj, key, observerOrListener, '__ember_observes__', ember_metal__observer.addObserver); | |
+ updateObserversAndListeners(obj, key, observerOrListener, '__ember_listens__', events.addListener); | |
} | |
} | |
@@ -14155,16 +14151,12 @@ | |
for (var i = 0, l = keys.length; i < l; i++) { | |
key = keys[i]; | |
- if (key === "constructor" || !values.hasOwnProperty(key)) { | |
- continue; | |
- } | |
+ if (key === 'constructor' || !values.hasOwnProperty(key)) { continue; } | |
desc = descs[key]; | |
value = values[key]; | |
- if (desc === REQUIRED) { | |
- continue; | |
- } | |
+ if (desc === REQUIRED) { continue; } | |
while (desc && desc instanceof Alias) { | |
var followed = followAlias(obj, desc, m, descs, values); | |
@@ -14172,22 +14164,27 @@ | |
value = followed.value; | |
} | |
- if (desc === undefined && value === undefined) { | |
- continue; | |
- } | |
+ if (desc === undefined && value === undefined) { continue; } | |
replaceObserversAndListeners(obj, key, value); | |
detectBinding(obj, key, value, m); | |
properties.defineProperty(obj, key, desc, value, m); | |
} | |
- if (!partial) { | |
- // don't apply to prototype | |
+ if (!partial) { // don't apply to prototype | |
finishPartial(obj, m); | |
} | |
return obj; | |
} | |
+ | |
+ /** | |
+ @method mixin | |
+ @for Ember | |
+ @param obj | |
+ @param mixins* | |
+ @return obj | |
+ */ | |
function mixin(obj) { | |
var args = a_slice.call(arguments, 1); | |
applyMixin(obj, args, false); | |
@@ -14275,7 +14272,7 @@ | |
Mixin._apply = applyMixin; | |
- Mixin.applyPartial = function (obj) { | |
+ Mixin.applyPartial = function(obj) { | |
var args = a_slice.call(arguments, 1); | |
return applyMixin(obj, args, true); | |
}; | |
@@ -14290,7 +14287,7 @@ | |
@static | |
@param arguments* | |
*/ | |
- Mixin.create = function () { | |
+ Mixin.create = function() { | |
// ES6TODO: this relies on a global state? | |
Ember['default'].anyUnprocessedMixins = true; | |
var M = this; | |
@@ -14308,7 +14305,7 @@ | |
@method reopen | |
@param arguments* | |
*/ | |
- MixinPrototype.reopen = function () { | |
+ MixinPrototype.reopen = function() { | |
var currentMixin; | |
if (this.properties) { | |
@@ -14323,9 +14320,11 @@ | |
var mixins = this.mixins; | |
var idx; | |
- for (idx = 0; idx < len; idx++) { | |
+ for (idx=0; idx < len; idx++) { | |
currentMixin = arguments[idx]; | |
- Ember['default'].assert("Expected hash or Mixin instance, got " + Object.prototype.toString.call(currentMixin), typeof currentMixin === "object" && currentMixin !== null && Object.prototype.toString.call(currentMixin) !== "[object Array]"); | |
+ Ember['default'].assert('Expected hash or Mixin instance, got ' + Object.prototype.toString.call(currentMixin), | |
+ typeof currentMixin === 'object' && currentMixin !== null && | |
+ Object.prototype.toString.call(currentMixin) !== '[object Array]'); | |
if (currentMixin instanceof Mixin) { | |
mixins.push(currentMixin); | |
@@ -14342,31 +14341,25 @@ | |
@param obj | |
@return applied object | |
*/ | |
- MixinPrototype.apply = function (obj) { | |
+ MixinPrototype.apply = function(obj) { | |
return applyMixin(obj, [this], false); | |
}; | |
- MixinPrototype.applyPartial = function (obj) { | |
+ MixinPrototype.applyPartial = function(obj) { | |
return applyMixin(obj, [this], true); | |
}; | |
function _detect(curMixin, targetMixin, seen) { | |
var guid = utils.guidFor(curMixin); | |
- if (seen[guid]) { | |
- return false; | |
- } | |
+ if (seen[guid]) { return false; } | |
seen[guid] = true; | |
- if (curMixin === targetMixin) { | |
- return true; | |
- } | |
+ if (curMixin === targetMixin) { return true; } | |
var mixins = curMixin.mixins; | |
var loc = mixins ? mixins.length : 0; | |
while (--loc >= 0) { | |
- if (_detect(mixins[loc], targetMixin, seen)) { | |
- return true; | |
- } | |
+ if (_detect(mixins[loc], targetMixin, seen)) { return true; } | |
} | |
return false; | |
} | |
@@ -14376,14 +14369,10 @@ | |
@param obj | |
@return {Boolean} | |
*/ | |
- MixinPrototype.detect = function (obj) { | |
- if (!obj) { | |
- return false; | |
- } | |
- if (obj instanceof Mixin) { | |
- return _detect(obj, this, {}); | |
- } | |
- var m = obj["__ember_meta__"]; | |
+ MixinPrototype.detect = function(obj) { | |
+ if (!obj) { return false; } | |
+ if (obj instanceof Mixin) { return _detect(obj, this, {}); } | |
+ var m = obj['__ember_meta__']; | |
var mixins = m && m.mixins; | |
if (mixins) { | |
return !!mixins[utils.guidFor(this)]; | |
@@ -14391,33 +14380,27 @@ | |
return false; | |
}; | |
- MixinPrototype.without = function () { | |
+ MixinPrototype.without = function() { | |
var ret = new Mixin([this]); | |
ret._without = a_slice.call(arguments); | |
return ret; | |
}; | |
function _keys(ret, mixin, seen) { | |
- if (seen[utils.guidFor(mixin)]) { | |
- return; | |
- } | |
+ if (seen[utils.guidFor(mixin)]) { return; } | |
seen[utils.guidFor(mixin)] = true; | |
if (mixin.properties) { | |
var props = mixin.properties; | |
for (var key in props) { | |
- if (props.hasOwnProperty(key)) { | |
- ret[key] = true; | |
- } | |
+ if (props.hasOwnProperty(key)) { ret[key] = true; } | |
} | |
} else if (mixin.mixins) { | |
- array.forEach.call(mixin.mixins, function (x) { | |
- _keys(ret, x, seen); | |
- }); | |
+ array.forEach.call(mixin.mixins, function(x) { _keys(ret, x, seen); }); | |
} | |
} | |
- MixinPrototype.keys = function () { | |
+ MixinPrototype.keys = function() { | |
var keys = {}; | |
var seen = {}; | |
var ret = []; | |
@@ -14432,31 +14415,32 @@ | |
// returns the mixins currently applied to the specified object | |
// TODO: Make Ember.mixin | |
- Mixin.mixins = function (obj) { | |
- var m = obj["__ember_meta__"]; | |
+ Mixin.mixins = function(obj) { | |
+ var m = obj['__ember_meta__']; | |
var mixins = m && m.mixins; | |
var ret = []; | |
- if (!mixins) { | |
- return ret; | |
- } | |
+ if (!mixins) { return ret; } | |
for (var key in mixins) { | |
var currentMixin = mixins[key]; | |
// skip primitive mixins since these are always anonymous | |
- if (!currentMixin.properties) { | |
- ret.push(currentMixin); | |
- } | |
+ if (!currentMixin.properties) { ret.push(currentMixin); } | |
} | |
return ret; | |
}; | |
REQUIRED = new properties.Descriptor(); | |
- REQUIRED.toString = function () { | |
- return "(Required Property)"; | |
- }; | |
+ REQUIRED.toString = function() { return '(Required Property)'; }; | |
+ | |
+ /** | |
+ Denotes a required property for a mixin | |
+ | |
+ @method required | |
+ @for Ember | |
+ */ | |
function required() { | |
return REQUIRED; | |
} | |
@@ -14467,29 +14451,77 @@ | |
} | |
Alias.prototype = new properties.Descriptor(); | |
+ | |
+ /** | |
+ Makes a method available via an additional name. | |
+ | |
+ ```javascript | |
+ App.Person = Ember.Object.extend({ | |
+ name: function() { | |
+ return 'Tomhuda Katzdale'; | |
+ }, | |
+ moniker: Ember.aliasMethod('name') | |
+ }); | |
+ | |
+ var goodGuy = App.Person.create(); | |
+ | |
+ goodGuy.name(); // 'Tomhuda Katzdale' | |
+ goodGuy.moniker(); // 'Tomhuda Katzdale' | |
+ ``` | |
+ | |
+ @method aliasMethod | |
+ @for Ember | |
+ @param {String} methodName name of the method to alias | |
+ @return {Ember.Descriptor} | |
+ */ | |
function aliasMethod(methodName) { | |
return new Alias(methodName); | |
} | |
+ // .......................................................... | |
+ // OBSERVER HELPER | |
+ // | |
+ | |
+ /** | |
+ Specify a method that observes property changes. | |
+ | |
+ ```javascript | |
+ Ember.Object.extend({ | |
+ valueObserver: Ember.observer('value', function() { | |
+ // Executes whenever the "value" property changes | |
+ }) | |
+ }); | |
+ ``` | |
+ | |
+ In the future this method may become asynchronous. If you want to ensure | |
+ synchronous behavior, use `immediateObserver`. | |
+ | |
+ Also available as `Function.prototype.observes` if prototype extensions are | |
+ enabled. | |
+ | |
+ @method observer | |
+ @for Ember | |
+ @param {String} propertyNames* | |
+ @param {Function} func | |
+ @return func | |
+ */ | |
function observer() { | |
- var func = a_slice.call(arguments, -1)[0]; | |
+ var func = a_slice.call(arguments, -1)[0]; | |
var paths; | |
- var addWatchedProperty = function (path) { | |
- paths.push(path); | |
- }; | |
+ var addWatchedProperty = function (path) { paths.push(path); }; | |
var _paths = a_slice.call(arguments, 0, -1); | |
if (typeof func !== "function") { | |
// revert to old, soft-deprecated argument ordering | |
- func = arguments[0]; | |
+ func = arguments[0]; | |
_paths = a_slice.call(arguments, 1); | |
} | |
paths = []; | |
- for (var i = 0; i < _paths.length; ++i) { | |
+ for (var i=0; i<_paths.length; ++i) { | |
expandProperties['default'](_paths[i], addWatchedProperty); | |
} | |
@@ -14501,35 +14533,99 @@ | |
return func; | |
} | |
+ /** | |
+ Specify a method that observes property changes. | |
+ | |
+ ```javascript | |
+ Ember.Object.extend({ | |
+ valueObserver: Ember.immediateObserver('value', function() { | |
+ // Executes whenever the "value" property changes | |
+ }) | |
+ }); | |
+ ``` | |
+ | |
+ In the future, `Ember.observer` may become asynchronous. In this event, | |
+ `Ember.immediateObserver` will maintain the synchronous behavior. | |
+ | |
+ Also available as `Function.prototype.observesImmediately` if prototype extensions are | |
+ enabled. | |
+ | |
+ @method immediateObserver | |
+ @for Ember | |
+ @param {String} propertyNames* | |
+ @param {Function} func | |
+ @return func | |
+ */ | |
function immediateObserver() { | |
- for (var i = 0, l = arguments.length; i < l; i++) { | |
+ for (var i=0, l=arguments.length; i<l; i++) { | |
var arg = arguments[i]; | |
- Ember['default'].assert("Immediate observers must observe internal properties only, not properties on other objects.", typeof arg !== "string" || arg.indexOf(".") === -1); | |
+ Ember['default'].assert("Immediate observers must observe internal properties only, not properties on other objects.", | |
+ typeof arg !== "string" || arg.indexOf('.') === -1); | |
} | |
return observer.apply(this, arguments); | |
} | |
+ /** | |
+ When observers fire, they are called with the arguments `obj`, `keyName`. | |
+ | |
+ Note, `@each.property` observer is called per each add or replace of an element | |
+ and it's not called with a specific enumeration item. | |
+ | |
+ A `beforeObserver` fires before a property changes. | |
+ | |
+ A `beforeObserver` is an alternative form of `.observesBefore()`. | |
+ | |
+ ```javascript | |
+ App.PersonView = Ember.View.extend({ | |
+ friends: [{ name: 'Tom' }, { name: 'Stefan' }, { name: 'Kris' }], | |
+ | |
+ valueWillChange: Ember.beforeObserver('content.value', function(obj, keyName) { | |
+ this.changingFrom = obj.get(keyName); | |
+ }), | |
+ | |
+ valueDidChange: Ember.observer('content.value', function(obj, keyName) { | |
+ // only run if updating a value already in the DOM | |
+ if (this.get('state') === 'inDOM') { | |
+ var color = obj.get(keyName) > this.changingFrom ? 'green' : 'red'; | |
+ // logic | |
+ } | |
+ }), | |
+ | |
+ friendsDidChange: Ember.observer('[email protected]', function(obj, keyName) { | |
+ // some logic | |
+ // obj.get(keyName) returns friends array | |
+ }) | |
+ }); | |
+ ``` | |
+ | |
+ Also available as `Function.prototype.observesBefore` if prototype extensions are | |
+ enabled. | |
+ | |
+ @method beforeObserver | |
+ @for Ember | |
+ @param {String} propertyNames* | |
+ @param {Function} func | |
+ @return func | |
+ */ | |
function beforeObserver() { | |
- var func = a_slice.call(arguments, -1)[0]; | |
+ var func = a_slice.call(arguments, -1)[0]; | |
var paths; | |
- var addWatchedProperty = function (path) { | |
- paths.push(path); | |
- }; | |
+ var addWatchedProperty = function(path) { paths.push(path); }; | |
var _paths = a_slice.call(arguments, 0, -1); | |
if (typeof func !== "function") { | |
// revert to old, soft-deprecated argument ordering | |
- func = arguments[0]; | |
+ func = arguments[0]; | |
_paths = a_slice.call(arguments, 1); | |
} | |
paths = []; | |
- for (var i = 0; i < _paths.length; ++i) { | |
+ for (var i=0; i<_paths.length; ++i) { | |
expandProperties['default'](_paths[i], addWatchedProperty); | |
} | |
@@ -14559,6 +14655,17 @@ | |
exports.beforeObserversFor = beforeObserversFor; | |
exports.removeBeforeObserver = removeBeforeObserver; | |
+ var AFTER_OBSERVERS = ':change'; | |
+ var BEFORE_OBSERVERS = ':before'; | |
+ | |
+ function changeEvent(keyName) { | |
+ return keyName + AFTER_OBSERVERS; | |
+ } | |
+ | |
+ function beforeEvent(keyName) { | |
+ return keyName + BEFORE_OBSERVERS; | |
+ } | |
+ | |
/** | |
@method addObserver | |
@for Ember | |
@@ -14567,16 +14674,6 @@ | |
@param {Object|Function} targetOrMethod | |
@param {Function|String} [method] | |
*/ | |
- var AFTER_OBSERVERS = ":change"; | |
- var BEFORE_OBSERVERS = ":before"; | |
- | |
- function changeEvent(keyName) { | |
- return keyName + AFTER_OBSERVERS; | |
- } | |
- | |
- function beforeEvent(keyName) { | |
- return keyName + BEFORE_OBSERVERS; | |
- } | |
function addObserver(obj, _path, target, method) { | |
ember_metal__events.addListener(obj, changeEvent(_path), target, method); | |
watching.watch(obj, _path); | |
@@ -14588,6 +14685,14 @@ | |
return ember_metal__events.listenersFor(obj, changeEvent(path)); | |
} | |
+ /** | |
+ @method removeObserver | |
+ @for Ember | |
+ @param obj | |
+ @param {String} path | |
+ @param {Object|Function} target | |
+ @param {Function|String} [method] | |
+ */ | |
function removeObserver(obj, path, target, method) { | |
watching.unwatch(obj, path); | |
ember_metal__events.removeListener(obj, changeEvent(path), target, method); | |
@@ -14595,6 +14700,14 @@ | |
return this; | |
} | |
+ /** | |
+ @method addBeforeObserver | |
+ @for Ember | |
+ @param obj | |
+ @param {String} path | |
+ @param {Object|Function} target | |
+ @param {Function|String} [method] | |
+ */ | |
function addBeforeObserver(obj, path, target, method) { | |
ember_metal__events.addListener(obj, beforeEvent(path), target, method); | |
watching.watch(obj, path); | |
@@ -14602,6 +14715,10 @@ | |
return this; | |
} | |
+ // Suspend observer during callback. | |
+ // | |
+ // This should only be used by the target of the observer | |
+ // while it is setting the observed path. | |
function _suspendBeforeObserver(obj, path, target, method, callback) { | |
return ember_metal__events.suspendListener(obj, beforeEvent(path), target, method, callback); | |
} | |
@@ -14624,6 +14741,14 @@ | |
return ember_metal__events.listenersFor(obj, beforeEvent(path)); | |
} | |
+ /** | |
+ @method removeBeforeObserver | |
+ @for Ember | |
+ @param obj | |
+ @param {String} path | |
+ @param {Object|Function} target | |
+ @param {Function|String} [method] | |
+ */ | |
function removeBeforeObserver(obj, path, target, method) { | |
watching.unwatch(obj, path); | |
ember_metal__events.removeListener(obj, beforeEvent(path), target, method); | |
@@ -14641,7 +14766,8 @@ | |
this.clear(); | |
} | |
- ObserverSet.prototype.add = function (sender, keyName, eventName) { | |
+ | |
+ ObserverSet.prototype.add = function(sender, keyName, eventName) { | |
var observerSet = this.observerSet; | |
var observers = this.observers; | |
var senderGuid = utils.guidFor(sender); | |
@@ -14664,21 +14790,19 @@ | |
return observers[index].listeners; | |
}; | |
- ObserverSet.prototype.flush = function () { | |
+ ObserverSet.prototype.flush = function() { | |
var observers = this.observers; | |
var i, len, observer, sender; | |
this.clear(); | |
- for (i = 0, len = observers.length; i < len; ++i) { | |
+ for (i=0, len=observers.length; i < len; ++i) { | |
observer = observers[i]; | |
sender = observer.sender; | |
- if (sender.isDestroying || sender.isDestroyed) { | |
- continue; | |
- } | |
+ if (sender.isDestroying || sender.isDestroyed) { continue; } | |
events.sendEvent(sender, observer.eventName, [sender, observer.keyName], observer.listeners); | |
} | |
}; | |
- ObserverSet.prototype.clear = function () { | |
+ ObserverSet.prototype.clear = function() { | |
this.observerSet = {}; | |
this.observers = []; | |
}; | |
@@ -14695,24 +14819,16 @@ | |
exports.getFirstKey = getFirstKey; | |
exports.getTailPath = getTailPath; | |
- var IS_GLOBAL = /^([A-Z$]|([0-9][A-Z$]))/; | |
+ var IS_GLOBAL = /^([A-Z$]|([0-9][A-Z$]))/; | |
var IS_GLOBAL_PATH = /^([A-Z$]|([0-9][A-Z$])).*[\.]/; | |
- var HAS_THIS = "this."; | |
+ var HAS_THIS = 'this.'; | |
- var isGlobalCache = new Cache['default'](1000, function (key) { | |
- return IS_GLOBAL.test(key); | |
- }); | |
- var isGlobalPathCache = new Cache['default'](1000, function (key) { | |
- return IS_GLOBAL_PATH.test(key); | |
- }); | |
- var hasThisCache = new Cache['default'](1000, function (key) { | |
- return key.lastIndexOf(HAS_THIS, 0) === 0; | |
- }); | |
- var firstDotIndexCache = new Cache['default'](1000, function (key) { | |
- return key.indexOf("."); | |
- }); | |
+ var isGlobalCache = new Cache['default'](1000, function(key) { return IS_GLOBAL.test(key); }); | |
+ var isGlobalPathCache = new Cache['default'](1000, function(key) { return IS_GLOBAL_PATH.test(key); }); | |
+ var hasThisCache = new Cache['default'](1000, function(key) { return key.lastIndexOf(HAS_THIS, 0) === 0; }); | |
+ var firstDotIndexCache = new Cache['default'](1000, function(key) { return key.indexOf('.'); }); | |
- var firstKeyCache = new Cache['default'](1000, function (path) { | |
+ var firstKeyCache = new Cache['default'](1000, function(path) { | |
var index = firstDotIndexCache.get(path); | |
if (index === -1) { | |
return path; | |
@@ -14721,7 +14837,7 @@ | |
} | |
}); | |
- var tailPathCache = new Cache['default'](1000, function (path) { | |
+ var tailPathCache = new Cache['default'](1000, function(path) { | |
var index = firstDotIndexCache.get(path); | |
if (index !== -1) { | |
return path.slice(index + 1); | |
@@ -14729,13 +14845,15 @@ | |
}); | |
var caches = { | |
- isGlobalCache: isGlobalCache, | |
- isGlobalPathCache: isGlobalPathCache, | |
- hasThisCache: hasThisCache, | |
+ isGlobalCache: isGlobalCache, | |
+ isGlobalPathCache: isGlobalPathCache, | |
+ hasThisCache: hasThisCache, | |
firstDotIndexCache: firstDotIndexCache, | |
- firstKeyCache: firstKeyCache, | |
- tailPathCache: tailPathCache | |
- };function isGlobal(path) { | |
+ firstKeyCache: firstKeyCache, | |
+ tailPathCache: tailPathCache | |
+ }; | |
+ | |
+ function isGlobal(path) { | |
return isGlobalCache.get(path); | |
} | |
@@ -14777,11 +14895,11 @@ | |
/* jshint scripturl:true, proto:true */ | |
// Contributed by Brandon Benvie, October, 2012 | |
var createEmpty; | |
- var supportsProto = !({ "__proto__": null } instanceof Object); | |
+ var supportsProto = !({ '__proto__': null } instanceof Object); | |
// the following produces false positives | |
// in Opera Mini => not a reliable check | |
// Object.prototype.__proto__ === null | |
- if (supportsProto || typeof document === "undefined") { | |
+ if (supportsProto || typeof document === 'undefined') { | |
createEmpty = function () { | |
return { "__proto__": null }; | |
}; | |
@@ -14792,11 +14910,11 @@ | |
// object and *steal* its Object.prototype and strip it bare. This is | |
// used as the prototype to create nullary objects. | |
createEmpty = function () { | |
- var iframe = document.createElement("iframe"); | |
+ var iframe = document.createElement('iframe'); | |
var parent = document.body || document.documentElement; | |
- iframe.style.display = "none"; | |
+ iframe.style.display = 'none'; | |
parent.appendChild(iframe); | |
- iframe.src = "javascript:"; | |
+ iframe.src = 'javascript:'; | |
var empty = iframe.contentWindow.Object.prototype; | |
parent.removeChild(iframe); | |
iframe = null; | |
@@ -14821,7 +14939,7 @@ | |
create = Object.create = function create(prototype, properties) { | |
var object; | |
- function Type() {} // An empty constructor. | |
+ function Type() {} // An empty constructor. | |
if (prototype === null) { | |
object = createEmpty(); | |
@@ -14914,7 +15032,7 @@ | |
try { | |
var a = 5; | |
var obj = {}; | |
- defineProperty(obj, "a", { | |
+ defineProperty(obj, 'a', { | |
configurable: true, | |
enumerable: true, | |
get: function () { | |
@@ -14934,14 +15052,14 @@ | |
} | |
// check non-enumerability | |
- defineProperty(obj, "a", { | |
+ defineProperty(obj, 'a', { | |
configurable: true, | |
enumerable: false, | |
writable: true, | |
value: true | |
}); | |
for (var key in obj) { | |
- if (key === "a") { | |
+ if (key === 'a') { | |
return; | |
} | |
} | |
@@ -14954,7 +15072,7 @@ | |
// Detects a bug in Android <3 where redefining a property without a value changes the value | |
// Object.defineProperty once accessors have already been set. | |
- defineProperty(obj, "a", { | |
+ defineProperty(obj, 'a', { | |
enumerable: false | |
}); | |
if (obj.a !== true) { | |
@@ -14971,20 +15089,20 @@ | |
var hasES5CompliantDefineProperty = !!defineProperty; | |
- if (hasES5CompliantDefineProperty && typeof document !== "undefined") { | |
+ if (hasES5CompliantDefineProperty && typeof document !== 'undefined') { | |
// This is for Safari 5.0, which supports Object.defineProperty, but not | |
// on DOM nodes. | |
- var canDefinePropertyOnDOM = (function () { | |
+ var canDefinePropertyOnDOM = (function() { | |
try { | |
- defineProperty(document.createElement("div"), "definePropertyOnDOM", {}); | |
+ defineProperty(document.createElement('div'), 'definePropertyOnDOM', {}); | |
return true; | |
- } catch (e) {} | |
+ } catch(e) { } | |
return false; | |
})(); | |
if (!canDefinePropertyOnDOM) { | |
- defineProperty = function (obj, keyName, desc) { | |
+ defineProperty = function(obj, keyName, desc) { | |
var isNode; | |
if (typeof Node === "object") { | |
@@ -14995,7 +15113,7 @@ | |
if (isNode) { | |
// TODO: Should we have a warning here? | |
- return obj[keyName] = desc.value; | |
+ return (obj[keyName] = desc.value); | |
} else { | |
return Object.defineProperty(obj, keyName, desc); | |
} | |
@@ -15005,9 +15123,7 @@ | |
if (!hasES5CompliantDefineProperty) { | |
defineProperty = function definePropertyPolyfill(obj, keyName, desc) { | |
- if (!desc.get) { | |
- obj[keyName] = desc.value; | |
- } | |
+ if (!desc.get) { obj[keyName] = desc.value; } | |
}; | |
} | |
@@ -15029,25 +15145,18 @@ | |
exports.DEFAULT_GETTER_FUNCTION = DEFAULT_GETTER_FUNCTION; | |
exports.defineProperty = defineProperty; | |
- // .......................................................... | |
- // DESCRIPTOR | |
- // | |
- | |
/** | |
- Objects of this type can implement an interface to respond to requests to | |
- get and set. The default implementation handles simple properties. | |
- | |
- You generally won't need to create or subclass this directly. | |
- | |
- @class Descriptor | |
- @namespace Ember | |
- @private | |
- @constructor | |
+ @module ember-metal | |
*/ | |
+ | |
function Descriptor() { | |
this.isDescriptor = true; | |
} | |
+ // .......................................................... | |
+ // DEFINING PROPERTIES API | |
+ // | |
+ | |
function MANDATORY_SETTER_FUNCTION(name) { | |
return function SETTER_FUNCTION(value) { | |
Ember['default'].assert("You must use Ember.set() to set the `" + name + "` property (of " + this + ") to `" + value + "`.", false); | |
@@ -15056,11 +15165,56 @@ | |
function DEFAULT_GETTER_FUNCTION(name) { | |
return function GETTER_FUNCTION() { | |
- var meta = this["__ember_meta__"]; | |
+ var meta = this['__ember_meta__']; | |
return meta && meta.values[name]; | |
}; | |
} | |
+ /** | |
+ NOTE: This is a low-level method used by other parts of the API. You almost | |
+ never want to call this method directly. Instead you should use | |
+ `Ember.mixin()` to define new properties. | |
+ | |
+ Defines a property on an object. This method works much like the ES5 | |
+ `Object.defineProperty()` method except that it can also accept computed | |
+ properties and other special descriptors. | |
+ | |
+ Normally this method takes only three parameters. However if you pass an | |
+ instance of `Ember.Descriptor` as the third param then you can pass an | |
+ optional value as the fourth parameter. This is often more efficient than | |
+ creating new descriptor hashes for each property. | |
+ | |
+ ## Examples | |
+ | |
+ ```javascript | |
+ // ES5 compatible mode | |
+ Ember.defineProperty(contact, 'firstName', { | |
+ writable: true, | |
+ configurable: false, | |
+ enumerable: true, | |
+ value: 'Charles' | |
+ }); | |
+ | |
+ // define a simple property | |
+ Ember.defineProperty(contact, 'lastName', undefined, 'Jolley'); | |
+ | |
+ // define a computed property | |
+ Ember.defineProperty(contact, 'fullName', Ember.computed(function() { | |
+ return this.firstName+' '+this.lastName; | |
+ }).property('firstName', 'lastName')); | |
+ ``` | |
+ | |
+ @private | |
+ @method defineProperty | |
+ @for Ember | |
+ @param {Object} obj the object to define this property on. This may be a prototype. | |
+ @param {String} keyName the name of the property | |
+ @param {Ember.Descriptor} [desc] an instance of `Ember.Descriptor` (typically a | |
+ computed property) or an ES5 descriptor. | |
+ You must provide this or `data` but not both. | |
+ @param {*} [data] something other than a descriptor, that will | |
+ become the explicit value of this property. | |
+ */ | |
function defineProperty(obj, keyName, desc, data, meta) { | |
var possibleDesc, existingDesc, watching, value; | |
@@ -15069,7 +15223,7 @@ | |
} | |
var watchEntry = meta.watching[keyName]; | |
possibleDesc = obj[keyName]; | |
- existingDesc = possibleDesc !== null && typeof possibleDesc === "object" && possibleDesc.isDescriptor ? possibleDesc : undefined; | |
+ existingDesc = (possibleDesc !== null && typeof possibleDesc === 'object' && possibleDesc.isDescriptor) ? possibleDesc : undefined; | |
watching = watchEntry !== undefined && watchEntry > 0; | |
@@ -15091,9 +15245,7 @@ | |
} else { | |
obj[keyName] = value; | |
} | |
- if (desc.setup) { | |
- desc.setup(obj, keyName); | |
- } | |
+ if (desc.setup) { desc.setup(obj, keyName); } | |
} else { | |
if (desc == null) { | |
value = data; | |
@@ -15120,15 +15272,11 @@ | |
// if key is being watched, override chains that | |
// were initialized with the prototype | |
- if (watching) { | |
- property_events.overrideChains(obj, keyName, meta); | |
- } | |
+ if (watching) { property_events.overrideChains(obj, keyName, meta); } | |
// The `value` passed to the `didDefineProperty` hook is | |
// either the descriptor or data, whichever was passed. | |
- if (obj.didDefineProperty) { | |
- obj.didDefineProperty(obj, keyName, value); | |
- } | |
+ if (obj.didDefineProperty) { obj.didDefineProperty(obj, keyName, value); } | |
return this; | |
} | |
@@ -15169,11 +15317,11 @@ | |
@return {void} | |
*/ | |
function propertyWillChange(obj, keyName) { | |
- var m = obj["__ember_meta__"]; | |
- var watching = m && m.watching[keyName] > 0 || keyName === "length"; | |
+ var m = obj['__ember_meta__']; | |
+ var watching = (m && m.watching[keyName] > 0) || keyName === 'length'; | |
var proto = m && m.proto; | |
var possibleDesc = obj[keyName]; | |
- var desc = possibleDesc !== null && typeof possibleDesc === "object" && possibleDesc.isDescriptor ? possibleDesc : undefined; | |
+ var desc = (possibleDesc !== null && typeof possibleDesc === 'object' && possibleDesc.isDescriptor) ? possibleDesc : undefined; | |
if (!watching) { | |
return; | |
@@ -15208,11 +15356,11 @@ | |
@return {void} | |
*/ | |
function propertyDidChange(obj, keyName) { | |
- var m = obj["__ember_meta__"]; | |
- var watching = m && m.watching[keyName] > 0 || keyName === "length"; | |
+ var m = obj['__ember_meta__']; | |
+ var watching = (m && m.watching[keyName] > 0) || keyName === 'length'; | |
var proto = m && m.proto; | |
var possibleDesc = obj[keyName]; | |
- var desc = possibleDesc !== null && typeof possibleDesc === "object" && possibleDesc.isDescriptor ? possibleDesc : undefined; | |
+ var desc = (possibleDesc !== null && typeof possibleDesc === 'object' && possibleDesc.isDescriptor) ? possibleDesc : undefined; | |
if (proto === obj) { | |
return; | |
@@ -15223,7 +15371,7 @@ | |
desc.didChange(obj, keyName); | |
} | |
- if (!watching && keyName !== "length") { | |
+ if (!watching && keyName !== 'length') { | |
return; | |
} | |
@@ -15238,9 +15386,7 @@ | |
var WILL_SEEN, DID_SEEN; | |
// called whenever a property is about to change to clear the cache of any dependent keys (and notify those properties of changes, etc...) | |
function dependentKeysWillChange(obj, depKey, meta) { | |
- if (obj.isDestroying) { | |
- return; | |
- } | |
+ if (obj.isDestroying) { return; } | |
var deps; | |
if (meta && meta.deps && (deps = meta.deps[depKey])) { | |
@@ -15261,9 +15407,7 @@ | |
// called whenever a property has just changed to update dependent keys | |
function dependentKeysDidChange(obj, depKey, meta) { | |
- if (obj.isDestroying) { | |
- return; | |
- } | |
+ if (obj.isDestroying) { return; } | |
var deps; | |
if (meta && meta.deps && (deps = meta.deps[depKey])) { | |
@@ -15309,10 +15453,10 @@ | |
if (deps) { | |
keys = keysOf(deps); | |
- for (i = 0; i < keys.length; i++) { | |
+ for (i=0; i<keys.length; i++) { | |
key = keys[i]; | |
possibleDesc = obj[key]; | |
- desc = possibleDesc !== null && typeof possibleDesc === "object" && possibleDesc.isDescriptor ? possibleDesc : undefined; | |
+ desc = (possibleDesc !== null && typeof possibleDesc === 'object' && possibleDesc.isDescriptor) ? possibleDesc : undefined; | |
if (desc && desc._suspended === obj) { | |
continue; | |
@@ -15324,7 +15468,8 @@ | |
} | |
function chainsWillChange(obj, keyName, m) { | |
- if (!(m.hasOwnProperty("chainWatchers") && m.chainWatchers[keyName])) { | |
+ if (!(m.hasOwnProperty('chainWatchers') && | |
+ m.chainWatchers[keyName])) { | |
return; | |
} | |
@@ -15337,12 +15482,13 @@ | |
} | |
for (i = 0, l = events.length; i < l; i += 2) { | |
- propertyWillChange(events[i], events[i + 1]); | |
+ propertyWillChange(events[i], events[i+1]); | |
} | |
} | |
function chainsDidChange(obj, keyName, m, suppressEvents) { | |
- if (!(m && m.hasOwnProperty("chainWatchers") && m.chainWatchers[keyName])) { | |
+ if (!(m && m.hasOwnProperty('chainWatchers') && | |
+ m.chainWatchers[keyName])) { | |
return; | |
} | |
@@ -15359,7 +15505,7 @@ | |
} | |
for (i = 0, l = events.length; i < l; i += 2) { | |
- propertyDidChange(events[i], events[i + 1]); | |
+ propertyDidChange(events[i], events[i+1]); | |
} | |
} | |
@@ -15382,7 +15528,7 @@ | |
*/ | |
function endPropertyChanges() { | |
deferred--; | |
- if (deferred <= 0) { | |
+ if (deferred<=0) { | |
beforeObserverSet.clear(); | |
observerSet.flush(); | |
} | |
@@ -15409,11 +15555,9 @@ | |
} | |
function notifyBeforeObservers(obj, keyName) { | |
- if (obj.isDestroying) { | |
- return; | |
- } | |
+ if (obj.isDestroying) { return; } | |
- var eventName = keyName + ":before"; | |
+ var eventName = keyName + ':before'; | |
var listeners, added; | |
if (deferred) { | |
listeners = beforeObserverSet.add(obj, keyName, eventName); | |
@@ -15425,11 +15569,9 @@ | |
} | |
function notifyObservers(obj, keyName) { | |
- if (obj.isDestroying) { | |
- return; | |
- } | |
+ if (obj.isDestroying) { return; } | |
- var eventName = keyName + ":change"; | |
+ var eventName = keyName + ':change'; | |
var listeners; | |
if (deferred) { | |
listeners = observerSet.add(obj, keyName, eventName); | |
@@ -15449,6 +15591,12 @@ | |
exports._getPath = _getPath; | |
exports.getWithDefault = getWithDefault; | |
+ /** | |
+ @module ember-metal | |
+ */ | |
+ | |
+ var FIRST_KEY = /^([^\.]+)/; | |
+ | |
// .......................................................... | |
// GET AND SET | |
// | |
@@ -15480,31 +15628,32 @@ | |
@param {String} keyName The property key to retrieve | |
@return {Object} the property value or `null`. | |
*/ | |
- var FIRST_KEY = /^([^\.]+)/; | |
function get(obj, keyName) { | |
// Helpers that operate with 'this' within an #each | |
- if (keyName === "") { | |
+ if (keyName === '') { | |
return obj; | |
} | |
- if (!keyName && "string" === typeof obj) { | |
+ if (!keyName && 'string' === typeof obj) { | |
keyName = obj; | |
obj = null; | |
} | |
- Ember['default'].assert("Cannot call get with " + keyName + " key.", !!keyName); | |
- Ember['default'].assert("Cannot call get with '" + keyName + "' on an undefined object.", obj !== undefined); | |
+ Ember['default'].assert("Cannot call get with "+ keyName +" key.", !!keyName); | |
+ Ember['default'].assert("Cannot call get with '"+ keyName +"' on an undefined object.", obj !== undefined); | |
if (obj === null) { | |
var value = _getPath(obj, keyName); | |
- Ember['default'].deprecate("Ember.get fetched '" + keyName + "' from the global context. This behavior will change in the future (issue #3852)", !value || obj && obj !== Ember['default'].lookup || path_cache.isPath(keyName) || path_cache.isGlobalPath(keyName + ".") // Add a . to ensure simple paths are matched. | |
+ Ember['default'].deprecate( | |
+ "Ember.get fetched '"+keyName+"' from the global context. This behavior will change in the future (issue #3852)", | |
+ !value || (obj && obj !== Ember['default'].lookup) || path_cache.isPath(keyName) || path_cache.isGlobalPath(keyName+".") // Add a . to ensure simple paths are matched. | |
); | |
return value; | |
} | |
- var meta = obj["__ember_meta__"]; | |
+ var meta = obj['__ember_meta__']; | |
var possibleDesc = obj[keyName]; | |
- var desc = possibleDesc !== null && typeof possibleDesc === "object" && possibleDesc.isDescriptor ? possibleDesc : undefined; | |
+ var desc = (possibleDesc !== null && typeof possibleDesc === 'object' && possibleDesc.isDescriptor) ? possibleDesc : undefined; | |
var ret; | |
if (desc === undefined && path_cache.isPath(keyName)) { | |
@@ -15521,7 +15670,8 @@ | |
ret = obj[keyName]; | |
} | |
- if (ret === undefined && "object" === typeof obj && !(keyName in obj) && "function" === typeof obj.unknownProperty) { | |
+ if (ret === undefined && | |
+ 'object' === typeof obj && !(keyName in obj) && 'function' === typeof obj.unknownProperty) { | |
return obj.unknownProperty(keyName); | |
} | |
@@ -15529,8 +15679,21 @@ | |
} | |
} | |
+ /** | |
+ Normalizes a target/path pair to reflect that actual target/path that should | |
+ be observed, etc. This takes into account passing in global property | |
+ paths (i.e. a path beginning with a capital letter not defined on the | |
+ target). | |
+ | |
+ @private | |
+ @method normalizeTuple | |
+ @for Ember | |
+ @param {Object} target The current target. May be `null`. | |
+ @param {String} path A path on the target or a global property path. | |
+ @return {Array} a temporary array with the normalized target/path pair. | |
+ */ | |
function normalizeTuple(target, path) { | |
- var hasThis = path_cache.hasThis(path); | |
+ var hasThis = path_cache.hasThis(path); | |
var isGlobal = !hasThis && path_cache.isGlobalPath(path); | |
var key; | |
@@ -15542,17 +15705,20 @@ | |
path = path.slice(5); | |
} | |
- Ember['default'].deprecate("normalizeTuple will return '" + path + "' as a non-global. This behavior will change in the future (issue #3852)", target === Ember['default'].lookup || !target || hasThis || isGlobal || !path_cache.isGlobalPath(path + ".")); | |
+ Ember['default'].deprecate( | |
+ "normalizeTuple will return '"+path+"' as a non-global. This behavior will change in the future (issue #3852)", | |
+ target === Ember['default'].lookup || !target || hasThis || isGlobal || !path_cache.isGlobalPath(path+'.') | |
+ ); | |
if (target === Ember['default'].lookup) { | |
key = path.match(FIRST_KEY)[0]; | |
target = get(target, key); | |
- path = path.slice(key.length + 1); | |
+ path = path.slice(key.length+1); | |
} | |
// must return some kind of path to be valid else other things will break. | |
- if (!path || path.length === 0) { | |
- throw new EmberError['default']("Path cannot be empty"); | |
+ if (!path || path.length===0) { | |
+ throw new EmberError['default']('Path cannot be empty'); | |
} | |
return [target, path]; | |
@@ -15582,9 +15748,7 @@ | |
len = parts.length; | |
for (idx = 0; root != null && idx < len; idx++) { | |
root = get(root, parts[idx], true); | |
- if (root && root.isDestroyed) { | |
- return undefined; | |
- } | |
+ if (root && root.isDestroyed) { return undefined; } | |
} | |
return root; | |
} | |
@@ -15592,9 +15756,7 @@ | |
function getWithDefault(root, key, defaultValue) { | |
var value = get(root, key); | |
- if (value === undefined) { | |
- return defaultValue; | |
- } | |
+ if (value === undefined) { return defaultValue; } | |
return value; | |
} | |
@@ -15608,6 +15770,8 @@ | |
exports.set = set; | |
exports.trySet = trySet; | |
+ var IS_GLOBAL = /^([A-Z$]|([0-9][A-Z$]))/; | |
+ | |
/** | |
Sets the value of a property on an object, respecting computed properties | |
and notifying observers and other listeners of the change. If the | |
@@ -15621,24 +15785,23 @@ | |
@param {Object} value The value to set | |
@return {Object} the passed value. | |
*/ | |
- var IS_GLOBAL = /^([A-Z$]|([0-9][A-Z$]))/; | |
function set(obj, keyName, value, tolerant) { | |
- if (typeof obj === "string") { | |
+ if (typeof obj === 'string') { | |
Ember['default'].assert("Path '" + obj + "' must be global if no obj is given.", IS_GLOBAL.test(obj)); | |
value = keyName; | |
keyName = obj; | |
obj = null; | |
} | |
- Ember['default'].assert("Cannot call set with " + keyName + " key.", !!keyName); | |
+ Ember['default'].assert("Cannot call set with "+ keyName +" key.", !!keyName); | |
if (!obj) { | |
return setPath(obj, keyName, value, tolerant); | |
} | |
- var meta = obj["__ember_meta__"]; | |
+ var meta = obj['__ember_meta__']; | |
var possibleDesc = obj[keyName]; | |
- var desc = possibleDesc !== null && typeof possibleDesc === "object" && possibleDesc.isDescriptor ? possibleDesc : undefined; | |
+ var desc = (possibleDesc !== null && typeof possibleDesc === 'object' && possibleDesc.isDescriptor) ? possibleDesc : undefined; | |
var isUnknown, currentValue; | |
@@ -15647,22 +15810,22 @@ | |
} | |
Ember['default'].assert("You need to provide an object and key to `set`.", !!obj && keyName !== undefined); | |
- Ember['default'].assert("calling set on destroyed object", !obj.isDestroyed); | |
+ Ember['default'].assert('calling set on destroyed object', !obj.isDestroyed); | |
if (desc) { | |
desc.set(obj, keyName, value); | |
} else { | |
- if (typeof obj === "object" && obj !== null && value !== undefined && obj[keyName] === value) { | |
+ if (typeof obj === 'object' && obj !== null && value !== undefined && obj[keyName] === value) { | |
return value; | |
} | |
- isUnknown = "object" === typeof obj && !(keyName in obj); | |
+ isUnknown = 'object' === typeof obj && !(keyName in obj); | |
// setUnknownProperty is called if `obj` is an object, | |
// the property does not already exist, and the | |
// `setUnknownProperty` method exists on the object | |
- if (isUnknown && "function" === typeof obj.setUnknownProperty) { | |
+ if (isUnknown && 'function' === typeof obj.setUnknownProperty) { | |
obj.setUnknownProperty(keyName, value); | |
} else if (meta && meta.watching[keyName] > 0) { | |
if (meta.proto !== obj) { | |
@@ -15678,7 +15841,10 @@ | |
property_events.propertyWillChange(obj, keyName); | |
if (define_property.hasPropertyAccessors) { | |
- if (currentValue === undefined && !(keyName in obj) || !Object.prototype.propertyIsEnumerable.call(obj, keyName)) { | |
+ if ( | |
+ (currentValue === undefined && !(keyName in obj)) || | |
+ !Object.prototype.propertyIsEnumerable.call(obj, keyName) | |
+ ) { | |
properties.defineProperty(obj, keyName, null, value); // setup mandatory setter | |
} else { | |
meta.values[keyName] = value; | |
@@ -15699,31 +15865,45 @@ | |
var keyName; | |
// get the last part of the path | |
- keyName = path.slice(path.lastIndexOf(".") + 1); | |
+ keyName = path.slice(path.lastIndexOf('.') + 1); | |
// get the first part of the part | |
- path = path === keyName ? keyName : path.slice(0, path.length - (keyName.length + 1)); | |
+ path = (path === keyName) ? keyName : path.slice(0, path.length-(keyName.length+1)); | |
// unless the path is this, look up the first part to | |
// get the root | |
- if (path !== "this") { | |
+ if (path !== 'this') { | |
root = property_get._getPath(root, path); | |
} | |
if (!keyName || keyName.length === 0) { | |
- throw new EmberError['default']("Property set failed: You passed an empty path"); | |
+ throw new EmberError['default']('Property set failed: You passed an empty path'); | |
} | |
if (!root) { | |
if (tolerant) { | |
return; | |
} else { | |
- throw new EmberError['default']("Property set failed: object in path \"" + path + "\" could not be found or was destroyed."); | |
+ throw new EmberError['default']('Property set failed: object in path "'+path+'" could not be found or was destroyed.'); | |
} | |
} | |
return set(root, keyName, value); | |
} | |
+ | |
+ /** | |
+ Error-tolerant form of `Ember.set`. Will not blow up if any part of the | |
+ chain is `undefined`, `null`, or destroyed. | |
+ | |
+ This is primarily used when syncing bindings, which may try to update after | |
+ an object has been destroyed. | |
+ | |
+ @method trySet | |
+ @for Ember | |
+ @param {Object} obj The object to modify. | |
+ @param {String} path The property path to set | |
+ @param {Object} value The value to set | |
+ */ | |
function trySet(root, path, value) { | |
return set(root, path, value, true); | |
} | |
@@ -15742,17 +15922,17 @@ | |
} | |
// ES6TODO: should Backburner become es6? | |
- var backburner = new Backburner['default'](["sync", "actions", "destroy"], { | |
+ var backburner = new Backburner['default'](['sync', 'actions', 'destroy'], { | |
GUID_KEY: utils.GUID_KEY, | |
sync: { | |
before: property_events.beginPropertyChanges, | |
after: property_events.endPropertyChanges | |
}, | |
- defaultQueue: "actions", | |
+ defaultQueue: 'actions', | |
onBegin: onBegin, | |
onEnd: onEnd, | |
onErrorTarget: Ember['default'], | |
- onErrorMethod: "onerror" | |
+ onErrorMethod: 'onerror' | |
}); | |
var slice = [].slice; | |
@@ -15829,7 +16009,7 @@ | |
@return {Object} Return value from invoking the passed function. Please note, | |
when called within an existing loop, no return value is possible. | |
*/ | |
- run.join = function () { | |
+ run.join = function() { | |
return backburner.join.apply(backburner, arguments); | |
}; | |
@@ -15882,9 +16062,9 @@ | |
@return {Function} returns a new function that will always have a particular context | |
@since 1.4.0 | |
*/ | |
- run.bind = function (target, method /* args */) { | |
+ run.bind = function(target, method /* args */) { | |
var args = slice.call(arguments); | |
- return function () { | |
+ return function() { | |
return run.join.apply(run, args.concat(slice.call(arguments))); | |
}; | |
}; | |
@@ -15907,7 +16087,7 @@ | |
@method begin | |
@return {void} | |
*/ | |
- run.begin = function () { | |
+ run.begin = function() { | |
backburner.begin(); | |
}; | |
@@ -15925,7 +16105,7 @@ | |
@method end | |
@return {void} | |
*/ | |
- run.end = function () { | |
+ run.end = function() { | |
backburner.end(); | |
}; | |
@@ -15977,13 +16157,13 @@ | |
@param {Object} [arguments*] Optional arguments to be passed to the queued method. | |
@return {void} | |
*/ | |
- run.schedule = function (queue, target, method) { | |
+ run.schedule = function(queue, target, method) { | |
checkAutoRun(); | |
backburner.schedule.apply(backburner, arguments); | |
}; | |
// Used by global test teardown | |
- run.hasScheduledTimers = function () { | |
+ run.hasScheduledTimers = function() { | |
return backburner.hasTimers(); | |
}; | |
@@ -16008,7 +16188,7 @@ | |
@method sync | |
@return {void} | |
*/ | |
- run.sync = function () { | |
+ run.sync = function() { | |
if (backburner.currentInstance) { | |
backburner.currentInstance.queues.sync.flush(); | |
} | |
@@ -16039,7 +16219,7 @@ | |
@param {Number} wait Number of milliseconds to wait. | |
@return {*} Timer information for use in cancelling, see `run.cancel`. | |
*/ | |
- run.later = function () { | |
+ run.later = function(/*target, method*/) { | |
return backburner.later.apply(backburner, arguments); | |
}; | |
@@ -16055,11 +16235,11 @@ | |
@param {Object} [args*] Optional arguments to pass to the timeout. | |
@return {Object} Timer information for use in cancelling, see `run.cancel`. | |
*/ | |
- run.once = function () { | |
+ run.once = function(/*target, method */) { | |
checkAutoRun(); | |
var length = arguments.length; | |
var args = new Array(length); | |
- args[0] = "actions"; | |
+ args[0] = 'actions'; | |
for (var i = 0; i < length; i++) { | |
args[i + 1] = arguments[i]; | |
} | |
@@ -16117,7 +16297,7 @@ | |
@param {Object} [args*] Optional arguments to pass to the timeout. | |
@return {Object} Timer information for use in cancelling, see `run.cancel`. | |
*/ | |
- run.scheduleOnce = function () { | |
+ run.scheduleOnce = function(/*queue, target, method*/) { | |
checkAutoRun(); | |
return backburner.scheduleOnce.apply(backburner, arguments); | |
}; | |
@@ -16180,7 +16360,7 @@ | |
@param {Object} [args*] Optional arguments to pass to the timeout. | |
@return {Object} Timer information for use in cancelling, see `run.cancel`. | |
*/ | |
- run.next = function () { | |
+ run.next = function() { | |
var args = slice.call(arguments); | |
args.push(1); | |
return utils.apply(backburner, backburner.later, args); | |
@@ -16234,7 +16414,7 @@ | |
@param {Object} timer Timer object to cancel | |
@return {Boolean} true if cancelled or false/undefined if it wasn't found | |
*/ | |
- run.cancel = function (timer) { | |
+ run.cancel = function(timer) { | |
return backburner.cancel(timer); | |
}; | |
@@ -16306,7 +16486,7 @@ | |
of the trailing edge of the wait interval. Defaults to false. | |
@return {Array} Timer information for use in cancelling, see `run.cancel`. | |
*/ | |
- run.debounce = function () { | |
+ run.debounce = function() { | |
return backburner.debounce.apply(backburner, arguments); | |
}; | |
@@ -16348,14 +16528,15 @@ | |
of the trailing edge of the wait interval. Defaults to true. | |
@return {Array} Timer information for use in cancelling, see `run.cancel`. | |
*/ | |
- run.throttle = function () { | |
+ run.throttle = function() { | |
return backburner.throttle.apply(backburner, arguments); | |
}; | |
// Make sure it's not an autorun during testing | |
function checkAutoRun() { | |
if (!run.currentRunLoop) { | |
- Ember['default'].assert("You have turned on testing mode, which disabled the run-loop's autorun." + " You will need to wrap any code with asynchronous side-effects in a run", !Ember['default'].testing); | |
+ Ember['default'].assert("You have turned on testing mode, which disabled the run-loop's autorun." + | |
+ " You will need to wrap any code with asynchronous side-effects in a run", !Ember['default'].testing); | |
} | |
} | |
@@ -16369,46 +16550,20 @@ | |
@param {String} after the name of the queue to add after. | |
@private | |
*/ | |
- run._addQueue = function (name, after) { | |
+ run._addQueue = function(name, after) { | |
if (array.indexOf.call(run.queues, name) === -1) { | |
- run.queues.splice(array.indexOf.call(run.queues, after) + 1, 0, name); | |
+ run.queues.splice(array.indexOf.call(run.queues, after)+1, 0, name); | |
} | |
}; | |
- /*target, method*/ /*target, method */ /*queue, target, method*/ | |
}); | |
enifed('ember-metal/set_properties', ['exports', 'ember-metal/property_events', 'ember-metal/property_set', 'ember-metal/keys'], function (exports, property_events, property_set, keys) { | |
'use strict'; | |
- | |
- | |
- /** | |
- Set a list of properties on an object. These properties are set inside | |
- a single `beginPropertyChanges` and `endPropertyChanges` batch, so | |
- observers will be buffered. | |
- | |
- ```javascript | |
- var anObject = Ember.Object.create(); | |
- | |
- anObject.setProperties({ | |
- firstName: 'Stanley', | |
- lastName: 'Stuart', | |
- age: 21 | |
- }); | |
- ``` | |
- | |
- @method setProperties | |
- @param obj | |
- @param {Object} properties | |
- @return obj | |
- */ | |
- exports['default'] = setProperties; | |
function setProperties(obj, properties) { | |
- if (!properties || typeof properties !== "object") { | |
- return obj; | |
- } | |
- property_events.changeProperties(function () { | |
+ if (!properties || typeof properties !== "object") { return obj; } | |
+ property_events.changeProperties(function() { | |
var props = keys['default'](properties); | |
var propertyName; | |
@@ -16420,16 +16575,13 @@ | |
}); | |
return obj; | |
} | |
+ exports['default'] = setProperties; | |
}); | |
enifed('ember-metal/streams/conditional', ['exports', 'ember-metal/streams/stream', 'ember-metal/streams/utils', 'ember-metal/platform/create'], function (exports, Stream, utils, create) { | |
'use strict'; | |
- | |
- | |
- exports['default'] = conditional; | |
- | |
function conditional(test, consequent, alternate) { | |
if (utils.isStream(test)) { | |
return new ConditionalStream(test, consequent, alternate); | |
@@ -16441,6 +16593,7 @@ | |
} | |
} | |
} | |
+ exports['default'] = conditional; | |
function ConditionalStream(test, consequent, alternate) { | |
this.init(); | |
@@ -16453,25 +16606,20 @@ | |
ConditionalStream.prototype = create['default'](Stream['default'].prototype); | |
- ConditionalStream.prototype.valueFn = function () { | |
+ ConditionalStream.prototype.valueFn = function() { | |
var oldTestResult = this.oldTestResult; | |
var newTestResult = !!utils.read(this.test); | |
if (newTestResult !== oldTestResult) { | |
switch (oldTestResult) { | |
- case true: | |
- utils.unsubscribe(this.consequent, this.notify, this);break; | |
- case false: | |
- utils.unsubscribe(this.alternate, this.notify, this);break; | |
- case undefined: | |
- utils.subscribe(this.test, this.notify, this); | |
+ case true: utils.unsubscribe(this.consequent, this.notify, this); break; | |
+ case false: utils.unsubscribe(this.alternate, this.notify, this); break; | |
+ case undefined: utils.subscribe(this.test, this.notify, this); | |
} | |
switch (newTestResult) { | |
- case true: | |
- utils.subscribe(this.consequent, this.notify, this);break; | |
- case false: | |
- utils.subscribe(this.alternate, this.notify, this); | |
+ case true: utils.subscribe(this.consequent, this.notify, this); break; | |
+ case false: utils.subscribe(this.alternate, this.notify, this); | |
} | |
this.oldTestResult = newTestResult; | |
@@ -16497,11 +16645,11 @@ | |
SimpleStream.prototype = create['default'](Stream['default'].prototype); | |
merge['default'](SimpleStream.prototype, { | |
- valueFn: function () { | |
+ valueFn: function() { | |
return utils.read(this.source); | |
}, | |
- setValue: function (value) { | |
+ setValue: function(value) { | |
var source = this.source; | |
if (utils.isStream(source)) { | |
@@ -16509,7 +16657,7 @@ | |
} | |
}, | |
- setSource: function (nextSource) { | |
+ setSource: function(nextSource) { | |
var prevSource = this.source; | |
if (nextSource !== prevSource) { | |
if (utils.isStream(prevSource)) { | |
@@ -16525,13 +16673,13 @@ | |
} | |
}, | |
- _didChange: function () { | |
+ _didChange: function() { | |
this.notify(); | |
}, | |
_super$destroy: Stream['default'].prototype.destroy, | |
- destroy: function () { | |
+ destroy: function() { | |
if (this._super$destroy()) { | |
if (utils.isStream(this.source)) { | |
this.source.unsubscribe(this._didChange, this); | |
@@ -16557,15 +16705,15 @@ | |
Stream.prototype = { | |
isStream: true, | |
- init: function () { | |
- this.state = "dirty"; | |
+ init: function() { | |
+ this.state = 'dirty'; | |
this.cache = undefined; | |
this.subscribers = undefined; | |
this.children = undefined; | |
this._label = undefined; | |
}, | |
- get: function (path) { | |
+ get: function(path) { | |
var firstKey = path_cache.getFirstKey(path); | |
var tailPath = path_cache.getTailPath(path); | |
@@ -16587,11 +16735,11 @@ | |
} | |
}, | |
- value: function () { | |
- if (this.state === "clean") { | |
+ value: function() { | |
+ if (this.state === 'clean') { | |
return this.cache; | |
- } else if (this.state === "dirty") { | |
- this.state = "clean"; | |
+ } else if (this.state === 'dirty') { | |
+ this.state = 'clean'; | |
return this.cache = this.valueFn(); | |
} | |
// TODO: Ensure value is never called on a destroyed stream | |
@@ -16600,26 +16748,26 @@ | |
// Ember.assert("Stream error: value was called in an invalid state: " + this.state); | |
}, | |
- valueFn: function () { | |
+ valueFn: function() { | |
throw new Error("Stream error: valueFn not implemented"); | |
}, | |
- setValue: function () { | |
+ setValue: function() { | |
throw new Error("Stream error: setValue not implemented"); | |
}, | |
- notify: function () { | |
+ notify: function() { | |
this.notifyExcept(); | |
}, | |
- notifyExcept: function (callbackToSkip, contextToSkip) { | |
- if (this.state === "clean") { | |
- this.state = "dirty"; | |
+ notifyExcept: function(callbackToSkip, contextToSkip) { | |
+ if (this.state === 'clean') { | |
+ this.state = 'dirty'; | |
this._notifySubscribers(callbackToSkip, contextToSkip); | |
} | |
}, | |
- subscribe: function (callback, context) { | |
+ subscribe: function(callback, context) { | |
if (this.subscribers === undefined) { | |
this.subscribers = [callback, context]; | |
} else { | |
@@ -16627,12 +16775,12 @@ | |
} | |
}, | |
- unsubscribe: function (callback, context) { | |
+ unsubscribe: function(callback, context) { | |
var subscribers = this.subscribers; | |
if (subscribers !== undefined) { | |
for (var i = 0, l = subscribers.length; i < l; i += 2) { | |
- if (subscribers[i] === callback && subscribers[i + 1] === context) { | |
+ if (subscribers[i] === callback && subscribers[i+1] === context) { | |
subscribers.splice(i, 2); | |
return; | |
} | |
@@ -16640,13 +16788,13 @@ | |
} | |
}, | |
- _notifySubscribers: function (callbackToSkip, contextToSkip) { | |
+ _notifySubscribers: function(callbackToSkip, contextToSkip) { | |
var subscribers = this.subscribers; | |
if (subscribers !== undefined) { | |
for (var i = 0, l = subscribers.length; i < l; i += 2) { | |
var callback = subscribers[i]; | |
- var context = subscribers[i + 1]; | |
+ var context = subscribers[i+1]; | |
if (callback === callbackToSkip && context === contextToSkip) { | |
continue; | |
@@ -16661,9 +16809,9 @@ | |
} | |
}, | |
- destroy: function () { | |
- if (this.state !== "destroyed") { | |
- this.state = "destroyed"; | |
+ destroy: function() { | |
+ if (this.state !== 'destroyed') { | |
+ this.state = 'destroyed'; | |
var children = this.children; | |
for (var key in children) { | |
@@ -16674,7 +16822,7 @@ | |
} | |
}, | |
- isGlobal: function () { | |
+ isGlobal: function() { | |
var stream = this; | |
while (stream !== undefined) { | |
if (stream._isRoot) { | |
@@ -16707,24 +16855,24 @@ | |
StreamBinding.prototype = create['default'](Stream['default'].prototype); | |
merge['default'](StreamBinding.prototype, { | |
- valueFn: function () { | |
+ valueFn: function() { | |
return this.stream.value(); | |
}, | |
- _onNotify: function () { | |
+ _onNotify: function() { | |
this._scheduleSync(undefined, undefined, this); | |
}, | |
- setValue: function (value, callback, context) { | |
+ setValue: function(value, callback, context) { | |
this._scheduleSync(value, callback, context); | |
}, | |
- _scheduleSync: function (value, callback, context) { | |
+ _scheduleSync: function(value, callback, context) { | |
if (this.senderCallback === undefined && this.senderContext === undefined) { | |
this.senderCallback = callback; | |
this.senderContext = context; | |
this.senderValue = value; | |
- run['default'].schedule("sync", this, this._sync); | |
+ run['default'].schedule('sync', this, this._sync); | |
} else if (this.senderContext !== this) { | |
this.senderCallback = callback; | |
this.senderContext = context; | |
@@ -16732,8 +16880,8 @@ | |
} | |
}, | |
- _sync: function () { | |
- if (this.state === "destroyed") { | |
+ _sync: function() { | |
+ if (this.state === 'destroyed') { | |
return; | |
} | |
@@ -16748,14 +16896,14 @@ | |
this.senderValue = undefined; | |
// Force StreamBindings to always notify | |
- this.state = "clean"; | |
+ this.state = 'clean'; | |
this.notifyExcept(senderCallback, senderContext); | |
}, | |
_super$destroy: Stream['default'].prototype.destroy, | |
- destroy: function () { | |
+ destroy: function() { | |
if (this._super$destroy()) { | |
this.stream.unsubscribe(this._onNotify, this); | |
return true; | |
@@ -16781,31 +16929,55 @@ | |
exports.concat = concat; | |
exports.chain = chain; | |
- /* | |
- Check whether an object is a stream or not | |
- | |
- @public | |
- @for Ember.stream | |
- @function isStream | |
- @param {Object|Stream} object object to check whether it is a stream | |
- @return {Boolean} `true` if the object is a stream, `false` otherwise | |
- */ | |
function isStream(object) { | |
return object && object.isStream; | |
} | |
+ /* | |
+ A method of subscribing to a stream which is safe for use with a non-stream | |
+ object. If a non-stream object is passed, the function does nothing. | |
+ | |
+ @public | |
+ @for Ember.stream | |
+ @function subscribe | |
+ @param {Object|Stream} object object or stream to potentially subscribe to | |
+ @param {Function} callback function to run when stream value changes | |
+ @param {Object} [context] the callback will be executed with this context if it | |
+ is provided | |
+ */ | |
function subscribe(object, callback, context) { | |
if (object && object.isStream) { | |
object.subscribe(callback, context); | |
} | |
} | |
+ /* | |
+ A method of unsubscribing from a stream which is safe for use with a non-stream | |
+ object. If a non-stream object is passed, the function does nothing. | |
+ | |
+ @public | |
+ @for Ember.stream | |
+ @function unsubscribe | |
+ @param {Object|Stream} object object or stream to potentially unsubscribe from | |
+ @param {Function} callback function originally passed to `subscribe()` | |
+ @param {Object} [context] object originally passed to `subscribe()` | |
+ */ | |
function unsubscribe(object, callback, context) { | |
if (object && object.isStream) { | |
object.unsubscribe(callback, context); | |
} | |
} | |
+ /* | |
+ Retrieve the value of a stream, or in the case a non-stream object is passed, | |
+ return the object itself. | |
+ | |
+ @public | |
+ @for Ember.stream | |
+ @function read | |
+ @param {Object|Stream} object object to return the value of | |
+ @return the stream's current value, or the non-stream object itself | |
+ */ | |
function read(object) { | |
if (object && object.isStream) { | |
return object.value(); | |
@@ -16814,6 +16986,18 @@ | |
} | |
} | |
+ /* | |
+ Map an array, replacing any streams with their values. | |
+ | |
+ @public | |
+ @for Ember.stream | |
+ @function readArray | |
+ @param {Array} array The array to read values from | |
+ @return {Array} a new array of the same length with the values of non-stream | |
+ objects mapped from their original positions untouched, and | |
+ the values of stream objects retaining their original position | |
+ and replaced with the stream's current value. | |
+ */ | |
function readArray(array) { | |
var length = array.length; | |
var ret = new Array(length); | |
@@ -16823,6 +17007,19 @@ | |
return ret; | |
} | |
+ /* | |
+ Map a hash, replacing any stream property values with the current value of that | |
+ stream. | |
+ | |
+ @public | |
+ @for Ember.stream | |
+ @function readHash | |
+ @param {Object} object The hash to read keys and values from | |
+ @return {Object} a new object with the same keys as the passed object. The | |
+ property values in the new object are the original values in | |
+ the case of non-stream objects, and the streams' current | |
+ values in the case of stream objects. | |
+ */ | |
function readHash(object) { | |
var ret = {}; | |
for (var key in object) { | |
@@ -16831,6 +17028,16 @@ | |
return ret; | |
} | |
+ /* | |
+ Check whether an array contains any stream values | |
+ | |
+ @public | |
+ @for Ember.stream | |
+ @function scanArray | |
+ @param {Array} array array given to a handlebars helper | |
+ @return {Boolean} `true` if the array contains a stream/bound value, `false` | |
+ otherwise | |
+ */ | |
function scanArray(array) { | |
var length = array.length; | |
var containsStream = false; | |
@@ -16845,6 +17052,16 @@ | |
return containsStream; | |
} | |
+ /* | |
+ Check whether a hash has any stream property values | |
+ | |
+ @public | |
+ @for Ember.stream | |
+ @function scanHash | |
+ @param {Object} hash "hash" argument given to a handlebars helper | |
+ @return {Boolean} `true` if the object contains a stream/bound value, `false` | |
+ otherwise | |
+ */ | |
function scanHash(hash) { | |
var containsStream = false; | |
@@ -16858,17 +17075,30 @@ | |
return containsStream; | |
} | |
+ /* | |
+ Join an array, with any streams replaced by their current values | |
+ | |
+ @public | |
+ @for Ember.stream | |
+ @function concat | |
+ @param {Array} array An array containing zero or more stream objects and | |
+ zero or more non-stream objects | |
+ @param {String} separator string to be used to join array elements | |
+ @return {String} String with array elements concatenated and joined by the | |
+ provided separator, and any stream array members having been | |
+ replaced by the current value of the stream | |
+ */ | |
function concat(array, separator) { | |
// TODO: Create subclass ConcatStream < Stream. Defer | |
// subscribing to streams until the value() is called. | |
var hasStream = scanArray(array); | |
if (hasStream) { | |
var i, l; | |
- var stream = new Stream['default'](function () { | |
+ var stream = new Stream['default'](function() { | |
return readArray(array).join(separator); | |
}); | |
- for (i = 0, l = array.length; i < l; i++) { | |
+ for (i = 0, l=array.length; i < l; i++) { | |
subscribe(array[i], stream.notify, stream); | |
} | |
@@ -16878,6 +17108,38 @@ | |
} | |
} | |
+ /* | |
+ Generate a new stream by providing a source stream and a function that can | |
+ be used to transform the stream's value. In the case of a non-stream object, | |
+ returns the result of the function. | |
+ | |
+ The value to transform would typically be available to the function you pass | |
+ to `chain()` via scope. For example: | |
+ | |
+ ```javascript | |
+ var source = ...; // stream returning a number | |
+ // or a numeric (non-stream) object | |
+ var result = chain(source, function() { | |
+ var currentValue = read(source); | |
+ return currentValue + 1; | |
+ }); | |
+ ``` | |
+ | |
+ In the example, result is a stream if source is a stream, or a number of | |
+ source was numeric. | |
+ | |
+ @public | |
+ @for Ember.stream | |
+ @function chain | |
+ @param {Object|Stream} value A stream or non-stream object | |
+ @param {Function} fn function to be run when the stream value changes, or to | |
+ be run once in the case of a non-stream object | |
+ @return {Object|Stream} In the case of a stream `value` parameter, a new | |
+ stream that will be updated with the return value of | |
+ the provided function `fn`. In the case of a | |
+ non-stream object, the return value of the provided | |
+ function `fn`. | |
+ */ | |
function chain(value, fn) { | |
if (isStream(value)) { | |
var stream = new Stream['default'](fn); | |
@@ -16914,6 +17176,8 @@ | |
// | |
"REMOVE_USE_STRICT: true"; | |
+ var _uuid = 0; | |
+ | |
/** | |
Generates a universally unique identifier. This method | |
is used internally by Ember for assisting with | |
@@ -16923,7 +17187,6 @@ | |
@public | |
@return {Number} [description] | |
*/ | |
- var _uuid = 0; | |
function uuid() { | |
return ++_uuid; | |
} | |
@@ -16936,11 +17199,11 @@ | |
@type String | |
@final | |
*/ | |
- var GUID_PREFIX = "ember"; | |
+ var GUID_PREFIX = 'ember'; | |
// Used for guid generation... | |
- var numberCache = []; | |
- var stringCache = {}; | |
+ var numberCache = []; | |
+ var stringCache = {}; | |
/** | |
Strongly hint runtimes to intern the provided string. | |
@@ -17006,12 +17269,12 @@ | |
@type String | |
@final | |
*/ | |
- var GUID_KEY = intern("__ember" + +new Date()); | |
+ var GUID_KEY = intern('__ember' + (+ new Date())); | |
var GUID_DESC = { | |
- writable: true, | |
+ writable: true, | |
configurable: true, | |
- enumerable: false, | |
+ enumerable: false, | |
value: null | |
}; | |
@@ -17037,7 +17300,7 @@ | |
}; | |
var EMBER_META_PROPERTY = { | |
- name: "__ember_meta__", | |
+ name: '__ember_meta__', | |
descriptor: META_DESC | |
}; | |
@@ -17047,14 +17310,34 @@ | |
}; | |
var NEXT_SUPER_PROPERTY = { | |
- name: "__nextSuper", | |
+ name: '__nextSuper', | |
descriptor: undefinedDescriptor | |
- };function generateGuid(obj, prefix) { | |
+ }; | |
+ | |
+ | |
+ /** | |
+ Generates a new guid, optionally saving the guid to the object that you | |
+ pass in. You will rarely need to use this method. Instead you should | |
+ call `Ember.guidFor(obj)`, which return an existing guid if available. | |
+ | |
+ @private | |
+ @method generateGuid | |
+ @for Ember | |
+ @param {Object} [obj] Object the guid will be used for. If passed in, the guid will | |
+ be saved on the object and reused whenever you pass the same object | |
+ again. | |
+ | |
+ If no object is passed, just generate a new guid. | |
+ @param {String} [prefix] Prefix to place in front of the guid. Useful when you want to | |
+ separate the guid into separate namespaces. | |
+ @return {String} the guid | |
+ */ | |
+ function generateGuid(obj, prefix) { | |
if (!prefix) { | |
prefix = GUID_PREFIX; | |
} | |
- var ret = prefix + uuid(); | |
+ var ret = (prefix + uuid()); | |
if (obj) { | |
if (obj[GUID_KEY] === null) { | |
obj[GUID_KEY] = ret; | |
@@ -17070,6 +17353,20 @@ | |
return ret; | |
} | |
+ /** | |
+ Returns a unique id for the object. If the object does not yet have a guid, | |
+ one will be assigned to it. You can call this on any object, | |
+ `Ember.Object`-based or not, but be aware that it will add a `_guid` | |
+ property. | |
+ | |
+ You can also use this method on DOM Element objects. | |
+ | |
+ @private | |
+ @method guidFor | |
+ @for Ember | |
+ @param {Object} obj any object, string, number, Element, or primitive | |
+ @return {String} the unique guid for this instance. | |
+ */ | |
function guidFor(obj) { | |
// special cases where we don't want to add a key to object | |
@@ -17086,26 +17383,26 @@ | |
// Don't allow prototype changes to String etc. to change the guidFor | |
switch (type) { | |
- case "number": | |
+ case 'number': | |
ret = numberCache[obj]; | |
if (!ret) { | |
- ret = numberCache[obj] = "nu" + obj; | |
+ ret = numberCache[obj] = 'nu'+obj; | |
} | |
return ret; | |
- case "string": | |
+ case 'string': | |
ret = stringCache[obj]; | |
if (!ret) { | |
- ret = stringCache[obj] = "st" + uuid(); | |
+ ret = stringCache[obj] = 'st' + uuid(); | |
} | |
return ret; | |
- case "boolean": | |
- return obj ? "(true)" : "(false)"; | |
+ case 'boolean': | |
+ return obj ? '(true)' : '(false)'; | |
default: | |
if (obj[GUID_KEY]) { | |
@@ -17113,11 +17410,11 @@ | |
} | |
if (obj === Object) { | |
- return "(Object)"; | |
+ return '(Object)'; | |
} | |
if (obj === Array) { | |
- return "(Array)"; | |
+ return '(Array)'; | |
} | |
ret = GUID_PREFIX + uuid(); | |
@@ -17167,7 +17464,7 @@ | |
// Without non-enumerable properties, meta objects will be output in JSON | |
// unless explicitly suppressed | |
- Meta.prototype.toJSON = function () {}; | |
+ Meta.prototype.toJSON = function () { }; | |
} | |
// Placeholder for non-writable metas. | |
@@ -17199,7 +17496,7 @@ | |
*/ | |
function meta(obj, writable) { | |
var ret = obj.__ember_meta__; | |
- if (writable === false) { | |
+ if (writable===false) { | |
return ret || EMPTY_META; | |
} | |
@@ -17208,7 +17505,7 @@ | |
if (obj.__defineNonEnumerable) { | |
obj.__defineNonEnumerable(EMBER_META_PROPERTY); | |
} else { | |
- define_property.defineProperty(obj, "__ember_meta__", META_DESC); | |
+ define_property.defineProperty(obj, '__ember_meta__', META_DESC); | |
} | |
} | |
@@ -17225,14 +17522,14 @@ | |
if (obj.__defineNonEnumerable) { | |
obj.__defineNonEnumerable(EMBER_META_PROPERTY); | |
} else { | |
- define_property.defineProperty(obj, "__ember_meta__", META_DESC); | |
+ define_property.defineProperty(obj, '__ember_meta__', META_DESC); | |
} | |
ret = o_create['default'](ret); | |
- ret.watching = o_create['default'](ret.watching); | |
- ret.cache = undefined; | |
+ ret.watching = o_create['default'](ret.watching); | |
+ ret.cache = undefined; | |
ret.cacheMeta = undefined; | |
- ret.source = obj; | |
+ ret.source = obj; | |
if (define_property.hasPropertyAccessors) { | |
@@ -17240,10 +17537,11 @@ | |
} | |
- obj["__ember_meta__"] = ret; | |
+ obj['__ember_meta__'] = ret; | |
} | |
return ret; | |
} | |
+ | |
function getMeta(obj, property) { | |
var _meta = meta(obj, false); | |
return _meta[property]; | |
@@ -17255,24 +17553,53 @@ | |
return value; | |
} | |
+ /** | |
+ @deprecated | |
+ @private | |
+ | |
+ In order to store defaults for a class, a prototype may need to create | |
+ a default meta object, which will be inherited by any objects instantiated | |
+ from the class's constructor. | |
+ | |
+ However, the properties of that meta object are only shallow-cloned, | |
+ so if a property is a hash (like the event system's `listeners` hash), | |
+ it will by default be shared across all instances of that class. | |
+ | |
+ This method allows extensions to deeply clone a series of nested hashes or | |
+ other complex objects. For instance, the event system might pass | |
+ `['listeners', 'foo:change', 'ember157']` to `prepareMetaPath`, which will | |
+ walk down the keys provided. | |
+ | |
+ For each key, if the key does not exist, it is created. If it already | |
+ exists and it was inherited from its constructor, the constructor's | |
+ key is cloned. | |
+ | |
+ You can also pass false for `writable`, which will simply return | |
+ undefined if `prepareMetaPath` discovers any part of the path that | |
+ shared or undefined. | |
+ | |
+ @method metaPath | |
+ @for Ember | |
+ @param {Object} obj The object whose meta we are examining | |
+ @param {Array} path An array of keys to walk down | |
+ @param {Boolean} writable whether or not to create a new meta | |
+ (or meta property) if one does not already exist or if it's | |
+ shared with its constructor | |
+ */ | |
function metaPath(obj, path, writable) { | |
Ember['default'].deprecate("Ember.metaPath is deprecated and will be removed from future releases."); | |
var _meta = meta(obj, writable); | |
var keyName, value; | |
- for (var i = 0, l = path.length; i < l; i++) { | |
+ for (var i=0, l=path.length; i<l; i++) { | |
keyName = path[i]; | |
value = _meta[keyName]; | |
if (!value) { | |
- if (!writable) { | |
- return undefined; | |
- } | |
+ if (!writable) { return undefined; } | |
value = _meta[keyName] = { __ember_source__: obj }; | |
} else if (value.__ember_source__ !== obj) { | |
- if (!writable) { | |
- return undefined; | |
- } | |
+ if (!writable) { return undefined; } | |
value = _meta[keyName] = o_create['default'](value); | |
value.__ember_source__ = obj; | |
} | |
@@ -17283,10 +17610,23 @@ | |
return value; | |
} | |
+ /** | |
+ Wraps the passed function so that `this._super` will point to the superFunc | |
+ when the function is invoked. This is the primitive we use to implement | |
+ calls to super. | |
+ | |
+ @private | |
+ @method wrap | |
+ @for Ember | |
+ @param {Function} func The function to call | |
+ @param {Function} superFunc The super function. | |
+ @return {Function} wrapped function. | |
+ */ | |
+ | |
function wrap(func, superFunc) { | |
function superWrapper() { | |
var ret; | |
- var sup = this && this.__nextSuper; | |
+ var sup = this && this.__nextSuper; | |
var length = arguments.length; | |
if (this) { | |
@@ -17352,35 +17692,46 @@ | |
var modulePath, type; | |
if (typeof EmberArray === "undefined") { | |
- modulePath = "ember-runtime/mixins/array"; | |
+ modulePath = 'ember-runtime/mixins/array'; | |
if (Ember['default'].__loader.registry[modulePath]) { | |
- EmberArray = Ember['default'].__loader.require(modulePath)["default"]; | |
+ EmberArray = Ember['default'].__loader.require(modulePath)['default']; | |
} | |
} | |
- if (!obj || obj.setInterval) { | |
- return false; | |
- } | |
- if (Array.isArray && Array.isArray(obj)) { | |
- return true; | |
- } | |
- if (EmberArray && EmberArray.detect(obj)) { | |
- return true; | |
- } | |
+ if (!obj || obj.setInterval) { return false; } | |
+ if (Array.isArray && Array.isArray(obj)) { return true; } | |
+ if (EmberArray && EmberArray.detect(obj)) { return true; } | |
type = typeOf(obj); | |
- if ("array" === type) { | |
- return true; | |
- } | |
- if (obj.length !== undefined && "object" === type) { | |
- return true; | |
- } | |
+ if ('array' === type) { return true; } | |
+ if ((obj.length !== undefined) && 'object' === type) { return true; } | |
return false; | |
} | |
+ | |
+ /** | |
+ Forces the passed object to be part of an array. If the object is already | |
+ an array or array-like, it will return the object. Otherwise, it will add the object to | |
+ an array. If obj is `null` or `undefined`, it will return an empty array. | |
+ | |
+ ```javascript | |
+ Ember.makeArray(); // [] | |
+ Ember.makeArray(null); // [] | |
+ Ember.makeArray(undefined); // [] | |
+ Ember.makeArray('lindsay'); // ['lindsay'] | |
+ Ember.makeArray([1, 2, 42]); // [1, 2, 42] | |
+ | |
+ var controller = Ember.ArrayProxy.create({ content: [] }); | |
+ | |
+ Ember.makeArray(controller) === controller; // true | |
+ ``` | |
+ | |
+ @method makeArray | |
+ @for Ember | |
+ @param {Object} obj the object | |
+ @return {Array} | |
+ */ | |
function makeArray(obj) { | |
- if (obj === null || obj === undefined) { | |
- return []; | |
- } | |
+ if (obj === null || obj === undefined) { return []; } | |
return isArray(obj) ? obj : [obj]; | |
} | |
@@ -17402,8 +17753,28 @@ | |
@return {Boolean} | |
*/ | |
function canInvoke(obj, methodName) { | |
- return !!(obj && typeof obj[methodName] === "function"); | |
+ return !!(obj && typeof obj[methodName] === 'function'); | |
} | |
+ | |
+ /** | |
+ Checks to see if the `methodName` exists on the `obj`, | |
+ and if it does, invokes it with the arguments passed. | |
+ | |
+ ```javascript | |
+ var d = new Date('03/15/2013'); | |
+ | |
+ Ember.tryInvoke(d, 'getTime'); // 1363320000000 | |
+ Ember.tryInvoke(d, 'setFullYear', [2014]); // 1394856000000 | |
+ Ember.tryInvoke(d, 'noSuchMethod', [2014]); // undefined | |
+ ``` | |
+ | |
+ @method tryInvoke | |
+ @for Ember | |
+ @param {Object} obj The object to check for the method | |
+ @param {String} methodName The method name to check for | |
+ @param {Array} [args] The arguments to pass to the method | |
+ @return {*} the return value of the invoked method or undefined if it cannot be invoked | |
+ */ | |
function tryInvoke(obj, methodName, args) { | |
if (canInvoke(obj, methodName)) { | |
return args ? applyStr(obj, methodName, args) : applyStr(obj, methodName); | |
@@ -17411,13 +17782,14 @@ | |
} | |
// https://github.com/emberjs/ember.js/pull/1617 | |
- var needsFinallyFix = (function () { | |
+ var needsFinallyFix = (function() { | |
var count = 0; | |
try { | |
// jscs:disable | |
- try {} finally { | |
+ try { | |
+ } finally { | |
count++; | |
- throw new Error("needsFinallyFixTest"); | |
+ throw new Error('needsFinallyFixTest'); | |
} | |
// jscs:enable | |
} catch (e) {} | |
@@ -17454,7 +17826,7 @@ | |
var tryFinally; | |
if (needsFinallyFix) { | |
- tryFinally = function (tryable, finalizer, binding) { | |
+ tryFinally = function(tryable, finalizer, binding) { | |
var result, finalResult, finalError; | |
binding = binding || this; | |
@@ -17469,14 +17841,12 @@ | |
} | |
} | |
- if (finalError) { | |
- throw finalError; | |
- } | |
+ if (finalError) { throw finalError; } | |
- return finalResult === undefined ? result : finalResult; | |
+ return (finalResult === undefined) ? result : finalResult; | |
}; | |
} else { | |
- tryFinally = function (tryable, finalizer, binding) { | |
+ tryFinally = function(tryable, finalizer, binding) { | |
var result, finalResult; | |
binding = binding || this; | |
@@ -17487,7 +17857,7 @@ | |
finalResult = finalizer.call(binding); | |
} | |
- return finalResult === undefined ? result : finalResult; | |
+ return (finalResult === undefined) ? result : finalResult; | |
}; | |
} | |
@@ -17532,14 +17902,14 @@ | |
*/ | |
var tryCatchFinally; | |
if (needsFinallyFix) { | |
- tryCatchFinally = function (tryable, catchable, finalizer, binding) { | |
+ tryCatchFinally = function(tryable, catchable, finalizer, binding) { | |
var result, finalResult, finalError; | |
binding = binding || this; | |
try { | |
result = tryable.call(binding); | |
- } catch (error) { | |
+ } catch(error) { | |
result = catchable.call(binding, error); | |
} finally { | |
try { | |
@@ -17549,27 +17919,25 @@ | |
} | |
} | |
- if (finalError) { | |
- throw finalError; | |
- } | |
+ if (finalError) { throw finalError; } | |
- return finalResult === undefined ? result : finalResult; | |
+ return (finalResult === undefined) ? result : finalResult; | |
}; | |
} else { | |
- tryCatchFinally = function (tryable, catchable, finalizer, binding) { | |
+ tryCatchFinally = function(tryable, catchable, finalizer, binding) { | |
var result, finalResult; | |
binding = binding || this; | |
try { | |
result = tryable.call(binding); | |
- } catch (error) { | |
+ } catch(error) { | |
result = catchable.call(binding, error); | |
} finally { | |
finalResult = finalizer.call(binding); | |
} | |
- return finalResult === undefined ? result : finalResult; | |
+ return (finalResult === undefined) ? result : finalResult; | |
}; | |
} | |
@@ -17579,7 +17947,7 @@ | |
var TYPE_MAP = {}; | |
var t = "Boolean Number String Function Array Date RegExp Object".split(" "); | |
- array.forEach.call(t, function (name) { | |
+ array.forEach.call(t, function(name) { | |
TYPE_MAP["[object " + name + "]"] = name.toLowerCase(); | |
}); | |
@@ -17644,37 +18012,51 @@ | |
// ES6TODO: Depends on Ember.Object which is defined in runtime. | |
if (typeof EmberObject === "undefined") { | |
- modulePath = "ember-runtime/system/object"; | |
+ modulePath = 'ember-runtime/system/object'; | |
if (Ember['default'].__loader.registry[modulePath]) { | |
- EmberObject = Ember['default'].__loader.require(modulePath)["default"]; | |
+ EmberObject = Ember['default'].__loader.require(modulePath)['default']; | |
} | |
} | |
- ret = item === null || item === undefined ? String(item) : TYPE_MAP[toString.call(item)] || "object"; | |
+ ret = (item === null || item === undefined) ? String(item) : TYPE_MAP[toString.call(item)] || 'object'; | |
- if (ret === "function") { | |
+ if (ret === 'function') { | |
if (EmberObject && EmberObject.detect(item)) { | |
- ret = "class"; | |
+ ret = 'class'; | |
} | |
- } else if (ret === "object") { | |
+ } else if (ret === 'object') { | |
if (item instanceof Error) { | |
- ret = "error"; | |
+ ret = 'error'; | |
} else if (EmberObject && item instanceof EmberObject) { | |
- ret = "instance"; | |
+ ret = 'instance'; | |
} else if (item instanceof Date) { | |
- ret = "date"; | |
+ ret = 'date'; | |
} | |
} | |
return ret; | |
} | |
+ | |
+ /** | |
+ Convenience method to inspect an object. This method will attempt to | |
+ convert the object into a useful string description. | |
+ | |
+ It is a pretty simple implementation. If you want something more robust, | |
+ use something like JSDump: https://github.com/NV/jsDump | |
+ | |
+ @method inspect | |
+ @for Ember | |
+ @param {Object} obj The object you want to inspect. | |
+ @return {String} A description of the object | |
+ @since 1.4.0 | |
+ */ | |
function inspect(obj) { | |
var type = typeOf(obj); | |
- if (type === "array") { | |
- return "[" + obj + "]"; | |
+ if (type === 'array') { | |
+ return '[' + obj + ']'; | |
} | |
- if (type !== "object") { | |
- return obj + ""; | |
+ if (type !== 'object') { | |
+ return obj + ''; | |
} | |
var v; | |
@@ -17682,14 +18064,10 @@ | |
for (var key in obj) { | |
if (obj.hasOwnProperty(key)) { | |
v = obj[key]; | |
- if (v === "toString") { | |
- continue; | |
- } // ignore useless items | |
- if (typeOf(v) === "function") { | |
- v = "function() { ... }"; | |
- } | |
+ if (v === 'toString') { continue; } // ignore useless items | |
+ if (typeOf(v) === 'function') { v = "function() { ... }"; } | |
- if (v && typeof v.toString !== "function") { | |
+ if (v && typeof v.toString !== 'function') { | |
ret.push(key + ": " + toString.call(v)); | |
} else { | |
ret.push(key + ": " + v); | |
@@ -17699,45 +18077,41 @@ | |
return "{" + ret.join(", ") + "}"; | |
} | |
+ // The following functions are intentionally minified to keep the functions | |
+ // below Chrome's function body size inlining limit of 600 chars. | |
+ /** | |
+ @param {Object} target | |
+ @param {Function} method | |
+ @param {Array} args | |
+ */ | |
function apply(t, m, a) { | |
var l = a && a.length; | |
- if (!a || !l) { | |
- return m.call(t); | |
- } | |
+ if (!a || !l) { return m.call(t); } | |
switch (l) { | |
- case 1: | |
- return m.call(t, a[0]); | |
- case 2: | |
- return m.call(t, a[0], a[1]); | |
- case 3: | |
- return m.call(t, a[0], a[1], a[2]); | |
- case 4: | |
- return m.call(t, a[0], a[1], a[2], a[3]); | |
- case 5: | |
- return m.call(t, a[0], a[1], a[2], a[3], a[4]); | |
- default: | |
- return m.apply(t, a); | |
+ case 1: return m.call(t, a[0]); | |
+ case 2: return m.call(t, a[0], a[1]); | |
+ case 3: return m.call(t, a[0], a[1], a[2]); | |
+ case 4: return m.call(t, a[0], a[1], a[2], a[3]); | |
+ case 5: return m.call(t, a[0], a[1], a[2], a[3], a[4]); | |
+ default: return m.apply(t, a); | |
} | |
} | |
+ /** | |
+ @param {Object} target | |
+ @param {String} method | |
+ @param {Array} args | |
+ */ | |
function applyStr(t, m, a) { | |
var l = a && a.length; | |
- if (!a || !l) { | |
- return t[m](); | |
- } | |
+ if (!a || !l) { return t[m](); } | |
switch (l) { | |
- case 1: | |
- return t[m](a[0]); | |
- case 2: | |
- return t[m](a[0], a[1]); | |
- case 3: | |
- return t[m](a[0], a[1], a[2]); | |
- case 4: | |
- return t[m](a[0], a[1], a[2], a[3]); | |
- case 5: | |
- return t[m](a[0], a[1], a[2], a[3], a[4]); | |
- default: | |
- return t[m].apply(t, a); | |
+ case 1: return t[m](a[0]); | |
+ case 2: return t[m](a[0], a[1]); | |
+ case 3: return t[m](a[0], a[1], a[2]); | |
+ case 4: return t[m](a[0], a[1], a[2], a[3]); | |
+ case 5: return t[m](a[0], a[1], a[2], a[3], a[4]); | |
+ default: return t[m].apply(t, a); | |
} | |
} | |
@@ -17761,9 +18135,7 @@ | |
function watchKey(obj, keyName, meta) { | |
// can't watch length on Array - it is special... | |
- if (keyName === "length" && utils.typeOf(obj) === "array") { | |
- return; | |
- } | |
+ if (keyName === 'length' && utils.typeOf(obj) === 'array') { return; } | |
var m = meta || utils.meta(obj); | |
var watching = m.watching; | |
@@ -17773,12 +18145,10 @@ | |
watching[keyName] = 1; | |
var possibleDesc = obj[keyName]; | |
- var desc = possibleDesc !== null && typeof possibleDesc === "object" && possibleDesc.isDescriptor ? possibleDesc : undefined; | |
- if (desc && desc.willWatch) { | |
- desc.willWatch(obj, keyName); | |
- } | |
+ var desc = (possibleDesc !== null && typeof possibleDesc === 'object' && possibleDesc.isDescriptor) ? possibleDesc : undefined; | |
+ if (desc && desc.willWatch) { desc.willWatch(obj, keyName); } | |
- if ("function" === typeof obj.willWatchProperty) { | |
+ if ('function' === typeof obj.willWatchProperty) { | |
obj.willWatchProperty(keyName); | |
} | |
@@ -17792,18 +18162,17 @@ | |
} | |
} | |
+ | |
var handleMandatorySetter = function handleMandatorySetter(m, obj, keyName) { | |
var descriptor = Object.getOwnPropertyDescriptor && Object.getOwnPropertyDescriptor(obj, keyName); | |
var configurable = descriptor ? descriptor.configurable : true; | |
var isWritable = descriptor ? descriptor.writable : true; | |
- var hasValue = descriptor ? "value" in descriptor : true; | |
+ var hasValue = descriptor ? 'value' in descriptor : true; | |
var possibleDesc = descriptor && descriptor.value; | |
- var isDescriptor = possibleDesc !== null && typeof possibleDesc === "object" && possibleDesc.isDescriptor; | |
+ var isDescriptor = possibleDesc !== null && typeof possibleDesc === 'object' && possibleDesc.isDescriptor; | |
- if (isDescriptor) { | |
- return; | |
- } | |
+ if (isDescriptor) { return; } | |
// this x in Y deopts, so keeping it in this function is better; | |
if (configurable && isWritable && hasValue && keyName in obj) { | |
@@ -17817,6 +18186,7 @@ | |
} | |
}; | |
+ | |
function unwatchKey(obj, keyName, meta) { | |
var m = meta || utils.meta(obj); | |
var watching = m.watching; | |
@@ -17825,12 +18195,10 @@ | |
watching[keyName] = 0; | |
var possibleDesc = obj[keyName]; | |
- var desc = possibleDesc !== null && typeof possibleDesc === "object" && possibleDesc.isDescriptor ? possibleDesc : undefined; | |
- if (desc && desc.didUnwatch) { | |
- desc.didUnwatch(obj, keyName); | |
- } | |
+ var desc = (possibleDesc !== null && typeof possibleDesc === 'object' && possibleDesc.isDescriptor) ? possibleDesc : undefined; | |
+ if (desc && desc.didUnwatch) { desc.didUnwatch(obj, keyName); } | |
- if ("function" === typeof obj.didUnwatchProperty) { | |
+ if ('function' === typeof obj.didUnwatchProperty) { | |
obj.didUnwatchProperty(keyName); | |
} | |
@@ -17839,7 +18207,7 @@ | |
define_property.defineProperty(obj, keyName, { | |
configurable: true, | |
enumerable: Object.prototype.propertyIsEnumerable.call(obj, keyName), | |
- set: function (val) { | |
+ set: function(val) { | |
// redefine to set as enumerable | |
define_property.defineProperty(obj, keyName, { | |
configurable: true, | |
@@ -17876,17 +18244,15 @@ | |
} | |
return ret; | |
} | |
+ | |
function watchPath(obj, keyPath, meta) { | |
// can't watch length on Array - it is special... | |
- if (keyPath === "length" && utils.typeOf(obj) === "array") { | |
- return; | |
- } | |
+ if (keyPath === 'length' && utils.typeOf(obj) === 'array') { return; } | |
var m = meta || utils.meta(obj); | |
var watching = m.watching; | |
- if (!watching[keyPath]) { | |
- // activate watching first time | |
+ if (!watching[keyPath]) { // activate watching first time | |
watching[keyPath] = 1; | |
chainsFor(obj, m).add(keyPath); | |
} else { | |
@@ -17911,16 +18277,18 @@ | |
'use strict'; | |
+ exports.watch = watch; | |
exports.isWatching = isWatching; | |
exports.unwatch = unwatch; | |
exports.destroy = destroy; | |
- exports.watch = watch; | |
+ | |
+ /** | |
+ @module ember-metal | |
+ */ | |
function watch(obj, _keyPath, m) { | |
// can't watch length on Array - it is special... | |
- if (_keyPath === "length" && utils.typeOf(obj) === "array") { | |
- return; | |
- } | |
+ if (_keyPath === 'length' && utils.typeOf(obj) === 'array') { return; } | |
if (!path_cache.isPath(_keyPath)) { | |
watch_key.watchKey(obj, _keyPath, m); | |
@@ -17930,16 +18298,15 @@ | |
} | |
function isWatching(obj, key) { | |
- var meta = obj["__ember_meta__"]; | |
+ var meta = obj['__ember_meta__']; | |
return (meta && meta.watching[key]) > 0; | |
} | |
watch.flushPending = chains.flushPendingChains; | |
+ | |
function unwatch(obj, _keyPath, m) { | |
// can't watch length on Array - it is special... | |
- if (_keyPath === "length" && utils.typeOf(obj) === "array") { | |
- return; | |
- } | |
+ if (_keyPath === 'length' && utils.typeOf(obj) === 'array') { return; } | |
if (!path_cache.isPath(_keyPath)) { | |
watch_key.unwatchKey(obj, _keyPath, m); | |
@@ -17949,12 +18316,22 @@ | |
} | |
var NODE_STACK = []; | |
+ | |
+ /** | |
+ Tears down the meta on an object so that it can be garbage collected. | |
+ Multiple calls will have no effect. | |
+ | |
+ @method destroy | |
+ @for Ember | |
+ @param {Object} obj the object to destroy | |
+ @return {void} | |
+ */ | |
function destroy(obj) { | |
- var meta = obj["__ember_meta__"]; | |
+ var meta = obj['__ember_meta__']; | |
var node, nodes, key, nodeObject; | |
if (meta) { | |
- obj["__ember_meta__"] = null; | |
+ obj['__ember_meta__'] = null; | |
// remove chainWatchers to remove circular references that would prevent GC | |
node = meta.chains; | |
if (node) { | |
@@ -17986,24 +18363,24 @@ | |
}); | |
enifed('ember-routing-htmlbars', ['exports', 'ember-metal/core', 'ember-htmlbars/helpers', 'ember-routing-htmlbars/helpers/outlet', 'ember-routing-htmlbars/helpers/render', 'ember-routing-htmlbars/helpers/link-to', 'ember-routing-htmlbars/helpers/action', 'ember-routing-htmlbars/helpers/query-params'], function (exports, Ember, helpers, outlet, render, link_to, action, query_params) { | |
- 'use strict'; | |
+ 'use strict'; | |
- /** | |
- Ember Routing HTMLBars Helpers | |
+ /** | |
+ Ember Routing HTMLBars Helpers | |
- @module ember | |
- @submodule ember-routing-htmlbars | |
- @requires ember-routing | |
- */ | |
+ @module ember | |
+ @submodule ember-routing-htmlbars | |
+ @requires ember-routing | |
+ */ | |
- helpers.registerHelper("outlet", outlet.outletHelper); | |
- helpers.registerHelper("render", render.renderHelper); | |
- helpers.registerHelper("link-to", link_to.linkToHelper); | |
- helpers.registerHelper("linkTo", link_to.deprecatedLinkToHelper); | |
- helpers.registerHelper("action", action.actionHelper); | |
- helpers.registerHelper("query-params", query_params.queryParamsHelper); | |
+ helpers.registerHelper('outlet', outlet.outletHelper); | |
+ helpers.registerHelper('render', render.renderHelper); | |
+ helpers.registerHelper('link-to', link_to.linkToHelper); | |
+ helpers.registerHelper('linkTo', link_to.deprecatedLinkToHelper); | |
+ helpers.registerHelper('action', action.actionHelper); | |
+ helpers.registerHelper('query-params', query_params.queryParamsHelper); | |
- exports['default'] = Ember['default']; | |
+ exports['default'] = Ember['default']; | |
}); | |
enifed('ember-routing-htmlbars/helpers/action', ['exports', 'ember-metal/core', 'ember-metal/utils', 'ember-metal/run_loop', 'ember-views/streams/utils', 'ember-views/system/utils', 'ember-views/system/action_manager', 'ember-metal/streams/utils'], function (exports, Ember, utils, run, streams__utils, system__utils, ActionManager, ember_metal__streams__utils) { | |
@@ -18013,6 +18390,113 @@ | |
exports.actionHelper = actionHelper; | |
/** | |
+ @module ember | |
+ @submodule ember-routing-htmlbars | |
+ */ | |
+ | |
+ function actionArgs(parameters, actionName) { | |
+ var ret, i, l; | |
+ | |
+ if (actionName === undefined) { | |
+ ret = new Array(parameters.length); | |
+ for (i=0, l=parameters.length;i<l;i++) { | |
+ ret[i] = streams__utils.readUnwrappedModel(parameters[i]); | |
+ } | |
+ } else { | |
+ ret = new Array(parameters.length + 1); | |
+ ret[0] = actionName; | |
+ for (i=0, l=parameters.length;i<l; i++) { | |
+ ret[i + 1] = streams__utils.readUnwrappedModel(parameters[i]); | |
+ } | |
+ } | |
+ | |
+ return ret; | |
+ } | |
+ | |
+ var ActionHelper = {}; | |
+ | |
+ // registeredActions is re-exported for compatibility with older plugins | |
+ // that were using this undocumented API. | |
+ ActionHelper.registeredActions = ActionManager['default'].registeredActions; | |
+ | |
+ var keys = ["alt", "shift", "meta", "ctrl"]; | |
+ | |
+ var POINTER_EVENT_TYPE_REGEX = /^click|mouse|touch/; | |
+ | |
+ var isAllowedEvent = function(event, allowedKeys) { | |
+ if (typeof allowedKeys === "undefined") { | |
+ if (POINTER_EVENT_TYPE_REGEX.test(event.type)) { | |
+ return system__utils.isSimpleClick(event); | |
+ } else { | |
+ allowedKeys = ''; | |
+ } | |
+ } | |
+ | |
+ if (allowedKeys.indexOf("any") >= 0) { | |
+ return true; | |
+ } | |
+ | |
+ for (var i=0, l=keys.length;i<l;i++) { | |
+ if (event[keys[i] + "Key"] && allowedKeys.indexOf(keys[i]) === -1) { | |
+ return false; | |
+ } | |
+ } | |
+ | |
+ return true; | |
+ }; | |
+ | |
+ ActionHelper.registerAction = function(actionNameOrStream, options, allowedKeys) { | |
+ var actionId = utils.uuid(); | |
+ var eventName = options.eventName; | |
+ var parameters = options.parameters; | |
+ | |
+ ActionManager['default'].registeredActions[actionId] = { | |
+ eventName: eventName, | |
+ handler: function handleRegisteredAction(event) { | |
+ if (!isAllowedEvent(event, allowedKeys)) { return true; } | |
+ | |
+ if (options.preventDefault !== false) { | |
+ event.preventDefault(); | |
+ } | |
+ | |
+ if (options.bubbles === false) { | |
+ event.stopPropagation(); | |
+ } | |
+ | |
+ var target = options.target.value(); | |
+ | |
+ var actionName; | |
+ | |
+ if (ember_metal__streams__utils.isStream(actionNameOrStream)) { | |
+ actionName = actionNameOrStream.value(); | |
+ | |
+ Ember['default'].assert("You specified a quoteless path to the {{action}} helper " + | |
+ "which did not resolve to an action name (a string). " + | |
+ "Perhaps you meant to use a quoted actionName? (e.g. {{action 'save'}}).", | |
+ typeof actionName === 'string'); | |
+ } else { | |
+ actionName = actionNameOrStream; | |
+ } | |
+ | |
+ run['default'](function runRegisteredAction() { | |
+ if (target.send) { | |
+ target.send.apply(target, actionArgs(parameters, actionName)); | |
+ } else { | |
+ Ember['default'].assert("The action '" + actionName + "' did not exist on " + target, typeof target[actionName] === 'function'); | |
+ target[actionName].apply(target, actionArgs(parameters)); | |
+ } | |
+ }); | |
+ } | |
+ }; | |
+ | |
+ options.view.on('willClearRender', function() { | |
+ delete ActionManager['default'].registeredActions[actionId]; | |
+ }); | |
+ | |
+ return actionId; | |
+ }; | |
+ | |
+ /** | |
The `{{action}}` helper provides a useful shortcut for registering an HTML | |
element within a template for a single DOM event and forwarding that | |
interaction to the template's controller or specified `target` option. | |
@@ -18174,112 +18658,12 @@ | |
@param {String} actionName | |
@param {Object} [context]* | |
@param {Hash} options | |
- */ | |
- function actionArgs(parameters, actionName) { | |
- var ret, i, l; | |
- | |
- if (actionName === undefined) { | |
- ret = new Array(parameters.length); | |
- for (i = 0, l = parameters.length; i < l; i++) { | |
- ret[i] = streams__utils.readUnwrappedModel(parameters[i]); | |
- } | |
- } else { | |
- ret = new Array(parameters.length + 1); | |
- ret[0] = actionName; | |
- for (i = 0, l = parameters.length; i < l; i++) { | |
- ret[i + 1] = streams__utils.readUnwrappedModel(parameters[i]); | |
- } | |
- } | |
- | |
- return ret; | |
- } | |
- | |
- var ActionHelper = {}; | |
- | |
- // registeredActions is re-exported for compatibility with older plugins | |
- // that were using this undocumented API. | |
- ActionHelper.registeredActions = ActionManager['default'].registeredActions; | |
- | |
- var keys = ["alt", "shift", "meta", "ctrl"]; | |
- | |
- var POINTER_EVENT_TYPE_REGEX = /^click|mouse|touch/; | |
- | |
- var isAllowedEvent = function (event, allowedKeys) { | |
- if (typeof allowedKeys === "undefined") { | |
- if (POINTER_EVENT_TYPE_REGEX.test(event.type)) { | |
- return system__utils.isSimpleClick(event); | |
- } else { | |
- allowedKeys = ""; | |
- } | |
- } | |
- | |
- if (allowedKeys.indexOf("any") >= 0) { | |
- return true; | |
- } | |
- | |
- for (var i = 0, l = keys.length; i < l; i++) { | |
- if (event[keys[i] + "Key"] && allowedKeys.indexOf(keys[i]) === -1) { | |
- return false; | |
- } | |
- } | |
- | |
- return true; | |
- }; | |
- | |
- ActionHelper.registerAction = function (actionNameOrStream, options, allowedKeys) { | |
- var actionId = utils.uuid(); | |
- var eventName = options.eventName; | |
- var parameters = options.parameters; | |
- | |
- ActionManager['default'].registeredActions[actionId] = { | |
- eventName: eventName, | |
- handler: function handleRegisteredAction(event) { | |
- if (!isAllowedEvent(event, allowedKeys)) { | |
- return true; | |
- } | |
- | |
- if (options.preventDefault !== false) { | |
- event.preventDefault(); | |
- } | |
- | |
- if (options.bubbles === false) { | |
- event.stopPropagation(); | |
- } | |
- | |
- var target = options.target.value(); | |
- | |
- var actionName; | |
- | |
- if (ember_metal__streams__utils.isStream(actionNameOrStream)) { | |
- actionName = actionNameOrStream.value(); | |
- | |
- Ember['default'].assert("You specified a quoteless path to the {{action}} helper " + "which did not resolve to an action name (a string). " + "Perhaps you meant to use a quoted actionName? (e.g. {{action 'save'}}).", typeof actionName === "string"); | |
- } else { | |
- actionName = actionNameOrStream; | |
- } | |
- | |
- run['default'](function runRegisteredAction() { | |
- if (target.send) { | |
- target.send.apply(target, actionArgs(parameters, actionName)); | |
- } else { | |
- Ember['default'].assert("The action '" + actionName + "' did not exist on " + target, typeof target[actionName] === "function"); | |
- target[actionName].apply(target, actionArgs(parameters)); | |
- } | |
- }); | |
- } | |
- }; | |
- | |
- options.view.on("willClearRender", function () { | |
- delete ActionManager['default'].registeredActions[actionId]; | |
- }); | |
- | |
- return actionId; | |
- }; | |
+ */ | |
function actionHelper(params, hash, options, env) { | |
var view = env.data.view; | |
var target; | |
if (!hash.target) { | |
- target = view.getStream("controller"); | |
+ target = view.getStream('controller'); | |
} else if (ember_metal__streams__utils.isStream(hash.target)) { | |
target = hash.target; | |
} else { | |
@@ -18300,7 +18684,7 @@ | |
}; | |
var actionId = ActionHelper.registerAction(params[0], actionOptions, hash.allowedKeys); | |
- env.dom.setAttribute(options.element, "data-ember-action", actionId); | |
+ env.dom.setAttribute(options.element, 'data-ember-action', actionId); | |
} | |
exports.ActionHelper = ActionHelper; | |
@@ -18354,9 +18738,9 @@ | |
if (!lazyValue._isController) { | |
while (ControllerMixin['default'].detect(lazyValue.value())) { | |
- Ember['default'].deprecate("Providing `{{link-to}}` with a param that is wrapped in a controller is deprecated. Please update `" + view + "` to use `{{link-to \"post\" someController.model}}` instead."); | |
+ Ember['default'].deprecate('Providing `{{link-to}}` with a param that is wrapped in a controller is deprecated. Please update `' + view + '` to use `{{link-to "post" someController.model}}` instead.'); | |
- lazyValue = lazyValue.get("model"); | |
+ lazyValue = lazyValue.get('model'); | |
} | |
} | |
@@ -18366,7 +18750,7 @@ | |
hash.params = params; | |
- options.helperName = options.helperName || "link-to"; | |
+ options.helperName = options.helperName || 'link-to'; | |
return env.helpers.view.helperFunction.call(this, [link.LinkView], hash, options, env); | |
} | |
@@ -18384,7 +18768,7 @@ | |
function deprecatedLinkToHelper(params, hash, options, env) { | |
Ember['default'].deprecate("The 'linkTo' view helper is deprecated in favor of 'link-to'"); | |
- return env.helpers["link-to"].helperFunction.call(this, params, hash, options, env); | |
+ return env.helpers['link-to'].helperFunction.call(this, params, hash, options, env); | |
} | |
}); | |
@@ -18394,93 +18778,44 @@ | |
exports.outletHelper = outletHelper; | |
- // assert | |
- | |
/** | |
- The `outlet` helper is a placeholder that the router will fill in with | |
- the appropriate template based on the current state of the application. | |
- | |
- ``` handlebars | |
- {{outlet}} | |
- ``` | |
- | |
- By default, a template based on Ember's naming conventions will be rendered | |
- into the `outlet` (e.g. `App.PostsRoute` will render the `posts` template). | |
- | |
- You can render a different template by using the `render()` method in the | |
- route's `renderTemplate` hook. The following will render the `favoritePost` | |
- template into the `outlet`. | |
- | |
- ``` javascript | |
- App.PostsRoute = Ember.Route.extend({ | |
- renderTemplate: function() { | |
- this.render('favoritePost'); | |
- } | |
- }); | |
- ``` | |
- | |
- You can create custom named outlets for more control. | |
- | |
- ``` handlebars | |
- {{outlet 'favoritePost'}} | |
- {{outlet 'posts'}} | |
- ``` | |
- | |
- Then you can define what template is rendered into each outlet in your | |
- route. | |
- | |
- | |
- ``` javascript | |
- App.PostsRoute = Ember.Route.extend({ | |
- renderTemplate: function() { | |
- this.render('favoritePost', { outlet: 'favoritePost' }); | |
- this.render('posts', { outlet: 'posts' }); | |
- } | |
- }); | |
- ``` | |
- | |
- You can specify the view that the outlet uses to contain and manage the | |
- templates rendered into it. | |
- | |
- ``` handlebars | |
- {{outlet view='sectionContainer'}} | |
- ``` | |
- | |
- ``` javascript | |
- App.SectionContainer = Ember.ContainerView.extend({ | |
- tagName: 'section', | |
- classNames: ['special'] | |
- }); | |
- ``` | |
- | |
- @method outlet | |
- @for Ember.Handlebars.helpers | |
- @param {String} property the property on the controller | |
- that holds the view for this outlet | |
- @return {String} HTML string | |
+ @module ember | |
+ @submodule ember-routing-htmlbars | |
*/ | |
+ | |
function outletHelper(params, hash, options, env) { | |
var viewName; | |
var viewClass; | |
var viewFullName; | |
var view = env.data.view; | |
- Ember['default'].assert("Using {{outlet}} with an unquoted name is not supported.", params.length === 0 || typeof params[0] === "string"); | |
+ Ember['default'].assert( | |
+ "Using {{outlet}} with an unquoted name is not supported.", | |
+ params.length === 0 || typeof params[0] === 'string' | |
+ ); | |
+ | |
+ var property = params[0] || 'main'; | |
- var property = params[0] || "main"; | |
// provide controller override | |
viewName = hash.view; | |
if (viewName) { | |
- viewFullName = "view:" + viewName; | |
- Ember['default'].assert("Using a quoteless view parameter with {{outlet}} is not supported." + " Please update to quoted usage '{{outlet ... view=\"" + viewName + "\"}}.", typeof hash.view === "string"); | |
- Ember['default'].assert("The view name you supplied '" + viewName + "' did not resolve to a view.", view.container._registry.has(viewFullName)); | |
+ viewFullName = 'view:' + viewName; | |
+ Ember['default'].assert( | |
+ "Using a quoteless view parameter with {{outlet}} is not supported." + | |
+ " Please update to quoted usage '{{outlet ... view=\"" + viewName + "\"}}.", | |
+ typeof hash.view === 'string' | |
+ ); | |
+ Ember['default'].assert( | |
+ "The view name you supplied '" + viewName + "' did not resolve to a view.", | |
+ view.container._registry.has(viewFullName) | |
+ ); | |
} | |
- viewClass = viewName ? view.container.lookupFactory(viewFullName) : hash.viewClass || view.container.lookupFactory("view:-outlet"); | |
+ viewClass = viewName ? view.container.lookupFactory(viewFullName) : hash.viewClass || view.container.lookupFactory('view:-outlet'); | |
hash._outletName = property; | |
- options.helperName = options.helperName || "outlet"; | |
+ options.helperName = options.helperName || 'outlet'; | |
return env.helpers.view.helperFunction.call(this, [viewClass], hash, options, env); | |
} | |
@@ -18492,18 +18827,10 @@ | |
exports.queryParamsHelper = queryParamsHelper; | |
/** | |
- This is a sub-expression to be used in conjunction with the link-to helper. | |
- It will supply url query parameters to the target route. | |
- | |
- Example | |
- | |
- {{#link-to 'posts' (query-params direction="asc")}}Sort{{/link-to}} | |
- | |
- @method query-params | |
- @for Ember.Handlebars.helpers | |
- @param {Object} hash takes a hash of query parameters | |
- @return {String} HTML string | |
+ @module ember | |
+ @submodule ember-routing-htmlbars | |
*/ | |
+ | |
function queryParamsHelper(params, hash) { | |
Ember['default'].assert("The `query-params` helper only accepts hash parameters, e.g. (query-params queryParamPropertyName='foo') as opposed to just (query-params 'foo')", params.length === 0); | |
@@ -18520,75 +18847,10 @@ | |
exports.renderHelper = renderHelper; | |
/** | |
- Calling ``{{render}}`` from within a template will insert another | |
- template that matches the provided name. The inserted template will | |
- access its properties on its own controller (rather than the controller | |
- of the parent template). | |
- | |
- If a view class with the same name exists, the view class also will be used. | |
- | |
- Note: A given controller may only be used *once* in your app in this manner. | |
- A singleton instance of the controller will be created for you. | |
- | |
- Example: | |
- | |
- ```javascript | |
- App.NavigationController = Ember.Controller.extend({ | |
- who: "world" | |
- }); | |
- ``` | |
- | |
- ```handlebars | |
- <!-- navigation.hbs --> | |
- Hello, {{who}}. | |
- ``` | |
- | |
- ```handlebars | |
- <!-- application.hbs --> | |
- <h1>My great app</h1> | |
- {{render "navigation"}} | |
- ``` | |
- | |
- ```html | |
- <h1>My great app</h1> | |
- <div class='ember-view'> | |
- Hello, world. | |
- </div> | |
- ``` | |
- | |
- Optionally you may provide a second argument: a property path | |
- that will be bound to the `model` property of the controller. | |
- | |
- If a `model` property path is specified, then a new instance of the | |
- controller will be created and `{{render}}` can be used multiple times | |
- with the same name. | |
- | |
- For example if you had this `author` template. | |
- | |
- ```handlebars | |
- <div class="author"> | |
- Written by {{firstName}} {{lastName}}. | |
- Total Posts: {{postCount}} | |
- </div> | |
- ``` | |
- | |
- You could render it inside the `post` template using the `render` helper. | |
- | |
- ```handlebars | |
- <div class="post"> | |
- <h1>{{title}}</h1> | |
- <div>{{body}}</div> | |
- {{render "author" author}} | |
- </div> | |
- ``` | |
- | |
- @method render | |
- @for Ember.Handlebars.helpers | |
- @param {String} name | |
- @param {Object?} context | |
- @param {Hash} options | |
- @return {String} HTML string | |
+ @module ember | |
+ @submodule ember-routing-htmlbars | |
*/ | |
+ | |
function renderHelper(params, hash, options, env) { | |
var currentView = env.data.view; | |
var container, router, controller, view, initialContext; | |
@@ -18597,15 +18859,26 @@ | |
var context = params[1]; | |
container = currentView._keywords.controller.value().container; | |
- router = container.lookup("router:main"); | |
+ router = container.lookup('router:main'); | |
- Ember['default'].assert("The first argument of {{render}} must be quoted, e.g. {{render \"sidebar\"}}.", typeof name === "string"); | |
+ Ember['default'].assert( | |
+ "The first argument of {{render}} must be quoted, e.g. {{render \"sidebar\"}}.", | |
+ typeof name === 'string' | |
+ ); | |
+ | |
+ Ember['default'].assert( | |
+ "The second argument of {{render}} must be a path, e.g. {{render \"post\" post}}.", | |
+ params.length < 2 || utils.isStream(params[1]) | |
+ ); | |
- Ember['default'].assert("The second argument of {{render}} must be a path, e.g. {{render \"post\" post}}.", params.length < 2 || utils.isStream(params[1])); | |
if (params.length === 1) { | |
// use the singleton controller | |
- Ember['default'].assert("You can only use the {{render}} helper once without a model object as " + "its second argument, as in {{render \"post\" post}}.", !router || !router._lookupActiveView(name)); | |
+ Ember['default'].assert( | |
+ "You can only use the {{render}} helper once without a model object as " + | |
+ "its second argument, as in {{render \"post\" post}}.", | |
+ !router || !router._lookupActiveView(name) | |
+ ); | |
} else if (params.length === 2) { | |
// create a new controller | |
initialContext = context.value(); | |
@@ -18614,18 +18887,22 @@ | |
} | |
// # legacy namespace | |
- name = name.replace(/\//g, "."); | |
+ name = name.replace(/\//g, '.'); | |
// \ legacy slash as namespace support | |
- var templateName = "template:" + name; | |
- Ember['default'].assert("You used `{{render '" + name + "'}}`, but '" + name + "' can not be " + "found as either a template or a view.", container._registry.has("view:" + name) || container._registry.has(templateName) || !!options.template); | |
+ var templateName = 'template:' + name; | |
+ Ember['default'].assert( | |
+ "You used `{{render '" + name + "'}}`, but '" + name + "' can not be " + | |
+ "found as either a template or a view.", | |
+ container._registry.has("view:" + name) || container._registry.has(templateName) || !!options.template | |
+ ); | |
var template = options.template; | |
- view = container.lookup("view:" + name); | |
+ view = container.lookup('view:' + name); | |
if (!view) { | |
- view = container.lookup("view:default"); | |
+ view = container.lookup('view:default'); | |
} | |
- var viewHasTemplateSpecified = !!property_get.get(view, "template"); | |
+ var viewHasTemplateSpecified = !!property_get.get(view, 'template'); | |
if (!viewHasTemplateSpecified) { | |
template = template || container.lookup(templateName); | |
} | |
@@ -18636,20 +18913,25 @@ | |
if (hash.controller) { | |
controllerName = hash.controller; | |
- controllerFullName = "controller:" + controllerName; | |
+ controllerFullName = 'controller:' + controllerName; | |
delete hash.controller; | |
- Ember['default'].assert("The controller name you supplied '" + controllerName + "' " + "did not resolve to a controller.", container._registry.has(controllerFullName)); | |
+ Ember['default'].assert( | |
+ "The controller name you supplied '" + controllerName + "' " + | |
+ "did not resolve to a controller.", | |
+ container._registry.has(controllerFullName) | |
+ ); | |
} else { | |
controllerName = name; | |
- controllerFullName = "controller:" + controllerName; | |
+ controllerFullName = 'controller:' + controllerName; | |
} | |
var parentController = currentView._keywords.controller.value(); | |
// choose name | |
if (params.length > 1) { | |
- var factory = container.lookupFactory(controllerFullName) || generate_controller.generateControllerFactory(container, controllerName, initialContext); | |
+ var factory = container.lookupFactory(controllerFullName) || | |
+ generate_controller.generateControllerFactory(container, controllerName, initialContext); | |
controller = factory.create({ | |
modelBinding: context, // TODO: Use a StreamBinding | |
@@ -18657,11 +18939,12 @@ | |
target: parentController | |
}); | |
- view.one("willDestroyElement", function () { | |
+ view.one('willDestroyElement', function() { | |
controller.destroy(); | |
}); | |
} else { | |
- controller = container.lookup(controllerFullName) || generate_controller.generateController(container, controllerName); | |
+ controller = container.lookup(controllerFullName) || | |
+ generate_controller["default"](container, controllerName); | |
controller.setProperties({ | |
target: parentController, | |
@@ -18678,7 +18961,7 @@ | |
var props = { | |
template: template, | |
controller: controller, | |
- helperName: "render \"" + name + "\"" | |
+ helperName: 'render "' + name + '"' | |
}; | |
impersonateAnOutlet(currentView, view, name); | |
@@ -18691,20 +18974,20 @@ | |
function impersonateAnOutlet(currentView, view, name) { | |
view._childOutlets = Ember['default'].A(); | |
view._isOutlet = true; | |
- view._outletName = "__ember_orphans__"; | |
+ view._outletName = '__ember_orphans__'; | |
view._matchOutletName = name; | |
- view._parentOutlet = function () { | |
+ view._parentOutlet = function() { | |
var parent = this._parentView; | |
while (parent && !parent._isOutlet) { | |
parent = parent._parentView; | |
} | |
return parent; | |
}; | |
- view.setOutletState = function (state) { | |
+ view.setOutletState = function(state) { | |
var ownState; | |
if (state && (ownState = state.outlets[this._matchOutletName])) { | |
this._outletState = { | |
- render: { name: "render helper stub" }, | |
+ render: { name: 'render helper stub' }, | |
outlets: create['default'](null) | |
}; | |
this._outletState.outlets[ownState.render.outlet] = ownState; | |
@@ -18765,7 +19048,7 @@ | |
@submodule ember-routing-views | |
*/ | |
- var numberOfContextsAcceptedByHandler = function (handler, handlerInfos) { | |
+ var numberOfContextsAcceptedByHandler = function(handler, handlerInfos) { | |
var req = 0; | |
for (var i = 0, l = handlerInfos.length; i < l; i++) { | |
req = req + handlerInfos[i].names.length; | |
@@ -18777,9 +19060,9 @@ | |
return req; | |
}; | |
- var linkViewClassNameBindings = ["active", "loading", "disabled"]; | |
+ var linkViewClassNameBindings = ['active', 'loading', 'disabled']; | |
- linkViewClassNameBindings = ["active", "loading", "disabled", "transitioningIn", "transitioningOut"]; | |
+ linkViewClassNameBindings = ['active', 'loading', 'disabled', 'transitioningIn', 'transitioningOut']; | |
/** | |
@@ -18797,7 +19080,7 @@ | |
@see {Handlebars.helpers.link-to} | |
**/ | |
var LinkView = EmberComponent['default'].extend({ | |
- tagName: "a", | |
+ tagName: 'a', | |
/** | |
@deprecated Use current-when instead. | |
@@ -18807,34 +19090,39 @@ | |
/** | |
Used to determine when this LinkView is active. | |
- @property currentWhen | |
+ | |
+ @property currentWhen | |
*/ | |
- "current-when": null, | |
+ 'current-when': null, | |
/** | |
Sets the `title` attribute of the `LinkView`'s HTML element. | |
- @property title | |
+ | |
+ @property title | |
@default null | |
**/ | |
title: null, | |
/** | |
Sets the `rel` attribute of the `LinkView`'s HTML element. | |
- @property rel | |
+ | |
+ @property rel | |
@default null | |
**/ | |
rel: null, | |
/** | |
Sets the `tabindex` attribute of the `LinkView`'s HTML element. | |
- @property tabindex | |
+ | |
+ @property tabindex | |
@default null | |
**/ | |
tabindex: null, | |
/** | |
Sets the `target` attribute of the `LinkView`'s HTML element. | |
- @since 1.8.0 | |
+ | |
+ @since 1.8.0 | |
@property target | |
@default null | |
**/ | |
@@ -18843,35 +19131,39 @@ | |
/** | |
The CSS class to apply to `LinkView`'s element when its `active` | |
property is `true`. | |
- @property activeClass | |
+ | |
+ @property activeClass | |
@type String | |
@default active | |
**/ | |
- activeClass: "active", | |
+ activeClass: 'active', | |
/** | |
The CSS class to apply to `LinkView`'s element when its `loading` | |
property is `true`. | |
- @property loadingClass | |
+ | |
+ @property loadingClass | |
@type String | |
@default loading | |
**/ | |
- loadingClass: "loading", | |
+ loadingClass: 'loading', | |
/** | |
The CSS class to apply to a `LinkView`'s element when its `disabled` | |
property is `true`. | |
- @property disabledClass | |
+ | |
+ @property disabledClass | |
@type String | |
@default disabled | |
**/ | |
- disabledClass: "disabled", | |
+ disabledClass: 'disabled', | |
_isDisabled: false, | |
/** | |
Determines whether the `LinkView` will trigger routing via | |
the `replaceWith` routing strategy. | |
- @property replace | |
+ | |
+ @property replace | |
@type Boolean | |
@default false | |
**/ | |
@@ -18881,16 +19173,18 @@ | |
By default the `{{link-to}}` helper will bind to the `href` and | |
`title` attributes. It's discouraged that you override these defaults, | |
however you can push onto the array if needed. | |
- @property attributeBindings | |
+ | |
+ @property attributeBindings | |
@type Array | String | |
@default ['href', 'title', 'rel', 'tabindex', 'target'] | |
**/ | |
- attributeBindings: ["href", "title", "rel", "tabindex", "target"], | |
+ attributeBindings: ['href', 'title', 'rel', 'tabindex', 'target'], | |
/** | |
By default the `{{link-to}}` helper will bind to the `active`, `loading`, and | |
`disabled` classes. It is discouraged to override these directly. | |
- @property classNameBindings | |
+ | |
+ @property classNameBindings | |
@type Array | |
@default ['active', 'loading', 'disabled'] | |
**/ | |
@@ -18900,13 +19194,15 @@ | |
By default the `{{link-to}}` helper responds to the `click` event. You | |
can override this globally by setting this property to your custom | |
event name. | |
- This is particularly useful on mobile when one wants to avoid the 300ms | |
+ | |
+ This is particularly useful on mobile when one wants to avoid the 300ms | |
click delay using some sort of custom `tap` event. | |
- @property eventName | |
+ | |
+ @property eventName | |
@type String | |
@default click | |
*/ | |
- eventName: "click", | |
+ eventName: 'click', | |
// this is doc'ed here so it shows up in the events | |
// section of the API documentation, which is where | |
@@ -18916,13 +19212,16 @@ | |
`eventName` is changed to a value other than `click` | |
the routing behavior will trigger on that custom event | |
instead. | |
- @event click | |
+ | |
+ @event click | |
**/ | |
/** | |
An overridable method called when LinkView objects are instantiated. | |
- Example: | |
- ```javascript | |
+ | |
+ Example: | |
+ | |
+ ```javascript | |
App.MyLinkView = Ember.LinkView.extend({ | |
init: function() { | |
this._super.apply(this, arguments); | |
@@ -18930,41 +19229,48 @@ | |
} | |
}); | |
``` | |
- NOTE: If you do override `init` for a framework class like `Ember.View` or | |
+ | |
+ NOTE: If you do override `init` for a framework class like `Ember.View` or | |
`Ember.ArrayController`, be sure to call `this._super.apply(this, arguments)` in your | |
`init` declaration! If you don't, Ember may not have an opportunity to | |
do important setup work, and you'll see strange behavior in your | |
application. | |
- @method init | |
+ | |
+ @method init | |
*/ | |
- init: function () { | |
+ init: function() { | |
this._super.apply(this, arguments); | |
- Ember['default'].deprecate("Using currentWhen with {{link-to}} is deprecated in favor of `current-when`.", !this.currentWhen); | |
+ Ember['default'].deprecate( | |
+ 'Using currentWhen with {{link-to}} is deprecated in favor of `current-when`.', | |
+ !this.currentWhen | |
+ ); | |
// Map desired event name to invoke function | |
- var eventName = property_get.get(this, "eventName"); | |
+ var eventName = property_get.get(this, 'eventName'); | |
this.on(eventName, this, this._invoke); | |
}, | |
/** | |
This method is invoked by observers installed during `init` that fire | |
whenever the params change | |
- @private | |
+ | |
+ @private | |
@method _paramsChanged | |
@since 1.3.0 | |
*/ | |
- _paramsChanged: function () { | |
- this.notifyPropertyChange("resolvedParams"); | |
+ _paramsChanged: function() { | |
+ this.notifyPropertyChange('resolvedParams'); | |
}, | |
/** | |
This is called to setup observers that will trigger a rerender. | |
- @private | |
+ | |
+ @private | |
@method _setupPathObservers | |
@since 1.3.0 | |
**/ | |
- _setupPathObservers: function () { | |
+ _setupPathObservers: function() { | |
var params = this.params; | |
var scheduledParamsChanged = this._wrapAsScheduled(this._paramsChanged); | |
@@ -18986,143 +19292,132 @@ | |
} | |
}, | |
- afterRender: function () { | |
+ afterRender: function() { | |
this._super.apply(this, arguments); | |
this._setupPathObservers(); | |
}, | |
/** | |
- Accessed as a classname binding to apply the `LinkView`'s `disabledClass` | |
+ | |
+ Accessed as a classname binding to apply the `LinkView`'s `disabledClass` | |
CSS `class` to the element when the link is disabled. | |
- When `true` interactions with the element will not trigger route changes. | |
+ | |
+ When `true` interactions with the element will not trigger route changes. | |
@property disabled | |
*/ | |
disabled: computed.computed(function computeLinkViewDisabled(key, value) { | |
- if (value !== undefined) { | |
- this.set("_isDisabled", value); | |
- } | |
+ if (value !== undefined) { this.set('_isDisabled', value); } | |
- return value ? property_get.get(this, "disabledClass") : false; | |
+ return value ? property_get.get(this, 'disabledClass') : false; | |
}), | |
/** | |
Accessed as a classname binding to apply the `LinkView`'s `activeClass` | |
CSS `class` to the element when the link is active. | |
- A `LinkView` is considered active when its `currentWhen` property is `true` | |
+ | |
+ A `LinkView` is considered active when its `currentWhen` property is `true` | |
or the application's current route is the route the `LinkView` would trigger | |
transitions into. | |
- The `currentWhen` property can match against multiple routes by separating | |
+ | |
+ The `currentWhen` property can match against multiple routes by separating | |
route names using the ` ` (space) character. | |
- @property active | |
+ | |
+ @property active | |
**/ | |
- active: computed.computed("loadedParams", function computeLinkViewActive() { | |
- var router = property_get.get(this, "router"); | |
- if (!router) { | |
- return; | |
- } | |
+ active: computed.computed('loadedParams', function computeLinkViewActive() { | |
+ var router = property_get.get(this, 'router'); | |
+ if (!router) { return; } | |
return computeActive(this, router.currentState); | |
}), | |
- willBeActive: computed.computed("router.targetState", function () { | |
- var router = property_get.get(this, "router"); | |
- if (!router) { | |
- return; | |
- } | |
+ willBeActive: computed.computed('router.targetState', function() { | |
+ var router = property_get.get(this, 'router'); | |
+ if (!router) { return; } | |
var targetState = router.targetState; | |
- if (router.currentState === targetState) { | |
- return; | |
- } | |
+ if (router.currentState === targetState) { return; } | |
return !!computeActive(this, targetState); | |
}), | |
- transitioningIn: computed.computed("active", "willBeActive", function () { | |
- var willBeActive = property_get.get(this, "willBeActive"); | |
- if (typeof willBeActive === "undefined") { | |
- return false; | |
- } | |
+ transitioningIn: computed.computed('active', 'willBeActive', function() { | |
+ var willBeActive = property_get.get(this, 'willBeActive'); | |
+ if (typeof willBeActive === 'undefined') { return false; } | |
- return !property_get.get(this, "active") && willBeActive && "ember-transitioning-in"; | |
+ return !property_get.get(this, 'active') && willBeActive && 'ember-transitioning-in'; | |
}), | |
- transitioningOut: computed.computed("active", "willBeActive", function () { | |
- var willBeActive = property_get.get(this, "willBeActive"); | |
- if (typeof willBeActive === "undefined") { | |
- return false; | |
- } | |
+ transitioningOut: computed.computed('active', 'willBeActive', function() { | |
+ var willBeActive = property_get.get(this, 'willBeActive'); | |
+ if (typeof willBeActive === 'undefined') { return false; } | |
- return property_get.get(this, "active") && !willBeActive && "ember-transitioning-out"; | |
+ return property_get.get(this, 'active') && !willBeActive && 'ember-transitioning-out'; | |
}), | |
/** | |
Accessed as a classname binding to apply the `LinkView`'s `loadingClass` | |
CSS `class` to the element when the link is loading. | |
- A `LinkView` is considered loading when it has at least one | |
+ | |
+ A `LinkView` is considered loading when it has at least one | |
parameter whose value is currently null or undefined. During | |
this time, clicking the link will perform no transition and | |
emit a warning that the link is still in a loading state. | |
- @property loading | |
+ | |
+ @property loading | |
**/ | |
- loading: computed.computed("loadedParams", function computeLinkViewLoading() { | |
- if (!property_get.get(this, "loadedParams")) { | |
- return property_get.get(this, "loadingClass"); | |
- } | |
+ loading: computed.computed('loadedParams', function computeLinkViewLoading() { | |
+ if (!property_get.get(this, 'loadedParams')) { return property_get.get(this, 'loadingClass'); } | |
}), | |
/** | |
Returns the application's main router from the container. | |
- @private | |
+ | |
+ @private | |
@property router | |
**/ | |
- router: computed.computed(function () { | |
- var controller = property_get.get(this, "controller"); | |
+ router: computed.computed(function() { | |
+ var controller = property_get.get(this, 'controller'); | |
if (controller && controller.container) { | |
- return controller.container.lookup("router:main"); | |
+ return controller.container.lookup('router:main'); | |
} | |
}), | |
/** | |
Event handler that invokes the link, activating the associated route. | |
- @private | |
+ | |
+ @private | |
@method _invoke | |
@param {Event} event | |
*/ | |
- _invoke: function (event) { | |
- if (!utils.isSimpleClick(event)) { | |
- return true; | |
- } | |
+ _invoke: function(event) { | |
+ if (!utils.isSimpleClick(event)) { return true; } | |
if (this.preventDefault !== false) { | |
- var targetAttribute = property_get.get(this, "target"); | |
- if (!targetAttribute || targetAttribute === "_self") { | |
+ var targetAttribute = property_get.get(this, 'target'); | |
+ if (!targetAttribute || targetAttribute === '_self') { | |
event.preventDefault(); | |
} | |
} | |
- if (this.bubbles === false) { | |
- event.stopPropagation(); | |
- } | |
+ if (this.bubbles === false) { event.stopPropagation(); } | |
- if (property_get.get(this, "_isDisabled")) { | |
- return false; | |
- } | |
+ if (property_get.get(this, '_isDisabled')) { return false; } | |
- if (property_get.get(this, "loading")) { | |
+ if (property_get.get(this, 'loading')) { | |
Ember['default'].Logger.warn("This link-to is in an inactive loading state because at least one of its parameters presently has a null/undefined value, or the provided route name is invalid."); | |
return false; | |
} | |
- var targetAttribute2 = property_get.get(this, "target"); | |
- if (targetAttribute2 && targetAttribute2 !== "_self") { | |
+ var targetAttribute2 = property_get.get(this, 'target'); | |
+ if (targetAttribute2 && targetAttribute2 !== '_self') { | |
return false; | |
} | |
- var router = property_get.get(this, "router"); | |
- var loadedParams = property_get.get(this, "loadedParams"); | |
+ var router = property_get.get(this, 'router'); | |
+ var loadedParams = property_get.get(this, 'loadedParams'); | |
var transition = router._doTransition(loadedParams.targetRouteName, loadedParams.models, loadedParams.queryParams); | |
- if (property_get.get(this, "replace")) { | |
- transition.method("replace"); | |
+ if (property_get.get(this, 'replace')) { | |
+ transition.method('replace'); | |
} | |
@@ -19138,7 +19433,7 @@ | |
var args = ember_routing__utils.routeArgs(loadedParams.targetRouteName, loadedParams.models, transition.state.queryParams); | |
var url = router.router.generate.apply(router.router, args); | |
- run['default'].scheduleOnce("routerTransitions", this, this._eagerUpdateUrl, transition, url); | |
+ run['default'].scheduleOnce('routerTransitions', this, this._eagerUpdateUrl, transition, url); | |
}, | |
/** | |
@@ -19147,22 +19442,22 @@ | |
@param transition | |
@param href | |
*/ | |
- _eagerUpdateUrl: function (transition, href) { | |
+ _eagerUpdateUrl: function(transition, href) { | |
if (!transition.isActive || !transition.urlMethod) { | |
// transition was aborted, already ran to completion, | |
// or it has a null url-updated method. | |
return; | |
} | |
- if (href.indexOf("#") === 0) { | |
+ if (href.indexOf('#') === 0) { | |
href = href.slice(1); | |
} | |
// Re-use the routerjs hooks set up by the Ember router. | |
- var routerjs = property_get.get(this, "router.router"); | |
- if (transition.urlMethod === "update") { | |
+ var routerjs = property_get.get(this, 'router.router'); | |
+ if (transition.urlMethod === 'update') { | |
routerjs.updateURL(href); | |
- } else if (transition.urlMethod === "replace") { | |
+ } else if (transition.urlMethod === 'replace') { | |
routerjs.replaceURL(href); | |
} | |
@@ -19174,26 +19469,30 @@ | |
Computed property that returns an array of the | |
resolved parameters passed to the `link-to` helper, | |
e.g.: | |
- ```hbs | |
+ | |
+ ```hbs | |
{{link-to a b '123' c}} | |
``` | |
- will generate a `resolvedParams` of: | |
- ```js | |
+ | |
+ will generate a `resolvedParams` of: | |
+ | |
+ ```js | |
[aObject, bObject, '123', cObject] | |
``` | |
- @private | |
+ | |
+ @private | |
@property | |
@return {Array} | |
*/ | |
- resolvedParams: computed.computed("router.url", function () { | |
+ resolvedParams: computed.computed('router.url', function() { | |
var params = this.params; | |
var targetRouteName; | |
var models = []; | |
- var onlyQueryParamsSupplied = params.length === 0; | |
+ var onlyQueryParamsSupplied = (params.length === 0); | |
if (onlyQueryParamsSupplied) { | |
- var appController = this.container.lookup("controller:application"); | |
- targetRouteName = property_get.get(appController, "currentRouteName"); | |
+ var appController = this.container.lookup('controller:application'); | |
+ targetRouteName = property_get.get(appController, 'currentRouteName'); | |
} else { | |
targetRouteName = streams__utils.read(params[0]); | |
@@ -19216,28 +19515,26 @@ | |
dynamic segments, and query params. Returns falsy if | |
for null/undefined params to indicate that the link view | |
is still in a loading state. | |
- @private | |
+ | |
+ @private | |
@property | |
@return {Array} An array with the route name and any dynamic segments | |
**/ | |
- loadedParams: computed.computed("resolvedParams", function computeLinkViewRouteArgs() { | |
- var router = property_get.get(this, "router"); | |
- if (!router) { | |
- return; | |
- } | |
+ loadedParams: computed.computed('resolvedParams', function computeLinkViewRouteArgs() { | |
+ var router = property_get.get(this, 'router'); | |
+ if (!router) { return; } | |
- var resolvedParams = property_get.get(this, "resolvedParams"); | |
+ var resolvedParams = property_get.get(this, 'resolvedParams'); | |
var namedRoute = resolvedParams.targetRouteName; | |
- if (!namedRoute) { | |
- return; | |
- } | |
+ if (!namedRoute) { return; } | |
- Ember['default'].assert(string.fmt("The attempt to link-to route '%@' failed. " + "The router did not find '%@' in its possible routes: '%@'", [namedRoute, namedRoute, keys['default'](router.router.recognizer.names).join("', '")]), router.hasRoute(namedRoute)); | |
+ Ember['default'].assert(string.fmt("The attempt to link-to route '%@' failed. " + | |
+ "The router did not find '%@' in its possible routes: '%@'", | |
+ [namedRoute, namedRoute, keys['default'](router.router.recognizer.names).join("', '")]), | |
+ router.hasRoute(namedRoute)); | |
- if (!paramsAreLoaded(resolvedParams.models)) { | |
- return; | |
- } | |
+ if (!paramsAreLoaded(resolvedParams.models)) { return; } | |
return resolvedParams; | |
}), | |
@@ -19247,20 +19544,20 @@ | |
/** | |
Sets the element's `href` attribute to the url for | |
the `LinkView`'s targeted route. | |
- If the `LinkView`'s `tagName` is changed to a value other | |
+ | |
+ If the `LinkView`'s `tagName` is changed to a value other | |
than `a`, this property will be ignored. | |
- @property href | |
+ | |
+ @property href | |
**/ | |
- href: computed.computed("loadedParams", function computeLinkViewHref() { | |
- if (property_get.get(this, "tagName") !== "a") { | |
- return; | |
- } | |
+ href: computed.computed('loadedParams', function computeLinkViewHref() { | |
+ if (property_get.get(this, 'tagName') !== 'a') { return; } | |
- var router = property_get.get(this, "router"); | |
- var loadedParams = property_get.get(this, "loadedParams"); | |
+ var router = property_get.get(this, 'router'); | |
+ var loadedParams = property_get.get(this, 'loadedParams'); | |
if (!loadedParams) { | |
- return property_get.get(this, "loadingHref"); | |
+ return property_get.get(this, 'loadingHref'); | |
} | |
var visibleQueryParams = {}; | |
@@ -19275,30 +19572,25 @@ | |
/** | |
The default href value to use while a link-to is loading. | |
Only applies when tagName is 'a' | |
- @property loadingHref | |
+ | |
+ @property loadingHref | |
@type String | |
@default # | |
*/ | |
- loadingHref: "#" | |
+ loadingHref: '#' | |
}); | |
- LinkView.toString = function () { | |
- return "LinkView"; | |
- }; | |
+ LinkView.toString = function() { return "LinkView"; }; | |
function getResolvedQueryParams(linkView, targetRouteName) { | |
var queryParamsObject = linkView.queryParamsObject; | |
var resolvedQueryParams = {}; | |
- if (!queryParamsObject) { | |
- return resolvedQueryParams; | |
- } | |
+ if (!queryParamsObject) { return resolvedQueryParams; } | |
var values = queryParamsObject.values; | |
for (var key in values) { | |
- if (!values.hasOwnProperty(key)) { | |
- continue; | |
- } | |
+ if (!values.hasOwnProperty(key)) { continue; } | |
resolvedQueryParams[key] = streams__utils.read(values[key]); | |
} | |
@@ -19308,7 +19600,7 @@ | |
function paramsAreLoaded(params) { | |
for (var i = 0, len = params.length; i < len; ++i) { | |
var param = params[i]; | |
- if (param === null || typeof param === "undefined") { | |
+ if (param === null || typeof param === 'undefined') { | |
return false; | |
} | |
} | |
@@ -19316,17 +19608,15 @@ | |
} | |
function computeActive(route, routerState) { | |
- if (property_get.get(route, "loading")) { | |
- return false; | |
- } | |
+ if (property_get.get(route, 'loading')) { return false; } | |
- var currentWhen = route["current-when"] || route.currentWhen; | |
+ var currentWhen = route['current-when'] || route.currentWhen; | |
var isCurrentWhenSpecified = !!currentWhen; | |
- currentWhen = currentWhen || property_get.get(route, "loadedParams").targetRouteName; | |
- currentWhen = currentWhen.split(" "); | |
+ currentWhen = currentWhen || property_get.get(route, 'loadedParams').targetRouteName; | |
+ currentWhen = currentWhen.split(' '); | |
for (var i = 0, len = currentWhen.length; i < len; i++) { | |
if (isActiveForRoute(route, currentWhen[i], isCurrentWhenSpecified, routerState)) { | |
- return property_get.get(route, "activeClass"); | |
+ return property_get.get(route, 'activeClass'); | |
} | |
} | |
@@ -19334,12 +19624,12 @@ | |
} | |
function isActiveForRoute(route, routeName, isCurrentWhenSpecified, routerState) { | |
- var router = property_get.get(route, "router"); | |
- var loadedParams = property_get.get(route, "loadedParams"); | |
+ var router = property_get.get(route, 'router'); | |
+ var loadedParams = property_get.get(route, 'loadedParams'); | |
var contexts = loadedParams.models; | |
var handlers = router.router.recognizer.handlersFor(routeName); | |
- var leafName = handlers[handlers.length - 1].handler; | |
+ var leafName = handlers[handlers.length-1].handler; | |
var maximumContexts = numberOfContextsAcceptedByHandler(routeName, handlers); | |
// NOTE: any ugliness in the calculation of activeness is largely | |
@@ -19372,7 +19662,7 @@ | |
*/ | |
var CoreOutletView = ContainerView['default'].extend({ | |
- init: function () { | |
+ init: function() { | |
this._super(); | |
this._childOutlets = Ember.A(); | |
this._outletState = null; | |
@@ -19380,7 +19670,7 @@ | |
_isOutlet: true, | |
- _parentOutlet: function () { | |
+ _parentOutlet: function() { | |
var parent = this._parentView; | |
while (parent && !parent._isOutlet) { | |
parent = parent._parentView; | |
@@ -19388,7 +19678,7 @@ | |
return parent; | |
}, | |
- _linkParent: Ember.on("init", "parentViewDidChange", function () { | |
+ _linkParent: Ember.on('init', 'parentViewDidChange', function() { | |
var parent = this._parentOutlet(); | |
if (parent) { | |
parent._childOutlets.push(this); | |
@@ -19398,7 +19688,7 @@ | |
} | |
}), | |
- willDestroy: function () { | |
+ willDestroy: function() { | |
var parent = this._parentOutlet(); | |
if (parent) { | |
parent._childOutlets.removeObject(this); | |
@@ -19406,7 +19696,8 @@ | |
this._super(); | |
}, | |
- _diffState: function (state) { | |
+ | |
+ _diffState: function(state) { | |
while (state && emptyRouteState(state)) { | |
state = state.outlets.main; | |
} | |
@@ -19415,30 +19706,28 @@ | |
return different; | |
}, | |
- setOutletState: function (state) { | |
+ setOutletState: function(state) { | |
if (!this._diffState(state)) { | |
var children = this._childOutlets; | |
- for (var i = 0; i < children.length; i++) { | |
+ for (var i = 0 ; i < children.length; i++) { | |
var child = children[i]; | |
child.setOutletState(this._outletState && this._outletState.outlets[child._outletName]); | |
} | |
} else { | |
var view = this._buildView(this._outletState); | |
- var length = property_get.get(this, "length"); | |
+ var length = property_get.get(this, 'length'); | |
if (view) { | |
this.replace(0, length, [view]); | |
} else { | |
- this.replace(0, length, []); | |
+ this.replace(0, length , []); | |
} | |
} | |
}, | |
- _buildView: function (state) { | |
- if (!state) { | |
- return; | |
- } | |
+ _buildView: function(state) { | |
+ if (!state) { return; } | |
- var LOG_VIEW_LOOKUPS = property_get.get(this, "namespace.LOG_VIEW_LOOKUPS"); | |
+ var LOG_VIEW_LOOKUPS = property_get.get(this, 'namespace.LOG_VIEW_LOOKUPS'); | |
var view; | |
var render = state.render; | |
var ViewClass = render.ViewClass; | |
@@ -19446,7 +19735,7 @@ | |
if (!ViewClass) { | |
isDefaultView = true; | |
- ViewClass = this.container.lookupFactory(this._isTopLevel ? "view:toplevel" : "view:default"); | |
+ ViewClass = this.container.lookupFactory(this._isTopLevel ? 'view:toplevel' : 'view:default'); | |
} | |
view = ViewClass.create({ | |
@@ -19455,12 +19744,12 @@ | |
controller: render.controller | |
}); | |
- if (!property_get.get(view, "template")) { | |
- view.set("template", render.template); | |
+ if (!property_get.get(view, 'template')) { | |
+ view.set('template', render.template); | |
} | |
if (LOG_VIEW_LOOKUPS) { | |
- Ember.Logger.info("Rendering " + render.name + " with " + (render.isDefaultView ? "default view " : "") + view, { fullName: "view:" + render.name }); | |
+ Ember.Logger.info("Rendering " + render.name + " with " + (render.isDefaultView ? "default view " : "") + view, { fullName: 'view:' + render.name }); | |
} | |
return view; | |
@@ -19485,7 +19774,7 @@ | |
// name is only here for logging & debugging. If two different | |
// names result in otherwise identical states, they're still | |
// identical. | |
- if (a[key] !== b[key] && key !== "name") { | |
+ if (a[key] !== b[key] && key !== 'name') { | |
return false; | |
} | |
} | |
@@ -19501,30 +19790,30 @@ | |
}); | |
enifed('ember-routing', ['exports', 'ember-metal/core', 'ember-routing/ext/run_loop', 'ember-routing/ext/controller', 'ember-routing/location/api', 'ember-routing/location/none_location', 'ember-routing/location/hash_location', 'ember-routing/location/history_location', 'ember-routing/location/auto_location', 'ember-routing/system/generate_controller', 'ember-routing/system/controller_for', 'ember-routing/system/dsl', 'ember-routing/system/router', 'ember-routing/system/route'], function (exports, Ember, __dep1__, __dep2__, EmberLocation, NoneLocation, HashLocation, HistoryLocation, AutoLocation, generate_controller, controllerFor, RouterDSL, Router, Route) { | |
- 'use strict'; | |
+ 'use strict'; | |
- /** | |
- Ember Routing | |
+ /** | |
+ Ember Routing | |
- @module ember | |
- @submodule ember-routing | |
- @requires ember-views | |
- */ | |
+ @module ember | |
+ @submodule ember-routing | |
+ @requires ember-views | |
+ */ | |
- Ember['default'].Location = EmberLocation['default']; | |
- Ember['default'].AutoLocation = AutoLocation['default']; | |
- Ember['default'].HashLocation = HashLocation['default']; | |
- Ember['default'].HistoryLocation = HistoryLocation['default']; | |
- Ember['default'].NoneLocation = NoneLocation['default']; | |
- | |
- Ember['default'].controllerFor = controllerFor['default']; | |
- Ember['default'].generateControllerFactory = generate_controller.generateControllerFactory; | |
- Ember['default'].generateController = generate_controller.generateController; | |
- Ember['default'].RouterDSL = RouterDSL['default']; | |
- Ember['default'].Router = Router['default']; | |
- Ember['default'].Route = Route['default']; | |
+ Ember['default'].Location = EmberLocation['default']; | |
+ Ember['default'].AutoLocation = AutoLocation['default']; | |
+ Ember['default'].HashLocation = HashLocation['default']; | |
+ Ember['default'].HistoryLocation = HistoryLocation['default']; | |
+ Ember['default'].NoneLocation = NoneLocation['default']; | |
+ | |
+ Ember['default'].controllerFor = controllerFor['default']; | |
+ Ember['default'].generateControllerFactory = generate_controller.generateControllerFactory; | |
+ Ember['default'].generateController = generate_controller["default"]; | |
+ Ember['default'].RouterDSL = RouterDSL['default']; | |
+ Ember['default'].Router = Router['default']; | |
+ Ember['default'].Route = Route['default']; | |
- exports['default'] = Ember['default']; | |
+ exports['default'] = Ember['default']; | |
}); | |
enifed('ember-routing/ext/controller', ['exports', 'ember-metal/core', 'ember-metal/property_get', 'ember-metal/property_set', 'ember-metal/computed', 'ember-metal/utils', 'ember-metal/merge', 'ember-runtime/mixins/controller'], function (exports, Ember, property_get, property_set, computed, utils, merge, ControllerMixin) { | |
@@ -19532,9 +19821,9 @@ | |
'use strict'; | |
ControllerMixin['default'].reopen({ | |
- concatenatedProperties: ["queryParams", "_pCacheMeta"], | |
+ concatenatedProperties: ['queryParams', '_pCacheMeta'], | |
- init: function () { | |
+ init: function() { | |
this._super.apply(this, arguments); | |
listenForQueryParamChanges(this); | |
}, | |
@@ -19544,7 +19833,8 @@ | |
If you give the names ['category','page'] it will bind | |
the values of these query parameters to the variables | |
`this.category` and `this.page` | |
- @property queryParams | |
+ | |
+ @property queryParams | |
@public | |
*/ | |
queryParams: null, | |
@@ -19559,13 +19849,13 @@ | |
@property _normalizedQueryParams | |
@private | |
*/ | |
- _normalizedQueryParams: computed.computed(function () { | |
+ _normalizedQueryParams: computed.computed(function() { | |
var m = utils.meta(this); | |
if (m.proto !== this) { | |
- return property_get.get(m.proto, "_normalizedQueryParams"); | |
+ return property_get.get(m.proto, '_normalizedQueryParams'); | |
} | |
- var queryParams = property_get.get(this, "queryParams"); | |
+ var queryParams = property_get.get(this, 'queryParams'); | |
if (queryParams._qpMap) { | |
return queryParams._qpMap; | |
} | |
@@ -19583,24 +19873,22 @@ | |
@property _cacheMeta | |
@private | |
*/ | |
- _cacheMeta: computed.computed(function () { | |
+ _cacheMeta: computed.computed(function() { | |
var m = utils.meta(this); | |
if (m.proto !== this) { | |
- return property_get.get(m.proto, "_cacheMeta"); | |
+ return property_get.get(m.proto, '_cacheMeta'); | |
} | |
var cacheMeta = {}; | |
- var qpMap = property_get.get(this, "_normalizedQueryParams"); | |
+ var qpMap = property_get.get(this, '_normalizedQueryParams'); | |
for (var prop in qpMap) { | |
- if (!qpMap.hasOwnProperty(prop)) { | |
- continue; | |
- } | |
+ if (!qpMap.hasOwnProperty(prop)) { continue; } | |
var qp = qpMap[prop]; | |
var scope = qp.scope; | |
var parts; | |
- if (scope === "controller") { | |
+ if (scope === 'controller') { | |
parts = []; | |
} | |
@@ -19620,12 +19908,10 @@ | |
@method _updateCacheParams | |
@private | |
*/ | |
- _updateCacheParams: function (params) { | |
- var cacheMeta = property_get.get(this, "_cacheMeta"); | |
+ _updateCacheParams: function(params) { | |
+ var cacheMeta = property_get.get(this, '_cacheMeta'); | |
for (var prop in cacheMeta) { | |
- if (!cacheMeta.hasOwnProperty(prop)) { | |
- continue; | |
- } | |
+ if (!cacheMeta.hasOwnProperty(prop)) { continue; } | |
var propMeta = cacheMeta[prop]; | |
propMeta.values = params; | |
@@ -19643,9 +19929,9 @@ | |
@method _qpChanged | |
@private | |
*/ | |
- _qpChanged: function (controller, _prop) { | |
- var prop = _prop.substr(0, _prop.length - 3); | |
- var cacheMeta = property_get.get(controller, "_cacheMeta"); | |
+ _qpChanged: function(controller, _prop) { | |
+ var prop = _prop.substr(0, _prop.length-3); | |
+ var cacheMeta = property_get.get(controller, '_cacheMeta'); | |
var propCache = cacheMeta[prop]; | |
var cacheKey = controller._calculateCacheKey(propCache.prefix || "", propCache.parts, propCache.values); | |
var value = property_get.get(controller, prop); | |
@@ -19667,7 +19953,7 @@ | |
@method _calculateCacheKey | |
@private | |
*/ | |
- _calculateCacheKey: function (prefix, _parts, values) { | |
+ _calculateCacheKey: function(prefix, _parts, values) { | |
var parts = _parts || []; | |
var suffixes = ""; | |
for (var i = 0, len = parts.length; i < len; ++i) { | |
@@ -19675,58 +19961,73 @@ | |
var value = property_get.get(values, part); | |
suffixes += "::" + part + ":" + value; | |
} | |
- return prefix + suffixes.replace(ALL_PERIODS_REGEX, "-"); | |
+ return prefix + suffixes.replace(ALL_PERIODS_REGEX, '-'); | |
}, | |
/** | |
Transition the application into another route. The route may | |
be either a single route or route path: | |
- ```javascript | |
+ | |
+ ```javascript | |
aController.transitionToRoute('blogPosts'); | |
aController.transitionToRoute('blogPosts.recentEntries'); | |
``` | |
- Optionally supply a model for the route in question. The model | |
+ | |
+ Optionally supply a model for the route in question. The model | |
will be serialized into the URL using the `serialize` hook of | |
the route: | |
- ```javascript | |
+ | |
+ ```javascript | |
aController.transitionToRoute('blogPost', aPost); | |
``` | |
- If a literal is passed (such as a number or a string), it will | |
+ | |
+ If a literal is passed (such as a number or a string), it will | |
be treated as an identifier instead. In this case, the `model` | |
hook of the route will be triggered: | |
- ```javascript | |
+ | |
+ ```javascript | |
aController.transitionToRoute('blogPost', 1); | |
``` | |
- Multiple models will be applied last to first recursively up the | |
+ | |
+ Multiple models will be applied last to first recursively up the | |
resource tree. | |
- ```javascript | |
+ | |
+ ```javascript | |
App.Router.map(function() { | |
this.resource('blogPost', {path:':blogPostId'}, function() { | |
this.resource('blogComment', {path: ':blogCommentId'}); | |
}); | |
}); | |
- aController.transitionToRoute('blogComment', aPost, aComment); | |
+ | |
+ aController.transitionToRoute('blogComment', aPost, aComment); | |
aController.transitionToRoute('blogComment', 1, 13); | |
``` | |
- It is also possible to pass a URL (a string that starts with a | |
+ | |
+ It is also possible to pass a URL (a string that starts with a | |
`/`). This is intended for testing and debugging purposes and | |
should rarely be used in production code. | |
- ```javascript | |
+ | |
+ ```javascript | |
aController.transitionToRoute('/'); | |
aController.transitionToRoute('/blog/post/1/comment/13'); | |
aController.transitionToRoute('/blog/posts?sort=title'); | |
``` | |
- An options hash with a `queryParams` property may be provided as | |
+ | |
+ An options hash with a `queryParams` property may be provided as | |
the final argument to add query parameters to the destination URL. | |
- ```javascript | |
+ | |
+ ```javascript | |
aController.transitionToRoute('blogPost', 1, { | |
queryParams: {showComments: 'true'} | |
}); | |
- // if you just want to transition the query parameters without changing the route | |
+ | |
+ // if you just want to transition the query parameters without changing the route | |
aController.transitionToRoute({queryParams: {sort: 'date'}}); | |
``` | |
- See also [replaceRoute](/api/classes/Ember.ControllerMixin.html#method_replaceRoute). | |
- @param {String} name the name of the route or a URL | |
+ | |
+ See also [replaceRoute](/api/classes/Ember.ControllerMixin.html#method_replaceRoute). | |
+ | |
+ @param {String} name the name of the route or a URL | |
@param {...Object} models the model(s) or identifier(s) to be used | |
while transitioning to the route. | |
@param {Object} [options] optional hash with a queryParams property | |
@@ -19734,9 +20035,9 @@ | |
@for Ember.ControllerMixin | |
@method transitionToRoute | |
*/ | |
- transitionToRoute: function () { | |
+ transitionToRoute: function() { | |
// target may be either another controller or a router | |
- var target = property_get.get(this, "target"); | |
+ var target = property_get.get(this, 'target'); | |
var method = target.transitionToRoute || target.transitionTo; | |
return method.apply(target, arguments); | |
}, | |
@@ -19746,7 +20047,7 @@ | |
@for Ember.ControllerMixin | |
@method transitionTo | |
*/ | |
- transitionTo: function () { | |
+ transitionTo: function() { | |
Ember['default'].deprecate("transitionTo is deprecated. Please use transitionToRoute."); | |
return this.transitionToRoute.apply(this, arguments); | |
}, | |
@@ -19755,49 +20056,60 @@ | |
Transition into another route while replacing the current URL, if possible. | |
This will replace the current history entry instead of adding a new one. | |
Beside that, it is identical to `transitionToRoute` in all other respects. | |
- ```javascript | |
+ | |
+ ```javascript | |
aController.replaceRoute('blogPosts'); | |
aController.replaceRoute('blogPosts.recentEntries'); | |
``` | |
- Optionally supply a model for the route in question. The model | |
+ | |
+ Optionally supply a model for the route in question. The model | |
will be serialized into the URL using the `serialize` hook of | |
the route: | |
- ```javascript | |
+ | |
+ ```javascript | |
aController.replaceRoute('blogPost', aPost); | |
``` | |
- If a literal is passed (such as a number or a string), it will | |
+ | |
+ If a literal is passed (such as a number or a string), it will | |
be treated as an identifier instead. In this case, the `model` | |
hook of the route will be triggered: | |
- ```javascript | |
+ | |
+ ```javascript | |
aController.replaceRoute('blogPost', 1); | |
``` | |
- Multiple models will be applied last to first recursively up the | |
+ | |
+ Multiple models will be applied last to first recursively up the | |
resource tree. | |
- ```javascript | |
+ | |
+ ```javascript | |
App.Router.map(function() { | |
this.resource('blogPost', {path:':blogPostId'}, function() { | |
this.resource('blogComment', {path: ':blogCommentId'}); | |
}); | |
}); | |
- aController.replaceRoute('blogComment', aPost, aComment); | |
+ | |
+ aController.replaceRoute('blogComment', aPost, aComment); | |
aController.replaceRoute('blogComment', 1, 13); | |
``` | |
- It is also possible to pass a URL (a string that starts with a | |
+ | |
+ It is also possible to pass a URL (a string that starts with a | |
`/`). This is intended for testing and debugging purposes and | |
should rarely be used in production code. | |
- ```javascript | |
+ | |
+ ```javascript | |
aController.replaceRoute('/'); | |
aController.replaceRoute('/blog/post/1/comment/13'); | |
``` | |
- @param {String} name the name of the route or a URL | |
+ | |
+ @param {String} name the name of the route or a URL | |
@param {...Object} models the model(s) or identifier(s) to be used | |
while transitioning to the route. | |
@for Ember.ControllerMixin | |
@method replaceRoute | |
*/ | |
- replaceRoute: function () { | |
+ replaceRoute: function() { | |
// target may be either another controller or a router | |
- var target = property_get.get(this, "target"); | |
+ var target = property_get.get(this, 'target'); | |
var method = target.replaceRoute || target.replaceWith; | |
return method.apply(target, arguments); | |
}, | |
@@ -19807,7 +20119,7 @@ | |
@for Ember.ControllerMixin | |
@method replaceWith | |
*/ | |
- replaceWith: function () { | |
+ replaceWith: function() { | |
Ember['default'].deprecate("replaceWith is deprecated. Please use replaceRoute."); | |
return this.replaceRoute.apply(this, arguments); | |
} | |
@@ -19818,23 +20130,21 @@ | |
function accumulateQueryParamDescriptors(_desc, accum) { | |
var desc = _desc; | |
var tmp; | |
- if (utils.typeOf(desc) === "string") { | |
+ if (utils.typeOf(desc) === 'string') { | |
tmp = {}; | |
tmp[desc] = { as: null }; | |
desc = tmp; | |
} | |
for (var key in desc) { | |
- if (!desc.hasOwnProperty(key)) { | |
- return; | |
- } | |
+ if (!desc.hasOwnProperty(key)) { return; } | |
var singleDesc = desc[key]; | |
- if (utils.typeOf(singleDesc) === "string") { | |
+ if (utils.typeOf(singleDesc) === 'string') { | |
singleDesc = { as: singleDesc }; | |
} | |
- tmp = accum[key] || { as: null, scope: "model" }; | |
+ tmp = accum[key] || { as: null, scope: 'model' }; | |
merge['default'](tmp, singleDesc); | |
accum[key] = tmp; | |
@@ -19842,15 +20152,14 @@ | |
} | |
function listenForQueryParamChanges(controller) { | |
- var qpMap = property_get.get(controller, "_normalizedQueryParams"); | |
+ var qpMap = property_get.get(controller, '_normalizedQueryParams'); | |
for (var prop in qpMap) { | |
- if (!qpMap.hasOwnProperty(prop)) { | |
- continue; | |
- } | |
- controller.addObserver(prop + ".[]", controller, controller._qpChanged); | |
+ if (!qpMap.hasOwnProperty(prop)) { continue; } | |
+ controller.addObserver(prop + '.[]', controller, controller._qpChanged); | |
} | |
} | |
+ | |
exports['default'] = ControllerMixin['default']; | |
}); | |
@@ -19858,7 +20167,7 @@ | |
'use strict'; | |
- run['default']._addQueue("routerTransitions", "actions"); | |
+ run['default']._addQueue('routerTransitions', 'actions'); | |
}); | |
enifed('ember-routing/location/api', ['exports', 'ember-metal/core', 'ember-metal/environment'], function (exports, Ember, environment) { | |
@@ -19869,20 +20178,24 @@ | |
/** | |
This is deprecated in favor of using the container to lookup the location | |
implementation as desired. | |
- For example: | |
- ```javascript | |
+ | |
+ For example: | |
+ | |
+ ```javascript | |
// Given a location registered as follows: | |
container.register('location:history-test', HistoryTestLocation); | |
- // You could create a new instance via: | |
+ | |
+ // You could create a new instance via: | |
container.lookup('location:history-test'); | |
``` | |
- @method create | |
+ | |
+ @method create | |
@param {Object} options | |
@return {Object} an instance of an implementation of the `location` API | |
@deprecated Use the container to lookup the location implementation that you | |
need. | |
*/ | |
- create: function (options) { | |
+ create: function(options) { | |
var implementation = options && options.implementation; | |
Ember['default'].assert("Ember.Location.create: you must specify a 'implementation' option", !!implementation); | |
@@ -19895,23 +20208,28 @@ | |
/** | |
This is deprecated in favor of using the container to register the | |
location implementation as desired. | |
- Example: | |
- ```javascript | |
+ | |
+ Example: | |
+ | |
+ ```javascript | |
Application.initializer({ | |
name: "history-test-location", | |
- initialize: function(container, application) { | |
+ | |
+ initialize: function(container, application) { | |
application.register('location:history-test', HistoryTestLocation); | |
} | |
}); | |
``` | |
- @method registerImplementation | |
+ | |
+ @method registerImplementation | |
@param {String} name | |
@param {Object} implementation of the `location` API | |
@deprecated Register your custom location implementation with the | |
container directly. | |
*/ | |
- registerImplementation: function (name, implementation) { | |
- Ember['default'].deprecate("Using the Ember.Location.registerImplementation is no longer supported." + " Register your custom location implementation with the container instead."); | |
+ registerImplementation: function(name, implementation) { | |
+ Ember['default'].deprecate('Using the Ember.Location.registerImplementation is no longer supported.' + | |
+ ' Register your custom location implementation with the container instead.'); | |
this.implementations[name] = implementation; | |
}, | |
@@ -19922,8 +20240,10 @@ | |
/** | |
Returns the current `location.hash` by parsing location.href since browsers | |
inconsistently URL-decode `location.hash`. | |
- https://bugzilla.mozilla.org/show_bug.cgi?id=483304 | |
- @private | |
+ | |
+ https://bugzilla.mozilla.org/show_bug.cgi?id=483304 | |
+ | |
+ @private | |
@method getHash | |
@since 1.4.0 | |
*/ | |
@@ -19931,10 +20251,10 @@ | |
// AutoLocation has it at _location, HashLocation at .location. | |
// Being nice and not changing | |
var href = (this._location || this.location).href; | |
- var hashIndex = href.indexOf("#"); | |
+ var hashIndex = href.indexOf('#'); | |
if (hashIndex === -1) { | |
- return ""; | |
+ return ''; | |
} else { | |
return href.substr(hashIndex); | |
} | |
@@ -19949,16 +20269,20 @@ | |
exports['default'] = { | |
/** | |
@private | |
- Attached for mocking in tests | |
- @property location | |
+ | |
+ Attached for mocking in tests | |
+ | |
+ @property location | |
@default environment.location | |
*/ | |
_location: environment['default'].location, | |
/** | |
@private | |
- Attached for mocking in tests | |
- @since 1.5.1 | |
+ | |
+ Attached for mocking in tests | |
+ | |
+ @since 1.5.1 | |
@property _history | |
@default environment.history | |
*/ | |
@@ -19966,9 +20290,11 @@ | |
/** | |
@private | |
- This property is used by router:main to know whether to cancel the routing | |
+ | |
+ This property is used by router:main to know whether to cancel the routing | |
setup process, which is needed while we redirect the browser. | |
- @since 1.5.1 | |
+ | |
+ @since 1.5.1 | |
@property cancelRouterSetup | |
@default false | |
*/ | |
@@ -19976,17 +20302,21 @@ | |
/** | |
@private | |
- Will be pre-pended to path upon state change. | |
- @since 1.5.1 | |
+ | |
+ Will be pre-pended to path upon state change. | |
+ | |
+ @since 1.5.1 | |
@property rootURL | |
@default '/' | |
*/ | |
- rootURL: "/", | |
+ rootURL: '/', | |
/** | |
@private | |
- Attached for mocking in tests | |
- @since 1.5.1 | |
+ | |
+ Attached for mocking in tests | |
+ | |
+ @since 1.5.1 | |
@property _HistoryLocation | |
@default Ember.HistoryLocation | |
*/ | |
@@ -19994,8 +20324,10 @@ | |
/** | |
@private | |
- Attached for mocking in tests | |
- @since 1.5.1 | |
+ | |
+ Attached for mocking in tests | |
+ | |
+ @since 1.5.1 | |
@property _HashLocation | |
@default Ember.HashLocation | |
*/ | |
@@ -20003,8 +20335,10 @@ | |
/** | |
@private | |
- Attached for mocking in tests | |
- @since 1.5.1 | |
+ | |
+ Attached for mocking in tests | |
+ | |
+ @since 1.5.1 | |
@property _NoneLocation | |
@default Ember.NoneLocation | |
*/ | |
@@ -20012,8 +20346,10 @@ | |
/** | |
@private | |
- Returns location.origin or builds it if device doesn't support it. | |
- @method _getOrigin | |
+ | |
+ Returns location.origin or builds it if device doesn't support it. | |
+ | |
+ @method _getOrigin | |
*/ | |
_getOrigin: function () { | |
var location = this._location; | |
@@ -20021,10 +20357,10 @@ | |
// Older browsers, especially IE, don't have origin | |
if (!origin) { | |
- origin = location.protocol + "//" + location.hostname; | |
+ origin = location.protocol + '//' + location.hostname; | |
if (location.port) { | |
- origin += ":" + location.port; | |
+ origin += ':' + location.port; | |
} | |
} | |
@@ -20035,7 +20371,8 @@ | |
/** | |
@private | |
- @method _getSupportsHistory | |
+ | |
+ @method _getSupportsHistory | |
*/ | |
_getSupportsHistory: function () { | |
return feature_detect.supportsHistory(environment['default'].userAgent, environment['default'].history); | |
@@ -20043,7 +20380,8 @@ | |
/** | |
@private | |
- @method _getSupportsHashChange | |
+ | |
+ @method _getSupportsHashChange | |
*/ | |
_getSupportsHashChange: function () { | |
return feature_detect.supportsHashChange(document.documentMode, window); | |
@@ -20051,9 +20389,11 @@ | |
/** | |
@private | |
- Redirects the browser using location.replace, prepending the location.origin | |
+ | |
+ Redirects the browser using location.replace, prepending the location.origin | |
to prevent phishing attempts | |
- @method _replacePath | |
+ | |
+ @method _replacePath | |
*/ | |
_replacePath: function (path) { | |
this._location.replace(this._getOrigin() + path); | |
@@ -20070,14 +20410,16 @@ | |
/** | |
@private | |
- Returns the current `location.pathname`, normalized for IE inconsistencies. | |
- @method _getPath | |
+ | |
+ Returns the current `location.pathname`, normalized for IE inconsistencies. | |
+ | |
+ @method _getPath | |
*/ | |
_getPath: function () { | |
var pathname = this._location.pathname; | |
// Various versions of IE/Opera don't always return a leading slash | |
- if (pathname.charAt(0) !== "/") { | |
- pathname = "/" + pathname; | |
+ if (pathname.charAt(0) !== '/') { | |
+ pathname = '/' + pathname; | |
} | |
return pathname; | |
@@ -20085,16 +20427,20 @@ | |
/** | |
@private | |
- Returns normalized location.hash as an alias to Ember.Location._getHash | |
- @since 1.5.1 | |
+ | |
+ Returns normalized location.hash as an alias to Ember.Location._getHash | |
+ | |
+ @since 1.5.1 | |
@method _getHash | |
*/ | |
_getHash: EmberLocation['default']._getHash, | |
/** | |
@private | |
- Returns location.search | |
- @since 1.5.1 | |
+ | |
+ Returns location.search | |
+ | |
+ @since 1.5.1 | |
@method _getQuery | |
*/ | |
_getQuery: function () { | |
@@ -20103,8 +20449,10 @@ | |
/** | |
@private | |
- Returns the full pathname including query and hash | |
- @method _getFullPath | |
+ | |
+ Returns the full pathname including query and hash | |
+ | |
+ @method _getFullPath | |
*/ | |
_getFullPath: function () { | |
return this._getPath() + this._getQuery() + this._getHash(); | |
@@ -20112,10 +20460,12 @@ | |
/** | |
@private | |
- Returns the current path as it should appear for HistoryLocation supported | |
+ | |
+ Returns the current path as it should appear for HistoryLocation supported | |
browsers. This may very well differ from the real current path (e.g. if it | |
starts off as a hashed URL) | |
- @method _getHistoryPath | |
+ | |
+ @method _getHistoryPath | |
*/ | |
_getHistoryPath: function () { | |
var rootURL = this._getRootURL(); | |
@@ -20125,20 +20475,20 @@ | |
var rootURLIndex = path.indexOf(rootURL); | |
var routeHash, hashParts; | |
- Ember['default'].assert("Path " + path + " does not start with the provided rootURL " + rootURL, rootURLIndex === 0); | |
+ Ember['default'].assert('Path ' + path + ' does not start with the provided rootURL ' + rootURL, rootURLIndex === 0); | |
// By convention, Ember.js routes using HashLocation are required to start | |
// with `#/`. Anything else should NOT be considered a route and should | |
// be passed straight through, without transformation. | |
- if (hash.substr(0, 2) === "#/") { | |
+ if (hash.substr(0, 2) === '#/') { | |
// There could be extra hash segments after the route | |
- hashParts = hash.substr(1).split("#"); | |
+ hashParts = hash.substr(1).split('#'); | |
// The first one is always the route url | |
routeHash = hashParts.shift(); | |
// If the path already has a trailing slash, remove the one | |
// from the hashed route so we don't double up. | |
- if (path.slice(-1) === "/") { | |
+ if (path.slice(-1) === '/') { | |
routeHash = routeHash.substr(1); | |
} | |
@@ -20147,7 +20497,7 @@ | |
path += query; | |
if (hashParts.length) { | |
- path += "#" + hashParts.join("#"); | |
+ path += '#' + hashParts.join('#'); | |
} | |
} else { | |
path += query; | |
@@ -20159,9 +20509,11 @@ | |
/** | |
@private | |
- Returns the current path as it should appear for HashLocation supported | |
+ | |
+ Returns the current path as it should appear for HashLocation supported | |
browsers. This may very well differ from the real current path. | |
- @method _getHashPath | |
+ | |
+ @method _getHashPath | |
*/ | |
_getHashPath: function () { | |
var rootURL = this._getRootURL(); | |
@@ -20169,12 +20521,12 @@ | |
var historyPath = this._getHistoryPath(); | |
var routePath = historyPath.substr(rootURL.length); | |
- if (routePath !== "") { | |
- if (routePath.charAt(0) !== "/") { | |
- routePath = "/" + routePath; | |
+ if (routePath !== '') { | |
+ if (routePath.charAt(0) !== '/') { | |
+ routePath = '/' + routePath; | |
} | |
- path += "#" + routePath; | |
+ path += '#' + routePath; | |
} | |
return path; | |
@@ -20183,12 +20535,14 @@ | |
/** | |
Selects the best location option based off browser support and returns an | |
instance of that Location class. | |
- @see Ember.AutoLocation | |
+ | |
+ @see Ember.AutoLocation | |
@method create | |
*/ | |
create: function (options) { | |
if (options && options.rootURL) { | |
- Ember['default'].assert("rootURL must end with a trailing forward slash e.g. \"/app/\"", options.rootURL.charAt(options.rootURL.length - 1) === "/"); | |
+ Ember['default'].assert('rootURL must end with a trailing forward slash e.g. "/app/"', | |
+ options.rootURL.charAt(options.rootURL.length-1) === '/'); | |
this.rootURL = options.rootURL; | |
} | |
@@ -20205,7 +20559,7 @@ | |
if (currentPath === historyPath) { | |
implementationClass = this._HistoryLocation; | |
} else { | |
- if (currentPath.substr(0, 2) === "/#") { | |
+ if (currentPath.substr(0, 2) === '/#') { | |
this._history.replaceState({ path: historyPath }, null, historyPath); | |
implementationClass = this._HistoryLocation; | |
} else { | |
@@ -20213,13 +20567,14 @@ | |
this._replacePath(historyPath); | |
} | |
} | |
+ | |
} else if (this._getSupportsHashChange()) { | |
hashPath = this._getHashPath(); | |
// Be sure we're using a hashed path, otherwise let's switch over it to so | |
// we start off clean and consistent. We'll count an index path with no | |
// hash as "good enough" as well. | |
- if (currentPath === hashPath || currentPath === "/" && hashPath === "/#/") { | |
+ if (currentPath === hashPath || (currentPath === '/' && hashPath === '/#/')) { | |
implementationClass = this._HashLocation; | |
} else { | |
// Our URL isn't in the expected hash-supported format, so we want to | |
@@ -20232,7 +20587,7 @@ | |
var implementation = implementationClass.create.apply(implementationClass, arguments); | |
if (cancelRouterSetup) { | |
- property_set.set(implementation, "cancelRouterSetup", true); | |
+ property_set.set(implementation, 'cancelRouterSetup', true); | |
} | |
return implementation; | |
@@ -20257,9 +20612,19 @@ | |
@function supportsHashChange | |
*/ | |
function supportsHashChange(documentMode, global) { | |
- return "onhashchange" in global && (documentMode === undefined || documentMode > 7); | |
+ return ('onhashchange' in global) && (documentMode === undefined || documentMode > 7); | |
} | |
+ /* | |
+ `userAgent` is a user agent string. We use user agent testing here, because | |
+ the stock Android browser in Gingerbread has a buggy versions of this API, | |
+ Before feature detecting, we blacklist a browser identifying as both Android 2 | |
+ and Mobile Safari, but not Chrome. | |
+ | |
+ @private | |
+ @function supportsHistory | |
+ */ | |
+ | |
function supportsHistory(userAgent, history) { | |
// Boosted from Modernizr: https://github.com/Modernizr/Modernizr/blob/master/feature-detects/history.js | |
// The stock browser on Android 2.2 & 2.3 returns positive on history support | |
@@ -20268,11 +20633,13 @@ | |
// We only want Android 2, stock browser, and not Chrome which identifies | |
// itself as 'Mobile Safari' as well | |
- if (userAgent.indexOf("Android 2") !== -1 && userAgent.indexOf("Mobile Safari") !== -1 && userAgent.indexOf("Chrome") === -1) { | |
+ if (userAgent.indexOf('Android 2') !== -1 && | |
+ userAgent.indexOf('Mobile Safari') !== -1 && | |
+ userAgent.indexOf('Chrome') === -1) { | |
return false; | |
} | |
- return !!(history && "pushState" in history); | |
+ return !!(history && 'pushState' in history); | |
} | |
}); | |
@@ -20281,41 +20648,46 @@ | |
'use strict'; | |
exports['default'] = EmberObject['default'].extend({ | |
- implementation: "hash", | |
+ implementation: 'hash', | |
- init: function () { | |
- property_set.set(this, "location", property_get.get(this, "_location") || window.location); | |
+ init: function() { | |
+ property_set.set(this, 'location', property_get.get(this, '_location') || window.location); | |
}, | |
/** | |
@private | |
- Returns normalized location.hash | |
- @since 1.5.1 | |
+ | |
+ Returns normalized location.hash | |
+ | |
+ @since 1.5.1 | |
@method getHash | |
*/ | |
getHash: EmberLocation['default']._getHash, | |
/** | |
Returns the normalized URL, constructed from `location.hash`. | |
- e.g. `#/foo` => `/foo` as well as `#/foo#bar` => `/foo#bar`. | |
- By convention, hashed paths must begin with a forward slash, otherwise they | |
+ | |
+ e.g. `#/foo` => `/foo` as well as `#/foo#bar` => `/foo#bar`. | |
+ | |
+ By convention, hashed paths must begin with a forward slash, otherwise they | |
are not treated as a path so we can distinguish intent. | |
- @private | |
+ | |
+ @private | |
@method getURL | |
*/ | |
- getURL: function () { | |
+ getURL: function() { | |
var originalPath = this.getHash().substr(1); | |
var outPath = originalPath; | |
- if (outPath.charAt(0) !== "/") { | |
- outPath = "/"; | |
+ if (outPath.charAt(0) !== '/') { | |
+ outPath = '/'; | |
// Only add the # if the path isn't empty. | |
// We do NOT want `/#` since the ampersand | |
// is only included (conventionally) when | |
// the location.hash has a value | |
if (originalPath) { | |
- outPath += "#" + originalPath; | |
+ outPath += '#' + originalPath; | |
} | |
} | |
@@ -20326,47 +20698,48 @@ | |
Set the `location.hash` and remembers what was set. This prevents | |
`onUpdateURL` callbacks from triggering when the hash was set by | |
`HashLocation`. | |
- @private | |
+ | |
+ @private | |
@method setURL | |
@param path {String} | |
*/ | |
- setURL: function (path) { | |
- property_get.get(this, "location").hash = path; | |
- property_set.set(this, "lastSetURL", path); | |
+ setURL: function(path) { | |
+ property_get.get(this, 'location').hash = path; | |
+ property_set.set(this, 'lastSetURL', path); | |
}, | |
/** | |
Uses location.replace to update the url without a page reload | |
or history modification. | |
- @private | |
+ | |
+ @private | |
@method replaceURL | |
@param path {String} | |
*/ | |
- replaceURL: function (path) { | |
- property_get.get(this, "location").replace("#" + path); | |
- property_set.set(this, "lastSetURL", path); | |
+ replaceURL: function(path) { | |
+ property_get.get(this, 'location').replace('#' + path); | |
+ property_set.set(this, 'lastSetURL', path); | |
}, | |
/** | |
Register a callback to be invoked when the hash changes. These | |
callbacks will execute when the user presses the back or forward | |
button, but not after `setURL` is invoked. | |
- @private | |
+ | |
+ @private | |
@method onUpdateURL | |
@param callback {Function} | |
*/ | |
- onUpdateURL: function (callback) { | |
+ onUpdateURL: function(callback) { | |
var self = this; | |
var guid = utils.guidFor(this); | |
- Ember['default'].$(window).on("hashchange.ember-location-" + guid, function () { | |
- run['default'](function () { | |
+ Ember['default'].$(window).on('hashchange.ember-location-'+guid, function() { | |
+ run['default'](function() { | |
var path = self.getURL(); | |
- if (property_get.get(self, "lastSetURL") === path) { | |
- return; | |
- } | |
+ if (property_get.get(self, 'lastSetURL') === path) { return; } | |
- property_set.set(self, "lastSetURL", null); | |
+ property_set.set(self, 'lastSetURL', null); | |
callback(path); | |
}); | |
@@ -20376,25 +20749,28 @@ | |
/** | |
Given a URL, formats it to be placed into the page as part | |
of an element's `href` attribute. | |
- This is used, for example, when using the {{action}} helper | |
+ | |
+ This is used, for example, when using the {{action}} helper | |
to generate a URL based on an event. | |
- @private | |
+ | |
+ @private | |
@method formatURL | |
@param url {String} | |
*/ | |
- formatURL: function (url) { | |
- return "#" + url; | |
+ formatURL: function(url) { | |
+ return '#' + url; | |
}, | |
/** | |
Cleans up the HashLocation event listener. | |
- @private | |
+ | |
+ @private | |
@method willDestroy | |
*/ | |
- willDestroy: function () { | |
+ willDestroy: function() { | |
var guid = utils.guidFor(this); | |
- Ember['default'].$(window).off("hashchange.ember-location-" + guid); | |
+ Ember['default'].$(window).off('hashchange.ember-location-'+guid); | |
} | |
}); | |
@@ -20414,23 +20790,25 @@ | |
@extends Ember.Object | |
*/ | |
exports['default'] = EmberObject['default'].extend({ | |
- implementation: "history", | |
+ implementation: 'history', | |
+ | |
+ init: function() { | |
+ property_set.set(this, 'location', property_get.get(this, 'location') || window.location); | |
+ property_set.set(this, 'baseURL', jQuery['default']('base').attr('href') || ''); | |
- init: function () { | |
- property_set.set(this, "location", property_get.get(this, "location") || window.location); | |
- property_set.set(this, "baseURL", jQuery['default']("base").attr("href") || ""); | |
}, | |
/** | |
Used to set state on first call to setURL | |
- @private | |
+ | |
+ @private | |
@method initState | |
*/ | |
- initState: function () { | |
- var history = property_get.get(this, "history") || window.history; | |
- property_set.set(this, "history", history); | |
+ initState: function() { | |
+ var history = property_get.get(this, 'history') || window.history; | |
+ property_set.set(this, 'history', history); | |
- if (history && "state" in history) { | |
+ if (history && 'state' in history) { | |
this.supportsHistory = true; | |
} | |
@@ -20439,28 +20817,30 @@ | |
/** | |
Will be pre-pended to path upon state change | |
- @property rootURL | |
+ | |
+ @property rootURL | |
@default '/' | |
*/ | |
- rootURL: "/", | |
+ rootURL: '/', | |
/** | |
Returns the current `location.pathname` without `rootURL` or `baseURL` | |
- @private | |
+ | |
+ @private | |
@method getURL | |
@return url {String} | |
*/ | |
- getURL: function () { | |
- var rootURL = property_get.get(this, "rootURL"); | |
- var location = property_get.get(this, "location"); | |
+ getURL: function() { | |
+ var rootURL = property_get.get(this, 'rootURL'); | |
+ var location = property_get.get(this, 'location'); | |
var path = location.pathname; | |
- var baseURL = property_get.get(this, "baseURL"); | |
+ var baseURL = property_get.get(this, 'baseURL'); | |
- rootURL = rootURL.replace(/\/$/, ""); | |
- baseURL = baseURL.replace(/\/$/, ""); | |
+ rootURL = rootURL.replace(/\/$/, ''); | |
+ baseURL = baseURL.replace(/\/$/, ''); | |
- var url = path.replace(baseURL, "").replace(rootURL, ""); | |
- var search = location.search || ""; | |
+ var url = path.replace(baseURL, '').replace(rootURL, ''); | |
+ var search = location.search || ''; | |
url += search; | |
url += this.getHash(); | |
@@ -20470,11 +20850,12 @@ | |
/** | |
Uses `history.pushState` to update the url without a page reload. | |
- @private | |
+ | |
+ @private | |
@method setURL | |
@param path {String} | |
*/ | |
- setURL: function (path) { | |
+ setURL: function(path) { | |
var state = this.getState(); | |
path = this.formatURL(path); | |
@@ -20486,11 +20867,12 @@ | |
/** | |
Uses `history.replaceState` to update the url without a page reload | |
or history modification. | |
- @private | |
+ | |
+ @private | |
@method replaceURL | |
@param path {String} | |
*/ | |
- replaceURL: function (path) { | |
+ replaceURL: function(path) { | |
var state = this.getState(); | |
path = this.formatURL(path); | |
@@ -20504,13 +20886,14 @@ | |
required and if so fetches this._historyState. The state returned | |
from getState may be null if an iframe has changed a window's | |
history. | |
- @private | |
+ | |
+ @private | |
@method getState | |
@return state {Object} | |
*/ | |
- getState: function () { | |
+ getState: function() { | |
if (this.supportsHistory) { | |
- return property_get.get(this, "history").state; | |
+ return property_get.get(this, 'history').state; | |
} | |
return this._historyState; | |
@@ -20518,14 +20901,15 @@ | |
/** | |
Pushes a new state. | |
- @private | |
+ | |
+ @private | |
@method pushState | |
@param path {String} | |
*/ | |
- pushState: function (path) { | |
+ pushState: function(path) { | |
var state = { path: path }; | |
- property_get.get(this, "history").pushState(state, null, path); | |
+ property_get.get(this, 'history').pushState(state, null, path); | |
this._historyState = state; | |
@@ -20535,13 +20919,14 @@ | |
/** | |
Replaces the current state. | |
- @private | |
+ | |
+ @private | |
@method replaceState | |
@param path {String} | |
*/ | |
- replaceState: function (path) { | |
+ replaceState: function(path) { | |
var state = { path: path }; | |
- property_get.get(this, "history").replaceState(state, null, path); | |
+ property_get.get(this, 'history').replaceState(state, null, path); | |
this._historyState = state; | |
@@ -20552,21 +20937,20 @@ | |
/** | |
Register a callback to be invoked whenever the browser | |
history changes, including using forward and back buttons. | |
- @private | |
+ | |
+ @private | |
@method onUpdateURL | |
@param callback {Function} | |
*/ | |
- onUpdateURL: function (callback) { | |
+ onUpdateURL: function(callback) { | |
var guid = utils.guidFor(this); | |
var self = this; | |
- jQuery['default'](window).on("popstate.ember-location-" + guid, function (e) { | |
+ jQuery['default'](window).on('popstate.ember-location-'+guid, function(e) { | |
// Ignore initial page load popstate event in Chrome | |
if (!popstateFired) { | |
popstateFired = true; | |
- if (self.getURL() === self._previousURL) { | |
- return; | |
- } | |
+ if (self.getURL() === self._previousURL) { return; } | |
} | |
callback(self.getURL()); | |
}); | |
@@ -20574,20 +20958,21 @@ | |
/** | |
Used when using `{{action}}` helper. The url is always appended to the rootURL. | |
- @private | |
+ | |
+ @private | |
@method formatURL | |
@param url {String} | |
@return formatted url {String} | |
*/ | |
- formatURL: function (url) { | |
- var rootURL = property_get.get(this, "rootURL"); | |
- var baseURL = property_get.get(this, "baseURL"); | |
- | |
- if (url !== "") { | |
- rootURL = rootURL.replace(/\/$/, ""); | |
- baseURL = baseURL.replace(/\/$/, ""); | |
+ formatURL: function(url) { | |
+ var rootURL = property_get.get(this, 'rootURL'); | |
+ var baseURL = property_get.get(this, 'baseURL'); | |
+ | |
+ if (url !== '') { | |
+ rootURL = rootURL.replace(/\/$/, ''); | |
+ baseURL = baseURL.replace(/\/$/, ''); | |
} else if (baseURL.match(/^\//) && rootURL.match(/^\//)) { | |
- baseURL = baseURL.replace(/\/$/, ""); | |
+ baseURL = baseURL.replace(/\/$/, ''); | |
} | |
return baseURL + rootURL + url; | |
@@ -20595,19 +20980,22 @@ | |
/** | |
Cleans up the HistoryLocation event listener. | |
- @private | |
+ | |
+ @private | |
@method willDestroy | |
*/ | |
- willDestroy: function () { | |
+ willDestroy: function() { | |
var guid = utils.guidFor(this); | |
- jQuery['default'](window).off("popstate.ember-location-" + guid); | |
+ jQuery['default'](window).off('popstate.ember-location-'+guid); | |
}, | |
/** | |
@private | |
- Returns normalized location.hash | |
- @method getHash | |
+ | |
+ Returns normalized location.hash | |
+ | |
+ @method getHash | |
*/ | |
getHash: EmberLocation['default']._getHash | |
}); | |
@@ -20618,64 +21006,70 @@ | |
'use strict'; | |
exports['default'] = EmberObject['default'].extend({ | |
- implementation: "none", | |
- path: "", | |
+ implementation: 'none', | |
+ path: '', | |
/** | |
Returns the current path. | |
- @private | |
+ | |
+ @private | |
@method getURL | |
@return {String} path | |
*/ | |
- getURL: function () { | |
- return property_get.get(this, "path"); | |
+ getURL: function() { | |
+ return property_get.get(this, 'path'); | |
}, | |
/** | |
Set the path and remembers what was set. Using this method | |
to change the path will not invoke the `updateURL` callback. | |
- @private | |
+ | |
+ @private | |
@method setURL | |
@param path {String} | |
*/ | |
- setURL: function (path) { | |
- property_set.set(this, "path", path); | |
+ setURL: function(path) { | |
+ property_set.set(this, 'path', path); | |
}, | |
/** | |
Register a callback to be invoked when the path changes. These | |
callbacks will execute when the user presses the back or forward | |
button, but not after `setURL` is invoked. | |
- @private | |
+ | |
+ @private | |
@method onUpdateURL | |
@param callback {Function} | |
*/ | |
- onUpdateURL: function (callback) { | |
+ onUpdateURL: function(callback) { | |
this.updateCallback = callback; | |
}, | |
/** | |
Sets the path and calls the `updateURL` callback. | |
- @private | |
+ | |
+ @private | |
@method handleURL | |
@param callback {Function} | |
*/ | |
- handleURL: function (url) { | |
- property_set.set(this, "path", url); | |
+ handleURL: function(url) { | |
+ property_set.set(this, 'path', url); | |
this.updateCallback(url); | |
}, | |
/** | |
Given a URL, formats it to be placed into the page as part | |
of an element's `href` attribute. | |
- This is used, for example, when using the {{action}} helper | |
+ | |
+ This is used, for example, when using the {{action}} helper | |
to generate a URL based on an event. | |
- @private | |
+ | |
+ @private | |
@method formatURL | |
@param url {String} | |
@return {String} url | |
*/ | |
- formatURL: function (url) { | |
+ formatURL: function(url) { | |
// The return value is not overly meaningful, but we do not want to throw | |
// errors when test code renders templates containing {{action href=true}} | |
// helpers. | |
@@ -20689,20 +21083,20 @@ | |
'use strict'; | |
exports['default'] = EmberObject['default'].extend({ | |
- init: function () { | |
+ init: function() { | |
this.cache = {}; | |
}, | |
- has: function (bucketKey) { | |
+ has: function(bucketKey) { | |
return bucketKey in this.cache; | |
}, | |
- stash: function (bucketKey, key, value) { | |
+ stash: function(bucketKey, key, value) { | |
var bucket = this.cache[bucketKey]; | |
if (!bucket) { | |
bucket = this.cache[bucketKey] = {}; | |
} | |
bucket[key] = value; | |
}, | |
- lookup: function (bucketKey, prop, defaultValue) { | |
+ lookup: function(bucketKey, prop, defaultValue) { | |
var cache = this.cache; | |
if (!(bucketKey in cache)) { | |
return defaultValue; | |
@@ -20735,11 +21129,10 @@ | |
@method controllerFor | |
@private | |
*/ | |
- exports['default'] = controllerFor; | |
- | |
function controllerFor(container, controllerName, lookupOptions) { | |
- return container.lookup("controller:" + controllerName, lookupOptions); | |
+ return container.lookup('controller:' + controllerName, lookupOptions); | |
} | |
+ exports['default'] = controllerFor; | |
}); | |
enifed('ember-routing/system/dsl', ['exports', 'ember-metal/core', 'ember-metal/array'], function (exports, Ember, array) { | |
@@ -20754,8 +21147,8 @@ | |
exports['default'] = DSL; | |
DSL.prototype = { | |
- route: function (name, options, callback) { | |
- if (arguments.length === 2 && typeof options === "function") { | |
+ route: function(name, options, callback) { | |
+ if (arguments.length === 2 && typeof options === 'function') { | |
callback = options; | |
options = {}; | |
} | |
@@ -20764,19 +21157,20 @@ | |
options = {}; | |
} | |
- var type = options.resetNamespace === true ? "resource" : "route"; | |
- Ember['default'].assert("'" + name + "' cannot be used as a " + type + " name.", (function () { | |
- if (options.overrideNameAssertion === true) { | |
- return true; | |
- } | |
+ var type = options.resetNamespace === true ? 'resource' : 'route'; | |
+ Ember['default'].assert( | |
+ "'" + name + "' cannot be used as a " + type + " name.", | |
+ (function() { | |
+ if (options.overrideNameAssertion === true) { return true; } | |
- return array.indexOf.call(["array", "basic", "object", "application"], name) === -1; | |
- })()); | |
+ return array.indexOf.call(['array', 'basic', 'object', 'application'], name) === -1; | |
+ })() | |
+ ); | |
if (this.enableLoadingSubstates) { | |
- createRoute(this, name + "_loading", { resetNamespace: options.resetNamespace }); | |
- createRoute(this, name + "_error", { path: "/_unused_dummy_error_path_route_" + name + "/:error" }); | |
+ createRoute(this, name + '_loading', { resetNamespace: options.resetNamespace }); | |
+ createRoute(this, name + '_error', { path: "/_unused_dummy_error_path_route_" + name + "/:error" }); | |
} | |
@@ -20786,8 +21180,8 @@ | |
enableLoadingSubstates: this.enableLoadingSubstates | |
}); | |
- createRoute(dsl, "loading"); | |
- createRoute(dsl, "error", { path: "/_unused_dummy_error_path_route_" + name + "/:error" }); | |
+ createRoute(dsl, 'loading'); | |
+ createRoute(dsl, 'error', { path: "/_unused_dummy_error_path_route_" + name + "/:error" }); | |
callback.call(dsl); | |
@@ -20797,17 +21191,15 @@ | |
} | |
}, | |
- push: function (url, name, callback) { | |
- var parts = name.split("."); | |
- if (url === "" || url === "/" || parts[parts.length - 1] === "index") { | |
- this.explicitIndex = true; | |
- } | |
+ push: function(url, name, callback) { | |
+ var parts = name.split('.'); | |
+ if (url === "" || url === "/" || parts[parts.length-1] === "index") { this.explicitIndex = true; } | |
this.matches.push([url, name, callback]); | |
}, | |
- resource: function (name, options, callback) { | |
- if (arguments.length === 2 && typeof options === "function") { | |
+ resource: function(name, options, callback) { | |
+ if (arguments.length === 2 && typeof options === 'function') { | |
callback = options; | |
options = {}; | |
} | |
@@ -20820,15 +21212,15 @@ | |
this.route(name, options, callback); | |
}, | |
- generate: function () { | |
+ generate: function() { | |
var dslMatches = this.matches; | |
if (!this.explicitIndex) { | |
this.route("index", { path: "/" }); | |
} | |
- return function (match) { | |
- for (var i = 0, l = dslMatches.length; i < l; i++) { | |
+ return function(match) { | |
+ for (var i=0, l=dslMatches.length; i<l; i++) { | |
var dslMatch = dslMatches[i]; | |
match(dslMatch[0]).to(dslMatch[1], dslMatch[2]); | |
} | |
@@ -20837,7 +21229,7 @@ | |
}; | |
function canNest(dsl) { | |
- return dsl.parent && dsl.parent !== "application"; | |
+ return dsl.parent && dsl.parent !== 'application'; | |
} | |
function getFullName(dsl, name, resetNamespace) { | |
@@ -20853,14 +21245,14 @@ | |
var fullName = getFullName(dsl, name, options.resetNamespace); | |
- if (typeof options.path !== "string") { | |
+ if (typeof options.path !== 'string') { | |
options.path = "/" + name; | |
} | |
dsl.push(options.path, fullName, callback); | |
} | |
- DSL.map = function (callback) { | |
+ DSL.map = function(callback) { | |
var dsl = new DSL(); | |
callback.call(dsl); | |
return dsl; | |
@@ -20873,66 +21265,58 @@ | |
exports.generateControllerFactory = generateControllerFactory; | |
- /** | |
- @module ember | |
- @submodule ember-routing | |
- */ | |
- | |
- /** | |
- Generates a controller factory | |
- | |
- The type of the generated controller factory is derived | |
- from the context. If the context is an array an array controller | |
- is generated, if an object, an object controller otherwise, a basic | |
- controller is generated. | |
- | |
- You can customize your generated controllers by defining | |
- `App.ObjectController` or `App.ArrayController`. | |
- | |
- @for Ember | |
- @method generateControllerFactory | |
- @private | |
- */ | |
- | |
- exports['default'] = generateController; | |
function generateControllerFactory(container, controllerName, context) { | |
var Factory, fullName, factoryName, controllerType; | |
if (context && utils.isArray(context)) { | |
- controllerType = "array"; | |
+ controllerType = 'array'; | |
} else if (context) { | |
- controllerType = "object"; | |
+ controllerType = 'object'; | |
} else { | |
- controllerType = "basic"; | |
+ controllerType = 'basic'; | |
} | |
- factoryName = "controller:" + controllerType; | |
+ factoryName = 'controller:' + controllerType; | |
Factory = container.lookupFactory(factoryName).extend({ | |
isGenerated: true, | |
- toString: function () { | |
+ toString: function() { | |
return "(generated " + controllerName + " controller)"; | |
} | |
}); | |
- fullName = "controller:" + controllerName; | |
+ fullName = 'controller:' + controllerName; | |
container._registry.register(fullName, Factory); | |
return Factory; | |
} | |
+ /** | |
+ Generates and instantiates a controller. | |
+ | |
+ The type of the generated controller factory is derived | |
+ from the context. If the context is an array an array controller | |
+ is generated, if an object, an object controller otherwise, a basic | |
+ controller is generated. | |
+ | |
+ @for Ember | |
+ @method generateController | |
+ @private | |
+ @since 1.3.0 | |
+ */ | |
function generateController(container, controllerName, context) { | |
generateControllerFactory(container, controllerName, context); | |
- var fullName = "controller:" + controllerName; | |
+ var fullName = 'controller:' + controllerName; | |
var instance = container.lookup(fullName); | |
- if (property_get.get(instance, "namespace.LOG_ACTIVE_GENERATION")) { | |
+ if (property_get.get(instance, 'namespace.LOG_ACTIVE_GENERATION')) { | |
Ember['default'].Logger.info("generated -> " + fullName, { fullName: fullName }); | |
} | |
return instance; | |
} | |
+ exports['default'] = generateController; | |
}); | |
enifed('ember-routing/system/query_params', ['exports', 'ember-runtime/system/object'], function (exports, EmberObject) { | |
@@ -20951,9 +21335,7 @@ | |
var slice = Array.prototype.slice; | |
- function K() { | |
- return this; | |
- } | |
+ function K() { return this; } | |
/** | |
@module ember | |
@@ -20975,7 +21357,8 @@ | |
Configuration hash for this route's queryParams. The possible | |
configuration options and their defaults are as follows | |
(assuming a query param whose URL key is `page`): | |
- ```javascript | |
+ | |
+ ```javascript | |
queryParams: { | |
page: { | |
// By default, controller query param properties don't | |
@@ -20987,7 +21370,8 @@ | |
// you to reload models (e.g., from the server) using the | |
// updated query param values. | |
refreshModel: false, | |
- // By default, changes to controller query param properties | |
+ | |
+ // By default, changes to controller query param properties | |
// cause the URL to update via `pushState`, which means an | |
// item will be added to the browser's history, allowing | |
// you to use the back button to restore the app to the | |
@@ -21000,7 +21384,8 @@ | |
} | |
} | |
``` | |
- @property queryParams | |
+ | |
+ @property queryParams | |
@for Ember.Route | |
@type Hash | |
*/ | |
@@ -21008,27 +21393,26 @@ | |
/** | |
@private | |
- @property _qp | |
+ | |
+ @property _qp | |
*/ | |
- _qp: computed.computed(function () { | |
+ _qp: computed.computed(function() { | |
var controllerName = this.controllerName || this.routeName; | |
- var controllerClass = this.container.lookupFactory("controller:" + controllerName); | |
+ var controllerClass = this.container.lookupFactory('controller:' + controllerName); | |
if (!controllerClass) { | |
return defaultQPMeta; | |
} | |
var controllerProto = controllerClass.proto(); | |
- var qpProps = property_get.get(controllerProto, "_normalizedQueryParams"); | |
- var cacheMeta = property_get.get(controllerProto, "_cacheMeta"); | |
+ var qpProps = property_get.get(controllerProto, '_normalizedQueryParams'); | |
+ var cacheMeta = property_get.get(controllerProto, '_cacheMeta'); | |
var qps = []; | |
var map = {}; | |
var self = this; | |
for (var propName in qpProps) { | |
- if (!qpProps.hasOwnProperty(propName)) { | |
- continue; | |
- } | |
+ if (!qpProps.hasOwnProperty(propName)) { continue; } | |
var desc = qpProps[propName]; | |
var urlKey = desc.as || this.serializeQueryParamKey(propName); | |
@@ -21040,7 +21424,7 @@ | |
var type = utils.typeOf(defaultValue); | |
var defaultValueSerialized = this.serializeQueryParam(defaultValue, urlKey, type); | |
- var fprop = controllerName + ":" + propName; | |
+ var fprop = controllerName + ':' + propName; | |
var qp = { | |
def: defaultValue, | |
sdef: defaultValueSerialized, | |
@@ -21064,13 +21448,13 @@ | |
qps: qps, | |
map: map, | |
states: { | |
- active: function (controller, prop) { | |
+ active: function(controller, prop) { | |
return self._activeQPChanged(controller, map[prop]); | |
}, | |
- allowOverrides: function (controller, prop) { | |
+ allowOverrides: function(controller, prop) { | |
return self._updatingQPChanged(controller, map[prop]); | |
}, | |
- changingKeys: function (controller, prop) { | |
+ changingKeys: function(controller, prop) { | |
return self._updateSerializedQPValue(controller, map[prop]); | |
} | |
} | |
@@ -21079,19 +21463,19 @@ | |
/** | |
@private | |
- @property _names | |
+ | |
+ @property _names | |
*/ | |
_names: null, | |
/** | |
@private | |
- @method _stashNames | |
+ | |
+ @method _stashNames | |
*/ | |
- _stashNames: function (_handlerInfo, dynamicParent) { | |
+ _stashNames: function(_handlerInfo, dynamicParent) { | |
var handlerInfo = _handlerInfo; | |
- if (this._names) { | |
- return; | |
- } | |
+ if (this._names) { return; } | |
var names = this._names = handlerInfo._names; | |
if (!names.length) { | |
@@ -21099,18 +21483,18 @@ | |
names = handlerInfo && handlerInfo._names || []; | |
} | |
- var qps = property_get.get(this, "_qp.qps"); | |
+ var qps = property_get.get(this, '_qp.qps'); | |
var len = qps.length; | |
var namePaths = new Array(names.length); | |
for (var a = 0, nlen = names.length; a < nlen; ++a) { | |
- namePaths[a] = handlerInfo.name + "." + names[a]; | |
+ namePaths[a] = handlerInfo.name + '.' + names[a]; | |
} | |
for (var i = 0; i < len; ++i) { | |
var qp = qps[i]; | |
var cacheMeta = qp.cacheMeta; | |
- if (cacheMeta.scope === "model") { | |
+ if (cacheMeta.scope === 'model') { | |
cacheMeta.parts = namePaths; | |
} | |
cacheMeta.prefix = qp.ctrl; | |
@@ -21119,18 +21503,20 @@ | |
/** | |
@private | |
- @property _updateSerializedQPValue | |
+ | |
+ @property _updateSerializedQPValue | |
*/ | |
- _updateSerializedQPValue: function (controller, qp) { | |
+ _updateSerializedQPValue: function(controller, qp) { | |
var value = property_get.get(controller, qp.prop); | |
qp.svalue = this.serializeQueryParam(value, qp.urlKey, qp.type); | |
}, | |
/** | |
@private | |
- @property _activeQPChanged | |
+ | |
+ @property _activeQPChanged | |
*/ | |
- _activeQPChanged: function (controller, qp) { | |
+ _activeQPChanged: function(controller, qp) { | |
var value = property_get.get(controller, qp.prop); | |
this.router._queuedQPChanges[qp.fprop] = value; | |
run['default'].once(this, this._fireQueryParamTransition); | |
@@ -21140,7 +21526,7 @@ | |
@private | |
@method _updatingQPChanged | |
*/ | |
- _updatingQPChanged: function (controller, qp) { | |
+ _updatingQPChanged: function(controller, qp) { | |
var router = this.router; | |
if (!router._qpUpdates) { | |
router._qpUpdates = {}; | |
@@ -21148,16 +21534,18 @@ | |
router._qpUpdates[qp.urlKey] = true; | |
}, | |
- mergedProperties: ["events", "queryParams"], | |
+ mergedProperties: ['events', 'queryParams'], | |
/** | |
Retrieves parameters, for current route using the state.params | |
variable and getQueryParamsFor, using the supplied routeName. | |
- @method paramsFor | |
+ | |
+ @method paramsFor | |
@param {String} name | |
- */ | |
- paramsFor: function (name) { | |
- var route = this.container.lookup("route:" + name); | |
+ | |
+ */ | |
+ paramsFor: function(name) { | |
+ var route = this.container.lookup('route:' + name); | |
if (!route) { | |
return {}; | |
@@ -21175,85 +21563,93 @@ | |
/** | |
Serializes the query parameter key | |
- @method serializeQueryParamKey | |
+ | |
+ @method serializeQueryParamKey | |
@param {String} controllerPropertyName | |
*/ | |
- serializeQueryParamKey: function (controllerPropertyName) { | |
+ serializeQueryParamKey: function(controllerPropertyName) { | |
return controllerPropertyName; | |
}, | |
/** | |
Serializes value of the query parameter based on defaultValueType | |
- @method serializeQueryParam | |
+ | |
+ @method serializeQueryParam | |
@param {Object} value | |
@param {String} urlKey | |
@param {String} defaultValueType | |
*/ | |
- serializeQueryParam: function (value, urlKey, defaultValueType) { | |
+ serializeQueryParam: function(value, urlKey, defaultValueType) { | |
// urlKey isn't used here, but anyone overriding | |
// can use it to provide serialization specific | |
// to a certain query param. | |
- if (defaultValueType === "array") { | |
+ if (defaultValueType === 'array') { | |
return JSON.stringify(value); | |
} | |
- return "" + value; | |
+ return '' + value; | |
}, | |
/** | |
Deserializes value of the query parameter based on defaultValueType | |
- @method deserializeQueryParam | |
+ | |
+ @method deserializeQueryParam | |
@param {Object} value | |
@param {String} urlKey | |
@param {String} defaultValueType | |
*/ | |
- deserializeQueryParam: function (value, urlKey, defaultValueType) { | |
+ deserializeQueryParam: function(value, urlKey, defaultValueType) { | |
// urlKey isn't used here, but anyone overriding | |
// can use it to provide deserialization specific | |
// to a certain query param. | |
// Use the defaultValueType of the default value (the initial value assigned to a | |
// controller query param property), to intelligently deserialize and cast. | |
- if (defaultValueType === "boolean") { | |
- return value === "true" ? true : false; | |
- } else if (defaultValueType === "number") { | |
- return Number(value).valueOf(); | |
- } else if (defaultValueType === "array") { | |
+ if (defaultValueType === 'boolean') { | |
+ return (value === 'true') ? true : false; | |
+ } else if (defaultValueType === 'number') { | |
+ return (Number(value)).valueOf(); | |
+ } else if (defaultValueType === 'array') { | |
return Ember['default'].A(JSON.parse(value)); | |
} | |
return value; | |
}, | |
+ | |
/** | |
@private | |
@property _fireQueryParamTransition | |
*/ | |
- _fireQueryParamTransition: function () { | |
+ _fireQueryParamTransition: function() { | |
this.transitionTo({ queryParams: this.router._queuedQPChanges }); | |
this.router._queuedQPChanges = {}; | |
}, | |
/** | |
@private | |
- @property _optionsForQueryParam | |
+ | |
+ @property _optionsForQueryParam | |
*/ | |
- _optionsForQueryParam: function (qp) { | |
- return property_get.get(this, "queryParams." + qp.urlKey) || property_get.get(this, "queryParams." + qp.prop) || {}; | |
+ _optionsForQueryParam: function(qp) { | |
+ return property_get.get(this, 'queryParams.' + qp.urlKey) || property_get.get(this, 'queryParams.' + qp.prop) || {}; | |
}, | |
/** | |
A hook you can use to reset controller values either when the model | |
changes or the route is exiting. | |
- ```javascript | |
+ | |
+ ```javascript | |
App.ArticlesRoute = Ember.Route.extend({ | |
// ... | |
- resetController: function (controller, isExiting, transition) { | |
+ | |
+ resetController: function (controller, isExiting, transition) { | |
if (isExiting) { | |
controller.set('page', 1); | |
} | |
} | |
}); | |
``` | |
- @method resetController | |
+ | |
+ @method resetController | |
@param {Controller} controller instance | |
@param {Boolean} isExiting | |
@param {Object} transition | |
@@ -21263,53 +21659,61 @@ | |
/** | |
@private | |
- @method exit | |
+ | |
+ @method exit | |
*/ | |
- exit: function () { | |
+ exit: function() { | |
this.deactivate(); | |
- this.trigger("deactivate"); | |
+ this.trigger('deactivate'); | |
this.teardownViews(); | |
}, | |
/** | |
@private | |
- @method _reset | |
+ | |
+ @method _reset | |
@since 1.7.0 | |
*/ | |
- _reset: function (isExiting, transition) { | |
+ _reset: function(isExiting, transition) { | |
var controller = this.controller; | |
- controller._qpDelegate = property_get.get(this, "_qp.states.inactive"); | |
+ controller._qpDelegate = property_get.get(this, '_qp.states.inactive'); | |
this.resetController(controller, isExiting, transition); | |
}, | |
/** | |
@private | |
- @method enter | |
+ | |
+ @method enter | |
*/ | |
- enter: function () { | |
+ enter: function() { | |
this.connections = []; | |
this.activate(); | |
- this.trigger("activate"); | |
+ this.trigger('activate'); | |
}, | |
/** | |
The name of the view to use by default when rendering this routes template. | |
- When rendering a template, the route will, by default, determine the | |
+ | |
+ When rendering a template, the route will, by default, determine the | |
template and view to use from the name of the route itself. If you need to | |
define a specific view, set this property. | |
- This is useful when multiple routes would benefit from using the same view | |
+ | |
+ This is useful when multiple routes would benefit from using the same view | |
because it doesn't require a custom `renderTemplate` method. For example, | |
the following routes will all render using the `App.PostsListView` view: | |
- ```javascript | |
+ | |
+ ```javascript | |
var PostsList = Ember.Route.extend({ | |
viewName: 'postsList' | |
}); | |
- App.PostsIndexRoute = PostsList.extend(); | |
+ | |
+ App.PostsIndexRoute = PostsList.extend(); | |
App.PostsArchivedRoute = PostsList.extend(); | |
``` | |
- @property viewName | |
+ | |
+ @property viewName | |
@type String | |
@default null | |
@since 1.4.0 | |
@@ -21319,16 +21723,20 @@ | |
/** | |
The name of the template to use by default when rendering this routes | |
template. | |
- This is similar with `viewName`, but is useful when you just want a custom | |
+ | |
+ This is similar with `viewName`, but is useful when you just want a custom | |
template without a view. | |
- ```javascript | |
+ | |
+ ```javascript | |
var PostsList = Ember.Route.extend({ | |
templateName: 'posts/list' | |
}); | |
- App.PostsIndexRoute = PostsList.extend(); | |
+ | |
+ App.PostsIndexRoute = PostsList.extend(); | |
App.PostsArchivedRoute = PostsList.extend(); | |
``` | |
- @property templateName | |
+ | |
+ @property templateName | |
@type String | |
@default null | |
@since 1.4.0 | |
@@ -21337,15 +21745,19 @@ | |
/** | |
The name of the controller to associate with this route. | |
- By default, Ember will lookup a route's controller that matches the name | |
+ | |
+ By default, Ember will lookup a route's controller that matches the name | |
of the route (i.e. `App.PostController` for `App.PostRoute`). However, | |
if you would like to define a specific controller to use, you can do so | |
using this property. | |
- This is useful in many ways, as the controller specified will be: | |
- * passed to the `setupController` method. | |
+ | |
+ This is useful in many ways, as the controller specified will be: | |
+ | |
+ * passed to the `setupController` method. | |
* used as the controller for the view being rendered by the route. | |
* returned from a call to `controllerFor` for the route. | |
- @property controllerName | |
+ | |
+ @property controllerName | |
@type String | |
@default null | |
@since 1.4.0 | |
@@ -21357,9 +21769,11 @@ | |
attempted transition with a `Transition` object as the sole | |
argument. This action can be used for aborting, redirecting, | |
or decorating the transition from the currently active routes. | |
- A good example is preventing navigation when a form is | |
+ | |
+ A good example is preventing navigation when a form is | |
half-filled out: | |
- ```javascript | |
+ | |
+ ```javascript | |
App.ContactFormRoute = Ember.Route.extend({ | |
actions: { | |
willTransition: function(transition) { | |
@@ -21371,7 +21785,8 @@ | |
} | |
}); | |
``` | |
- You can also redirect elsewhere by calling | |
+ | |
+ You can also redirect elsewhere by calling | |
`this.transitionTo('elsewhere')` from within `willTransition`. | |
Note that `willTransition` will not be fired for the | |
redirecting `transitionTo`, since `willTransition` doesn't | |
@@ -21379,7 +21794,8 @@ | |
subsequent `willTransition` actions to fire for the redirecting | |
transition, you must first explicitly call | |
`transition.abort()`. | |
- @event willTransition | |
+ | |
+ @event willTransition | |
@param {Transition} transition | |
*/ | |
@@ -21390,7 +21806,8 @@ | |
have resolved. The `didTransition` action has no arguments, | |
however, it can be useful for tracking page views or resetting | |
state on the controller. | |
- ```javascript | |
+ | |
+ ```javascript | |
App.LoginRoute = Ember.Route.extend({ | |
actions: { | |
didTransition: function() { | |
@@ -21400,7 +21817,8 @@ | |
} | |
}); | |
``` | |
- @event didTransition | |
+ | |
+ @event didTransition | |
@since 1.2.0 | |
*/ | |
@@ -21409,7 +21827,8 @@ | |
hook returns a promise that is not already resolved. The current | |
`Transition` object is the first parameter and the route that | |
triggered the loading event is the second parameter. | |
- ```javascript | |
+ | |
+ ```javascript | |
App.ApplicationRoute = Ember.Route.extend({ | |
actions: { | |
loading: function(transition, route) { | |
@@ -21417,15 +21836,18 @@ | |
classNames: ['app-loading'] | |
}) | |
.append(); | |
- this.router.one('didTransition', function() { | |
+ | |
+ this.router.one('didTransition', function() { | |
view.destroy(); | |
}); | |
- return true; // Bubble the loading event | |
+ | |
+ return true; // Bubble the loading event | |
} | |
} | |
}); | |
``` | |
- @event loading | |
+ | |
+ @event loading | |
@param {Transition} transition | |
@param {Ember.Route} route The route that triggered the loading event | |
@since 1.2.0 | |
@@ -21437,34 +21859,41 @@ | |
action will be fired on the partially-entered routes, allowing | |
for per-route error handling logic, or shared error handling | |
logic defined on a parent route. | |
- Here is an example of an error handler that will be invoked | |
+ | |
+ Here is an example of an error handler that will be invoked | |
for rejected promises from the various hooks on the route, | |
as well as any unhandled errors from child routes: | |
- ```javascript | |
+ | |
+ ```javascript | |
App.AdminRoute = Ember.Route.extend({ | |
beforeModel: function() { | |
return Ember.RSVP.reject('bad things!'); | |
}, | |
- actions: { | |
+ | |
+ actions: { | |
error: function(error, transition) { | |
// Assuming we got here due to the error in `beforeModel`, | |
// we can expect that error === "bad things!", | |
// but a promise model rejecting would also | |
// call this hook, as would any errors encountered | |
// in `afterModel`. | |
- // The `error` hook is also provided the failed | |
+ | |
+ // The `error` hook is also provided the failed | |
// `transition`, which can be stored and later | |
// `.retry()`d if desired. | |
- this.transitionTo('login'); | |
+ | |
+ this.transitionTo('login'); | |
} | |
} | |
}); | |
``` | |
- `error` actions that bubble up all the way to `ApplicationRoute` | |
+ | |
+ `error` actions that bubble up all the way to `ApplicationRoute` | |
will fire a default error handler that logs the error. You can | |
specify your own global default error handler by overriding the | |
`error` handler on `ApplicationRoute`: | |
- ```javascript | |
+ | |
+ ```javascript | |
App.ApplicationRoute = Ember.Route.extend({ | |
actions: { | |
error: function(error, transition) { | |
@@ -21481,35 +21910,41 @@ | |
/** | |
This event is triggered when the router enters the route. It is | |
not executed when the model for the route changes. | |
- ```javascript | |
+ | |
+ ```javascript | |
App.ApplicationRoute = Ember.Route.extend({ | |
collectAnalytics: function(){ | |
collectAnalytics(); | |
}.on('activate') | |
}); | |
``` | |
- @event activate | |
+ | |
+ @event activate | |
@since 1.9.0 | |
*/ | |
/** | |
This event is triggered when the router completely exits this | |
route. It is not executed when the model for the route changes. | |
- ```javascript | |
+ | |
+ ```javascript | |
App.IndexRoute = Ember.Route.extend({ | |
trackPageLeaveAnalytics: function(){ | |
trackPageLeaveAnalytics(); | |
}.on('deactivate') | |
}); | |
``` | |
- @event deactivate | |
+ | |
+ @event deactivate | |
@since 1.9.0 | |
*/ | |
/** | |
The controller associated with this route. | |
- Example | |
- ```javascript | |
+ | |
+ Example | |
+ | |
+ ```javascript | |
App.FormRoute = Ember.Route.extend({ | |
actions: { | |
willTransition: function(transition) { | |
@@ -21525,20 +21960,21 @@ | |
} | |
}); | |
``` | |
- @property controller | |
+ | |
+ @property controller | |
@type Ember.Controller | |
@since 1.6.0 | |
*/ | |
_actions: { | |
- queryParamsDidChange: function (changed, totalPresent, removed) { | |
- var qpMap = property_get.get(this, "_qp").map; | |
+ queryParamsDidChange: function(changed, totalPresent, removed) { | |
+ var qpMap = property_get.get(this, '_qp').map; | |
var totalChanged = keys['default'](changed).concat(keys['default'](removed)); | |
for (var i = 0, len = totalChanged.length; i < len; ++i) { | |
var qp = qpMap[totalChanged[i]]; | |
- if (qp && property_get.get(this._optionsForQueryParam(qp), "refreshModel")) { | |
+ if (qp && property_get.get(this._optionsForQueryParam(qp), 'refreshModel')) { | |
this.refresh(); | |
} | |
} | |
@@ -21546,19 +21982,15 @@ | |
return true; | |
}, | |
- finalizeQueryParamChange: function (params, finalParams, transition) { | |
- if (this.routeName !== "application") { | |
- return true; | |
- } | |
+ finalizeQueryParamChange: function(params, finalParams, transition) { | |
+ if (this.routeName !== 'application') { return true; } | |
// Transition object is absent for intermediate transitions. | |
- if (!transition) { | |
- return; | |
- } | |
+ if (!transition) { return; } | |
var handlerInfos = transition.state.handlerInfos; | |
var router = this.router; | |
- var qpMeta = router._queryParamsFor(handlerInfos[handlerInfos.length - 1].name); | |
+ var qpMeta = router._queryParamsFor(handlerInfos[handlerInfos.length-1].name); | |
var changes = router._qpUpdates; | |
var replaceUrl; | |
@@ -21589,13 +22021,13 @@ | |
} | |
} | |
- controller._qpDelegate = property_get.get(this, "_qp.states.inactive"); | |
+ controller._qpDelegate = property_get.get(this, '_qp.states.inactive'); | |
- var thisQueryParamChanged = svalue !== qp.svalue; | |
+ var thisQueryParamChanged = (svalue !== qp.svalue); | |
if (thisQueryParamChanged) { | |
if (transition.queryParamsOnly && replaceUrl !== false) { | |
var options = route._optionsForQueryParam(qp); | |
- var replaceConfigValue = property_get.get(options, "replace"); | |
+ var replaceConfigValue = property_get.get(options, 'replace'); | |
if (replaceConfigValue) { | |
replaceUrl = true; | |
} else if (replaceConfigValue === false) { | |
@@ -21610,7 +22042,7 @@ | |
// Stash current serialized value of controller. | |
qp.svalue = svalue; | |
- var thisQueryParamHasDefaultValue = qp.sdef === svalue; | |
+ var thisQueryParamHasDefaultValue = (qp.sdef === svalue); | |
if (!thisQueryParamHasDefaultValue) { | |
finalParams.push({ | |
value: svalue, | |
@@ -21621,13 +22053,13 @@ | |
} | |
if (replaceUrl) { | |
- transition.method("replace"); | |
+ transition.method('replace'); | |
} | |
- enumerable_utils.forEach(qpMeta.qps, function (qp) { | |
- var routeQpMeta = property_get.get(qp.route, "_qp"); | |
+ enumerable_utils.forEach(qpMeta.qps, function(qp) { | |
+ var routeQpMeta = property_get.get(qp.route, '_qp'); | |
var finalizedController = qp.route.controller; | |
- finalizedController._qpDelegate = property_get.get(routeQpMeta, "states.active"); | |
+ finalizedController._qpDelegate = property_get.get(routeQpMeta, 'states.active'); | |
}); | |
router._qpUpdates = null; | |
@@ -21636,7 +22068,8 @@ | |
/** | |
@deprecated | |
- Please use `actions` instead. | |
+ | |
+ Please use `actions` instead. | |
@method events | |
*/ | |
events: null, | |
@@ -21644,73 +22077,92 @@ | |
/** | |
This hook is executed when the router completely exits this route. It is | |
not executed when the model for the route changes. | |
- @method deactivate | |
+ | |
+ @method deactivate | |
*/ | |
deactivate: K, | |
/** | |
This hook is executed when the router enters the route. It is not executed | |
when the model for the route changes. | |
- @method activate | |
+ | |
+ @method activate | |
*/ | |
activate: K, | |
/** | |
Transition the application into another route. The route may | |
be either a single route or route path: | |
- ```javascript | |
+ | |
+ ```javascript | |
this.transitionTo('blogPosts'); | |
this.transitionTo('blogPosts.recentEntries'); | |
``` | |
- Optionally supply a model for the route in question. The model | |
+ | |
+ Optionally supply a model for the route in question. The model | |
will be serialized into the URL using the `serialize` hook of | |
the route: | |
- ```javascript | |
+ | |
+ ```javascript | |
this.transitionTo('blogPost', aPost); | |
``` | |
- If a literal is passed (such as a number or a string), it will | |
+ | |
+ If a literal is passed (such as a number or a string), it will | |
be treated as an identifier instead. In this case, the `model` | |
hook of the route will be triggered: | |
- ```javascript | |
+ | |
+ ```javascript | |
this.transitionTo('blogPost', 1); | |
``` | |
- Multiple models will be applied last to first recursively up the | |
+ | |
+ Multiple models will be applied last to first recursively up the | |
resource tree. | |
- ```javascript | |
+ | |
+ ```javascript | |
App.Router.map(function() { | |
this.resource('blogPost', { path:':blogPostId' }, function() { | |
this.resource('blogComment', { path: ':blogCommentId' }); | |
}); | |
}); | |
- this.transitionTo('blogComment', aPost, aComment); | |
+ | |
+ this.transitionTo('blogComment', aPost, aComment); | |
this.transitionTo('blogComment', 1, 13); | |
``` | |
- It is also possible to pass a URL (a string that starts with a | |
+ | |
+ It is also possible to pass a URL (a string that starts with a | |
`/`). This is intended for testing and debugging purposes and | |
should rarely be used in production code. | |
- ```javascript | |
+ | |
+ ```javascript | |
this.transitionTo('/'); | |
this.transitionTo('/blog/post/1/comment/13'); | |
this.transitionTo('/blog/posts?sort=title'); | |
``` | |
- An options hash with a `queryParams` property may be provided as | |
+ | |
+ An options hash with a `queryParams` property may be provided as | |
the final argument to add query parameters to the destination URL. | |
- ```javascript | |
+ | |
+ ```javascript | |
this.transitionTo('blogPost', 1, { | |
queryParams: {showComments: 'true'} | |
}); | |
- // if you just want to transition the query parameters without changing the route | |
+ | |
+ // if you just want to transition the query parameters without changing the route | |
this.transitionTo({queryParams: {sort: 'date'}}); | |
``` | |
- See also 'replaceWith'. | |
- Simple Transition Example | |
- ```javascript | |
+ | |
+ See also 'replaceWith'. | |
+ | |
+ Simple Transition Example | |
+ | |
+ ```javascript | |
App.Router.map(function() { | |
this.route('index'); | |
this.route('secret'); | |
this.route('fourOhFour', { path: '*:' }); | |
}); | |
- App.IndexRoute = Ember.Route.extend({ | |
+ | |
+ App.IndexRoute = Ember.Route.extend({ | |
actions: { | |
moveToSecret: function(context) { | |
if (authorized()) { | |
@@ -21722,14 +22174,17 @@ | |
} | |
}); | |
``` | |
- Transition to a nested route | |
- ```javascript | |
+ | |
+ Transition to a nested route | |
+ | |
+ ```javascript | |
App.Router.map(function() { | |
this.resource('articles', { path: '/articles' }, function() { | |
this.route('new'); | |
}); | |
}); | |
- App.IndexRoute = Ember.Route.extend({ | |
+ | |
+ App.IndexRoute = Ember.Route.extend({ | |
actions: { | |
transitionToNewArticle: function() { | |
this.transitionTo('articles.new'); | |
@@ -21737,32 +22192,40 @@ | |
} | |
}); | |
``` | |
- Multiple Models Example | |
- ```javascript | |
+ | |
+ Multiple Models Example | |
+ | |
+ ```javascript | |
App.Router.map(function() { | |
this.route('index'); | |
- this.resource('breakfast', { path: ':breakfastId' }, function() { | |
+ | |
+ this.resource('breakfast', { path: ':breakfastId' }, function() { | |
this.resource('cereal', { path: ':cerealId' }); | |
}); | |
}); | |
- App.IndexRoute = Ember.Route.extend({ | |
+ | |
+ App.IndexRoute = Ember.Route.extend({ | |
actions: { | |
moveToChocolateCereal: function() { | |
var cereal = { cerealId: 'ChocolateYumminess' }; | |
var breakfast = { breakfastId: 'CerealAndMilk' }; | |
- this.transitionTo('cereal', breakfast, cereal); | |
+ | |
+ this.transitionTo('cereal', breakfast, cereal); | |
} | |
} | |
}); | |
``` | |
- Nested Route with Query String Example | |
- ```javascript | |
+ | |
+ Nested Route with Query String Example | |
+ | |
+ ```javascript | |
App.Router.map(function() { | |
this.resource('fruits', function() { | |
this.route('apples'); | |
}); | |
}); | |
- App.IndexRoute = Ember.Route.extend({ | |
+ | |
+ App.IndexRoute = Ember.Route.extend({ | |
actions: { | |
transitionToApples: function() { | |
this.transitionTo('fruits.apples', {queryParams: {color: 'red'}}); | |
@@ -21770,7 +22233,8 @@ | |
} | |
}); | |
``` | |
- @method transitionTo | |
+ | |
+ @method transitionTo | |
@param {String} name the name of the route or a URL | |
@param {...Object} models the model(s) or identifier(s) to be used while | |
transitioning to the route. | |
@@ -21779,7 +22243,7 @@ | |
@return {Transition} the transition object associated with this | |
attempted transition | |
*/ | |
- transitionTo: function (name, context) { | |
+ transitionTo: function(name, context) { | |
var router = this.router; | |
return router.transitionTo.apply(router, arguments); | |
}, | |
@@ -21789,16 +22253,18 @@ | |
to resolve promises, update the URL, or abort any currently active | |
asynchronous transitions (i.e. regular transitions caused by | |
`transitionTo` or URL changes). | |
- This method is handy for performing intermediate transitions on the | |
+ | |
+ This method is handy for performing intermediate transitions on the | |
way to a final destination route, and is called internally by the | |
default implementations of the `error` and `loading` handlers. | |
- @method intermediateTransitionTo | |
+ | |
+ @method intermediateTransitionTo | |
@param {String} name the name of the route | |
@param {...Object} models the model(s) to be used while transitioning | |
to the route. | |
@since 1.2.0 | |
*/ | |
- intermediateTransitionTo: function () { | |
+ intermediateTransitionTo: function() { | |
var router = this.router; | |
router.intermediateTransitionTo.apply(router, arguments); | |
}, | |
@@ -21810,18 +22276,21 @@ | |
The current route params (e.g. `article_id`) will be passed in | |
to the respective model hooks, and if a different model is returned, | |
`setupController` and associated route hooks will re-fire as well. | |
- An example usage of this method is re-querying the server for the | |
+ | |
+ An example usage of this method is re-querying the server for the | |
latest information using the same parameters as when the route | |
was first entered. | |
- Note that this will cause `model` hooks to fire even on routes | |
+ | |
+ Note that this will cause `model` hooks to fire even on routes | |
that were provided a model object when the route was initially | |
entered. | |
- @method refresh | |
+ | |
+ @method refresh | |
@return {Transition} the transition object associated with this | |
attempted transition | |
@since 1.4.0 | |
*/ | |
- refresh: function () { | |
+ refresh: function() { | |
return this.router.router.refresh(this); | |
}, | |
@@ -21830,13 +22299,16 @@ | |
This will replace the current history entry instead of adding a new one. | |
Beside that, it is identical to `transitionTo` in all other respects. See | |
'transitionTo' for additional information regarding multiple models. | |
- Example | |
- ```javascript | |
+ | |
+ Example | |
+ | |
+ ```javascript | |
App.Router.map(function() { | |
this.route('index'); | |
this.route('secret'); | |
}); | |
- App.SecretRoute = Ember.Route.extend({ | |
+ | |
+ App.SecretRoute = Ember.Route.extend({ | |
afterModel: function() { | |
if (!authorized()){ | |
this.replaceWith('index'); | |
@@ -21844,14 +22316,15 @@ | |
} | |
}); | |
``` | |
- @method replaceWith | |
+ | |
+ @method replaceWith | |
@param {String} name the name of the route or a URL | |
@param {...Object} models the model(s) or identifier(s) to be used while | |
transitioning to the route. | |
@return {Transition} the transition object associated with this | |
attempted transition | |
*/ | |
- replaceWith: function () { | |
+ replaceWith: function() { | |
var router = this.router; | |
return router.replaceWith.apply(router, arguments); | |
}, | |
@@ -21859,19 +22332,23 @@ | |
/** | |
Sends an action to the router, which will delegate it to the currently | |
active route hierarchy per the bubbling rules explained under `actions`. | |
- Example | |
- ```javascript | |
+ | |
+ Example | |
+ | |
+ ```javascript | |
App.Router.map(function() { | |
this.route('index'); | |
}); | |
- App.ApplicationRoute = Ember.Route.extend({ | |
+ | |
+ App.ApplicationRoute = Ember.Route.extend({ | |
actions: { | |
track: function(arg) { | |
console.log(arg, 'was clicked'); | |
} | |
} | |
}); | |
- App.IndexRoute = Ember.Route.extend({ | |
+ | |
+ App.IndexRoute = Ember.Route.extend({ | |
actions: { | |
trackIfDebug: function(arg) { | |
if (debug) { | |
@@ -21881,11 +22358,12 @@ | |
} | |
}); | |
``` | |
- @method send | |
+ | |
+ @method send | |
@param {String} name the name of the action to trigger | |
@param {...*} args | |
*/ | |
- send: function () { | |
+ send: function() { | |
if (this.router || !Ember['default'].testing) { | |
this.router.send.apply(this.router, arguments); | |
} else { | |
@@ -21900,15 +22378,16 @@ | |
/** | |
This hook is the entry point for router.js | |
- @private | |
+ | |
+ @private | |
@method setup | |
*/ | |
- setup: function (context, transition) { | |
+ setup: function(context, transition) { | |
var controllerName = this.controllerName || this.routeName; | |
var controller = this.controllerFor(controllerName, true); | |
if (!controller) { | |
- controller = this.generateController(controllerName, context); | |
+ controller = this.generateController(controllerName, context); | |
} | |
// Assign the route's controller so that it can more easily be | |
@@ -21919,7 +22398,7 @@ | |
Ember['default'].deprecate("Ember.Route.setupControllers is deprecated. Please use Ember.Route.setupController(controller, model) instead."); | |
this.setupControllers(controller, context); | |
} else { | |
- var states = property_get.get(this, "_qp.states"); | |
+ var states = property_get.get(this, '_qp.states'); | |
if (transition) { | |
// Update the model dep values used to calculate cache keys. | |
ember_routing__utils.stashParamNames(this.router, transition.state.handlerInfos); | |
@@ -21949,21 +22428,25 @@ | |
called when an attempt is made to transition into a route | |
or one of its children. It is called before `model` and | |
`afterModel`, and is appropriate for cases when: | |
- 1) A decision can be made to redirect elsewhere without | |
+ | |
+ 1) A decision can be made to redirect elsewhere without | |
needing to resolve the model first. | |
2) Any async operations need to occur first before the | |
model is attempted to be resolved. | |
- This hook is provided the current `transition` attempt | |
+ | |
+ This hook is provided the current `transition` attempt | |
as a parameter, which can be used to `.abort()` the transition, | |
save it for a later `.retry()`, or retrieve values set | |
on it from a previous hook. You can also just call | |
`this.transitionTo` to another route to implicitly | |
abort the `transition`. | |
- You can return a promise from this hook to pause the | |
+ | |
+ You can return a promise from this hook to pause the | |
transition until the promise resolves (or rejects). This could | |
be useful, for instance, for retrieving async code from | |
the server that is required to enter a route. | |
- ```javascript | |
+ | |
+ ```javascript | |
App.PostRoute = Ember.Route.extend({ | |
beforeModel: function(transition) { | |
if (!App.Post) { | |
@@ -21972,7 +22455,8 @@ | |
} | |
}); | |
``` | |
- If `App.Post` doesn't exist in the above example, | |
+ | |
+ If `App.Post` doesn't exist in the above example, | |
`beforeModel` will use jQuery's `getScript`, which | |
returns a promise that resolves after the server has | |
successfully retrieved and executed the code from the | |
@@ -21982,14 +22466,16 @@ | |
`beforeModel` right from within the hook (to distinguish | |
from the shared error handling behavior of the `error` | |
hook): | |
- ```javascript | |
+ | |
+ ```javascript | |
App.PostRoute = Ember.Route.extend({ | |
beforeModel: function(transition) { | |
if (!App.Post) { | |
var self = this; | |
return Ember.$.getScript('post.js').then(null, function(e) { | |
self.transitionTo('help'); | |
- // Note that the above transitionTo will implicitly | |
+ | |
+ // Note that the above transitionTo will implicitly | |
// halt the transition. If you were to return | |
// nothing from this promise reject handler, | |
// according to promise semantics, that would | |
@@ -22003,7 +22489,8 @@ | |
} | |
}); | |
``` | |
- @method beforeModel | |
+ | |
+ @method beforeModel | |
@param {Transition} transition | |
@return {Promise} if the value returned from this hook is | |
a promise, the transition will pause until the transition | |
@@ -22019,7 +22506,8 @@ | |
the `transition`, and is therefore suited to performing | |
logic that can only take place after the model has already | |
resolved. | |
- ```javascript | |
+ | |
+ ```javascript | |
App.PostsRoute = Ember.Route.extend({ | |
afterModel: function(posts, transition) { | |
if (posts.get('length') === 1) { | |
@@ -22028,10 +22516,12 @@ | |
} | |
}); | |
``` | |
- Refer to documentation for `beforeModel` for a description | |
+ | |
+ Refer to documentation for `beforeModel` for a description | |
of transition-pausing semantics when a promise is returned | |
from this hook. | |
- @method afterModel | |
+ | |
+ @method afterModel | |
@param {Object} resolvedModel the value returned from `model`, | |
or its resolved value if it was a promise | |
@param {Transition} transition | |
@@ -22044,9 +22534,11 @@ | |
/** | |
A hook you can implement to optionally redirect to another route. | |
- If you call `this.transitionTo` from inside of this hook, this route | |
+ | |
+ If you call `this.transitionTo` from inside of this hook, this route | |
will not be entered in favor of the other hook. | |
- `redirect` and `afterModel` behave very similarly and are | |
+ | |
+ `redirect` and `afterModel` behave very similarly and are | |
called almost at the same time, but they have an important | |
distinction in the case that, from one of these hooks, a | |
redirect into a child route of this route occurs: redirects | |
@@ -22059,7 +22551,8 @@ | |
other words, by the time the `redirect` hook has been called, | |
both the resolved model and attempted entry into this route | |
are considered to be fully validated. | |
- @method redirect | |
+ | |
+ @method redirect | |
@param {Object} model the model for this route | |
@param {Transition} transition the transition object associated with the current transition | |
*/ | |
@@ -22067,57 +22560,73 @@ | |
/** | |
Called when the context is changed by router.js. | |
- @private | |
+ | |
+ @private | |
@method contextDidChange | |
*/ | |
- contextDidChange: function () { | |
+ contextDidChange: function() { | |
this.currentModel = this.context; | |
}, | |
/** | |
A hook you can implement to convert the URL into the model for | |
this route. | |
- ```javascript | |
+ | |
+ ```javascript | |
App.Router.map(function() { | |
this.resource('post', { path: '/posts/:post_id' }); | |
}); | |
``` | |
- The model for the `post` route is `store.find('post', params.post_id)`. | |
- By default, if your route has a dynamic segment ending in `_id`: | |
- * The model class is determined from the segment (`post_id`'s | |
+ | |
+ The model for the `post` route is `store.find('post', params.post_id)`. | |
+ | |
+ By default, if your route has a dynamic segment ending in `_id`: | |
+ | |
+ * The model class is determined from the segment (`post_id`'s | |
class is `App.Post`) | |
* The find method is called on the model class with the value of | |
the dynamic segment. | |
- Note that for routes with dynamic segments, this hook is not always | |
+ | |
+ Note that for routes with dynamic segments, this hook is not always | |
executed. If the route is entered through a transition (e.g. when | |
using the `link-to` Handlebars helper or the `transitionTo` method | |
of routes), and a model context is already provided this hook | |
is not called. | |
- A model context does not include a primitive string or number, | |
+ | |
+ A model context does not include a primitive string or number, | |
which does cause the model hook to be called. | |
- Routes without dynamic segments will always execute the model hook. | |
- ```javascript | |
+ | |
+ Routes without dynamic segments will always execute the model hook. | |
+ | |
+ ```javascript | |
// no dynamic segment, model hook always called | |
this.transitionTo('posts'); | |
- // model passed in, so model hook not called | |
+ | |
+ // model passed in, so model hook not called | |
thePost = store.find('post', 1); | |
this.transitionTo('post', thePost); | |
- // integer passed in, model hook is called | |
+ | |
+ // integer passed in, model hook is called | |
this.transitionTo('post', 1); | |
``` | |
- This hook follows the asynchronous/promise semantics | |
+ | |
+ | |
+ This hook follows the asynchronous/promise semantics | |
described in the documentation for `beforeModel`. In particular, | |
if a promise returned from `model` fails, the error will be | |
handled by the `error` hook on `Ember.Route`. | |
- Example | |
- ```javascript | |
+ | |
+ Example | |
+ | |
+ ```javascript | |
App.PostRoute = Ember.Route.extend({ | |
model: function(params) { | |
return this.store.find('post', params.post_id); | |
} | |
}); | |
``` | |
- @method model | |
+ | |
+ @method model | |
@param {Object} params the parameters extracted from the URL | |
@param {Transition} transition | |
@return {Object|Promise} the model for this route. If | |
@@ -22125,13 +22634,13 @@ | |
the promise resolves, and the resolved value of the promise | |
will be used as the model for this route. | |
*/ | |
- model: function (params, transition) { | |
+ model: function(params, transition) { | |
var match, name, sawParams, value; | |
- var queryParams = property_get.get(this, "_qp.map"); | |
+ var queryParams = property_get.get(this, '_qp.map'); | |
for (var prop in params) { | |
- if (prop === "queryParams" || queryParams && prop in queryParams) { | |
+ if (prop === 'queryParams' || (queryParams && prop in queryParams)) { | |
continue; | |
} | |
@@ -22145,11 +22654,9 @@ | |
if (!name && sawParams) { | |
return copy['default'](params); | |
} else if (!name) { | |
- if (transition.resolveIndex < 1) { | |
- return; | |
- } | |
+ if (transition.resolveIndex < 1) { return; } | |
- var parentModel = transition.state.handlerInfos[transition.resolveIndex - 1].context; | |
+ var parentModel = transition.state.handlerInfos[transition.resolveIndex-1].context; | |
return parentModel; | |
} | |
@@ -22163,47 +22670,54 @@ | |
@param {Object} params the parameters extracted from the URL | |
@param {Transition} transition | |
@return {Object|Promise} the model for this route. | |
- Router.js hook. | |
+ | |
+ Router.js hook. | |
*/ | |
- deserialize: function (params, transition) { | |
+ deserialize: function(params, transition) { | |
return this.model(this.paramsFor(this.routeName), transition); | |
}, | |
/** | |
- @method findModel | |
+ | |
+ @method findModel | |
@param {String} type the model type | |
@param {Object} value the value passed to find | |
*/ | |
- findModel: function () { | |
- var store = property_get.get(this, "store"); | |
+ findModel: function() { | |
+ var store = property_get.get(this, 'store'); | |
return store.find.apply(store, arguments); | |
}, | |
/** | |
Store property provides a hook for data persistence libraries to inject themselves. | |
- By default, this store property provides the exact same functionality previously | |
+ | |
+ By default, this store property provides the exact same functionality previously | |
in the model hook. | |
- Currently, the required interface is: | |
- `store.find(modelName, findArguments)` | |
- @method store | |
+ | |
+ Currently, the required interface is: | |
+ | |
+ `store.find(modelName, findArguments)` | |
+ | |
+ @method store | |
@param {Object} store | |
*/ | |
- store: computed.computed(function () { | |
+ store: computed.computed(function() { | |
var container = this.container; | |
var routeName = this.routeName; | |
- var namespace = property_get.get(this, "router.namespace"); | |
+ var namespace = property_get.get(this, 'router.namespace'); | |
return { | |
- find: function (name, value) { | |
- var modelClass = container.lookupFactory("model:" + name); | |
+ find: function(name, value) { | |
+ var modelClass = container.lookupFactory('model:' + name); | |
- Ember['default'].assert("You used the dynamic segment " + name + "_id in your route " + routeName + ", but " + namespace + "." + string.classify(name) + " did not exist and you did not override your route's `model` " + "hook.", !!modelClass); | |
+ Ember['default'].assert("You used the dynamic segment " + name + "_id in your route " + | |
+ routeName + ", but " + namespace + "." + string.classify(name) + | |
+ " did not exist and you did not override your route's `model` " + | |
+ "hook.", !!modelClass); | |
- if (!modelClass) { | |
- return; | |
- } | |
+ if (!modelClass) { return; } | |
- Ember['default'].assert(string.classify(name) + " has no method `find`.", typeof modelClass.find === "function"); | |
+ Ember['default'].assert(string.classify(name) + ' has no method `find`.', typeof modelClass.find === 'function'); | |
return modelClass.find(value); | |
} | |
@@ -22213,40 +22727,42 @@ | |
/** | |
A hook you can implement to convert the route's model into parameters | |
for the URL. | |
- ```javascript | |
+ | |
+ ```javascript | |
App.Router.map(function() { | |
this.resource('post', { path: '/posts/:post_id' }); | |
}); | |
- App.PostRoute = Ember.Route.extend({ | |
+ | |
+ App.PostRoute = Ember.Route.extend({ | |
model: function(params) { | |
// the server returns `{ id: 12 }` | |
return Ember.$.getJSON('/posts/' + params.post_id); | |
}, | |
- serialize: function(model) { | |
+ | |
+ serialize: function(model) { | |
// this will make the URL `/posts/12` | |
return { post_id: model.id }; | |
} | |
}); | |
``` | |
- The default `serialize` method will insert the model's `id` into the | |
+ | |
+ The default `serialize` method will insert the model's `id` into the | |
route's dynamic segment (in this case, `:post_id`) if the segment contains '_id'. | |
If the route has multiple dynamic segments or does not contain '_id', `serialize` | |
will return `Ember.getProperties(model, params)` | |
- This method is called when `transitionTo` is called with a context | |
+ | |
+ This method is called when `transitionTo` is called with a context | |
in order to populate the URL. | |
- @method serialize | |
+ | |
+ @method serialize | |
@param {Object} model the route's model | |
@param {Array} params an Array of parameter names for the current | |
route (in the example, `['post_id']`. | |
@return {Object} the serialized parameters | |
*/ | |
- serialize: function (model, params) { | |
- if (params.length < 1) { | |
- return; | |
- } | |
- if (!model) { | |
- return; | |
- } | |
+ serialize: function(model, params) { | |
+ if (params.length < 1) { return; } | |
+ if (!model) { return; } | |
var name = params[0]; | |
var object = {}; | |
@@ -22266,20 +22782,25 @@ | |
/** | |
A hook you can use to setup the controller for the current route. | |
- This method is called with the controller for the current route and the | |
+ | |
+ This method is called with the controller for the current route and the | |
model supplied by the `model` hook. | |
- By default, the `setupController` hook sets the `model` property of | |
+ | |
+ By default, the `setupController` hook sets the `model` property of | |
the controller to the `model`. | |
- If you implement the `setupController` hook in your Route, it will | |
+ | |
+ If you implement the `setupController` hook in your Route, it will | |
prevent this default behavior. If you want to preserve that behavior | |
when implementing your `setupController` function, make sure to call | |
`_super`: | |
- ```javascript | |
+ | |
+ ```javascript | |
App.PhotosRoute = Ember.Route.extend({ | |
model: function() { | |
return this.store.find('photo'); | |
}, | |
- setupController: function (controller, model) { | |
+ | |
+ setupController: function (controller, model) { | |
// Call _super for default behavior | |
this._super(controller, model); | |
// Implement your custom setup after | |
@@ -22287,47 +22808,59 @@ | |
} | |
}); | |
``` | |
- This means that your template will get a proxy for the model as its | |
+ | |
+ This means that your template will get a proxy for the model as its | |
context, and you can act as though the model itself was the context. | |
- The provided controller will be one resolved based on the name | |
+ | |
+ The provided controller will be one resolved based on the name | |
of this route. | |
- If no explicit controller is defined, Ember will automatically create | |
+ | |
+ If no explicit controller is defined, Ember will automatically create | |
an appropriate controller for the model. | |
- * if the model is an `Ember.Array` (including record arrays from Ember | |
+ | |
+ * if the model is an `Ember.Array` (including record arrays from Ember | |
Data), the controller is an `Ember.ArrayController`. | |
* otherwise, the controller is an `Ember.ObjectController`. | |
- As an example, consider the router: | |
- ```javascript | |
+ | |
+ As an example, consider the router: | |
+ | |
+ ```javascript | |
App.Router.map(function() { | |
this.resource('post', { path: '/posts/:post_id' }); | |
}); | |
``` | |
- For the `post` route, a controller named `App.PostController` would | |
+ | |
+ For the `post` route, a controller named `App.PostController` would | |
be used if it is defined. If it is not defined, an `Ember.ObjectController` | |
instance would be used. | |
- Example | |
- ```javascript | |
+ | |
+ Example | |
+ | |
+ ```javascript | |
App.PostRoute = Ember.Route.extend({ | |
setupController: function(controller, model) { | |
controller.set('model', model); | |
} | |
}); | |
``` | |
- @method setupController | |
+ | |
+ @method setupController | |
@param {Controller} controller instance | |
@param {Object} model | |
*/ | |
- setupController: function (controller, context, transition) { | |
- if (controller && context !== undefined) { | |
- property_set.set(controller, "model", context); | |
+ setupController: function(controller, context, transition) { | |
+ if (controller && (context !== undefined)) { | |
+ property_set.set(controller, 'model', context); | |
} | |
}, | |
/** | |
Returns the controller for a particular route or name. | |
- The controller instance must already have been created, either through entering the | |
+ | |
+ The controller instance must already have been created, either through entering the | |
associated route or using `generateController`. | |
- ```javascript | |
+ | |
+ ```javascript | |
App.PostRoute = Ember.Route.extend({ | |
setupController: function(controller, post) { | |
this._super(controller, post); | |
@@ -22335,35 +22868,43 @@ | |
} | |
}); | |
``` | |
- @method controllerFor | |
+ | |
+ @method controllerFor | |
@param {String} name the name of the route or controller | |
@return {Ember.Controller} | |
*/ | |
- controllerFor: function (name, _skipAssert) { | |
+ controllerFor: function(name, _skipAssert) { | |
var container = this.container; | |
- var route = container.lookup("route:" + name); | |
+ var route = container.lookup('route:'+name); | |
var controller; | |
if (route && route.controllerName) { | |
name = route.controllerName; | |
} | |
- controller = container.lookup("controller:" + name); | |
+ controller = container.lookup('controller:' + name); | |
// NOTE: We're specifically checking that skipAssert is true, because according | |
// to the old API the second parameter was model. We do not want people who | |
// passed a model to skip the assertion. | |
- Ember['default'].assert("The controller named '" + name + "' could not be found. Make sure " + "that this route exists and has already been entered at least " + "once. If you are accessing a controller not associated with a " + "route, make sure the controller class is explicitly defined.", controller || _skipAssert === true); | |
+ Ember['default'].assert("The controller named '"+name+"' could not be found. Make sure " + | |
+ "that this route exists and has already been entered at least " + | |
+ "once. If you are accessing a controller not associated with a " + | |
+ "route, make sure the controller class is explicitly defined.", | |
+ controller || _skipAssert === true); | |
return controller; | |
}, | |
/** | |
Generates a controller for a route. | |
- If the optional model is passed then the controller type is determined automatically, | |
+ | |
+ If the optional model is passed then the controller type is determined automatically, | |
e.g., an ArrayController for arrays. | |
- Example | |
- ```javascript | |
+ | |
+ Example | |
+ | |
+ ```javascript | |
App.PostRoute = Ember.Route.extend({ | |
setupController: function(controller, post) { | |
this._super(controller, post); | |
@@ -22371,11 +22912,12 @@ | |
} | |
}); | |
``` | |
- @method generateController | |
+ | |
+ @method generateController | |
@param {String} name the name of the controller | |
@param {Object} model the model to infer the type of the controller (optional) | |
*/ | |
- generateController: function (name, model) { | |
+ generateController: function(name, model) { | |
var container = this.container; | |
model = model || this.modelFor(name); | |
@@ -22391,31 +22933,35 @@ | |
resolve a model (or just reuse the model from a parent), | |
it can call `this.modelFor(theNameOfParentRoute)` to | |
retrieve it. | |
- Example | |
- ```javascript | |
+ | |
+ Example | |
+ | |
+ ```javascript | |
App.Router.map(function() { | |
this.resource('post', { path: '/post/:post_id' }, function() { | |
this.resource('comments'); | |
}); | |
}); | |
- App.CommentsRoute = Ember.Route.extend({ | |
+ | |
+ App.CommentsRoute = Ember.Route.extend({ | |
afterModel: function() { | |
this.set('post', this.modelFor('post')); | |
} | |
}); | |
``` | |
- @method modelFor | |
+ | |
+ @method modelFor | |
@param {String} name the name of the route | |
@return {Object} the model object | |
*/ | |
- modelFor: function (name) { | |
- var route = this.container.lookup("route:" + name); | |
+ modelFor: function(name) { | |
+ var route = this.container.lookup('route:' + name); | |
var transition = this.router ? this.router.router.activeTransition : null; | |
// If we are mid-transition, we want to try and look up | |
// resolved parent contexts on the current transitionEvent. | |
if (transition) { | |
- var modelLookupName = route && route.routeName || name; | |
+ var modelLookupName = (route && route.routeName) || name; | |
if (transition.resolvedModels.hasOwnProperty(modelLookupName)) { | |
return transition.resolvedModels[modelLookupName]; | |
} | |
@@ -22426,16 +22972,20 @@ | |
/** | |
A hook you can use to render the template for the current route. | |
- This method is called with the controller for the current route and the | |
+ | |
+ This method is called with the controller for the current route and the | |
model supplied by the `model` hook. By default, it renders the route's | |
template, configured with the controller for the route. | |
- This method can be overridden to set up and render additional or | |
+ | |
+ This method can be overridden to set up and render additional or | |
alternative templates. | |
- ```javascript | |
+ | |
+ ```javascript | |
App.PostsRoute = Ember.Route.extend({ | |
renderTemplate: function(controller, model) { | |
var favController = this.controllerFor('favoritePost'); | |
- // Render the `favoritePost` template into | |
+ | |
+ // Render the `favoritePost` template into | |
// the outlet `posts`, and display the `favoritePost` | |
// controller. | |
this.render('favoritePost', { | |
@@ -22445,11 +22995,12 @@ | |
} | |
}); | |
``` | |
- @method renderTemplate | |
+ | |
+ @method renderTemplate | |
@param {Object} controller the route's controller | |
@param {Object} model the route's model | |
*/ | |
- renderTemplate: function (controller, model) { | |
+ renderTemplate: function(controller, model) { | |
this.render(); | |
}, | |
@@ -22458,25 +23009,31 @@ | |
(indicated by an `{{outlet}}`). `render` is used both during the entry | |
phase of routing (via the `renderTemplate` hook) and later in response to | |
user interaction. | |
- For example, given the following minimal router and templates: | |
- ```javascript | |
+ | |
+ For example, given the following minimal router and templates: | |
+ | |
+ ```javascript | |
Router.map(function() { | |
this.resource('photos'); | |
}); | |
``` | |
- ```handlebars | |
+ | |
+ ```handlebars | |
<!-- application.hbs --> | |
<div class='something-in-the-app-hbs'> | |
{{outlet "anOutletName"}} | |
</div> | |
``` | |
- ```handlebars | |
+ | |
+ ```handlebars | |
<!-- photos.hbs --> | |
<h1>Photos</h1> | |
``` | |
- You can render `photos.hbs` into the `"anOutletName"` outlet of | |
+ | |
+ You can render `photos.hbs` into the `"anOutletName"` outlet of | |
`application.hbs` by calling `render`: | |
- ```javascript | |
+ | |
+ ```javascript | |
// posts route | |
Ember.Route.extend({ | |
renderTemplate: function() { | |
@@ -22487,9 +23044,12 @@ | |
} | |
}); | |
``` | |
- `render` additionally allows you to supply which `view`, `controller`, and | |
+ | |
+ `render` additionally allows you to supply which `view`, `controller`, and | |
`model` objects should be loaded and associated with the rendered template. | |
- ```javascript | |
+ | |
+ | |
+ ```javascript | |
// posts route | |
Ember.Route.extend({ | |
renderTemplate: function(controller, model){ | |
@@ -22503,22 +23063,27 @@ | |
} | |
}); | |
``` | |
- The string values provided for the template name, view, and controller | |
+ | |
+ The string values provided for the template name, view, and controller | |
will eventually pass through to the resolver for lookup. See | |
Ember.Resolver for how these are mapped to JavaScript objects in your | |
application. | |
- Not all options need to be passed to `render`. Default values will be used | |
+ | |
+ Not all options need to be passed to `render`. Default values will be used | |
based on the name of the route specified in the router or the Route's | |
`controllerName`, `viewName` and `templateName` properties. | |
- For example: | |
- ```javascript | |
+ | |
+ For example: | |
+ | |
+ ```javascript | |
// router | |
Router.map(function() { | |
this.route('index'); | |
this.resource('post', { path: '/posts/:post_id' }); | |
}); | |
``` | |
- ```javascript | |
+ | |
+ ```javascript | |
// post route | |
PostRoute = App.Route.extend({ | |
renderTemplate: function() { | |
@@ -22526,10 +23091,13 @@ | |
} | |
}); | |
``` | |
- The name of the `PostRoute`, defined by the router, is `post`. | |
- The following equivalent default options will be applied when | |
+ | |
+ The name of the `PostRoute`, defined by the router, is `post`. | |
+ | |
+ The following equivalent default options will be applied when | |
the Route calls `render`: | |
- ```javascript | |
+ | |
+ ```javascript | |
// | |
this.render('post', { // the template name associated with 'post' Route | |
into: 'application', // the parent route to 'post' Route | |
@@ -22538,9 +23106,11 @@ | |
controller: 'post', // the controller associated with the 'post' Route | |
}) | |
``` | |
- By default the controller's `model` will be the route's model, so it does not | |
+ | |
+ By default the controller's `model` will be the route's model, so it does not | |
need to be passed unless you wish to change which model is being used. | |
- @method render | |
+ | |
+ @method render | |
@param {String} name the name of the template to render | |
@param {Object} [options] the options | |
@param {String} [options.into] the template to render into, | |
@@ -22552,14 +23122,14 @@ | |
@param {Object} [options.model] the model object to set on `options.controller`. | |
Defaults to the return value of the Route's model hook | |
*/ | |
- render: function (_name, options) { | |
+ render: function(_name, options) { | |
Ember['default'].assert("The name in the given arguments is undefined", arguments.length > 0 ? !isNone['default'](arguments[0]) : true); | |
- var namePassed = typeof _name === "string" && !!_name; | |
+ var namePassed = typeof _name === 'string' && !!_name; | |
var isDefaultRender = arguments.length === 0 || Ember['default'].isEmpty(arguments[0]); | |
var name; | |
- if (typeof _name === "object" && !options) { | |
+ if (typeof _name === 'object' && !options) { | |
name = this.routeName; | |
options = _name; | |
} else { | |
@@ -22568,17 +23138,21 @@ | |
var renderOptions = buildRenderOptions(this, namePassed, isDefaultRender, name, options); | |
this.connections.push(renderOptions); | |
- run['default'].once(this.router, "_setOutlets"); | |
+ run['default'].once(this.router, '_setOutlets'); | |
}, | |
/** | |
Disconnects a view that has been rendered into an outlet. | |
- You may pass any or all of the following options to `disconnectOutlet`: | |
- * `outlet`: the name of the outlet to clear (default: 'main') | |
+ | |
+ You may pass any or all of the following options to `disconnectOutlet`: | |
+ | |
+ * `outlet`: the name of the outlet to clear (default: 'main') | |
* `parentView`: the name of the view containing the outlet to clear | |
(default: the view rendered by the parent route) | |
- Example: | |
- ```javascript | |
+ | |
+ Example: | |
+ | |
+ ```javascript | |
App.ApplicationRoute = App.Route.extend({ | |
actions: { | |
showModal: function(evt) { | |
@@ -22596,17 +23170,21 @@ | |
} | |
}); | |
``` | |
- Alternatively, you can pass the `outlet` name directly as a string. | |
- Example: | |
- ```javascript | |
+ | |
+ Alternatively, you can pass the `outlet` name directly as a string. | |
+ | |
+ Example: | |
+ | |
+ ```javascript | |
hideModal: function(evt) { | |
this.disconnectOutlet('modal'); | |
} | |
``` | |
- @method disconnectOutlet | |
+ | |
+ @method disconnectOutlet | |
@param {Object|String} options the options hash or outlet name | |
*/ | |
- disconnectOutlet: function (options) { | |
+ disconnectOutlet: function(options) { | |
var outletName; | |
var parentView; | |
if (!options || typeof options === "string") { | |
@@ -22615,19 +23193,20 @@ | |
outletName = options.outlet; | |
parentView = options.parentView; | |
} | |
- parentView = parentView && parentView.replace(/\//g, "."); | |
- outletName = outletName || "main"; | |
+ parentView = parentView && parentView.replace(/\//g, '.'); | |
+ outletName = outletName || 'main'; | |
this._disconnectOutlet(outletName, parentView); | |
for (var i = 0; i < this.router.router.currentHandlerInfos.length; i++) { | |
// This non-local state munging is sadly necessary to maintain | |
// backward compatibility with our existing semantics, which allow | |
// any route to disconnectOutlet things originally rendered by any | |
// other route. This should all get cut in 2.0. | |
- this.router.router.currentHandlerInfos[i].handler._disconnectOutlet(outletName, parentView); | |
+ this.router.router. | |
+ currentHandlerInfos[i].handler._disconnectOutlet(outletName, parentView); | |
} | |
}, | |
- _disconnectOutlet: function (outletName, parentView) { | |
+ _disconnectOutlet: function(outletName, parentView) { | |
var parent = parentRoute(this); | |
if (parent && parentView === parent.routeName) { | |
parentView = undefined; | |
@@ -22646,23 +23225,24 @@ | |
outlet: connection.outlet, | |
name: connection.name | |
}; | |
- run['default'].once(this.router, "_setOutlets"); | |
+ run['default'].once(this.router, '_setOutlets'); | |
} | |
} | |
}, | |
- willDestroy: function () { | |
+ willDestroy: function() { | |
this.teardownViews(); | |
}, | |
/** | |
@private | |
- @method teardownViews | |
+ | |
+ @method teardownViews | |
*/ | |
- teardownViews: function () { | |
+ teardownViews: function() { | |
if (this.connections && this.connections.length > 0) { | |
this.connections = []; | |
- run['default'].once(this.router, "_setOutlets"); | |
+ run['default'].once(this.router, '_setOutlets'); | |
} | |
} | |
}); | |
@@ -22679,17 +23259,13 @@ | |
} | |
function handlerInfoFor(route, handlerInfos, _offset) { | |
- if (!handlerInfos) { | |
- return; | |
- } | |
+ if (!handlerInfos) { return; } | |
var offset = _offset || 0; | |
var current; | |
- for (var i = 0, l = handlerInfos.length; i < l; i++) { | |
+ for (var i=0, l=handlerInfos.length; i<l; i++) { | |
current = handlerInfos[i].handler; | |
- if (current === route) { | |
- return handlerInfos[i + offset]; | |
- } | |
+ if (current === route) { return handlerInfos[i+offset]; } | |
} | |
} | |
@@ -22699,12 +23275,12 @@ | |
var viewName; | |
var ViewClass; | |
var template; | |
- var LOG_VIEW_LOOKUPS = property_get.get(route.router, "namespace.LOG_VIEW_LOOKUPS"); | |
- var into = options && options.into && options.into.replace(/\//g, "."); | |
- var outlet = options && options.outlet || "main"; | |
+ var LOG_VIEW_LOOKUPS = property_get.get(route.router, 'namespace.LOG_VIEW_LOOKUPS'); | |
+ var into = options && options.into && options.into.replace(/\//g, '.'); | |
+ var outlet = (options && options.outlet) || 'main'; | |
if (name) { | |
- name = name.replace(/\//g, "."); | |
+ name = name.replace(/\//g, '.'); | |
templateName = name; | |
} else { | |
name = route.routeName; | |
@@ -22713,31 +23289,31 @@ | |
if (!controller) { | |
if (namePassed) { | |
- controller = route.container.lookup("controller:" + name) || route.controllerName || route.routeName; | |
+ controller = route.container.lookup('controller:' + name) || route.controllerName || route.routeName; | |
} else { | |
- controller = route.controllerName || route.container.lookup("controller:" + name); | |
+ controller = route.controllerName || route.container.lookup('controller:' + name); | |
} | |
} | |
- if (typeof controller === "string") { | |
+ if (typeof controller === 'string') { | |
var controllerName = controller; | |
- controller = route.container.lookup("controller:" + controllerName); | |
+ controller = route.container.lookup('controller:' + controllerName); | |
if (!controller) { | |
throw new EmberError['default']("You passed `controller: '" + controllerName + "'` into the `render` method, but no such controller could be found."); | |
} | |
} | |
if (options && options.model) { | |
- controller.set("model", options.model); | |
+ controller.set('model', options.model); | |
} | |
viewName = options && options.view || namePassed && name || route.viewName || name; | |
- ViewClass = route.container.lookupFactory("view:" + viewName); | |
- template = route.container.lookup("template:" + templateName); | |
+ ViewClass = route.container.lookupFactory('view:' + viewName); | |
+ template = route.container.lookup('template:' + templateName); | |
if (!ViewClass && !template) { | |
Ember['default'].assert("Could not find \"" + name + "\" template or view.", isDefaultRender); | |
if (LOG_VIEW_LOOKUPS) { | |
- Ember['default'].Logger.info("Could not find \"" + name + "\" template or view. Nothing will be rendered", { fullName: "template:" + name }); | |
+ Ember['default'].Logger.info("Could not find \"" + name + "\" template or view. Nothing will be rendered", { fullName: 'template:' + name }); | |
} | |
} | |
@@ -22759,14 +23335,12 @@ | |
} | |
function getFullQueryParams(router, state) { | |
- if (state.fullQueryParams) { | |
- return state.fullQueryParams; | |
- } | |
+ if (state.fullQueryParams) { return state.fullQueryParams; } | |
state.fullQueryParams = {}; | |
merge['default'](state.fullQueryParams, state.queryParams); | |
- var targetRouteName = state.handlerInfos[state.handlerInfos.length - 1].name; | |
+ var targetRouteName = state.handlerInfos[state.handlerInfos.length-1].name; | |
router._deserializeQueryParams(targetRouteName, state.fullQueryParams); | |
return state.fullQueryParams; | |
} | |
@@ -22775,23 +23349,23 @@ | |
state.queryParamsFor = state.queryParamsFor || {}; | |
var name = route.routeName; | |
- if (state.queryParamsFor[name]) { | |
- return state.queryParamsFor[name]; | |
- } | |
+ if (state.queryParamsFor[name]) { return state.queryParamsFor[name]; } | |
var fullQueryParams = getFullQueryParams(route.router, state); | |
var params = state.queryParamsFor[name] = {}; | |
// Copy over all the query params for this route/controller into params hash. | |
- var qpMeta = property_get.get(route, "_qp"); | |
+ var qpMeta = property_get.get(route, '_qp'); | |
var qps = qpMeta.qps; | |
for (var i = 0, len = qps.length; i < len; ++i) { | |
// Put deserialized qp on params hash. | |
var qp = qps[i]; | |
var qpValueWasPassedIn = (qp.prop in fullQueryParams); | |
- params[qp.prop] = qpValueWasPassedIn ? fullQueryParams[qp.prop] : copyDefaultValue(qp.def); | |
+ params[qp.prop] = qpValueWasPassedIn ? | |
+ fullQueryParams[qp.prop] : | |
+ copyDefaultValue(qp.def); | |
} | |
return params; | |
@@ -22811,9 +23385,7 @@ | |
'use strict'; | |
- function K() { | |
- return this; | |
- } | |
+ function K() { return this; } | |
var slice = [].slice; | |
@@ -22830,25 +23402,29 @@ | |
/** | |
The `location` property determines the type of URL's that your | |
application will use. | |
- The following location types are currently available: | |
- * `hash` | |
+ | |
+ The following location types are currently available: | |
+ | |
+ * `hash` | |
* `history` | |
* `none` | |
- @property location | |
+ | |
+ @property location | |
@default 'hash' | |
@see {Ember.Location} | |
*/ | |
- location: "hash", | |
+ location: 'hash', | |
/** | |
Represents the URL of the root of the application, often '/'. This prefix is | |
assumed on all routes defined on this router. | |
- @property rootURL | |
+ | |
+ @property rootURL | |
@default '/' | |
*/ | |
- rootURL: "/", | |
+ rootURL: '/', | |
- _initRouterJs: function (moduleBasedResolver) { | |
+ _initRouterJs: function(moduleBasedResolver) { | |
var router = this.router = new Router['default'](); | |
router.triggerEvent = triggerEvent; | |
@@ -22861,8 +23437,8 @@ | |
}); | |
function generateDSL() { | |
- this.resource("application", { path: "/", overrideNameAssertion: true }, function () { | |
- for (var i = 0; i < dslCallbacks.length; i++) { | |
+ this.resource('application', { path: "/", overrideNameAssertion: true }, function() { | |
+ for (var i=0; i < dslCallbacks.length; i++) { | |
dslCallbacks[i].call(this); | |
} | |
}); | |
@@ -22870,14 +23446,14 @@ | |
generateDSL.call(dsl); | |
- if (property_get.get(this, "namespace.LOG_TRANSITIONS_INTERNAL")) { | |
+ if (property_get.get(this, 'namespace.LOG_TRANSITIONS_INTERNAL')) { | |
router.log = Ember['default'].Logger.debug; | |
} | |
router.map(dsl.generate()); | |
}, | |
- init: function () { | |
+ init: function() { | |
this._activeViews = {}; | |
this._setupLocation(); | |
this._qpCache = {}; | |
@@ -22886,28 +23462,31 @@ | |
/** | |
Represents the current URL. | |
- @method url | |
+ | |
+ @method url | |
@return {String} The current URL. | |
*/ | |
- url: computed.computed(function () { | |
- return property_get.get(this, "location").getURL(); | |
+ url: computed.computed(function() { | |
+ return property_get.get(this, 'location').getURL(); | |
}), | |
/** | |
Initializes the current router instance and sets up the change handling | |
event listeners used by the instances `location` implementation. | |
- A property named `initialURL` will be used to determine the initial URL. | |
+ | |
+ A property named `initialURL` will be used to determine the initial URL. | |
If no value is found `/` will be used. | |
- @method startRouting | |
+ | |
+ @method startRouting | |
@private | |
*/ | |
- startRouting: function (moduleBasedResolver) { | |
- var initialURL = property_get.get(this, "initialURL"); | |
- var location = property_get.get(this, "location"); | |
+ startRouting: function(moduleBasedResolver) { | |
+ var initialURL = property_get.get(this, 'initialURL'); | |
+ var location = property_get.get(this, 'location'); | |
if (this.setupRouter(moduleBasedResolver, location)) { | |
if (typeof initialURL === "undefined") { | |
- initialURL = property_get.get(this, "location").getURL(); | |
+ initialURL = property_get.get(this, 'location').getURL(); | |
} | |
var initialTransition = this.handleURL(initialURL); | |
if (initialTransition && initialTransition.error) { | |
@@ -22916,22 +23495,22 @@ | |
} | |
}, | |
- setupRouter: function (moduleBasedResolver) { | |
+ setupRouter: function(moduleBasedResolver) { | |
this._initRouterJs(moduleBasedResolver); | |
var router = this.router; | |
- var location = property_get.get(this, "location"); | |
+ var location = property_get.get(this, 'location'); | |
var self = this; | |
// Allow the Location class to cancel the router setup while it refreshes | |
// the page | |
- if (property_get.get(location, "cancelRouterSetup")) { | |
+ if (property_get.get(location, 'cancelRouterSetup')) { | |
return false; | |
} | |
this._setupRouter(router, location); | |
- location.onUpdateURL(function (url) { | |
+ location.onUpdateURL(function(url) { | |
self.handleURL(url); | |
}); | |
@@ -22941,29 +23520,31 @@ | |
/** | |
Handles updating the paths and notifying any listeners of the URL | |
change. | |
- Triggers the router level `didTransition` hook. | |
- @method didTransition | |
+ | |
+ Triggers the router level `didTransition` hook. | |
+ | |
+ @method didTransition | |
@private | |
@since 1.2.0 | |
*/ | |
- didTransition: function (infos) { | |
+ didTransition: function(infos) { | |
updatePaths(this); | |
this._cancelSlowTransitionTimer(); | |
- this.notifyPropertyChange("url"); | |
- this.set("currentState", this.targetState); | |
+ this.notifyPropertyChange('url'); | |
+ this.set('currentState', this.targetState); | |
// Put this in the runloop so url will be accurate. Seems | |
// less surprising than didTransition being out of sync. | |
- run['default'].once(this, this.trigger, "didTransition"); | |
+ run['default'].once(this, this.trigger, 'didTransition'); | |
- if (property_get.get(this, "namespace").LOG_TRANSITIONS) { | |
+ if (property_get.get(this, 'namespace').LOG_TRANSITIONS) { | |
Ember['default'].Logger.log("Transitioned into '" + EmberRouter._routePath(infos) + "'"); | |
} | |
}, | |
- _setOutlets: function () { | |
+ _setOutlets: function() { | |
var handlerInfos = this.router.currentHandlerInfos; | |
var route; | |
var defaultParentState; | |
@@ -22980,7 +23561,7 @@ | |
for (var j = 0; j < connections.length; j++) { | |
var appended = appendLiveRoute(liveRoutes, defaultParentState, connections[j]); | |
liveRoutes = appended.liveRoutes; | |
- if (appended.ownState.render.name === route.routeName || appended.ownState.render.outlet === "main") { | |
+ if (appended.ownState.render.name === route.routeName || appended.ownState.render.outlet === 'main') { | |
ownState = appended.ownState; | |
} | |
} | |
@@ -22990,9 +23571,9 @@ | |
defaultParentState = ownState; | |
} | |
if (!this._toplevelView) { | |
- var OutletView = this.container.lookupFactory("view:-outlet"); | |
+ var OutletView = this.container.lookupFactory('view:-outlet'); | |
this._toplevelView = OutletView.create({ _isTopLevel: true }); | |
- var instance = this.container.lookup("-application-instance:main"); | |
+ var instance = this.container.lookup('-application-instance:main'); | |
instance.didCreateRootView(this._toplevelView); | |
} | |
this._toplevelView.setOutletState(liveRoutes); | |
@@ -23001,41 +23582,43 @@ | |
/** | |
Handles notifying any listeners of an impending URL | |
change. | |
- Triggers the router level `willTransition` hook. | |
- @method willTransition | |
+ | |
+ Triggers the router level `willTransition` hook. | |
+ | |
+ @method willTransition | |
@private | |
@since 1.11.0 | |
*/ | |
- willTransition: function (oldInfos, newInfos, transition) { | |
- run['default'].once(this, this.trigger, "willTransition", transition); | |
+ willTransition: function(oldInfos, newInfos, transition) { | |
+ run['default'].once(this, this.trigger, 'willTransition', transition); | |
- if (property_get.get(this, "namespace").LOG_TRANSITIONS) { | |
+ if (property_get.get(this, 'namespace').LOG_TRANSITIONS) { | |
Ember['default'].Logger.log("Preparing to transition from '" + EmberRouter._routePath(oldInfos) + "' to '" + EmberRouter._routePath(newInfos) + "'"); | |
} | |
}, | |
- handleURL: function (url) { | |
+ handleURL: function(url) { | |
// Until we have an ember-idiomatic way of accessing #hashes, we need to | |
// remove it because router.js doesn't know how to handle it. | |
url = url.split(/#(.+)?/)[0]; | |
- return this._doURLTransition("handleURL", url); | |
+ return this._doURLTransition('handleURL', url); | |
}, | |
- _doURLTransition: function (routerJsMethod, url) { | |
- var transition = this.router[routerJsMethod](url || "/"); | |
+ _doURLTransition: function(routerJsMethod, url) { | |
+ var transition = this.router[routerJsMethod](url || '/'); | |
didBeginTransition(transition, this); | |
return transition; | |
}, | |
- transitionTo: function () { | |
+ transitionTo: function() { | |
var args = slice.call(arguments); | |
var queryParams; | |
if (resemblesURL(args[0])) { | |
- return this._doURLTransition("transitionTo", args[0]); | |
+ return this._doURLTransition('transitionTo', args[0]); | |
} | |
- var possibleQueryParams = args[args.length - 1]; | |
- if (possibleQueryParams && possibleQueryParams.hasOwnProperty("queryParams")) { | |
+ var possibleQueryParams = args[args.length-1]; | |
+ if (possibleQueryParams && possibleQueryParams.hasOwnProperty('queryParams')) { | |
queryParams = args.pop().queryParams; | |
} else { | |
queryParams = {}; | |
@@ -23045,34 +23628,35 @@ | |
return this._doTransition(targetRouteName, args, queryParams); | |
}, | |
- intermediateTransitionTo: function () { | |
+ intermediateTransitionTo: function() { | |
this.router.intermediateTransitionTo.apply(this.router, arguments); | |
updatePaths(this); | |
var infos = this.router.currentHandlerInfos; | |
- if (property_get.get(this, "namespace").LOG_TRANSITIONS) { | |
+ if (property_get.get(this, 'namespace').LOG_TRANSITIONS) { | |
Ember['default'].Logger.log("Intermediate-transitioned into '" + EmberRouter._routePath(infos) + "'"); | |
} | |
}, | |
- replaceWith: function () { | |
- return this.transitionTo.apply(this, arguments).method("replace"); | |
+ replaceWith: function() { | |
+ return this.transitionTo.apply(this, arguments).method('replace'); | |
}, | |
- generate: function () { | |
+ generate: function() { | |
var url = this.router.generate.apply(this.router, arguments); | |
return this.location.formatURL(url); | |
}, | |
/** | |
Determines if the supplied route is currently active. | |
- @method isActive | |
+ | |
+ @method isActive | |
@param routeName | |
@return {Boolean} | |
@private | |
*/ | |
- isActive: function (routeName) { | |
+ isActive: function(routeName) { | |
var router = this.router; | |
return router.isActive.apply(router, arguments); | |
}, | |
@@ -23081,7 +23665,8 @@ | |
An alternative form of `isActive` that doesn't require | |
manual concatenation of the arguments into a single | |
array. | |
- @method isActiveIntent | |
+ | |
+ @method isActiveIntent | |
@param routeName | |
@param models | |
@param queryParams | |
@@ -23089,37 +23674,39 @@ | |
@private | |
@since 1.7.0 | |
*/ | |
- isActiveIntent: function (routeName, models, queryParams) { | |
+ isActiveIntent: function(routeName, models, queryParams) { | |
return this.currentState.isActiveIntent(routeName, models, queryParams); | |
}, | |
- send: function (name, context) { | |
+ send: function(name, context) { | |
this.router.trigger.apply(this.router, arguments); | |
}, | |
/** | |
Does this router instance have the given route. | |
- @method hasRoute | |
+ | |
+ @method hasRoute | |
@return {Boolean} | |
@private | |
*/ | |
- hasRoute: function (route) { | |
+ hasRoute: function(route) { | |
return this.router.hasRoute(route); | |
}, | |
/** | |
Resets the state of the router by clearing the current route | |
handlers and deactivating them. | |
- @private | |
+ | |
+ @private | |
@method reset | |
*/ | |
- reset: function () { | |
+ reset: function() { | |
if (this.router) { | |
this.router.reset(); | |
} | |
}, | |
- willDestroy: function () { | |
+ willDestroy: function() { | |
if (this._toplevelView) { | |
this._toplevelView.destroy(); | |
this._toplevelView = null; | |
@@ -23128,16 +23715,16 @@ | |
this.reset(); | |
}, | |
- _lookupActiveView: function (templateName) { | |
+ _lookupActiveView: function(templateName) { | |
var active = this._activeViews[templateName]; | |
return active && active[0]; | |
}, | |
- _connectActiveView: function (templateName, view) { | |
+ _connectActiveView: function(templateName, view) { | |
var existing = this._activeViews[templateName]; | |
if (existing) { | |
- existing[0].off("willDestroyElement", this, existing[1]); | |
+ existing[0].off('willDestroyElement', this, existing[1]); | |
} | |
function disconnectActiveView() { | |
@@ -23145,55 +23732,55 @@ | |
} | |
this._activeViews[templateName] = [view, disconnectActiveView]; | |
- view.one("willDestroyElement", this, disconnectActiveView); | |
+ view.one('willDestroyElement', this, disconnectActiveView); | |
}, | |
- _setupLocation: function () { | |
- var location = property_get.get(this, "location"); | |
- var rootURL = property_get.get(this, "rootURL"); | |
+ _setupLocation: function() { | |
+ var location = property_get.get(this, 'location'); | |
+ var rootURL = property_get.get(this, 'rootURL'); | |
- if (rootURL && this.container && !this.container._registry.has("-location-setting:root-url")) { | |
- this.container._registry.register("-location-setting:root-url", rootURL, { | |
+ if (rootURL && this.container && !this.container._registry.has('-location-setting:root-url')) { | |
+ this.container._registry.register('-location-setting:root-url', rootURL, { | |
instantiate: false | |
}); | |
} | |
- if ("string" === typeof location && this.container) { | |
- var resolvedLocation = this.container.lookup("location:" + location); | |
+ if ('string' === typeof location && this.container) { | |
+ var resolvedLocation = this.container.lookup('location:' + location); | |
- if ("undefined" !== typeof resolvedLocation) { | |
- location = property_set.set(this, "location", resolvedLocation); | |
+ if ('undefined' !== typeof resolvedLocation) { | |
+ location = property_set.set(this, 'location', resolvedLocation); | |
} else { | |
// Allow for deprecated registration of custom location API's | |
var options = { | |
implementation: location | |
}; | |
- location = property_set.set(this, "location", EmberLocation['default'].create(options)); | |
+ location = property_set.set(this, 'location', EmberLocation['default'].create(options)); | |
} | |
} | |
- if (location !== null && typeof location === "object") { | |
- if (rootURL && typeof rootURL === "string") { | |
+ if (location !== null && typeof location === 'object') { | |
+ if (rootURL && typeof rootURL === 'string') { | |
location.rootURL = rootURL; | |
} | |
// ensure that initState is called AFTER the rootURL is set on | |
// the location instance | |
- if (typeof location.initState === "function") { | |
+ if (typeof location.initState === 'function') { | |
location.initState(); | |
} | |
} | |
}, | |
- _getHandlerFunction: function () { | |
+ _getHandlerFunction: function() { | |
var seen = create['default'](null); | |
var container = this.container; | |
- var DefaultRoute = container.lookupFactory("route:basic"); | |
+ var DefaultRoute = container.lookupFactory('route:basic'); | |
var self = this; | |
- return function (name) { | |
- var routeName = "route:" + name; | |
+ return function(name) { | |
+ var routeName = 'route:' + name; | |
var handler = container.lookup(routeName); | |
if (seen[name]) { | |
@@ -23206,7 +23793,7 @@ | |
container._registry.register(routeName, DefaultRoute.extend()); | |
handler = container.lookup(routeName); | |
- if (property_get.get(self, "namespace.LOG_ACTIVE_GENERATION")) { | |
+ if (property_get.get(self, 'namespace.LOG_ACTIVE_GENERATION')) { | |
Ember['default'].Logger.info("generated -> " + routeName, { fullName: routeName }); | |
} | |
} | |
@@ -23216,47 +23803,47 @@ | |
}; | |
}, | |
- _setupRouter: function (router, location) { | |
+ _setupRouter: function(router, location) { | |
var lastURL; | |
var emberRouter = this; | |
router.getHandler = this._getHandlerFunction(); | |
- var doUpdateURL = function () { | |
+ var doUpdateURL = function() { | |
location.setURL(lastURL); | |
}; | |
- router.updateURL = function (path) { | |
+ router.updateURL = function(path) { | |
lastURL = path; | |
run['default'].once(doUpdateURL); | |
}; | |
if (location.replaceURL) { | |
- var doReplaceURL = function () { | |
+ var doReplaceURL = function() { | |
location.replaceURL(lastURL); | |
}; | |
- router.replaceURL = function (path) { | |
+ router.replaceURL = function(path) { | |
lastURL = path; | |
run['default'].once(doReplaceURL); | |
}; | |
} | |
- router.didTransition = function (infos) { | |
+ router.didTransition = function(infos) { | |
emberRouter.didTransition(infos); | |
}; | |
- router.willTransition = function (oldInfos, newInfos, transition) { | |
+ router.willTransition = function(oldInfos, newInfos, transition) { | |
emberRouter.willTransition(oldInfos, newInfos, transition); | |
}; | |
}, | |
- _serializeQueryParams: function (targetRouteName, queryParams) { | |
+ _serializeQueryParams: function(targetRouteName, queryParams) { | |
var groupedByUrlKey = {}; | |
- forEachQueryParam(this, targetRouteName, queryParams, function (key, value, qp) { | |
+ forEachQueryParam(this, targetRouteName, queryParams, function(key, value, qp) { | |
var urlKey = qp.urlKey; | |
if (!groupedByUrlKey[urlKey]) { | |
groupedByUrlKey[urlKey] = []; | |
@@ -23270,20 +23857,25 @@ | |
for (var key in groupedByUrlKey) { | |
var qps = groupedByUrlKey[key]; | |
- Ember['default'].assert(string.fmt("You're not allowed to have more than one controller " + "property map to the same query param key, but both " + "`%@` and `%@` map to `%@`. You can fix this by mapping " + "one of the controller properties to a different query " + "param key via the `as` config option, e.g. `%@: { as: 'other-%@' }`", [qps[0].qp.fprop, qps[1] ? qps[1].qp.fprop : "", qps[0].qp.urlKey, qps[0].qp.prop, qps[0].qp.prop]), qps.length <= 1); | |
+ Ember['default'].assert(string.fmt("You're not allowed to have more than one controller " + | |
+ "property map to the same query param key, but both " + | |
+ "`%@` and `%@` map to `%@`. You can fix this by mapping " + | |
+ "one of the controller properties to a different query " + | |
+ "param key via the `as` config option, e.g. `%@: { as: 'other-%@' }`", | |
+ [qps[0].qp.fprop, qps[1] ? qps[1].qp.fprop : "", qps[0].qp.urlKey, qps[0].qp.prop, qps[0].qp.prop]), qps.length <= 1); | |
var qp = qps[0].qp; | |
queryParams[qp.urlKey] = qp.route.serializeQueryParam(qps[0].value, qp.urlKey, qp.type); | |
} | |
}, | |
- _deserializeQueryParams: function (targetRouteName, queryParams) { | |
- forEachQueryParam(this, targetRouteName, queryParams, function (key, value, qp) { | |
+ _deserializeQueryParams: function(targetRouteName, queryParams) { | |
+ forEachQueryParam(this, targetRouteName, queryParams, function(key, value, qp) { | |
delete queryParams[key]; | |
queryParams[qp.prop] = qp.route.deserializeQueryParam(value, qp.urlKey, qp.type); | |
}); | |
}, | |
- _pruneDefaultQueryParamValues: function (targetRouteName, queryParams) { | |
+ _pruneDefaultQueryParamValues: function(targetRouteName, queryParams) { | |
var qps = this._queryParamsFor(targetRouteName); | |
for (var key in queryParams) { | |
var qp = qps.map[key]; | |
@@ -23293,7 +23885,7 @@ | |
} | |
}, | |
- _doTransition: function (_targetRouteName, models, _queryParams) { | |
+ _doTransition: function(_targetRouteName, models, _queryParams) { | |
var targetRouteName = _targetRouteName || utils.getActiveTargetName(this.router); | |
Ember['default'].assert("The route " + targetRouteName + " was not found", targetRouteName && this.router.hasRoute(targetRouteName)); | |
@@ -23309,7 +23901,7 @@ | |
return transitionPromise; | |
}, | |
- _prepareQueryParams: function (targetRouteName, models, queryParams) { | |
+ _prepareQueryParams: function(targetRouteName, models, queryParams) { | |
this._hydrateUnsuppliedQueryParams(targetRouteName, models, queryParams); | |
this._serializeQueryParams(targetRouteName, queryParams); | |
this._pruneDefaultQueryParamValues(targetRouteName, queryParams); | |
@@ -23319,7 +23911,7 @@ | |
Returns a merged query params meta object for a given route. | |
Useful for asking a route what its known query params are. | |
*/ | |
- _queryParamsFor: function (leafRouteName) { | |
+ _queryParamsFor: function(leafRouteName) { | |
if (this._qpCache[leafRouteName]) { | |
return this._qpCache[leafRouteName]; | |
} | |
@@ -23337,11 +23929,9 @@ | |
for (var i = 0, len = recogHandlerInfos.length; i < len; ++i) { | |
var recogHandler = recogHandlerInfos[i]; | |
var route = routerjs.getHandler(recogHandler.handler); | |
- var qpMeta = property_get.get(route, "_qp"); | |
+ var qpMeta = property_get.get(route, '_qp'); | |
- if (!qpMeta) { | |
- continue; | |
- } | |
+ if (!qpMeta) { continue; } | |
merge['default'](map, qpMeta.map); | |
qps.push.apply(qps, qpMeta.qps); | |
@@ -23356,12 +23946,14 @@ | |
/* | |
becomeResolved: function(payload, resolvedContext) { | |
var params = this.serialize(resolvedContext); | |
- if (payload) { | |
+ | |
+ if (payload) { | |
this.stashResolvedModel(payload, resolvedContext); | |
payload.params = payload.params || {}; | |
payload.params[this.name] = params; | |
} | |
- return this.factory('resolved', { | |
+ | |
+ return this.factory('resolved', { | |
context: resolvedContext, | |
name: this.name, | |
handler: this.handler, | |
@@ -23370,7 +23962,7 @@ | |
}, | |
*/ | |
- _hydrateUnsuppliedQueryParams: function (leafRouteName, contexts, queryParams) { | |
+ _hydrateUnsuppliedQueryParams: function(leafRouteName, contexts, queryParams) { | |
var state = calculatePostTransitionState(this, leafRouteName, contexts); | |
var handlerInfos = state.handlerInfos; | |
var appCache = this._bucketCache; | |
@@ -23379,11 +23971,12 @@ | |
for (var i = 0, len = handlerInfos.length; i < len; ++i) { | |
var route = handlerInfos[i].handler; | |
- var qpMeta = property_get.get(route, "_qp"); | |
+ var qpMeta = property_get.get(route, '_qp'); | |
for (var j = 0, qpLen = qpMeta.qps.length; j < qpLen; ++j) { | |
var qp = qpMeta.qps[j]; | |
- var presentProp = qp.prop in queryParams && qp.prop || qp.fprop in queryParams && qp.fprop; | |
+ var presentProp = qp.prop in queryParams && qp.prop || | |
+ qp.fprop in queryParams && qp.fprop; | |
if (presentProp) { | |
if (presentProp !== qp.fprop) { | |
@@ -23392,7 +23985,7 @@ | |
} | |
} else { | |
var controllerProto = qp.cProto; | |
- var cacheMeta = property_get.get(controllerProto, "_cacheMeta"); | |
+ var cacheMeta = property_get.get(controllerProto, '_cacheMeta'); | |
var cacheKey = controllerProto._calculateCacheKey(qp.ctrl, cacheMeta[qp.prop].parts, state.params); | |
queryParams[qp.fprop] = appCache.lookup(cacheKey, qp.prop, qp.def); | |
@@ -23401,28 +23994,28 @@ | |
} | |
}, | |
- _scheduleLoadingEvent: function (transition, originRoute) { | |
+ _scheduleLoadingEvent: function(transition, originRoute) { | |
this._cancelSlowTransitionTimer(); | |
- this._slowTransitionTimer = run['default'].scheduleOnce("routerTransitions", this, "_handleSlowTransition", transition, originRoute); | |
+ this._slowTransitionTimer = run['default'].scheduleOnce('routerTransitions', this, '_handleSlowTransition', transition, originRoute); | |
}, | |
currentState: null, | |
targetState: null, | |
- _handleSlowTransition: function (transition, originRoute) { | |
+ _handleSlowTransition: function(transition, originRoute) { | |
if (!this.router.activeTransition) { | |
// Don't fire an event if we've since moved on from | |
// the transition that put us in a loading state. | |
return; | |
} | |
- this.set("targetState", RouterState['default'].create({ | |
+ this.set('targetState', RouterState['default'].create({ | |
emberRouter: this, | |
routerJs: this.router, | |
routerJsState: this.router.activeTransition.state | |
})); | |
- transition.trigger(true, "loading", transition, originRoute); | |
+ transition.trigger(true, 'loading', transition, originRoute); | |
}, | |
_cancelSlowTransitionTimer: function () { | |
@@ -23469,16 +24062,16 @@ | |
// and are not meant to be overridable. | |
var defaultActionHandlers = { | |
- willResolveModel: function (transition, originRoute) { | |
+ willResolveModel: function(transition, originRoute) { | |
originRoute.router._scheduleLoadingEvent(transition, originRoute); | |
}, | |
- error: function (error, transition, originRoute) { | |
+ error: function(error, transition, originRoute) { | |
// Attempt to find an appropriate error substate to enter. | |
var router = originRoute.router; | |
- var tryTopLevel = forEachRouteAbove(originRoute, transition, function (route, childRoute) { | |
- var childErrorRouteName = findChildRouteName(route, childRoute, "error"); | |
+ var tryTopLevel = forEachRouteAbove(originRoute, transition, function(route, childRoute) { | |
+ var childErrorRouteName = findChildRouteName(route, childRoute, 'error'); | |
if (childErrorRouteName) { | |
router.intermediateTransitionTo(childErrorRouteName, error); | |
return; | |
@@ -23488,21 +24081,21 @@ | |
if (tryTopLevel) { | |
// Check for top-level error state to enter. | |
- if (routeHasBeenDefined(originRoute.router, "application_error")) { | |
- router.intermediateTransitionTo("application_error", error); | |
+ if (routeHasBeenDefined(originRoute.router, 'application_error')) { | |
+ router.intermediateTransitionTo('application_error', error); | |
return; | |
} | |
} | |
- logError(error, "Error while processing route: " + transition.targetName); | |
+ logError(error, 'Error while processing route: ' + transition.targetName); | |
}, | |
- loading: function (transition, originRoute) { | |
+ loading: function(transition, originRoute) { | |
// Attempt to find an appropriate loading substate to enter. | |
var router = originRoute.router; | |
- var tryTopLevel = forEachRouteAbove(originRoute, transition, function (route, childRoute) { | |
- var childLoadingRouteName = findChildRouteName(route, childRoute, "loading"); | |
+ var tryTopLevel = forEachRouteAbove(originRoute, transition, function(route, childRoute) { | |
+ var childLoadingRouteName = findChildRouteName(route, childRoute, 'loading'); | |
if (childLoadingRouteName) { | |
router.intermediateTransitionTo(childLoadingRouteName); | |
@@ -23517,8 +24110,8 @@ | |
if (tryTopLevel) { | |
// Check for top-level loading state to enter. | |
- if (routeHasBeenDefined(originRoute.router, "application_loading")) { | |
- router.intermediateTransitionTo("application_loading"); | |
+ if (routeHasBeenDefined(originRoute.router, 'application_loading')) { | |
+ router.intermediateTransitionTo('application_loading'); | |
return; | |
} | |
} | |
@@ -23528,27 +24121,19 @@ | |
function logError(_error, initialMessage) { | |
var errorArgs = []; | |
var error; | |
- if (_error && typeof _error === "object" && typeof _error.errorThrown === "object") { | |
+ if (_error && typeof _error === 'object' && typeof _error.errorThrown === 'object') { | |
error = _error.errorThrown; | |
} else { | |
error = _error; | |
} | |
- if (initialMessage) { | |
- errorArgs.push(initialMessage); | |
- } | |
+ if (initialMessage) { errorArgs.push(initialMessage); } | |
if (error) { | |
- if (error.message) { | |
- errorArgs.push(error.message); | |
- } | |
- if (error.stack) { | |
- errorArgs.push(error.stack); | |
- } | |
+ if (error.message) { errorArgs.push(error.message); } | |
+ if (error.stack) { errorArgs.push(error.stack); } | |
- if (typeof error === "string") { | |
- errorArgs.push(error); | |
- } | |
+ if (typeof error === "string") { errorArgs.push(error); } | |
} | |
Ember['default'].Logger.error.apply(this, errorArgs); | |
@@ -23557,12 +24142,12 @@ | |
function findChildRouteName(parentRoute, originatingChildRoute, name) { | |
var router = parentRoute.router; | |
var childName; | |
- var targetChildRouteName = originatingChildRoute.routeName.split(".").pop(); | |
- var namespace = parentRoute.routeName === "application" ? "" : parentRoute.routeName + "."; | |
+ var targetChildRouteName = originatingChildRoute.routeName.split('.').pop(); | |
+ var namespace = parentRoute.routeName === 'application' ? '' : parentRoute.routeName + '.'; | |
// First, try a named loading state, e.g. 'foo_loading' | |
- childName = namespace + targetChildRouteName + "_" + name; | |
+ childName = namespace + targetChildRouteName + '_' + name; | |
if (routeHasBeenDefined(router, childName)) { | |
return childName; | |
} | |
@@ -23577,16 +24162,15 @@ | |
function routeHasBeenDefined(router, name) { | |
var container = router.container; | |
- return router.hasRoute(name) && (container._registry.has("template:" + name) || container._registry.has("route:" + name)); | |
+ return router.hasRoute(name) && | |
+ (container._registry.has('template:' + name) || container._registry.has('route:' + name)); | |
} | |
function triggerEvent(handlerInfos, ignoreFailure, args) { | |
var name = args.shift(); | |
if (!handlerInfos) { | |
- if (ignoreFailure) { | |
- return; | |
- } | |
+ if (ignoreFailure) { return; } | |
throw new EmberError['default']("Can't trigger action '" + name + "' because your app hasn't finished transitioning into its first route. To trigger an action on destination routes during a transition, you can call `.send()` on the `Transition` object passed to the `model/beforeModel/afterModel` hooks."); | |
} | |
@@ -23633,7 +24217,7 @@ | |
} | |
function updatePaths(router) { | |
- var appController = router.container.lookup("controller:application"); | |
+ var appController = router.container.lookup('controller:application'); | |
if (!appController) { | |
// appController might not exist when top-level loading/error | |
@@ -23645,17 +24229,17 @@ | |
var infos = router.router.currentHandlerInfos; | |
var path = EmberRouter._routePath(infos); | |
- if (!("currentPath" in appController)) { | |
- properties.defineProperty(appController, "currentPath"); | |
+ if (!('currentPath' in appController)) { | |
+ properties.defineProperty(appController, 'currentPath'); | |
} | |
- property_set.set(appController, "currentPath", path); | |
+ property_set.set(appController, 'currentPath', path); | |
- if (!("currentRouteName" in appController)) { | |
- properties.defineProperty(appController, "currentRouteName"); | |
+ if (!('currentRouteName' in appController)) { | |
+ properties.defineProperty(appController, 'currentRouteName'); | |
} | |
- property_set.set(appController, "currentRouteName", infos[infos.length - 1].name); | |
+ property_set.set(appController, 'currentRouteName', infos[infos.length - 1].name); | |
} | |
EmberRouter.reopenClass({ | |
@@ -23665,18 +24249,21 @@ | |
The `Router.map` function allows you to define mappings from URLs to routes | |
and resources in your application. These mappings are defined within the | |
supplied callback function using `this.resource` and `this.route`. | |
- ```javascript | |
+ | |
+ ```javascript | |
App.Router.map(function({ | |
this.route('about'); | |
this.resource('article'); | |
})); | |
``` | |
- For more detailed examples please see | |
+ | |
+ For more detailed examples please see | |
[the guides](http://emberjs.com/guides/routing/defining-your-routes/). | |
- @method map | |
+ | |
+ @method map | |
@param callback | |
*/ | |
- map: function (callback) { | |
+ map: function(callback) { | |
if (!this.dslCallbacks) { | |
this.dslCallbacks = []; | |
@@ -23688,7 +24275,7 @@ | |
return this; | |
}, | |
- _routePath: function (handlerInfos) { | |
+ _routePath: function(handlerInfos) { | |
var path = []; | |
// We have to handle coalescing resource names that | |
@@ -23705,7 +24292,7 @@ | |
} | |
var name, nameParts, oldNameParts; | |
- for (var i = 1, l = handlerInfos.length; i < l; i++) { | |
+ for (var i=1, l=handlerInfos.length; i<l; i++) { | |
name = handlerInfos[i].name; | |
nameParts = name.split("."); | |
oldNameParts = slice.call(path); | |
@@ -23732,32 +24319,28 @@ | |
}); | |
if (!router.currentState) { | |
- router.set("currentState", routerState); | |
+ router.set('currentState', routerState); | |
} | |
- router.set("targetState", routerState); | |
+ router.set('targetState', routerState); | |
- transition.then(null, function (error) { | |
- if (!error || !error.name) { | |
- return; | |
- } | |
+ transition.then(null, function(error) { | |
+ if (!error || !error.name) { return; } | |
Ember['default'].assert("The URL '" + error.message + "' did not match any routes in your application", error.name !== "UnrecognizedURLError"); | |
return error; | |
- }, "Ember: Process errors from Router"); | |
+ }, 'Ember: Process errors from Router'); | |
} | |
function resemblesURL(str) { | |
- return typeof str === "string" && (str === "" || str.charAt(0) === "/"); | |
+ return typeof str === 'string' && ( str === '' || str.charAt(0) === '/'); | |
} | |
function forEachQueryParam(router, targetRouteName, queryParams, callback) { | |
var qpCache = router._queryParamsFor(targetRouteName); | |
for (var key in queryParams) { | |
- if (!queryParams.hasOwnProperty(key)) { | |
- continue; | |
- } | |
+ if (!queryParams.hasOwnProperty(key)) { continue; } | |
var value = queryParams[key]; | |
var qp = qpCache.map[key]; | |
@@ -23768,9 +24351,7 @@ | |
} | |
function findLiveRoute(liveRoutes, name) { | |
- if (!liveRoutes) { | |
- return; | |
- } | |
+ if (!liveRoutes) { return; } | |
var stack = [liveRoutes]; | |
while (stack.length > 0) { | |
var test = stack.shift(); | |
@@ -23820,16 +24401,17 @@ | |
if (!liveRoutes.outlets.__ember_orphans__) { | |
liveRoutes.outlets.__ember_orphans__ = { | |
render: { | |
- name: "__ember_orphans__" | |
+ name: '__ember_orphans__' | |
}, | |
outlets: create['default'](null) | |
}; | |
} | |
liveRoutes.outlets.__ember_orphans__.outlets[into] = myState; | |
- Ember['default'].run.schedule("afterRender", function () { | |
+ Ember['default'].run.schedule('afterRender', function() { | |
// `wasUsed` gets set by the render helper. See the function | |
// `impersonateAnOutlet`. | |
- Ember['default'].assert("You attempted to render into '" + into + "' but it was not found", liveRoutes.outlets.__ember_orphans__.outlets[into].wasUsed); | |
+ Ember['default'].assert("You attempted to render into '" + into + "' but it was not found", | |
+ liveRoutes.outlets.__ember_orphans__.outlets[into].wasUsed); | |
}); | |
} | |
@@ -23848,7 +24430,7 @@ | |
defaultParentState.outlets.main = { | |
render: { | |
name: route.routeName, | |
- outlet: "main" | |
+ outlet: 'main' | |
}, | |
outlets: {} | |
}; | |
@@ -23868,11 +24450,9 @@ | |
routerJs: null, | |
routerJsState: null, | |
- isActiveIntent: function (routeName, models, queryParams, queryParamsMustMatch) { | |
+ isActiveIntent: function(routeName, models, queryParams, queryParamsMustMatch) { | |
var state = this.routerJsState; | |
- if (!this.routerJs.isActiveIntent(routeName, models, null, state)) { | |
- return false; | |
- } | |
+ if (!this.routerJs.isActiveIntent(routeName, models, null, state)) { return false; } | |
var emptyQueryParams = Ember['default'].isEmpty(Ember['default'].keys(queryParams)); | |
@@ -23891,14 +24471,10 @@ | |
function shallowEqual(a, b) { | |
var k; | |
for (k in a) { | |
- if (a.hasOwnProperty(k) && a[k] !== b[k]) { | |
- return false; | |
- } | |
+ if (a.hasOwnProperty(k) && a[k] !== b[k]) { return false; } | |
} | |
for (k in b) { | |
- if (b.hasOwnProperty(k) && a[k] !== b[k]) { | |
- return false; | |
- } | |
+ if (b.hasOwnProperty(k) && a[k] !== b[k]) { return false; } | |
} | |
return true; | |
} | |
@@ -23916,8 +24492,8 @@ | |
function routeArgs(targetRouteName, models, queryParams) { | |
var args = []; | |
- if (utils.typeOf(targetRouteName) === "string") { | |
- args.push("" + targetRouteName); | |
+ if (utils.typeOf(targetRouteName) === 'string') { | |
+ args.push('' + targetRouteName); | |
} | |
args.push.apply(args, models); | |
args.push({ queryParams: queryParams }); | |
@@ -23925,20 +24501,20 @@ | |
} | |
function getActiveTargetName(router) { | |
- var handlerInfos = router.activeTransition ? router.activeTransition.state.handlerInfos : router.state.handlerInfos; | |
+ var handlerInfos = router.activeTransition ? | |
+ router.activeTransition.state.handlerInfos : | |
+ router.state.handlerInfos; | |
return handlerInfos[handlerInfos.length - 1].name; | |
} | |
function stashParamNames(router, handlerInfos) { | |
- if (handlerInfos._namesStashed) { | |
- return; | |
- } | |
+ if (handlerInfos._namesStashed) { return; } | |
// This helper exists because router.js/route-recognizer.js awkwardly | |
// keeps separate a handlerInfo's list of parameter names depending | |
// on whether a URL transition or named transition is happening. | |
// Hopefully we can remove this in the future. | |
- var targetRouteName = handlerInfos[handlerInfos.length - 1].name; | |
+ var targetRouteName = handlerInfos[handlerInfos.length-1].name; | |
var recogHandlers = router.router.recognizer.handlersFor(targetRouteName); | |
var dynamicParent = null; | |
@@ -23962,110 +24538,130 @@ | |
}); | |
enifed('ember-runtime', ['exports', 'ember-metal', 'ember-runtime/core', 'ember-runtime/compare', 'ember-runtime/copy', 'ember-runtime/inject', 'ember-runtime/system/namespace', 'ember-runtime/system/object', 'ember-runtime/system/tracked_array', 'ember-runtime/system/subarray', 'ember-runtime/system/container', 'ember-runtime/system/array_proxy', 'ember-runtime/system/object_proxy', 'ember-runtime/system/core_object', 'ember-runtime/system/each_proxy', 'ember-runtime/system/native_array', 'ember-runtime/system/set', 'ember-runtime/system/string', 'ember-runtime/system/deferred', 'ember-runtime/system/lazy_load', 'ember-runtime/mixins/array', 'ember-runtime/mixins/comparable', 'ember-runtime/mixins/copyable', 'ember-runtime/mixins/enumerable', 'ember-runtime/mixins/freezable', 'ember-runtime/mixins/-proxy', 'ember-runtime/mixins/observable', 'ember-runtime/mixins/action_handler', 'ember-runtime/mixins/deferred', 'ember-runtime/mixins/mutable_enumerable', 'ember-runtime/mixins/mutable_array', 'ember-runtime/mixins/target_action_support', 'ember-runtime/mixins/evented', 'ember-runtime/mixins/promise_proxy', 'ember-runtime/mixins/sortable', 'ember-runtime/computed/array_computed', 'ember-runtime/computed/reduce_computed', 'ember-runtime/computed/reduce_computed_macros', 'ember-runtime/controllers/array_controller', 'ember-runtime/controllers/object_controller', 'ember-runtime/controllers/controller', 'ember-runtime/mixins/controller', 'ember-runtime/system/service', 'ember-runtime/ext/rsvp', 'ember-runtime/ext/string', 'ember-runtime/ext/function'], function (exports, Ember, core, compare, copy, inject, Namespace, EmberObject, TrackedArray, SubArray, container, ArrayProxy, ObjectProxy, CoreObject, each_proxy, NativeArray, Set, EmberStringUtils, Deferred, lazy_load, EmberArray, Comparable, Copyable, Enumerable, freezable, _ProxyMixin, Observable, ActionHandler, DeferredMixin, MutableEnumerable, MutableArray, TargetActionSupport, Evented, PromiseProxyMixin, SortableMixin, array_computed, reduce_computed, reduce_computed_macros, ArrayController, ObjectController, Controller, ControllerMixin, Service, RSVP) { | |
- 'use strict'; | |
+ 'use strict'; | |
- /** | |
- Ember Runtime | |
+ /** | |
+ Ember Runtime | |
- @module ember | |
- @submodule ember-runtime | |
- @requires ember-metal | |
- */ | |
+ @module ember | |
+ @submodule ember-runtime | |
+ @requires ember-metal | |
+ */ | |
- // BEGIN IMPORTS | |
- Ember['default'].compare = compare['default']; | |
- Ember['default'].copy = copy['default']; | |
- Ember['default'].isEqual = core.isEqual; | |
- | |
- Ember['default'].inject = inject['default']; | |
- | |
- Ember['default'].Array = EmberArray['default']; | |
- | |
- Ember['default'].Comparable = Comparable['default']; | |
- Ember['default'].Copyable = Copyable['default']; | |
- | |
- Ember['default'].SortableMixin = SortableMixin['default']; | |
- | |
- Ember['default'].Freezable = freezable.Freezable; | |
- Ember['default'].FROZEN_ERROR = freezable.FROZEN_ERROR; | |
- | |
- Ember['default'].DeferredMixin = DeferredMixin['default']; | |
- | |
- Ember['default'].MutableEnumerable = MutableEnumerable['default']; | |
- Ember['default'].MutableArray = MutableArray['default']; | |
- | |
- Ember['default'].TargetActionSupport = TargetActionSupport['default']; | |
- Ember['default'].Evented = Evented['default']; | |
- | |
- Ember['default'].PromiseProxyMixin = PromiseProxyMixin['default']; | |
- | |
- Ember['default'].Observable = Observable['default']; | |
- | |
- Ember['default'].arrayComputed = array_computed.arrayComputed; | |
- Ember['default'].ArrayComputedProperty = array_computed.ArrayComputedProperty; | |
- Ember['default'].reduceComputed = reduce_computed.reduceComputed; | |
- Ember['default'].ReduceComputedProperty = reduce_computed.ReduceComputedProperty; | |
- | |
- // ES6TODO: this seems a less than ideal way/place to add properties to Ember.computed | |
- var EmComputed = Ember['default'].computed; | |
- | |
- EmComputed.sum = reduce_computed_macros.sum; | |
- EmComputed.min = reduce_computed_macros.min; | |
- EmComputed.max = reduce_computed_macros.max; | |
- EmComputed.map = reduce_computed_macros.map; | |
- EmComputed.sort = reduce_computed_macros.sort; | |
- EmComputed.setDiff = reduce_computed_macros.setDiff; | |
- EmComputed.mapBy = reduce_computed_macros.mapBy; | |
- EmComputed.mapProperty = reduce_computed_macros.mapProperty; | |
- EmComputed.filter = reduce_computed_macros.filter; | |
- EmComputed.filterBy = reduce_computed_macros.filterBy; | |
- EmComputed.filterProperty = reduce_computed_macros.filterProperty; | |
- EmComputed.uniq = reduce_computed_macros.uniq; | |
- EmComputed.union = reduce_computed_macros.union; | |
- EmComputed.intersect = reduce_computed_macros.intersect; | |
- | |
- Ember['default'].String = EmberStringUtils['default']; | |
- Ember['default'].Object = EmberObject['default']; | |
- Ember['default'].TrackedArray = TrackedArray['default']; | |
- Ember['default'].SubArray = SubArray['default']; | |
- Ember['default'].Container = container.Container; | |
- Ember['default'].Registry = container.Registry; | |
- Ember['default'].Namespace = Namespace['default']; | |
- Ember['default'].Enumerable = Enumerable['default']; | |
- Ember['default'].ArrayProxy = ArrayProxy['default']; | |
- Ember['default'].ObjectProxy = ObjectProxy['default']; | |
- Ember['default'].ActionHandler = ActionHandler['default']; | |
- Ember['default'].CoreObject = CoreObject['default']; | |
- Ember['default'].EachArray = each_proxy.EachArray; | |
- Ember['default'].EachProxy = each_proxy.EachProxy; | |
- Ember['default'].NativeArray = NativeArray['default']; | |
- // ES6TODO: Currently we must rely on the global from ember-metal/core to avoid circular deps | |
- // Ember.A = A; | |
- Ember['default'].Set = Set['default']; | |
- Ember['default'].Deferred = Deferred['default']; | |
- Ember['default'].onLoad = lazy_load.onLoad; | |
- Ember['default'].runLoadHooks = lazy_load.runLoadHooks; | |
- | |
- Ember['default'].ArrayController = ArrayController['default']; | |
- Ember['default'].ObjectController = ObjectController['default']; | |
- Ember['default'].Controller = Controller['default']; | |
- Ember['default'].ControllerMixin = ControllerMixin['default']; | |
+ // BEGIN IMPORTS | |
+ Ember['default'].compare = compare['default']; | |
+ Ember['default'].copy = copy['default']; | |
+ Ember['default'].isEqual = core.isEqual; | |
+ | |
+ Ember['default'].inject = inject['default']; | |
+ | |
+ Ember['default'].Array = EmberArray['default']; | |
+ | |
+ Ember['default'].Comparable = Comparable['default']; | |
+ Ember['default'].Copyable = Copyable['default']; | |
+ | |
+ Ember['default'].SortableMixin = SortableMixin['default']; | |
+ | |
+ Ember['default'].Freezable = freezable.Freezable; | |
+ Ember['default'].FROZEN_ERROR = freezable.FROZEN_ERROR; | |
+ | |
+ Ember['default'].DeferredMixin = DeferredMixin['default']; | |
+ | |
+ Ember['default'].MutableEnumerable = MutableEnumerable['default']; | |
+ Ember['default'].MutableArray = MutableArray['default']; | |
+ | |
+ Ember['default'].TargetActionSupport = TargetActionSupport['default']; | |
+ Ember['default'].Evented = Evented['default']; | |
+ | |
+ Ember['default'].PromiseProxyMixin = PromiseProxyMixin['default']; | |
+ | |
+ Ember['default'].Observable = Observable['default']; | |
+ | |
+ Ember['default'].arrayComputed = array_computed.arrayComputed; | |
+ Ember['default'].ArrayComputedProperty = array_computed.ArrayComputedProperty; | |
+ Ember['default'].reduceComputed = reduce_computed.reduceComputed; | |
+ Ember['default'].ReduceComputedProperty = reduce_computed.ReduceComputedProperty; | |
+ | |
+ // ES6TODO: this seems a less than ideal way/place to add properties to Ember.computed | |
+ var EmComputed = Ember['default'].computed; | |
+ | |
+ EmComputed.sum = reduce_computed_macros.sum; | |
+ EmComputed.min = reduce_computed_macros.min; | |
+ EmComputed.max = reduce_computed_macros.max; | |
+ EmComputed.map = reduce_computed_macros.map; | |
+ EmComputed.sort = reduce_computed_macros.sort; | |
+ EmComputed.setDiff = reduce_computed_macros.setDiff; | |
+ EmComputed.mapBy = reduce_computed_macros.mapBy; | |
+ EmComputed.mapProperty = reduce_computed_macros.mapProperty; | |
+ EmComputed.filter = reduce_computed_macros.filter; | |
+ EmComputed.filterBy = reduce_computed_macros.filterBy; | |
+ EmComputed.filterProperty = reduce_computed_macros.filterProperty; | |
+ EmComputed.uniq = reduce_computed_macros.uniq; | |
+ EmComputed.union = reduce_computed_macros.union; | |
+ EmComputed.intersect = reduce_computed_macros.intersect; | |
+ | |
+ Ember['default'].String = EmberStringUtils['default']; | |
+ Ember['default'].Object = EmberObject['default']; | |
+ Ember['default'].TrackedArray = TrackedArray['default']; | |
+ Ember['default'].SubArray = SubArray['default']; | |
+ Ember['default'].Container = container.Container; | |
+ Ember['default'].Registry = container.Registry; | |
+ Ember['default'].Namespace = Namespace['default']; | |
+ Ember['default'].Enumerable = Enumerable['default']; | |
+ Ember['default'].ArrayProxy = ArrayProxy['default']; | |
+ Ember['default'].ObjectProxy = ObjectProxy['default']; | |
+ Ember['default'].ActionHandler = ActionHandler['default']; | |
+ Ember['default'].CoreObject = CoreObject['default']; | |
+ Ember['default'].EachArray = each_proxy.EachArray; | |
+ Ember['default'].EachProxy = each_proxy.EachProxy; | |
+ Ember['default'].NativeArray = NativeArray['default']; | |
+ // ES6TODO: Currently we must rely on the global from ember-metal/core to avoid circular deps | |
+ // Ember.A = A; | |
+ Ember['default'].Set = Set['default']; | |
+ Ember['default'].Deferred = Deferred['default']; | |
+ Ember['default'].onLoad = lazy_load.onLoad; | |
+ Ember['default'].runLoadHooks = lazy_load.runLoadHooks; | |
+ | |
+ Ember['default'].ArrayController = ArrayController['default']; | |
+ Ember['default'].ObjectController = ObjectController['default']; | |
+ Ember['default'].Controller = Controller['default']; | |
+ Ember['default'].ControllerMixin = ControllerMixin['default']; | |
- Ember['default'].Service = Service['default']; | |
+ Ember['default'].Service = Service['default']; | |
- Ember['default']._ProxyMixin = _ProxyMixin['default']; | |
+ Ember['default']._ProxyMixin = _ProxyMixin['default']; | |
- Ember['default'].RSVP = RSVP['default']; | |
- // END EXPORTS | |
+ Ember['default'].RSVP = RSVP['default']; | |
+ // END EXPORTS | |
- exports['default'] = Ember['default']; | |
+ exports['default'] = Ember['default']; | |
}); | |
enifed('ember-runtime/compare', ['exports', 'ember-metal/utils', 'ember-runtime/mixins/comparable'], function (exports, utils, Comparable) { | |
'use strict'; | |
+ var TYPE_ORDER = { | |
+ 'undefined': 0, | |
+ 'null': 1, | |
+ 'boolean': 2, | |
+ 'number': 3, | |
+ 'string': 4, | |
+ 'array': 5, | |
+ 'object': 6, | |
+ 'instance': 7, | |
+ 'function': 8, | |
+ 'class': 9, | |
+ 'date': 10 | |
+ }; | |
+ // | |
+ // the spaceship operator | |
+ // | |
+ function spaceship(a, b) { | |
+ var diff = a - b; | |
+ return (diff > 0) - (diff < 0); | |
+ } | |
/** | |
This will compare two javascript values of possibly different types. | |
@@ -24090,28 +24686,6 @@ | |
@param {Object} w Second value to compare | |
@return {Number} -1 if v < w, 0 if v = w and 1 if v > w. | |
*/ | |
- exports['default'] = compare; | |
- var TYPE_ORDER = { | |
- "undefined": 0, | |
- "null": 1, | |
- "boolean": 2, | |
- "number": 3, | |
- "string": 4, | |
- "array": 5, | |
- "object": 6, | |
- "instance": 7, | |
- "function": 8, | |
- "class": 9, | |
- "date": 10 | |
- }; | |
- | |
- // | |
- // the spaceship operator | |
- // | |
- function spaceship(a, b) { | |
- var diff = a - b; | |
- return (diff > 0) - (diff < 0); | |
- } | |
function compare(v, w) { | |
if (v === w) { | |
return 0; | |
@@ -24121,11 +24695,11 @@ | |
var type2 = utils.typeOf(w); | |
if (Comparable['default']) { | |
- if (type1 === "instance" && Comparable['default'].detect(v) && v.constructor.compare) { | |
+ if (type1 === 'instance' && Comparable['default'].detect(v) && v.constructor.compare) { | |
return v.constructor.compare(v, w); | |
} | |
- if (type2 === "instance" && Comparable['default'].detect(w) && w.constructor.compare) { | |
+ if (type2 === 'instance' && Comparable['default'].detect(w) && w.constructor.compare) { | |
return w.constructor.compare(w, v) * -1; | |
} | |
} | |
@@ -24138,14 +24712,14 @@ | |
// types are equal - so we have to check values now | |
switch (type1) { | |
- case "boolean": | |
- case "number": | |
+ case 'boolean': | |
+ case 'number': | |
return spaceship(v, w); | |
- case "string": | |
+ case 'string': | |
return spaceship(v.localeCompare(w), 0); | |
- case "array": | |
+ case 'array': | |
var vLen = v.length; | |
var wLen = w.length; | |
var len = Math.min(vLen, wLen); | |
@@ -24161,19 +24735,20 @@ | |
// shorter array should be ordered first | |
return spaceship(vLen, wLen); | |
- case "instance": | |
+ case 'instance': | |
if (Comparable['default'] && Comparable['default'].detect(v)) { | |
return v.compare(v, w); | |
} | |
return 0; | |
- case "date": | |
+ case 'date': | |
return spaceship(v.getTime(), w.getTime()); | |
default: | |
return 0; | |
} | |
} | |
+ exports['default'] = compare; | |
}); | |
enifed('ember-runtime/computed/array_computed', ['exports', 'ember-metal/core', 'ember-runtime/computed/reduce_computed', 'ember-metal/enumerable_utils', 'ember-metal/platform/create', 'ember-metal/observer', 'ember-metal/error'], function (exports, Ember, reduce_computed, enumerable_utils, o_create, observer, EmberError) { | |
@@ -24190,14 +24765,14 @@ | |
reduce_computed.ReduceComputedProperty.apply(this, arguments); | |
- this._getter = (function (reduceFunc) { | |
+ this._getter = (function(reduceFunc) { | |
return function (propertyName) { | |
if (!cp._hasInstanceMeta(this, propertyName)) { | |
// When we recompute an array computed property, we need already | |
// retrieved arrays to be updated; we can't simply empty the cache and | |
// hope the array is re-retrieved. | |
- enumerable_utils.forEach(cp._dependentKeys, function (dependentKey) { | |
- observer.addObserver(this, dependentKey, function () { | |
+ enumerable_utils.forEach(cp._dependentKeys, function(dependentKey) { | |
+ observer.addObserver(this, dependentKey, function() { | |
cp.recomputeOnce.call(this, propertyName); | |
}); | |
}, this); | |
@@ -24348,8 +24923,8 @@ | |
options = a_slice.call(arguments, -1)[0]; | |
} | |
- if (typeof options !== "object") { | |
- throw new EmberError['default']("Array Computed Property declared without an options hash"); | |
+ if (typeof options !== 'object') { | |
+ throw new EmberError['default']('Array Computed Property declared without an options hash'); | |
} | |
var cp = new ArrayComputedProperty(options); | |
@@ -24366,194 +24941,9 @@ | |
'use strict'; | |
- exports.reduceComputed = reduceComputed; | |
exports.ReduceComputedProperty = ReduceComputedProperty; | |
- | |
- /** | |
- Creates a computed property which operates on dependent arrays and | |
- is updated with "one at a time" semantics. When items are added or | |
- removed from the dependent array(s) a reduce computed only operates | |
- on the change instead of re-evaluating the entire array. | |
- | |
- If there are more than one arguments the first arguments are | |
- considered to be dependent property keys. The last argument is | |
- required to be an options object. The options object can have the | |
- following four properties: | |
- | |
- `initialValue` - A value or function that will be used as the initial | |
- value for the computed. If this property is a function the result of calling | |
- the function will be used as the initial value. This property is required. | |
- | |
- `initialize` - An optional initialize function. Typically this will be used | |
- to set up state on the instanceMeta object. | |
- | |
- `removedItem` - A function that is called each time an element is removed | |
- from the array. | |
- | |
- `addedItem` - A function that is called each time an element is added to | |
- the array. | |
- | |
- | |
- The `initialize` function has the following signature: | |
- | |
- ```javascript | |
- function(initialValue, changeMeta, instanceMeta) | |
- ``` | |
- | |
- `initialValue` - The value of the `initialValue` property from the | |
- options object. | |
- | |
- `changeMeta` - An object which contains meta information about the | |
- computed. It contains the following properties: | |
- | |
- - `property` the computed property | |
- - `propertyName` the name of the property on the object | |
- | |
- `instanceMeta` - An object that can be used to store meta | |
- information needed for calculating your computed. For example a | |
- unique computed might use this to store the number of times a given | |
- element is found in the dependent array. | |
- | |
- | |
- The `removedItem` and `addedItem` functions both have the following signature: | |
- | |
- ```javascript | |
- function(accumulatedValue, item, changeMeta, instanceMeta) | |
- ``` | |
- | |
- `accumulatedValue` - The value returned from the last time | |
- `removedItem` or `addedItem` was called or `initialValue`. | |
- | |
- `item` - the element added or removed from the array | |
- | |
- `changeMeta` - An object which contains meta information about the | |
- change. It contains the following properties: | |
- | |
- - `property` the computed property | |
- - `propertyName` the name of the property on the object | |
- - `index` the index of the added or removed item | |
- - `item` the added or removed item: this is exactly the same as | |
- the second arg | |
- - `arrayChanged` the array that triggered the change. Can be | |
- useful when depending on multiple arrays. | |
- | |
- For property changes triggered on an item property change (when | |
- depKey is something like `[email protected]`), | |
- `changeMeta` will also contain the following property: | |
- | |
- - `previousValues` an object whose keys are the properties that changed on | |
- the item, and whose values are the item's previous values. | |
- | |
- `previousValues` is important Ember coalesces item property changes via | |
- Ember.run.once. This means that by the time removedItem gets called, item has | |
- the new values, but you may need the previous value (eg for sorting & | |
- filtering). | |
- | |
- `instanceMeta` - An object that can be used to store meta | |
- information needed for calculating your computed. For example a | |
- unique computed might use this to store the number of times a given | |
- element is found in the dependent array. | |
- | |
- The `removedItem` and `addedItem` functions should return the accumulated | |
- value. It is acceptable to not return anything (ie return undefined) | |
- to invalidate the computation. This is generally not a good idea for | |
- arrayComputed but it's used in eg max and min. | |
- | |
- Note that observers will be fired if either of these functions return a value | |
- that differs from the accumulated value. When returning an object that | |
- mutates in response to array changes, for example an array that maps | |
- everything from some other array (see `Ember.computed.map`), it is usually | |
- important that the *same* array be returned to avoid accidentally triggering observers. | |
- | |
- Example | |
- | |
- ```javascript | |
- Ember.computed.max = function(dependentKey) { | |
- return Ember.reduceComputed(dependentKey, { | |
- initialValue: -Infinity, | |
- | |
- addedItem: function(accumulatedValue, item, changeMeta, instanceMeta) { | |
- return Math.max(accumulatedValue, item); | |
- }, | |
- | |
- removedItem: function(accumulatedValue, item, changeMeta, instanceMeta) { | |
- if (item < accumulatedValue) { | |
- return accumulatedValue; | |
- } | |
- } | |
- }); | |
- }; | |
- ``` | |
- | |
- Dependent keys may refer to `@this` to observe changes to the object itself, | |
- which must be array-like, rather than a property of the object. This is | |
- mostly useful for array proxies, to ensure objects are retrieved via | |
- `objectAtContent`. This is how you could sort items by properties defined on an item controller. | |
- | |
- Example | |
- | |
- ```javascript | |
- App.PeopleController = Ember.ArrayController.extend({ | |
- itemController: 'person', | |
- | |
- sortedPeople: Ember.computed.sort('@[email protected]', function(personA, personB) { | |
- // `reversedName` isn't defined on Person, but we have access to it via | |
- // the item controller App.PersonController. If we'd used | |
- // `[email protected]` above, we would be getting the objects | |
- // directly and not have access to `reversedName`. | |
- // | |
- var reversedNameA = get(personA, 'reversedName'); | |
- var reversedNameB = get(personB, 'reversedName'); | |
- | |
- return Ember.compare(reversedNameA, reversedNameB); | |
- }) | |
- }); | |
- | |
- App.PersonController = Ember.ObjectController.extend({ | |
- reversedName: function() { | |
- return reverse(get(this, 'name')); | |
- }.property('name') | |
- }); | |
- ``` | |
- | |
- Dependent keys whose values are not arrays are treated as regular | |
- dependencies: when they change, the computed property is completely | |
- recalculated. It is sometimes useful to have dependent arrays with similar | |
- semantics. Dependent keys which end in `.[]` do not use "one at a time" | |
- semantics. When an item is added or removed from such a dependency, the | |
- computed property is completely recomputed. | |
- | |
- When the computed property is completely recomputed, the `accumulatedValue` | |
- is discarded, it starts with `initialValue` again, and each item is passed | |
- to `addedItem` in turn. | |
- | |
- Example | |
- | |
- ```javascript | |
- Ember.Object.extend({ | |
- // When `string` is changed, `computed` is completely recomputed. | |
- string: 'a string', | |
- | |
- // When an item is added to `array`, `addedItem` is called. | |
- array: [], | |
- | |
- // When an item is added to `anotherArray`, `computed` is completely | |
- // recomputed. | |
- anotherArray: [], | |
- | |
- computed: Ember.reduceComputed('string', 'array', 'anotherArray.[]', { | |
- addedItem: addedItemCallback, | |
- removedItem: removedItemCallback | |
- }) | |
- }); | |
- ``` | |
- | |
- @method reduceComputed | |
- @for Ember | |
- @param {String} [dependentKeys*] | |
- @param {Object} options | |
- @return {Ember.ComputedProperty} | |
- */ | |
+ exports.reduceComputed = reduceComputed; | |
+ | |
var cacheSet = computed.cacheFor.set; | |
var cacheGet = computed.cacheFor.get; | |
var cacheRemove = computed.cacheFor.remove; | |
@@ -24565,7 +24955,7 @@ | |
var arrayBracketPattern = /\.\[\]$/; | |
function get(obj, key) { | |
- if (key === "@this") { | |
+ if (key === '@this') { | |
return obj; | |
} | |
@@ -24614,7 +25004,7 @@ | |
} | |
function ItemPropertyObserverContext(dependentArray, index, trackedArray) { | |
- Ember['default'].assert("Internal error: trackedArray is null or undefined", trackedArray); | |
+ Ember['default'].assert('Internal error: trackedArray is null or undefined', trackedArray); | |
this.dependentArray = dependentArray; | |
this.index = index; | |
@@ -24638,8 +25028,8 @@ | |
this.dependentKeysByGuid[utils.guidFor(dependentArray)] = dependentKey; | |
dependentArray.addArrayObserver(this, { | |
- willChange: "dependentArrayWillChange", | |
- didChange: "dependentArrayDidChange" | |
+ willChange: 'dependentArrayWillChange', | |
+ didChange: 'dependentArrayDidChange' | |
}); | |
if (this.cp._itemPropertyKeys[dependentKey]) { | |
@@ -24655,8 +25045,8 @@ | |
this.teardownPropertyObservers(dependentKey, itemPropertyKeys); | |
dependentArray.removeArrayObserver(this, { | |
- willChange: "dependentArrayWillChange", | |
- didChange: "dependentArrayDidChange" | |
+ willChange: 'dependentArrayWillChange', | |
+ didChange: 'dependentArrayDidChange' | |
}); | |
}, | |
@@ -24669,7 +25059,7 @@ | |
setupPropertyObservers: function (dependentKey, itemPropertyKeys) { | |
var dependentArray = get(this.instanceMeta.context, dependentKey); | |
- var length = get(dependentArray, "length"); | |
+ var length = get(dependentArray, 'length'); | |
var observerContexts = new Array(length); | |
this.resetTransformations(dependentKey, observerContexts); | |
@@ -24690,14 +25080,10 @@ | |
var trackedArray = this.trackedArraysByGuid[dependentKey]; | |
var beforeObserver, observer, item; | |
- if (!trackedArray) { | |
- return; | |
- } | |
+ if (!trackedArray) { return; } | |
trackedArray.apply(function (observerContexts, offset, operation) { | |
- if (operation === TrackedArray['default'].DELETE) { | |
- return; | |
- } | |
+ if (operation === TrackedArray['default'].DELETE) { return; } | |
enumerable_utils.forEach(observerContexts, function (observerContext) { | |
observerContext.destroyed = true; | |
@@ -24756,15 +25142,13 @@ | |
}, | |
updateIndexes: function (trackedArray, array) { | |
- var length = get(array, "length"); | |
+ var length = get(array, 'length'); | |
// OPTIMIZE: we could stop updating once we hit the object whose observer | |
// fired; ie partially apply the transformations | |
trackedArray.apply(function (observerContexts, offset, operation, operationIndex) { | |
// we don't even have observer contexts for removed items, even if we did, | |
// they no longer have any index in the array | |
- if (operation === TrackedArray['default'].DELETE) { | |
- return; | |
- } | |
+ if (operation === TrackedArray['default'].DELETE) { return; } | |
if (operationIndex === 0 && operation === TrackedArray['default'].RETAIN && observerContexts.length === length && offset === 0) { | |
// If we update many items we don't want to walk the array each time: we | |
// only need to update the indexes at most once per run loop. | |
@@ -24778,16 +25162,14 @@ | |
}, | |
dependentArrayWillChange: function (dependentArray, index, removedCount, addedCount) { | |
- if (this.suspended) { | |
- return; | |
- } | |
+ if (this.suspended) { return; } | |
var removedItem = this.callbacks.removedItem; | |
var changeMeta; | |
var guid = utils.guidFor(dependentArray); | |
var dependentKey = this.dependentKeysByGuid[guid]; | |
var itemPropertyKeys = this.cp._itemPropertyKeys[dependentKey] || []; | |
- var length = get(dependentArray, "length"); | |
+ var length = get(dependentArray, 'length'); | |
var normalizedIndex = normalizeIndex(index, length, 0); | |
var normalizedRemoveCount = normalizeRemoveCount(normalizedIndex, length, removedCount); | |
var item, itemIndex, sliceIndex, observerContexts; | |
@@ -24802,38 +25184,36 @@ | |
for (sliceIndex = normalizedRemoveCount - 1; sliceIndex >= 0; --sliceIndex) { | |
itemIndex = normalizedIndex + sliceIndex; | |
- if (itemIndex >= length) { | |
- break; | |
- } | |
+ if (itemIndex >= length) { break; } | |
item = dependentArray.objectAt(itemIndex); | |
enumerable_utils.forEach(itemPropertyKeys, removeObservers, this); | |
changeMeta = new ChangeMeta(dependentArray, item, itemIndex, this.instanceMeta.propertyName, this.cp, normalizedRemoveCount); | |
- this.setValue(removedItem.call(this.instanceMeta.context, this.getValue(), item, changeMeta, this.instanceMeta.sugarMeta)); | |
+ this.setValue(removedItem.call( | |
+ this.instanceMeta.context, this.getValue(), item, changeMeta, this.instanceMeta.sugarMeta)); | |
} | |
this.callbacks.flushedChanges.call(this.instanceMeta.context, this.getValue(), this.instanceMeta.sugarMeta); | |
}, | |
dependentArrayDidChange: function (dependentArray, index, removedCount, addedCount) { | |
- if (this.suspended) { | |
- return; | |
- } | |
+ if (this.suspended) { return; } | |
var addedItem = this.callbacks.addedItem; | |
var guid = utils.guidFor(dependentArray); | |
var dependentKey = this.dependentKeysByGuid[guid]; | |
var observerContexts = new Array(addedCount); | |
var itemPropertyKeys = this.cp._itemPropertyKeys[dependentKey]; | |
- var length = get(dependentArray, "length"); | |
+ var length = get(dependentArray, 'length'); | |
var normalizedIndex = normalizeIndex(index, length, addedCount); | |
var endIndex = normalizedIndex + addedCount; | |
var changeMeta, observerContext; | |
enumerable_utils.forEach(dependentArray.slice(normalizedIndex, endIndex), function (item, sliceIndex) { | |
if (itemPropertyKeys) { | |
- observerContext = this.createPropertyObserverContext(dependentArray, normalizedIndex + sliceIndex, this.trackedArraysByGuid[dependentKey]); | |
+ observerContext = this.createPropertyObserverContext(dependentArray, normalizedIndex + sliceIndex, | |
+ this.trackedArraysByGuid[dependentKey]); | |
observerContexts[sliceIndex] = observerContext; | |
enumerable_utils.forEach(itemPropertyKeys, function (propertyKey) { | |
@@ -24843,7 +25223,8 @@ | |
} | |
changeMeta = new ChangeMeta(dependentArray, item, normalizedIndex + sliceIndex, this.instanceMeta.propertyName, this.cp, addedCount); | |
- this.setValue(addedItem.call(this.instanceMeta.context, this.getValue(), item, changeMeta, this.instanceMeta.sugarMeta)); | |
+ this.setValue(addedItem.call( | |
+ this.instanceMeta.context, this.getValue(), item, changeMeta, this.instanceMeta.sugarMeta)); | |
}, this); | |
this.callbacks.flushedChanges.call(this.instanceMeta.context, this.getValue(), this.instanceMeta.sugarMeta); | |
this.trackAdd(dependentKey, normalizedIndex, observerContexts); | |
@@ -24877,15 +25258,15 @@ | |
for (key in changedItems) { | |
c = changedItems[key]; | |
- if (c.observerContext.destroyed) { | |
- continue; | |
- } | |
+ if (c.observerContext.destroyed) { continue; } | |
this.updateIndexes(c.observerContext.trackedArray, c.observerContext.dependentArray); | |
changeMeta = new ChangeMeta(c.array, c.obj, c.observerContext.index, this.instanceMeta.propertyName, this.cp, changedItems.length, c.previousValues); | |
- this.setValue(this.callbacks.removedItem.call(this.instanceMeta.context, this.getValue(), c.obj, changeMeta, this.instanceMeta.sugarMeta)); | |
- this.setValue(this.callbacks.addedItem.call(this.instanceMeta.context, this.getValue(), c.obj, changeMeta, this.instanceMeta.sugarMeta)); | |
+ this.setValue( | |
+ this.callbacks.removedItem.call(this.instanceMeta.context, this.getValue(), c.obj, changeMeta, this.instanceMeta.sugarMeta)); | |
+ this.setValue( | |
+ this.callbacks.addedItem.call(this.instanceMeta.context, this.getValue(), c.obj, changeMeta, this.instanceMeta.sugarMeta)); | |
} | |
this.changedItems = {}; | |
@@ -24898,8 +25279,7 @@ | |
return Math.max(0, length + index); | |
} else if (index < length) { | |
return index; | |
- } else { | |
- // index > length | |
+ } else { // index > length | |
return Math.min(length - newItemsOffset, index); | |
} | |
} | |
@@ -24924,7 +25304,8 @@ | |
function addItems(dependentArray, callbacks, cp, propertyName, meta) { | |
enumerable_utils.forEach(dependentArray, function (item, index) { | |
- meta.setValue(callbacks.addedItem.call(this, meta.getValue(), item, new ChangeMeta(dependentArray, item, index, propertyName, cp, dependentArray.length), meta.sugarMeta)); | |
+ meta.setValue(callbacks.addedItem.call( | |
+ this, meta.getValue(), item, new ChangeMeta(dependentArray, item, index, propertyName, cp, dependentArray.length), meta.sugarMeta)); | |
}, this); | |
callbacks.flushedChanges.call(this, meta.getValue(), meta.sugarMeta); | |
} | |
@@ -24933,9 +25314,7 @@ | |
var hadMeta = cp._hasInstanceMeta(this, propertyName); | |
var meta = cp._instanceMeta(this, propertyName); | |
- if (hadMeta) { | |
- meta.setValue(cp.resetValue(meta.getValue())); | |
- } | |
+ if (hadMeta) { meta.setValue(cp.resetValue(meta.getValue())); } | |
if (cp.options.initialize) { | |
cp.options.initialize.call(this, meta.getValue(), { | |
@@ -24959,9 +25338,7 @@ | |
this.propertyName = propertyName; | |
var contextMeta = utils.meta(context); | |
var contextCache = contextMeta.cache; | |
- if (!contextCache) { | |
- contextCache = contextMeta.cache = {}; | |
- } | |
+ if (!contextCache) { contextCache = contextMeta.cache = {}; } | |
this.cache = contextCache; | |
this.dependentArrays = {}; | |
this.sugarMeta = {}; | |
@@ -24979,7 +25356,7 @@ | |
} | |
}, | |
- setValue: function (newValue, triggerObservers) { | |
+ setValue: function(newValue, triggerObservers) { | |
// This lets sugars force a recomputation, handy for very simple | |
// implementations of eg max. | |
if (newValue === cacheGet(this.cache, this.propertyName)) { | |
@@ -25025,14 +25402,14 @@ | |
this.readOnly(); | |
- this.recomputeOnce = function (propertyName) { | |
+ this.recomputeOnce = function(propertyName) { | |
// What we really want to do is coalesce by <cp, propertyName>. | |
// We need a form of `scheduleOnce` that accepts an arbitrary token to | |
// coalesce by, in addition to the target and method. | |
run['default'].once(this, recompute, propertyName); | |
}; | |
- var recompute = function (propertyName) { | |
+ var recompute = function(propertyName) { | |
var meta = cp._instanceMeta(this, propertyName); | |
var callbacks = cp._callbacks(); | |
@@ -25040,11 +25417,12 @@ | |
meta.dependentArraysObserver.suspendArrayObservers(function () { | |
enumerable_utils.forEach(cp._dependentKeys, function (dependentKey) { | |
- Ember['default'].assert("dependent array " + dependentKey + " must be an `Ember.Array`. " + "If you are not extending arrays, you will need to wrap native arrays with `Ember.A`", !(utils.isArray(get(this, dependentKey)) && !EmberArray['default'].detect(get(this, dependentKey)))); | |
+ Ember['default'].assert( | |
+ 'dependent array ' + dependentKey + ' must be an `Ember.Array`. ' + | |
+ 'If you are not extending arrays, you will need to wrap native arrays with `Ember.A`', | |
+ !(utils.isArray(get(this, dependentKey)) && !EmberArray['default'].detect(get(this, dependentKey)))); | |
- if (!partiallyRecomputeFor(this, dependentKey)) { | |
- return; | |
- } | |
+ if (!partiallyRecomputeFor(this, dependentKey)) { return; } | |
var dependentArray = get(this, dependentKey); | |
var previousDependentArray = meta.dependentArrays[dependentKey]; | |
@@ -25072,10 +25450,8 @@ | |
}, this); | |
}, this); | |
- enumerable_utils.forEach(cp._dependentKeys, function (dependentKey) { | |
- if (!partiallyRecomputeFor(this, dependentKey)) { | |
- return; | |
- } | |
+ enumerable_utils.forEach(cp._dependentKeys, function(dependentKey) { | |
+ if (!partiallyRecomputeFor(this, dependentKey)) { return; } | |
var dependentArray = get(this, dependentKey); | |
@@ -25085,8 +25461,9 @@ | |
}, this); | |
}; | |
+ | |
this._getter = function (propertyName) { | |
- Ember['default'].assert("Computed reduce values require at least one dependent key", cp._dependentKeys); | |
+ Ember['default'].assert('Computed reduce values require at least one dependent key', cp._dependentKeys); | |
recompute.call(this, propertyName); | |
@@ -25137,7 +25514,7 @@ | |
}; | |
ReduceComputedProperty.prototype.initialValue = function () { | |
- if (typeof this.options.initialValue === "function") { | |
+ if (typeof this.options.initialValue === 'function') { | |
return this.options.initialValue(); | |
} else { | |
return this.options.initialValue; | |
@@ -25168,7 +25545,7 @@ | |
enumerable_utils.forEach(args, function (dependentKey) { | |
if (doubleEachPropertyPattern.test(dependentKey)) { | |
- throw new EmberError['default']("Nested @each properties not supported: " + dependentKey); | |
+ throw new EmberError['default']('Nested @each properties not supported: ' + dependentKey); | |
} else if (match = eachPropertyPattern.exec(dependentKey)) { | |
dependentArrayKey = match[1]; | |
@@ -25191,6 +25568,192 @@ | |
return computed.ComputedProperty.prototype.property.apply(this, propertyArgsToArray); | |
}; | |
+ | |
+ /** | |
+ Creates a computed property which operates on dependent arrays and | |
+ is updated with "one at a time" semantics. When items are added or | |
+ removed from the dependent array(s) a reduce computed only operates | |
+ on the change instead of re-evaluating the entire array. | |
+ | |
+ If there are more than one arguments the first arguments are | |
+ considered to be dependent property keys. The last argument is | |
+ required to be an options object. The options object can have the | |
+ following four properties: | |
+ | |
+ `initialValue` - A value or function that will be used as the initial | |
+ value for the computed. If this property is a function the result of calling | |
+ the function will be used as the initial value. This property is required. | |
+ | |
+ `initialize` - An optional initialize function. Typically this will be used | |
+ to set up state on the instanceMeta object. | |
+ | |
+ `removedItem` - A function that is called each time an element is removed | |
+ from the array. | |
+ | |
+ `addedItem` - A function that is called each time an element is added to | |
+ the array. | |
+ | |
+ | |
+ The `initialize` function has the following signature: | |
+ | |
+ ```javascript | |
+ function(initialValue, changeMeta, instanceMeta) | |
+ ``` | |
+ | |
+ `initialValue` - The value of the `initialValue` property from the | |
+ options object. | |
+ | |
+ `changeMeta` - An object which contains meta information about the | |
+ computed. It contains the following properties: | |
+ | |
+ - `property` the computed property | |
+ - `propertyName` the name of the property on the object | |
+ | |
+ `instanceMeta` - An object that can be used to store meta | |
+ information needed for calculating your computed. For example a | |
+ unique computed might use this to store the number of times a given | |
+ element is found in the dependent array. | |
+ | |
+ | |
+ The `removedItem` and `addedItem` functions both have the following signature: | |
+ | |
+ ```javascript | |
+ function(accumulatedValue, item, changeMeta, instanceMeta) | |
+ ``` | |
+ | |
+ `accumulatedValue` - The value returned from the last time | |
+ `removedItem` or `addedItem` was called or `initialValue`. | |
+ | |
+ `item` - the element added or removed from the array | |
+ | |
+ `changeMeta` - An object which contains meta information about the | |
+ change. It contains the following properties: | |
+ | |
+ - `property` the computed property | |
+ - `propertyName` the name of the property on the object | |
+ - `index` the index of the added or removed item | |
+ - `item` the added or removed item: this is exactly the same as | |
+ the second arg | |
+ - `arrayChanged` the array that triggered the change. Can be | |
+ useful when depending on multiple arrays. | |
+ | |
+ For property changes triggered on an item property change (when | |
+ depKey is something like `[email protected]`), | |
+ `changeMeta` will also contain the following property: | |
+ | |
+ - `previousValues` an object whose keys are the properties that changed on | |
+ the item, and whose values are the item's previous values. | |
+ | |
+ `previousValues` is important Ember coalesces item property changes via | |
+ Ember.run.once. This means that by the time removedItem gets called, item has | |
+ the new values, but you may need the previous value (eg for sorting & | |
+ filtering). | |
+ | |
+ `instanceMeta` - An object that can be used to store meta | |
+ information needed for calculating your computed. For example a | |
+ unique computed might use this to store the number of times a given | |
+ element is found in the dependent array. | |
+ | |
+ The `removedItem` and `addedItem` functions should return the accumulated | |
+ value. It is acceptable to not return anything (ie return undefined) | |
+ to invalidate the computation. This is generally not a good idea for | |
+ arrayComputed but it's used in eg max and min. | |
+ | |
+ Note that observers will be fired if either of these functions return a value | |
+ that differs from the accumulated value. When returning an object that | |
+ mutates in response to array changes, for example an array that maps | |
+ everything from some other array (see `Ember.computed.map`), it is usually | |
+ important that the *same* array be returned to avoid accidentally triggering observers. | |
+ | |
+ Example | |
+ | |
+ ```javascript | |
+ Ember.computed.max = function(dependentKey) { | |
+ return Ember.reduceComputed(dependentKey, { | |
+ initialValue: -Infinity, | |
+ | |
+ addedItem: function(accumulatedValue, item, changeMeta, instanceMeta) { | |
+ return Math.max(accumulatedValue, item); | |
+ }, | |
+ | |
+ removedItem: function(accumulatedValue, item, changeMeta, instanceMeta) { | |
+ if (item < accumulatedValue) { | |
+ return accumulatedValue; | |
+ } | |
+ } | |
+ }); | |
+ }; | |
+ ``` | |
+ | |
+ Dependent keys may refer to `@this` to observe changes to the object itself, | |
+ which must be array-like, rather than a property of the object. This is | |
+ mostly useful for array proxies, to ensure objects are retrieved via | |
+ `objectAtContent`. This is how you could sort items by properties defined on an item controller. | |
+ | |
+ Example | |
+ | |
+ ```javascript | |
+ App.PeopleController = Ember.ArrayController.extend({ | |
+ itemController: 'person', | |
+ | |
+ sortedPeople: Ember.computed.sort('@[email protected]', function(personA, personB) { | |
+ // `reversedName` isn't defined on Person, but we have access to it via | |
+ // the item controller App.PersonController. If we'd used | |
+ // `[email protected]` above, we would be getting the objects | |
+ // directly and not have access to `reversedName`. | |
+ // | |
+ var reversedNameA = get(personA, 'reversedName'); | |
+ var reversedNameB = get(personB, 'reversedName'); | |
+ | |
+ return Ember.compare(reversedNameA, reversedNameB); | |
+ }) | |
+ }); | |
+ | |
+ App.PersonController = Ember.ObjectController.extend({ | |
+ reversedName: function() { | |
+ return reverse(get(this, 'name')); | |
+ }.property('name') | |
+ }); | |
+ ``` | |
+ | |
+ Dependent keys whose values are not arrays are treated as regular | |
+ dependencies: when they change, the computed property is completely | |
+ recalculated. It is sometimes useful to have dependent arrays with similar | |
+ semantics. Dependent keys which end in `.[]` do not use "one at a time" | |
+ semantics. When an item is added or removed from such a dependency, the | |
+ computed property is completely recomputed. | |
+ | |
+ When the computed property is completely recomputed, the `accumulatedValue` | |
+ is discarded, it starts with `initialValue` again, and each item is passed | |
+ to `addedItem` in turn. | |
+ | |
+ Example | |
+ | |
+ ```javascript | |
+ Ember.Object.extend({ | |
+ // When `string` is changed, `computed` is completely recomputed. | |
+ string: 'a string', | |
+ | |
+ // When an item is added to `array`, `addedItem` is called. | |
+ array: [], | |
+ | |
+ // When an item is added to `anotherArray`, `computed` is completely | |
+ // recomputed. | |
+ anotherArray: [], | |
+ | |
+ computed: Ember.reduceComputed('string', 'array', 'anotherArray.[]', { | |
+ addedItem: addedItemCallback, | |
+ removedItem: removedItemCallback | |
+ }) | |
+ }); | |
+ ``` | |
+ | |
+ @method reduceComputed | |
+ @for Ember | |
+ @param {String} [dependentKeys*] | |
+ @param {Object} options | |
+ @return {Ember.ComputedProperty} | |
+ */ | |
function reduceComputed(options) { | |
var args; | |
@@ -25199,12 +25762,12 @@ | |
options = a_slice.call(arguments, -1)[0]; | |
} | |
- if (typeof options !== "object") { | |
- throw new EmberError['default']("Reduce Computed Property declared without an options hash"); | |
+ if (typeof options !== 'object') { | |
+ throw new EmberError['default']('Reduce Computed Property declared without an options hash'); | |
} | |
- if (!("initialValue" in options)) { | |
- throw new EmberError['default']("Reduce Computed Property declared without an initial value"); | |
+ if (!('initialValue' in options)) { | |
+ throw new EmberError['default']('Reduce Computed Property declared without an initial value'); | |
} | |
var cp = new ReduceComputedProperty(options); | |
@@ -25234,6 +25797,13 @@ | |
exports.sort = sort; | |
/** | |
+ @module ember | |
+ @submodule ember-runtime | |
+ */ | |
+ | |
+ var a_slice = [].slice; | |
+ | |
+ /** | |
A computed property that returns the sum of the value | |
in the dependent array. | |
@@ -25244,21 +25814,53 @@ | |
@since 1.4.0 | |
*/ | |
- var a_slice = [].slice; | |
function sum(dependentKey) { | |
return reduce_computed.reduceComputed(dependentKey, { | |
initialValue: 0, | |
- addedItem: function (accumulatedValue, item, changeMeta, instanceMeta) { | |
+ addedItem: function(accumulatedValue, item, changeMeta, instanceMeta) { | |
return accumulatedValue + item; | |
}, | |
- removedItem: function (accumulatedValue, item, changeMeta, instanceMeta) { | |
+ removedItem: function(accumulatedValue, item, changeMeta, instanceMeta) { | |
return accumulatedValue - item; | |
} | |
}); | |
} | |
+ /** | |
+ A computed property that calculates the maximum value in the | |
+ dependent array. This will return `-Infinity` when the dependent | |
+ array is empty. | |
+ | |
+ ```javascript | |
+ var Person = Ember.Object.extend({ | |
+ childAges: Ember.computed.mapBy('children', 'age'), | |
+ maxChildAge: Ember.computed.max('childAges') | |
+ }); | |
+ | |
+ var lordByron = Person.create({ children: [] }); | |
+ | |
+ lordByron.get('maxChildAge'); // -Infinity | |
+ lordByron.get('children').pushObject({ | |
+ name: 'Augusta Ada Byron', age: 7 | |
+ }); | |
+ lordByron.get('maxChildAge'); // 7 | |
+ lordByron.get('children').pushObjects([{ | |
+ name: 'Allegra Byron', | |
+ age: 5 | |
+ }, { | |
+ name: 'Elizabeth Medora Leigh', | |
+ age: 8 | |
+ }]); | |
+ lordByron.get('maxChildAge'); // 8 | |
+ ``` | |
+ | |
+ @method max | |
+ @for Ember.computed | |
+ @param {String} dependentKey | |
+ @return {Ember.ComputedProperty} computes the largest value in the dependentKey's array | |
+ */ | |
function max(dependentKey) { | |
return reduce_computed.reduceComputed(dependentKey, { | |
initialValue: -Infinity, | |
@@ -25275,6 +25877,39 @@ | |
}); | |
} | |
+ /** | |
+ A computed property that calculates the minimum value in the | |
+ dependent array. This will return `Infinity` when the dependent | |
+ array is empty. | |
+ | |
+ ```javascript | |
+ var Person = Ember.Object.extend({ | |
+ childAges: Ember.computed.mapBy('children', 'age'), | |
+ minChildAge: Ember.computed.min('childAges') | |
+ }); | |
+ | |
+ var lordByron = Person.create({ children: [] }); | |
+ | |
+ lordByron.get('minChildAge'); // Infinity | |
+ lordByron.get('children').pushObject({ | |
+ name: 'Augusta Ada Byron', age: 7 | |
+ }); | |
+ lordByron.get('minChildAge'); // 7 | |
+ lordByron.get('children').pushObjects([{ | |
+ name: 'Allegra Byron', | |
+ age: 5 | |
+ }, { | |
+ name: 'Elizabeth Medora Leigh', | |
+ age: 8 | |
+ }]); | |
+ lordByron.get('minChildAge'); // 5 | |
+ ``` | |
+ | |
+ @method min | |
+ @for Ember.computed | |
+ @param {String} dependentKey | |
+ @return {Ember.ComputedProperty} computes the smallest value in the dependentKey's array | |
+ */ | |
function min(dependentKey) { | |
return reduce_computed.reduceComputed(dependentKey, { | |
initialValue: Infinity, | |
@@ -25291,14 +25926,47 @@ | |
}); | |
} | |
+ /** | |
+ Returns an array mapped via the callback | |
+ | |
+ The callback method you provide should have the following signature. | |
+ `item` is the current item in the iteration. | |
+ `index` is the integer index of the current item in the iteration. | |
+ | |
+ ```javascript | |
+ function(item, index); | |
+ ``` | |
+ | |
+ Example | |
+ | |
+ ```javascript | |
+ var Hamster = Ember.Object.extend({ | |
+ excitingChores: Ember.computed.map('chores', function(chore, index) { | |
+ return chore.toUpperCase() + '!'; | |
+ }) | |
+ }); | |
+ | |
+ var hamster = Hamster.create({ | |
+ chores: ['clean', 'write more unit tests'] | |
+ }); | |
+ | |
+ hamster.get('excitingChores'); // ['CLEAN!', 'WRITE MORE UNIT TESTS!'] | |
+ ``` | |
+ | |
+ @method map | |
+ @for Ember.computed | |
+ @param {String} dependentKey | |
+ @param {Function} callback | |
+ @return {Ember.ComputedProperty} an array mapped via the callback | |
+ */ | |
function map(dependentKey, callback) { | |
var options = { | |
- addedItem: function (array, item, changeMeta, instanceMeta) { | |
+ addedItem: function(array, item, changeMeta, instanceMeta) { | |
var mapped = callback.call(this, item, changeMeta.index); | |
array.insertAt(changeMeta.index, mapped); | |
return array; | |
}, | |
- removedItem: function (array, item, changeMeta, instanceMeta) { | |
+ removedItem: function(array, item, changeMeta, instanceMeta) { | |
array.removeAt(changeMeta.index, 1); | |
return array; | |
} | |
@@ -25307,11 +25975,38 @@ | |
return array_computed.arrayComputed(dependentKey, options); | |
} | |
+ /** | |
+ Returns an array mapped to the specified key. | |
+ | |
+ ```javascript | |
+ var Person = Ember.Object.extend({ | |
+ childAges: Ember.computed.mapBy('children', 'age') | |
+ }); | |
+ | |
+ var lordByron = Person.create({ children: [] }); | |
+ | |
+ lordByron.get('childAges'); // [] | |
+ lordByron.get('children').pushObject({ name: 'Augusta Ada Byron', age: 7 }); | |
+ lordByron.get('childAges'); // [7] | |
+ lordByron.get('children').pushObjects([{ | |
+ name: 'Allegra Byron', | |
+ age: 5 | |
+ }, { | |
+ name: 'Elizabeth Medora Leigh', | |
+ age: 8 | |
+ }]); | |
+ lordByron.get('childAges'); // [7, 5, 8] | |
+ ``` | |
+ | |
+ @method mapBy | |
+ @for Ember.computed | |
+ @param {String} dependentKey | |
+ @param {String} propertyKey | |
+ @return {Ember.ComputedProperty} an array mapped to the specified key | |
+ */ | |
function mapBy(dependentKey, propertyKey) { | |
- var callback = function (item) { | |
- return property_get.get(item, propertyKey); | |
- }; | |
- return map(dependentKey + ".@each." + propertyKey, callback); | |
+ var callback = function(item) { return property_get.get(item, propertyKey); }; | |
+ return map(dependentKey + '.@each.' + propertyKey, callback); | |
} | |
/** | |
@@ -25321,7 +26016,45 @@ | |
@param dependentKey | |
@param propertyKey | |
*/ | |
- var mapProperty = mapBy;function filter(dependentKey, callback) { | |
+ var mapProperty = mapBy; | |
+ | |
+ /** | |
+ Filters the array by the callback. | |
+ | |
+ The callback method you provide should have the following signature. | |
+ `item` is the current item in the iteration. | |
+ `index` is the integer index of the current item in the iteration. | |
+ `array` is the dependant array itself. | |
+ | |
+ ```javascript | |
+ function(item, index, array); | |
+ ``` | |
+ | |
+ ```javascript | |
+ var Hamster = Ember.Object.extend({ | |
+ remainingChores: Ember.computed.filter('chores', function(chore, index, array) { | |
+ return !chore.done; | |
+ }) | |
+ }); | |
+ | |
+ var hamster = Hamster.create({ | |
+ chores: [ | |
+ { name: 'cook', done: true }, | |
+ { name: 'clean', done: true }, | |
+ { name: 'write more unit tests', done: false } | |
+ ] | |
+ }); | |
+ | |
+ hamster.get('remainingChores'); // [{name: 'write more unit tests', done: false}] | |
+ ``` | |
+ | |
+ @method filter | |
+ @for Ember.computed | |
+ @param {String} dependentKey | |
+ @param {Function} callback | |
+ @return {Ember.ComputedProperty} the filtered array | |
+ */ | |
+ function filter(dependentKey, callback) { | |
var options = { | |
initialize: function (array, changeMeta, instanceMeta) { | |
instanceMeta.filteredArrayIndexes = new SubArray['default'](); | |
@@ -25338,7 +26071,7 @@ | |
return array; | |
}, | |
- removedItem: function (array, item, changeMeta, instanceMeta) { | |
+ removedItem: function(array, item, changeMeta, instanceMeta) { | |
var filterIndex = instanceMeta.filteredArrayIndexes.removeItem(changeMeta.index); | |
if (filterIndex > -1) { | |
@@ -25352,20 +26085,46 @@ | |
return array_computed.arrayComputed(dependentKey, options); | |
} | |
+ /** | |
+ Filters the array by the property and value | |
+ | |
+ ```javascript | |
+ var Hamster = Ember.Object.extend({ | |
+ remainingChores: Ember.computed.filterBy('chores', 'done', false) | |
+ }); | |
+ | |
+ var hamster = Hamster.create({ | |
+ chores: [ | |
+ { name: 'cook', done: true }, | |
+ { name: 'clean', done: true }, | |
+ { name: 'write more unit tests', done: false } | |
+ ] | |
+ }); | |
+ | |
+ hamster.get('remainingChores'); // [{ name: 'write more unit tests', done: false }] | |
+ ``` | |
+ | |
+ @method filterBy | |
+ @for Ember.computed | |
+ @param {String} dependentKey | |
+ @param {String} propertyKey | |
+ @param {*} value | |
+ @return {Ember.ComputedProperty} the filtered array | |
+ */ | |
function filterBy(dependentKey, propertyKey, value) { | |
var callback; | |
if (arguments.length === 2) { | |
- callback = function (item) { | |
+ callback = function(item) { | |
return property_get.get(item, propertyKey); | |
}; | |
} else { | |
- callback = function (item) { | |
+ callback = function(item) { | |
return property_get.get(item, propertyKey) === value; | |
}; | |
} | |
- return filter(dependentKey + ".@each." + propertyKey, callback); | |
+ return filter(dependentKey + '.@each.' + propertyKey, callback); | |
} | |
/** | |
@@ -25376,15 +26135,46 @@ | |
@param value | |
@deprecated Use `Ember.computed.filterBy` instead | |
*/ | |
- var filterProperty = filterBy;function uniq() { | |
+ var filterProperty = filterBy; | |
+ | |
+ /** | |
+ A computed property which returns a new array with all the unique | |
+ elements from one or more dependent arrays. | |
+ | |
+ Example | |
+ | |
+ ```javascript | |
+ var Hamster = Ember.Object.extend({ | |
+ uniqueFruits: Ember.computed.uniq('fruits') | |
+ }); | |
+ | |
+ var hamster = Hamster.create({ | |
+ fruits: [ | |
+ 'banana', | |
+ 'grape', | |
+ 'kale', | |
+ 'banana' | |
+ ] | |
+ }); | |
+ | |
+ hamster.get('uniqueFruits'); // ['banana', 'grape', 'kale'] | |
+ ``` | |
+ | |
+ @method uniq | |
+ @for Ember.computed | |
+ @param {String} propertyKey* | |
+ @return {Ember.ComputedProperty} computes a new array with all the | |
+ unique elements from the dependent array | |
+ */ | |
+ function uniq() { | |
var args = a_slice.call(arguments); | |
args.push({ | |
- initialize: function (array, changeMeta, instanceMeta) { | |
+ initialize: function(array, changeMeta, instanceMeta) { | |
instanceMeta.itemCounts = {}; | |
}, | |
- addedItem: function (array, item, changeMeta, instanceMeta) { | |
+ addedItem: function(array, item, changeMeta, instanceMeta) { | |
var guid = utils.guidFor(item); | |
if (!instanceMeta.itemCounts[guid]) { | |
@@ -25396,7 +26186,7 @@ | |
return array; | |
}, | |
- removedItem: function (array, item, _, instanceMeta) { | |
+ removedItem: function(array, item, _, instanceMeta) { | |
var guid = utils.guidFor(item); | |
var itemCounts = instanceMeta.itemCounts; | |
@@ -25420,7 +26210,31 @@ | |
@return {Ember.ComputedProperty} computes a new array with all the | |
unique elements from the dependent array | |
*/ | |
- var union = uniq;function intersect() { | |
+ var union = uniq; | |
+ | |
+ /** | |
+ A computed property which returns a new array with all the duplicated | |
+ elements from two or more dependent arrays. | |
+ | |
+ Example | |
+ | |
+ ```javascript | |
+ var obj = Ember.Object.createWithMixins({ | |
+ adaFriends: ['Charles Babbage', 'John Hobhouse', 'William King', 'Mary Somerville'], | |
+ charlesFriends: ['William King', 'Mary Somerville', 'Ada Lovelace', 'George Peacock'], | |
+ friendsInCommon: Ember.computed.intersect('adaFriends', 'charlesFriends') | |
+ }); | |
+ | |
+ obj.get('friendsInCommon'); // ['William King', 'Mary Somerville'] | |
+ ``` | |
+ | |
+ @method intersect | |
+ @for Ember.computed | |
+ @param {String} propertyKey* | |
+ @return {Ember.ComputedProperty} computes a new array with all the | |
+ duplicated elements from the dependent arrays | |
+ */ | |
+ function intersect() { | |
var args = a_slice.call(arguments); | |
args.push({ | |
@@ -25428,7 +26242,7 @@ | |
instanceMeta.itemCounts = {}; | |
}, | |
- addedItem: function (array, item, changeMeta, instanceMeta) { | |
+ addedItem: function(array, item, changeMeta, instanceMeta) { | |
var itemGuid = utils.guidFor(item); | |
var dependentGuid = utils.guidFor(changeMeta.arrayChanged); | |
var numberOfDependentArrays = changeMeta.property._dependentKeys.length; | |
@@ -25442,14 +26256,15 @@ | |
itemCounts[itemGuid][dependentGuid] = 0; | |
} | |
- if (++itemCounts[itemGuid][dependentGuid] === 1 && numberOfDependentArrays === keys['default'](itemCounts[itemGuid]).length) { | |
+ if (++itemCounts[itemGuid][dependentGuid] === 1 && | |
+ numberOfDependentArrays === keys['default'](itemCounts[itemGuid]).length) { | |
array.addObject(item); | |
} | |
return array; | |
}, | |
- removedItem: function (array, item, changeMeta, instanceMeta) { | |
+ removedItem: function(array, item, changeMeta, instanceMeta) { | |
var itemGuid = utils.guidFor(item); | |
var dependentGuid = utils.guidFor(changeMeta.arrayChanged); | |
var numberOfArraysItemAppearsIn; | |
@@ -25477,9 +26292,40 @@ | |
return array_computed.arrayComputed.apply(null, args); | |
} | |
+ /** | |
+ A computed property which returns a new array with all the | |
+ properties from the first dependent array that are not in the second | |
+ dependent array. | |
+ | |
+ Example | |
+ | |
+ ```javascript | |
+ var Hamster = Ember.Object.extend({ | |
+ likes: ['banana', 'grape', 'kale'], | |
+ wants: Ember.computed.setDiff('likes', 'fruits') | |
+ }); | |
+ | |
+ var hamster = Hamster.create({ | |
+ fruits: [ | |
+ 'grape', | |
+ 'kale', | |
+ ] | |
+ }); | |
+ | |
+ hamster.get('wants'); // ['banana'] | |
+ ``` | |
+ | |
+ @method setDiff | |
+ @for Ember.computed | |
+ @param {String} setAProperty | |
+ @param {String} setBProperty | |
+ @return {Ember.ComputedProperty} computes a new array with all the | |
+ items from the first dependent array that are not in the second | |
+ dependent array | |
+ */ | |
function setDiff(setAProperty, setBProperty) { | |
if (arguments.length !== 2) { | |
- throw new EmberError['default']("setDiff requires exactly two dependent arrays."); | |
+ throw new EmberError['default']('setDiff requires exactly two dependent arrays.'); | |
} | |
return array_computed.arrayComputed(setAProperty, setBProperty, { | |
@@ -25519,7 +26365,7 @@ | |
var mid, midItem, res, guidMid, guidItem; | |
if (arguments.length < 4) { | |
- high = property_get.get(array, "length"); | |
+ high = property_get.get(array, 'length'); | |
} | |
if (arguments.length < 3) { | |
@@ -25546,18 +26392,86 @@ | |
res = guidMid < guidItem ? -1 : 1; | |
} | |
+ | |
if (res < 0) { | |
- return this.binarySearch(array, item, mid + 1, high); | |
+ return this.binarySearch(array, item, mid+1, high); | |
} else if (res > 0) { | |
return this.binarySearch(array, item, low, mid); | |
} | |
return mid; | |
} | |
+ | |
+ | |
+ /** | |
+ A computed property which returns a new array with all the | |
+ properties from the first dependent array sorted based on a property | |
+ or sort function. | |
+ | |
+ The callback method you provide should have the following signature: | |
+ | |
+ ```javascript | |
+ function(itemA, itemB); | |
+ ``` | |
+ | |
+ - `itemA` the first item to compare. | |
+ - `itemB` the second item to compare. | |
+ | |
+ This function should return negative number (e.g. `-1`) when `itemA` should come before | |
+ `itemB`. It should return positive number (e.g. `1`) when `itemA` should come after | |
+ `itemB`. If the `itemA` and `itemB` are equal this function should return `0`. | |
+ | |
+ Therefore, if this function is comparing some numeric values, simple `itemA - itemB` or | |
+ `itemA.get( 'foo' ) - itemB.get( 'foo' )` can be used instead of series of `if`. | |
+ | |
+ Example | |
+ | |
+ ```javascript | |
+ var ToDoList = Ember.Object.extend({ | |
+ // using standard ascending sort | |
+ todosSorting: ['name'], | |
+ sortedTodos: Ember.computed.sort('todos', 'todosSorting'), | |
+ | |
+ // using descending sort | |
+ todosSortingDesc: ['name:desc'], | |
+ sortedTodosDesc: Ember.computed.sort('todos', 'todosSortingDesc'), | |
+ | |
+ // using a custom sort function | |
+ priorityTodos: Ember.computed.sort('todos', function(a, b){ | |
+ if (a.priority > b.priority) { | |
+ return 1; | |
+ } else if (a.priority < b.priority) { | |
+ return -1; | |
+ } | |
+ | |
+ return 0; | |
+ }) | |
+ }); | |
+ | |
+ var todoList = ToDoList.create({todos: [ | |
+ { name: 'Unit Test', priority: 2 }, | |
+ { name: 'Documentation', priority: 3 }, | |
+ { name: 'Release', priority: 1 } | |
+ ]}); | |
+ | |
+ todoList.get('sortedTodos'); // [{ name:'Documentation', priority:3 }, { name:'Release', priority:1 }, { name:'Unit Test', priority:2 }] | |
+ todoList.get('sortedTodosDesc'); // [{ name:'Unit Test', priority:2 }, { name:'Release', priority:1 }, { name:'Documentation', priority:3 }] | |
+ todoList.get('priorityTodos'); // [{ name:'Release', priority:1 }, { name:'Unit Test', priority:2 }, { name:'Documentation', priority:3 }] | |
+ ``` | |
+ | |
+ @method sort | |
+ @for Ember.computed | |
+ @param {String} dependentKey | |
+ @param {String or Function} sortDefinition a dependent key to an | |
+ array of sort properties (add `:desc` to the arrays sort properties to sort descending) or a function to use when sorting | |
+ @return {Ember.ComputedProperty} computes a new sorted array based | |
+ on the sort property array or callback function | |
+ */ | |
function sort(itemsKey, sortDefinition) { | |
- Ember['default'].assert("Ember.computed.sort requires two arguments: an array key to sort and " + "either a sort properties key or sort function", arguments.length === 2); | |
+ Ember['default'].assert('Ember.computed.sort requires two arguments: an array key to sort and ' + | |
+ 'either a sort properties key or sort function', arguments.length === 2); | |
- if (typeof sortDefinition === "function") { | |
+ if (typeof sortDefinition === 'function') { | |
return customSort(itemsKey, sortDefinition); | |
} else { | |
return propertySort(itemsKey, sortDefinition); | |
@@ -25570,17 +26484,17 @@ | |
instanceMeta.order = comparator; | |
instanceMeta.binarySearch = binarySearch; | |
instanceMeta.waitingInsertions = []; | |
- instanceMeta.insertWaiting = function () { | |
+ instanceMeta.insertWaiting = function() { | |
var index, item; | |
var waiting = instanceMeta.waitingInsertions; | |
instanceMeta.waitingInsertions = []; | |
- for (var i = 0; i < waiting.length; i++) { | |
+ for (var i=0; i<waiting.length; i++) { | |
item = waiting[i]; | |
index = instanceMeta.binarySearch(array, item); | |
array.insertAt(index, item); | |
} | |
}; | |
- instanceMeta.insertLater = function (item) { | |
+ instanceMeta.insertLater = function(item) { | |
this.waitingInsertions.push(item); | |
}; | |
}, | |
@@ -25595,7 +26509,7 @@ | |
return array; | |
}, | |
- flushedChanges: function (array, instanceMeta) { | |
+ flushedChanges: function(array, instanceMeta) { | |
instanceMeta.insertWaiting(); | |
} | |
}); | |
@@ -25610,14 +26524,15 @@ | |
var sortPropertyAscending = instanceMeta.sortPropertyAscending = {}; | |
var sortProperty, idx, asc; | |
- Ember['default'].assert("Cannot sort: '" + sortPropertiesKey + "' is not an array.", utils.isArray(sortPropertyDefinitions)); | |
+ Ember['default'].assert('Cannot sort: \'' + sortPropertiesKey + '\' is not an array.', | |
+ utils.isArray(sortPropertyDefinitions)); | |
changeMeta.property.clearItemPropertyKeys(itemsKey); | |
enumerable_utils.forEach(sortPropertyDefinitions, function (sortPropertyDefinition) { | |
- if ((idx = sortPropertyDefinition.indexOf(":")) !== -1) { | |
+ if ((idx = sortPropertyDefinition.indexOf(':')) !== -1) { | |
sortProperty = sortPropertyDefinition.substring(0, idx); | |
- asc = sortPropertyDefinition.substring(idx + 1).toLowerCase() !== "desc"; | |
+ asc = sortPropertyDefinition.substring(idx+1).toLowerCase() !== 'desc'; | |
} else { | |
sortProperty = sortPropertyDefinition; | |
asc = true; | |
@@ -25628,7 +26543,7 @@ | |
changeMeta.property.itemPropertyKey(itemsKey, sortProperty); | |
}); | |
- sortPropertyDefinitions.addObserver("@each", this, updateSortPropertiesOnce); | |
+ sortPropertyDefinitions.addObserver('@each', this, updateSortPropertiesOnce); | |
} | |
function updateSortPropertiesOnce() { | |
@@ -25655,7 +26570,7 @@ | |
if (result !== 0) { | |
asc = this.sortPropertyAscending[sortProperty]; | |
- return asc ? result : -1 * result; | |
+ return asc ? result : (-1 * result); | |
} | |
} | |
@@ -25682,7 +26597,7 @@ | |
} | |
function setupKeyCache(instanceMeta) { | |
- instanceMeta.keyFor = function (item) { | |
+ instanceMeta.keyFor = function(item) { | |
var guid = utils.guidFor(item); | |
if (this.keyCache[guid]) { | |
return this.keyCache[guid]; | |
@@ -25696,7 +26611,7 @@ | |
return this.keyCache[guid] = key; | |
}; | |
- instanceMeta.dropKeyFor = function (item) { | |
+ instanceMeta.dropKeyFor = function(item) { | |
var guid = utils.guidFor(item); | |
this.keyCache[guid] = null; | |
}; | |
@@ -25722,13 +26637,16 @@ | |
/** | |
A string containing the controller name used to wrap items. | |
- For example: | |
- ```javascript | |
+ | |
+ For example: | |
+ | |
+ ```javascript | |
App.MyArrayController = Ember.ArrayController.extend({ | |
itemController: 'myItem' // use App.MyItemController | |
}); | |
``` | |
- @property itemController | |
+ | |
+ @property itemController | |
@type String | |
@default null | |
*/ | |
@@ -25739,8 +26657,10 @@ | |
be returned directly. The default implementation simply returns the | |
`itemController` property, but subclasses can override this method to return | |
different controllers for different objects. | |
- For example: | |
- ```javascript | |
+ | |
+ For example: | |
+ | |
+ ```javascript | |
App.MyArrayController = Ember.ArrayController.extend({ | |
lookupItemController: function( object ) { | |
if (object.get('isSpecial')) { | |
@@ -25751,17 +26671,18 @@ | |
} | |
}); | |
``` | |
- @method lookupItemController | |
+ | |
+ @method lookupItemController | |
@param {Object} object | |
@return {String} | |
*/ | |
- lookupItemController: function (object) { | |
- return property_get.get(this, "itemController"); | |
+ lookupItemController: function(object) { | |
+ return property_get.get(this, 'itemController'); | |
}, | |
- objectAtContent: function (idx) { | |
- var length = property_get.get(this, "length"); | |
- var arrangedContent = property_get.get(this, "arrangedContent"); | |
+ objectAtContent: function(idx) { | |
+ var length = property_get.get(this, 'length'); | |
+ var arrangedContent = property_get.get(this, 'arrangedContent'); | |
var object = arrangedContent && arrangedContent.objectAt(idx); | |
var controllerClass; | |
@@ -25782,18 +26703,18 @@ | |
return object; | |
}, | |
- arrangedContentDidChange: function () { | |
+ arrangedContentDidChange: function() { | |
this._super.apply(this, arguments); | |
this._resetSubControllers(); | |
}, | |
- arrayContentDidChange: function (idx, removedCnt, addedCnt) { | |
+ arrayContentDidChange: function(idx, removedCnt, addedCnt) { | |
var subControllers = this._subControllers; | |
if (subControllers.length) { | |
var subControllersToRemove = subControllers.slice(idx, idx + removedCnt); | |
- enumerable_utils.forEach(subControllersToRemove, function (subController) { | |
+ enumerable_utils.forEach(subControllersToRemove, function(subController) { | |
if (subController) { | |
subController.destroy(); | |
} | |
@@ -25808,14 +26729,18 @@ | |
this._super(idx, removedCnt, addedCnt); | |
}, | |
- init: function () { | |
+ init: function() { | |
this._super.apply(this, arguments); | |
this._subControllers = []; | |
}, | |
model: computed.computed(function (key, value) { | |
if (arguments.length > 1) { | |
- Ember['default'].assert("ArrayController expects `model` to implement the Ember.Array mixin. " + "This can often be fixed by wrapping your model with `Ember.A()`.", EmberArray['default'].detect(value) || !value); | |
+ Ember['default'].assert( | |
+ 'ArrayController expects `model` to implement the Ember.Array mixin. ' + | |
+ 'This can often be fixed by wrapping your model with `Ember.A()`.', | |
+ EmberArray['default'].detect(value) || !value | |
+ ); | |
return value; | |
} | |
@@ -25833,8 +26758,8 @@ | |
*/ | |
_isVirtual: false, | |
- controllerAt: function (idx, object, controllerClass) { | |
- var container = property_get.get(this, "container"); | |
+ controllerAt: function(idx, object, controllerClass) { | |
+ var container = property_get.get(this, 'container'); | |
var subControllers = this._subControllers; | |
var fullName, subController, parentController; | |
@@ -25847,15 +26772,15 @@ | |
} | |
if (this._isVirtual) { | |
- parentController = property_get.get(this, "parentController"); | |
+ parentController = property_get.get(this, 'parentController'); | |
} else { | |
parentController = this; | |
} | |
- fullName = "controller:" + controllerClass; | |
+ fullName = 'controller:' + controllerClass; | |
if (!container._registry.has(fullName)) { | |
- throw new EmberError['default']("Could not resolve itemController: \"" + controllerClass + "\""); | |
+ throw new EmberError['default']('Could not resolve itemController: "' + controllerClass + '"'); | |
} | |
subController = container.lookupFactory(fullName).create({ | |
@@ -25871,7 +26796,7 @@ | |
_subControllers: null, | |
- _resetSubControllers: function () { | |
+ _resetSubControllers: function() { | |
var controller; | |
var subControllers = this._subControllers; | |
@@ -25888,7 +26813,7 @@ | |
} | |
}, | |
- willDestroy: function () { | |
+ willDestroy: function() { | |
this._resetSubControllers(); | |
this._super.apply(this, arguments); | |
} | |
@@ -25902,7 +26827,8 @@ | |
var Controller = EmberObject['default'].extend(Mixin['default']); | |
function controllerInjectionHelper(factory) { | |
- Ember['default'].assert("Defining an injected controller property on a " + "non-controller is not allowed.", Mixin['default'].detect(factory.PrototypeMixin)); | |
+ Ember['default'].assert("Defining an injected controller property on a " + | |
+ "non-controller is not allowed.", Mixin['default'].detect(factory.PrototypeMixin)); | |
} | |
/** | |
@@ -25935,7 +26861,7 @@ | |
to the property's name | |
@return {Ember.InjectedProperty} injection descriptor instance | |
*/ | |
- inject.createInjectionHelper("controller", controllerInjectionHelper); | |
+ inject.createInjectionHelper('controller', controllerInjectionHelper); | |
exports['default'] = Controller; | |
@@ -25944,14 +26870,34 @@ | |
'use strict'; | |
- var objectControllerDeprecation = "Ember.ObjectController is deprecated, " + "please use Ember.Controller and use `model.propertyName`."; | |
+ var objectControllerDeprecation = 'Ember.ObjectController is deprecated, ' + | |
+ 'please use Ember.Controller and use `model.propertyName`.'; | |
+ | |
+ /** | |
+ @module ember | |
+ @submodule ember-runtime | |
+ */ | |
+ | |
+ /** | |
+ `Ember.ObjectController` is part of Ember's Controller layer. It is intended | |
+ to wrap a single object, proxying unhandled attempts to `get` and `set` to the underlying | |
+ model object, and to forward unhandled action attempts to its `target`. | |
+ | |
+ `Ember.ObjectController` derives this functionality from its superclass | |
+ `Ember.ObjectProxy` and the `Ember.ControllerMixin` mixin. | |
+ @class ObjectController | |
+ @namespace Ember | |
+ @extends Ember.ObjectProxy | |
+ @uses Ember.ControllerMixin | |
+ @deprecated | |
+ **/ | |
exports['default'] = ObjectProxy['default'].extend(ControllerMixin['default'], { | |
- init: function () { | |
+ init: function() { | |
this._super(); | |
Ember['default'].deprecate(objectControllerDeprecation, this.isGenerated, { | |
- url: "http://emberjs.com/guides/deprecations/#toc_objectcontroller" | |
+ url: 'http://emberjs.com/guides/deprecations/#toc_objectcontroller' | |
}); | |
} | |
}); | |
@@ -25963,29 +26909,11 @@ | |
'use strict'; | |
- | |
- | |
- /** | |
- Creates a clone of the passed object. This function can take just about | |
- any type of object and create a clone of it, including primitive values | |
- (which are not actually cloned because they are immutable). | |
- | |
- If the passed object implements the `copy()` method, then this function | |
- will simply call that method and return the result. Please see | |
- `Ember.Copyable` for further details. | |
- | |
- @method copy | |
- @for Ember | |
- @param {Object} obj The object to clone | |
- @param {Boolean} deep If true, a deep copy of the object is made | |
- @return {Object} The cloned object | |
- */ | |
- exports['default'] = copy; | |
function _copy(obj, deep, seen, copies) { | |
var ret, loc, key; | |
// primitive data types are immutable, just return them. | |
- if (typeof obj !== "object" || obj === null) { | |
+ if (typeof obj !== 'object' || obj === null) { | |
return obj; | |
} | |
@@ -25994,11 +26922,12 @@ | |
return copies[loc]; | |
} | |
- Ember.assert("Cannot clone an Ember.Object that does not implement Ember.Copyable", !(obj instanceof EmberObject['default']) || Copyable['default'] && Copyable['default'].detect(obj)); | |
+ Ember.assert('Cannot clone an Ember.Object that does not implement Ember.Copyable', | |
+ !(obj instanceof EmberObject['default']) || (Copyable['default'] && Copyable['default'].detect(obj))); | |
// IMPORTANT: this specific test will detect a native array only. Any other | |
// object will need to implement Copyable. | |
- if (utils.typeOf(obj) === "array") { | |
+ if (utils.typeOf(obj) === 'array') { | |
ret = obj.slice(); | |
if (deep) { | |
@@ -26023,7 +26952,7 @@ | |
// Prevents browsers that don't respect non-enumerability from | |
// copying internal Ember properties | |
- if (key.substring(0, 2) === "__") { | |
+ if (key.substring(0, 2) === '__') { | |
continue; | |
} | |
@@ -26038,9 +26967,25 @@ | |
return ret; | |
} | |
+ | |
+ /** | |
+ Creates a clone of the passed object. This function can take just about | |
+ any type of object and create a clone of it, including primitive values | |
+ (which are not actually cloned because they are immutable). | |
+ | |
+ If the passed object implements the `copy()` method, then this function | |
+ will simply call that method and return the result. Please see | |
+ `Ember.Copyable` for further details. | |
+ | |
+ @method copy | |
+ @for Ember | |
+ @param {Object} obj The object to clone | |
+ @param {Boolean} deep If true, a deep copy of the object is made | |
+ @return {Object} The cloned object | |
+ */ | |
function copy(obj, deep) { | |
// fast paths | |
- if ("object" !== typeof obj || obj === null) { | |
+ if ('object' !== typeof obj || obj === null) { | |
return obj; // can't copy primitives | |
} | |
@@ -26050,6 +26995,7 @@ | |
return _copy(obj, deep, deep ? [] : null, deep ? [] : null); | |
} | |
+ exports['default'] = copy; | |
}); | |
enifed('ember-runtime/core', ['exports'], function (exports) { | |
@@ -26082,7 +27028,7 @@ | |
@return {Boolean} | |
*/ | |
function isEqual(a, b) { | |
- if (a && typeof a.isEqual === "function") { | |
+ if (a && typeof a.isEqual === 'function') { | |
return a.isEqual(b); | |
} | |
@@ -26112,45 +27058,58 @@ | |
The `property` extension of Javascript's Function prototype is available | |
when `Ember.EXTEND_PROTOTYPES` or `Ember.EXTEND_PROTOTYPES.Function` is | |
`true`, which is the default. | |
- Computed properties allow you to treat a function like a property: | |
- ```javascript | |
+ | |
+ Computed properties allow you to treat a function like a property: | |
+ | |
+ ```javascript | |
MyApp.President = Ember.Object.extend({ | |
firstName: '', | |
lastName: '', | |
- fullName: function() { | |
+ | |
+ fullName: function() { | |
return this.get('firstName') + ' ' + this.get('lastName'); | |
}.property() // Call this flag to mark the function as a property | |
}); | |
- var president = MyApp.President.create({ | |
+ | |
+ var president = MyApp.President.create({ | |
firstName: 'Barack', | |
lastName: 'Obama' | |
}); | |
- president.get('fullName'); // 'Barack Obama' | |
+ | |
+ president.get('fullName'); // 'Barack Obama' | |
``` | |
- Treating a function like a property is useful because they can work with | |
+ | |
+ Treating a function like a property is useful because they can work with | |
bindings, just like any other property. | |
- Many computed properties have dependencies on other properties. For | |
+ | |
+ Many computed properties have dependencies on other properties. For | |
example, in the above example, the `fullName` property depends on | |
`firstName` and `lastName` to determine its value. You can tell Ember | |
about these dependencies like this: | |
- ```javascript | |
+ | |
+ ```javascript | |
MyApp.President = Ember.Object.extend({ | |
firstName: '', | |
lastName: '', | |
- fullName: function() { | |
+ | |
+ fullName: function() { | |
return this.get('firstName') + ' ' + this.get('lastName'); | |
- // Tell Ember.js that this computed property depends on firstName | |
+ | |
+ // Tell Ember.js that this computed property depends on firstName | |
// and lastName | |
}.property('firstName', 'lastName') | |
}); | |
``` | |
- Make sure you list these dependencies so Ember knows when to update | |
+ | |
+ Make sure you list these dependencies so Ember knows when to update | |
bindings that connect to a computed property. Changing a dependency | |
will not immediately trigger an update of the computed property, but | |
will instead clear the cache so that it is updated when the next `get` | |
is called on the property. | |
- See [Ember.ComputedProperty](/api/classes/Ember.ComputedProperty.html), [Ember.computed](/api/#method_computed). | |
- @method property | |
+ | |
+ See [Ember.ComputedProperty](/api/classes/Ember.ComputedProperty.html), [Ember.computed](/api/#method_computed). | |
+ | |
+ @method property | |
@for Function | |
*/ | |
FunctionPrototype.property = function () { | |
@@ -26164,23 +27123,28 @@ | |
The `observes` extension of Javascript's Function prototype is available | |
when `Ember.EXTEND_PROTOTYPES` or `Ember.EXTEND_PROTOTYPES.Function` is | |
true, which is the default. | |
- You can observe property changes simply by adding the `observes` | |
+ | |
+ You can observe property changes simply by adding the `observes` | |
call to the end of your method declarations in classes that you write. | |
For example: | |
- ```javascript | |
+ | |
+ ```javascript | |
Ember.Object.extend({ | |
valueObserver: function() { | |
// Executes whenever the "value" property changes | |
}.observes('value') | |
}); | |
``` | |
- In the future this method may become asynchronous. If you want to ensure | |
+ | |
+ In the future this method may become asynchronous. If you want to ensure | |
synchronous behavior, use `observesImmediately`. | |
- See `Ember.observer`. | |
- @method observes | |
+ | |
+ See `Ember.observer`. | |
+ | |
+ @method observes | |
@for Function | |
*/ | |
- FunctionPrototype.observes = function () { | |
+ FunctionPrototype.observes = function() { | |
var length = arguments.length; | |
var args = new Array(length); | |
for (var x = 0; x < length; x++) { | |
@@ -26193,26 +27157,32 @@ | |
The `observesImmediately` extension of Javascript's Function prototype is | |
available when `Ember.EXTEND_PROTOTYPES` or | |
`Ember.EXTEND_PROTOTYPES.Function` is true, which is the default. | |
- You can observe property changes simply by adding the `observesImmediately` | |
+ | |
+ You can observe property changes simply by adding the `observesImmediately` | |
call to the end of your method declarations in classes that you write. | |
For example: | |
- ```javascript | |
+ | |
+ ```javascript | |
Ember.Object.extend({ | |
valueObserver: function() { | |
// Executes immediately after the "value" property changes | |
}.observesImmediately('value') | |
}); | |
``` | |
- In the future, `observes` may become asynchronous. In this event, | |
+ | |
+ In the future, `observes` may become asynchronous. In this event, | |
`observesImmediately` will maintain the synchronous behavior. | |
- See `Ember.immediateObserver`. | |
- @method observesImmediately | |
+ | |
+ See `Ember.immediateObserver`. | |
+ | |
+ @method observesImmediately | |
@for Function | |
*/ | |
FunctionPrototype.observesImmediately = function () { | |
- Ember['default'].assert("Immediate observers must observe internal properties only, " + "not properties on other objects.", function checkIsInternalProperty() { | |
+ Ember['default'].assert('Immediate observers must observe internal properties only, ' + | |
+ 'not properties on other objects.', function checkIsInternalProperty() { | |
for (var i = 0, l = arguments.length; i < l; i++) { | |
- if (arguments[i].indexOf(".") !== -1) { | |
+ if (arguments[i].indexOf('.') !== -1) { | |
return false; | |
} | |
} | |
@@ -26227,18 +27197,22 @@ | |
The `observesBefore` extension of Javascript's Function prototype is | |
available when `Ember.EXTEND_PROTOTYPES` or | |
`Ember.EXTEND_PROTOTYPES.Function` is true, which is the default. | |
- You can get notified when a property change is about to happen by | |
+ | |
+ You can get notified when a property change is about to happen by | |
by adding the `observesBefore` call to the end of your method | |
declarations in classes that you write. For example: | |
- ```javascript | |
+ | |
+ ```javascript | |
Ember.Object.extend({ | |
valueObserver: function() { | |
// Executes whenever the "value" property is about to change | |
}.observesBefore('value') | |
}); | |
``` | |
- See `Ember.beforeObserver`. | |
- @method observesBefore | |
+ | |
+ See `Ember.beforeObserver`. | |
+ | |
+ @method observesBefore | |
@for Function | |
*/ | |
FunctionPrototype.observesBefore = function () { | |
@@ -26260,17 +27234,21 @@ | |
The `on` extension of Javascript's Function prototype is available | |
when `Ember.EXTEND_PROTOTYPES` or `Ember.EXTEND_PROTOTYPES.Function` is | |
true, which is the default. | |
- You can listen for events simply by adding the `on` call to the end of | |
+ | |
+ You can listen for events simply by adding the `on` call to the end of | |
your method declarations in classes or mixins that you write. For example: | |
- ```javascript | |
+ | |
+ ```javascript | |
Ember.Mixin.create({ | |
doSomethingWithElement: function() { | |
// Executes whenever the "didInsertElement" event fires | |
}.on('didInsertElement') | |
}); | |
``` | |
- See `Ember.on`. | |
- @method on | |
+ | |
+ See `Ember.on`. | |
+ | |
+ @method on | |
@for Function | |
*/ | |
FunctionPrototype.on = function () { | |
@@ -26288,47 +27266,46 @@ | |
exports.onerrorDefault = onerrorDefault; | |
- var testModuleName = "ember-testing/test"; | |
+ /* globals RSVP:true */ | |
+ | |
+ var testModuleName = 'ember-testing/test'; | |
var Test; | |
- var asyncStart = function () { | |
+ var asyncStart = function() { | |
if (Ember['default'].Test && Ember['default'].Test.adapter) { | |
Ember['default'].Test.adapter.asyncStart(); | |
} | |
}; | |
- var asyncEnd = function () { | |
+ var asyncEnd = function() { | |
if (Ember['default'].Test && Ember['default'].Test.adapter) { | |
Ember['default'].Test.adapter.asyncEnd(); | |
} | |
}; | |
- RSVP.configure("async", function (callback, promise) { | |
+ RSVP.configure('async', function(callback, promise) { | |
var async = !run['default'].currentRunLoop; | |
- if (Ember['default'].testing && async) { | |
- asyncStart(); | |
- } | |
+ if (Ember['default'].testing && async) { asyncStart(); } | |
- run['default'].backburner.schedule("actions", function () { | |
- if (Ember['default'].testing && async) { | |
- asyncEnd(); | |
- } | |
+ run['default'].backburner.schedule('actions', function() { | |
+ if (Ember['default'].testing && async) { asyncEnd(); } | |
callback(promise); | |
}); | |
}); | |
- RSVP.Promise.prototype.fail = function (callback, label) { | |
- Ember['default'].deprecate("RSVP.Promise.fail has been renamed as RSVP.Promise.catch"); | |
- return this["catch"](callback, label); | |
+ RSVP.Promise.prototype.fail = function(callback, label) { | |
+ Ember['default'].deprecate('RSVP.Promise.fail has been renamed as RSVP.Promise.catch'); | |
+ return this['catch'](callback, label); | |
}; | |
+ | |
function onerrorDefault(e) { | |
var error; | |
if (e && e.errorThrown) { | |
// jqXHR provides this | |
error = e.errorThrown; | |
- if (typeof error === "string") { | |
+ if (typeof error === 'string') { | |
error = new Error(error); | |
} | |
error.__reason_with_error_thrown__ = e; | |
@@ -26336,11 +27313,11 @@ | |
error = e; | |
} | |
- if (error && error.name !== "TransitionAborted") { | |
+ if (error && error.name !== 'TransitionAborted') { | |
if (Ember['default'].testing) { | |
// ES6TODO: remove when possible | |
if (!Test && Ember['default'].__loader.registry[testModuleName]) { | |
- Test = requireModule(testModuleName)["default"]; | |
+ Test = requireModule(testModuleName)['default']; | |
} | |
if (Test && Test.adapter) { | |
@@ -26357,7 +27334,7 @@ | |
} | |
} | |
- RSVP.on("error", onerrorDefault); | |
+ RSVP.on('error', onerrorDefault); | |
exports['default'] = RSVP; | |
@@ -26377,7 +27354,8 @@ | |
/** | |
See [Ember.String.fmt](/api/classes/Ember.String.html#method_fmt). | |
- @method fmt | |
+ | |
+ @method fmt | |
@for String | |
*/ | |
StringPrototype.fmt = function () { | |
@@ -26386,7 +27364,8 @@ | |
/** | |
See [Ember.String.w](/api/classes/Ember.String.html#method_w). | |
- @method w | |
+ | |
+ @method w | |
@for String | |
*/ | |
StringPrototype.w = function () { | |
@@ -26395,7 +27374,8 @@ | |
/** | |
See [Ember.String.loc](/api/classes/Ember.String.html#method_loc). | |
- @method loc | |
+ | |
+ @method loc | |
@for String | |
*/ | |
StringPrototype.loc = function () { | |
@@ -26404,7 +27384,8 @@ | |
/** | |
See [Ember.String.camelize](/api/classes/Ember.String.html#method_camelize). | |
- @method camelize | |
+ | |
+ @method camelize | |
@for String | |
*/ | |
StringPrototype.camelize = function () { | |
@@ -26413,7 +27394,8 @@ | |
/** | |
See [Ember.String.decamelize](/api/classes/Ember.String.html#method_decamelize). | |
- @method decamelize | |
+ | |
+ @method decamelize | |
@for String | |
*/ | |
StringPrototype.decamelize = function () { | |
@@ -26422,7 +27404,8 @@ | |
/** | |
See [Ember.String.dasherize](/api/classes/Ember.String.html#method_dasherize). | |
- @method dasherize | |
+ | |
+ @method dasherize | |
@for String | |
*/ | |
StringPrototype.dasherize = function () { | |
@@ -26431,7 +27414,8 @@ | |
/** | |
See [Ember.String.underscore](/api/classes/Ember.String.html#method_underscore). | |
- @method underscore | |
+ | |
+ @method underscore | |
@for String | |
*/ | |
StringPrototype.underscore = function () { | |
@@ -26440,7 +27424,8 @@ | |
/** | |
See [Ember.String.classify](/api/classes/Ember.String.html#method_classify). | |
- @method classify | |
+ | |
+ @method classify | |
@for String | |
*/ | |
StringPrototype.classify = function () { | |
@@ -26449,7 +27434,8 @@ | |
/** | |
See [Ember.String.capitalize](/api/classes/Ember.String.html#method_capitalize). | |
- @method capitalize | |
+ | |
+ @method capitalize | |
@for String | |
*/ | |
StringPrototype.capitalize = function () { | |
@@ -26465,6 +27451,14 @@ | |
exports.createInjectionHelper = createInjectionHelper; | |
exports.validatePropertyInjections = validatePropertyInjections; | |
+ function inject() { | |
+ Ember['default'].assert("Injected properties must be created through helpers, see `" + | |
+ keys['default'](inject).join("`, `") + "`"); | |
+ } | |
+ | |
+ // Dictionary of injection validations by type, added to by `createInjectionHelper` | |
+ var typeValidators = {}; | |
+ | |
/** | |
This method allows other Ember modules to register injection helpers for a | |
given container type. Helpers are exported to the `inject` namespace as the | |
@@ -26477,20 +27471,24 @@ | |
@param {String} type The container type the helper will inject | |
@param {Function} validator A validation callback that is executed at mixin-time | |
*/ | |
- function inject() { | |
- Ember['default'].assert("Injected properties must be created through helpers, see `" + keys['default'](inject).join("`, `") + "`"); | |
- } | |
- | |
- // Dictionary of injection validations by type, added to by `createInjectionHelper` | |
- var typeValidators = {}; | |
function createInjectionHelper(type, validator) { | |
typeValidators[type] = validator; | |
- inject[type] = function (name) { | |
+ inject[type] = function(name) { | |
return new InjectedProperty['default'](type, name); | |
}; | |
} | |
+ /** | |
+ Validation function that runs per-type validation functions once for each | |
+ injected type encountered. | |
+ | |
+ @private | |
+ @method validatePropertyInjections | |
+ @since 1.10.0 | |
+ @for Ember | |
+ @param {Object} factory The factory object | |
+ */ | |
function validatePropertyInjections(factory) { | |
var proto = factory.proto(); | |
var types = []; | |
@@ -26507,7 +27505,7 @@ | |
for (i = 0, l = types.length; i < l; i++) { | |
validator = typeValidators[types[i]]; | |
- if (typeof validator === "function") { | |
+ if (typeof validator === 'function') { | |
validator(factory); | |
} | |
} | |
@@ -26530,17 +27528,13 @@ | |
function contentPropertyWillChange(content, contentKey) { | |
var key = contentKey.slice(8); // remove "content." | |
- if (key in this) { | |
- return; | |
- } // if shadowed in proxy | |
+ if (key in this) { return; } // if shadowed in proxy | |
property_events.propertyWillChange(this, key); | |
} | |
function contentPropertyDidChange(content, contentKey) { | |
var key = contentKey.slice(8); // remove "content." | |
- if (key in this) { | |
- return; | |
- } // if shadowed in proxy | |
+ if (key in this) { return; } // if shadowed in proxy | |
property_events.propertyDidChange(this, key); | |
} | |
@@ -26554,35 +27548,41 @@ | |
exports['default'] = mixin.Mixin.create({ | |
/** | |
The object whose properties will be forwarded. | |
- @property content | |
+ | |
+ @property content | |
@type Ember.Object | |
@default null | |
*/ | |
content: null, | |
- _contentDidChange: mixin.observer("content", function () { | |
- Ember['default'].assert("Can't set Proxy's content to itself", property_get.get(this, "content") !== this); | |
+ _contentDidChange: mixin.observer('content', function() { | |
+ Ember['default'].assert("Can't set Proxy's content to itself", property_get.get(this, 'content') !== this); | |
}), | |
- isTruthy: computed.computed.bool("content"), | |
+ isTruthy: computed.computed.bool('content'), | |
_debugContainerKey: null, | |
willWatchProperty: function (key) { | |
- var contentKey = "content." + key; | |
+ var contentKey = 'content.' + key; | |
observer.addBeforeObserver(this, contentKey, null, contentPropertyWillChange); | |
observer.addObserver(this, contentKey, null, contentPropertyDidChange); | |
}, | |
didUnwatchProperty: function (key) { | |
- var contentKey = "content." + key; | |
+ var contentKey = 'content.' + key; | |
observer.removeBeforeObserver(this, contentKey, null, contentPropertyWillChange); | |
observer.removeObserver(this, contentKey, null, contentPropertyDidChange); | |
}, | |
unknownProperty: function (key) { | |
- var content = property_get.get(this, "content"); | |
+ var content = property_get.get(this, 'content'); | |
if (content) { | |
- Ember['default'].deprecate(string.fmt("You attempted to access `%@` from `%@`, but object proxying is deprecated. " + "Please use `model.%@` instead.", [key, this, key]), !this.isController, { url: "http://emberjs.com/guides/deprecations/#toc_objectcontroller" }); | |
+ Ember['default'].deprecate( | |
+ string.fmt('You attempted to access `%@` from `%@`, but object proxying is deprecated. ' + | |
+ 'Please use `model.%@` instead.', [key, this, key]), | |
+ !this.isController, | |
+ { url: 'http://emberjs.com/guides/deprecations/#toc_objectcontroller' } | |
+ ); | |
return property_get.get(content, key); | |
} | |
}, | |
@@ -26596,10 +27596,16 @@ | |
return value; | |
} | |
- var content = property_get.get(this, "content"); | |
- Ember['default'].assert(string.fmt("Cannot delegate set('%@', %@) to the 'content' property of" + " object proxy %@: its 'content' is undefined.", [key, value, this]), content); | |
- | |
- Ember['default'].deprecate(string.fmt("You attempted to set `%@` from `%@`, but object proxying is deprecated. " + "Please use `model.%@` instead.", [key, this, key]), !this.isController, { url: "http://emberjs.com/guides/deprecations/#toc_objectcontroller" }); | |
+ var content = property_get.get(this, 'content'); | |
+ Ember['default'].assert(string.fmt("Cannot delegate set('%@', %@) to the 'content' property of" + | |
+ " object proxy %@: its 'content' is undefined.", [key, value, this]), content); | |
+ | |
+ Ember['default'].deprecate( | |
+ string.fmt('You attempted to set `%@` from `%@`, but object proxying is deprecated. ' + | |
+ 'Please use `model.%@` instead.', [key, this, key]), | |
+ !this.isController, | |
+ { url: 'http://emberjs.com/guides/deprecations/#toc_objectcontroller' } | |
+ ); | |
return property_set.set(content, key, value); | |
} | |
@@ -26615,19 +27621,23 @@ | |
@submodule ember-runtime | |
*/ | |
var ActionHandler = mixin.Mixin.create({ | |
- mergedProperties: ["_actions"], | |
+ mergedProperties: ['_actions'], | |
/** | |
The collection of functions, keyed by name, available on this | |
`ActionHandler` as action targets. | |
- These functions will be invoked when a matching `{{action}}` is triggered | |
+ | |
+ These functions will be invoked when a matching `{{action}}` is triggered | |
from within a template and the application's current route is this route. | |
- Actions can also be invoked from other parts of your application | |
+ | |
+ Actions can also be invoked from other parts of your application | |
via `ActionHandler#send`. | |
- The `actions` hash will inherit action handlers from | |
+ | |
+ The `actions` hash will inherit action handlers from | |
the `actions` hash defined on extended parent classes | |
or mixins rather than just replace the entire hash, e.g.: | |
- ```js | |
+ | |
+ ```js | |
App.CanDisplayBanner = Ember.Mixin.create({ | |
actions: { | |
displayBanner: function(msg) { | |
@@ -26635,23 +27645,27 @@ | |
} | |
} | |
}); | |
- App.WelcomeRoute = Ember.Route.extend(App.CanDisplayBanner, { | |
+ | |
+ App.WelcomeRoute = Ember.Route.extend(App.CanDisplayBanner, { | |
actions: { | |
playMusic: function() { | |
// ... | |
} | |
} | |
}); | |
- // `WelcomeRoute`, when active, will be able to respond | |
+ | |
+ // `WelcomeRoute`, when active, will be able to respond | |
// to both actions, since the actions hash is merged rather | |
// then replaced when extending mixins / parent classes. | |
this.send('displayBanner'); | |
this.send('playMusic'); | |
``` | |
- Within a Controller, Route, View or Component's action handler, | |
+ | |
+ Within a Controller, Route, View or Component's action handler, | |
the value of the `this` context is the Controller, Route, View or | |
Component object: | |
- ```js | |
+ | |
+ ```js | |
App.SongRoute = Ember.Route.extend({ | |
actions: { | |
myAction: function() { | |
@@ -26662,11 +27676,14 @@ | |
} | |
}); | |
``` | |
- It is also possible to call `this._super.apply(this, arguments)` from within an | |
+ | |
+ It is also possible to call `this._super.apply(this, arguments)` from within an | |
action handler if it overrides a handler defined on a parent | |
class or mixin: | |
- Take for example the following routes: | |
- ```js | |
+ | |
+ Take for example the following routes: | |
+ | |
+ ```js | |
App.DebugRoute = Ember.Mixin.create({ | |
actions: { | |
debugRouteInformation: function() { | |
@@ -26674,45 +27691,54 @@ | |
} | |
} | |
}); | |
- App.AnnoyingDebugRoute = Ember.Route.extend(App.DebugRoute, { | |
+ | |
+ App.AnnoyingDebugRoute = Ember.Route.extend(App.DebugRoute, { | |
actions: { | |
debugRouteInformation: function() { | |
// also call the debugRouteInformation of mixed in App.DebugRoute | |
this._super.apply(this, arguments); | |
- // show additional annoyance | |
+ | |
+ // show additional annoyance | |
window.alert(...); | |
} | |
} | |
}); | |
``` | |
- ## Bubbling | |
- By default, an action will stop bubbling once a handler defined | |
+ | |
+ ## Bubbling | |
+ | |
+ By default, an action will stop bubbling once a handler defined | |
on the `actions` hash handles it. To continue bubbling the action, | |
you must return `true` from the handler: | |
- ```js | |
+ | |
+ ```js | |
App.Router.map(function() { | |
this.resource("album", function() { | |
this.route("song"); | |
}); | |
}); | |
- App.AlbumRoute = Ember.Route.extend({ | |
+ | |
+ App.AlbumRoute = Ember.Route.extend({ | |
actions: { | |
startPlaying: function() { | |
} | |
} | |
}); | |
- App.AlbumSongRoute = Ember.Route.extend({ | |
+ | |
+ App.AlbumSongRoute = Ember.Route.extend({ | |
actions: { | |
startPlaying: function() { | |
// ... | |
- if (actionShouldAlsoBeTriggeredOnParentRoute) { | |
+ | |
+ if (actionShouldAlsoBeTriggeredOnParentRoute) { | |
return true; | |
} | |
} | |
} | |
}); | |
``` | |
- @property actions | |
+ | |
+ @property actions | |
@type Hash | |
@default null | |
*/ | |
@@ -26721,20 +27747,22 @@ | |
Moves `actions` to `_actions` at extend time. Note that this currently | |
modifies the mixin themselves, which is technically dubious but | |
is practically of little consequence. This may change in the future. | |
- @private | |
+ | |
+ @private | |
@method willMergeMixin | |
*/ | |
- willMergeMixin: function (props) { | |
+ willMergeMixin: function(props) { | |
var hashName; | |
if (!props._actions) { | |
- Ember.assert("'actions' should not be a function", typeof props.actions !== "function"); | |
+ Ember.assert("'actions' should not be a function", typeof(props.actions) !== 'function'); | |
- if (utils.typeOf(props.actions) === "object") { | |
- hashName = "actions"; | |
- } else if (utils.typeOf(props.events) === "object") { | |
- Ember.deprecate("Action handlers contained in an `events` object are deprecated in favor" + " of putting them in an `actions` object"); | |
- hashName = "events"; | |
+ if (utils.typeOf(props.actions) === 'object') { | |
+ hashName = 'actions'; | |
+ } else if (utils.typeOf(props.events) === 'object') { | |
+ Ember.deprecate('Action handlers contained in an `events` object are deprecated in favor' + | |
+ ' of putting them in an `actions` object'); | |
+ hashName = 'events'; | |
} | |
if (hashName) { | |
@@ -26749,12 +27777,15 @@ | |
Triggers a named action on the `ActionHandler`. Any parameters | |
supplied after the `actionName` string will be passed as arguments | |
to the action target function. | |
- If the `ActionHandler` has its `target` property set, actions may | |
+ | |
+ If the `ActionHandler` has its `target` property set, actions may | |
bubble to the `target`. Bubbling happens when an `actionName` can | |
not be found in the `ActionHandler`'s `actions` hash or if the | |
action target function returns `true`. | |
- Example | |
- ```js | |
+ | |
+ Example | |
+ | |
+ ```js | |
App.WelcomeRoute = Ember.Route.extend({ | |
actions: { | |
playTheme: function() { | |
@@ -26766,23 +27797,23 @@ | |
} | |
}); | |
``` | |
- @method send | |
+ | |
+ @method send | |
@param {String} actionName The action to trigger | |
@param {*} context a context to send with the action | |
*/ | |
- send: function (actionName) { | |
+ send: function(actionName) { | |
var args = [].slice.call(arguments, 1); | |
var target; | |
if (this._actions && this._actions[actionName]) { | |
var shouldBubble = this._actions[actionName].apply(this, args) === true; | |
- if (!shouldBubble) { | |
- return; | |
- } | |
+ if (!shouldBubble) { return; } | |
} | |
- if (target = property_get.get(this, "target")) { | |
- Ember.assert("The `target` for " + this + " (" + target + ") does not have a `send` method", typeof target.send === "function"); | |
+ if (target = property_get.get(this, 'target')) { | |
+ Ember.assert("The `target` for " + this + " (" + target + | |
+ ") does not have a `send` method", typeof target.send === 'function'); | |
target.send.apply(target, arguments); | |
} | |
} | |
@@ -26804,19 +27835,19 @@ | |
// HELPERS | |
// | |
function arrayObserversHelper(obj, target, opts, operation, notify) { | |
- var willChange = opts && opts.willChange || "arrayWillChange"; | |
- var didChange = opts && opts.didChange || "arrayDidChange"; | |
- var hasObservers = property_get.get(obj, "hasArrayObservers"); | |
+ var willChange = (opts && opts.willChange) || 'arrayWillChange'; | |
+ var didChange = (opts && opts.didChange) || 'arrayDidChange'; | |
+ var hasObservers = property_get.get(obj, 'hasArrayObservers'); | |
if (hasObservers === notify) { | |
- property_events.propertyWillChange(obj, "hasArrayObservers"); | |
+ property_events.propertyWillChange(obj, 'hasArrayObservers'); | |
} | |
- operation(obj, "@array:before", target, willChange); | |
- operation(obj, "@array:change", target, didChange); | |
+ operation(obj, '@array:before', target, willChange); | |
+ operation(obj, '@array:change', target, didChange); | |
if (hasObservers === notify) { | |
- property_events.propertyDidChange(obj, "hasArrayObservers"); | |
+ property_events.propertyDidChange(obj, 'hasArrayObservers'); | |
} | |
return obj; | |
@@ -26866,31 +27897,36 @@ | |
/** | |
Your array must support the `length` property. Your replace methods should | |
set this property whenever it changes. | |
- @property {Number} length | |
+ | |
+ @property {Number} length | |
*/ | |
length: mixin.required(), | |
/** | |
Returns the object at the given `index`. If the given `index` is negative | |
or is greater or equal than the array length, returns `undefined`. | |
- This is one of the primitives you must implement to support `Ember.Array`. | |
+ | |
+ This is one of the primitives you must implement to support `Ember.Array`. | |
If your object supports retrieving the value of an array item using `get()` | |
(i.e. `myArray.get(0)`), then you do not need to implement this method | |
yourself. | |
- ```javascript | |
+ | |
+ ```javascript | |
var arr = ['a', 'b', 'c', 'd']; | |
- arr.objectAt(0); // 'a' | |
+ | |
+ arr.objectAt(0); // 'a' | |
arr.objectAt(3); // 'd' | |
arr.objectAt(-1); // undefined | |
arr.objectAt(4); // undefined | |
arr.objectAt(5); // undefined | |
``` | |
- @method objectAt | |
+ | |
+ @method objectAt | |
@param {Number} idx The index of the item to return. | |
@return {*} item at index or undefined | |
*/ | |
- objectAt: function (idx) { | |
- if (idx < 0 || idx >= property_get.get(this, "length")) { | |
+ objectAt: function(idx) { | |
+ if (idx < 0 || idx >= property_get.get(this, 'length')) { | |
return undefined; | |
} | |
@@ -26899,25 +27935,28 @@ | |
/** | |
This returns the objects at the specified indexes, using `objectAt`. | |
- ```javascript | |
+ | |
+ ```javascript | |
var arr = ['a', 'b', 'c', 'd']; | |
- arr.objectsAt([0, 1, 2]); // ['a', 'b', 'c'] | |
+ | |
+ arr.objectsAt([0, 1, 2]); // ['a', 'b', 'c'] | |
arr.objectsAt([2, 3, 4]); // ['c', 'd', undefined] | |
``` | |
- @method objectsAt | |
+ | |
+ @method objectsAt | |
@param {Array} indexes An array of indexes of items to return. | |
@return {Array} | |
*/ | |
- objectsAt: function (indexes) { | |
+ objectsAt: function(indexes) { | |
var self = this; | |
- return enumerable_utils.map(indexes, function (idx) { | |
+ return enumerable_utils.map(indexes, function(idx) { | |
return self.objectAt(idx); | |
}); | |
}, | |
// overrides Ember.Enumerable version | |
- nextObject: function (idx) { | |
+ nextObject: function(idx) { | |
return this.objectAt(idx); | |
}, | |
@@ -26925,28 +27964,30 @@ | |
This is the handler for the special array content property. If you get | |
this property, it will return this. If you set this property to a new | |
array, it will replace the current content. | |
- This property overrides the default property defined in `Ember.Enumerable`. | |
- @property [] | |
+ | |
+ This property overrides the default property defined in `Ember.Enumerable`. | |
+ | |
+ @property [] | |
@return this | |
*/ | |
- "[]": computed.computed(function (key, value) { | |
+ '[]': computed.computed(function(key, value) { | |
if (value !== undefined) { | |
- this.replace(0, property_get.get(this, "length"), value); | |
+ this.replace(0, property_get.get(this, 'length'), value); | |
} | |
return this; | |
}), | |
- firstObject: computed.computed(function () { | |
+ firstObject: computed.computed(function() { | |
return this.objectAt(0); | |
}), | |
- lastObject: computed.computed(function () { | |
- return this.objectAt(property_get.get(this, "length") - 1); | |
+ lastObject: computed.computed(function() { | |
+ return this.objectAt(property_get.get(this, 'length') - 1); | |
}), | |
// optimized version from Enumerable | |
- contains: function (obj) { | |
+ contains: function(obj) { | |
return this.indexOf(obj) >= 0; | |
}, | |
@@ -26955,26 +27996,29 @@ | |
Returns a new array that is a slice of the receiver. This implementation | |
uses the observable array methods to retrieve the objects for the new | |
slice. | |
- ```javascript | |
+ | |
+ ```javascript | |
var arr = ['red', 'green', 'blue']; | |
- arr.slice(0); // ['red', 'green', 'blue'] | |
+ | |
+ arr.slice(0); // ['red', 'green', 'blue'] | |
arr.slice(0, 2); // ['red', 'green'] | |
arr.slice(1, 100); // ['green', 'blue'] | |
``` | |
- @method slice | |
+ | |
+ @method slice | |
@param {Integer} beginIndex (Optional) index to begin slicing from. | |
@param {Integer} endIndex (Optional) index to end the slice at (but not included). | |
@return {Array} New array with specified slice | |
*/ | |
- slice: function (beginIndex, endIndex) { | |
+ slice: function(beginIndex, endIndex) { | |
var ret = Ember['default'].A(); | |
- var length = property_get.get(this, "length"); | |
+ var length = property_get.get(this, 'length'); | |
if (isNone['default'](beginIndex)) { | |
beginIndex = 0; | |
} | |
- if (isNone['default'](endIndex) || endIndex > length) { | |
+ if (isNone['default'](endIndex) || (endIndex > length)) { | |
endIndex = length; | |
} | |
@@ -26998,22 +28042,25 @@ | |
If no `startAt` argument is given, the starting location to | |
search is 0. If it's negative, will count backward from | |
the end of the array. Returns -1 if no match is found. | |
- ```javascript | |
+ | |
+ ```javascript | |
var arr = ['a', 'b', 'c', 'd', 'a']; | |
- arr.indexOf('a'); // 0 | |
+ | |
+ arr.indexOf('a'); // 0 | |
arr.indexOf('z'); // -1 | |
arr.indexOf('a', 2); // 4 | |
arr.indexOf('a', -1); // 4 | |
arr.indexOf('b', 3); // -1 | |
arr.indexOf('a', 100); // -1 | |
``` | |
- @method indexOf | |
+ | |
+ @method indexOf | |
@param {Object} object the item to search for | |
@param {Number} startAt optional starting location to search, default 0 | |
@return {Number} index or -1 if not found | |
*/ | |
- indexOf: function (object, startAt) { | |
- var len = property_get.get(this, "length"); | |
+ indexOf: function(object, startAt) { | |
+ var len = property_get.get(this, 'length'); | |
var idx; | |
if (startAt === undefined) { | |
@@ -27038,26 +28085,29 @@ | |
If no `startAt` argument is given, the search starts from | |
the last position. If it's negative, will count backward | |
from the end of the array. Returns -1 if no match is found. | |
- ```javascript | |
+ | |
+ ```javascript | |
var arr = ['a', 'b', 'c', 'd', 'a']; | |
- arr.lastIndexOf('a'); // 4 | |
+ | |
+ arr.lastIndexOf('a'); // 4 | |
arr.lastIndexOf('z'); // -1 | |
arr.lastIndexOf('a', 2); // 0 | |
arr.lastIndexOf('a', -1); // 4 | |
arr.lastIndexOf('b', 3); // 1 | |
arr.lastIndexOf('a', 100); // 4 | |
``` | |
- @method lastIndexOf | |
+ | |
+ @method lastIndexOf | |
@param {Object} object the item to search for | |
@param {Number} startAt optional starting location to search, default 0 | |
@return {Number} index or -1 if not found | |
*/ | |
- lastIndexOf: function (object, startAt) { | |
- var len = property_get.get(this, "length"); | |
+ lastIndexOf: function(object, startAt) { | |
+ var len = property_get.get(this, 'length'); | |
var idx; | |
if (startAt === undefined || startAt >= len) { | |
- startAt = len - 1; | |
+ startAt = len-1; | |
} | |
if (startAt < 0) { | |
@@ -27080,25 +28130,29 @@ | |
/** | |
Adds an array observer to the receiving array. The array observer object | |
normally must implement two methods: | |
- * `arrayWillChange(observedObj, start, removeCount, addCount)` - This method will be | |
+ | |
+ * `arrayWillChange(observedObj, start, removeCount, addCount)` - This method will be | |
called just before the array is modified. | |
* `arrayDidChange(observedObj, start, removeCount, addCount)` - This method will be | |
called just after the array is modified. | |
- Both callbacks will be passed the observed object, starting index of the | |
+ | |
+ Both callbacks will be passed the observed object, starting index of the | |
change as well a a count of the items to be removed and added. You can use | |
these callbacks to optionally inspect the array during the change, clear | |
caches, or do any other bookkeeping necessary. | |
- In addition to passing a target, you can also include an options hash | |
+ | |
+ In addition to passing a target, you can also include an options hash | |
which you can use to override the method names that will be invoked on the | |
target. | |
- @method addArrayObserver | |
+ | |
+ @method addArrayObserver | |
@param {Object} target The observer object. | |
@param {Hash} opts Optional hash of configuration options including | |
`willChange` and `didChange` option. | |
@return {Ember.Array} receiver | |
*/ | |
- addArrayObserver: function (target, opts) { | |
+ addArrayObserver: function(target, opts) { | |
return arrayObserversHelper(this, target, opts, events.addListener, false); | |
}, | |
@@ -27106,23 +28160,25 @@ | |
Removes an array observer from the object if the observer is current | |
registered. Calling this method multiple times with the same object will | |
have no effect. | |
- @method removeArrayObserver | |
+ | |
+ @method removeArrayObserver | |
@param {Object} target The object observing the array. | |
@param {Hash} opts Optional hash of configuration options including | |
`willChange` and `didChange` option. | |
@return {Ember.Array} receiver | |
*/ | |
- removeArrayObserver: function (target, opts) { | |
+ removeArrayObserver: function(target, opts) { | |
return arrayObserversHelper(this, target, opts, events.removeListener, true); | |
}, | |
/** | |
Becomes true whenever the array currently has observers watching changes | |
on the array. | |
- @property {Boolean} hasArrayObservers | |
+ | |
+ @property {Boolean} hasArrayObservers | |
*/ | |
- hasArrayObservers: computed.computed(function () { | |
- return events.hasListeners(this, "@array:change") || events.hasListeners(this, "@array:before"); | |
+ hasArrayObservers: computed.computed(function() { | |
+ return events.hasListeners(this, '@array:change') || events.hasListeners(this, '@array:before'); | |
}), | |
/** | |
@@ -27130,7 +28186,8 @@ | |
method just before the array content changes to notify any observers and | |
invalidate any related properties. Pass the starting index of the change | |
as well as a delta of the amounts to change. | |
- @method arrayContentWillChange | |
+ | |
+ @method arrayContentWillChange | |
@param {Number} startIdx The starting index in the array that will change. | |
@param {Number} removeAmt The number of items that will be removed. If you | |
pass `null` assumes 0 | |
@@ -27138,7 +28195,7 @@ | |
pass `null` assumes 0. | |
@return {Ember.Array} receiver | |
*/ | |
- arrayContentWillChange: function (startIdx, removeAmt, addAmt) { | |
+ arrayContentWillChange: function(startIdx, removeAmt, addAmt) { | |
var removing, lim; | |
// if no args are passed assume everything changes | |
@@ -27156,13 +28213,13 @@ | |
} | |
// Make sure the @each proxy is set up if anyone is observing @each | |
- if (watching.isWatching(this, "@each")) { | |
- property_get.get(this, "@each"); | |
+ if (watching.isWatching(this, '@each')) { | |
+ property_get.get(this, '@each'); | |
} | |
- events.sendEvent(this, "@array:before", [this, startIdx, removeAmt, addAmt]); | |
+ events.sendEvent(this, '@array:before', [this, startIdx, removeAmt, addAmt]); | |
- if (startIdx >= 0 && removeAmt >= 0 && property_get.get(this, "hasEnumerableObservers")) { | |
+ if (startIdx >= 0 && removeAmt >= 0 && property_get.get(this, 'hasEnumerableObservers')) { | |
removing = []; | |
lim = startIdx + removeAmt; | |
@@ -27183,7 +28240,8 @@ | |
method just after the array content changes to notify any observers and | |
invalidate any related properties. Pass the starting index of the change | |
as well as a delta of the amounts to change. | |
- @method arrayContentDidChange | |
+ | |
+ @method arrayContentDidChange | |
@param {Number} startIdx The starting index in the array that did change. | |
@param {Number} removeAmt The number of items that were removed. If you | |
pass `null` assumes 0 | |
@@ -27191,7 +28249,7 @@ | |
pass `null` assumes 0. | |
@return {Ember.Array} receiver | |
*/ | |
- arrayContentDidChange: function (startIdx, removeAmt, addAmt) { | |
+ arrayContentDidChange: function(startIdx, removeAmt, addAmt) { | |
var adding, lim; | |
// if no args are passed assume everything changes | |
@@ -27208,7 +28266,7 @@ | |
} | |
} | |
- if (startIdx >= 0 && addAmt >= 0 && property_get.get(this, "hasEnumerableObservers")) { | |
+ if (startIdx >= 0 && addAmt >= 0 && property_get.get(this, 'hasEnumerableObservers')) { | |
adding = []; | |
lim = startIdx + addAmt; | |
@@ -27220,20 +28278,20 @@ | |
} | |
this.enumerableContentDidChange(removeAmt, adding); | |
- events.sendEvent(this, "@array:change", [this, startIdx, removeAmt, addAmt]); | |
+ events.sendEvent(this, '@array:change', [this, startIdx, removeAmt, addAmt]); | |
- var length = property_get.get(this, "length"); | |
- var cachedFirst = computed.cacheFor(this, "firstObject"); | |
- var cachedLast = computed.cacheFor(this, "lastObject"); | |
+ var length = property_get.get(this, 'length'); | |
+ var cachedFirst = computed.cacheFor(this, 'firstObject'); | |
+ var cachedLast = computed.cacheFor(this, 'lastObject'); | |
if (this.objectAt(0) !== cachedFirst) { | |
- property_events.propertyWillChange(this, "firstObject"); | |
- property_events.propertyDidChange(this, "firstObject"); | |
+ property_events.propertyWillChange(this, 'firstObject'); | |
+ property_events.propertyDidChange(this, 'firstObject'); | |
} | |
- if (this.objectAt(length - 1) !== cachedLast) { | |
- property_events.propertyWillChange(this, "lastObject"); | |
- property_events.propertyDidChange(this, "lastObject"); | |
+ if (this.objectAt(length-1) !== cachedLast) { | |
+ property_events.propertyWillChange(this, 'lastObject'); | |
+ property_events.propertyDidChange(this, 'lastObject'); | |
} | |
return this; | |
@@ -27248,14 +28306,16 @@ | |
on the array. Just get an equivalent property on this object and it will | |
return an enumerable that maps automatically to the named key on the | |
member objects. | |
- If you merely want to watch for any items being added or removed to the array, | |
+ | |
+ If you merely want to watch for any items being added or removed to the array, | |
use the `[]` property instead of `@each`. | |
- @property @each | |
+ | |
+ @property @each | |
*/ | |
- "@each": computed.computed(function () { | |
+ '@each': computed.computed(function() { | |
if (!this.__each) { | |
// ES6TODO: GRRRRR | |
- var EachProxy = requireModule("ember-runtime/system/each_proxy")["EachProxy"]; | |
+ var EachProxy = requireModule('ember-runtime/system/each_proxy')['EachProxy']; | |
this.__each = new EachProxy(this); | |
} | |
@@ -27274,11 +28334,14 @@ | |
/** | |
Override to return the result of the comparison of the two parameters. The | |
compare method should return: | |
- - `-1` if `a < b` | |
+ | |
+ - `-1` if `a < b` | |
- `0` if `a == b` | |
- `1` if `a > b` | |
- Default implementation raises an exception. | |
- @method compare | |
+ | |
+ Default implementation raises an exception. | |
+ | |
+ @method compare | |
@param a {Object} the first object to compare | |
@param b {Object} the second object to compare | |
@return {Integer} the result of the comparison | |
@@ -27297,9 +28360,11 @@ | |
/** | |
The object to which actions from the view should be sent. | |
- For example, when a Handlebars template uses the `{{action}}` helper, | |
+ | |
+ For example, when a Handlebars template uses the `{{action}}` helper, | |
it will attempt to send the action to the view's controller's `target`. | |
- By default, the value of the target property is set to the router, and | |
+ | |
+ By default, the value of the target property is set to the router, and | |
is injected when a controller is instantiated. This injection is defined | |
in Ember.Application#buildContainer, and is applied as part of the | |
applications initialization process. It can also be set after a controller | |
@@ -27307,7 +28372,8 @@ | |
template, or when a controller is used as an `itemController`. In most | |
cases the `target` property will automatically be set to the logical | |
consumer of actions for the controller. | |
- @property target | |
+ | |
+ @property target | |
@default null | |
*/ | |
target: null, | |
@@ -27321,7 +28387,8 @@ | |
/** | |
The controller's current model. When retrieving or modifying a controller's | |
model, this property should be used instead of the `content` property. | |
- @property model | |
+ | |
+ @property model | |
@public | |
*/ | |
model: null, | |
@@ -27329,7 +28396,7 @@ | |
/** | |
@private | |
*/ | |
- content: alias['default']("model") | |
+ content: alias['default']('model') | |
}); | |
@@ -27341,14 +28408,17 @@ | |
exports['default'] = mixin.Mixin.create({ | |
/** | |
@private | |
- Moves `content` to `model` at extend time if a `model` is not also specified. | |
- Note that this currently modifies the mixin themselves, which is technically | |
+ | |
+ Moves `content` to `model` at extend time if a `model` is not also specified. | |
+ | |
+ Note that this currently modifies the mixin themselves, which is technically | |
dubious but is practically of little consequence. This may change in the | |
future. | |
- @method willMergeMixin | |
+ | |
+ @method willMergeMixin | |
@since 1.4.0 | |
*/ | |
- willMergeMixin: function (props) { | |
+ willMergeMixin: function(props) { | |
// Calling super is only OK here since we KNOW that | |
// there is another Mixin loaded first. | |
this._super.apply(this, arguments); | |
@@ -27357,9 +28427,9 @@ | |
if (props.content && !modelSpecified) { | |
props.model = props.content; | |
- delete props["content"]; | |
+ delete props['content']; | |
- Ember['default'].deprecate("Do not specify `content` on a Controller, use `model` instead."); | |
+ Ember['default'].deprecate('Do not specify `content` on a Controller, use `model` instead.'); | |
} | |
} | |
}); | |
@@ -27374,11 +28444,13 @@ | |
@submodule ember-runtime | |
*/ | |
+ | |
exports['default'] = mixin.Mixin.create({ | |
/** | |
Override to return a copy of the receiver. Default implementation raises | |
an exception. | |
- @method copy | |
+ | |
+ @method copy | |
@param {Boolean} deep if `true`, a deep copy of the object should be made | |
@return {Object} copy of receiver | |
*/ | |
@@ -27387,17 +28459,20 @@ | |
/** | |
If the object implements `Ember.Freezable`, then this will return a new | |
copy if the object is not frozen and the receiver if the object is frozen. | |
- Raises an exception if you try to call this method on a object that does | |
+ | |
+ Raises an exception if you try to call this method on a object that does | |
not support freezing. | |
- You should use this method whenever you want a copy of a freezable object | |
+ | |
+ You should use this method whenever you want a copy of a freezable object | |
since a freezable object can simply return itself without actually | |
consuming more memory. | |
- @method frozenCopy | |
+ | |
+ @method frozenCopy | |
@return {Object} copy of receiver or receiver | |
*/ | |
- frozenCopy: function () { | |
+ frozenCopy: function() { | |
if (freezable.Freezable && freezable.Freezable.detect(this)) { | |
- return property_get.get(this, "isFrozen") ? this : this.copy().freeze(); | |
+ return property_get.get(this, 'isFrozen') ? this : this.copy().freeze(); | |
} else { | |
throw new EmberError['default'](string.fmt("%@ does not support freezing", [this])); | |
} | |
@@ -27412,15 +28487,16 @@ | |
exports['default'] = mixin.Mixin.create({ | |
/** | |
Add handlers to be called when the Deferred object is resolved or rejected. | |
- @method then | |
+ | |
+ @method then | |
@param {Function} resolve a callback function to be called when done | |
@param {Function} reject a callback function to be called when failed | |
*/ | |
- then: function (resolve, reject, label) { | |
+ then: function(resolve, reject, label) { | |
var deferred, promise, entity; | |
entity = this; | |
- deferred = property_get.get(this, "_deferred"); | |
+ deferred = property_get.get(this, '_deferred'); | |
promise = deferred.promise; | |
function fulfillmentHandler(fulfillment) { | |
@@ -27436,12 +28512,13 @@ | |
/** | |
Resolve a Deferred object and call any `doneCallbacks` with the given args. | |
- @method resolve | |
+ | |
+ @method resolve | |
*/ | |
- resolve: function (value) { | |
+ resolve: function(value) { | |
var deferred, promise; | |
- deferred = property_get.get(this, "_deferred"); | |
+ deferred = property_get.get(this, '_deferred'); | |
promise = deferred.promise; | |
if (value === this) { | |
@@ -27453,16 +28530,21 @@ | |
/** | |
Reject a Deferred object and call any `failCallbacks` with the given args. | |
- @method reject | |
+ | |
+ @method reject | |
*/ | |
- reject: function (value) { | |
- property_get.get(this, "_deferred").reject(value); | |
+ reject: function(value) { | |
+ property_get.get(this, '_deferred').reject(value); | |
}, | |
- _deferred: computed.computed(function () { | |
- Ember['default'].deprecate("Usage of Ember.DeferredMixin or Ember.Deferred is deprecated.", this._suppressDeferredDeprecation, { url: "http://emberjs.com/guides/deprecations/#toc_ember-deferredmixin-and-ember-deferred" }); | |
+ _deferred: computed.computed(function() { | |
+ Ember['default'].deprecate( | |
+ 'Usage of Ember.DeferredMixin or Ember.Deferred is deprecated.', | |
+ this._suppressDeferredDeprecation, | |
+ { url: 'http://emberjs.com/guides/deprecations/#toc_ember-deferredmixin-and-ember-deferred' } | |
+ ); | |
- return RSVP['default'].defer("Ember: DeferredMixin - " + this); | |
+ return RSVP['default'].defer('Ember: DeferredMixin - ' + this); | |
}) | |
}); | |
@@ -27545,25 +28627,31 @@ | |
/** | |
Implement this method to make your class enumerable. | |
- This method will be called repeatedly during enumeration. The index value | |
+ | |
+ This method will be called repeatedly during enumeration. The index value | |
will always begin with 0 and increment monotonically. You don't have to | |
rely on the index value to determine what object to return, but you should | |
always check the value and start from the beginning when you see the | |
requested index is 0. | |
- The `previousObject` is the object that was returned from the last call | |
+ | |
+ The `previousObject` is the object that was returned from the last call | |
to `nextObject` for the current iteration. This is a useful way to | |
manage iteration if you are tracing a linked list, for example. | |
- Finally the context parameter will always contain a hash you can use as | |
+ | |
+ Finally the context parameter will always contain a hash you can use as | |
a "scratchpad" to maintain any other state you need in order to iterate | |
properly. The context object is reused and is not reset between | |
iterations so make sure you setup the context with a fresh state whenever | |
the index parameter is 0. | |
- Generally iterators will continue to call `nextObject` until the index | |
+ | |
+ Generally iterators will continue to call `nextObject` until the index | |
reaches the your current length-1. If you run out of data before this | |
time for some reason, you should simply return undefined. | |
- The default implementation of this method simply looks up the index. | |
+ | |
+ The default implementation of this method simply looks up the index. | |
This works great on any Array-like objects. | |
- @method nextObject | |
+ | |
+ @method nextObject | |
@param {Number} index the current index of the iteration | |
@param {Object} previousObject the value returned by the last call to | |
`nextObject`. | |
@@ -27576,21 +28664,25 @@ | |
Helper method returns the first object from a collection. This is usually | |
used by bindings and other parts of the framework to extract a single | |
object if the enumerable contains only one item. | |
- If you override this method, you should implement it so that it will | |
+ | |
+ If you override this method, you should implement it so that it will | |
always return the same value each time it is called. If your enumerable | |
contains only one object, this method should always return that object. | |
If your enumerable is empty, this method should return `undefined`. | |
- ```javascript | |
+ | |
+ ```javascript | |
var arr = ['a', 'b', 'c']; | |
arr.get('firstObject'); // 'a' | |
- var arr = []; | |
+ | |
+ var arr = []; | |
arr.get('firstObject'); // undefined | |
``` | |
- @property firstObject | |
+ | |
+ @property firstObject | |
@return {Object} the object or undefined | |
*/ | |
- firstObject: computed.computed("[]", function () { | |
- if (property_get.get(this, "length") === 0) { | |
+ firstObject: computed.computed('[]', function() { | |
+ if (property_get.get(this, 'length') === 0) { | |
return undefined; | |
} | |
@@ -27607,17 +28699,20 @@ | |
Helper method returns the last object from a collection. If your enumerable | |
contains only one object, this method should always return that object. | |
If your enumerable is empty, this method should return `undefined`. | |
- ```javascript | |
+ | |
+ ```javascript | |
var arr = ['a', 'b', 'c']; | |
arr.get('lastObject'); // 'c' | |
- var arr = []; | |
+ | |
+ var arr = []; | |
arr.get('lastObject'); // undefined | |
``` | |
- @property lastObject | |
+ | |
+ @property lastObject | |
@return {Object} the last object or undefined | |
*/ | |
- lastObject: computed.computed("[]", function () { | |
- var len = property_get.get(this, "length"); | |
+ lastObject: computed.computed('[]', function() { | |
+ var len = property_get.get(this, 'length'); | |
if (len === 0) { | |
return undefined; | |
@@ -27642,17 +28737,20 @@ | |
Returns `true` if the passed object can be found in the receiver. The | |
default version will iterate through the enumerable until the object | |
is found. You may want to override this with a more efficient version. | |
- ```javascript | |
+ | |
+ ```javascript | |
var arr = ['a', 'b', 'c']; | |
- arr.contains('a'); // true | |
+ | |
+ arr.contains('a'); // true | |
arr.contains('z'); // false | |
``` | |
- @method contains | |
+ | |
+ @method contains | |
@param {Object} obj The object to search for. | |
@return {Boolean} `true` if object is found in enumerable. | |
*/ | |
- contains: function (obj) { | |
- var found = this.find(function (item) { | |
+ contains: function(obj) { | |
+ var found = this.find(function(item) { | |
return item === obj; | |
}); | |
@@ -27663,29 +28761,34 @@ | |
Iterates through the enumerable, calling the passed function on each | |
item. This method corresponds to the `forEach()` method defined in | |
JavaScript 1.6. | |
- The callback method you provide should have the following signature (all | |
+ | |
+ The callback method you provide should have the following signature (all | |
parameters are optional): | |
- ```javascript | |
+ | |
+ ```javascript | |
function(item, index, enumerable); | |
``` | |
- - `item` is the current item in the iteration. | |
+ | |
+ - `item` is the current item in the iteration. | |
- `index` is the current index in the iteration. | |
- `enumerable` is the enumerable object itself. | |
- Note that in addition to a callback, you can also pass an optional target | |
+ | |
+ Note that in addition to a callback, you can also pass an optional target | |
object that will be set as `this` on the context. This is a good way | |
to give your iterator function access to the current object. | |
- @method forEach | |
+ | |
+ @method forEach | |
@param {Function} callback The callback to execute | |
@param {Object} [target] The target object to use | |
@return {Object} receiver | |
*/ | |
- forEach: function (callback, target) { | |
- if (typeof callback !== "function") { | |
+ forEach: function(callback, target) { | |
+ if (typeof callback !== 'function') { | |
throw new TypeError(); | |
} | |
var context = popCtx(); | |
- var len = property_get.get(this, "length"); | |
+ var len = property_get.get(this, 'length'); | |
var last = null; | |
if (target === undefined) { | |
@@ -27706,24 +28809,26 @@ | |
/** | |
Alias for `mapBy` | |
- @method getEach | |
+ | |
+ @method getEach | |
@param {String} key name of the property | |
@return {Array} The mapped array. | |
*/ | |
- getEach: mixin.aliasMethod("mapBy"), | |
+ getEach: mixin.aliasMethod('mapBy'), | |
/** | |
Sets the value on the named property for each member. This is more | |
efficient than using other methods defined on this helper. If the object | |
implements Ember.Observable, the value will be changed to `set(),` otherwise | |
it will be set directly. `null` objects are skipped. | |
- @method setEach | |
+ | |
+ @method setEach | |
@param {String} key The key to set | |
@param {Object} value The object to set | |
@return {Object} receiver | |
*/ | |
- setEach: function (key, value) { | |
- return this.forEach(function (item) { | |
+ setEach: function(key, value) { | |
+ return this.forEach(function(item) { | |
property_set.set(item, key, value); | |
}); | |
}, | |
@@ -27731,27 +28836,33 @@ | |
/** | |
Maps all of the items in the enumeration to another value, returning | |
a new array. This method corresponds to `map()` defined in JavaScript 1.6. | |
- The callback method you provide should have the following signature (all | |
+ | |
+ The callback method you provide should have the following signature (all | |
parameters are optional): | |
- ```javascript | |
+ | |
+ ```javascript | |
function(item, index, enumerable); | |
``` | |
- - `item` is the current item in the iteration. | |
+ | |
+ - `item` is the current item in the iteration. | |
- `index` is the current index in the iteration. | |
- `enumerable` is the enumerable object itself. | |
- It should return the mapped value. | |
- Note that in addition to a callback, you can also pass an optional target | |
+ | |
+ It should return the mapped value. | |
+ | |
+ Note that in addition to a callback, you can also pass an optional target | |
object that will be set as `this` on the context. This is a good way | |
to give your iterator function access to the current object. | |
- @method map | |
+ | |
+ @method map | |
@param {Function} callback The callback to execute | |
@param {Object} [target] The target object to use | |
@return {Array} The mapped array. | |
*/ | |
- map: function (callback, target) { | |
+ map: function(callback, target) { | |
var ret = Ember['default'].A(); | |
- this.forEach(function (x, idx, i) { | |
+ this.forEach(function(x, idx, i) { | |
ret[idx] = callback.call(target, x, idx, i); | |
}); | |
@@ -27761,12 +28872,13 @@ | |
/** | |
Similar to map, this specialized function returns the value of the named | |
property on all items in the enumeration. | |
- @method mapBy | |
+ | |
+ @method mapBy | |
@param {String} key name of the property | |
@return {Array} The mapped array. | |
*/ | |
- mapBy: function (key) { | |
- return this.map(function (next) { | |
+ mapBy: function(key) { | |
+ return this.map(function(next) { | |
return property_get.get(next, key); | |
}); | |
}, | |
@@ -27774,40 +28886,47 @@ | |
/** | |
Similar to map, this specialized function returns the value of the named | |
property on all items in the enumeration. | |
- @method mapProperty | |
+ | |
+ @method mapProperty | |
@param {String} key name of the property | |
@return {Array} The mapped array. | |
@deprecated Use `mapBy` instead | |
*/ | |
- mapProperty: mixin.aliasMethod("mapBy"), | |
+ mapProperty: mixin.aliasMethod('mapBy'), | |
/** | |
Returns an array with all of the items in the enumeration that the passed | |
function returns true for. This method corresponds to `filter()` defined in | |
JavaScript 1.6. | |
- The callback method you provide should have the following signature (all | |
+ | |
+ The callback method you provide should have the following signature (all | |
parameters are optional): | |
- ```javascript | |
+ | |
+ ```javascript | |
function(item, index, enumerable); | |
``` | |
- - `item` is the current item in the iteration. | |
+ | |
+ - `item` is the current item in the iteration. | |
- `index` is the current index in the iteration. | |
- `enumerable` is the enumerable object itself. | |
- It should return `true` to include the item in the results, `false` | |
+ | |
+ It should return `true` to include the item in the results, `false` | |
otherwise. | |
- Note that in addition to a callback, you can also pass an optional target | |
+ | |
+ Note that in addition to a callback, you can also pass an optional target | |
object that will be set as `this` on the context. This is a good way | |
to give your iterator function access to the current object. | |
- @method filter | |
+ | |
+ @method filter | |
@param {Function} callback The callback to execute | |
@param {Object} [target] The target object to use | |
@return {Array} A filtered array. | |
*/ | |
- filter: function (callback, target) { | |
+ filter: function(callback, target) { | |
var ret = Ember['default'].A(); | |
- this.forEach(function (x, idx, i) { | |
+ this.forEach(function(x, idx, i) { | |
if (callback.call(target, x, idx, i)) { | |
ret.push(x); | |
} | |
@@ -27819,26 +28938,32 @@ | |
/** | |
Returns an array with all of the items in the enumeration where the passed | |
function returns true. This method is the inverse of filter(). | |
- The callback method you provide should have the following signature (all | |
+ | |
+ The callback method you provide should have the following signature (all | |
parameters are optional): | |
- ```javascript | |
+ | |
+ ```javascript | |
function(item, index, enumerable); | |
``` | |
- - *item* is the current item in the iteration. | |
+ | |
+ - *item* is the current item in the iteration. | |
- *index* is the current index in the iteration | |
- *enumerable* is the enumerable object itself. | |
- It should return the a falsey value to include the item in the results. | |
- Note that in addition to a callback, you can also pass an optional target | |
+ | |
+ It should return the a falsey value to include the item in the results. | |
+ | |
+ Note that in addition to a callback, you can also pass an optional target | |
object that will be set as "this" on the context. This is a good way | |
to give your iterator function access to the current object. | |
- @method reject | |
+ | |
+ @method reject | |
@param {Function} callback The callback to execute | |
@param {Object} [target] The target object to use | |
@return {Array} A rejected array. | |
*/ | |
- reject: function (callback, target) { | |
- return this.filter(function () { | |
- return !utils.apply(target, callback, arguments); | |
+ reject: function(callback, target) { | |
+ return this.filter(function() { | |
+ return !(utils.apply(target, callback, arguments)); | |
}); | |
}, | |
@@ -27846,12 +28971,13 @@ | |
Returns an array with just the items with the matched property. You | |
can pass an optional second argument with the target value. Otherwise | |
this will match any property that evaluates to `true`. | |
- @method filterBy | |
+ | |
+ @method filterBy | |
@param {String} key the property to test | |
@param {*} [value] optional value to test against. | |
@return {Array} filtered array | |
*/ | |
- filterBy: function (key, value) { | |
+ filterBy: function(key, value) { | |
return this.filter(utils.apply(this, iter, arguments)); | |
}, | |
@@ -27859,33 +28985,35 @@ | |
Returns an array with just the items with the matched property. You | |
can pass an optional second argument with the target value. Otherwise | |
this will match any property that evaluates to `true`. | |
- @method filterProperty | |
+ | |
+ @method filterProperty | |
@param {String} key the property to test | |
@param {String} [value] optional value to test against. | |
@return {Array} filtered array | |
@deprecated Use `filterBy` instead | |
*/ | |
- filterProperty: mixin.aliasMethod("filterBy"), | |
+ filterProperty: mixin.aliasMethod('filterBy'), | |
/** | |
Returns an array with the items that do not have truthy values for | |
key. You can pass an optional second argument with the target value. Otherwise | |
this will match any property that evaluates to false. | |
- @method rejectBy | |
+ | |
+ @method rejectBy | |
@param {String} key the property to test | |
@param {String} [value] optional value to test against. | |
@return {Array} rejected array | |
*/ | |
- rejectBy: function (key, value) { | |
- var exactValue = function (item) { | |
+ rejectBy: function(key, value) { | |
+ var exactValue = function(item) { | |
return property_get.get(item, key) === value; | |
}; | |
- var hasValue = function (item) { | |
+ var hasValue = function(item) { | |
return !!property_get.get(item, key); | |
}; | |
- var use = arguments.length === 2 ? exactValue : hasValue; | |
+ var use = (arguments.length === 2 ? exactValue : hasValue); | |
return this.reject(use); | |
}, | |
@@ -27894,38 +29022,45 @@ | |
Returns an array with the items that do not have truthy values for | |
key. You can pass an optional second argument with the target value. Otherwise | |
this will match any property that evaluates to false. | |
- @method rejectProperty | |
+ | |
+ @method rejectProperty | |
@param {String} key the property to test | |
@param {String} [value] optional value to test against. | |
@return {Array} rejected array | |
@deprecated Use `rejectBy` instead | |
*/ | |
- rejectProperty: mixin.aliasMethod("rejectBy"), | |
+ rejectProperty: mixin.aliasMethod('rejectBy'), | |
/** | |
Returns the first item in the array for which the callback returns true. | |
This method works similar to the `filter()` method defined in JavaScript 1.6 | |
except that it will stop working on the array once a match is found. | |
- The callback method you provide should have the following signature (all | |
+ | |
+ The callback method you provide should have the following signature (all | |
parameters are optional): | |
- ```javascript | |
+ | |
+ ```javascript | |
function(item, index, enumerable); | |
``` | |
- - `item` is the current item in the iteration. | |
+ | |
+ - `item` is the current item in the iteration. | |
- `index` is the current index in the iteration. | |
- `enumerable` is the enumerable object itself. | |
- It should return the `true` to include the item in the results, `false` | |
+ | |
+ It should return the `true` to include the item in the results, `false` | |
otherwise. | |
- Note that in addition to a callback, you can also pass an optional target | |
+ | |
+ Note that in addition to a callback, you can also pass an optional target | |
object that will be set as `this` on the context. This is a good way | |
to give your iterator function access to the current object. | |
- @method find | |
+ | |
+ @method find | |
@param {Function} callback The callback to execute | |
@param {Object} [target] The target object to use | |
@return {Object} Found item or `undefined`. | |
*/ | |
- find: function (callback, target) { | |
- var len = property_get.get(this, "length"); | |
+ find: function(callback, target) { | |
+ var len = property_get.get(this, 'length'); | |
if (target === undefined) { | |
target = null; | |
@@ -27956,13 +29091,15 @@ | |
Returns the first item with a property matching the passed value. You | |
can pass an optional second argument with the target value. Otherwise | |
this will match any property that evaluates to `true`. | |
- This method works much like the more generic `find()` method. | |
- @method findBy | |
+ | |
+ This method works much like the more generic `find()` method. | |
+ | |
+ @method findBy | |
@param {String} key the property to test | |
@param {String} [value] optional value to test against. | |
@return {Object} found item or `undefined` | |
*/ | |
- findBy: function (key, value) { | |
+ findBy: function(key, value) { | |
return this.find(utils.apply(this, iter, arguments)); | |
}, | |
@@ -27970,43 +29107,53 @@ | |
Returns the first item with a property matching the passed value. You | |
can pass an optional second argument with the target value. Otherwise | |
this will match any property that evaluates to `true`. | |
- This method works much like the more generic `find()` method. | |
- @method findProperty | |
+ | |
+ This method works much like the more generic `find()` method. | |
+ | |
+ @method findProperty | |
@param {String} key the property to test | |
@param {String} [value] optional value to test against. | |
@return {Object} found item or `undefined` | |
@deprecated Use `findBy` instead | |
*/ | |
- findProperty: mixin.aliasMethod("findBy"), | |
+ findProperty: mixin.aliasMethod('findBy'), | |
/** | |
Returns `true` if the passed function returns true for every item in the | |
enumeration. This corresponds with the `every()` method in JavaScript 1.6. | |
- The callback method you provide should have the following signature (all | |
+ | |
+ The callback method you provide should have the following signature (all | |
parameters are optional): | |
- ```javascript | |
+ | |
+ ```javascript | |
function(item, index, enumerable); | |
``` | |
- - `item` is the current item in the iteration. | |
+ | |
+ - `item` is the current item in the iteration. | |
- `index` is the current index in the iteration. | |
- `enumerable` is the enumerable object itself. | |
- It should return the `true` or `false`. | |
- Note that in addition to a callback, you can also pass an optional target | |
+ | |
+ It should return the `true` or `false`. | |
+ | |
+ Note that in addition to a callback, you can also pass an optional target | |
object that will be set as `this` on the context. This is a good way | |
to give your iterator function access to the current object. | |
- Example Usage: | |
- ```javascript | |
+ | |
+ Example Usage: | |
+ | |
+ ```javascript | |
if (people.every(isEngineer)) { | |
Paychecks.addBigBonus(); | |
} | |
``` | |
- @method every | |
+ | |
+ @method every | |
@param {Function} callback The callback to execute | |
@param {Object} [target] The target object to use | |
@return {Boolean} | |
*/ | |
- every: function (callback, target) { | |
- return !this.find(function (x, idx, i) { | |
+ every: function(callback, target) { | |
+ return !this.find(function(x, idx, i) { | |
return !callback.call(target, x, idx, i); | |
}); | |
}, | |
@@ -28018,7 +29165,7 @@ | |
@deprecated Use `isEvery` instead | |
@return {Boolean} | |
*/ | |
- everyBy: mixin.aliasMethod("isEvery"), | |
+ everyBy: mixin.aliasMethod('isEvery'), | |
/** | |
@method everyProperty | |
@@ -28027,50 +29174,59 @@ | |
@deprecated Use `isEvery` instead | |
@return {Boolean} | |
*/ | |
- everyProperty: mixin.aliasMethod("isEvery"), | |
+ everyProperty: mixin.aliasMethod('isEvery'), | |
/** | |
Returns `true` if the passed property resolves to `true` for all items in | |
the enumerable. This method is often simpler/faster than using a callback. | |
- @method isEvery | |
+ | |
+ @method isEvery | |
@param {String} key the property to test | |
@param {String} [value] optional value to test against. | |
@return {Boolean} | |
@since 1.3.0 | |
*/ | |
- isEvery: function (key, value) { | |
+ isEvery: function(key, value) { | |
return this.every(utils.apply(this, iter, arguments)); | |
}, | |
/** | |
Returns `true` if the passed function returns true for any item in the | |
enumeration. This corresponds with the `some()` method in JavaScript 1.6. | |
- The callback method you provide should have the following signature (all | |
+ | |
+ The callback method you provide should have the following signature (all | |
parameters are optional): | |
- ```javascript | |
+ | |
+ ```javascript | |
function(item, index, enumerable); | |
``` | |
- - `item` is the current item in the iteration. | |
+ | |
+ - `item` is the current item in the iteration. | |
- `index` is the current index in the iteration. | |
- `enumerable` is the enumerable object itself. | |
- It should return the `true` to include the item in the results, `false` | |
+ | |
+ It should return the `true` to include the item in the results, `false` | |
otherwise. | |
- Note that in addition to a callback, you can also pass an optional target | |
+ | |
+ Note that in addition to a callback, you can also pass an optional target | |
object that will be set as `this` on the context. This is a good way | |
to give your iterator function access to the current object. | |
- Usage Example: | |
- ```javascript | |
+ | |
+ Usage Example: | |
+ | |
+ ```javascript | |
if (people.any(isManager)) { | |
Paychecks.addBiggerBonus(); | |
} | |
``` | |
- @method any | |
+ | |
+ @method any | |
@param {Function} callback The callback to execute | |
@param {Object} [target] The target object to use | |
@return {Boolean} `true` if the passed function returns `true` for any item | |
*/ | |
- any: function (callback, target) { | |
- var len = property_get.get(this, "length"); | |
+ any: function(callback, target) { | |
+ var len = property_get.get(this, 'length'); | |
var context = popCtx(); | |
var found = false; | |
var last = null; | |
@@ -28081,9 +29237,9 @@ | |
} | |
for (idx = 0; idx < len && !found; idx++) { | |
- next = this.nextObject(idx, last, context); | |
+ next = this.nextObject(idx, last, context); | |
found = callback.call(target, next, idx, this); | |
- last = next; | |
+ last = next; | |
} | |
next = last = null; | |
@@ -28094,43 +29250,52 @@ | |
/** | |
Returns `true` if the passed function returns true for any item in the | |
enumeration. This corresponds with the `some()` method in JavaScript 1.6. | |
- The callback method you provide should have the following signature (all | |
+ | |
+ The callback method you provide should have the following signature (all | |
parameters are optional): | |
- ```javascript | |
+ | |
+ ```javascript | |
function(item, index, enumerable); | |
``` | |
- - `item` is the current item in the iteration. | |
+ | |
+ - `item` is the current item in the iteration. | |
- `index` is the current index in the iteration. | |
- `enumerable` is the enumerable object itself. | |
- It should return the `true` to include the item in the results, `false` | |
+ | |
+ It should return the `true` to include the item in the results, `false` | |
otherwise. | |
- Note that in addition to a callback, you can also pass an optional target | |
+ | |
+ Note that in addition to a callback, you can also pass an optional target | |
object that will be set as `this` on the context. This is a good way | |
to give your iterator function access to the current object. | |
- Usage Example: | |
- ```javascript | |
+ | |
+ Usage Example: | |
+ | |
+ ```javascript | |
if (people.some(isManager)) { | |
Paychecks.addBiggerBonus(); | |
} | |
``` | |
- @method some | |
+ | |
+ @method some | |
@param {Function} callback The callback to execute | |
@param {Object} [target] The target object to use | |
@return {Boolean} `true` if the passed function returns `true` for any item | |
@deprecated Use `any` instead | |
*/ | |
- some: mixin.aliasMethod("any"), | |
+ some: mixin.aliasMethod('any'), | |
/** | |
Returns `true` if the passed property resolves to `true` for any item in | |
the enumerable. This method is often simpler/faster than using a callback. | |
- @method isAny | |
+ | |
+ @method isAny | |
@param {String} key the property to test | |
@param {String} [value] optional value to test against. | |
@return {Boolean} | |
@since 1.3.0 | |
*/ | |
- isAny: function (key, value) { | |
+ isAny: function(key, value) { | |
return this.any(utils.apply(this, iter, arguments)); | |
}, | |
@@ -28141,7 +29306,7 @@ | |
@return {Boolean} | |
@deprecated Use `isAny` instead | |
*/ | |
- anyBy: mixin.aliasMethod("isAny"), | |
+ anyBy: mixin.aliasMethod('isAny'), | |
/** | |
@method someProperty | |
@@ -28150,42 +29315,49 @@ | |
@return {Boolean} | |
@deprecated Use `isAny` instead | |
*/ | |
- someProperty: mixin.aliasMethod("isAny"), | |
+ someProperty: mixin.aliasMethod('isAny'), | |
/** | |
This will combine the values of the enumerator into a single value. It | |
is a useful way to collect a summary value from an enumeration. This | |
corresponds to the `reduce()` method defined in JavaScript 1.8. | |
- The callback method you provide should have the following signature (all | |
+ | |
+ The callback method you provide should have the following signature (all | |
parameters are optional): | |
- ```javascript | |
+ | |
+ ```javascript | |
function(previousValue, item, index, enumerable); | |
``` | |
- - `previousValue` is the value returned by the last call to the iterator. | |
+ | |
+ - `previousValue` is the value returned by the last call to the iterator. | |
- `item` is the current item in the iteration. | |
- `index` is the current index in the iteration. | |
- `enumerable` is the enumerable object itself. | |
- Return the new cumulative value. | |
- In addition to the callback you can also pass an `initialValue`. An error | |
+ | |
+ Return the new cumulative value. | |
+ | |
+ In addition to the callback you can also pass an `initialValue`. An error | |
will be raised if you do not pass an initial value and the enumerator is | |
empty. | |
- Note that unlike the other methods, this method does not allow you to | |
+ | |
+ Note that unlike the other methods, this method does not allow you to | |
pass a target object to set as this for the callback. It's part of the | |
spec. Sorry. | |
- @method reduce | |
+ | |
+ @method reduce | |
@param {Function} callback The callback to execute | |
@param {Object} initialValue Initial value for the reduce | |
@param {String} reducerProperty internal use only. | |
@return {Object} The reduced value. | |
*/ | |
- reduce: function (callback, initialValue, reducerProperty) { | |
- if (typeof callback !== "function") { | |
+ reduce: function(callback, initialValue, reducerProperty) { | |
+ if (typeof callback !== 'function') { | |
throw new TypeError(); | |
} | |
var ret = initialValue; | |
- this.forEach(function (item, i) { | |
+ this.forEach(function(item, i) { | |
ret = callback(ret, item, i, this, reducerProperty); | |
}, this); | |
@@ -28196,12 +29368,13 @@ | |
Invokes the named method on every object in the receiver that | |
implements it. This method corresponds to the implementation in | |
Prototype 1.6. | |
- @method invoke | |
+ | |
+ @method invoke | |
@param {String} methodName the name of the method | |
@param {Object...} args optional arguments to pass as well. | |
@return {Array} return values from calling invoke. | |
*/ | |
- invoke: function (methodName) { | |
+ invoke: function(methodName) { | |
var ret = Ember['default'].A(); | |
var args; | |
@@ -28209,10 +29382,10 @@ | |
args = a_slice.call(arguments, 1); | |
} | |
- this.forEach(function (x, idx) { | |
+ this.forEach(function(x, idx) { | |
var method = x && x[methodName]; | |
- if ("function" === typeof method) { | |
+ if ('function' === typeof method) { | |
ret[idx] = args ? utils.apply(x, method, args) : x[methodName](); | |
} | |
}, this); | |
@@ -28223,13 +29396,14 @@ | |
/** | |
Simply converts the enumerable into a genuine array. The order is not | |
guaranteed. Corresponds to the method implemented by Prototype. | |
- @method toArray | |
+ | |
+ @method toArray | |
@return {Array} the enumerable as an array. | |
*/ | |
- toArray: function () { | |
+ toArray: function() { | |
var ret = Ember['default'].A(); | |
- this.forEach(function (o, idx) { | |
+ this.forEach(function(o, idx) { | |
ret[idx] = o; | |
}); | |
@@ -28238,15 +29412,17 @@ | |
/** | |
Returns a copy of the array with all `null` and `undefined` elements removed. | |
- ```javascript | |
+ | |
+ ```javascript | |
var arr = ['a', null, 'c', undefined]; | |
arr.compact(); // ['a', 'c'] | |
``` | |
- @method compact | |
+ | |
+ @method compact | |
@return {Array} the array without null and undefined elements. | |
*/ | |
- compact: function () { | |
- return this.filter(function (value) { | |
+ compact: function() { | |
+ return this.filter(function(value) { | |
return value != null; | |
}); | |
}, | |
@@ -28255,22 +29431,24 @@ | |
Returns a new enumerable that excludes the passed value. The default | |
implementation returns an array regardless of the receiver type unless | |
the receiver does not contain the value. | |
- ```javascript | |
+ | |
+ ```javascript | |
var arr = ['a', 'b', 'a', 'c']; | |
arr.without('a'); // ['b', 'c'] | |
``` | |
- @method without | |
+ | |
+ @method without | |
@param {Object} value | |
@return {Ember.Enumerable} | |
*/ | |
- without: function (value) { | |
+ without: function(value) { | |
if (!this.contains(value)) { | |
return this; // nothing to do | |
} | |
var ret = Ember['default'].A(); | |
- this.forEach(function (k) { | |
+ this.forEach(function(k) { | |
if (k !== value) { | |
ret[ret.length] = k; | |
} | |
@@ -28282,18 +29460,21 @@ | |
/** | |
Returns a new enumerable that contains only unique values. The default | |
implementation returns an array regardless of the receiver type. | |
- ```javascript | |
+ | |
+ ```javascript | |
var arr = ['a', 'a', 'b', 'b']; | |
arr.uniq(); // ['a', 'b'] | |
``` | |
- This only works on primitive data types, e.g. Strings, Numbers, etc. | |
- @method uniq | |
+ | |
+ This only works on primitive data types, e.g. Strings, Numbers, etc. | |
+ | |
+ @method uniq | |
@return {Ember.Enumerable} | |
*/ | |
- uniq: function () { | |
+ uniq: function() { | |
var ret = Ember['default'].A(); | |
- this.forEach(function (k) { | |
+ this.forEach(function(k) { | |
if (enumerable_utils.indexOf(ret, k) < 0) { | |
ret.push(k); | |
} | |
@@ -28306,13 +29487,15 @@ | |
This property will trigger anytime the enumerable's content changes. | |
You can observe this property to be notified of changes to the enumerable's | |
content. | |
- For plain enumerables, this property is read only. `Array` overrides | |
+ | |
+ For plain enumerables, this property is read only. `Array` overrides | |
this method. | |
- @property [] | |
+ | |
+ @property [] | |
@type Array | |
@return this | |
*/ | |
- "[]": computed.computed(function (key, value) { | |
+ '[]': computed.computed(function(key, value) { | |
return this; | |
}), | |
@@ -28323,25 +29506,26 @@ | |
/** | |
Registers an enumerable observer. Must implement `Ember.EnumerableObserver` | |
mixin. | |
- @method addEnumerableObserver | |
+ | |
+ @method addEnumerableObserver | |
@param {Object} target | |
@param {Hash} [opts] | |
@return this | |
*/ | |
- addEnumerableObserver: function (target, opts) { | |
- var willChange = opts && opts.willChange || "enumerableWillChange"; | |
- var didChange = opts && opts.didChange || "enumerableDidChange"; | |
- var hasObservers = property_get.get(this, "hasEnumerableObservers"); | |
+ addEnumerableObserver: function(target, opts) { | |
+ var willChange = (opts && opts.willChange) || 'enumerableWillChange'; | |
+ var didChange = (opts && opts.didChange) || 'enumerableDidChange'; | |
+ var hasObservers = property_get.get(this, 'hasEnumerableObservers'); | |
if (!hasObservers) { | |
- property_events.propertyWillChange(this, "hasEnumerableObservers"); | |
+ property_events.propertyWillChange(this, 'hasEnumerableObservers'); | |
} | |
- events.addListener(this, "@enumerable:before", target, willChange); | |
- events.addListener(this, "@enumerable:change", target, didChange); | |
+ events.addListener(this, '@enumerable:before', target, willChange); | |
+ events.addListener(this, '@enumerable:change', target, didChange); | |
if (!hasObservers) { | |
- property_events.propertyDidChange(this, "hasEnumerableObservers"); | |
+ property_events.propertyDidChange(this, 'hasEnumerableObservers'); | |
} | |
return this; | |
@@ -28349,25 +29533,26 @@ | |
/** | |
Removes a registered enumerable observer. | |
- @method removeEnumerableObserver | |
+ | |
+ @method removeEnumerableObserver | |
@param {Object} target | |
@param {Hash} [opts] | |
@return this | |
*/ | |
- removeEnumerableObserver: function (target, opts) { | |
- var willChange = opts && opts.willChange || "enumerableWillChange"; | |
- var didChange = opts && opts.didChange || "enumerableDidChange"; | |
- var hasObservers = property_get.get(this, "hasEnumerableObservers"); | |
+ removeEnumerableObserver: function(target, opts) { | |
+ var willChange = (opts && opts.willChange) || 'enumerableWillChange'; | |
+ var didChange = (opts && opts.didChange) || 'enumerableDidChange'; | |
+ var hasObservers = property_get.get(this, 'hasEnumerableObservers'); | |
if (hasObservers) { | |
- property_events.propertyWillChange(this, "hasEnumerableObservers"); | |
+ property_events.propertyWillChange(this, 'hasEnumerableObservers'); | |
} | |
- events.removeListener(this, "@enumerable:before", target, willChange); | |
- events.removeListener(this, "@enumerable:change", target, didChange); | |
+ events.removeListener(this, '@enumerable:before', target, willChange); | |
+ events.removeListener(this, '@enumerable:change', target, didChange); | |
if (hasObservers) { | |
- property_events.propertyDidChange(this, "hasEnumerableObservers"); | |
+ property_events.propertyDidChange(this, 'hasEnumerableObservers'); | |
} | |
return this; | |
@@ -28376,39 +29561,42 @@ | |
/** | |
Becomes true whenever the array currently has observers watching changes | |
on the array. | |
- @property hasEnumerableObservers | |
+ | |
+ @property hasEnumerableObservers | |
@type Boolean | |
*/ | |
- hasEnumerableObservers: computed.computed(function () { | |
- return events.hasListeners(this, "@enumerable:change") || events.hasListeners(this, "@enumerable:before"); | |
+ hasEnumerableObservers: computed.computed(function() { | |
+ return events.hasListeners(this, '@enumerable:change') || events.hasListeners(this, '@enumerable:before'); | |
}), | |
+ | |
/** | |
Invoke this method just before the contents of your enumerable will | |
change. You can either omit the parameters completely or pass the objects | |
to be removed or added if available or just a count. | |
- @method enumerableContentWillChange | |
+ | |
+ @method enumerableContentWillChange | |
@param {Ember.Enumerable|Number} removing An enumerable of the objects to | |
be removed or the number of items to be removed. | |
@param {Ember.Enumerable|Number} adding An enumerable of the objects to be | |
added or the number of items to be added. | |
@chainable | |
*/ | |
- enumerableContentWillChange: function (removing, adding) { | |
+ enumerableContentWillChange: function(removing, adding) { | |
var removeCnt, addCnt, hasDelta; | |
- if ("number" === typeof removing) { | |
+ if ('number' === typeof removing) { | |
removeCnt = removing; | |
} else if (removing) { | |
- removeCnt = property_get.get(removing, "length"); | |
+ removeCnt = property_get.get(removing, 'length'); | |
} else { | |
removeCnt = removing = -1; | |
} | |
- if ("number" === typeof adding) { | |
+ if ('number' === typeof adding) { | |
addCnt = adding; | |
} else if (adding) { | |
- addCnt = property_get.get(adding, "length"); | |
+ addCnt = property_get.get(adding, 'length'); | |
} else { | |
addCnt = adding = -1; | |
} | |
@@ -28423,13 +29611,13 @@ | |
adding = null; | |
} | |
- property_events.propertyWillChange(this, "[]"); | |
+ property_events.propertyWillChange(this, '[]'); | |
if (hasDelta) { | |
- property_events.propertyWillChange(this, "length"); | |
+ property_events.propertyWillChange(this, 'length'); | |
} | |
- events.sendEvent(this, "@enumerable:before", [this, removing, adding]); | |
+ events.sendEvent(this, '@enumerable:before', [this, removing, adding]); | |
return this; | |
}, | |
@@ -28440,28 +29628,29 @@ | |
implementing an ordered enumerable (such as an array), also pass the | |
start and end values where the content changed so that it can be used to | |
notify range observers. | |
- @method enumerableContentDidChange | |
+ | |
+ @method enumerableContentDidChange | |
@param {Ember.Enumerable|Number} removing An enumerable of the objects to | |
be removed or the number of items to be removed. | |
@param {Ember.Enumerable|Number} adding An enumerable of the objects to | |
be added or the number of items to be added. | |
@chainable | |
*/ | |
- enumerableContentDidChange: function (removing, adding) { | |
+ enumerableContentDidChange: function(removing, adding) { | |
var removeCnt, addCnt, hasDelta; | |
- if ("number" === typeof removing) { | |
+ if ('number' === typeof removing) { | |
removeCnt = removing; | |
} else if (removing) { | |
- removeCnt = property_get.get(removing, "length"); | |
+ removeCnt = property_get.get(removing, 'length'); | |
} else { | |
removeCnt = removing = -1; | |
} | |
- if ("number" === typeof adding) { | |
+ if ('number' === typeof adding) { | |
addCnt = adding; | |
} else if (adding) { | |
- addCnt = property_get.get(adding, "length"); | |
+ addCnt = property_get.get(adding, 'length'); | |
} else { | |
addCnt = adding = -1; | |
} | |
@@ -28476,13 +29665,13 @@ | |
adding = null; | |
} | |
- events.sendEvent(this, "@enumerable:change", [this, removing, adding]); | |
+ events.sendEvent(this, '@enumerable:change', [this, removing, adding]); | |
if (hasDelta) { | |
- property_events.propertyDidChange(this, "length"); | |
+ property_events.propertyDidChange(this, 'length'); | |
} | |
- property_events.propertyDidChange(this, "[]"); | |
+ property_events.propertyDidChange(this, '[]'); | |
return this; | |
}, | |
@@ -28490,16 +29679,18 @@ | |
/** | |
Converts the enumerable into an array and sorts by the keys | |
specified in the argument. | |
- You may provide multiple arguments to sort by multiple properties. | |
- @method sortBy | |
+ | |
+ You may provide multiple arguments to sort by multiple properties. | |
+ | |
+ @method sortBy | |
@param {String} property name(s) to sort on | |
@return {Array} The sorted array. | |
@since 1.2.0 | |
*/ | |
- sortBy: function () { | |
+ sortBy: function() { | |
var sortKeys = arguments; | |
- return this.toArray().sort(function (a, b) { | |
+ return this.toArray().sort(function(a, b) { | |
for (var i = 0; i < sortKeys.length; i++) { | |
var key = sortKeys[i]; | |
var propA = property_get.get(a, key); | |
@@ -28525,22 +29716,25 @@ | |
/** | |
Subscribes to a named event with given function. | |
- ```javascript | |
+ | |
+ ```javascript | |
person.on('didLoad', function() { | |
// fired once the person has loaded | |
}); | |
``` | |
- An optional target can be passed in as the 2nd argument that will | |
+ | |
+ An optional target can be passed in as the 2nd argument that will | |
be set as the "this" for the callback. This is a good way to give your | |
function access to the object triggering the event. When the target | |
parameter is used the callback becomes the third argument. | |
- @method on | |
+ | |
+ @method on | |
@param {String} name The name of the event | |
@param {Object} [target] The "this" binding for the callback | |
@param {Function} method The callback to execute | |
@return this | |
*/ | |
- on: function (name, target, method) { | |
+ on: function(name, target, method) { | |
events.addListener(this, name, target, method); | |
return this; | |
}, | |
@@ -28549,16 +29743,18 @@ | |
Subscribes a function to a named event and then cancels the subscription | |
after the first time the event is triggered. It is good to use ``one`` when | |
you only care about the first time an event has taken place. | |
- This function takes an optional 2nd argument that will become the "this" | |
+ | |
+ This function takes an optional 2nd argument that will become the "this" | |
value for the callback. If this argument is passed then the 3rd argument | |
becomes the function. | |
- @method one | |
+ | |
+ @method one | |
@param {String} name The name of the event | |
@param {Object} [target] The "this" binding for the callback | |
@param {Function} method The callback to execute | |
@return this | |
*/ | |
- one: function (name, target, method) { | |
+ one: function(name, target, method) { | |
if (!method) { | |
method = target; | |
target = null; | |
@@ -28572,18 +29768,21 @@ | |
Triggers a named event for the object. Any additional arguments | |
will be passed as parameters to the functions that are subscribed to the | |
event. | |
- ```javascript | |
+ | |
+ ```javascript | |
person.on('didEat', function(food) { | |
console.log('person ate some ' + food); | |
}); | |
- person.trigger('didEat', 'broccoli'); | |
- // outputs: person ate some broccoli | |
+ | |
+ person.trigger('didEat', 'broccoli'); | |
+ | |
+ // outputs: person ate some broccoli | |
``` | |
@method trigger | |
@param {String} name The name of the event | |
@param {Object...} args Optional arguments to pass on | |
*/ | |
- trigger: function (name) { | |
+ trigger: function(name) { | |
var length = arguments.length; | |
var args = new Array(length - 1); | |
@@ -28596,24 +29795,26 @@ | |
/** | |
Cancels subscription for given name, target, and method. | |
- @method off | |
+ | |
+ @method off | |
@param {String} name The name of the event | |
@param {Object} target The target of the subscription | |
@param {Function} method The function of the subscription | |
@return this | |
*/ | |
- off: function (name, target, method) { | |
+ off: function(name, target, method) { | |
events.removeListener(this, name, target, method); | |
return this; | |
}, | |
/** | |
Checks to see if object has any subscriptions for named event. | |
- @method has | |
+ | |
+ @method has | |
@param {String} name The name of the event | |
@return {Boolean} does the object have a subscription for event | |
*/ | |
- has: function (name) { | |
+ has: function(name) { | |
return events.hasListeners(this, name); | |
} | |
}); | |
@@ -28633,7 +29834,8 @@ | |
/** | |
Set to `true` when the object is frozen. Use this property to detect | |
whether your object is frozen or not. | |
- @property isFrozen | |
+ | |
+ @property isFrozen | |
@type Boolean | |
*/ | |
isFrozen: false, | |
@@ -28641,15 +29843,16 @@ | |
/** | |
Freezes the object. Once this method has been called the object should | |
no longer allow any properties to be edited. | |
- @method freeze | |
+ | |
+ @method freeze | |
@return {Object} receiver | |
*/ | |
- freeze: function () { | |
- if (property_get.get(this, "isFrozen")) { | |
+ freeze: function() { | |
+ if (property_get.get(this, 'isFrozen')) { | |
return this; | |
} | |
- property_set.set(this, "isFrozen", true); | |
+ property_set.set(this, 'isFrozen', true); | |
return this; | |
} | |
@@ -28670,6 +29873,7 @@ | |
@submodule ember-runtime | |
*/ | |
+ | |
// require('ember-runtime/mixins/array'); | |
// require('ember-runtime/mixins/mutable_enumerable'); | |
@@ -28688,10 +29892,12 @@ | |
/** | |
__Required.__ You must implement this method to apply this mixin. | |
- This is one of the primitives you must implement to support `Ember.Array`. | |
+ | |
+ This is one of the primitives you must implement to support `Ember.Array`. | |
You should replace amt objects started at idx with the objects in the | |
passed array. You should also call `this.enumerableContentDidChange()` | |
- @method replace | |
+ | |
+ @method replace | |
@param {Number} idx Starting index in the array to replace. If | |
idx >= length, then append to the end of the array. | |
@param {Number} amt Number of elements that should be removed from | |
@@ -28704,17 +29910,19 @@ | |
/** | |
Remove all elements from the array. This is useful if you | |
want to reuse an existing array without having to recreate it. | |
- ```javascript | |
+ | |
+ ```javascript | |
var colors = ["red", "green", "blue"]; | |
color.length(); // 3 | |
colors.clear(); // [] | |
colors.length(); // 0 | |
``` | |
- @method clear | |
+ | |
+ @method clear | |
@return {Ember.Array} An empty Array. | |
*/ | |
clear: function () { | |
- var len = property_get.get(this, "length"); | |
+ var len = property_get.get(this, 'length'); | |
if (len === 0) { | |
return this; | |
} | |
@@ -28726,18 +29934,20 @@ | |
/** | |
This will use the primitive `replace()` method to insert an object at the | |
specified index. | |
- ```javascript | |
+ | |
+ ```javascript | |
var colors = ["red", "green", "blue"]; | |
colors.insertAt(2, "yellow"); // ["red", "green", "yellow", "blue"] | |
colors.insertAt(5, "orange"); // Error: Index out of range | |
``` | |
- @method insertAt | |
+ | |
+ @method insertAt | |
@param {Number} idx index of insert the object at. | |
@param {Object} object object to insert | |
@return {Ember.Array} receiver | |
*/ | |
- insertAt: function (idx, object) { | |
- if (idx > property_get.get(this, "length")) { | |
+ insertAt: function(idx, object) { | |
+ if (idx > property_get.get(this, 'length')) { | |
throw new EmberError['default'](OUT_OF_RANGE_EXCEPTION); | |
} | |
@@ -28748,23 +29958,26 @@ | |
/** | |
Remove an object at the specified index using the `replace()` primitive | |
method. You can pass either a single index, or a start and a length. | |
- If you pass a start and length that is beyond the | |
+ | |
+ If you pass a start and length that is beyond the | |
length this method will throw an `OUT_OF_RANGE_EXCEPTION`. | |
- ```javascript | |
+ | |
+ ```javascript | |
var colors = ["red", "green", "blue", "yellow", "orange"]; | |
colors.removeAt(0); // ["green", "blue", "yellow", "orange"] | |
colors.removeAt(2, 2); // ["green", "blue"] | |
colors.removeAt(4, 2); // Error: Index out of range | |
``` | |
- @method removeAt | |
+ | |
+ @method removeAt | |
@param {Number} start index, start of range | |
@param {Number} len length of passing range | |
@return {Ember.Array} receiver | |
*/ | |
- removeAt: function (start, len) { | |
- if ("number" === typeof start) { | |
+ removeAt: function(start, len) { | |
+ if ('number' === typeof start) { | |
- if (start < 0 || start >= property_get.get(this, "length")) { | |
+ if ((start < 0) || (start >= property_get.get(this, 'length'))) { | |
throw new EmberError['default'](OUT_OF_RANGE_EXCEPTION); | |
} | |
@@ -28782,74 +29995,82 @@ | |
/** | |
Push the object onto the end of the array. Works just like `push()` but it | |
is KVO-compliant. | |
- ```javascript | |
+ | |
+ ```javascript | |
var colors = ["red", "green"]; | |
colors.pushObject("black"); // ["red", "green", "black"] | |
colors.pushObject(["yellow"]); // ["red", "green", ["yellow"]] | |
``` | |
- @method pushObject | |
+ | |
+ @method pushObject | |
@param {*} obj object to push | |
@return object same object passed as a param | |
*/ | |
- pushObject: function (obj) { | |
- this.insertAt(property_get.get(this, "length"), obj); | |
+ pushObject: function(obj) { | |
+ this.insertAt(property_get.get(this, 'length'), obj); | |
return obj; | |
}, | |
/** | |
Add the objects in the passed numerable to the end of the array. Defers | |
notifying observers of the change until all objects are added. | |
- ```javascript | |
+ | |
+ ```javascript | |
var colors = ["red"]; | |
colors.pushObjects(["yellow", "orange"]); // ["red", "yellow", "orange"] | |
``` | |
- @method pushObjects | |
+ | |
+ @method pushObjects | |
@param {Ember.Enumerable} objects the objects to add | |
@return {Ember.Array} receiver | |
*/ | |
- pushObjects: function (objects) { | |
+ pushObjects: function(objects) { | |
if (!(Enumerable['default'].detect(objects) || utils.isArray(objects))) { | |
throw new TypeError("Must pass Ember.Enumerable to Ember.MutableArray#pushObjects"); | |
} | |
- this.replace(property_get.get(this, "length"), 0, objects); | |
+ this.replace(property_get.get(this, 'length'), 0, objects); | |
return this; | |
}, | |
/** | |
Pop object from array or nil if none are left. Works just like `pop()` but | |
it is KVO-compliant. | |
- ```javascript | |
+ | |
+ ```javascript | |
var colors = ["red", "green", "blue"]; | |
colors.popObject(); // "blue" | |
console.log(colors); // ["red", "green"] | |
``` | |
- @method popObject | |
+ | |
+ @method popObject | |
@return object | |
*/ | |
- popObject: function () { | |
- var len = property_get.get(this, "length"); | |
+ popObject: function() { | |
+ var len = property_get.get(this, 'length'); | |
if (len === 0) { | |
return null; | |
} | |
- var ret = this.objectAt(len - 1); | |
- this.removeAt(len - 1, 1); | |
+ var ret = this.objectAt(len-1); | |
+ this.removeAt(len-1, 1); | |
return ret; | |
}, | |
/** | |
Shift an object from start of array or nil if none are left. Works just | |
like `shift()` but it is KVO-compliant. | |
- ```javascript | |
+ | |
+ ```javascript | |
var colors = ["red", "green", "blue"]; | |
colors.shiftObject(); // "red" | |
console.log(colors); // ["green", "blue"] | |
``` | |
- @method shiftObject | |
+ | |
+ @method shiftObject | |
@return object | |
*/ | |
- shiftObject: function () { | |
- if (property_get.get(this, "length") === 0) { | |
+ shiftObject: function() { | |
+ if (property_get.get(this, 'length') === 0) { | |
return null; | |
} | |
@@ -28861,16 +30082,18 @@ | |
/** | |
Unshift an object to start of array. Works just like `unshift()` but it is | |
KVO-compliant. | |
- ```javascript | |
+ | |
+ ```javascript | |
var colors = ["red"]; | |
colors.unshiftObject("yellow"); // ["yellow", "red"] | |
colors.unshiftObject(["black"]); // [["black"], "yellow", "red"] | |
``` | |
- @method unshiftObject | |
+ | |
+ @method unshiftObject | |
@param {*} obj object to unshift | |
@return object same object passed as a param | |
*/ | |
- unshiftObject: function (obj) { | |
+ unshiftObject: function(obj) { | |
this.insertAt(0, obj); | |
return obj; | |
}, | |
@@ -28878,16 +30101,18 @@ | |
/** | |
Adds the named objects to the beginning of the array. Defers notifying | |
observers until all objects have been added. | |
- ```javascript | |
+ | |
+ ```javascript | |
var colors = ["red"]; | |
colors.unshiftObjects(["black", "white"]); // ["black", "white", "red"] | |
colors.unshiftObjects("yellow"); // Type Error: 'undefined' is not a function | |
``` | |
- @method unshiftObjects | |
+ | |
+ @method unshiftObjects | |
@param {Ember.Enumerable} objects the objects to add | |
@return {Ember.Array} receiver | |
*/ | |
- unshiftObjects: function (objects) { | |
+ unshiftObjects: function(objects) { | |
this.replace(0, 0, objects); | |
return this; | |
}, | |
@@ -28895,11 +30120,12 @@ | |
/** | |
Reverse objects in the array. Works just like `reverse()` but it is | |
KVO-compliant. | |
- @method reverseObjects | |
+ | |
+ @method reverseObjects | |
@return {Ember.Array} receiver | |
*/ | |
- reverseObjects: function () { | |
- var len = property_get.get(this, "length"); | |
+ reverseObjects: function() { | |
+ var len = property_get.get(this, 'length'); | |
if (len === 0) { | |
return this; | |
} | |
@@ -28912,22 +30138,24 @@ | |
/** | |
Replace all the receiver's content with content of the argument. | |
If argument is an empty array receiver will be cleared. | |
- ```javascript | |
+ | |
+ ```javascript | |
var colors = ["red", "green", "blue"]; | |
colors.setObjects(["black", "white"]); // ["black", "white"] | |
colors.setObjects([]); // [] | |
``` | |
- @method setObjects | |
+ | |
+ @method setObjects | |
@param {Ember.Array} objects array whose content will be used for replacing | |
the content of the receiver | |
@return {Ember.Array} receiver with the new content | |
*/ | |
- setObjects: function (objects) { | |
+ setObjects: function(objects) { | |
if (objects.length === 0) { | |
return this.clear(); | |
} | |
- var len = property_get.get(this, "length"); | |
+ var len = property_get.get(this, 'length'); | |
this.replace(0, len, objects); | |
return this; | |
}, | |
@@ -28938,18 +30166,20 @@ | |
/** | |
Remove all occurrences of an object in the array. | |
- ```javascript | |
+ | |
+ ```javascript | |
var cities = ["Chicago", "Berlin", "Lima", "Chicago"]; | |
cities.removeObject("Chicago"); // ["Berlin", "Lima"] | |
cities.removeObject("Lima"); // ["Berlin"] | |
cities.removeObject("Tokyo") // ["Berlin"] | |
``` | |
- @method removeObject | |
+ | |
+ @method removeObject | |
@param {*} obj object to remove | |
@return {Ember.Array} receiver | |
*/ | |
- removeObject: function (obj) { | |
- var loc = property_get.get(this, "length") || 0; | |
+ removeObject: function(obj) { | |
+ var loc = property_get.get(this, 'length') || 0; | |
while (--loc >= 0) { | |
var curObject = this.objectAt(loc); | |
@@ -28963,16 +30193,18 @@ | |
/** | |
Push the object onto the end of the array if it is not already | |
present in the array. | |
- ```javascript | |
+ | |
+ ```javascript | |
var cities = ["Chicago", "Berlin"]; | |
cities.addObject("Lima"); // ["Chicago", "Berlin", "Lima"] | |
cities.addObject("Berlin"); // ["Chicago", "Berlin", "Lima"] | |
``` | |
- @method addObject | |
+ | |
+ @method addObject | |
@param {*} obj object to add, if not already present | |
@return {Ember.Array} receiver | |
*/ | |
- addObject: function (obj) { | |
+ addObject: function(obj) { | |
if (!this.contains(obj)) { | |
this.pushObject(obj); | |
} | |
@@ -28991,12 +30223,15 @@ | |
/** | |
__Required.__ You must implement this method to apply this mixin. | |
- Attempts to add the passed object to the receiver if the object is not | |
+ | |
+ Attempts to add the passed object to the receiver if the object is not | |
already present in the collection. If the object is present, this method | |
has no effect. | |
- If the passed object is of a type not supported by the receiver, | |
+ | |
+ If the passed object is of a type not supported by the receiver, | |
then this method should raise an exception. | |
- @method addObject | |
+ | |
+ @method addObject | |
@param {Object} object The object to add to the enumerable. | |
@return {Object} the passed object | |
*/ | |
@@ -29004,39 +30239,43 @@ | |
/** | |
Adds each object in the passed enumerable to the receiver. | |
- @method addObjects | |
+ | |
+ @method addObjects | |
@param {Ember.Enumerable} objects the objects to add. | |
@return {Object} receiver | |
*/ | |
- addObjects: function (objects) { | |
+ addObjects: function(objects) { | |
property_events.beginPropertyChanges(this); | |
- enumerable_utils.forEach(objects, function (obj) { | |
- this.addObject(obj); | |
- }, this); | |
+ enumerable_utils.forEach(objects, function(obj) { this.addObject(obj); }, this); | |
property_events.endPropertyChanges(this); | |
return this; | |
}, | |
/** | |
__Required.__ You must implement this method to apply this mixin. | |
- Attempts to remove the passed object from the receiver collection if the | |
+ | |
+ Attempts to remove the passed object from the receiver collection if the | |
object is present in the collection. If the object is not present, | |
this method has no effect. | |
- If the passed object is of a type not supported by the receiver, | |
+ | |
+ If the passed object is of a type not supported by the receiver, | |
then this method should raise an exception. | |
- @method removeObject | |
+ | |
+ @method removeObject | |
@param {Object} object The object to remove from the enumerable. | |
@return {Object} the passed object | |
*/ | |
removeObject: mixin.required(Function), | |
+ | |
/** | |
Removes each object in the passed enumerable from the receiver. | |
- @method removeObjects | |
+ | |
+ @method removeObjects | |
@param {Ember.Enumerable} objects the objects to remove | |
@return {Object} receiver | |
*/ | |
- removeObjects: function (objects) { | |
+ removeObjects: function(objects) { | |
property_events.beginPropertyChanges(this); | |
for (var i = objects.length - 1; i >= 0; i--) { | |
this.removeObject(objects[i]); | |
@@ -29125,183 +30364,220 @@ | |
/** | |
Retrieves the value of a property from the object. | |
- This method is usually similar to using `object[keyName]` or `object.keyName`, | |
+ | |
+ This method is usually similar to using `object[keyName]` or `object.keyName`, | |
however it supports both computed properties and the unknownProperty | |
handler. | |
- Because `get` unifies the syntax for accessing all these kinds | |
+ | |
+ Because `get` unifies the syntax for accessing all these kinds | |
of properties, it can make many refactorings easier, such as replacing a | |
simple property with a computed property, or vice versa. | |
- ### Computed Properties | |
- Computed properties are methods defined with the `property` modifier | |
+ | |
+ ### Computed Properties | |
+ | |
+ Computed properties are methods defined with the `property` modifier | |
declared at the end, such as: | |
- ```javascript | |
+ | |
+ ```javascript | |
fullName: function() { | |
return this.get('firstName') + ' ' + this.get('lastName'); | |
}.property('firstName', 'lastName') | |
``` | |
- When you call `get` on a computed property, the function will be | |
+ | |
+ When you call `get` on a computed property, the function will be | |
called and the return value will be returned instead of the function | |
itself. | |
- ### Unknown Properties | |
- Likewise, if you try to call `get` on a property whose value is | |
+ | |
+ ### Unknown Properties | |
+ | |
+ Likewise, if you try to call `get` on a property whose value is | |
`undefined`, the `unknownProperty()` method will be called on the object. | |
If this method returns any value other than `undefined`, it will be returned | |
instead. This allows you to implement "virtual" properties that are | |
not defined upfront. | |
- @method get | |
+ | |
+ @method get | |
@param {String} keyName The property to retrieve | |
@return {Object} The property value or undefined. | |
*/ | |
- get: function (keyName) { | |
+ get: function(keyName) { | |
return property_get.get(this, keyName); | |
}, | |
/** | |
To get the values of multiple properties at once, call `getProperties` | |
with a list of strings or an array: | |
- ```javascript | |
+ | |
+ ```javascript | |
record.getProperties('firstName', 'lastName', 'zipCode'); | |
// { firstName: 'John', lastName: 'Doe', zipCode: '10011' } | |
``` | |
- is equivalent to: | |
- ```javascript | |
+ | |
+ is equivalent to: | |
+ | |
+ ```javascript | |
record.getProperties(['firstName', 'lastName', 'zipCode']); | |
// { firstName: 'John', lastName: 'Doe', zipCode: '10011' } | |
``` | |
- @method getProperties | |
+ | |
+ @method getProperties | |
@param {String...|Array} list of keys to get | |
@return {Hash} | |
*/ | |
- getProperties: function () { | |
+ getProperties: function() { | |
return utils.apply(null, getProperties['default'], [this].concat(slice.call(arguments))); | |
}, | |
/** | |
Sets the provided key or path to the value. | |
- This method is generally very similar to calling `object[key] = value` or | |
+ | |
+ This method is generally very similar to calling `object[key] = value` or | |
`object.key = value`, except that it provides support for computed | |
properties, the `setUnknownProperty()` method and property observers. | |
- ### Computed Properties | |
- If you try to set a value on a key that has a computed property handler | |
+ | |
+ ### Computed Properties | |
+ | |
+ If you try to set a value on a key that has a computed property handler | |
defined (see the `get()` method for an example), then `set()` will call | |
that method, passing both the value and key instead of simply changing | |
the value itself. This is useful for those times when you need to | |
implement a property that is composed of one or more member | |
properties. | |
- ### Unknown Properties | |
- If you try to set a value on a key that is undefined in the target | |
+ | |
+ ### Unknown Properties | |
+ | |
+ If you try to set a value on a key that is undefined in the target | |
object, then the `setUnknownProperty()` handler will be called instead. This | |
gives you an opportunity to implement complex "virtual" properties that | |
are not predefined on the object. If `setUnknownProperty()` returns | |
undefined, then `set()` will simply set the value on the object. | |
- ### Property Observers | |
- In addition to changing the property, `set()` will also register a property | |
+ | |
+ ### Property Observers | |
+ | |
+ In addition to changing the property, `set()` will also register a property | |
change with the object. Unless you have placed this call inside of a | |
`beginPropertyChanges()` and `endPropertyChanges(),` any "local" observers | |
(i.e. observer methods declared on the same object), will be called | |
immediately. Any "remote" observers (i.e. observer methods declared on | |
another object) will be placed in a queue and called at a later time in a | |
coalesced manner. | |
- ### Chaining | |
- In addition to property changes, `set()` returns the value of the object | |
+ | |
+ ### Chaining | |
+ | |
+ In addition to property changes, `set()` returns the value of the object | |
itself so you can do chaining like this: | |
- ```javascript | |
+ | |
+ ```javascript | |
record.set('firstName', 'Charles').set('lastName', 'Jolley'); | |
``` | |
- @method set | |
+ | |
+ @method set | |
@param {String} keyName The property to set | |
@param {Object} value The value to set or `null`. | |
@return {Ember.Observable} | |
*/ | |
- set: function (keyName, value) { | |
+ set: function(keyName, value) { | |
property_set.set(this, keyName, value); | |
return this; | |
}, | |
+ | |
/** | |
Sets a list of properties at once. These properties are set inside | |
a single `beginPropertyChanges` and `endPropertyChanges` batch, so | |
observers will be buffered. | |
- ```javascript | |
+ | |
+ ```javascript | |
record.setProperties({ firstName: 'Charles', lastName: 'Jolley' }); | |
``` | |
- @method setProperties | |
+ | |
+ @method setProperties | |
@param {Hash} hash the hash of keys and values to set | |
@return {Ember.Observable} | |
*/ | |
- setProperties: function (hash) { | |
+ setProperties: function(hash) { | |
return setProperties['default'](this, hash); | |
}, | |
/** | |
Begins a grouping of property changes. | |
- You can use this method to group property changes so that notifications | |
+ | |
+ You can use this method to group property changes so that notifications | |
will not be sent until the changes are finished. If you plan to make a | |
large number of changes to an object at one time, you should call this | |
method at the beginning of the changes to begin deferring change | |
notifications. When you are done making changes, call | |
`endPropertyChanges()` to deliver the deferred change notifications and end | |
deferring. | |
- @method beginPropertyChanges | |
+ | |
+ @method beginPropertyChanges | |
@return {Ember.Observable} | |
*/ | |
- beginPropertyChanges: function () { | |
+ beginPropertyChanges: function() { | |
property_events.beginPropertyChanges(); | |
return this; | |
}, | |
/** | |
Ends a grouping of property changes. | |
- You can use this method to group property changes so that notifications | |
+ | |
+ You can use this method to group property changes so that notifications | |
will not be sent until the changes are finished. If you plan to make a | |
large number of changes to an object at one time, you should call | |
`beginPropertyChanges()` at the beginning of the changes to defer change | |
notifications. When you are done making changes, call this method to | |
deliver the deferred change notifications and end deferring. | |
- @method endPropertyChanges | |
+ | |
+ @method endPropertyChanges | |
@return {Ember.Observable} | |
*/ | |
- endPropertyChanges: function () { | |
+ endPropertyChanges: function() { | |
property_events.endPropertyChanges(); | |
return this; | |
}, | |
/** | |
Notify the observer system that a property is about to change. | |
- Sometimes you need to change a value directly or indirectly without | |
+ | |
+ Sometimes you need to change a value directly or indirectly without | |
actually calling `get()` or `set()` on it. In this case, you can use this | |
method and `propertyDidChange()` instead. Calling these two methods | |
together will notify all observers that the property has potentially | |
changed value. | |
- Note that you must always call `propertyWillChange` and `propertyDidChange` | |
+ | |
+ Note that you must always call `propertyWillChange` and `propertyDidChange` | |
as a pair. If you do not, it may get the property change groups out of | |
order and cause notifications to be delivered more often than you would | |
like. | |
- @method propertyWillChange | |
+ | |
+ @method propertyWillChange | |
@param {String} keyName The property key that is about to change. | |
@return {Ember.Observable} | |
*/ | |
- propertyWillChange: function (keyName) { | |
+ propertyWillChange: function(keyName) { | |
property_events.propertyWillChange(this, keyName); | |
return this; | |
}, | |
/** | |
Notify the observer system that a property has just changed. | |
- Sometimes you need to change a value directly or indirectly without | |
+ | |
+ Sometimes you need to change a value directly or indirectly without | |
actually calling `get()` or `set()` on it. In this case, you can use this | |
method and `propertyWillChange()` instead. Calling these two methods | |
together will notify all observers that the property has potentially | |
changed value. | |
- Note that you must always call `propertyWillChange` and `propertyDidChange` | |
+ | |
+ Note that you must always call `propertyWillChange` and `propertyDidChange` | |
as a pair. If you do not, it may get the property change groups out of | |
order and cause notifications to be delivered more often than you would | |
like. | |
- @method propertyDidChange | |
+ | |
+ @method propertyDidChange | |
@param {String} keyName The property key that has just changed. | |
@return {Ember.Observable} | |
*/ | |
- propertyDidChange: function (keyName) { | |
+ propertyDidChange: function(keyName) { | |
property_events.propertyDidChange(this, keyName); | |
return this; | |
}, | |
@@ -29309,58 +30585,74 @@ | |
/** | |
Convenience method to call `propertyWillChange` and `propertyDidChange` in | |
succession. | |
- @method notifyPropertyChange | |
+ | |
+ @method notifyPropertyChange | |
@param {String} keyName The property key to be notified about. | |
@return {Ember.Observable} | |
*/ | |
- notifyPropertyChange: function (keyName) { | |
+ notifyPropertyChange: function(keyName) { | |
this.propertyWillChange(keyName); | |
this.propertyDidChange(keyName); | |
return this; | |
}, | |
- addBeforeObserver: function (key, target, method) { | |
- Ember['default'].deprecate("Before observers are deprecated and will be removed in a future release. If you want to keep track of previous values you have to implement it yourself.", false, { url: "http://emberjs.com/guides/deprecations/#toc_beforeobserver" }); | |
+ addBeforeObserver: function(key, target, method) { | |
+ Ember['default'].deprecate( | |
+ 'Before observers are deprecated and will be removed in a future release. If you want to keep track of previous values you have to implement it yourself.', | |
+ false, | |
+ { url: 'http://emberjs.com/guides/deprecations/#toc_beforeobserver' } | |
+ ); | |
observer.addBeforeObserver(this, key, target, method); | |
}, | |
/** | |
Adds an observer on a property. | |
- This is the core method used to register an observer for a property. | |
- Once you call this method, any time the key's value is set, your observer | |
+ | |
+ This is the core method used to register an observer for a property. | |
+ | |
+ Once you call this method, any time the key's value is set, your observer | |
will be notified. Note that the observers are triggered any time the | |
value is set, regardless of whether it has actually changed. Your | |
observer should be prepared to handle that. | |
- You can also pass an optional context parameter to this method. The | |
+ | |
+ You can also pass an optional context parameter to this method. The | |
context will be passed to your observer method whenever it is triggered. | |
Note that if you add the same target/method pair on a key multiple times | |
with different context parameters, your observer will only be called once | |
with the last context you passed. | |
- ### Observer Methods | |
- Observer methods you pass should generally have the following signature if | |
+ | |
+ ### Observer Methods | |
+ | |
+ Observer methods you pass should generally have the following signature if | |
you do not pass a `context` parameter: | |
- ```javascript | |
+ | |
+ ```javascript | |
fooDidChange: function(sender, key, value, rev) { }; | |
``` | |
- The sender is the object that changed. The key is the property that | |
+ | |
+ The sender is the object that changed. The key is the property that | |
changes. The value property is currently reserved and unused. The rev | |
is the last property revision of the object when it changed, which you can | |
use to detect if the key value has really changed or not. | |
- If you pass a `context` parameter, the context will be passed before the | |
+ | |
+ If you pass a `context` parameter, the context will be passed before the | |
revision like so: | |
- ```javascript | |
+ | |
+ ```javascript | |
fooDidChange: function(sender, key, value, context, rev) { }; | |
``` | |
- Usually you will not need the value, context or revision parameters at | |
+ | |
+ Usually you will not need the value, context or revision parameters at | |
the end. In this case, it is common to write observer methods that take | |
only a sender and key value as parameters or, if you aren't interested in | |
any of these values, to write an observer that has no parameters at all. | |
- @method addObserver | |
+ | |
+ @method addObserver | |
@param {String} key The key to observer | |
@param {Object} target The target object to invoke | |
@param {String|Function} method The method to invoke. | |
*/ | |
- addObserver: function (key, target, method) { | |
+ addObserver: function(key, target, method) { | |
observer.addObserver(this, key, target, method); | |
}, | |
@@ -29368,12 +30660,13 @@ | |
Remove an observer you have previously registered on this object. Pass | |
the same key, target, and method you passed to `addObserver()` and your | |
target will no longer receive notifications. | |
- @method removeObserver | |
+ | |
+ @method removeObserver | |
@param {String} key The key to observer | |
@param {Object} target The target object to invoke | |
@param {String|Function} method The method to invoke. | |
*/ | |
- removeObserver: function (key, target, method) { | |
+ removeObserver: function(key, target, method) { | |
observer.removeObserver(this, key, target, method); | |
}, | |
@@ -29382,65 +30675,68 @@ | |
particular key. You can use this method to potentially defer performing | |
an expensive action until someone begins observing a particular property | |
on the object. | |
- @method hasObserverFor | |
+ | |
+ @method hasObserverFor | |
@param {String} key Key to check | |
@return {Boolean} | |
*/ | |
- hasObserverFor: function (key) { | |
- return events.hasListeners(this, key + ":change"); | |
+ hasObserverFor: function(key) { | |
+ return events.hasListeners(this, key+':change'); | |
}, | |
/** | |
Retrieves the value of a property, or a default value in the case that the | |
property returns `undefined`. | |
- ```javascript | |
+ | |
+ ```javascript | |
person.getWithDefault('lastName', 'Doe'); | |
``` | |
- @method getWithDefault | |
+ | |
+ @method getWithDefault | |
@param {String} keyName The name of the property to retrieve | |
@param {Object} defaultValue The value to return if the property value is undefined | |
@return {Object} The property value or the defaultValue. | |
*/ | |
- getWithDefault: function (keyName, defaultValue) { | |
+ getWithDefault: function(keyName, defaultValue) { | |
return property_get.getWithDefault(this, keyName, defaultValue); | |
}, | |
/** | |
Set the value of a property to the current value plus some amount. | |
- ```javascript | |
+ | |
+ ```javascript | |
person.incrementProperty('age'); | |
team.incrementProperty('score', 2); | |
``` | |
- @method incrementProperty | |
+ | |
+ @method incrementProperty | |
@param {String} keyName The name of the property to increment | |
@param {Number} increment The amount to increment by. Defaults to 1 | |
@return {Number} The new property value | |
*/ | |
- incrementProperty: function (keyName, increment) { | |
- if (isNone['default'](increment)) { | |
- increment = 1; | |
- } | |
- Ember['default'].assert("Must pass a numeric value to incrementProperty", !isNaN(parseFloat(increment)) && isFinite(increment)); | |
+ incrementProperty: function(keyName, increment) { | |
+ if (isNone['default'](increment)) { increment = 1; } | |
+ Ember['default'].assert("Must pass a numeric value to incrementProperty", (!isNaN(parseFloat(increment)) && isFinite(increment))); | |
property_set.set(this, keyName, (parseFloat(property_get.get(this, keyName)) || 0) + increment); | |
return property_get.get(this, keyName); | |
}, | |
/** | |
Set the value of a property to the current value minus some amount. | |
- ```javascript | |
+ | |
+ ```javascript | |
player.decrementProperty('lives'); | |
orc.decrementProperty('health', 5); | |
``` | |
- @method decrementProperty | |
+ | |
+ @method decrementProperty | |
@param {String} keyName The name of the property to decrement | |
@param {Number} decrement The amount to decrement by. Defaults to 1 | |
@return {Number} The new property value | |
*/ | |
- decrementProperty: function (keyName, decrement) { | |
- if (isNone['default'](decrement)) { | |
- decrement = 1; | |
- } | |
- Ember['default'].assert("Must pass a numeric value to decrementProperty", !isNaN(parseFloat(decrement)) && isFinite(decrement)); | |
+ decrementProperty: function(keyName, decrement) { | |
+ if (isNone['default'](decrement)) { decrement = 1; } | |
+ Ember['default'].assert("Must pass a numeric value to decrementProperty", (!isNaN(parseFloat(decrement)) && isFinite(decrement))); | |
property_set.set(this, keyName, (property_get.get(this, keyName) || 0) - decrement); | |
return property_get.get(this, keyName); | |
}, | |
@@ -29448,14 +30744,16 @@ | |
/** | |
Set the value of a boolean property to the opposite of its | |
current value. | |
- ```javascript | |
+ | |
+ ```javascript | |
starship.toggleProperty('warpDriveEngaged'); | |
``` | |
- @method toggleProperty | |
+ | |
+ @method toggleProperty | |
@param {String} keyName The name of the property to toggle | |
@return {Object} The new property value | |
*/ | |
- toggleProperty: function (keyName) { | |
+ toggleProperty: function(keyName) { | |
property_set.set(this, keyName, !property_get.get(this, keyName)); | |
return property_get.get(this, keyName); | |
}, | |
@@ -29465,16 +30763,17 @@ | |
This allows you to inspect the value of a computed property | |
without accidentally invoking it if it is intended to be | |
generated lazily. | |
- @method cacheFor | |
+ | |
+ @method cacheFor | |
@param {String} keyName | |
@return {Object} The cached value of the computed property, if any | |
*/ | |
- cacheFor: function (keyName) { | |
+ cacheFor: function(keyName) { | |
return computed.cacheFor(this, keyName); | |
}, | |
// intended for debugging purposes | |
- observersForKey: function (keyName) { | |
+ observersForKey: function(keyName) { | |
return observer.observersFor(this, keyName); | |
} | |
}); | |
@@ -29498,13 +30797,13 @@ | |
isRejected: false | |
}); | |
- return promise.then(function (value) { | |
+ return promise.then(function(value) { | |
setProperties['default'](proxy, { | |
content: value, | |
isFulfilled: true | |
}); | |
return value; | |
- }, function (reason) { | |
+ }, function(reason) { | |
setProperties['default'](proxy, { | |
reason: reason, | |
isRejected: true | |
@@ -29582,52 +30881,61 @@ | |
/** | |
If the proxied promise is rejected this will contain the reason | |
provided. | |
- @property reason | |
+ | |
+ @property reason | |
@default null | |
*/ | |
- reason: null, | |
+ reason: null, | |
/** | |
Once the proxied promise has settled this will become `false`. | |
- @property isPending | |
+ | |
+ @property isPending | |
@default true | |
*/ | |
- isPending: not("isSettled").readOnly(), | |
+ isPending: not('isSettled').readOnly(), | |
/** | |
Once the proxied promise has settled this will become `true`. | |
- @property isSettled | |
+ | |
+ @property isSettled | |
@default false | |
*/ | |
- isSettled: or("isRejected", "isFulfilled").readOnly(), | |
+ isSettled: or('isRejected', 'isFulfilled').readOnly(), | |
/** | |
Will become `true` if the proxied promise is rejected. | |
- @property isRejected | |
+ | |
+ @property isRejected | |
@default false | |
*/ | |
- isRejected: false, | |
+ isRejected: false, | |
/** | |
Will become `true` if the proxied promise is fulfilled. | |
- @property isFulfilled | |
+ | |
+ @property isFulfilled | |
@default false | |
*/ | |
isFulfilled: false, | |
/** | |
The promise whose fulfillment value is being proxied by this object. | |
- This property must be specified upon creation, and should not be | |
+ | |
+ This property must be specified upon creation, and should not be | |
changed once created. | |
- Example: | |
- ```javascript | |
+ | |
+ Example: | |
+ | |
+ ```javascript | |
Ember.ObjectController.extend(Ember.PromiseProxyMixin).create({ | |
promise: <thenable> | |
}); | |
``` | |
- @property promise | |
+ | |
+ @property promise | |
*/ | |
- promise: computed.computed(function (key, promise) { | |
+ promise: computed.computed(function(key, promise) { | |
if (arguments.length === 2) { | |
return tap(this, promise); | |
} else { | |
@@ -29637,38 +30945,44 @@ | |
/** | |
An alias to the proxied promise's `then`. | |
- See RSVP.Promise.then. | |
- @method then | |
+ | |
+ See RSVP.Promise.then. | |
+ | |
+ @method then | |
@param {Function} callback | |
@return {RSVP.Promise} | |
*/ | |
- then: promiseAlias("then"), | |
+ then: promiseAlias('then'), | |
/** | |
An alias to the proxied promise's `catch`. | |
- See RSVP.Promise.catch. | |
- @method catch | |
+ | |
+ See RSVP.Promise.catch. | |
+ | |
+ @method catch | |
@param {Function} callback | |
@return {RSVP.Promise} | |
@since 1.3.0 | |
*/ | |
- "catch": promiseAlias("catch"), | |
+ 'catch': promiseAlias('catch'), | |
/** | |
An alias to the proxied promise's `finally`. | |
- See RSVP.Promise.finally. | |
- @method finally | |
+ | |
+ See RSVP.Promise.finally. | |
+ | |
+ @method finally | |
@param {Function} callback | |
@return {RSVP.Promise} | |
@since 1.3.0 | |
*/ | |
- "finally": promiseAlias("finally") | |
+ 'finally': promiseAlias('finally') | |
}); | |
function promiseAlias(name) { | |
return function () { | |
- var promise = property_get.get(this, "promise"); | |
+ var promise = property_get.get(this, 'promise'); | |
return promise[name].apply(promise, arguments); | |
}; | |
} | |
@@ -29687,9 +31001,11 @@ | |
/** | |
Specifies which properties dictate the `arrangedContent`'s sort order. | |
- When specifying multiple properties the sorting will use properties | |
+ | |
+ When specifying multiple properties the sorting will use properties | |
from the `sortProperties` array prioritized from first to last. | |
- @property {Array} sortProperties | |
+ | |
+ @property {Array} sortProperties | |
*/ | |
sortProperties: null, | |
@@ -29697,7 +31013,8 @@ | |
Specifies the `arrangedContent`'s sort direction. | |
Sorts the content in ascending order by default. Set to `false` to | |
use descending order. | |
- @property {Boolean} sortAscending | |
+ | |
+ @property {Boolean} sortAscending | |
@default true | |
*/ | |
sortAscending: true, | |
@@ -29706,35 +31023,38 @@ | |
The function used to compare two values. You can override this if you | |
want to do custom comparisons. Functions must be of the type expected by | |
Array#sort, i.e., | |
- * return 0 if the two parameters are equal, | |
+ | |
+ * return 0 if the two parameters are equal, | |
* return a negative value if the first parameter is smaller than the second or | |
* return a positive value otherwise: | |
- ```javascript | |
+ | |
+ ```javascript | |
function(x, y) { // These are assumed to be integers | |
if (x === y) | |
return 0; | |
return x < y ? -1 : 1; | |
} | |
``` | |
- @property sortFunction | |
+ | |
+ @property sortFunction | |
@type {Function} | |
@default Ember.compare | |
*/ | |
sortFunction: compare['default'], | |
- orderBy: function (item1, item2) { | |
+ orderBy: function(item1, item2) { | |
var result = 0; | |
- var sortProperties = property_get.get(this, "sortProperties"); | |
- var sortAscending = property_get.get(this, "sortAscending"); | |
- var sortFunction = property_get.get(this, "sortFunction"); | |
+ var sortProperties = property_get.get(this, 'sortProperties'); | |
+ var sortAscending = property_get.get(this, 'sortAscending'); | |
+ var sortFunction = property_get.get(this, 'sortFunction'); | |
Ember['default'].assert("you need to define `sortProperties`", !!sortProperties); | |
- enumerable_utils.forEach(sortProperties, function (propertyName) { | |
+ enumerable_utils.forEach(sortProperties, function(propertyName) { | |
if (result === 0) { | |
result = sortFunction.call(this, property_get.get(item1, propertyName), property_get.get(item2, propertyName)); | |
- if (result !== 0 && !sortAscending) { | |
- result = -1 * result; | |
+ if ((result !== 0) && !sortAscending) { | |
+ result = (-1) * result; | |
} | |
} | |
}, this); | |
@@ -29742,14 +31062,14 @@ | |
return result; | |
}, | |
- destroy: function () { | |
- var content = property_get.get(this, "content"); | |
- var sortProperties = property_get.get(this, "sortProperties"); | |
+ destroy: function() { | |
+ var content = property_get.get(this, 'content'); | |
+ var sortProperties = property_get.get(this, 'sortProperties'); | |
if (content && sortProperties) { | |
- enumerable_utils.forEach(content, function (item) { | |
- enumerable_utils.forEach(sortProperties, function (sortProperty) { | |
- observer.removeObserver(item, sortProperty, this, "contentItemSortPropertyDidChange"); | |
+ enumerable_utils.forEach(content, function(item) { | |
+ enumerable_utils.forEach(sortProperties, function(sortProperty) { | |
+ observer.removeObserver(item, sortProperty, this, 'contentItemSortPropertyDidChange'); | |
}, this); | |
}, this); | |
} | |
@@ -29757,27 +31077,28 @@ | |
return this._super.apply(this, arguments); | |
}, | |
- isSorted: computed_macros.notEmpty("sortProperties"), | |
+ isSorted: computed_macros.notEmpty('sortProperties'), | |
/** | |
Overrides the default `arrangedContent` from `ArrayProxy` in order to sort by `sortFunction`. | |
Also sets up observers for each `sortProperty` on each item in the content Array. | |
- @property arrangedContent | |
+ | |
+ @property arrangedContent | |
*/ | |
- arrangedContent: computed.computed("content", "sortProperties.@each", function (key, value) { | |
- var content = property_get.get(this, "content"); | |
- var isSorted = property_get.get(this, "isSorted"); | |
- var sortProperties = property_get.get(this, "sortProperties"); | |
+ arrangedContent: computed.computed('content', 'sortProperties.@each', function(key, value) { | |
+ var content = property_get.get(this, 'content'); | |
+ var isSorted = property_get.get(this, 'isSorted'); | |
+ var sortProperties = property_get.get(this, 'sortProperties'); | |
var self = this; | |
if (content && isSorted) { | |
content = content.slice(); | |
- content.sort(function (item1, item2) { | |
+ content.sort(function(item1, item2) { | |
return self.orderBy(item1, item2); | |
}); | |
- enumerable_utils.forEach(content, function (item) { | |
- enumerable_utils.forEach(sortProperties, function (sortProperty) { | |
- observer.addObserver(item, sortProperty, this, "contentItemSortPropertyDidChange"); | |
+ enumerable_utils.forEach(content, function(item) { | |
+ enumerable_utils.forEach(sortProperties, function(sortProperty) { | |
+ observer.addObserver(item, sortProperty, this, 'contentItemSortPropertyDidChange'); | |
}, this); | |
}, this); | |
return Ember['default'].A(content); | |
@@ -29786,14 +31107,14 @@ | |
return content; | |
}), | |
- _contentWillChange: mixin.beforeObserver("content", function () { | |
- var content = property_get.get(this, "content"); | |
- var sortProperties = property_get.get(this, "sortProperties"); | |
+ _contentWillChange: mixin.beforeObserver('content', function() { | |
+ var content = property_get.get(this, 'content'); | |
+ var sortProperties = property_get.get(this, 'sortProperties'); | |
if (content && sortProperties) { | |
- enumerable_utils.forEach(content, function (item) { | |
- enumerable_utils.forEach(sortProperties, function (sortProperty) { | |
- observer.removeObserver(item, sortProperty, this, "contentItemSortPropertyDidChange"); | |
+ enumerable_utils.forEach(content, function(item) { | |
+ enumerable_utils.forEach(sortProperties, function(sortProperty) { | |
+ observer.removeObserver(item, sortProperty, this, 'contentItemSortPropertyDidChange'); | |
}, this); | |
}, this); | |
} | |
@@ -29801,38 +31122,38 @@ | |
this._super.apply(this, arguments); | |
}), | |
- sortPropertiesWillChange: mixin.beforeObserver("sortProperties", function () { | |
+ sortPropertiesWillChange: mixin.beforeObserver('sortProperties', function() { | |
this._lastSortAscending = undefined; | |
}), | |
- sortPropertiesDidChange: mixin.observer("sortProperties", function () { | |
+ sortPropertiesDidChange: mixin.observer('sortProperties', function() { | |
this._lastSortAscending = undefined; | |
}), | |
- sortAscendingWillChange: mixin.beforeObserver("sortAscending", function () { | |
- this._lastSortAscending = property_get.get(this, "sortAscending"); | |
+ sortAscendingWillChange: mixin.beforeObserver('sortAscending', function() { | |
+ this._lastSortAscending = property_get.get(this, 'sortAscending'); | |
}), | |
- sortAscendingDidChange: mixin.observer("sortAscending", function () { | |
- if (this._lastSortAscending !== undefined && property_get.get(this, "sortAscending") !== this._lastSortAscending) { | |
- var arrangedContent = property_get.get(this, "arrangedContent"); | |
+ sortAscendingDidChange: mixin.observer('sortAscending', function() { | |
+ if (this._lastSortAscending !== undefined && property_get.get(this, 'sortAscending') !== this._lastSortAscending) { | |
+ var arrangedContent = property_get.get(this, 'arrangedContent'); | |
arrangedContent.reverseObjects(); | |
} | |
}), | |
- contentArrayWillChange: function (array, idx, removedCount, addedCount) { | |
- var isSorted = property_get.get(this, "isSorted"); | |
+ contentArrayWillChange: function(array, idx, removedCount, addedCount) { | |
+ var isSorted = property_get.get(this, 'isSorted'); | |
if (isSorted) { | |
- var arrangedContent = property_get.get(this, "arrangedContent"); | |
- var removedObjects = array.slice(idx, idx + removedCount); | |
- var sortProperties = property_get.get(this, "sortProperties"); | |
+ var arrangedContent = property_get.get(this, 'arrangedContent'); | |
+ var removedObjects = array.slice(idx, idx+removedCount); | |
+ var sortProperties = property_get.get(this, 'sortProperties'); | |
- enumerable_utils.forEach(removedObjects, function (item) { | |
+ enumerable_utils.forEach(removedObjects, function(item) { | |
arrangedContent.removeObject(item); | |
- enumerable_utils.forEach(sortProperties, function (sortProperty) { | |
- observer.removeObserver(item, sortProperty, this, "contentItemSortPropertyDidChange"); | |
+ enumerable_utils.forEach(sortProperties, function(sortProperty) { | |
+ observer.removeObserver(item, sortProperty, this, 'contentItemSortPropertyDidChange'); | |
}, this); | |
}, this); | |
} | |
@@ -29840,18 +31161,18 @@ | |
return this._super(array, idx, removedCount, addedCount); | |
}, | |
- contentArrayDidChange: function (array, idx, removedCount, addedCount) { | |
- var isSorted = property_get.get(this, "isSorted"); | |
- var sortProperties = property_get.get(this, "sortProperties"); | |
+ contentArrayDidChange: function(array, idx, removedCount, addedCount) { | |
+ var isSorted = property_get.get(this, 'isSorted'); | |
+ var sortProperties = property_get.get(this, 'sortProperties'); | |
if (isSorted) { | |
- var addedObjects = array.slice(idx, idx + addedCount); | |
+ var addedObjects = array.slice(idx, idx+addedCount); | |
- enumerable_utils.forEach(addedObjects, function (item) { | |
+ enumerable_utils.forEach(addedObjects, function(item) { | |
this.insertItemSorted(item); | |
- enumerable_utils.forEach(sortProperties, function (sortProperty) { | |
- observer.addObserver(item, sortProperty, this, "contentItemSortPropertyDidChange"); | |
+ enumerable_utils.forEach(sortProperties, function(sortProperty) { | |
+ observer.addObserver(item, sortProperty, this, 'contentItemSortPropertyDidChange'); | |
}, this); | |
}, this); | |
} | |
@@ -29859,16 +31180,16 @@ | |
return this._super(array, idx, removedCount, addedCount); | |
}, | |
- insertItemSorted: function (item) { | |
- var arrangedContent = property_get.get(this, "arrangedContent"); | |
- var length = property_get.get(arrangedContent, "length"); | |
+ insertItemSorted: function(item) { | |
+ var arrangedContent = property_get.get(this, 'arrangedContent'); | |
+ var length = property_get.get(arrangedContent, 'length'); | |
var idx = this._binarySearch(item, 0, length); | |
arrangedContent.insertAt(idx, item); | |
}, | |
- contentItemSortPropertyDidChange: function (item) { | |
- var arrangedContent = property_get.get(this, "arrangedContent"); | |
+ contentItemSortPropertyDidChange: function(item) { | |
+ var arrangedContent = property_get.get(this, 'arrangedContent'); | |
var oldIndex = arrangedContent.indexOf(item); | |
var leftItem = arrangedContent.objectAt(oldIndex - 1); | |
var rightItem = arrangedContent.objectAt(oldIndex + 1); | |
@@ -29881,14 +31202,14 @@ | |
} | |
}, | |
- _binarySearch: function (item, low, high) { | |
+ _binarySearch: function(item, low, high) { | |
var mid, midItem, res, arrangedContent; | |
if (low === high) { | |
return low; | |
} | |
- arrangedContent = property_get.get(this, "arrangedContent"); | |
+ arrangedContent = property_get.get(this, 'arrangedContent'); | |
mid = low + Math.floor((high - low) / 2); | |
midItem = arrangedContent.objectAt(mid); | |
@@ -29896,7 +31217,7 @@ | |
res = this.orderBy(midItem, item); | |
if (res < 0) { | |
- return this._binarySearch(item, mid + 1, high); | |
+ return this._binarySearch(item, mid+1, high); | |
} else if (res > 0) { | |
return this._binarySearch(item, low, mid); | |
} | |
@@ -29919,8 +31240,8 @@ | |
action: null, | |
actionContext: null, | |
- targetObject: computed.computed(function () { | |
- var target = property_get.get(this, "target"); | |
+ targetObject: computed.computed(function() { | |
+ var target = property_get.get(this, 'target'); | |
if (utils.typeOf(target) === "string") { | |
var value = property_get.get(this, target); | |
@@ -29932,26 +31253,25 @@ | |
} else { | |
return target; | |
} | |
- }).property("target"), | |
+ }).property('target'), | |
- actionContextObject: computed.computed(function () { | |
- var actionContext = property_get.get(this, "actionContext"); | |
+ actionContextObject: computed.computed(function() { | |
+ var actionContext = property_get.get(this, 'actionContext'); | |
if (utils.typeOf(actionContext) === "string") { | |
var value = property_get.get(this, actionContext); | |
- if (value === undefined) { | |
- value = property_get.get(Ember['default'].lookup, actionContext); | |
- } | |
+ if (value === undefined) { value = property_get.get(Ember['default'].lookup, actionContext); } | |
return value; | |
} else { | |
return actionContext; | |
} | |
- }).property("actionContext"), | |
+ }).property('actionContext'), | |
/** | |
Send an `action` with an `actionContext` to a `target`. The action, actionContext | |
and target will be retrieved from properties of the object. For example: | |
- ```javascript | |
+ | |
+ ```javascript | |
App.SaveButtonView = Ember.View.extend(Ember.TargetActionSupport, { | |
target: Ember.computed.alias('controller'), | |
action: 'save', | |
@@ -29962,9 +31282,11 @@ | |
} | |
}); | |
``` | |
- The `target`, `action`, and `actionContext` can be provided as properties of | |
+ | |
+ The `target`, `action`, and `actionContext` can be provided as properties of | |
an optional object argument to `triggerAction` as well. | |
- ```javascript | |
+ | |
+ ```javascript | |
App.SaveButtonView = Ember.View.extend(Ember.TargetActionSupport, { | |
click: function() { | |
this.triggerAction({ | |
@@ -29976,10 +31298,12 @@ | |
} | |
}); | |
``` | |
- The `actionContext` defaults to the object you are mixing `TargetActionSupport` into. | |
+ | |
+ The `actionContext` defaults to the object you are mixing `TargetActionSupport` into. | |
But `target` and `action` must be specified either as properties or with the argument | |
to `triggerAction`, or a combination: | |
- ```javascript | |
+ | |
+ ```javascript | |
App.SaveButtonView = Ember.View.extend(Ember.TargetActionSupport, { | |
target: Ember.computed.alias('controller'), | |
click: function() { | |
@@ -29990,27 +31314,26 @@ | |
} | |
}); | |
``` | |
- @method triggerAction | |
+ | |
+ @method triggerAction | |
@param opts {Hash} (optional, with the optional keys action, target and/or actionContext) | |
@return {Boolean} true if the action was sent successfully and did not return false | |
*/ | |
- triggerAction: function (opts) { | |
+ triggerAction: function(opts) { | |
opts = opts || {}; | |
- var action = opts.action || property_get.get(this, "action"); | |
- var target = opts.target || property_get.get(this, "targetObject"); | |
+ var action = opts.action || property_get.get(this, 'action'); | |
+ var target = opts.target || property_get.get(this, 'targetObject'); | |
var actionContext = opts.actionContext; | |
function args(options, actionName) { | |
var ret = []; | |
- if (actionName) { | |
- ret.push(actionName); | |
- } | |
+ if (actionName) { ret.push(actionName); } | |
return ret.concat(options); | |
} | |
- if (typeof actionContext === "undefined") { | |
- actionContext = property_get.get(this, "actionContextObject") || this; | |
+ if (typeof actionContext === 'undefined') { | |
+ actionContext = property_get.get(this, 'actionContextObject') || this; | |
} | |
if (target && action) { | |
@@ -30019,7 +31342,7 @@ | |
if (target.send) { | |
ret = target.send.apply(target, args(actionContext, action)); | |
} else { | |
- Ember['default'].assert("The action '" + action + "' did not exist on " + target, typeof target[action] === "function"); | |
+ Ember['default'].assert("The action '" + action + "' did not exist on " + target, typeof target[action] === 'function'); | |
ret = target[action].apply(target, args(actionContext)); | |
} | |
@@ -30051,9 +31374,7 @@ | |
var OUT_OF_RANGE_EXCEPTION = "Index out of range"; | |
var EMPTY = []; | |
- function K() { | |
- return this; | |
- } | |
+ function K() { return this; } | |
/** | |
An ArrayProxy wraps any other object that implements `Ember.Array` and/or | |
@@ -30098,7 +31419,8 @@ | |
/** | |
The content array. Must be an object that implements `Ember.Array` and/or | |
`Ember.MutableArray.` | |
- @property content | |
+ | |
+ @property content | |
@type Ember.Array | |
*/ | |
content: null, | |
@@ -30107,73 +31429,84 @@ | |
The array that the proxy pretends to be. In the default `ArrayProxy` | |
implementation, this and `content` are the same. Subclasses of `ArrayProxy` | |
can override this property to provide things like sorting and filtering. | |
- @property arrangedContent | |
+ | |
+ @property arrangedContent | |
*/ | |
- arrangedContent: alias['default']("content"), | |
+ arrangedContent: alias['default']('content'), | |
/** | |
Should actually retrieve the object at the specified index from the | |
content. You can override this method in subclasses to transform the | |
content item to something new. | |
- This method will only be called if content is non-`null`. | |
- @method objectAtContent | |
+ | |
+ This method will only be called if content is non-`null`. | |
+ | |
+ @method objectAtContent | |
@param {Number} idx The index to retrieve. | |
@return {Object} the value or undefined if none found | |
*/ | |
- objectAtContent: function (idx) { | |
- return property_get.get(this, "arrangedContent").objectAt(idx); | |
+ objectAtContent: function(idx) { | |
+ return property_get.get(this, 'arrangedContent').objectAt(idx); | |
}, | |
/** | |
Should actually replace the specified objects on the content array. | |
You can override this method in subclasses to transform the content item | |
into something new. | |
- This method will only be called if content is non-`null`. | |
- @method replaceContent | |
+ | |
+ This method will only be called if content is non-`null`. | |
+ | |
+ @method replaceContent | |
@param {Number} idx The starting index | |
@param {Number} amt The number of items to remove from the content. | |
@param {Array} objects Optional array of objects to insert or null if no | |
objects. | |
@return {void} | |
*/ | |
- replaceContent: function (idx, amt, objects) { | |
- property_get.get(this, "content").replace(idx, amt, objects); | |
+ replaceContent: function(idx, amt, objects) { | |
+ property_get.get(this, 'content').replace(idx, amt, objects); | |
}, | |
/** | |
Invoked when the content property is about to change. Notifies observers that the | |
entire array content will change. | |
- @private | |
+ | |
+ @private | |
@method _contentWillChange | |
*/ | |
- _contentWillChange: mixin.beforeObserver("content", function () { | |
+ _contentWillChange: mixin.beforeObserver('content', function() { | |
this._teardownContent(); | |
}), | |
- _teardownContent: function () { | |
- var content = property_get.get(this, "content"); | |
+ _teardownContent: function() { | |
+ var content = property_get.get(this, 'content'); | |
if (content) { | |
content.removeArrayObserver(this, { | |
- willChange: "contentArrayWillChange", | |
- didChange: "contentArrayDidChange" | |
+ willChange: 'contentArrayWillChange', | |
+ didChange: 'contentArrayDidChange' | |
}); | |
} | |
}, | |
/** | |
Override to implement content array `willChange` observer. | |
- @method contentArrayWillChange | |
- @param {Ember.Array} contentArray the content array | |
+ | |
+ @method contentArrayWillChange | |
+ | |
+ @param {Ember.Array} contentArray the content array | |
@param {Number} start starting index of the change | |
@param {Number} removeCount count of items removed | |
@param {Number} addCount count of items added | |
- */ | |
+ | |
+ */ | |
contentArrayWillChange: K, | |
/** | |
Override to implement content array `didChange` observer. | |
- @method contentArrayDidChange | |
- @param {Ember.Array} contentArray the content array | |
+ | |
+ @method contentArrayDidChange | |
+ | |
+ @param {Ember.Array} contentArray the content array | |
@param {Number} start starting index of the change | |
@param {Number} removeCount count of items removed | |
@param {Number} addCount count of items added | |
@@ -30183,33 +31516,36 @@ | |
/** | |
Invoked when the content property changes. Notifies observers that the | |
entire array content has changed. | |
- @private | |
+ | |
+ @private | |
@method _contentDidChange | |
*/ | |
- _contentDidChange: mixin.observer("content", function () { | |
- var content = property_get.get(this, "content"); | |
+ _contentDidChange: mixin.observer('content', function() { | |
+ var content = property_get.get(this, 'content'); | |
Ember['default'].assert("Can't set ArrayProxy's content to itself", content !== this); | |
this._setupContent(); | |
}), | |
- _setupContent: function () { | |
- var content = property_get.get(this, "content"); | |
+ _setupContent: function() { | |
+ var content = property_get.get(this, 'content'); | |
if (content) { | |
- Ember['default'].assert(string.fmt("ArrayProxy expects an Array or " + "Ember.ArrayProxy, but you passed %@", [typeof content]), utils.isArray(content) || content.isDestroyed); | |
+ Ember['default'].assert(string.fmt('ArrayProxy expects an Array or ' + | |
+ 'Ember.ArrayProxy, but you passed %@', [typeof content]), | |
+ utils.isArray(content) || content.isDestroyed); | |
content.addArrayObserver(this, { | |
- willChange: "contentArrayWillChange", | |
- didChange: "contentArrayDidChange" | |
+ willChange: 'contentArrayWillChange', | |
+ didChange: 'contentArrayDidChange' | |
}); | |
} | |
}, | |
- _arrangedContentWillChange: mixin.beforeObserver("arrangedContent", function () { | |
- var arrangedContent = property_get.get(this, "arrangedContent"); | |
- var len = arrangedContent ? property_get.get(arrangedContent, "length") : 0; | |
+ _arrangedContentWillChange: mixin.beforeObserver('arrangedContent', function() { | |
+ var arrangedContent = property_get.get(this, 'arrangedContent'); | |
+ var len = arrangedContent ? property_get.get(arrangedContent, 'length') : 0; | |
this.arrangedContentArrayWillChange(this, 0, len, undefined); | |
this.arrangedContentWillChange(this); | |
@@ -30217,9 +31553,9 @@ | |
this._teardownArrangedContent(arrangedContent); | |
}), | |
- _arrangedContentDidChange: mixin.observer("arrangedContent", function () { | |
- var arrangedContent = property_get.get(this, "arrangedContent"); | |
- var len = arrangedContent ? property_get.get(arrangedContent, "length") : 0; | |
+ _arrangedContentDidChange: mixin.observer('arrangedContent', function() { | |
+ var arrangedContent = property_get.get(this, 'arrangedContent'); | |
+ var len = arrangedContent ? property_get.get(arrangedContent, 'length') : 0; | |
Ember['default'].assert("Can't set ArrayProxy's content to itself", arrangedContent !== this); | |
@@ -30229,26 +31565,28 @@ | |
this.arrangedContentArrayDidChange(this, 0, undefined, len); | |
}), | |
- _setupArrangedContent: function () { | |
- var arrangedContent = property_get.get(this, "arrangedContent"); | |
+ _setupArrangedContent: function() { | |
+ var arrangedContent = property_get.get(this, 'arrangedContent'); | |
if (arrangedContent) { | |
- Ember['default'].assert(string.fmt("ArrayProxy expects an Array or " + "Ember.ArrayProxy, but you passed %@", [typeof arrangedContent]), utils.isArray(arrangedContent) || arrangedContent.isDestroyed); | |
+ Ember['default'].assert(string.fmt('ArrayProxy expects an Array or ' + | |
+ 'Ember.ArrayProxy, but you passed %@', [typeof arrangedContent]), | |
+ utils.isArray(arrangedContent) || arrangedContent.isDestroyed); | |
arrangedContent.addArrayObserver(this, { | |
- willChange: "arrangedContentArrayWillChange", | |
- didChange: "arrangedContentArrayDidChange" | |
+ willChange: 'arrangedContentArrayWillChange', | |
+ didChange: 'arrangedContentArrayDidChange' | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment