dist/ember.prod.js in ember-source-1.4.0.beta.6 vs dist/ember.prod.js in ember-source-1.4.0
- old
+ new
@@ -3,11 +3,11 @@
* @copyright Copyright 2011-2014 Tilde Inc. and contributors
* Portions Copyright 2006-2011 Strobe Inc.
* Portions Copyright 2008-2011 Apple Inc. All rights reserved.
* @license Licensed under MIT license
* See https://raw.github.com/emberjs/ember.js/master/LICENSE
- * @version 1.4.0-beta.6
+ * @version 1.4.0
*/
(function() {
var define, requireModule, require, requirejs;
@@ -86,11 +86,11 @@
The core Runtime framework is based on the jQuery API with a number of
performance optimizations.
@class Ember
@static
- @version 1.4.0-beta.6
+ @version 1.4.0
*/
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.
@@ -113,14 +113,14 @@
/**
@property VERSION
@type String
- @default '1.4.0-beta.6'
+ @default '1.4.0'
@static
*/
-Ember.VERSION = '1.4.0-beta.6';
+Ember.VERSION = '1.4.0';
/**
Standard environmental variables. You can define these in a global `EmberENV`
variable before loading Ember to control various configuration settings.
@@ -4006,57 +4006,55 @@
})();
(function() {
-
- /**
- @module ember-metal
+/**
+ @module ember-metal
*/
- var forEach = Ember.EnumerableUtils.forEach,
- BRACE_EXPANSION = /^((?:[^\.]*\.)*)\{(.*)\}$/;
+var forEach = Ember.EnumerableUtils.forEach,
+BRACE_EXPANSION = /^((?:[^\.]*\.)*)\{(.*)\}$/;
- /**
- Expands `pattern`, invoking `callback` for each expansion.
+/**
+ Expands `pattern`, invoking `callback` for each expansion.
- The only pattern supported is brace-expansion, anything else will be passed
- once to `callback` directly. Brace expansion can only appear at the end of a
- pattern, for example as the last item in a chain.
+ The only pattern supported is brace-expansion, anything else will be passed
+ once to `callback` directly. Brace expansion can only appear at the end of a
+ pattern, for example as the last item in a chain.
- Example
- ```js
- function echo(arg){ console.log(arg); }
+ Example
+ ```js
+ function echo(arg){ console.log(arg); }
- Ember.expandProperties('foo.bar', echo); //=> 'foo.bar'
- Ember.expandProperties('{foo,bar}', echo); //=> 'foo', 'bar'
- Ember.expandProperties('foo.{bar,baz}', echo); //=> 'foo.bar', 'foo.baz'
- Ember.expandProperties('{foo,bar}.baz', echo); //=> '{foo,bar}.baz'
- ```
+ Ember.expandProperties('foo.bar', echo); //=> 'foo.bar'
+ Ember.expandProperties('{foo,bar}', echo); //=> 'foo', 'bar'
+ Ember.expandProperties('foo.{bar,baz}', echo); //=> 'foo.bar', 'foo.baz'
+ Ember.expandProperties('{foo,bar}.baz', echo); //=> '{foo,bar}.baz'
+ ```
- @method
- @private
- @param {string} pattern The property pattern to expand.
- @param {function} callback The callback to invoke. It is invoked once per
- expansion, and is passed the expansion.
+ @method
+ @private
+ @param {string} pattern The property pattern to expand.
+ @param {function} callback The callback to invoke. It is invoked once per
+ expansion, and is passed the expansion.
*/
- Ember.expandProperties = function (pattern, callback) {
- var match, prefix, list;
+Ember.expandProperties = function (pattern, callback) {
+ var match, prefix, list;
- if (match = BRACE_EXPANSION.exec(pattern)) {
- prefix = match[1];
- list = match[2];
+ if (match = BRACE_EXPANSION.exec(pattern)) {
+ prefix = match[1];
+ list = match[2];
- forEach(list.split(','), function (suffix) {
- callback(prefix + suffix);
- });
- } else {
- callback(pattern);
- }
- };
+ forEach(list.split(','), function (suffix) {
+ callback(prefix + suffix);
+ });
+ } else {
+ callback(pattern);
+ }
+};
-
})();
(function() {
@@ -4254,16 +4252,12 @@
o_create = Ember.create,
META_KEY = Ember.META_KEY,
watch = Ember.watch,
unwatch = Ember.unwatch;
+var expandProperties = Ember.expandProperties;
-
-
- var expandProperties = Ember.expandProperties;
-
-
// ..........................................................
// DEPENDENT KEYS
//
// data structure:
@@ -4526,21 +4520,20 @@
@chainable
*/
ComputedPropertyPrototype.property = function() {
var args;
-
- var addArg = function (property) {
- args.push(property);
- };
+ var addArg = function (property) {
+ args.push(property);
+ };
- args = [];
- for (var i = 0, l = arguments.length; i < l; i++) {
- expandProperties(arguments[i], addArg);
- }
+ args = [];
+ for (var i = 0, l = arguments.length; i < l; i++) {
+ expandProperties(arguments[i], addArg);
+ }
+
-
this._dependentKeys = args;
return this;
};
@@ -6266,11 +6259,10 @@
var args = slice.call(arguments);
args.unshift('actions');
Ember.run.schedule.apply(Ember.run, args);
};
-
/**
Provides a useful utility for when integrating with non-Ember libraries
that provide asynchronous callbacks.
Ember utilizes a run-loop to batch and coalesce changes. This works by
@@ -6307,18 +6299,17 @@
then it will be looked up on the passed target.
@param {Object} [args*] Any additional arguments you wish to pass to the method.
@return {Object} return value from invoking the passed function. Please note,
when called within an existing loop, no return value is possible.
*/
- Ember.run.bind = function(target, method /* args*/) {
- var args = arguments;
- return function() {
- return Ember.run.join.apply(Ember.run, args);
- };
+Ember.run.bind = function(target, method /* args*/) {
+ var args = arguments;
+ return function() {
+ return Ember.run.join.apply(Ember.run, args);
};
+};
-
Ember.run.backburner = backburner;
var run = Ember.run;
Ember.run.currentRunLoop = null;
@@ -7262,14 +7253,12 @@
defineProperty = Ember.defineProperty,
guidFor = Ember.guidFor,
metaFor = Ember.meta,
META_KEY = Ember.META_KEY;
+var expandProperties = Ember.expandProperties;
- var expandProperties = Ember.expandProperties;
-
-
function mixinsMeta(obj) {
var m = metaFor(obj, true), ret = m.mixins;
if (!ret) {
ret = m.mixins = {};
} else if (!m.hasOwnProperty('mixins')) {
@@ -7892,27 +7881,26 @@
*/
Ember.observer = function() {
var func = a_slice.call(arguments, -1)[0];
var paths;
-
- var addWatchedProperty = function (path) { paths.push(path); };
- var _paths = a_slice.call(arguments, 0, -1);
+ 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
+ if (typeof func !== "function") {
+ // revert to old, soft-deprecated argument ordering
- func = arguments[0];
- _paths = a_slice.call(arguments, 1);
- }
+ func = arguments[0];
+ _paths = a_slice.call(arguments, 1);
+ }
- paths = [];
+ paths = [];
- for (var i=0; i<_paths.length; ++i) {
- expandProperties(_paths[i], addWatchedProperty);
- }
-
+ for (var i=0; i<_paths.length; ++i) {
+ expandProperties(_paths[i], addWatchedProperty);
+ }
+
if (typeof func !== "function") {
throw new Ember.Error("Ember.observer called without a function");
}
func.__ember_observes__ = paths;
@@ -7995,28 +7983,27 @@
*/
Ember.beforeObserver = function() {
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);
+ var _paths = a_slice.call(arguments, 0, -1);
- if (typeof func !== "function") {
- // revert to old, soft-deprecated argument ordering
+ if (typeof func !== "function") {
+ // revert to old, soft-deprecated argument ordering
- func = arguments[0];
- _paths = a_slice.call(arguments, 1);
- }
+ func = arguments[0];
+ _paths = a_slice.call(arguments, 1);
+ }
- paths = [];
+ paths = [];
- for (var i=0; i<_paths.length; ++i) {
- expandProperties(_paths[i], addWatchedProperty);
- }
-
+ for (var i=0; i<_paths.length; ++i) {
+ expandProperties(_paths[i], addWatchedProperty);
+ }
+
if (typeof func !== "function") {
throw new Ember.Error("Ember.beforeObserver called without a function");
}
func.__ember_observesBefore__ = paths;
@@ -11700,11 +11687,10 @@
}
};
-
})();
(function() {
@@ -11724,11 +11710,10 @@
underscore = Ember.String.underscore,
capitalize = Ember.String.capitalize,
classify = Ember.String.classify;
-
if (Ember.EXTEND_PROTOTYPES === true || Ember.EXTEND_PROTOTYPES.String) {
/**
See [Ember.String.fmt](/api/classes/Ember.String.html#method_fmt).
@@ -11818,11 +11803,10 @@
String.prototype.capitalize = function() {
return capitalize(this);
};
-
}
})();
@@ -14921,14 +14905,12 @@
// testing, but there's no particular reason why it should be disallowed.
eachPropertyPattern = /^(.*)\.@each\.(.*)/,
doubleEachPropertyPattern = /(.*\.@each){2,}/,
arrayBracketPattern = /\.\[\]$/;
+var expandProperties = Ember.expandProperties;
- var expandProperties = Ember.expandProperties;
-
-
function get(obj, key) {
if (key === '@this') {
return obj;
}
@@ -15505,18 +15487,17 @@
if (doubleEachPropertyPattern.test(dependentKey)) {
throw new Ember.Error("Nested @each properties not supported: " + dependentKey);
} else if (match = eachPropertyPattern.exec(dependentKey)) {
dependentArrayKey = match[1];
-
- var itemPropertyKeyPattern = match[2],
- addItemPropertyKey = function (itemPropertyKey) {
- cp.itemPropertyKey(dependentArrayKey, itemPropertyKey);
- };
+ var itemPropertyKeyPattern = match[2],
+ addItemPropertyKey = function (itemPropertyKey) {
+ cp.itemPropertyKey(dependentArrayKey, itemPropertyKey);
+ };
- expandProperties(itemPropertyKeyPattern, addItemPropertyKey);
- propertyArgs.add(dependentArrayKey);
+ expandProperties(itemPropertyKeyPattern, addItemPropertyKey);
+ propertyArgs.add(dependentArrayKey);
} else {
propertyArgs.add(dependentKey);
}
});
@@ -16689,14 +16670,12 @@
@submodule ember-runtime
*/
var a_slice = Array.prototype.slice;
+var expandProperties = Ember.expandProperties;
- var expandProperties = Ember.expandProperties;
-
-
if (Ember.EXTEND_PROTOTYPES === true || Ember.EXTEND_PROTOTYPES.Function) {
/**
The `property` extension of Javascript's Function prototype is available
when `Ember.EXTEND_PROTOTYPES` or `Ember.EXTEND_PROTOTYPES.Function` is
@@ -16788,20 +16767,19 @@
@method observes
@for Function
*/
Function.prototype.observes = function() {
-
- var addWatchedProperty = function (obs) { watched.push(obs); };
- var watched = [];
+ var addWatchedProperty = function (obs) { watched.push(obs); };
+ var watched = [];
- for (var i=0; i<arguments.length; ++i) {
- expandProperties(arguments[i], addWatchedProperty);
- }
+ for (var i=0; i<arguments.length; ++i) {
+ expandProperties(arguments[i], addWatchedProperty);
+ }
- this.__ember_observes__ = watched;
-
+ this.__ember_observes__ = watched;
+
return this;
};
/**
The `observesImmediately` extension of Javascript's Function prototype is
@@ -16858,20 +16836,19 @@
@method observesBefore
@for Function
*/
Function.prototype.observesBefore = function() {
-
- var addWatchedProperty = function (obs) { watched.push(obs); };
- var watched = [];
+ var addWatchedProperty = function (obs) { watched.push(obs); };
+ var watched = [];
- for (var i=0; i<arguments.length; ++i) {
- expandProperties(arguments[i], addWatchedProperty);
- }
+ for (var i=0; i<arguments.length; ++i) {
+ expandProperties(arguments[i], addWatchedProperty);
+ }
- this.__ember_observesBefore__ = watched;
-
+ this.__ember_observesBefore__ = watched;
+
return this;
};
/**
The `on` extension of Javascript's Function prototype is available
@@ -27682,16 +27659,12 @@
var shouldDisplay = get(this, 'shouldDisplayFunc'),
preserveContext = get(this, 'preserveContext'),
context = get(this, 'previousContext');
- var _contextController;
+ var _contextController = get(this, '_contextController');
-
- _contextController = get(this, '_contextController');
-
-
var inverseTemplate = get(this, 'inverseTemplate'),
displayTemplate = get(this, 'displayTemplate');
var result = this.normalizedValue();
this._lastNormalizedValue = result;
@@ -27707,16 +27680,14 @@
set(this, '_context', context);
} else {
// Otherwise, determine if this is a block bind or not.
// If so, pass the specified object to the template
if (displayTemplate) {
-
- if (_contextController) {
- set(_contextController, 'content', result);
- result = _contextController;
- }
-
+ if (_contextController) {
+ set(_contextController, 'content', result);
+ result = _contextController;
+ }
set(this, '_context', result);
} else {
// This is not a bind block, just push the result of the
// expression to the render context and return.
if (result === null || result === undefined) {
@@ -27814,19 +27785,17 @@
previousContext: currentContext,
isEscaped: !options.hash.unescaped,
templateData: options.data
});
-
- if (options.hash.controller) {
- bindView.set('_contextController', this.container.lookupFactory('controller:'+options.hash.controller).create({
- container: currentContext.container,
- parentController: currentContext,
- target: currentContext
- }));
- }
-
+ if (options.hash.controller) {
+ bindView.set('_contextController', this.container.lookupFactory('controller:'+options.hash.controller).create({
+ container: currentContext.container,
+ parentController: currentContext,
+ target: currentContext
+ }));
+ }
view.appendChild(bindView);
observer = function() {
Ember.run.scheduleOnce('render', bindView, 'rerenderIfNeeded');
@@ -28099,9 +28068,26 @@
{{/each}}
{{/with}}
```
Without the `as` operator, it would be impossible to reference `user.name` in the example above.
+
+ ### `controller` option
+
+ Adding `controller='something'` instructs the `{{with}}` helper to create and use an instance of
+ the specified controller with the new context as its content.
+
+ This is very similar to using an `itemController` option with the `{{each}}` helper.
+
+ ```handlebars
+ {{#with users.posts controller='userBlogPosts'}}
+ {{!- The current context is wrapped in our controller instance }}
+ {{/with}}
+ ```
+
+ In the above example, the template provided to the `{{with}}` block is now wrapped in the
+ `userBlogPost` controller, which provides a very elegant way to decorate the context with custom
+ functions/properties.
@method with
@for Ember.Handlebars.helpers
@param {Function} context
@param {Hash} options