- Start by going to your {{#linkTo "profile.index"}}profile{{/linkTo}} and enable one of your projects. We've been
+ Start by going to your {{#link-to "profile.index"}}profile{{/link-to}} and enable one of your projects. We've been
synchronizing all repositories you have administrative access to. Pick one and flip the switch next to it.
{{/if}}
{{!TODO: for some reason showDownloadLog, which just delegates to jobIdForLog
does not refresh 'if' properly, need further investigation}}
{{#if view.jobIdForLog}}
diff --git a/assets/scripts/app/templates/workers/list.hbs b/assets/scripts/app/templates/workers/list.hbs
index 6f41d33e..a9387fe9 100644
--- a/assets/scripts/app/templates/workers/list.hbs
+++ b/assets/scripts/app/templates/workers/list.hbs
@@ -14,9 +14,9 @@
{{#if worker.isWorking}}
{{#if worker.jobId}}
- {{#linkTo "job" worker.repo worker.jobId}}
+ {{#link-to "job" worker.repo worker.jobId}}
{{view.display}}
- {{/linkTo}}
+ {{/link-to}}
{{/if}}
{{else}}
{{view.display}}
diff --git a/assets/scripts/app/views/repo/show.coffee b/assets/scripts/app/views/repo/show.coffee
index a27a0b29..5deaf914 100644
--- a/assets/scripts/app/views/repo/show.coffee
+++ b/assets/scripts/app/views/repo/show.coffee
@@ -37,7 +37,7 @@ Travis.reopen
tabBinding: 'controller.tab'
contextBinding: 'controller'
- # hrm. how to parametrize bindAttr?
+ # hrm. how to parametrize bind-attr?
classCurrent: (->
'active' if @get('tab') == 'current'
).property('tab')
diff --git a/assets/scripts/app/views/top.coffee b/assets/scripts/app/views/top.coffee
index ac9e8d24..fe5d7aea 100644
--- a/assets/scripts/app/views/top.coffee
+++ b/assets/scripts/app/views/top.coffee
@@ -4,7 +4,7 @@
tabBinding: 'controller.tab'
- # hrm. how to parametrize bindAttr?
+ # hrm. how to parametrize bind-attr?
classHome: (->
'active' if @get('tab') == 'home'
).property('tab')
diff --git a/assets/scripts/vendor/ember.js b/assets/scripts/vendor/ember.js
index 735ee4b1..c5b93786 100644
--- a/assets/scripts/vendor/ember.js
+++ b/assets/scripts/vendor/ember.js
@@ -1,3 +1,4 @@
+<<<<<<< HEAD
// ==========================================================================
// Project: Ember - JavaScript Application Framework
// Copyright: Copyright 2011-2013 Tilde Inc. and contributors
@@ -6,6 +7,17 @@
// License: Licensed under MIT license
// See https://raw.github.com/emberjs/ember.js/master/LICENSE
// ==========================================================================
+=======
+/*!
+ * @overview Ember - JavaScript Application Framework
+ * @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.3.0
+ */
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
// Version: 1.2.0
@@ -32,7 +44,20 @@ if ('undefined' === typeof Ember) {
}
}
-Ember.ENV = 'undefined' === typeof ENV ? {} : ENV;
+// This needs to be kept in sync with the logic in
+// `packages/ember-metal/lib/core.js`.
+//
+// This is duplicated here to ensure that `Ember.ENV`
+// is setup even if `Ember` is not loaded yet.
+if (Ember.ENV) {
+ // do nothing if Ember.ENV is already setup
+} else if ('undefined' !== typeof EmberENV) {
+ Ember.ENV = EmberENV;
+} else if('undefined' !== typeof ENV) {
+ Ember.ENV = ENV;
+} else {
+ Ember.ENV = {};
+}
if (!('MANDATORY_SETTER' in Ember.ENV)) {
Ember.ENV.MANDATORY_SETTER = true; // default to true for debug dist
@@ -184,6 +209,7 @@ if (!Ember.testing) {
})();
+<<<<<<< HEAD
// ==========================================================================
// Project: Ember - JavaScript Application Framework
// Copyright: Copyright 2011-2013 Tilde Inc. and contributors
@@ -192,12 +218,23 @@ if (!Ember.testing) {
// License: Licensed under MIT license
// See https://raw.github.com/emberjs/ember.js/master/LICENSE
// ==========================================================================
+=======
+/*!
+ * @overview Ember - JavaScript Application Framework
+ * @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.3.0
+ */
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
// Version: 1.2.0
(function() {
-var define, requireModule;
+var define, requireModule, require, requirejs;
(function() {
var registry = {}, seen = {};
@@ -206,36 +243,52 @@ var define, requireModule;
registry[name] = { deps: deps, callback: callback };
};
- requireModule = function(name) {
+ requirejs = require = requireModule = function(name) {
+ requirejs._eak_seen = registry;
+
if (seen[name]) { return seen[name]; }
seen[name] = {};
- var mod, deps, callback, reified, exports;
-
- mod = registry[name];
-
- if (!mod) {
- throw new Error("Module '" + name + "' not found.");
+ if (!registry[name]) {
+ throw new Error("Could not find module " + name);
}
- deps = mod.deps;
- callback = mod.callback;
- reified = [];
+ var mod = registry[name],
+ deps = mod.deps,
+ callback = mod.callback,
+ reified = [],
+ exports;
for (var i=0, l=deps.length; i>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
*/
if ('undefined' === typeof Ember) {
@@ -286,34 +343,93 @@ Ember.toString = function() { return "Ember"; };
/**
@property VERSION
@type String
+<<<<<<< HEAD
@default '1.2.0'
@final
*/
Ember.VERSION = '1.2.0';
+=======
+ @default '1.3.0'
+ @static
+*/
+Ember.VERSION = '1.3.0';
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
/**
- Standard environmental variables. You can define these in a global `ENV`
- variable before loading Ember to control various configuration
- settings.
+ Standard environmental variables. You can define these in a global `EmberENV`
+ variable before loading Ember to control various configuration settings.
+
+ For backwards compatibility with earlier versions of Ember the global `ENV`
+ variable will be used if `EmberENV` is not defined.
@property ENV
@type Hash
*/
-if ('undefined' === typeof ENV) {
- exports.ENV = {};
+// This needs to be kept in sync with the logic in
+// `packages/ember-debug/lib/main.js`.
+if (Ember.ENV) {
+ // do nothing if Ember.ENV is already setup
+} else if ('undefined' !== typeof EmberENV) {
+ Ember.ENV = EmberENV;
+} else if('undefined' !== typeof ENV) {
+ Ember.ENV = ENV;
+} else {
+ Ember.ENV = {};
}
-// We disable the RANGE API by default for performance reasons
-if ('undefined' === typeof ENV.DISABLE_RANGE_API) {
- ENV.DISABLE_RANGE_API = true;
-}
-
-
-Ember.ENV = Ember.ENV || ENV;
-
Ember.config = Ember.config || {};
+// We disable the RANGE API by default for performance reasons
+if ('undefined' === typeof Ember.ENV.DISABLE_RANGE_API) {
+ Ember.ENV.DISABLE_RANGE_API = true;
+}
+
+if ("undefined" === typeof MetamorphENV) {
+ exports.MetamorphENV = {};
+}
+
+MetamorphENV.DISABLE_RANGE_API = Ember.ENV.DISABLE_RANGE_API;
+
+/**
+ Hash of enabled Canary features. Add to before creating your application.
+
+ You can also define `ENV.FEATURES` if you need to enable features flagged at runtime.
+
+ @property FEATURES
+ @type Hash
+*/
+
+Ember.FEATURES = Ember.ENV.FEATURES || {};
+
+/**
+ Test that a feature is enabled. Parsed by Ember's build tools to leave
+ experimental features out of beta/stable builds.
+
+ You can define the following configuration options:
+
+ * `ENV.ENABLE_ALL_FEATURES` - force all features to be enabled.
+ * `ENV.ENABLE_OPTIONAL_FEATURES` - enable any features that have not been explicitly
+ enabled/disabled.
+
+ @method isEnabled
+ @param {string} feature
+*/
+
+Ember.FEATURES.isEnabled = function(feature) {
+ var featureValue = Ember.FEATURES[feature];
+
+ if (Ember.ENV.ENABLE_ALL_FEATURES) {
+ return true;
+ } else if (featureValue === true || featureValue === false || featureValue === undefined) {
+ return featureValue;
+ } else if (Ember.ENV.ENABLE_OPTIONAL_FEATURES) {
+ return true;
+ } else {
+ return false;
+ }
+};
+
/**
Hash of enabled Canary features. Add to before creating your application.
@@ -795,6 +911,19 @@ var errorProps = ['description', 'fileName', 'lineNumber', 'message', 'name', 'n
Ember.Error = function() {
var tmp = Error.apply(this, arguments);
+<<<<<<< HEAD
+=======
+ // Adds a `stack` property to the given error object that will yield the
+ // stack trace at the time captureStackTrace was called.
+ // When collecting the stack trace all frames above the topmost call
+ // to this function, including that call, will be left out of the
+ // stack trace.
+ // This is useful because we can hide Ember implementation details
+ // that are not very helpful for the user.
+ if (Error.captureStackTrace) {
+ Error.captureStackTrace(this, Ember.Error);
+ }
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
// Unfortunately errors are not enumerable in Chrome (at least), so `for prop in tmp` doesn't work.
for (var idx = 0; idx < errorProps.length; idx++) {
this[errorProps[idx]] = tmp[errorProps[idx]];
@@ -828,10 +957,16 @@ Ember.Error.prototype = Ember.create(Error.prototype);
Ember.onerror = null;
/**
+<<<<<<< HEAD
@private
Wrap code block in a try/catch if `Ember.onerror` is set.
+=======
+ Wrap code block in a try/catch if `Ember.onerror` is set.
+
+ @private
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
@method handleErrors
@for Ember
@param {Function} func
@@ -861,10 +996,15 @@ Ember.handleErrors = function(func, context) {
*/
/**
+<<<<<<< HEAD
@private
Prefix used for guids through out Ember.
+=======
+ Prefix used for guids through out Ember.
+ @private
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
*/
Ember.GUID_PREFIX = 'ember';
@@ -880,8 +1020,6 @@ var o_defineProperty = Ember.platform.defineProperty,
var MANDATORY_SETTER = Ember.ENV.MANDATORY_SETTER;
/**
- @private
-
A unique key used to assign guids and other private metadata to objects.
If you inspect an object in your browser debugger you will often see these.
They can be safely ignored.
@@ -889,6 +1027,7 @@ var MANDATORY_SETTER = Ember.ENV.MANDATORY_SETTER;
On browsers that support it, these properties are added with enumeration
disabled so they won't show up when you iterate over your properties.
+ @private
@property GUID_KEY
@for Ember
@type String
@@ -904,12 +1043,11 @@ var GUID_DESC = {
};
/**
- @private
-
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
@@ -932,8 +1070,6 @@ Ember.generateGuid = function generateGuid(obj, prefix) {
};
/**
- @private
-
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`
@@ -941,6 +1077,7 @@ Ember.generateGuid = function generateGuid(obj, prefix) {
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
@@ -1005,18 +1142,6 @@ var META_KEY = Ember.GUID_KEY+'_meta';
*/
Ember.META_KEY = META_KEY;
-// Placeholder for non-writable metas.
-var EMPTY_META = {
- descs: {},
- watching: {}
-};
-
-if (MANDATORY_SETTER) { EMPTY_META.values = {}; }
-
-Ember.EMPTY_META = EMPTY_META;
-
-if (Object.freeze) Object.freeze(EMPTY_META);
-
var isDefinePropertySimulated = Ember.platform.defineProperty.isSimulated;
function Meta(obj) {
@@ -1026,6 +1151,20 @@ function Meta(obj) {
this.source = obj;
}
+Meta.prototype = {
+ descs: null,
+ deps: null,
+ watching: null,
+ listeners: null,
+ cache: null,
+ source: null,
+ mixins: null,
+ bindings: null,
+ chains: null,
+ chainWatchers: null,
+ values: null
+};
+
if (isDefinePropertySimulated) {
// on platforms that don't support enumerable false
// make meta fail jQuery.isPlainObject() to hide from
@@ -1038,6 +1177,13 @@ if (isDefinePropertySimulated) {
Meta.prototype.toJSON = function () { };
}
+// Placeholder for non-writable metas.
+var EMPTY_META = new Meta(null);
+
+if (MANDATORY_SETTER) { EMPTY_META.values = {}; }
+
+Ember.EMPTY_META = EMPTY_META;
+
/**
Retrieves the meta hash for an object. If `writable` is true ensures the
hash is writable for this object as well.
@@ -1157,12 +1303,11 @@ Ember.metaPath = function metaPath(obj, path, writable) {
};
/**
- @private
-
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
@@ -1472,6 +1617,8 @@ var toString = Object.prototype.toString;
| 'undefined' | Undefined value |
| 'function' | A function |
| 'array' | An instance of Array |
+ | 'regexp' | An instance of RegExp |
+ | 'date' | An instance of Date |
| 'class' | An Ember class (created using Ember.Object.extend()) |
| 'instance' | An Ember object instance |
| 'error' | An instance of the Error object |
@@ -1491,6 +1638,8 @@ var toString = Object.prototype.toString;
Ember.typeOf(new Boolean(true)); // 'boolean'
Ember.typeOf(Ember.makeArray); // 'function'
Ember.typeOf([1,2,90]); // 'array'
+ Ember.typeOf(/abc/); // 'regexp'
+ Ember.typeOf(new Date()); // 'date'
Ember.typeOf(Ember.Object.extend()); // 'class'
Ember.typeOf(Ember.Object.create()); // 'instance'
Ember.typeOf(new Error('teamocil')); // 'error'
@@ -1514,7 +1663,7 @@ Ember.typeOf = function(item) {
} else if (ret === 'object') {
if (item instanceof Error) ret = 'error';
else if (Ember.Object && item instanceof Ember.Object) ret = 'instance';
- else ret = 'object';
+ else if (item instanceof Date) ret = 'date';
}
return ret;
@@ -1903,13 +2052,12 @@ if (Ember.config.overrideAccessors) {
}
/**
- @private
-
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 captial letter not defined on the
target) and * separators.
+ @private
@method normalizeTuple
@for Ember
@param {Object} target The current target. May be `null`.
@@ -2158,8 +2306,6 @@ function removeListener(obj, eventName, target, method) {
}
/**
- @private
-
Suspend listener during callback.
This should only be used by the target of the event listener
@@ -2167,6 +2313,7 @@ function removeListener(obj, eventName, target, method) {
an object might suspend its property change listener while it is
setting that property.
+ @private
@method suspendListener
@for Ember
@param obj
@@ -2195,11 +2342,13 @@ function suspendListener(obj, eventName, target, method, callback) {
}
/**
- @private
-
Suspends multiple listeners during a callback.
+<<<<<<< HEAD
+=======
+ @private
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
@method suspendListeners
@for Ember
@param obj
@@ -2243,10 +2392,9 @@ function suspendListeners(obj, eventNames, target, method, callback) {
}
/**
- @private
-
Return a list of currently watched events
+ @private
@method watchedEvents
@for Ember
@param obj
@@ -2346,13 +2494,16 @@ function listenersFor(obj, eventName) {
Define a property as a function that should be executed when
a specified event or events are triggered.
- 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!"
+
+ ``` 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
@@ -2760,7 +2911,7 @@ var set = function set(obj, keyName, value, tolerant) {
if (value !== currentValue) {
Ember.propertyWillChange(obj, keyName);
if (MANDATORY_SETTER) {
- if (currentValue === undefined && !(keyName in obj)) {
+ if ((currentValue === undefined && !(keyName in obj)) || !obj.propertyIsEnumerable(keyName)) {
Ember.defineProperty(obj, keyName, null, value); // setup mandatory setter
} else {
meta.values[keyName] = value;
@@ -2791,7 +2942,7 @@ function setPath(root, path, value, tolerant) {
keyName = path.slice(path.lastIndexOf('.') + 1);
// get the first part of the part
- path = 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
@@ -2800,12 +2951,20 @@ function setPath(root, path, value, tolerant) {
}
if (!keyName || keyName.length === 0) {
+<<<<<<< HEAD
throw new Ember.Error('You passed an empty path');
+=======
+ throw new Ember.Error('Property set failed: You passed an empty path');
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
}
if (!root) {
if (tolerant) { return; }
+<<<<<<< HEAD
else { throw new Ember.Error('Object in path '+path+' could not be found or was destroyed.'); }
+=======
+ else { throw new Ember.Error('Property set failed: object in path "'+path+'" could not be found or was destroyed.'); }
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
}
return set(root, keyName, value);
@@ -3215,7 +3374,11 @@ MapWithDefault.prototype.copy = function() {
(function() {
function consoleMethod(name) {
+<<<<<<< HEAD
var consoleObj;
+=======
+ var consoleObj, logToConsole;
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
if (Ember.imports.console) {
consoleObj = Ember.imports.console;
} else if (typeof console !== 'undefined') {
@@ -3227,9 +3390,17 @@ function consoleMethod(name) {
if (method) {
// Older IE doesn't support apply, but Chrome needs it
if (method.apply) {
+<<<<<<< HEAD
return function() {
method.apply(consoleObj, arguments);
};
+=======
+ logToConsole = function() {
+ method.apply(consoleObj, arguments);
+ };
+ logToConsole.displayName = 'console.' + name;
+ return logToConsole;
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
} else {
return function() {
var message = Array.prototype.join.call(arguments, ', ');
@@ -3274,6 +3445,10 @@ Ember.Logger = {
@param {*} arguments
*/
log: consoleMethod('log') || Ember.K,
+<<<<<<< HEAD
+=======
+
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
/**
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.
@@ -3287,8 +3462,14 @@ Ember.Logger = {
@param {*} arguments
*/
warn: consoleMethod('warn') || Ember.K,
+<<<<<<< HEAD
/**
Prints the arguments to the console with an error icon, red text and a stack race.
+=======
+
+ /**
+ Prints the arguments to the console with an error icon, red text and a stack trace.
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
You can pass as many arguments as you want and they will be joined together with a space.
```javascript
@@ -3300,6 +3481,10 @@ Ember.Logger = {
@param {*} arguments
*/
error: consoleMethod('error') || Ember.K,
+<<<<<<< HEAD
+=======
+
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
/**
Logs the arguments to the console.
You can pass as many arguments as you want and they will be joined together with a space.
@@ -3314,6 +3499,10 @@ Ember.Logger = {
@param {*} arguments
*/
info: consoleMethod('info') || Ember.K,
+<<<<<<< HEAD
+=======
+
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
/**
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.
@@ -3328,9 +3517,15 @@ Ember.Logger = {
@param {*} arguments
*/
debug: consoleMethod('debug') || consoleMethod('info') || Ember.K,
+<<<<<<< HEAD
/**
If the value passed into Ember.Logger.assert is not truthy it will throw an error with a stack trace.
+=======
+
+ /**
+ If the value passed into `Ember.Logger.assert` is not truthy it will throw an error with a stack trace.
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
```javascript
Ember.Logger.assert(true); // undefined
@@ -3393,8 +3588,6 @@ var DEFAULT_GETTER_FUNCTION = Ember.DEFAULT_GETTER_FUNCTION = function(name) {
};
/**
- @private
-
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.
@@ -3428,6 +3621,7 @@ var DEFAULT_GETTER_FUNCTION = Ember.DEFAULT_GETTER_FUNCTION = function(name) {
}).property('firstName', 'lastName'));
```
+ @private
@method defineProperty
@for Ember
@param {Object} obj the object to define this property on. This may be a prototype.
@@ -3604,7 +3798,7 @@ Ember.watchKey = function(obj, keyName) {
m.values[keyName] = obj[keyName];
o_defineProperty(obj, keyName, {
configurable: true,
- enumerable: true,
+ enumerable: obj.propertyIsEnumerable(keyName),
set: Ember.MANDATORY_SETTER_FUNCTION,
get: Ember.DEFAULT_GETTER_FUNCTION(keyName)
});
@@ -3628,11 +3822,19 @@ Ember.unwatchKey = function(obj, keyName) {
if (MANDATORY_SETTER && keyName in obj) {
o_defineProperty(obj, keyName, {
configurable: true,
- enumerable: true,
- writable: true,
- value: m.values[keyName]
+ enumerable: obj.propertyIsEnumerable(keyName),
+ set: function(val) {
+ // redefine to set as enumerable
+ o_defineProperty(obj, keyName, {
+ configurable: true,
+ writable: true,
+ enumerable: true,
+ value: val
+ });
+ delete m.values[keyName];
+ },
+ get: Ember.DEFAULT_GETTER_FUNCTION(keyName)
});
- delete m.values[keyName];
}
} else if (watching[keyName] > 1) {
watching[keyName]--;
@@ -3975,10 +4177,13 @@ Ember.finishChains = function(obj) {
(function() {
+<<<<<<< HEAD
/**
@module ember-metal
*/
+=======
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
})();
@@ -4054,14 +4259,13 @@ function isKeyName(path) {
}
/**
- @private
-
Starts watching a property on an object. Whenever the property changes,
invokes `Ember.propertyWillChange` and `Ember.propertyDidChange`. This is the
primitive used by observers and dependent keys; usually you will never call
this method directly but instead use higher level methods like
`Ember.addObserver()`
+ @private
@method watch
@for Ember
@param obj
@@ -4071,6 +4275,7 @@ Ember.watch = function(obj, _keyPath) {
// can't watch length on Array - it is special...
if (_keyPath === 'length' && typeOf(obj) === 'array') { return; }
+<<<<<<< HEAD
if (isKeyName(_keyPath)) {
watchKey(obj, _keyPath);
@@ -4078,6 +4283,13 @@ Ember.watch = function(obj, _keyPath) {
watchPath(obj, _keyPath);
}
+=======
+ if (isKeyName(_keyPath)) {
+ watchKey(obj, _keyPath);
+ } else {
+ watchPath(obj, _keyPath);
+ }
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
};
Ember.isWatching = function isWatching(obj, key) {
@@ -4091,6 +4303,7 @@ Ember.unwatch = function(obj, _keyPath) {
// can't watch length on Array - it is special...
if (_keyPath === 'length' && typeOf(obj) === 'array') { return; }
+<<<<<<< HEAD
if (isKeyName(_keyPath)) {
unwatchKey(obj, _keyPath);
@@ -4098,15 +4311,21 @@ Ember.unwatch = function(obj, _keyPath) {
unwatchPath(obj, _keyPath);
}
+=======
+ if (isKeyName(_keyPath)) {
+ unwatchKey(obj, _keyPath);
+ } else {
+ unwatchPath(obj, _keyPath);
+ }
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
};
/**
- @private
-
Call on an object when you first beget it from another object. This will
setup any chained watchers on the object instance as needed. This method is
safe to call multiple times.
+ @private
@method rewatch
@for Ember
@param obj
@@ -4384,11 +4603,11 @@ ComputedPropertyPrototype.cacheable = function(aFlag) {
mode the computed property will not automatically cache the return value.
```javascript
- MyApp.outsideService = Ember.Object.create({
+ MyApp.outsideService = Ember.Object.extend({
value: function() {
return OutsideService.getValue();
}.property().volatile()
- });
+ }).create();
```
@method volatile
@@ -4404,12 +4623,14 @@ ComputedPropertyPrototype.volatile = function() {
mode the computed property will throw an error when set.
```javascript
- MyApp.person = Ember.Object.create({
+ MyApp.Person = Ember.Object.extend({
guid: function() {
return 'guid-guid-guid';
}.property().readOnly()
});
+ MyApp.person = MyApp.Person.create();
+
MyApp.person.set('guid', 'new-guid'); // will throw an exception
```
@@ -4427,7 +4648,7 @@ ComputedPropertyPrototype.readOnly = function(readOnly) {
arguments containing key paths that this computed property depends on.
```javascript
- MyApp.president = Ember.Object.create({
+ MyApp.President = Ember.Object.extend({
fullName: Ember.computed(function() {
return this.get('firstName') + ' ' + this.get('lastName');
@@ -4435,6 +4656,12 @@ ComputedPropertyPrototype.readOnly = function(readOnly) {
// and lastName
}).property('firstName', 'lastName')
});
+
+ MyApp.president = MyApp.President.create({
+ firstName: 'Barack',
+ lastName: 'Obama',
+ });
+ MyApp.president.get('fullName'); // Barack Obama
```
@method property
@@ -4443,6 +4670,7 @@ ComputedPropertyPrototype.readOnly = function(readOnly) {
@chainable
*/
ComputedPropertyPrototype.property = function() {
+<<<<<<< HEAD
var addArg;
@@ -4452,6 +4680,14 @@ ComputedPropertyPrototype.property = function() {
args.push(arguments[i]);
}
+=======
+ var args;
+
+
+ args = a_slice.call(arguments);
+
+
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
this._dependentKeys = args;
return this;
};
@@ -4765,11 +5001,22 @@ registerComputed('empty', function(dependentKey) {
A computed property that returns true if the value of the dependent
property is NOT null, an empty string, empty array, or empty function.
+<<<<<<< HEAD
+=======
+ Note: When using `Ember.computed.notEmpty` to watch an array make sure to
+ use the `array.[]` syntax so the computed can subscribe to transitions
+ from empty to non-empty states.
+
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
Example
```javascript
var Hamster = Ember.Object.extend({
+<<<<<<< HEAD
hasStuff: Ember.computed.notEmpty('backpack')
+=======
+ hasStuff: Ember.computed.notEmpty('backpack.[]')
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
});
var hamster = Hamster.create({backpack: ['Food', 'Sleeping Bag', 'Tent']});
hamster.get('hasStuff'); // true
@@ -5149,7 +5396,11 @@ registerComputedWithProperties('any', function(properties) {
```javascript
var Hamster = Ember.Object.extend({
+<<<<<<< HEAD
clothes: Ember.computed.map('hat', 'shirt')
+=======
+ clothes: Ember.computed.collect('hat', 'shirt')
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
});
var hamster = Hamster.create();
hamster.get('clothes'); // [null, null]
@@ -5158,7 +5409,11 @@ registerComputedWithProperties('any', function(properties) {
hamster.get('clothes'); // ['Camp Hat', 'Camp Shirt']
```
+<<<<<<< HEAD
@method computed.map
+=======
+ @method computed.collect
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
@for Ember
@param {String} dependentKey*
@return {Ember.ComputedProperty} computed property which maps
@@ -5303,7 +5558,10 @@ Ember.computed.defaultTo = function(defaultPath) {
var AFTER_OBSERVERS = ':change',
BEFORE_OBSERVERS = ':before';
+<<<<<<< HEAD
+=======
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
function changeEvent(keyName) {
return keyName+AFTER_OBSERVERS;
@@ -5321,10 +5579,15 @@ function beforeEvent(keyName) {
@param {Function|String} [method]
*/
Ember.addObserver = function(obj, _path, target, method) {
+<<<<<<< HEAD
Ember.addListener(obj, changeEvent(_path), target, method);
Ember.watch(obj, _path);
+=======
+ Ember.addListener(obj, changeEvent(_path), target, method);
+ Ember.watch(obj, _path);
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
return this;
};
@@ -5341,10 +5604,16 @@ Ember.observersFor = function(obj, path) {
@param {Function|String} [method]
*/
Ember.removeObserver = function(obj, _path, target, method) {
+<<<<<<< HEAD
Ember.unwatch(obj, _path);
Ember.removeListener(obj, changeEvent(_path), target, method);
+=======
+ Ember.unwatch(obj, _path);
+ Ember.removeListener(obj, changeEvent(_path), target, method);
+
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
return this;
};
@@ -5356,10 +5625,16 @@ Ember.removeObserver = function(obj, _path, target, method) {
@param {Function|String} [method]
*/
Ember.addBeforeObserver = function(obj, _path, target, method) {
+<<<<<<< HEAD
Ember.addListener(obj, beforeEvent(_path), target, method);
Ember.watch(obj, _path);
+=======
+ Ember.addListener(obj, beforeEvent(_path), target, method);
+ Ember.watch(obj, _path);
+
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
return this;
};
@@ -5399,10 +5674,16 @@ Ember.beforeObserversFor = function(obj, path) {
@param {Function|String} [method]
*/
Ember.removeBeforeObserver = function(obj, _path, target, method) {
+<<<<<<< HEAD
Ember.unwatch(obj, _path);
Ember.removeListener(obj, beforeEvent(_path), target, method);
+=======
+ Ember.unwatch(obj, _path);
+ Ember.removeListener(obj, beforeEvent(_path), target, method);
+
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
return this;
};
@@ -5734,7 +6015,7 @@ define("backburner",
method = target[method];
}
- var stack = this.DEBUG ? new Error().stack : undefined,
+ var stack = this.DEBUG ? new Error() : undefined,
args = arguments.length > 3 ? slice.call(arguments, 3) : undefined;
if (!this.currentInstance) { createAutorun(this); }
return this.currentInstance.schedule(queueName, target, method, args, false, stack);
@@ -5750,7 +6031,7 @@ define("backburner",
method = target[method];
}
- var stack = this.DEBUG ? new Error().stack : undefined,
+ var stack = this.DEBUG ? new Error() : undefined,
args = arguments.length > 3 ? slice.call(arguments, 3) : undefined;
if (!this.currentInstance) { createAutorun(this); }
return this.currentInstance.schedule(queueName, target, method, args, true, stack);
@@ -5821,18 +6102,7 @@ define("backburner",
timers.splice(i, 0, executeAt, fn);
- if (laterTimer && laterTimerExpiresAt < executeAt) { return fn; }
-
- if (laterTimer) {
- clearTimeout(laterTimer);
- laterTimer = null;
- }
- laterTimer = global.setTimeout(function() {
- executeTimers(self);
- laterTimer = null;
- laterTimerExpiresAt = null;
- }, wait);
- laterTimerExpiresAt = executeAt;
+ updateLaterTimer(self, executeAt, wait);
return fn;
},
@@ -5841,30 +6111,29 @@ define("backburner",
var self = this,
args = arguments,
wait = parseInt(pop.call(args), 10),
+<<<<<<< HEAD
throttler;
+=======
+ throttler,
+ index,
+ timer;
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
- for (var i = 0, l = throttlers.length; i < l; i++) {
- throttler = throttlers[i];
- if (throttler[0] === target && throttler[1] === method) { return; } // do nothing
- }
+ index = findThrottler(target, method);
+ if (index > -1) { return throttlers[index]; } // throttled
- var timer = global.setTimeout(function() {
+ timer = global.setTimeout(function() {
self.run.apply(self, args);
- // remove throttler
- var index = -1;
- for (var i = 0, l = throttlers.length; i < l; i++) {
- throttler = throttlers[i];
- if (throttler[0] === target && throttler[1] === method) {
- index = i;
- break;
- }
- }
-
+ var index = findThrottler(target, method);
if (index > -1) { throttlers.splice(index, 1); }
}, wait);
- throttlers.push([target, method, timer]);
+ throttler = [target, method, timer];
+
+ throttlers.push(throttler);
+
+ return throttler;
},
debounce: function(target, method /* , args, wait, [immediate] */) {
@@ -5873,7 +6142,8 @@ define("backburner",
immediate = pop.call(args),
wait,
index,
- debouncee;
+ debouncee,
+ timer;
if (typeof immediate === "number" || typeof immediate === "string") {
wait = immediate;
@@ -5886,18 +6156,22 @@ define("backburner",
// Remove debouncee
index = findDebouncee(target, method);
- if (index !== -1) {
+ if (index > -1) {
debouncee = debouncees[index];
debouncees.splice(index, 1);
clearTimeout(debouncee[2]);
}
+<<<<<<< HEAD
var timer = global.setTimeout(function() {
+=======
+ timer = global.setTimeout(function() {
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
if (!immediate) {
self.run.apply(self, args);
}
- index = findDebouncee(target, method);
- if (index) {
+ var index = findDebouncee(target, method);
+ if (index > -1) {
debouncees.splice(index, 1);
}
}, wait);
@@ -5906,7 +6180,11 @@ define("backburner",
self.run.apply(self, args);
}
- debouncees.push([target, method, timer]);
+ debouncee = [target, method, timer];
+
+ debouncees.push(debouncee);
+
+ return debouncee;
},
cancelTimers: function() {
@@ -5939,19 +6217,47 @@ define("backburner",
},
cancel: function(timer) {
- if (timer && typeof timer === 'object' && timer.queue && timer.method) { // we're cancelling a deferOnce
+ var timerType = typeof timer;
+
+ if (timer && timerType === 'object' && timer.queue && timer.method) { // we're cancelling a deferOnce
return timer.queue.cancel(timer);
- } else if (typeof timer === 'function') { // we're cancelling a setTimeout
+ } else if (timerType === 'function') { // we're cancelling a setTimeout
for (var i = 0, l = timers.length; i < l; i += 2) {
if (timers[i + 1] === timer) {
timers.splice(i, 2); // remove the two elements
return true;
}
}
+ } else if (window.toString.call(timer) === "[object Array]"){ // we're cancelling a throttle or debounce
+ return this._cancelItem(findThrottler, throttlers, timer) ||
+ this._cancelItem(findDebouncee, debouncees, timer);
} else {
return; // timer was null or not a timer
}
+ },
+
+ _cancelItem: function(findMethod, array, timer){
+ var item,
+ index;
+
+ if (timer.length < 3) { return false; }
+
+ index = findMethod(timer[0], timer[1]);
+
+ if(index > -1) {
+
+ item = array[index];
+
+ if(item[2] === timer[2]){
+ array.splice(index, 1);
+ clearTimeout(timer[2]);
+ return true;
+ }
+ }
+
+ return false;
}
+
};
Backburner.prototype.schedule = Backburner.prototype.defer;
@@ -5966,6 +6272,20 @@ define("backburner",
});
}
+ function updateLaterTimer(self, executeAt, wait) {
+ if (!laterTimer || executeAt < laterTimerExpiresAt) {
+ if (laterTimer) {
+ clearTimeout(laterTimer);
+ }
+ laterTimer = global.setTimeout(function() {
+ laterTimer = null;
+ laterTimerExpiresAt = null;
+ executeTimers(self);
+ }, wait);
+ laterTimerExpiresAt = executeAt;
+ }
+ }
+
function executeTimers(self) {
var now = +new Date(),
time, fns, i, l;
@@ -5985,12 +6305,7 @@ define("backburner",
});
if (timers.length) {
- laterTimer = global.setTimeout(function() {
- executeTimers(self);
- laterTimer = null;
- laterTimerExpiresAt = null;
- }, timers[0] - now);
- laterTimerExpiresAt = timers[0];
+ updateLaterTimer(self, timers[0], timers[0] - now);
}
}
@@ -6009,6 +6324,21 @@ define("backburner",
return index;
}
+ function findThrottler(target, method) {
+ var throttler,
+ index = -1;
+
+ for (var i = 0, l = throttlers.length; i < l; i++) {
+ throttler = throttlers[i];
+ if (throttler[0] === target && throttler[1] === method) {
+ index = i;
+ break;
+ }
+ }
+
+ return index;
+ }
+
__exports__.Backburner = Backburner;
});
@@ -6086,7 +6416,6 @@ Ember.run = function(target, method) {
};
/**
-
If no run-loop is present, it creates a new one. If a run loop is
present it will queue itself to run on the existing run-loops action
queue.
@@ -6120,7 +6449,7 @@ Ember.run = function(target, method) {
May be a function or a string. If you pass a string
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,
+ @return {Object} Return value from invoking the passed function. Please note,
when called within an existing loop, no return value is possible.
*/
Ember.run.join = function(target, method) {
@@ -6209,7 +6538,8 @@ Ember.run.end = function() {
console.log("scheduled on actions queue");
});
- // Note the functions will be run in order based on the run queues order. Output would be:
+ // Note the functions will be run in order based on the run queues order.
+ // Output would be:
// scheduled on sync queue
// scheduled on actions queue
```
@@ -6366,7 +6696,8 @@ Ember.run.scheduleOnce = function(queue, target, method) {
```javascript
Ember.run.next(myContext, function() {
- // code to be executed in the next run loop, which will be scheduled after the current one
+ // code to be executed in the next run loop,
+ // which will be scheduled after the current one
});
```
@@ -7032,6 +7363,7 @@ var Mixin, REQUIRED, Alias,
defineProperty = Ember.defineProperty,
guidFor = Ember.guidFor;
+
function mixinsMeta(obj) {
var m = Ember.meta(obj, true), ret = m.mixins;
if (!ret) {
@@ -7211,7 +7543,8 @@ function mergeMixins(mixins, m, descs, values, base, keys) {
for(var i=0, l=mixins.length; i>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
if (typeof func !== "function") {
throw new Ember.Error("Ember.observer called without a function");
@@ -7779,6 +8128,7 @@ Ember.immediateObserver = function() {
*/
Ember.beforeObserver = function() {
var func = a_slice.call(arguments, -1)[0];
+<<<<<<< HEAD
var paths = a_slice.call(arguments, 0, -1);
if (typeof func !== "function") {
@@ -7787,6 +8137,20 @@ Ember.beforeObserver = function() {
func = arguments[0];
paths = a_slice.call(arguments, 1);
}
+=======
+ var paths;
+
+
+ paths = a_slice.call(arguments, 0, -1);
+
+ if (typeof func !== "function") {
+ // revert to old, soft-deprecated argument ordering
+
+ func = arguments[0];
+ paths = a_slice.call(arguments, 1);
+ }
+
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
if (typeof func !== "function") {
throw new Ember.Error("Ember.beforeObserver called without a function");
@@ -7804,6 +8168,8 @@ Ember.beforeObserver = function() {
// Provides a way to register library versions with ember.
var forEach = Ember.EnumerableUtils.forEach,
indexOf = Ember.EnumerableUtils.indexOf;
+<<<<<<< HEAD
+=======
Ember.libraries = function() {
var libraries = [];
@@ -7849,6 +8215,56 @@ Ember.libraries.registerCoreLibrary('Ember', Ember.VERSION);
+(function() {
+/**
+Ember Metal
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
+
+Ember.libraries = function() {
+ var libraries = [];
+ var coreLibIndex = 0;
+
+ var getLibrary = function(name) {
+ for (var i = 0; i < libraries.length; i++) {
+ if (libraries[i].name === name) {
+ return libraries[i];
+ }
+ }
+ };
+
+<<<<<<< HEAD
+ libraries.register = function(name, version) {
+ if (!getLibrary(name)) {
+ libraries.push({name: name, version: version});
+ }
+ };
+
+ libraries.registerCoreLibrary = function(name, version) {
+ if (!getLibrary(name)) {
+ libraries.splice(coreLibIndex++, 0, {name: name, version: version});
+ }
+ };
+
+ libraries.deRegister = function(name) {
+ var lib = getLibrary(name);
+ if (lib) libraries.splice(indexOf(libraries, lib), 1);
+ };
+
+ libraries.each = function (callback) {
+ forEach(libraries, function(lib) {
+ callback(lib.name, lib.version);
+ });
+ };
+
+ return libraries;
+}();
+
+Ember.libraries.registerCoreLibrary('Ember', Ember.VERSION);
+
+})();
+
+
+
(function() {
/**
Ember Metal
@@ -7862,28 +8278,118 @@ Ember Metal
(function() {
define("rsvp/all",
["rsvp/promise","exports"],
+=======
+(function() {
+/**
+ @class RSVP
+ @module RSVP
+ */
+define("rsvp/all",
+ ["./promise","exports"],
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
function(__dependency1__, __exports__) {
"use strict";
- var Promise = __dependency1__.Promise;
- /* global toString */
+ var Promise = __dependency1__["default"];
+ /**
+ This is a convenient alias for `RSVP.Promise.all`.
- function all(promises) {
- if (Object.prototype.toString.call(promises) !== "[object Array]") {
- throw new TypeError('You must pass an array to all.');
- }
+ @method all
+ @for RSVP
+ @param {Array} array Array of promises.
+ @param {String} label An optional label. This is useful
+ for tooling.
+ @static
+ */
+ __exports__["default"] = function all(array, label) {
+ return Promise.all(array, label);
+ };
+ });
+define("rsvp/all_settled",
+ ["./promise","./utils","exports"],
+ function(__dependency1__, __dependency2__, __exports__) {
+ "use strict";
+ var Promise = __dependency1__["default"];
+ var isArray = __dependency2__.isArray;
+ var isNonThenable = __dependency2__.isNonThenable;
+ /**
+ `RSVP.allSettled` is similar to `RSVP.all`, but instead of implementing
+ a fail-fast method, it waits until all the promises have returned and
+ shows you all the results. This is useful if you want to handle multiple
+ promises' failure states together as a set.
+
+ Returns a promise that is fulfilled when all the given promises have been
+ settled. The return promise is fulfilled with an array of the states of
+ the promises passed into the `promises` array argument.
+
+ Each state object will either indicate fulfillment or rejection, and
+ provide the corresponding value or reason. The states will take one of
+ the following formats:
+
+ ```javascript
+ { state: 'fulfilled', value: value }
+ or
+ { state: 'rejected', reason: reason }
+ ```
+
+ Example:
+
+ ```javascript
+ var promise1 = RSVP.Promise.resolve(1);
+ var promise2 = RSVP.Promise.reject(new Error('2'));
+ var promise3 = RSVP.Promise.reject(new Error('3'));
+ var promises = [ promise1, promise2, promise3 ];
+
+ RSVP.allSettled(promises).then(function(array){
+ // array == [
+ // { state: 'fulfilled', value: 1 },
+ // { state: 'rejected', reason: Error },
+ // { state: 'rejected', reason: Error }
+ // ]
+ // Note that for the second item, reason.message will be "2", and for the
+ // third item, reason.message will be "3".
+ }, function(error) {
+ // Not run. (This block would only be called if allSettled had failed,
+ // for instance if passed an incorrect argument type.)
+ });
+ ```
+
+ @method allSettled
+ @for RSVP
+ @param {Array} promises
+ @param {String} label - optional string that describes the promise.
+ Useful for tooling.
+ @return {Promise} promise that is fulfilled with an array of the settled
+ states of the constituent promises.
+ @static
+ */
+
+ __exports__["default"] = function allSettled(entries, label) {
return new Promise(function(resolve, reject) {
- var results = [], remaining = promises.length,
- promise;
+ if (!isArray(entries)) {
+ throw new TypeError('You must pass an array to allSettled.');
+ }
+
+ var remaining = entries.length;
+ var entry;
if (remaining === 0) {
resolve([]);
+ return;
}
- function resolver(index) {
+ var results = new Array(remaining);
+
+ function fulfilledResolver(index) {
return function(value) {
- resolveAll(index, value);
+ resolveAll(index, fulfilled(value));
+ };
+ }
+
+ function rejectedResolver(index) {
+ return function(reason) {
+ resolveAll(index, rejected(reason));
};
}
@@ -7894,25 +8400,31 @@ define("rsvp/all",
}
}
- for (var i = 0; i < promises.length; i++) {
- promise = promises[i];
+ for (var index = 0; index < entries.length; index++) {
+ entry = entries[index];
- if (promise && typeof promise.then === 'function') {
- promise.then(resolver(i), reject);
+ if (isNonThenable(entry)) {
+ resolveAll(index, fulfilled(entry));
} else {
- resolveAll(i, promise);
+ Promise.cast(entry).then(fulfilledResolver(index), rejectedResolver(index));
}
}
- });
+ }, label);
+ };
+
+ function fulfilled(value) {
+ return { state: 'fulfilled', value: value };
}
-
- __exports__.all = all;
+ function rejected(reason) {
+ return { state: 'rejected', reason: reason };
+ }
});
-define("rsvp/async",
- ["exports"],
- function(__exports__) {
+define("rsvp/config",
+ ["./events","exports"],
+ function(__dependency1__, __exports__) {
"use strict";
+<<<<<<< HEAD
var browserGlobal = (typeof window !== 'undefined') ? window : {};
var BrowserMutationObserver = browserGlobal.MutationObserver || browserGlobal.WebKitMutationObserver;
var async;
@@ -7926,45 +8438,49 @@ define("rsvp/async",
});
};
}
+=======
+ var EventTarget = __dependency1__["default"];
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
- // node >= 0.10.x
- function useSetImmediate() {
- return function(callback, arg) {
- /* global setImmediate */
- setImmediate(function(){
- callback(arg);
- });
- };
+ var config = {
+ instrument: false
+ };
+
+ EventTarget.mixin(config);
+
+ function configure(name, value) {
+ if (name === 'onerror') {
+ // handle for legacy users that expect the actual
+ // error to be passed to their function added via
+ // `RSVP.configure('onerror', someFunctionHere);`
+ config.on('error', value);
+ return;
+ }
+
+ if (arguments.length === 2) {
+ config[name] = value;
+ } else {
+ return config[name];
+ }
}
- function useMutationObserver() {
- var queue = [];
+ __exports__.config = config;
+ __exports__.configure = configure;
+ });
+define("rsvp/defer",
+ ["./promise","exports"],
+ function(__dependency1__, __exports__) {
+ "use strict";
+ var Promise = __dependency1__["default"];
- var observer = new BrowserMutationObserver(function() {
- var toProcess = queue.slice();
- queue = [];
+ /**
+ `RSVP.defer` returns an object similar to jQuery's `$.Deferred`.
+ `RSVP.defer` should be used when porting over code reliant on `$.Deferred`'s
+ interface. New code should use the `RSVP.Promise` constructor instead.
- toProcess.forEach(function(tuple) {
- var callback = tuple[0], arg= tuple[1];
- callback(arg);
- });
- });
-
- var element = document.createElement('div');
- observer.observe(element, { attributes: true });
-
- // Chrome Memory Leak: https://bugs.webkit.org/show_bug.cgi?id=93661
- window.addEventListener('unload', function(){
- observer.disconnect();
- observer = null;
- }, false);
-
- return function(callback, arg) {
- queue.push([callback, arg]);
- element.setAttribute('drainQueue', 'drainQueue');
- };
- }
+ The object returned from `RSVP.defer` is a plain object with three properties:
+<<<<<<< HEAD
function useSetTimeout() {
return function(callback, arg) {
local.setTimeout(function() {
@@ -7972,74 +8488,51 @@ define("rsvp/async",
}, 1);
};
}
+=======
+ * promise - an `RSVP.Promise`.
+ * reject - a function that causes the `promise` property on this object to
+ become rejected
+ * resolve - a function that causes the `promise` property on this object to
+ become fulfilled.
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
- if (typeof setImmediate === 'function') {
- async = useSetImmediate();
- } else if (typeof process !== 'undefined' && {}.toString.call(process) === '[object process]') {
- async = useNextTick();
- } else if (BrowserMutationObserver) {
- async = useMutationObserver();
- } else {
- async = useSetTimeout();
- }
+ Example:
+ ```javascript
+ var deferred = RSVP.defer();
- __exports__.async = async;
- });
-define("rsvp/config",
- ["rsvp/async","exports"],
- function(__dependency1__, __exports__) {
- "use strict";
- var async = __dependency1__.async;
+ deferred.resolve("Success!");
- var config = {};
- config.async = async;
+ defered.promise.then(function(value){
+ // value here is "Success!"
+ });
+ ```
+ @method defer
+ @for RSVP
+ @param {String} label optional string for labeling the promise.
+ Useful for tooling.
+ @return {Object}
+ */
- __exports__.config = config;
- });
-define("rsvp/defer",
- ["rsvp/promise","exports"],
- function(__dependency1__, __exports__) {
- "use strict";
- var Promise = __dependency1__.Promise;
-
- function defer() {
- var deferred = {
- // pre-allocate shape
- resolve: undefined,
- reject: undefined,
- promise: undefined
- };
+ __exports__["default"] = function defer(label) {
+ var deferred = { };
deferred.promise = new Promise(function(resolve, reject) {
deferred.resolve = resolve;
deferred.reject = reject;
- });
+ }, label);
return deferred;
- }
-
-
- __exports__.defer = defer;
+ };
});
-define("rsvp/events",
+define("rsvp/events",
["exports"],
function(__exports__) {
"use strict";
- var Event = function(type, options) {
- this.type = type;
-
- for (var option in options) {
- if (!options.hasOwnProperty(option)) { continue; }
-
- this[option] = options[option];
- }
- };
-
var indexOf = function(callbacks, callback) {
for (var i=0, l=callbacks.length; i 1;
+ };
+
+ RSVP.filter(promises, filterFn).then(function(result){
+ // result is [ 2, 3 ]
+ });
+ ```
+
+ If any of the `promises` given to `RSVP.filter` are rejected, the first promise
+ that is rejected will be given as an argument to the returned promise's
+ rejection handler. For example:
+
+ ```javascript
+ var promise1 = RSVP.resolve(1);
+ var promise2 = RSVP.reject(new Error("2"));
+ var promise3 = RSVP.reject(new Error("3"));
+ var promises = [ promise1, promise2, promise3 ];
+
+ var filterFn = function(item){
+ return item > 1;
+ };
+
+ RSVP.filter(promises, filterFn).then(function(array){
+ // Code here never runs because there are rejected promises!
+ }, function(reason) {
+ // reason.message === "2"
+ });
+ ```
+
+ `RSVP.filter` will also wait for any promises returned from `filterFn`.
+ For instance, you may want to fetch a list of users then return a subset
+ of those users based on some asynchronous operation:
+
+ ```javascript
+
+ var alice = { name: 'alice' };
+ var bob = { name: 'bob' };
+ var users = [ alice, bob ];
+
+ var promises = users.map(function(user){
+ return RSVP.resolve(user);
+ });
+
+ var filterFn = function(user){
+ // Here, Alice has permissions to create a blog post, but Bob does not.
+ return getPrivilegesForUser(user).then(function(privs){
+ return privs.can_create_blog_post === true;
+ });
+ };
+ RSVP.filter(promises, filterFn).then(function(users){
+ // true, because the server told us only Alice can create a blog post.
+ users.length === 1;
+ // false, because Alice is the only user present in `users`
+ users[0] === bob;
+ });
+ ```
+
+ @method filter
+ @for RSVP
+ @param {Array} promises
+ @param {Function} filterFn - function to be called on each resolved value to
+ filter the final results.
+ @param {String} label optional string describing the promise. Useful for
+ tooling.
+ @return {Promise}
+ */
+ function filter(promises, filterFn, label) {
+ return all(promises, label).then(function(values){
+ if (!isArray(promises)) {
+ throw new TypeError('You must pass an array to filter.');
+ }
+
+ if (!isFunction(filterFn)){
+ throw new TypeError("You must pass a function to filter's second argument.");
+ }
+
+ return map(promises, filterFn, label).then(function(filterResults){
+ var i,
+ valuesLen = values.length,
+ filtered = [];
+
+ for (i = 0; i < valuesLen; i++){
+ if(filterResults[i]) filtered.push(values[i]);
+ }
+ return filtered;
+ });
+ });
}
- function hash(promises) {
- var results = {}, deferred = defer(), remaining = size(promises);
-
- if (remaining === 0) {
- deferred.resolve({});
- }
-
- var resolver = function(prop) {
- return function(value) {
- resolveAll(prop, value);
- };
- };
-
- var resolveAll = function(prop, value) {
- results[prop] = value;
- if (--remaining === 0) {
- deferred.resolve(results);
- }
- };
-
- var rejectAll = function(error) {
- deferred.reject(error);
- };
-
- for (var prop in promises) {
- if (promises[prop] && typeof promises[prop].then === 'function') {
- promises[prop].then(resolver(prop), rejectAll);
- } else {
- resolveAll(prop, promises[prop]);
- }
- }
-
- return deferred.promise;
- }
-
-
- __exports__.hash = hash;
+ __exports__["default"] = filter;
});
-define("rsvp/node",
- ["rsvp/promise","rsvp/all","exports"],
+define("rsvp/hash",
+ ["./promise","./utils","exports"],
function(__dependency1__, __dependency2__, __exports__) {
"use strict";
- var Promise = __dependency1__.Promise;
- var all = __dependency2__.all;
+ var Promise = __dependency1__["default"];
+ var isNonThenable = __dependency2__.isNonThenable;
+ var keysOf = __dependency2__.keysOf;
- function makeNodeCallbackFor(resolve, reject) {
- return function (error, value) {
- if (error) {
- reject(error);
- } else if (arguments.length > 2) {
- resolve(Array.prototype.slice.call(arguments, 1));
- } else {
- resolve(value);
+ /**
+ `RSVP.hash` is similar to `RSVP.all`, but takes an object instead of an array
+ for its `promises` argument.
+
+ Returns a promise that is fulfilled when all the given promises have been
+ fulfilled, or rejected if any of them become rejected. The returned promise
+ is fulfilled with a hash that has the same key names as the `promises` object
+ argument. If any of the values in the object are not promises, they will
+ simply be copied over to the fulfilled object.
+
+ Example:
+
+ ```javascript
+ var promises = {
+ myPromise: RSVP.resolve(1),
+ yourPromise: RSVP.resolve(2),
+ theirPromise: RSVP.resolve(3),
+ notAPromise: 4
+ };
+
+ RSVP.hash(promises).then(function(hash){
+ // hash here is an object that looks like:
+ // {
+ // myPromise: 1,
+ // yourPromise: 2,
+ // theirPromise: 3,
+ // notAPromise: 4
+ // }
+ });
+ ````
+
+ If any of the `promises` given to `RSVP.hash` are rejected, the first promise
+ that is rejected will be given as the reason to the rejection handler.
+
+ Example:
+
+ ```javascript
+ var promises = {
+ myPromise: RSVP.resolve(1),
+ rejectedPromise: RSVP.reject(new Error("rejectedPromise")),
+ anotherRejectedPromise: RSVP.reject(new Error("anotherRejectedPromise")),
+ };
+
+ RSVP.hash(promises).then(function(hash){
+ // Code here never runs because there are rejected promises!
+ }, function(reason) {
+ // reason.message === "rejectedPromise"
+ });
+ ```
+
+ An important note: `RSVP.hash` is intended for plain JavaScript objects that
+ are just a set of keys and values. `RSVP.hash` will NOT preserve prototype
+ chains.
+
+ Example:
+
+ ```javascript
+ function MyConstructor(){
+ this.example = RSVP.resolve("Example");
+ }
+
+ MyConstructor.prototype = {
+ protoProperty: RSVP.resolve("Proto Property")
+ };
+
+ var myObject = new MyConstructor();
+
+ RSVP.hash(myObject).then(function(hash){
+ // protoProperty will not be present, instead you will just have an
+ // object that looks like:
+ // {
+ // example: "Example"
+ // }
+ //
+ // hash.hasOwnProperty('protoProperty'); // false
+ // 'undefined' === typeof hash.protoProperty
+ });
+ ```
+
+ @method hash
+ @for RSVP
+ @param {Object} promises
+ @param {String} label optional string that describes the promise.
+ Useful for tooling.
+ @return {Promise} promise that is fulfilled when all properties of `promises`
+ have been fulfilled, or rejected if any of them become rejected.
+ @static
+ */
+ __exports__["default"] = function hash(object, label) {
+ return new Promise(function(resolve, reject){
+ var results = {};
+ var keys = keysOf(object);
+ var remaining = keys.length;
+ var entry, property;
+
+ if (remaining === 0) {
+ resolve(results);
+ return;
}
- };
- }
- function denodeify(nodeFunc) {
- return function() {
- var nodeArgs = Array.prototype.slice.call(arguments), resolve, reject;
- var thisArg = this;
+ function fulfilledTo(property) {
+ return function(value) {
+ results[property] = value;
+ if (--remaining === 0) {
+ resolve(results);
+ }
+ };
+ }
- var promise = new Promise(function(nodeResolve, nodeReject) {
- resolve = nodeResolve;
- reject = nodeReject;
- });
+ function onRejection(reason) {
+ remaining = 0;
+ reject(reason);
+ }
- all(nodeArgs).then(function(nodeArgs) {
- nodeArgs.push(makeNodeCallbackFor(resolve, reject));
+ for (var i = 0; i < keys.length; i++) {
+ property = keys[i];
+ entry = object[property];
- try {
- nodeFunc.apply(thisArg, nodeArgs);
- } catch(e) {
- reject(e);
+ if (isNonThenable(entry)) {
+ results[property] = entry;
+ if (--remaining === 0) {
+ resolve(results);
+ }
+ } else {
+ Promise.cast(entry).then(fulfilledTo(property), onRejection);
}
- });
-
- return promise;
- };
- }
-
-
- __exports__.denodeify = denodeify;
+ }
+ });
+ };
});
-define("rsvp/promise",
- ["rsvp/config","rsvp/events","exports"],
+define("rsvp/instrument",
+ ["./config","./utils","exports"],
function(__dependency1__, __dependency2__, __exports__) {
"use strict";
var config = __dependency1__.config;
- var EventTarget = __dependency2__.EventTarget;
-
- function objectOrFunction(x) {
- return isFunction(x) || (typeof x === "object" && x !== null);
- }
-
- function isFunction(x){
- return typeof x === "function";
- }
-
- var Promise = function(resolver) {
- var promise = this,
- resolved = false;
-
- if (typeof resolver !== 'function') {
- throw new TypeError('You must pass a resolver function as the sole argument to the promise constructor');
- }
-
- if (!(promise instanceof Promise)) {
- return new Promise(resolver);
- }
-
- var resolvePromise = function(value) {
- if (resolved) { return; }
- resolved = true;
- resolve(promise, value);
- };
-
- var rejectPromise = function(value) {
- if (resolved) { return; }
- resolved = true;
- reject(promise, value);
- };
-
- this.on('promise:resolved', function(event) {
- this.trigger('success', { detail: event.detail });
- }, this);
-
- this.on('promise:failed', function(event) {
- this.trigger('error', { detail: event.detail });
- }, this);
-
- this.on('error', onerror);
-
- try {
- resolver(resolvePromise, rejectPromise);
- } catch(e) {
- rejectPromise(e);
- }
- };
-
- function onerror(event) {
- if (config.onerror) {
- config.onerror(event.detail);
- }
- }
-
- var invokeCallback = function(type, promise, callback, event) {
- var hasCallback = isFunction(callback),
- value, error, succeeded, failed;
-
- if (hasCallback) {
- try {
- value = callback(event.detail);
- succeeded = true;
- } catch(e) {
- failed = true;
- error = e;
- }
- } else {
- value = event.detail;
- succeeded = true;
- }
-
- if (handleThenable(promise, value)) {
- return;
- } else if (hasCallback && succeeded) {
- resolve(promise, value);
- } else if (failed) {
- reject(promise, error);
- } else if (type === 'resolve') {
- resolve(promise, value);
- } else if (type === 'reject') {
- reject(promise, value);
- }
- };
-
- Promise.prototype = {
- constructor: Promise,
-
- isRejected: undefined,
- isFulfilled: undefined,
- rejectedReason: undefined,
- fulfillmentValue: undefined,
-
- then: function(done, fail) {
- this.off('error', onerror);
-
- var thenPromise = new this.constructor(function() {});
-
- if (this.isFulfilled) {
- config.async(function(promise) {
- invokeCallback('resolve', thenPromise, done, { detail: promise.fulfillmentValue });
- }, this);
- }
-
- if (this.isRejected) {
- config.async(function(promise) {
- invokeCallback('reject', thenPromise, fail, { detail: promise.rejectedReason });
- }, this);
- }
-
- this.on('promise:resolved', function(event) {
- invokeCallback('resolve', thenPromise, done, event);
- });
-
- this.on('promise:failed', function(event) {
- invokeCallback('reject', thenPromise, fail, event);
- });
+ var now = __dependency2__.now;
+<<<<<<< HEAD
return thenPromise;
},
fail: function(fail) {
return this.then(null, fail);
+=======
+ __exports__["default"] = function instrument(eventName, promise, child) {
+ // instrumentation should not disrupt normal usage.
+ try {
+ config.trigger(eventName, {
+ guid: promise._guidKey + promise._id,
+ eventName: eventName,
+ detail: promise._detail,
+ childGuid: child && promise._guidKey + child._id,
+ label: promise._label,
+ timeStamp: now(),
+ stack: new Error(promise._label).stack
+ });
+ } catch(error) {
+ setTimeout(function(){
+ throw error;
+ }, 0);
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
}
};
+ });
+define("rsvp/map",
+ ["./promise","./all","./utils","exports"],
+ function(__dependency1__, __dependency2__, __dependency3__, __exports__) {
+ "use strict";
+ var Promise = __dependency1__["default"];
+ var all = __dependency2__["default"];
+ var isArray = __dependency3__.isArray;
+ var isFunction = __dependency3__.isFunction;
- EventTarget.mixin(Promise.prototype);
+ /**
+ `RSVP.map` is similar to JavaScript's native `map` method, except that it
+ waits for all promises to become fulfilled before running the `mapFn` on
+ each item in given to `promises`. `RSVP.map` returns a promise that will
+ become fulfilled with the result of running `mapFn` on the values the promises
+ become fulfilled with.
- function resolve(promise, value) {
- if (promise === value) {
- fulfill(promise, value);
- } else if (!handleThenable(promise, value)) {
- fulfill(promise, value);
- }
- }
+ For example:
- function handleThenable(promise, value) {
- var then = null,
- resolved;
+ ```javascript
- try {
- if (promise === value) {
- throw new TypeError("A promises callback cannot return that same promise.");
+ var promise1 = RSVP.resolve(1);
+ var promise2 = RSVP.resolve(2);
+ var promise3 = RSVP.resolve(3);
+ var promises = [ promise1, promise2, promise3 ];
+
+ var mapFn = function(item){
+ return item + 1;
+ };
+
+ RSVP.map(promises, mapFn).then(function(result){
+ // result is [ 2, 3, 4 ]
+ });
+ ```
+
+ If any of the `promises` given to `RSVP.map` are rejected, the first promise
+ that is rejected will be given as an argument to the returned promise's
+ rejection handler. For example:
+
+ ```javascript
+ var promise1 = RSVP.resolve(1);
+ var promise2 = RSVP.reject(new Error("2"));
+ var promise3 = RSVP.reject(new Error("3"));
+ var promises = [ promise1, promise2, promise3 ];
+
+ var mapFn = function(item){
+ return item + 1;
+ };
+
+ RSVP.map(promises, mapFn).then(function(array){
+ // Code here never runs because there are rejected promises!
+ }, function(reason) {
+ // reason.message === "2"
+ });
+ ```
+
+ `RSVP.map` will also wait if a promise is returned from `mapFn`. For example,
+ say you want to get all comments from a set of blog posts, but you need
+ the blog posts first becuase they contain a url to those comments.
+
+ ```javscript
+
+ var mapFn = function(blogPost){
+ // getComments does some ajax and returns an RSVP.Promise that is fulfilled
+ // with some comments data
+ return getComments(blogPost.comments_url);
+ };
+
+ // getBlogPosts does some ajax and returns an RSVP.Promise that is fulfilled
+ // with some blog post data
+ RSVP.map(getBlogPosts(), mapFn).then(function(comments){
+ // comments is the result of asking the server for the comments
+ // of all blog posts returned from getBlogPosts()
+ });
+ ```
+
+ @method map
+ @for RSVP
+ @param {Array} promises
+ @param {Function} mapFn function to be called on each fulfilled promise.
+ @param {String} label optional string for labeling the promise.
+ Useful for tooling.
+ @return {Promise} promise that is fulfilled with the result of calling
+ `mapFn` on each fulfilled promise or value when they become fulfilled.
+ The promise will be rejected if any of the given `promises` become rejected.
+ @static
+ */
+ __exports__["default"] = function map(promises, mapFn, label) {
+ return all(promises, label).then(function(results){
+ if (!isArray(promises)) {
+ throw new TypeError('You must pass an array to map.');
}
- if (objectOrFunction(value)) {
- then = value.then;
-
- if (isFunction(then)) {
- then.call(value, function(val) {
- if (resolved) { return true; }
- resolved = true;
-
- if (value !== val) {
- resolve(promise, val);
- } else {
- fulfill(promise, val);
- }
- }, function(val) {
- if (resolved) { return true; }
- resolved = true;
-
- reject(promise, val);
- });
-
- return true;
- }
+ if (!isFunction(mapFn)){
+ throw new TypeError("You must pass a function to map's second argument.");
}
- } catch (error) {
- reject(promise, error);
- return true;
- }
- return false;
- }
- function fulfill(promise, value) {
- config.async(function() {
- promise.trigger('promise:resolved', { detail: value });
- promise.isFulfilled = true;
- promise.fulfillmentValue = value;
+ var resultLen = results.length,
+ mappedResults = [],
+ i;
+
+ for (i = 0; i < resultLen; i++){
+ mappedResults.push(mapFn(results[i]));
+ }
+
+ return all(mappedResults, label);
});
- }
-
- function reject(promise, value) {
- config.async(function() {
- promise.trigger('promise:failed', { detail: value });
- promise.isRejected = true;
- promise.rejectedReason = value;
- });
- }
-
-
- __exports__.Promise = Promise;
- });
-define("rsvp/reject",
- ["rsvp/promise","exports"],
- function(__dependency1__, __exports__) {
- "use strict";
- var Promise = __dependency1__.Promise;
-
- function reject(reason) {
- return new Promise(function (resolve, reject) {
- reject(reason);
- });
- }
-
-
- __exports__.reject = reject;
- });
-define("rsvp/resolve",
- ["rsvp/promise","exports"],
- function(__dependency1__, __exports__) {
- "use strict";
- var Promise = __dependency1__.Promise;
-
- function resolve(thenable) {
- return new Promise(function(resolve, reject) {
- resolve(thenable);
- });
- }
-
-
- __exports__.resolve = resolve;
+ };
});
+<<<<<<< HEAD
define("rsvp/rethrow",
["exports"],
function(__exports__) {
@@ -8486,12 +9158,35 @@ define("rsvp",
var config = __dependency8__.config;
var resolve = __dependency9__.resolve;
var reject = __dependency10__.reject;
+=======
+define("rsvp/node",
+ ["./promise","exports"],
+ function(__dependency1__, __exports__) {
+ "use strict";
+ var Promise = __dependency1__["default"];
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
- function configure(name, value) {
- config[name] = value;
+ var slice = Array.prototype.slice;
+
+ function makeNodeCallbackFor(resolve, reject) {
+ return function (error, value) {
+ if (error) {
+ reject(error);
+ } else if (arguments.length > 2) {
+ resolve(slice.call(arguments, 1));
+ } else {
+ resolve(value);
+ }
+ };
}
+ /**
+ `RSVP.denodeify` takes a "node-style" function and returns a function that
+ will return an `RSVP.Promise`. You can use `denodeify` in Node.js or the
+ browser when you'd prefer to use promises over using callbacks. For example,
+ `denodeify` transforms the following:
+<<<<<<< HEAD
__exports__.Promise = Promise;
__exports__.EventTarget = EventTarget;
__exports__.all = all;
@@ -8520,6 +9215,1515 @@ The public api, specified on the application namespace should be considered the
*/
Ember.MODEL_FACTORY_INJECTIONS = false || !!Ember.ENV.MODEL_FACTORY_INJECTIONS;
+define("container",
+ [],
+ function() {
+
+ // A safe and simple inheriting object.
+ function InheritingDict(parent) {
+ this.parent = parent;
+ this.dict = {};
+ }
+=======
+ ```javascript
+ var fs = require('fs');
+
+ fs.readFile('myfile.txt', function(err, data){
+ if (err) return handleError(err);
+ handleData(data);
+ });
+ ```
+
+ into:
+
+ ```javascript
+ var fs = require('fs');
+
+ var readFile = RSVP.denodeify(fs.readFile);
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
+
+ readFile('myfile.txt').then(handleData, handleError);
+ ```
+
+ Using `denodeify` makes it easier to compose asynchronous operations instead
+ of using callbacks. For example, instead of:
+
+ ```javascript
+ var fs = require('fs');
+ var log = require('some-async-logger');
+
+ fs.readFile('myfile.txt', function(err, data){
+ if (err) return handleError(err);
+ fs.writeFile('myfile2.txt', data, function(err){
+ if (err) throw err;
+ log('success', function(err) {
+ if (err) throw err;
+ });
+ });
+ });
+ ```
+
+ You can chain the operations together using `then` from the returned promise:
+
+ ```javascript
+ var fs = require('fs');
+ var denodeify = RSVP.denodeify;
+ var readFile = denodeify(fs.readFile);
+ var writeFile = denodeify(fs.writeFile);
+ var log = denodeify(require('some-async-logger'));
+
+ readFile('myfile.txt').then(function(data){
+ return writeFile('myfile2.txt', data);
+ }).then(function(){
+ return log('SUCCESS');
+ }).then(function(){
+ // success handler
+ }, function(reason){
+ // rejection handler
+ });
+ ```
+
+ @method denodeify
+ @for RSVP
+ @param {Function} nodeFunc a "node-style" function that takes a callback as
+ its last argument. The callback expects an error to be passed as its first
+ argument (if an error occurred, otherwise null), and the value from the
+ operation as its second argument ("function(err, value){ }").
+ @param {Any} binding optional argument for binding the "this" value when
+ calling the `nodeFunc` function.
+ @return {Function} a function that wraps `nodeFunc` to return an
+ `RSVP.Promise`
+ @static
+ */
+ __exports__["default"] = function denodeify(nodeFunc, binding) {
+ return function() {
+ var nodeArgs = slice.call(arguments), resolve, reject;
+ var thisArg = this || binding;
+
+ return new Promise(function(resolve, reject) {
+ Promise.all(nodeArgs).then(function(nodeArgs) {
+ try {
+ nodeArgs.push(makeNodeCallbackFor(resolve, reject));
+ nodeFunc.apply(thisArg, nodeArgs);
+ } catch(e) {
+ reject(e);
+ }
+ });
+ });
+ };
+ };
+ });
+define("rsvp/promise",
+ ["./config","./events","./instrument","./utils","./promise/cast","./promise/all","./promise/race","./promise/resolve","./promise/reject","exports"],
+ function(__dependency1__, __dependency2__, __dependency3__, __dependency4__, __dependency5__, __dependency6__, __dependency7__, __dependency8__, __dependency9__, __exports__) {
+ "use strict";
+ var config = __dependency1__.config;
+ var EventTarget = __dependency2__["default"];
+ var instrument = __dependency3__["default"];
+ var objectOrFunction = __dependency4__.objectOrFunction;
+ var isFunction = __dependency4__.isFunction;
+ var now = __dependency4__.now;
+ var cast = __dependency5__["default"];
+ var all = __dependency6__["default"];
+ var race = __dependency7__["default"];
+ var Resolve = __dependency8__["default"];
+ var Reject = __dependency9__["default"];
+
+ var guidKey = 'rsvp_' + now() + '-';
+ var counter = 0;
+
+ function noop() {}
+
+ __exports__["default"] = Promise;
+
+
+ /**
+ Promise objects represent the eventual result of an asynchronous operation. The
+ primary way of interacting with a promise is through its `then` method, which
+ registers callbacks to receive either a promise’s eventual value or the reason
+ why the promise cannot be fulfilled.
+
+ Terminology
+ -----------
+
+ - `promise` is an object or function with a `then` method whose behavior conforms to this specification.
+ - `thenable` is an object or function that defines a `then` method.
+ - `value` is any legal JavaScript value (including undefined, a thenable, or a promise).
+ - `exception` is a value that is thrown using the throw statement.
+ - `reason` is a value that indicates why a promise was rejected.
+ - `settled` the final resting state of a promise, fulfilled or rejected.
+
+ A promise can be in one of three states: pending, fulfilled, or rejected.
+
+<<<<<<< HEAD
+ @method has
+ @param {String} key
+ @return {Boolean}
+ */
+ has: function(key) {
+ var dict = this.dict;
+=======
+ Promises that are fulfilled have a fulfillment value and are in the fulfilled
+ state. Promises that are rejected have a rejection reason and are in the
+ rejected state. A fulfillment value is never a thenable. Similarly, a
+ rejection reason is never a thenable.
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
+
+ Promises can also be said to *resolve* a value. If this value is also a
+ promise, then the original promise's settled state will match the value's
+ settled state. So a promise that *resolves* a promise that rejects will
+ itself reject, and a promise that *resolves* a promise that fulfills will
+ itself fulfill.
+
+
+ Basic Usage:
+ ------------
+
+ ```js
+ var promise = new Promise(function(resolve, reject) {
+ // on success
+ resolve(value);
+
+ // on failure
+ reject(reason);
+ });
+
+ promise.then(function(value) {
+ // on fulfillment
+ }, function(reason) {
+ // on rejection
+ });
+ ```
+
+ Advanced Usage:
+ ---------------
+
+ Promises shine when abstracting away asynchronous interactions such as
+ `XMLHttpRequest`s.
+
+ ```js
+ function getJSON(url) {
+ return new Promise(function(resolve, reject){
+ var xhr = new XMLHttpRequest();
+
+ xhr.open('GET', url);
+ xhr.onreadystatechange = handler;
+ xhr.responseType = 'json';
+ xhr.setRequestHeader('Accept', 'application/json');
+ xhr.send();
+
+ function handler() {
+ if (this.readyState === this.DONE) {
+ if (this.status === 200) {
+ resolve(this.response);
+ } else {
+ reject(new Error("getJSON: `" + url + "` failed with status: [" + this.status + "]");
+ }
+ }
+ };
+ });
+ }
+
+<<<<<<< HEAD
+
+ // A lightweight container that helps to assemble and decouple components.
+ // Public api for the container is still in flux.
+ // The public api, specified on the application namespace should be considered the stable api.
+ function Container(parent) {
+ this.parent = parent;
+ this.children = [];
+=======
+ getJSON('/posts.json').then(function(json) {
+ // on fulfillment
+ }, function(reason) {
+ // on rejection
+ });
+ ```
+
+ Unlike callbacks, promises are great composable primitives.
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
+
+ ```js
+ Promise.all([
+ getJSON('/posts'),
+ getJSON('/comments')
+ ]).then(function(values){
+ values[0] // => postsJSON
+ values[1] // => commentsJSON
+
+ return values;
+ });
+ ```
+
+ @class RSVP.Promise
+ @param {function}
+ @param {String} label optional string for labeling the promise.
+ Useful for tooling.
+ @constructor
+ */
+ function Promise(resolver, label) {
+ if (!isFunction(resolver)) {
+ throw new TypeError('You must pass a resolver function as the first argument to the promise constructor');
+ }
+
+ if (!(this instanceof Promise)) {
+ throw new TypeError("Failed to construct 'Promise': Please use the 'new' operator, this object constructor cannot be called as a function.");
+ }
+
+ this._id = counter++;
+ this._label = label;
+ this._subscribers = [];
+
+ if (config.instrument) {
+ instrument('created', this);
+ }
+
+ if (noop !== resolver) {
+ invokeResolver(resolver, this);
+ }
+ }
+
+ function invokeResolver(resolver, promise) {
+ function resolvePromise(value) {
+ resolve(promise, value);
+ }
+
+ function rejectPromise(reason) {
+ reject(promise, reason);
+ }
+
+ try {
+ resolver(resolvePromise, rejectPromise);
+ } catch(e) {
+ rejectPromise(e);
+ }
+ }
+
+ Promise.cast = cast;
+ Promise.all = all;
+ Promise.race = race;
+ Promise.resolve = Resolve;
+ Promise.reject = Reject;
+
+ var PENDING = void 0;
+ var SEALED = 0;
+ var FULFILLED = 1;
+ var REJECTED = 2;
+
+ function subscribe(parent, child, onFulfillment, onRejection) {
+ var subscribers = parent._subscribers;
+ var length = subscribers.length;
+
+ subscribers[length] = child;
+ subscribers[length + FULFILLED] = onFulfillment;
+ subscribers[length + REJECTED] = onRejection;
+ }
+
+ function publish(promise, settled) {
+ var child, callback, subscribers = promise._subscribers, detail = promise._detail;
+
+ if (config.instrument) {
+ instrument(settled === FULFILLED ? 'fulfilled' : 'rejected', promise);
+ }
+
+ for (var i = 0; i < subscribers.length; i += 3) {
+ child = subscribers[i];
+ callback = subscribers[i + settled];
+
+ invokeCallback(settled, child, callback, detail);
+ }
+
+ promise._subscribers = null;
+ }
+
+ Promise.prototype = {
+ constructor: Promise,
+
+<<<<<<< HEAD
+ @method child
+ @return {Container}
+ */
+ child: function() {
+ var container = new Container(this);
+ this.children.push(container);
+ return container;
+ },
+=======
+ _id: undefined,
+ _guidKey: guidKey,
+ _label: undefined,
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
+
+ _state: undefined,
+ _detail: undefined,
+ _subscribers: undefined,
+
+ _onerror: function (reason) {
+ config.trigger('error', reason);
+ },
+
+ /**
+ The primary way of interacting with a promise is through its `then` method,
+ which registers callbacks to receive either a promise's eventual value or the
+ reason why the promise cannot be fulfilled.
+
+ ```js
+ findUser().then(function(user){
+ // user is available
+ }, function(reason){
+ // user is unavailable, and you are given the reason why
+ });
+ ```
+
+ Chaining
+ --------
+
+ The return value of `then` is itself a promise. This second, "downstream"
+ promise is resolved with the return value of the first promise's fulfillment
+ or rejection handler, or rejected if the handler throws an exception.
+
+ ```js
+ findUser().then(function (user) {
+ return user.name;
+ }, function (reason) {
+ return "default name";
+ }).then(function (userName) {
+ // If `findUser` fulfilled, `userName` will be the user's name, otherwise it
+ // will be `"default name"`
+ });
+
+<<<<<<< HEAD
+ container.register('model:user', Person, {singleton: false });
+ container.register('fruit:favorite', Orange);
+ container.register('communication:main', Email, {singleton: false});
+ ```
+
+ @method register
+ @param {String} fullName
+ @param {Function} factory
+ @param {Object} options
+ */
+ register: function(fullName, factory, options) {
+ if (fullName.indexOf(':') === -1) {
+ throw new TypeError("malformed fullName, expected: `type:name` got: " + fullName + "");
+ }
+
+ if (factory === undefined) {
+ throw new TypeError('Attempting to register an unknown factory: `' + fullName + '`');
+ }
+=======
+ findUser().then(function (user) {
+ throw new Error("Found user, but still unhappy");
+ }, function (reason) {
+ throw new Error("`findUser` rejected and we're unhappy");
+ }).then(function (value) {
+ // never reached
+ }, function (reason) {
+ // if `findUser` fulfilled, `reason` will be "Found user, but still unhappy".
+ // If `findUser` rejected, `reason` will be "`findUser` rejected and we're unhappy".
+ });
+ ```
+ If the downstream promise does not specify a rejection handler, rejection reasons will be propagated further downstream.
+
+ ```js
+ findUser().then(function (user) {
+ throw new PedagogicalException("Upstream error");
+ }).then(function (value) {
+ // never reached
+ }).then(function (value) {
+ // never reached
+ }, function (reason) {
+ // The `PedgagocialException` is propagated all the way down to here
+ });
+ ```
+
+ Assimilation
+ ------------
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
+
+ Sometimes the value you want to propagate to a downstream promise can only be
+ retrieved asynchronously. This can be achieved by returning a promise in the
+ fulfillment or rejection handler. The downstream promise will then be pending
+ until the returned promise is settled. This is called *assimilation*.
+
+<<<<<<< HEAD
+ if (this.cache.has(normalizedName)) {
+ throw new Error('Cannot re-register: `' + fullName +'`, as it has already been looked up.');
+ }
+
+ this.registry.set(normalizedName, factory);
+ this._options.set(normalizedName, options || {});
+ },
+=======
+ ```js
+ findUser().then(function (user) {
+ return findCommentsByAuthor(user);
+ }).then(function (comments) {
+ // The user's comments are now available
+ });
+ ```
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
+
+ If the assimliated promise rejects, then the downstream promise will also reject.
+
+ ```js
+ findUser().then(function (user) {
+ return findCommentsByAuthor(user);
+ }).then(function (comments) {
+ // If `findCommentsByAuthor` fulfills, we'll have the value here
+ }, function (reason) {
+ // If `findCommentsByAuthor` rejects, we'll have the reason here
+ });
+ ```
+
+ Simple Example
+ --------------
+
+<<<<<<< HEAD
+ container.unregister('model:user')
+ container.lookup('model:user') === undefined //=> true
+ ```
+=======
+ Synchronous Example
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
+
+ ```javascript
+ var result;
+
+<<<<<<< HEAD
+ this.registry.remove(normalizedName);
+ this.cache.remove(normalizedName);
+ this.factoryCache.remove(normalizedName);
+ this._options.remove(normalizedName);
+ },
+=======
+ try {
+ result = findResult();
+ // success
+ } catch(reason) {
+ // failure
+ }
+ ```
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
+
+ Errback Example
+
+ ```js
+ findResult(function(result, err){
+ if (err) {
+ // failure
+ } else {
+ // success
+ }
+ });
+ ```
+
+ Promise Example;
+
+ ```javascript
+ findResult().then(function(result){
+ // success
+ }, function(reason){
+ // failure
+ });
+ ```
+
+ Advanced Example
+ --------------
+
+ Synchronous Example
+
+ ```javascript
+ var author, books;
+
+<<<<<<< HEAD
+ @method resolve
+ @param {String} fullName
+ @return {Function} fullName's factory
+ */
+ resolve: function(fullName) {
+ return this.resolver(fullName) || this.registry.get(fullName);
+ },
+=======
+ try {
+ author = findAuthor();
+ books = findBooksByAuthor(author);
+ // success
+ } catch(reason) {
+ // failure
+ }
+ ```
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
+
+ Errback Example
+
+ ```js
+
+ function foundBooks(books) {
+
+ }
+
+ function failure(reason) {
+
+<<<<<<< HEAD
+ /**
+ @method makeToString
+
+ @param {any} factory
+ @param {string} fullName
+ @return {function} toString function
+ */
+ makeToString: function(factory, fullName) {
+ return factory.toString();
+ },
+
+ /**
+ Given a fullName return a corresponding instance.
+=======
+ }
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
+
+ findAuthor(function(author, err){
+ if (err) {
+ failure(err);
+ // failure
+ } else {
+ try {
+ findBoooksByAuthor(author, function(books, err) {
+ if (err) {
+ failure(err);
+ } else {
+ try {
+ foundBooks(books);
+ } catch(reason) {
+ failure(reason);
+ }
+ }
+ });
+ } catch(error) {
+ failure(err);
+ }
+ // success
+ }
+ });
+ ```
+
+ Promise Example;
+
+ ```javascript
+ findAuthor().
+ then(findBooksByAuthor).
+ then(function(books){
+ // found books
+ }).catch(function(reason){
+ // something went wrong
+ });
+ ```
+
+ @method then
+ @param {Function} onFulfilled
+ @param {Function} onRejected
+ @param {String} label optional string for labeling the promise.
+ Useful for tooling.
+ @return {Promise}
+ */
+ then: function(onFulfillment, onRejection, label) {
+ var promise = this;
+ this._onerror = null;
+
+ var thenPromise = new this.constructor(noop, label);
+
+ if (this._state) {
+ var callbacks = arguments;
+ config.async(function invokePromiseCallback() {
+ invokeCallback(promise._state, thenPromise, callbacks[promise._state - 1], promise._detail);
+ });
+ } else {
+ subscribe(this, thenPromise, onFulfillment, onRejection);
+ }
+
+ if (config.instrument) {
+ instrument('chained', promise, thenPromise);
+ }
+
+ return thenPromise;
+ },
+
+ /**
+ `catch` is simply sugar for `then(undefined, onRejection)` which makes it the same
+ as the catch block of a try/catch statement.
+
+ ```js
+ function findAuthor(){
+ throw new Error("couldn't find that author");
+ }
+
+ // synchronous
+ try {
+ findAuthor();
+ } catch(reason) {
+ // something went wrong
+ }
+
+ // async with promises
+ findAuthor().catch(function(reason){
+ // something went wrong
+ });
+ ```
+
+ @method catch
+ @param {Function} onRejection
+ @param {String} label optional string for labeling the promise.
+ Useful for tooling.
+ @return {Promise}
+ */
+ 'catch': function(onRejection, label) {
+ return this.then(null, onRejection, label);
+ },
+
+ /**
+ `finally` will be invoked regardless of the promise's fate just as native
+ try/catch/finally behaves
+
+<<<<<<< HEAD
+ if (value === undefined) { return; }
+=======
+ Synchronous example:
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
+
+ ```js
+ findAuthor() {
+ if (Math.random() > 0.5) {
+ throw new Error();
+ }
+ return new Author();
+ }
+
+ try {
+ return findAuthor(); // succeed or fail
+ } catch(error) {
+ return findOtherAuther();
+ } finally {
+ // always runs
+ // doesn't affect the return value
+ }
+ ```
+
+ Asynchronous example:
+
+ ```js
+ findAuthor().catch(function(reason){
+ return findOtherAuther();
+ }).finally(function(){
+ // author was either found, or not
+ });
+ ```
+
+ @method finally
+ @param {Function} callback
+ @param {String} label optional string for labeling the promise.
+ Useful for tooling.
+ @return {Promise}
+ */
+ 'finally': function(callback, label) {
+ var constructor = this.constructor;
+
+ return this.then(function(value) {
+ return constructor.cast(callback()).then(function(){
+ return value;
+ });
+ }, function(reason) {
+ return constructor.cast(callback()).then(function(){
+ throw reason;
+ });
+ }, label);
+ }
+ };
+
+ function invokeCallback(settled, promise, callback, detail) {
+ var hasCallback = isFunction(callback),
+ value, error, succeeded, failed;
+
+ if (hasCallback) {
+ try {
+ value = callback(detail);
+ succeeded = true;
+ } catch(e) {
+ failed = true;
+ error = e;
+ }
+ } else {
+ value = detail;
+ succeeded = true;
+ }
+
+ if (handleThenable(promise, value)) {
+ return;
+ } else if (hasCallback && succeeded) {
+ resolve(promise, value);
+ } else if (failed) {
+ reject(promise, error);
+ } else if (settled === FULFILLED) {
+ resolve(promise, value);
+ } else if (settled === REJECTED) {
+ reject(promise, value);
+ }
+ }
+
+ function handleThenable(promise, value) {
+ var then = null,
+ resolved;
+
+ try {
+ if (promise === value) {
+ throw new TypeError("A promises callback cannot return that same promise.");
+ }
+
+ if (objectOrFunction(value)) {
+ then = value.then;
+
+ if (isFunction(then)) {
+ then.call(value, function(val) {
+ if (resolved) { return true; }
+ resolved = true;
+
+ if (value !== val) {
+ resolve(promise, val);
+ } else {
+ fulfill(promise, val);
+ }
+ }, function(val) {
+ if (resolved) { return true; }
+ resolved = true;
+
+ reject(promise, val);
+ }, 'derived from: ' + (promise._label || ' unknown promise'));
+
+ return true;
+ }
+ }
+ } catch (error) {
+ if (resolved) { return true; }
+ reject(promise, error);
+ return true;
+ }
+
+ return false;
+ }
+
+ function resolve(promise, value) {
+ if (promise === value) {
+ fulfill(promise, value);
+ } else if (!handleThenable(promise, value)) {
+ fulfill(promise, value);
+ }
+ }
+
+<<<<<<< HEAD
+ /**
+ @private
+=======
+ function fulfill(promise, value) {
+ if (promise._state !== PENDING) { return; }
+ promise._state = SEALED;
+ promise._detail = value;
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
+
+ config.async(publishFulfillment, promise);
+ }
+
+ function reject(promise, reason) {
+ if (promise._state !== PENDING) { return; }
+ promise._state = SEALED;
+ promise._detail = reason;
+
+ config.async(publishRejection, promise);
+ }
+
+ function publishFulfillment(promise) {
+ publish(promise, promise._state = FULFILLED);
+ }
+
+ function publishRejection(promise) {
+ if (promise._onerror) {
+ promise._onerror(promise._detail);
+ }
+
+ publish(promise, promise._state = REJECTED);
+ }
+ });
+define("rsvp/promise/all",
+ ["../utils","exports"],
+ function(__dependency1__, __exports__) {
+ "use strict";
+ var isArray = __dependency1__.isArray;
+ var isNonThenable = __dependency1__.isNonThenable;
+
+ /**
+ `RSVP.Promise.all` accepts an array of promises, and returns a new promise which
+ is fulfilled with an array of fulfillment values for the passed promises, or
+ rejected with the reason of the first passed promise to be rejected. It casts all
+ elements of the passed iterable to promises as it runs this algorithm.
+
+ Example:
+
+ ```javascript
+ var promise1 = RSVP.resolve(1);
+ var promise2 = RSVP.resolve(2);
+ var promise3 = RSVP.resolve(3);
+ var promises = [ promise1, promise2, promise3 ];
+
+ RSVP.Promise.all(promises).then(function(array){
+ // The array here would be [ 1, 2, 3 ];
+ });
+ ```
+
+ If any of the `promises` given to `RSVP.all` are rejected, the first promise
+ that is rejected will be given as an argument to the returned promises's
+ rejection handler. For example:
+
+<<<<<<< HEAD
+ /**
+ Defines injection rules.
+=======
+ Example:
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
+
+ ```javascript
+ var promise1 = RSVP.resolve(1);
+ var promise2 = RSVP.reject(new Error("2"));
+ var promise3 = RSVP.reject(new Error("3"));
+ var promises = [ promise1, promise2, promise3 ];
+
+ RSVP.Promise.all(promises).then(function(array){
+ // Code here never runs because there are rejected promises!
+ }, function(error) {
+ // error.message === "2"
+ });
+ ```
+
+<<<<<<< HEAD
+ * Injecting one fullName on another fullName
+ * Injecting one fullName on a type
+=======
+ @method all
+ @for RSVP.Promise
+ @param {Array} entries array of promises
+ @param {String} label optional string for labeling the promise.
+ Useful for tooling.
+ @return {Promise} promise that is fulfilled when all `promises` have been
+ fulfilled, or rejected if any of them become rejected.
+ @static
+ */
+ __exports__["default"] = function all(entries, label) {
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
+
+ /*jshint validthis:true */
+ var Constructor = this;
+
+ return new Constructor(function(resolve, reject) {
+ if (!isArray(entries)) {
+ throw new TypeError('You must pass an array to all.');
+ }
+
+ var remaining = entries.length;
+ var results = new Array(remaining);
+ var entry, pending = true;
+
+ if (remaining === 0) {
+ resolve(results);
+ return;
+ }
+
+ function fulfillmentAt(index) {
+ return function(value) {
+ results[index] = value;
+ if (--remaining === 0) {
+ resolve(results);
+ }
+ };
+ }
+
+ function onRejection(reason) {
+ remaining = 0;
+ reject(reason);
+ }
+
+ for (var index = 0; index < entries.length; index++) {
+ entry = entries[index];
+ if (isNonThenable(entry)) {
+ results[index] = entry;
+ if (--remaining === 0) {
+ resolve(results);
+ }
+ } else {
+ Constructor.cast(entry).then(fulfillmentAt(index), onRejection);
+ }
+ }
+ }, label);
+ };
+ });
+define("rsvp/promise/cast",
+ ["exports"],
+ function(__exports__) {
+ "use strict";
+ /**
+ `RSVP.Promise.cast` coerces its argument to a promise, or returns the
+ argument if it is already a promise which shares a constructor with the caster.
+
+ Example:
+
+ ```javascript
+ var promise = RSVP.Promise.resolve(1);
+ var casted = RSVP.Promise.cast(promise);
+
+ console.log(promise === casted); // true
+ ```
+
+ In the case of a promise whose constructor does not match, it is assimilated.
+ The resulting promise will fulfill or reject based on the outcome of the
+ promise being casted.
+
+ Example:
+
+ ```javascript
+ var thennable = $.getJSON('/api/foo');
+ var casted = RSVP.Promise.cast(thennable);
+
+<<<<<<< HEAD
+ /**
+ @private
+=======
+ console.log(thennable === casted); // false
+ console.log(casted instanceof RSVP.Promise) // true
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
+
+ casted.then(function(data) {
+ // data is the value getJSON fulfills with
+ });
+ ```
+
+ In the case of a non-promise, a promise which will fulfill with that value is
+ returned.
+
+ Example:
+
+ ```javascript
+ var value = 1; // could be a number, boolean, string, undefined...
+ var casted = RSVP.Promise.cast(value);
+
+ console.log(value === casted); // false
+ console.log(casted instanceof RSVP.Promise) // true
+
+ casted.then(function(val) {
+ val === value // => true
+ });
+ ```
+
+ `RSVP.Promise.cast` is similar to `RSVP.Promise.resolve`, but `RSVP.Promise.cast` differs in the
+ following ways:
+
+ * `RSVP.Promise.cast` serves as a memory-efficient way of getting a promise, when you
+ have something that could either be a promise or a value. RSVP.resolve
+ will have the same effect but will create a new promise wrapper if the
+ argument is a promise.
+ * `RSVP.Promise.cast` is a way of casting incoming thenables or promise subclasses to
+ promises of the exact class specified, so that the resulting object's `then` is
+ ensured to have the behavior of the constructor you are calling cast on (i.e., RSVP.Promise).
+
+ @method cast
+ @param {Object} object to be casted
+ @param {String} label optional string for labeling the promise.
+ Useful for tooling.
+ @return {Promise} promise
+ @static
+ */
+
+ __exports__["default"] = function cast(object, label) {
+ /*jshint validthis:true */
+ var Constructor = this;
+
+ if (object && typeof object === 'object' && object.constructor === Constructor) {
+ return object;
+ }
+
+ return new Constructor(function(resolve) {
+ resolve(object);
+ }, label);
+ };
+ });
+define("rsvp/promise/race",
+ ["../utils","exports"],
+ function(__dependency1__, __exports__) {
+ "use strict";
+ /* global toString */
+
+<<<<<<< HEAD
+ /**
+ Defines factory injection rules.
+=======
+ var isArray = __dependency1__.isArray;
+ var isFunction = __dependency1__.isFunction;
+ var isNonThenable = __dependency1__.isNonThenable;
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
+
+ /**
+ `RSVP.Promise.race` returns a new promise which is settled in the same way as the
+ first passed promise to settle.
+
+ Example:
+
+ ```javascript
+ var promise1 = new RSVP.Promise(function(resolve, reject){
+ setTimeout(function(){
+ resolve("promise 1");
+ }, 200);
+ });
+
+<<<<<<< HEAD
+ * Injecting one fullName on another fullName
+ * Injecting one fullName on a type
+=======
+ var promise2 = new RSVP.Promise(function(resolve, reject){
+ setTimeout(function(){
+ resolve("promise 2");
+ }, 100);
+ });
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
+
+ RSVP.Promise.race([promise1, promise2]).then(function(result){
+ // result === "promise 2" because it was resolved before promise1
+ // was resolved.
+ });
+ ```
+
+ `RSVP.Promise.race` is deterministic in that only the state of the first
+ settled promise matters. For example, even if other promises given to the
+ `promises` array argument are resolved, but the first settled promise has
+ become rejected before the other promises became fulfilled, the returned
+ promise will become rejected:
+
+ ```javascript
+ var promise1 = new RSVP.Promise(function(resolve, reject){
+ setTimeout(function(){
+ resolve("promise 1");
+ }, 200);
+ });
+
+ var promise2 = new RSVP.Promise(function(resolve, reject){
+ setTimeout(function(){
+ reject(new Error("promise 2"));
+ }, 100);
+ });
+
+ RSVP.Promise.race([promise1, promise2]).then(function(result){
+ // Code here never runs
+ }, function(reason){
+ // reason.message === "promise2" because promise 2 became rejected before
+ // promise 1 became fulfilled
+ });
+ ```
+
+ An example real-world use case is implementing timeouts:
+
+ ```javascript
+ RSVP.Promise.race([ajax('foo.json'), timeout(5000)])
+ ```
+
+ @method race
+ @param {Array} promises array of promises to observe
+ @param {String} label optional string for describing the promise returned.
+ Useful for tooling.
+ @return {Promise} a promise which settles in the same way as the first passed
+ promise to settle.
+ @static
+ */
+ __exports__["default"] = function race(entries, label) {
+ /*jshint validthis:true */
+ var Constructor = this, entry;
+
+ return new Constructor(function(resolve, reject) {
+ if (!isArray(entries)) {
+ throw new TypeError('You must pass an array to race.');
+ }
+
+ var pending = true;
+
+ function onFulfillment(value) { if (pending) { pending = false; resolve(value); } }
+ function onRejection(reason) { if (pending) { pending = false; reject(reason); } }
+
+ for (var i = 0; i < entries.length; i++) {
+ entry = entries[i];
+ if (isNonThenable(entry)) {
+ pending = false;
+ resolve(entry);
+ return;
+ } else {
+ Constructor.cast(entry).then(onFulfillment, onRejection);
+ }
+ }
+ }, label);
+ };
+ });
+define("rsvp/promise/reject",
+ ["exports"],
+ function(__exports__) {
+ "use strict";
+ /**
+ `RSVP.Promise.reject` returns a promise rejected with the passed `reason`.
+ It is shorthand for the following:
+
+ ```javascript
+ var promise = new RSVP.Promise(function(resolve, reject){
+ reject(new Error('WHOOPS'));
+ });
+
+ promise.then(function(value){
+ // Code here doesn't run because the promise is rejected!
+ }, function(reason){
+ // reason.message === 'WHOOPS'
+ });
+ ```
+
+ Instead of writing the above, your code now simply becomes the following:
+
+ ```javascript
+ var promise = RSVP.Promise.reject(new Error('WHOOPS'));
+
+ promise.then(function(value){
+ // Code here doesn't run because the promise is rejected!
+ }, function(reason){
+ // reason.message === 'WHOOPS'
+ });
+ ```
+
+ @method reject
+ @param {Any} reason value that the returned promise will be rejected with.
+ @param {String} label optional string for identifying the returned promise.
+ Useful for tooling.
+ @return {Promise} a promise rejected with the given `reason`.
+ @static
+ */
+ __exports__["default"] = function reject(reason, label) {
+ /*jshint validthis:true */
+ var Constructor = this;
+
+ return new Constructor(function (resolve, reject) {
+ reject(reason);
+ }, label);
+ };
+ });
+define("rsvp/promise/resolve",
+ ["exports"],
+ function(__exports__) {
+ "use strict";
+ /**
+ `RSVP.Promise.resolve` returns a promise that will become resolved with the
+ passed `value`. It is shorthand for the following:
+
+ ```javascript
+ var promise = new RSVP.Promise(function(resolve, reject){
+ resolve(1);
+ });
+
+ promise.then(function(value){
+ // value === 1
+ });
+ ```
+
+ Instead of writing the above, your code now simply becomes the following:
+
+ ```javascript
+ var promise = RSVP.Promise.resolve(1);
+
+ promise.then(function(value){
+ // value === 1
+ });
+ ```
+
+<<<<<<< HEAD
+ if (lookup !== undefined) {
+ hash[injection.property] = lookup;
+ } else {
+ throw new Error('Attempting to inject an unknown injection: `' + injection.fullName + '`');
+ }
+ }
+=======
+ @method resolve
+ @param {Any} value value that the returned promise will be resolved with
+ @param {String} label optional string for identifying the returned promise.
+ Useful for tooling.
+ @return {Promise} a promise that will become fulfilled with the given
+ `value`
+ @static
+ */
+ __exports__["default"] = function resolve(value, label) {
+ /*jshint validthis:true */
+ var Constructor = this;
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
+
+ return new Constructor(function(resolve, reject) {
+ resolve(value);
+ }, label);
+ };
+ });
+define("rsvp/race",
+ ["./promise","exports"],
+ function(__dependency1__, __exports__) {
+ "use strict";
+ var Promise = __dependency1__["default"];
+
+ /**
+ This is a convenient alias for `RSVP.Promise.race`.
+
+ @method race
+ @param {Array} array Array of promises.
+ @param {String} label An optional label. This is useful
+ for tooling.
+ @static
+ */
+ __exports__["default"] = function race(array, label) {
+ return Promise.race(array, label);
+ };
+ });
+define("rsvp/reject",
+ ["./promise","exports"],
+ function(__dependency1__, __exports__) {
+ "use strict";
+ var Promise = __dependency1__["default"];
+
+ /**
+ This is a convenient alias for `RSVP.Promise.reject`.
+
+ @method reject
+ @for RSVP
+ @param {Any} reason value that the returned promise will be rejected with.
+ @param {String} label optional string for identifying the returned promise.
+ Useful for tooling.
+ @return {Promise} a promise rejected with the given `reason`.
+ @static
+ */
+ __exports__["default"] = function reject(reason, label) {
+ return Promise.reject(reason, label);
+ };
+ });
+define("rsvp/resolve",
+ ["./promise","exports"],
+ function(__dependency1__, __exports__) {
+ "use strict";
+ var Promise = __dependency1__["default"];
+
+ /**
+ This is a convenient alias for `RSVP.Promise.resolve`.
+
+ @method resolve
+ @for RSVP
+ @param {Any} value value that the returned promise will be resolved with
+ @param {String} label optional string for identifying the returned promise.
+ Useful for tooling.
+ @return {Promise} a promise that will become fulfilled with the given
+ `value`
+ @static
+ */
+ __exports__["default"] = function resolve(value, label) {
+ return Promise.resolve(value, label);
+ };
+ });
+define("rsvp/rethrow",
+ ["exports"],
+ function(__exports__) {
+ "use strict";
+ /**
+ `RSVP.rethrow` will rethrow an error on the next turn of the JavaScript event
+ loop in order to aid debugging.
+
+ Promises A+ specifies that any exceptions that occur with a promise must be
+ caught by the promises implementation and bubbled to the last handler. For
+ this reason, it is recommended that you always specify a second rejection
+ handler function to `then`. However, `RSVP.rethrow` will throw the exception
+ outside of the promise, so it bubbles up to your console if in the browser,
+ or domain/cause uncaught exception in Node. `rethrow` will also throw the
+ error again so the error can be handled by the promise per the spec.
+
+ ```javascript
+ function throws(){
+ throw new Error('Whoops!');
+ }
+<<<<<<< HEAD
+ }
+
+ function factoryFor(container, fullName) {
+ var name = container.normalize(fullName);
+ var factory = container.resolve(name);
+ var injectedFactory;
+ var cache = container.factoryCache;
+ var type = fullName.split(":")[0];
+
+ if (factory === undefined) { return; }
+
+ if (cache.has(fullName)) {
+ return cache.get(fullName);
+ }
+
+ if (!factory || typeof factory.extend !== 'function' || (!Ember.MODEL_FACTORY_INJECTIONS && type === 'model')) {
+ // TODO: think about a 'safe' merge style extension
+ // for now just fallback to create time injection
+ return factory;
+ } else {
+
+ var injections = injectionsFor(container, fullName);
+ var factoryInjections = factoryInjectionsFor(container, fullName);
+
+ factoryInjections._toString = container.makeToString(factory, fullName);
+
+ injectedFactory = factory.extend(injections);
+ injectedFactory.reopenClass(factoryInjections);
+=======
+
+ var promise = new RSVP.Promise(function(resolve, reject){
+ throws();
+ });
+
+ promise.catch(RSVP.rethrow).then(function(){
+ // Code here doesn't run because the promise became rejected due to an
+ // error!
+ }, function (err){
+ // handle the error here
+ });
+ ```
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
+
+ The 'Whoops' error will be thrown on the next turn of the event loop
+ and you can watch for it in your console. You can also handle it using a
+ rejection handler given to `.then` or `.catch` on the returned promise.
+
+ @method rethrow
+ @for RSVP
+ @param {Error} reason reason the promise became rejected.
+ @throws Error
+ @static
+ */
+ __exports__["default"] = function rethrow(reason) {
+ setTimeout(function() {
+ throw reason;
+ });
+ throw reason;
+ };
+ });
+define("rsvp/utils",
+ ["exports"],
+ function(__exports__) {
+ "use strict";
+ function objectOrFunction(x) {
+ return typeof x === "function" || (typeof x === "object" && x !== null);
+ }
+
+ __exports__.objectOrFunction = objectOrFunction;function isFunction(x) {
+ return typeof x === "function";
+ }
+
+ __exports__.isFunction = isFunction;function isNonThenable(x) {
+ return !objectOrFunction(x);
+ }
+
+ __exports__.isNonThenable = isNonThenable;function isArray(x) {
+ return Object.prototype.toString.call(x) === "[object Array]";
+ }
+
+ __exports__.isArray = isArray;// Date.now is not available in browsers < IE9
+ // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/now#Compatibility
+ var now = Date.now || function() { return new Date().getTime(); };
+ __exports__.now = now;
+ var keysOf = Object.keys || function(object) {
+ var result = [];
+
+ for (var prop in object) {
+ result.push(prop);
+ }
+
+ return result;
+ };
+ __exports__.keysOf = keysOf;
+ });
+define("rsvp",
+ ["./rsvp/promise","./rsvp/events","./rsvp/node","./rsvp/all","./rsvp/all_settled","./rsvp/race","./rsvp/hash","./rsvp/rethrow","./rsvp/defer","./rsvp/config","./rsvp/map","./rsvp/resolve","./rsvp/reject","./rsvp/filter","exports"],
+ function(__dependency1__, __dependency2__, __dependency3__, __dependency4__, __dependency5__, __dependency6__, __dependency7__, __dependency8__, __dependency9__, __dependency10__, __dependency11__, __dependency12__, __dependency13__, __dependency14__, __exports__) {
+ "use strict";
+ var Promise = __dependency1__["default"];
+ var EventTarget = __dependency2__["default"];
+ var denodeify = __dependency3__["default"];
+ var all = __dependency4__["default"];
+ var allSettled = __dependency5__["default"];
+ var race = __dependency6__["default"];
+ var hash = __dependency7__["default"];
+ var rethrow = __dependency8__["default"];
+ var defer = __dependency9__["default"];
+ var config = __dependency10__.config;
+ var configure = __dependency10__.configure;
+ var map = __dependency11__["default"];
+ var resolve = __dependency12__["default"];
+ var reject = __dependency13__["default"];
+ var filter = __dependency14__["default"];
+
+ function async(callback, arg) {
+ config.async(callback, arg);
+ }
+
+ function on() {
+ config.on.apply(config, arguments);
+ }
+
+ function off() {
+ config.off.apply(config, arguments);
+ }
+
+ // Set up instrumentation through `window.__PROMISE_INTRUMENTATION__`
+ if (typeof window !== 'undefined' && typeof window.__PROMISE_INSTRUMENTATION__ === 'object') {
+ var callbacks = window.__PROMISE_INSTRUMENTATION__;
+ configure('instrument', true);
+ for (var eventName in callbacks) {
+ if (callbacks.hasOwnProperty(eventName)) {
+ on(eventName, callbacks[eventName]);
+ }
+ }
+ }
+
+ __exports__.Promise = Promise;
+ __exports__.EventTarget = EventTarget;
+ __exports__.all = all;
+ __exports__.allSettled = allSettled;
+ __exports__.race = race;
+ __exports__.hash = hash;
+ __exports__.rethrow = rethrow;
+ __exports__.defer = defer;
+ __exports__.denodeify = denodeify;
+ __exports__.configure = configure;
+ __exports__.on = on;
+ __exports__.off = off;
+ __exports__.resolve = resolve;
+ __exports__.reject = reject;
+ __exports__.async = async;
+ __exports__.map = map;
+ __exports__.filter = filter;
+ });
+
+})();
+
+(function() {
+/**
+Public api for the container is still in flux.
+The public api, specified on the application namespace should be considered the stable api.
+// @module container
+ @private
+*/
+
+/*
+ Flag to enable/disable model factory injections (disabled by default)
+ If model factory injections are enabled, models should not be
+ accessed globally (only through `container.lookupFactory('model:modelName'))`);
+*/
+Ember.MODEL_FACTORY_INJECTIONS = false || !!Ember.ENV.MODEL_FACTORY_INJECTIONS;
+
define("container",
[],
function() {
@@ -8555,6 +10759,7 @@ define("container",
no matching key is found, return undefined.
@method get
+ @param {String} key
@return {any}
*/
get: function(key) {
@@ -8852,6 +11057,8 @@ define("container",
to find the `fullName`.
@method describe
+ @param {String} fullName
+ @return {string} described fullName
*/
describe: function(fullName) {
return fullName;
@@ -8895,7 +11102,7 @@ define("container",
twitter instanceof Twitter; // => true
// by default the container will return singletons
- twitter2 = container.lookup('api:twitter');
+ var twitter2 = container.lookup('api:twitter');
twitter instanceof Twitter; // => true
twitter === twitter2; //=> true
@@ -8962,7 +11169,7 @@ define("container",
return true;
}
- return !!factoryFor(this, fullName);
+ return !!this.resolve(fullName);
},
/**
@@ -9008,8 +11215,6 @@ define("container",
},
/**
- @private
-
Used only via `injection`.
Provides a specialized form of injection, specifically enabling
@@ -9038,6 +11243,7 @@ define("container",
user.router === post.router; //=> true
```
+ @private
@method typeInjection
@param {String} type
@param {String} property
@@ -9057,8 +11263,8 @@ define("container",
Two forms of injections are possible:
- * Injecting one fullName on another fullName
- * Injecting one fullName on a type
+ * Injecting one fullName on another fullName
+ * Injecting one fullName on a type
Example:
@@ -9105,8 +11311,6 @@ define("container",
/**
- @private
-
Used only via `factoryInjection`.
Provides a specialized form of injection, specifically enabling
@@ -9119,7 +11323,6 @@ define("container",
```javascript
var container = new Container();
- container.registerFactory('model:user', User);
container.register('store:main', SomeStore);
container.factoryTypeInjection('model', 'store', 'store:main');
@@ -9130,6 +11333,7 @@ define("container",
UserFactory.store instanceof SomeStore; //=> true
```
+ @private
@method factoryTypeInjection
@param {String} type
@param {String} property
@@ -9207,7 +11411,6 @@ define("container",
@method destroy
*/
destroy: function() {
- this.isDestroyed = true;
for (var i=0, l=this.children.length; i= 0) {
+ var baseValue = this[keyName];
+
+ if (baseValue) {
+ if ('function' === typeof baseValue.concat) {
+ value = baseValue.concat(value);
+ } else {
+ value = Ember.makeArray(baseValue).concat(value);
+ }
+ } else {
+ value = Ember.makeArray(value);
+ }
+ }
+
+ if (desc) {
+ desc.set(this, keyName, value);
+ } else {
+ if (typeof this.setUnknownProperty === 'function' && !(keyName in this)) {
+ this.setUnknownProperty(keyName, value);
+ } else if (MANDATORY_SETTER) {
+ Ember.defineProperty(this, keyName, null, value); // setup mandatory setter
+ } else {
+ this[keyName] = value;
+ }
+ }
+ }
+ }
+ }
+ finishPartial(this, m);
+ this.init.apply(this, arguments);
+ m.proto = proto;
+ finishChains(this);
+ sendEvent(this, "init");
+ };
+
+ Class.toString = Mixin.prototype.toString;
+ Class.willReopen = function() {
+ if (wasApplied) {
+ Class.PrototypeMixin = Mixin.create(Class.PrototypeMixin);
+ }
+
+ wasApplied = false;
+ };
+ Class._initMixins = function(args) { initMixins = args; };
+ Class._initProperties = function(args) { initProperties = args; };
+
+ Class.proto = function() {
+ var superclass = Class.superclass;
+ if (superclass) { superclass.proto(); }
+
+ if (!wasApplied) {
+ wasApplied = true;
+ Class.PrototypeMixin.applyPartial(Class.prototype);
+ rewatch(Class.prototype);
+ }
+
+ return this.prototype;
+ };
+
+ return Class;
+
+}
+
+/**
+ @class CoreObject
+ @namespace Ember
+*/
+var CoreObject = makeCtor();
+CoreObject.toString = function() { return "Ember.CoreObject"; };
+
+CoreObject.PrototypeMixin = Mixin.create({
+ reopen: function() {
+ applyMixin(this, arguments, true);
+ return this;
+ },
+
+ /**
+ An overridable method called when objects are instantiated. By default,
+ does nothing unless it is overridden during class definition.
+
+ Example:
+
+ ```javascript
+ App.Person = Ember.Object.extend({
+ init: function() {
+ alert('Name is ' + this.get('name'));
+ }
+ });
+
+ var steve = App.Person.create({
+ name: "Steve"
+ });
+
+ // alerts 'Name is Steve'.
+ ```
+
+ NOTE: If you do override `init` for a framework class like `Ember.View` or
+ `Ember.ArrayController`, be sure to call `this._super()` 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
+ */
+ init: function() {},
+
+ /**
+ Defines the properties that will be concatenated from the superclass
+ (instead of overridden).
+
+ By default, when you extend an Ember class a property defined in
+ the subclass overrides a property with the same name that is defined
+ in the superclass. However, there are some cases where it is preferable
+ to build up a property's value by combining the superclass' property
+ value with the subclass' value. An example of this in use within Ember
+ is the `classNames` property of `Ember.View`.
+
+ Here is some sample code showing the difference between a concatenated
+ property and a normal one:
+
+ ```javascript
+ App.BarView = Ember.View.extend({
+ someNonConcatenatedProperty: ['bar'],
+ classNames: ['bar']
+ });
+
+ App.FooBarView = App.BarView.extend({
+ someNonConcatenatedProperty: ['foo'],
+ classNames: ['foo'],
+ });
+
+ var fooBarView = App.FooBarView.create();
+ fooBarView.get('someNonConcatenatedProperty'); // ['foo']
+ fooBarView.get('classNames'); // ['ember-view', 'bar', 'foo']
+ ```
+
+ This behavior extends to object creation as well. Continuing the
+ above example:
+
+ ```javascript
+ var view = App.FooBarView.create({
+ someNonConcatenatedProperty: ['baz'],
+ classNames: ['baz']
+ })
+ view.get('someNonConcatenatedProperty'); // ['baz']
+ view.get('classNames'); // ['ember-view', 'bar', 'foo', 'baz']
+ ```
+ Adding a single property that is not an array will just add it in the array:
+
+ ```javascript
+ var view = App.FooBarView.create({
+ classNames: 'baz'
+ })
+ view.get('classNames'); // ['ember-view', 'bar', 'foo', 'baz']
+ ```
+
+ Using the `concatenatedProperties` property, we can tell to Ember that mix
+ the content of the properties.
+
+ In `Ember.View` the `classNameBindings` and `attributeBindings` properties
+ are also concatenated, in addition to `classNames`.
+
+ This feature is available for you to use throughout the Ember object model,
+ although typical app developers are likely to use it infrequently. Since
+ it changes expectations about behavior of properties, you should properly
+ document its usage in each individual concatenated property (to not
+ mislead your users to think they can override the property in a subclass).
+
+ @property concatenatedProperties
+ @type Array
+ @default null
+ */
+ concatenatedProperties: null,
+
+ /**
+ Destroyed object property flag.
+
+ if this property is `true` the observers and bindings were already
+ removed by the effect of calling the `destroy()` method.
+
+ @property isDestroyed
+ @default false
+ */
+ isDestroyed: false,
+
+ /**
+ Destruction scheduled flag. The `destroy()` method has been called.
+
+ The object stays intact until the end of the run loop at which point
+ the `isDestroyed` flag is set.
+
+ @property isDestroying
+ @default false
+ */
+ isDestroying: false,
+
+ /**
+ Destroys an object by setting the `isDestroyed` flag and removing its
+ metadata, which effectively destroys observers and bindings.
+
+ If you try to set a property on a destroyed object, an exception will be
+ raised.
+
+ Note that destruction is scheduled for the end of the run loop and does not
+ happen immediately. It will set an isDestroying flag immediately.
+
+ @method destroy
+ @return {Ember.Object} receiver
+ */
+ destroy: function() {
+ if (this.isDestroying) { return; }
+ this.isDestroying = true;
+
+ schedule('actions', this, this.willDestroy);
+ schedule('destroy', this, this._scheduledDestroy);
+ return this;
+ },
+
+ /**
+ Override to implement teardown.
+
+ @method willDestroy
+ */
+ willDestroy: Ember.K,
+
+ /**
+ Invoked by the run loop to actually destroy the object. This is
+ scheduled for execution by the `destroy` method.
+
+ @private
+ @method _scheduledDestroy
+ */
+ _scheduledDestroy: function() {
+ if (this.isDestroyed) { return; }
+ destroy(this);
+ this.isDestroyed = true;
+ },
+
+ bind: function(to, from) {
+ if (!(from instanceof Ember.Binding)) { from = Ember.Binding.from(from); }
+ from.to(to).connect(this);
+ return from;
+ },
+
+ /**
+ Returns a string representation which attempts to provide more information
+ than Javascript's `toString` typically does, in a generic way for all Ember
+ objects.
+
+ ```javascript
+ App.Person = Em.Object.extend()
+ person = App.Person.create()
+ person.toString() //=> ""
+ ```
+
+ If the object's class is not defined on an Ember namespace, it will
+ indicate it is a subclass of the registered superclass:
+
+ ```javascript
+ Student = App.Person.extend()
+ student = Student.create()
+ student.toString() //=> "<(subclass of App.Person):ember1025>"
+ ```
+
+ If the method `toStringExtension` is defined, its return value will be
+ included in the output.
+
+ ```javascript
+ App.Teacher = App.Person.extend({
+ toStringExtension: function() {
+ return this.get('fullName');
+ }
+ });
+ teacher = App.Teacher.create()
+ teacher.toString(); //=> ""
+ ```
+
+ @method toString
+ @return {String} string representation
+ */
+ toString: function toString() {
+ var hasToStringExtension = typeof this.toStringExtension === 'function',
+ extension = hasToStringExtension ? ":" + this.toStringExtension() : '';
+ var ret = '<'+this.constructor.toString()+':'+guidFor(this)+extension+'>';
+ this.toString = makeToString(ret);
+ return ret;
+ }
+});
+
+CoreObject.PrototypeMixin.ownerConstructor = CoreObject;
+
+function makeToString(ret) {
+ return function() { return ret; };
+}
+
+if (Ember.config.overridePrototypeMixin) {
+ Ember.config.overridePrototypeMixin(CoreObject.PrototypeMixin);
+}
+
+CoreObject.__super__ = null;
+
+var ClassMixin = Mixin.create({
+
+ ClassMixin: Ember.required(),
+
+ PrototypeMixin: Ember.required(),
+
+ isClass: true,
+
+ isMethod: false,
+
+ /**
+ Creates a new subclass.
+
+ ```javascript
+ App.Person = Ember.Object.extend({
+ say: function(thing) {
+ alert(thing);
+ }
+ });
+ ```
+
+ This defines a new subclass of Ember.Object: `App.Person`. It contains one method: `say()`.
+
+ You can also create a subclass from any existing class by calling its `extend()` method. For example, you might want to create a subclass of Ember's built-in `Ember.View` class:
+
+ ```javascript
+ App.PersonView = Ember.View.extend({
+ tagName: 'li',
+ classNameBindings: ['isAdministrator']
+ });
+ ```
+
+ When defining a subclass, you can override methods but still access the implementation of your parent class by calling the special `_super()` method:
+
+ ```javascript
+ App.Person = Ember.Object.extend({
+ say: function(thing) {
+ var name = this.get('name');
+ alert(name + ' says: ' + thing);
+ }
+ });
+
+ App.Soldier = App.Person.extend({
+ say: function(thing) {
+ this._super(thing + ", sir!");
+ },
+ march: function(numberOfHours) {
+ alert(this.get('name') + ' marches for ' + numberOfHours + ' hours.')
+ }
+ });
+
+ var yehuda = App.Soldier.create({
+ name: "Yehuda Katz"
+ });
+
+ yehuda.say("Yes"); // alerts "Yehuda Katz says: Yes, sir!"
+ ```
+
+ The `create()` on line #17 creates an *instance* of the `App.Soldier` class. The `extend()` on line #8 creates a *subclass* of `App.Person`. Any instance of the `App.Person` class will *not* have the `march()` method.
+
+ You can also pass `Ember.Mixin` classes to add additional properties to the subclass.
+
+ ```javascript
+ App.Person = Ember.Object.extend({
+ say: function(thing) {
+ alert(this.get('name') + ' says: ' + thing);
+ }
+ });
+
+ App.SingingMixin = Ember.Mixin.create({
+ sing: function(thing){
+ alert(this.get('name') + ' sings: la la la ' + thing);
+ }
+ });
+
+ App.BroadwayStar = App.Person.extend(App.SingingMixin, {
+ dance: function() {
+ alert(this.get('name') + ' dances: tap tap tap tap ');
+ }
+ });
+ ```
+
+ The `App.BroadwayStar` class contains three methods: `say()`, `sing()`, and `dance()`.
+
+ @method extend
+ @static
+
+ @param {Ember.Mixin} [mixins]* One or more Ember.Mixin classes
+ @param {Object} [arguments]* Object containing values to use within the new class
+ */
+ extend: function() {
+ var Class = makeCtor(), proto;
+ Class.ClassMixin = Mixin.create(this.ClassMixin);
+ Class.PrototypeMixin = Mixin.create(this.PrototypeMixin);
+
+ Class.ClassMixin.ownerConstructor = Class;
+ Class.PrototypeMixin.ownerConstructor = Class;
+
+ reopen.apply(Class.PrototypeMixin, arguments);
+
+ Class.superclass = this;
+ Class.__super__ = this.prototype;
+
+ proto = Class.prototype = o_create(this.prototype);
+ proto.constructor = Class;
+ generateGuid(proto);
+ meta(proto).proto = proto; // this will disable observers on prototype
+
+ Class.ClassMixin.apply(Class);
+ return Class;
+ },
+
+ /**
+ Equivalent to doing `extend(arguments).create()`.
+ If possible use the normal `create` method instead.
+
+ @method createWithMixins
+ @static
+ @param [arguments]*
+ */
+ createWithMixins: function() {
+ var C = this;
+ if (arguments.length>0) { this._initMixins(arguments); }
+ return new C();
+ },
+
+ /**
+ Creates an instance of a class. Accepts either no arguments, or an object
+ containing values to initialize the newly instantiated object with.
+
+ ```javascript
+ App.Person = Ember.Object.extend({
+ helloWorld: function() {
+ alert("Hi, my name is " + this.get('name'));
+ }
+ });
+
+ var tom = App.Person.create({
+ name: 'Tom Dale'
+ });
+
+ tom.helloWorld(); // alerts "Hi, my name is Tom Dale".
+ ```
+
+ `create` will call the `init` function if defined during
+ `Ember.AnyObject.extend`
+
+ If no arguments are passed to `create`, it will not set values to the new
+ instance during initialization:
+
+ ```javascript
+ var noName = App.Person.create();
+ noName.helloWorld(); // alerts undefined
+ ```
+
+ NOTE: For performance reasons, you cannot declare methods or computed
+ properties during `create`. You should instead declare methods and computed
+ properties when using `extend` or use the `createWithMixins` shorthand.
+
+ @method create
+ @static
+ @param [arguments]*
+ */
+ create: function() {
+ var C = this;
+ if (arguments.length>0) { this._initProperties(arguments); }
+ return new C();
+ },
+
+ /**
+ Augments a constructor's prototype with additional
+ properties and functions:
+
+ ```javascript
+ MyObject = Ember.Object.extend({
+ name: 'an object'
+ });
+
+ o = MyObject.create();
+ o.get('name'); // 'an object'
+
+ MyObject.reopen({
+ say: function(msg){
+ console.log(msg);
+ }
+ })
+
+ o2 = MyObject.create();
+ o2.say("hello"); // logs "hello"
+
+ o.say("goodbye"); // logs "goodbye"
+ ```
+
+ To add functions and properties to the constructor itself,
+ see `reopenClass`
+
+ @method reopen
+ */
+ reopen: function() {
+ this.willReopen();
+ reopen.apply(this.PrototypeMixin, arguments);
+ return this;
+ },
+
+ /**
+ Augments a constructor's own properties and functions:
+
+ ```javascript
+ MyObject = Ember.Object.extend({
+ name: 'an object'
+ });
+
+ MyObject.reopenClass({
+ canBuild: false
+ });
+
+ MyObject.canBuild; // false
+ o = MyObject.create();
+ ```
+
+ In other words, this creates static properties and functions for the class. These are only available on the class
+ and not on any instance of that class.
+
+ ```javascript
+ App.Person = Ember.Object.extend({
+ name : "",
+ sayHello : function(){
+ alert("Hello. My name is " + this.get('name'));
+ }
+ });
+
+ App.Person.reopenClass({
+ species : "Homo sapiens",
+ createPerson: function(newPersonsName){
+ return App.Person.create({
+ name:newPersonsName
+ });
+ }
+ });
+
+ var tom = App.Person.create({
+ name : "Tom Dale"
+ });
+ var yehuda = App.Person.createPerson("Yehuda Katz");
+
+ tom.sayHello(); // "Hello. My name is Tom Dale"
+ yehuda.sayHello(); // "Hello. My name is Yehuda Katz"
+ alert(App.Person.species); // "Homo sapiens"
+ ```
+
+ Note that `species` and `createPerson` are *not* valid on the `tom` and `yehuda`
+ variables. They are only valid on `App.Person`.
+
+ To add functions and properties to instances of
+ a constructor by extending the constructor's prototype
+ see `reopen`
+
+ @method reopenClass
+ */
+ reopenClass: function() {
+ reopen.apply(this.ClassMixin, arguments);
+ applyMixin(this, arguments, false);
+ return this;
+ },
+
+ detect: function(obj) {
+ if ('function' !== typeof obj) { return false; }
+ while(obj) {
+ if (obj===this) { return true; }
+ obj = obj.superclass;
+ }
+ return false;
+ },
+
+ detectInstance: function(obj) {
+ return obj instanceof this;
+ },
+
+ /**
+ In some cases, you may want to annotate computed properties with additional
+ metadata about how they function or what values they operate on. For
+ example, computed property functions may close over variables that are then
+ no longer available for introspection.
+
+ You can pass a hash of these values to a computed property like this:
+
+ ```javascript
+ person: function() {
+ var personId = this.get('personId');
+ return App.Person.create({ id: personId });
+ }.property().meta({ type: App.Person })
+ ```
+
+ Once you've done this, you can retrieve the values saved to the computed
+ property from your class like this:
+
+ ```javascript
+ MyClass.metaForProperty('person');
+ ```
+
+ This will return the original hash that was passed to `meta()`.
+
+ @method metaForProperty
+ @param key {String} property name
+ */
+ metaForProperty: function(key) {
+ var desc = meta(this.proto(), false).descs[key];
+
+ Ember.assert("metaForProperty() could not find a computed property with key '"+key+"'.", !!desc && desc instanceof Ember.ComputedProperty);
+ return desc._meta || {};
+ },
+
+ /**
+ Iterate over each computed property for the class, passing its name
+ and any associated metadata (see `metaForProperty`) to the callback.
+
+ @method eachComputedProperty
+ @param {Function} callback
+ @param {Object} binding
+ */
+ eachComputedProperty: function(callback, binding) {
+ var proto = this.proto(),
+ descs = meta(proto).descs,
+ empty = {},
+ property;
+
+ for (var name in descs) {
+ property = descs[name];
+
+ if (property instanceof Ember.ComputedProperty) {
+ callback.call(binding || this, name, property._meta || empty);
+ }
+ }
+ }
+
+});
+
+ClassMixin.ownerConstructor = CoreObject;
+
+if (Ember.config.overrideClassMixin) {
+ Ember.config.overrideClassMixin(ClassMixin);
+}
+
+CoreObject.ClassMixin = ClassMixin;
+ClassMixin.apply(CoreObject);
+
+Ember.CoreObject = CoreObject;
+
+})();
+
+
+
+(function() {
+/**
+@module ember
+@submodule ember-runtime
+*/
+
+/**
+ `Ember.Object` is the main base class for all Ember objects. It is a subclass
+ of `Ember.CoreObject` with the `Ember.Observable` mixin applied. For details,
+ see the documentation for each of these.
+
+ @class Object
+ @namespace Ember
+ @extends Ember.CoreObject
+ @uses Ember.Observable
+*/
+Ember.Object = Ember.CoreObject.extend(Ember.Observable);
+Ember.Object.toString = function() { return "Ember.Object"; };
+
+})();
+
+
+
+(function() {
+/**
+@module ember
+@submodule ember-runtime
+*/
+
+var get = Ember.get, indexOf = Ember.ArrayPolyfills.indexOf;
+
+/**
+ A Namespace is an object usually used to contain other objects or methods
+ such as an application or framework. Create a namespace anytime you want
+ to define one of these new containers.
+
+ # Example Usage
+
+ ```javascript
+ MyFramework = Ember.Namespace.create({
+ VERSION: '1.0.0'
+ });
+ ```
+
+ @class Namespace
+ @namespace Ember
+ @extends Ember.Object
+*/
+var Namespace = Ember.Namespace = Ember.Object.extend({
+ isNamespace: true,
+
+ init: function() {
+ Ember.Namespace.NAMESPACES.push(this);
+ Ember.Namespace.PROCESSED = false;
+ },
+
+ toString: function() {
+ var name = get(this, 'name');
+ if (name) { return name; }
+
+ findNamespaces();
+ return this[Ember.GUID_KEY+'_name'];
+ },
+
+ nameClasses: function() {
+ processNamespace([this.toString()], this, {});
+ },
+
+ destroy: function() {
+ var namespaces = Ember.Namespace.NAMESPACES;
+ Ember.lookup[this.toString()] = undefined;
+ namespaces.splice(indexOf.call(namespaces, this), 1);
+ this._super();
+ }
+});
+
+Namespace.reopenClass({
+ NAMESPACES: [Ember],
+ NAMESPACES_BY_ID: {},
+ PROCESSED: false,
+ processAll: processAllNamespaces,
+ byName: function(name) {
+ if (!Ember.BOOTED) {
+ processAllNamespaces();
+ }
+
+ return NAMESPACES_BY_ID[name];
+ }
+});
+
+var NAMESPACES_BY_ID = Namespace.NAMESPACES_BY_ID;
+
+var hasOwnProp = ({}).hasOwnProperty,
+ guidFor = Ember.guidFor;
+
+function processNamespace(paths, root, seen) {
+ var idx = paths.length;
+
+ NAMESPACES_BY_ID[paths.join('.')] = root;
+
+ // Loop over all of the keys in the namespace, looking for classes
+ for(var key in root) {
+ if (!hasOwnProp.call(root, key)) { continue; }
+ var obj = root[key];
+
+ // If we are processing the `Ember` namespace, for example, the
+ // `paths` will start with `["Ember"]`. Every iteration through
+ // the loop will update the **second** element of this list with
+ // the key, so processing `Ember.View` will make the Array
+ // `['Ember', 'View']`.
+ paths[idx] = key;
+
+ // If we have found an unprocessed class
+ if (obj && obj.toString === classToString) {
+ // Replace the class' `toString` with the dot-separated path
+ // and set its `NAME_KEY`
+ obj.toString = makeToString(paths.join('.'));
+ obj[NAME_KEY] = paths.join('.');
+
+ // Support nested namespaces
+ } else if (obj && obj.isNamespace) {
+ // Skip aliased namespaces
+ if (seen[guidFor(obj)]) { continue; }
+ seen[guidFor(obj)] = true;
+
+ // Process the child namespace
+ processNamespace(paths, obj, seen);
+ }
+ }
+
+ paths.length = idx; // cut out last item
+}
+
+function findNamespaces() {
+ var Namespace = Ember.Namespace, lookup = Ember.lookup, obj, isNamespace;
+
+ if (Namespace.PROCESSED) { return; }
+
+ for (var prop in lookup) {
+ // These don't raise exceptions but can cause warnings
+ if (prop === "parent" || prop === "top" || prop === "frameElement" || prop === "webkitStorageInfo") { continue; }
+
+ // get(window.globalStorage, 'isNamespace') would try to read the storage for domain isNamespace and cause exception in Firefox.
+ // globalStorage is a storage obsoleted by the WhatWG storage specification. See https://developer.mozilla.org/en/DOM/Storage#globalStorage
+ if (prop === "globalStorage" && lookup.StorageList && lookup.globalStorage instanceof lookup.StorageList) { continue; }
+ // Unfortunately, some versions of IE don't support window.hasOwnProperty
+ if (lookup.hasOwnProperty && !lookup.hasOwnProperty(prop)) { continue; }
+
+ // At times we are not allowed to access certain properties for security reasons.
+ // There are also times where even if we can access them, we are not allowed to access their properties.
+ try {
+ obj = Ember.lookup[prop];
+ isNamespace = obj && obj.isNamespace;
+ } catch (e) {
+ continue;
+ }
+
+ if (isNamespace) {
+ Ember.deprecate("Namespaces should not begin with lowercase.", /^[A-Z]/.test(prop));
+ obj[NAME_KEY] = prop;
+ }
+ }
+}
+
+var NAME_KEY = Ember.NAME_KEY = Ember.GUID_KEY + '_name';
+
+function superClassString(mixin) {
+ var superclass = mixin.superclass;
+ if (superclass) {
+ if (superclass[NAME_KEY]) { return superclass[NAME_KEY]; }
+ else { return superClassString(superclass); }
+ } else {
+ return;
+ }
+}
+
+function classToString() {
+ if (!Ember.BOOTED && !this[NAME_KEY]) {
+ processAllNamespaces();
+ }
+
+ var ret;
+
+ if (this[NAME_KEY]) {
+ ret = this[NAME_KEY];
+ } else if (this._toString) {
+ ret = this._toString;
+ } else {
+ var str = superClassString(this);
+ if (str) {
+ ret = "(subclass of " + str + ")";
+ } else {
+ ret = "(unknown mixin)";
+ }
+ this.toString = makeToString(ret);
+ }
+
+ return ret;
+}
+
+function processAllNamespaces() {
+ var unprocessedNamespaces = !Namespace.PROCESSED,
+ unprocessedMixins = Ember.anyUnprocessedMixins;
+
+ if (unprocessedNamespaces) {
+ findNamespaces();
+ Namespace.PROCESSED = true;
+ }
+
+ if (unprocessedNamespaces || unprocessedMixins) {
+ var namespaces = Namespace.NAMESPACES, namespace;
+ for (var i=0, l=namespaces.length; i= 0) return;
+ if (!obj.hasOwnProperty(key)) return;
+
+ array.push(key);
+ };
+
+ Ember.keys = function(obj) {
+ var ret = [], key;
+ for (key in obj) {
+ pushPropertyName(obj, ret, key);
+ }
+
+ // IE8 doesn't enumerate property that named the same as prototype properties.
+ for (var i = 0, l = prototypeProperties.length; i < l; i++) {
+ key = prototypeProperties[i];
+
+ pushPropertyName(obj, ret, key);
+ }
+
+ return ret;
+ };
+}
+
+})();
+=======
+ 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
+ @param {Function} callback The callback to execute
+ @param {Object} [target] The target object to use
+ @return {Array} The mapped array.
+ */
+ map: function(callback, target) {
+ var ret = Ember.A();
+ this.forEach(function(x, idx, i) {
+ ret[idx] = callback.call(target, x, idx,i);
+ });
+ return ret ;
+ },
+
+ /**
+ Similar to map, this specialized function returns the value of the named
+ property on all items in the enumeration.
+
+ @method mapBy
+ @param {String} key name of the property
+ @return {Array} The mapped array.
+ */
+ mapBy: function(key) {
+ return this.map(function(next) {
+ return get(next, key);
+ });
+ },
+
+ /**
+ Similar to map, this specialized function returns the value of the named
+ property on all items in the enumeration.
+
+ @method mapProperty
+ @param {String} key name of the property
+ @return {Array} The mapped array.
+ @deprecated Use `mapBy` instead
+ */
+
+ mapProperty: Ember.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
+ parameters are optional):
+
+ ```javascript
+ function(item, index, enumerable);
+ ```
+
+ - `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`
+ otherwise.
+
+ 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
+ @param {Function} callback The callback to execute
+ @param {Object} [target] The target object to use
+ @return {Array} A filtered array.
+ */
+ filter: function(callback, target) {
+ var ret = Ember.A();
+ this.forEach(function(x, idx, i) {
+ if (callback.call(target, x, idx, i)) ret.push(x);
+ });
+ return ret ;
+ },
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
+
+ /**
+ Returns an array with all of the items in the enumeration where the passed
+ function returns false for. This method is the inverse of filter().
+
+ The callback method you provide should have the following signature (all
+ parameters are optional):
+
+ ```javascript
+ function(item, index, enumerable);
+ ```
+
+<<<<<<< HEAD
+var STRING_DASHERIZE_REGEXP = (/[ _]/g);
+var STRING_DASHERIZE_CACHE = {};
+var STRING_DECAMELIZE_REGEXP = (/([a-z\d])([A-Z])/g);
+var STRING_CAMELIZE_REGEXP = (/(\-|_|\.|\s)+(.)?/g);
+var STRING_UNDERSCORE_REGEXP_1 = (/([a-z\d])([A-Z]+)/g);
+var STRING_UNDERSCORE_REGEXP_2 = (/\-|\s+/g);
+=======
+ - *item* is the current item in the iteration.
+ - *index* is the current index in the iteration
+ - *enumerable* is the enumerable object itself.
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
+
+ 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
+ @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 !(callback.apply(target, arguments));
+ });
+ },
+
+ /**
+ 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
+ @param {String} key the property to test
+ @param {String} [value] optional value to test against.
+ @return {Array} filtered array
+ */
+ filterBy: function(key, value) {
+ return this.filter(iter.apply(this, arguments));
+ },
+
+ /**
+ 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
+ @param {String} key the property to test
+ @param {String} [value] optional value to test against.
+ @return {Array} filtered array
+ @deprecated Use `filterBy` instead
+ */
+ filterProperty: Ember.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
+ @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) { return get(item, key) === value; },
+ hasValue = function(item) { return !!get(item, key); },
+ use = (arguments.length === 2 ? exactValue : hasValue);
+
+ return this.reject(use);
+ },
+
+ /**
+ 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
+ @param {String} key the property to test
+ @param {String} [value] optional value to test against.
+ @return {Array} rejected array
+ @deprecated Use `rejectBy` instead
+ */
+ rejectProperty: Ember.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
+ parameters are optional):
+
+ ```javascript
+ function(item, index, enumerable);
+ ```
+
+ - `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`
+ otherwise.
+
+ 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
+ @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 = get(this, 'length') ;
+ if (target === undefined) target = null;
+
+ var last = null, next, found = false, ret ;
+ var context = popCtx();
+ for(var idx=0;idx>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
+
+ ```javascript
+ function(item, index, enumerable);
+ ```
+
+ - `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
+ 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
+ if (people.every(isEngineer)) { Paychecks.addBigBonus(); }
+ ```
+
+ @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) {
+ return !callback.call(target, x, idx, i);
+ });
+ },
+
+ /**
+ @method everyBy
+ @param {String} key the property to test
+ @param {String} [value] optional value to test against.
+ @deprecated Use `isEvery` instead
+ @return {Boolean}
+ */
+ everyBy: Ember.aliasMethod('isEvery'),
+
+ /**
+ @method everyProperty
+ @param {String} key the property to test
+ @param {String} [value] optional value to test against.
+ @deprecated Use `isEvery` instead
+ @return {Boolean}
+ */
+ everyProperty: Ember.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
+ @param {String} key the property to test
+ @param {String} [value] optional value to test against.
+ @return {Boolean}
+ */
+ isEvery: function(key, value) {
+ return this.every(iter.apply(this, 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
+ parameters are optional):
+
+ ```javascript
+ function(item, index, enumerable);
+ ```
+
+ - `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`
+ otherwise.
+
+ 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
+ if (people.any(isManager)) { Paychecks.addBiggerBonus(); }
+ ```
+
+ @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
+ */
+<<<<<<< HEAD
+ capitalize: function(str) {
+ return str.charAt(0).toUpperCase() + str.substr(1);
+ }
+};
+
+
+
+})();
+
+=======
+ any: function(callback, target) {
+ var found = this.find(function(x, idx, i) {
+ return !!callback.call(target, x, idx, i);
+ });
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
+
+ return typeof found !== 'undefined';
+ },
+
+ /**
+ 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
+ parameters are optional):
+
+ ```javascript
+ function(item, index, enumerable);
+ ```
+
+ - `item` is the current item in the iteration.
+ - `index` is the current index in the iteration.
+ - `enumerable` is the enumerable object itself.
+
+<<<<<<< HEAD
+
+if (Ember.EXTEND_PROTOTYPES === true || Ember.EXTEND_PROTOTYPES.String) {
+
+ /**
+ See [Ember.String.fmt](/api/classes/Ember.String.html#method_fmt).
+=======
+ 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
+ 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.
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
+
+ Usage Example:
+
+<<<<<<< HEAD
+ /**
+ See [Ember.String.w](/api/classes/Ember.String.html#method_w).
+=======
+ ```javascript
+ if (people.some(isManager)) { Paychecks.addBiggerBonus(); }
+ ```
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
+
+ @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: Ember.aliasMethod('any'),
+
+ /**
+<<<<<<< HEAD
+ See [Ember.String.loc](/api/classes/Ember.String.html#method_loc).
+=======
+ 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.
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
+
+ @method isAny
+ @param {String} key the property to test
+ @param {String} [value] optional value to test against.
+ @return {Boolean} `true` if the passed function returns `true` for any item
+ */
+ isAny: function(key, value) {
+ return this.any(iter.apply(this, arguments));
+ },
+
+ /**
+<<<<<<< HEAD
+ See [Ember.String.camelize](/api/classes/Ember.String.html#method_camelize).
+
+ @method camelize
+ @for String
+=======
+ @method anyBy
+ @param {String} key the property to test
+ @param {String} [value] optional value to test against.
+ @return {Boolean} `true` if the passed function returns `true` for any item
+ @deprecated Use `isAny` instead
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
+ */
+ anyBy: Ember.aliasMethod('isAny'),
+
+ /**
+<<<<<<< HEAD
+ See [Ember.String.decamelize](/api/classes/Ember.String.html#method_decamelize).
+
+ @method decamelize
+ @for String
+=======
+ @method someProperty
+ @param {String} key the property to test
+ @param {String} [value] optional value to test against.
+ @return {Boolean} `true` if the passed function returns `true` for any item
+ @deprecated Use `isAny` instead
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
+ */
+ someProperty: Ember.aliasMethod('isAny'),
+
+ /**
+<<<<<<< HEAD
+ See [Ember.String.dasherize](/api/classes/Ember.String.html#method_dasherize).
+=======
+ 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.
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
+
+ The callback method you provide should have the following signature (all
+ parameters are optional):
+
+<<<<<<< HEAD
+ /**
+ See [Ember.String.underscore](/api/classes/Ember.String.html#method_underscore).
+=======
+ ```javascript
+ function(previousValue, item, index, enumerable);
+ ```
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
+
+ - `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.
+
+<<<<<<< HEAD
+ /**
+ See [Ember.String.classify](/api/classes/Ember.String.html#method_classify).
+=======
+ Return the new cumulative value.
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
+
+ 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.
+
+<<<<<<< HEAD
+ /**
+ See [Ember.String.capitalize](/api/classes/Ember.String.html#method_capitalize).
+=======
+ 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.
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
+
+ @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.
+ */
+<<<<<<< HEAD
+ String.prototype.capitalize = function() {
+ return capitalize(this);
+ };
+
+
+}
+=======
+ reduce: function(callback, initialValue, reducerProperty) {
+ if (typeof callback !== "function") { throw new TypeError(); }
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
+
+ var ret = initialValue;
+
+ this.forEach(function(item, i) {
+ ret = callback.call(null, ret, item, i, this, reducerProperty);
+ }, this);
+
+ return ret;
+ },
+
+ /**
+ 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
+ @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) {
+ var args, ret = Ember.A();
+ if (arguments.length>1) args = a_slice.call(arguments, 1);
+
+<<<<<<< HEAD
+var get = Ember.get,
+ set = Ember.set,
+ slice = Array.prototype.slice,
+ getProperties = Ember.getProperties;
+
+/**
+ ## Overview
+
+ This mixin provides properties and property observing functionality, core
+ features of the Ember object model.
+
+ Properties and observers allow one object to observe changes to a
+ property on another object. This is one of the fundamental ways that
+ models, controllers and views communicate with each other in an Ember
+ application.
+
+ Any object that has this mixin applied can be used in observer
+ operations. That includes `Ember.Object` and most objects you will
+ interact with as you write your Ember application.
+
+ Note that you will not generally apply this mixin to classes yourself,
+ but you will use the features provided by this module frequently, so it
+ is important to understand how to use it.
+
+ ## Using `get()` and `set()`
+
+ Because of Ember's support for bindings and observers, you will always
+ access properties using the get method, and set properties using the
+ set method. This allows the observing objects to be notified and
+ computed properties to be handled properly.
+
+ More documentation about `get` and `set` are below.
+
+ ## Observing Property Changes
+
+ You typically observe property changes simply by adding the `observes`
+ call to the end of your method declarations in classes that you write.
+ For example:
+
+ ```javascript
+ Ember.Object.extend({
+ valueObserver: function() {
+ // Executes whenever the "value" property changes
+ }.observes('value')
+ });
+ ```
+
+ Although this is the most common way to add an observer, this capability
+ is actually built into the `Ember.Object` class on top of two methods
+ defined in this mixin: `addObserver` and `removeObserver`. You can use
+ these two methods to add and remove observers yourself if you need to
+ do so at runtime.
+
+ To add an observer for a property, call:
+
+ ```javascript
+ object.addObserver('propertyKey', targetObject, targetAction)
+ ```
+
+ This will call the `targetAction` method on the `targetObject` whenever
+ the value of the `propertyKey` changes.
+
+ Note that if `propertyKey` is a computed property, the observer will be
+ called when any of the property dependencies are changed, even if the
+ resulting value of the computed property is unchanged. This is necessary
+ because computed properties are not computed until `get` is called.
+
+ @class Observable
+ @namespace Ember
+*/
+Ember.Observable = Ember.Mixin.create({
+
+ /**
+ Retrieves the value of a property from the object.
+
+ 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
+ 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
+ declared at the end, such as:
+
+ ```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
+ 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
+ `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
+ @param {String} keyName The property to retrieve
+ @return {Object} The property value or undefined.
+ */
+ get: function(keyName) {
+ return get(this, keyName);
+ },
+
+ /**
+ To get multiple properties at once, call `getProperties`
+ with a list of strings or an array:
+
+ ```javascript
+ record.getProperties('firstName', 'lastName', 'zipCode'); // { firstName: 'John', lastName: 'Doe', zipCode: '10011' }
+ ```
+
+ is equivalent to:
+
+ ```javascript
+ record.getProperties(['firstName', 'lastName', 'zipCode']); // { firstName: 'John', lastName: 'Doe', zipCode: '10011' }
+ ```
+
+ @method getProperties
+ @param {String...|Array} list of keys to get
+ @return {Hash}
+ */
+ getProperties: function() {
+ return getProperties.apply(null, [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
+ `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
+ 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.
+=======
+ this.forEach(function(x, idx) {
+ var method = x && x[methodName];
+ if ('function' === typeof method) {
+ ret[idx] = args ? method.apply(x, args) : method.call(x);
+ }
+ }, this);
+
+ return ret;
+ },
+
+ /**
+ Simply converts the enumerable into a genuine array. The order is not
+ guaranteed. Corresponds to the method implemented by Prototype.
+
+ @method toArray
+ @return {Array} the enumerable as an array.
+ */
+ toArray: function() {
+ var ret = Ember.A();
+ this.forEach(function(o, idx) { ret[idx] = o; });
+ return ret ;
+ },
+
+ /**
+ Returns a copy of the array with all null and undefined elements removed.
+
+ ```javascript
+ var arr = ["a", null, "c", undefined];
+ arr.compact(); // ["a", "c"]
+ ```
+
+ @method compact
+ @return {Array} the array without null and undefined elements.
+ */
+ compact: function() {
+ return this.filter(function(value) { return value != null; });
+ },
+
+ /**
+ 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
+ var arr = ["a", "b", "a", "c"];
+ arr.without("a"); // ["b", "c"]
+ ```
+
+ @method without
+ @param {Object} value
+ @return {Ember.Enumerable}
+ */
+ without: function(value) {
+ if (!this.contains(value)) return this; // nothing to do
+ var ret = Ember.A();
+ this.forEach(function(k) {
+ if (k !== value) ret[ret.length] = k;
+ }) ;
+ return ret ;
+ },
+
+ /**
+ Returns a new enumerable that contains only unique values. The default
+ implementation returns an array regardless of the receiver type.
+
+ ```javascript
+ var arr = ["a", "a", "b", "b"];
+ arr.uniq(); // ["a", "b"]
+ ```
+
+ @method uniq
+ @return {Ember.Enumerable}
+ */
+ uniq: function() {
+ var ret = Ember.A();
+ this.forEach(function(k) {
+ if (a_indexOf(ret, k)<0) ret.push(k);
+ });
+ return ret;
+ },
+
+ /**
+ This property will trigger anytime the enumerable's content changes.
+ You can observe this property to be notified of changes to the enumerables
+ content.
+
+ For plain enumerables, this property is read only. `Ember.Array` overrides
+ this method.
+
+ @property []
+ @type Ember.Array
+ @return this
+ */
+ '[]': Ember.computed(function(key, value) {
+ return this;
+ }),
+
+ // ..........................................................
+ // ENUMERABLE OBSERVERS
+ //
+
+ /**
+ Registers an enumerable observer. Must implement `Ember.EnumerableObserver`
+ mixin.
+
+ @method addEnumerableObserver
+ @param {Object} target
+ @param {Hash} [opts]
+ @return this
+ */
+ addEnumerableObserver: function(target, opts) {
+ var willChange = (opts && opts.willChange) || 'enumerableWillChange',
+ didChange = (opts && opts.didChange) || 'enumerableDidChange';
+
+ var hasObservers = get(this, 'hasEnumerableObservers');
+ if (!hasObservers) Ember.propertyWillChange(this, 'hasEnumerableObservers');
+ Ember.addListener(this, '@enumerable:before', target, willChange);
+ Ember.addListener(this, '@enumerable:change', target, didChange);
+ if (!hasObservers) Ember.propertyDidChange(this, 'hasEnumerableObservers');
+ return this;
+ },
+
+ /**
+ Removes a registered enumerable observer.
+
+ @method removeEnumerableObserver
+ @param {Object} target
+ @param {Hash} [opts]
+ @return this
+ */
+ removeEnumerableObserver: function(target, opts) {
+ var willChange = (opts && opts.willChange) || 'enumerableWillChange',
+ didChange = (opts && opts.didChange) || 'enumerableDidChange';
+
+ var hasObservers = get(this, 'hasEnumerableObservers');
+ if (hasObservers) Ember.propertyWillChange(this, 'hasEnumerableObservers');
+ Ember.removeListener(this, '@enumerable:before', target, willChange);
+ Ember.removeListener(this, '@enumerable:change', target, didChange);
+ if (hasObservers) Ember.propertyDidChange(this, 'hasEnumerableObservers');
+ return this;
+ },
+
+ /**
+ Becomes true whenever the array currently has observers watching changes
+ on the array.
+
+ @property hasEnumerableObservers
+ @type Boolean
+ */
+ hasEnumerableObservers: Ember.computed(function() {
+ return Ember.hasListeners(this, '@enumerable:change') || Ember.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
+ @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) {
+
+ var removeCnt, addCnt, hasDelta;
+
+ if ('number' === typeof removing) removeCnt = removing;
+ else if (removing) removeCnt = get(removing, 'length');
+ else removeCnt = removing = -1;
+
+ if ('number' === typeof adding) addCnt = adding;
+ else if (adding) addCnt = get(adding,'length');
+ else addCnt = adding = -1;
+
+ hasDelta = addCnt<0 || removeCnt<0 || addCnt-removeCnt!==0;
+
+ if (removing === -1) removing = null;
+ if (adding === -1) adding = null;
+
+ Ember.propertyWillChange(this, '[]');
+ if (hasDelta) Ember.propertyWillChange(this, 'length');
+ Ember.sendEvent(this, '@enumerable:before', [this, removing, adding]);
+
+ return this;
+ },
+
+ /**
+ Invoke this method when the contents of your enumerable has changed.
+ This will notify any observers watching for content changes. If your are
+ 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
+ @param {Number} [start] optional start offset for the content change.
+ For unordered enumerables, you should always pass -1.
+ @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) {
+ var removeCnt, addCnt, hasDelta;
+
+ if ('number' === typeof removing) removeCnt = removing;
+ else if (removing) removeCnt = get(removing, 'length');
+ else removeCnt = removing = -1;
+
+ if ('number' === typeof adding) addCnt = adding;
+ else if (adding) addCnt = get(adding, 'length');
+ else addCnt = adding = -1;
+
+ hasDelta = addCnt<0 || removeCnt<0 || addCnt-removeCnt!==0;
+
+ if (removing === -1) removing = null;
+ if (adding === -1) adding = null;
+
+ Ember.sendEvent(this, '@enumerable:change', [this, removing, adding]);
+ if (hasDelta) Ember.propertyDidChange(this, 'length');
+ Ember.propertyDidChange(this, '[]');
+
+ return this ;
+ },
+
+ /**
+ 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
+ @param {String} property name(s) to sort on
+ @return {Array} The sorted array.
+ */
+ sortBy: function() {
+ var sortKeys = arguments;
+ return this.toArray().sort(function(a, b){
+ for(var i = 0; i < sortKeys.length; i++) {
+ var key = sortKeys[i],
+ propA = get(a, key),
+ propB = get(b, key);
+ // return 1 or -1 else continue to the next sortKey
+ var compareValue = Ember.compare(propA, propB);
+ if (compareValue) { return compareValue; }
+ }
+ return 0;
+ });
+ }
+});
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
+
+ ### 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
+ 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
+
+<<<<<<< HEAD
+ In addition to property changes, `set()` returns the value of the object
+ itself so you can do chaining like this:
+
+ ```javascript
+ record.set('firstName', 'Charles').set('lastName', 'Jolley');
+ ```
+
+ @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(this, keyName, value);
+ return this;
+ },
+
+ /**
+ To set multiple properties at once, call `setProperties`
+ with a Hash:
+
+ ```javascript
+ record.setProperties({ firstName: 'Charles', lastName: 'Jolley' });
+ ```
+
+ @method setProperties
+ @param {Hash} hash the hash of keys and values to set
+ @return {Ember.Observable}
+ */
+ setProperties: function(hash) {
+ return Ember.setProperties(this, hash);
+ },
+
+ /**
+ Begins a grouping of property changes.
+
+ 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
+ @return {Ember.Observable}
+ */
+ beginPropertyChanges: function() {
+ Ember.beginPropertyChanges();
+ return this;
+ },
+
+ /**
+ Ends a grouping of property changes.
+
+ 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
+ @return {Ember.Observable}
+ */
+ endPropertyChanges: function() {
+ Ember.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
+ 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`
+ 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
+ @param {String} keyName The property key that is about to change.
+ @return {Ember.Observable}
+ */
+ propertyWillChange: function(keyName) {
+ Ember.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
+ 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`
+ 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
+ @param {String} keyName The property key that has just changed.
+ @return {Ember.Observable}
+ */
+ propertyDidChange: function(keyName) {
+ Ember.propertyDidChange(this, keyName);
+ return this;
+ },
+
+ /**
+ Convenience method to call `propertyWillChange` and `propertyDidChange` in
+ succession.
+
+ @method notifyPropertyChange
+ @param {String} keyName The property key to be notified about.
+ @return {Ember.Observable}
+ */
+ notifyPropertyChange: function(keyName) {
+ this.propertyWillChange(keyName);
+ this.propertyDidChange(keyName);
+ return this;
+ },
+
+ addBeforeObserver: function(key, target, method) {
+ Ember.addBeforeObserver(this, key, target, method);
+=======
+var get = Ember.get, set = Ember.set, isNone = Ember.isNone, map = Ember.EnumerableUtils.map, cacheFor = Ember.cacheFor;
+
+// ..........................................................
+// ARRAY
+//
+/**
+ This module implements Observer-friendly Array-like behavior. This mixin is
+ picked up by the Array class as well as other controllers, etc. that want to
+ appear to be arrays.
+
+ Unlike `Ember.Enumerable,` this mixin defines methods specifically for
+ collections that provide index-ordered access to their contents. When you
+ are designing code that needs to accept any kind of Array-like object, you
+ should use these methods instead of Array primitives because these will
+ properly notify observers of changes to the array.
+
+ Although these methods are efficient, they do add a layer of indirection to
+ your application so it is a good idea to use them only when you need the
+ flexibility of using both true JavaScript arrays and "virtual" arrays such
+ as controllers and collections.
+
+ You can use the methods defined in this module to access and modify array
+ contents in a KVO-friendly way. You can also be notified whenever the
+ membership of an array changes by changing the syntax of the property to
+ `.observes('*myProperty.[]')`.
+
+ To support `Ember.Array` in your own class, you must override two
+ primitives to use it: `replace()` and `objectAt()`.
+
+ Note that the Ember.Array mixin also incorporates the `Ember.Enumerable`
+ mixin. All `Ember.Array`-like objects are also enumerable.
+
+ @class Array
+ @namespace Ember
+ @uses Ember.Enumerable
+ @since Ember 0.9.0
+*/
+Ember.Array = Ember.Mixin.create(Ember.Enumerable, {
+
+ /**
+ Your array must support the `length` property. Your replace methods should
+ set this property whenever it changes.
+
+ @property {Number} length
+ */
+ length: Ember.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`.
+ 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
+ var arr = ['a', 'b', 'c', 'd'];
+ arr.objectAt(0); // "a"
+ arr.objectAt(3); // "d"
+ arr.objectAt(-1); // undefined
+ arr.objectAt(4); // undefined
+ arr.objectAt(5); // undefined
+ ```
+
+ @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>=get(this, 'length'))) return undefined ;
+ return get(this, idx);
+ },
+
+ /**
+ This returns the objects at the specified indexes, using `objectAt`.
+
+ ```javascript
+ var arr =Â ['a', 'b', 'c', 'd'];
+ arr.objectsAt([0, 1, 2]); // ["a", "b", "c"]
+ arr.objectsAt([2, 3, 4]); // ["c", "d", undefined]
+ ```
+
+ @method objectsAt
+ @param {Array} indexes An array of indexes of items to return.
+ @return {Array}
+ */
+ objectsAt: function(indexes) {
+ var self = this;
+ return map(indexes, function(idx) { return self.objectAt(idx); });
+ },
+
+ // overrides Ember.Enumerable version
+ nextObject: function(idx) {
+ return this.objectAt(idx);
+ },
+
+ /**
+ This is the handler for the special array content property. If you get
+ this property, it will return this. If you set this property it a new
+ array, it will replace the current content.
+
+ This property overrides the default property defined in `Ember.Enumerable`.
+
+ @property []
+ @return this
+ */
+ '[]': Ember.computed(function(key, value) {
+ if (value !== undefined) this.replace(0, get(this, 'length'), value) ;
+ return this ;
+ }),
+
+ firstObject: Ember.computed(function() {
+ return this.objectAt(0);
+ }),
+
+ lastObject: Ember.computed(function() {
+ return this.objectAt(get(this, 'length')-1);
+ }),
+
+ // optimized version from Enumerable
+ contains: function(obj) {
+ return this.indexOf(obj) >= 0;
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
+ },
+
+ // Add any extra methods to Ember.Array that are native to the built-in Array.
+ /**
+<<<<<<< HEAD
+ 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
+ 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
+ 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
+ you do not pass a `context` parameter:
+
+ ```javascript
+ fooDidChange: function(sender, key, value, rev) { };
+ ```
+
+ 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
+ revision like so:
+
+ ```javascript
+ fooDidChange: function(sender, key, value, context, rev) { };
+ ```
+
+ 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
+ @param {String} key The key to observer
+ @param {Object} target The target object to invoke
+ @param {String|Function} method The method to invoke.
+ @return {Ember.Object} self
+ */
+ addObserver: function(key, target, method) {
+ Ember.addObserver(this, key, target, method);
+ },
+
+ /**
+ 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
+ @param {String} key The key to observer
+ @param {Object} target The target object to invoke
+ @param {String|Function} method The method to invoke.
+ @return {Ember.Observable} receiver
+ */
+ removeObserver: function(key, target, method) {
+ Ember.removeObserver(this, key, target, method);
+ },
+
+ /**
+ Returns `true` if the object currently has observers registered for a
+ 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
+ @param {String} key Key to check
+ @return {Boolean}
+ */
+ hasObserverFor: function(key) {
+ return Ember.hasListeners(this, key+':change');
+ },
+
+ /**
+ Retrieves the value of a property, or a default value in the case that the
+ property returns `undefined`.
+
+ ```javascript
+ person.getWithDefault('lastName', 'Doe');
+ ```
+
+ @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) {
+ return Ember.getWithDefault(this, keyName, defaultValue);
+ },
+
+ /**
+ Set the value of a property to the current value plus some amount.
+
+ ```javascript
+ person.incrementProperty('age');
+ team.incrementProperty('score', 2);
+ ```
+
+ @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 (Ember.isNone(increment)) { increment = 1; }
+ Ember.assert("Must pass a numeric value to incrementProperty", (!isNaN(parseFloat(increment)) && isFinite(increment)));
+ set(this, keyName, (get(this, keyName) || 0) + increment);
+ return get(this, keyName);
+ },
+
+ /**
+ Set the value of a property to the current value minus some amount.
+
+ ```javascript
+ player.decrementProperty('lives');
+ orc.decrementProperty('health', 5);
+ ```
+
+ @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 (Ember.isNone(decrement)) { decrement = 1; }
+ Ember.assert("Must pass a numeric value to decrementProperty", (!isNaN(parseFloat(decrement)) && isFinite(decrement)));
+ set(this, keyName, (get(this, keyName) || 0) - decrement);
+ return get(this, keyName);
+ },
+
+ /**
+ Set the value of a boolean property to the opposite of it's
+ current value.
+
+ ```javascript
+ starship.toggleProperty('warpDriveEngaged');
+ ```
+
+ @method toggleProperty
+ @param {String} keyName The name of the property to toggle
+ @return {Object} The new property value
+ */
+ toggleProperty: function(keyName) {
+ set(this, keyName, !get(this, keyName));
+ return get(this, keyName);
+ },
+
+ /**
+ Returns the cached value of a computed property, if it exists.
+ 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
+ @param {String} keyName
+ @return {Object} The cached value of the computed property, if any
+ */
+ cacheFor: function(keyName) {
+ return Ember.cacheFor(this, keyName);
+ },
+
+ // intended for debugging purposes
+ observersForKey: function(keyName) {
+ return Ember.observersFor(this, keyName);
+ }
+});
+
+})();
+
+
+
(function() {
/**
@module ember
@@ -10763,8 +15857,467 @@ CoreObject.PrototypeMixin = Mixin.create({
init: function() {
alert('Name is ' + this.get('name'));
}
+=======
+ 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
+ var arr = ['red', 'green', 'blue'];
+ arr.slice(0); // ['red', 'green', 'blue']
+ arr.slice(0, 2); // ['red', 'green']
+ arr.slice(1, 100); // ['green', 'blue']
+ ```
+
+ @method slice
+ @param {Integer} beginIndex (Optional) index to begin slicing from.
+ @param {Integer} endIndex (Optional) index to end the slice at.
+ @return {Array} New array with specified slice
+ */
+ slice: function(beginIndex, endIndex) {
+ var ret = Ember.A();
+ var length = get(this, 'length') ;
+ if (isNone(beginIndex)) beginIndex = 0 ;
+ if (isNone(endIndex) || (endIndex > length)) endIndex = length ;
+
+ if (beginIndex < 0) beginIndex = length + beginIndex;
+ if (endIndex < 0) endIndex = length + endIndex;
+
+ while(beginIndex < endIndex) {
+ ret[ret.length] = this.objectAt(beginIndex++) ;
+ }
+ return ret ;
+ },
+
+ /**
+ Returns the index of the given object's first occurrence.
+ 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
+ var arr = ["a", "b", "c", "d", "a"];
+ 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
+ @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 idx, len = get(this, 'length');
+
+ if (startAt === undefined) startAt = 0;
+ if (startAt < 0) startAt += len;
+
+ for(idx=startAt;idx= len) startAt = len-1;
+ if (startAt < 0) startAt += len;
+
+ for(idx=startAt;idx>=0;idx--) {
+ if (this.objectAt(idx) === object) return idx ;
+ }
+ return -1;
+ },
+
+ // ..........................................................
+ // ARRAY OBSERVERS
+ //
+
+ /**
+ 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
+ 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
+ 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
+ which you can use to override the method names that will be invoked on the
+ target.
+
+ @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) {
+ var willChange = (opts && opts.willChange) || 'arrayWillChange',
+ didChange = (opts && opts.didChange) || 'arrayDidChange';
+
+ var hasObservers = get(this, 'hasArrayObservers');
+ if (!hasObservers) Ember.propertyWillChange(this, 'hasArrayObservers');
+ Ember.addListener(this, '@array:before', target, willChange);
+ Ember.addListener(this, '@array:change', target, didChange);
+ if (!hasObservers) Ember.propertyDidChange(this, 'hasArrayObservers');
+ return this;
+ },
+
+ /**
+ 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
+ @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) {
+ var willChange = (opts && opts.willChange) || 'arrayWillChange',
+ didChange = (opts && opts.didChange) || 'arrayDidChange';
+
+ var hasObservers = get(this, 'hasArrayObservers');
+ if (hasObservers) Ember.propertyWillChange(this, 'hasArrayObservers');
+ Ember.removeListener(this, '@array:before', target, willChange);
+ Ember.removeListener(this, '@array:change', target, didChange);
+ if (hasObservers) Ember.propertyDidChange(this, 'hasArrayObservers');
+ return this;
+ },
+
+ /**
+ Becomes true whenever the array currently has observers watching changes
+ on the array.
+
+ @property Boolean
+ */
+ hasArrayObservers: Ember.computed(function() {
+ return Ember.hasListeners(this, '@array:change') || Ember.hasListeners(this, '@array:before');
+ }),
+
+ /**
+ If you are implementing an object that supports `Ember.Array`, call this
+ 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
+ @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
+ @param {Number} addAmt The number of items that will be added. If you
+ pass `null` assumes 0.
+ @return {Ember.Array} receiver
+ */
+ arrayContentWillChange: function(startIdx, removeAmt, addAmt) {
+
+ // if no args are passed assume everything changes
+ if (startIdx===undefined) {
+ startIdx = 0;
+ removeAmt = addAmt = -1;
+ } else {
+ if (removeAmt === undefined) removeAmt=-1;
+ if (addAmt === undefined) addAmt=-1;
+ }
+
+ // Make sure the @each proxy is set up if anyone is observing @each
+ if (Ember.isWatching(this, '@each')) { get(this, '@each'); }
+
+ Ember.sendEvent(this, '@array:before', [this, startIdx, removeAmt, addAmt]);
+
+ var removing, lim;
+ if (startIdx>=0 && removeAmt>=0 && get(this, 'hasEnumerableObservers')) {
+ removing = [];
+ lim = startIdx+removeAmt;
+ for(var idx=startIdx;idx=0 && addAmt>=0 && get(this, 'hasEnumerableObservers')) {
+ adding = [];
+ lim = startIdx+addAmt;
+ for(var idx=startIdx;idx Ember.TrackedArray instances. We use
+ // this to lazily recompute indexes for item property observers.
+ this.trackedArraysByGuid = {};
+
+ // We suspend observers to ignore replacements from `reset` when totally
+ // recomputing. Unfortunately we cannot properly suspend the observers
+ // because we only have the key; instead we make the observers no-ops
+ this.suspended = false;
+
+ // This is used to coalesce item changes from property observers.
+ this.changedItems = {};
+}
+
+function ItemPropertyObserverContext (dependentArray, index, trackedArray) {
+ Ember.assert("Internal error: trackedArray is null or undefined", trackedArray);
+
+ this.dependentArray = dependentArray;
+ this.index = index;
+ this.item = dependentArray.objectAt(index);
+ this.trackedArray = trackedArray;
+ this.beforeObserver = null;
+ this.observer = null;
+
+ this.destroyed = false;
+}
+
+DependentArraysObserver.prototype = {
+ setValue: function (newValue) {
+ this.instanceMeta.setValue(newValue, true);
+ },
+ getValue: function () {
+ return this.instanceMeta.getValue();
+ },
+
+ setupObservers: function (dependentArray, dependentKey) {
+ Ember.assert("dependent array must be an `Ember.Array`", Ember.Array.detect(dependentArray));
+
+ this.dependentKeysByGuid[guidFor(dependentArray)] = dependentKey;
+
+ dependentArray.addArrayObserver(this, {
+ willChange: 'dependentArrayWillChange',
+ didChange: 'dependentArrayDidChange'
});
+ if (this.cp._itemPropertyKeys[dependentKey]) {
+ this.setupPropertyObservers(dependentKey, this.cp._itemPropertyKeys[dependentKey]);
+ }
+ },
+
+ teardownObservers: function (dependentArray, dependentKey) {
+ var itemPropertyKeys = this.cp._itemPropertyKeys[dependentKey] || [];
+
+ delete this.dependentKeysByGuid[guidFor(dependentArray)];
+
+ this.teardownPropertyObservers(dependentKey, itemPropertyKeys);
+
+ dependentArray.removeArrayObserver(this, {
+ willChange: 'dependentArrayWillChange',
+ didChange: 'dependentArrayDidChange'
+ });
+ },
+
+ suspendArrayObservers: function (callback, binding) {
+ var oldSuspended = this.suspended;
+ this.suspended = true;
+ callback.call(binding);
+ this.suspended = oldSuspended;
+ },
+
+ setupPropertyObservers: function (dependentKey, itemPropertyKeys) {
+ var dependentArray = get(this.instanceMeta.context, dependentKey),
+ length = get(dependentArray, 'length'),
+ observerContexts = new Array(length);
+
+ this.resetTransformations(dependentKey, observerContexts);
+
+ forEach(dependentArray, function (item, index) {
+ var observerContext = this.createPropertyObserverContext(dependentArray, index, this.trackedArraysByGuid[dependentKey]);
+ observerContexts[index] = observerContext;
+
+ forEach(itemPropertyKeys, function (propertyKey) {
+ addBeforeObserver(item, propertyKey, this, observerContext.beforeObserver);
+ addObserver(item, propertyKey, this, observerContext.observer);
+ }, this);
+ }, this);
+ },
+
+ teardownPropertyObservers: function (dependentKey, itemPropertyKeys) {
+ var dependentArrayObserver = this,
+ trackedArray = this.trackedArraysByGuid[dependentKey],
+ beforeObserver,
+ observer,
+ item;
+
+ if (!trackedArray) { return; }
+
+ trackedArray.apply(function (observerContexts, offset, operation) {
+ if (operation === Ember.TrackedArray.DELETE) { return; }
+
+ forEach(observerContexts, function (observerContext) {
+ observerContext.destroyed = true;
+ beforeObserver = observerContext.beforeObserver;
+ observer = observerContext.observer;
+ item = observerContext.item;
+
+ forEach(itemPropertyKeys, function (propertyKey) {
+ removeBeforeObserver(item, propertyKey, dependentArrayObserver, beforeObserver);
+ removeObserver(item, propertyKey, dependentArrayObserver, observer);
+ });
+ });
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
+ });
+
+<<<<<<< HEAD
var steve = App.Person.create({
name: "Steve"
});
@@ -11463,6 +17016,846 @@ function findNamespaces() {
var Namespace = Ember.Namespace, lookup = Ember.lookup, obj, isNamespace;
if (Namespace.PROCESSED) { return; }
+=======
+ createPropertyObserverContext: function (dependentArray, index, trackedArray) {
+ var observerContext = new ItemPropertyObserverContext(dependentArray, index, trackedArray);
+
+ this.createPropertyObserver(observerContext);
+
+ return observerContext;
+ },
+
+ createPropertyObserver: function (observerContext) {
+ var dependentArrayObserver = this;
+
+ observerContext.beforeObserver = function (obj, keyName) {
+ return dependentArrayObserver.itemPropertyWillChange(obj, keyName, observerContext.dependentArray, observerContext);
+ };
+ observerContext.observer = function (obj, keyName) {
+ return dependentArrayObserver.itemPropertyDidChange(obj, keyName, observerContext.dependentArray, observerContext);
+ };
+ },
+
+ resetTransformations: function (dependentKey, observerContexts) {
+ this.trackedArraysByGuid[dependentKey] = new Ember.TrackedArray(observerContexts);
+ },
+
+ trackAdd: function (dependentKey, index, newItems) {
+ var trackedArray = this.trackedArraysByGuid[dependentKey];
+ if (trackedArray) {
+ trackedArray.addItems(index, newItems);
+ }
+ },
+
+ trackRemove: function (dependentKey, index, removedCount) {
+ var trackedArray = this.trackedArraysByGuid[dependentKey];
+
+ if (trackedArray) {
+ return trackedArray.removeItems(index, removedCount);
+ }
+
+ return [];
+ },
+
+ updateIndexes: function (trackedArray, array) {
+ 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) {
+ // 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 === Ember.TrackedArray.DELETE) { return; }
+ if (operation === Ember.TrackedArray.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.
+ return;
+ }
+
+ forEach(observerContexts, function (context, index) {
+ context.index = index + offset;
+ });
+ });
+ },
+
+ dependentArrayWillChange: function (dependentArray, index, removedCount, addedCount) {
+ if (this.suspended) { return; }
+
+ var removedItem = this.callbacks.removedItem,
+ changeMeta,
+ guid = guidFor(dependentArray),
+ dependentKey = this.dependentKeysByGuid[guid],
+ itemPropertyKeys = this.cp._itemPropertyKeys[dependentKey] || [],
+ length = get(dependentArray, 'length'),
+ normalizedIndex = normalizeIndex(index, length, 0),
+ normalizedRemoveCount = normalizeRemoveCount(normalizedIndex, length, removedCount),
+ item,
+ itemIndex,
+ sliceIndex,
+ observerContexts;
+
+ observerContexts = this.trackRemove(dependentKey, normalizedIndex, normalizedRemoveCount);
+
+ function removeObservers(propertyKey) {
+ observerContexts[sliceIndex].destroyed = true;
+ removeBeforeObserver(item, propertyKey, this, observerContexts[sliceIndex].beforeObserver);
+ removeObserver(item, propertyKey, this, observerContexts[sliceIndex].observer);
+ }
+
+ for (sliceIndex = normalizedRemoveCount - 1; sliceIndex >= 0; --sliceIndex) {
+ itemIndex = normalizedIndex + sliceIndex;
+ if (itemIndex >= length) { break; }
+
+ item = dependentArray.objectAt(itemIndex);
+
+ forEach(itemPropertyKeys, removeObservers, this);
+
+ changeMeta = createChangeMeta(dependentArray, item, itemIndex, this.instanceMeta.propertyName, this.cp);
+ this.setValue( removedItem.call(
+ this.instanceMeta.context, this.getValue(), item, changeMeta, this.instanceMeta.sugarMeta));
+ }
+ },
+
+ dependentArrayDidChange: function (dependentArray, index, removedCount, addedCount) {
+ if (this.suspended) { return; }
+
+ var addedItem = this.callbacks.addedItem,
+ guid = guidFor(dependentArray),
+ dependentKey = this.dependentKeysByGuid[guid],
+ observerContexts = new Array(addedCount),
+ itemPropertyKeys = this.cp._itemPropertyKeys[dependentKey],
+ length = get(dependentArray, 'length'),
+ normalizedIndex = normalizeIndex(index, length, addedCount),
+ changeMeta,
+ observerContext;
+
+ forEach(dependentArray.slice(normalizedIndex, normalizedIndex + addedCount), function (item, sliceIndex) {
+ if (itemPropertyKeys) {
+ observerContext =
+ observerContexts[sliceIndex] =
+ this.createPropertyObserverContext(dependentArray, normalizedIndex + sliceIndex, this.trackedArraysByGuid[dependentKey]);
+ forEach(itemPropertyKeys, function (propertyKey) {
+ addBeforeObserver(item, propertyKey, this, observerContext.beforeObserver);
+ addObserver(item, propertyKey, this, observerContext.observer);
+ }, this);
+ }
+
+ changeMeta = createChangeMeta(dependentArray, item, normalizedIndex + sliceIndex, this.instanceMeta.propertyName, this.cp);
+ this.setValue( addedItem.call(
+ this.instanceMeta.context, this.getValue(), item, changeMeta, this.instanceMeta.sugarMeta));
+ }, this);
+
+ this.trackAdd(dependentKey, normalizedIndex, observerContexts);
+ },
+
+ itemPropertyWillChange: function (obj, keyName, array, observerContext) {
+ var guid = guidFor(obj);
+
+ if (!this.changedItems[guid]) {
+ this.changedItems[guid] = {
+ array: array,
+ observerContext: observerContext,
+ obj: obj,
+ previousValues: {}
+ };
+ }
+
+ this.changedItems[guid].previousValues[keyName] = get(obj, keyName);
+ },
+
+ itemPropertyDidChange: function(obj, keyName, array, observerContext) {
+ this.flushChanges();
+ },
+
+ flushChanges: function() {
+ var changedItems = this.changedItems, key, c, changeMeta;
+
+ for (key in changedItems) {
+ c = changedItems[key];
+ if (c.observerContext.destroyed) { continue; }
+
+ this.updateIndexes(c.observerContext.trackedArray, c.observerContext.dependentArray);
+
+ changeMeta = createChangeMeta(c.array, c.obj, c.observerContext.index, this.instanceMeta.propertyName, this.cp, 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.changedItems = {};
+ }
+};
+
+function normalizeIndex(index, length, newItemsOffset) {
+ if (index < 0) {
+ return Math.max(0, length + index);
+ } else if (index < length) {
+ return index;
+ } else /* index > length */ {
+ return Math.min(length - newItemsOffset, index);
+ }
+}
+
+function normalizeRemoveCount(index, length, removedCount) {
+ return Math.min(removedCount, length - index);
+}
+
+function createChangeMeta(dependentArray, item, index, propertyName, property, previousValues) {
+ var meta = {
+ arrayChanged: dependentArray,
+ index: index,
+ item: item,
+ propertyName: propertyName,
+ property: property
+ };
+
+ if (previousValues) {
+ // previous values only available for item property changes
+ meta.previousValues = previousValues;
+ }
+
+ return meta;
+}
+
+function addItems (dependentArray, callbacks, cp, propertyName, meta) {
+ forEach(dependentArray, function (item, index) {
+ meta.setValue( callbacks.addedItem.call(
+ this, meta.getValue(), item, createChangeMeta(dependentArray, item, index, propertyName, cp), meta.sugarMeta));
+ }, this);
+}
+
+function reset(cp, propertyName) {
+ var callbacks = cp._callbacks(),
+ meta;
+
+ if (cp._hasInstanceMeta(this, propertyName)) {
+ meta = cp._instanceMeta(this, propertyName);
+ meta.setValue(cp.resetValue(meta.getValue()));
+ } else {
+ meta = cp._instanceMeta(this, propertyName);
+ }
+
+ if (cp.options.initialize) {
+ cp.options.initialize.call(this, meta.getValue(), { property: cp, propertyName: propertyName }, meta.sugarMeta);
+ }
+}
+
+function partiallyRecomputeFor(obj, dependentKey) {
+ if (arrayBracketPattern.test(dependentKey)) {
+ return false;
+ }
+
+ var value = get(obj, dependentKey);
+ return Ember.Array.detect(value);
+}
+
+function ReduceComputedPropertyInstanceMeta(context, propertyName, initialValue) {
+ this.context = context;
+ this.propertyName = propertyName;
+ this.cache = metaFor(context).cache;
+
+ this.dependentArrays = {};
+ this.sugarMeta = {};
+
+ this.initialValue = initialValue;
+}
+
+ReduceComputedPropertyInstanceMeta.prototype = {
+ getValue: function () {
+ if (this.propertyName in this.cache) {
+ return this.cache[this.propertyName];
+ } else {
+ return this.initialValue;
+ }
+ },
+
+ setValue: function(newValue, triggerObservers) {
+ // This lets sugars force a recomputation, handy for very simple
+ // implementations of eg max.
+ if (newValue !== undefined) {
+ var fireObservers = triggerObservers && (newValue !== this.cache[this.propertyName]);
+
+ if (fireObservers) {
+ propertyWillChange(this.context, this.propertyName);
+ }
+
+ this.cache[this.propertyName] = newValue;
+
+ if (fireObservers) {
+ propertyDidChange(this.context, this.propertyName);
+ }
+ } else {
+ delete this.cache[this.propertyName];
+ }
+ }
+};
+
+/**
+ A computed property whose dependent keys are arrays and which is updated with
+ "one at a time" semantics.
+
+ @class ReduceComputedProperty
+ @namespace Ember
+ @extends Ember.ComputedProperty
+ @constructor
+*/
+function ReduceComputedProperty(options) {
+ var cp = this;
+
+ this.options = options;
+ this._instanceMetas = {};
+
+ this._dependentKeys = null;
+ // A map of dependentKey -> [itemProperty, ...] that tracks what properties of
+ // items in the array we must track to update this property.
+ this._itemPropertyKeys = {};
+ this._previousItemPropertyKeys = {};
+
+ this.readOnly();
+ this.cacheable();
+
+ this.recomputeOnce = function(propertyName) {
+ // What we really want to do is coalesce by .
+ // We need a form of `scheduleOnce` that accepts an arbitrary token to
+ // coalesce by, in addition to the target and method.
+ Ember.run.once(this, recompute, propertyName);
+ };
+ var recompute = function(propertyName) {
+ var dependentKeys = cp._dependentKeys,
+ meta = cp._instanceMeta(this, propertyName),
+ callbacks = cp._callbacks();
+
+ reset.call(this, cp, propertyName);
+
+ meta.dependentArraysObserver.suspendArrayObservers(function () {
+ forEach(cp._dependentKeys, function (dependentKey) {
+ if (!partiallyRecomputeFor(this, dependentKey)) { return; }
+
+ var dependentArray = get(this, dependentKey),
+ previousDependentArray = meta.dependentArrays[dependentKey];
+
+ if (dependentArray === previousDependentArray) {
+ // The array may be the same, but our item property keys may have
+ // changed, so we set them up again. We can't easily tell if they've
+ // changed: the array may be the same object, but with different
+ // contents.
+ if (cp._previousItemPropertyKeys[dependentKey]) {
+ delete cp._previousItemPropertyKeys[dependentKey];
+ meta.dependentArraysObserver.setupPropertyObservers(dependentKey, cp._itemPropertyKeys[dependentKey]);
+ }
+ } else {
+ meta.dependentArrays[dependentKey] = dependentArray;
+
+ if (previousDependentArray) {
+ meta.dependentArraysObserver.teardownObservers(previousDependentArray, dependentKey);
+ }
+
+ if (dependentArray) {
+ meta.dependentArraysObserver.setupObservers(dependentArray, dependentKey);
+ }
+ }
+ }, this);
+ }, this);
+
+ forEach(cp._dependentKeys, function(dependentKey) {
+ if (!partiallyRecomputeFor(this, dependentKey)) { return; }
+
+ var dependentArray = get(this, dependentKey);
+ if (dependentArray) {
+ addItems.call(this, dependentArray, callbacks, cp, propertyName, meta);
+ }
+ }, this);
+ };
+
+ this.func = function (propertyName) {
+ Ember.assert("Computed reduce values require at least one dependent key", cp._dependentKeys);
+
+ recompute.call(this, propertyName);
+
+ return cp._instanceMeta(this, propertyName).getValue();
+ };
+}
+
+Ember.ReduceComputedProperty = ReduceComputedProperty;
+ReduceComputedProperty.prototype = o_create(ComputedProperty.prototype);
+
+function defaultCallback(computedValue) {
+ return computedValue;
+}
+
+ReduceComputedProperty.prototype._callbacks = function () {
+ if (!this.callbacks) {
+ var options = this.options;
+ this.callbacks = {
+ removedItem: options.removedItem || defaultCallback,
+ addedItem: options.addedItem || defaultCallback
+ };
+ }
+ return this.callbacks;
+};
+
+ReduceComputedProperty.prototype._hasInstanceMeta = function (context, propertyName) {
+ var guid = guidFor(context),
+ key = guid + ':' + propertyName;
+
+ return !!this._instanceMetas[key];
+};
+
+ReduceComputedProperty.prototype._instanceMeta = function (context, propertyName) {
+ var guid = guidFor(context),
+ key = guid + ':' + propertyName,
+ meta = this._instanceMetas[key];
+
+ if (!meta) {
+ meta = this._instanceMetas[key] = new ReduceComputedPropertyInstanceMeta(context, propertyName, this.initialValue());
+ meta.dependentArraysObserver = new DependentArraysObserver(this._callbacks(), this, meta, context, propertyName, meta.sugarMeta);
+ }
+
+ return meta;
+};
+
+ReduceComputedProperty.prototype.initialValue = function () {
+ if (typeof this.options.initialValue === 'function') {
+ return this.options.initialValue();
+ }
+ else {
+ return this.options.initialValue;
+ }
+};
+
+ReduceComputedProperty.prototype.resetValue = function (value) {
+ return this.initialValue();
+};
+
+ReduceComputedProperty.prototype.itemPropertyKey = function (dependentArrayKey, itemPropertyKey) {
+ this._itemPropertyKeys[dependentArrayKey] = this._itemPropertyKeys[dependentArrayKey] || [];
+ this._itemPropertyKeys[dependentArrayKey].push(itemPropertyKey);
+};
+
+ReduceComputedProperty.prototype.clearItemPropertyKeys = function (dependentArrayKey) {
+ if (this._itemPropertyKeys[dependentArrayKey]) {
+ this._previousItemPropertyKeys[dependentArrayKey] = this._itemPropertyKeys[dependentArrayKey];
+ this._itemPropertyKeys[dependentArrayKey] = [];
+ }
+};
+
+ReduceComputedProperty.prototype.property = function () {
+ var cp = this,
+ args = a_slice.call(arguments),
+ propertyArgs = new Ember.Set(),
+ match,
+ dependentArrayKey,
+ itemPropertyKey;
+
+ forEach(a_slice.call(arguments), function (dependentKey) {
+ if (doubleEachPropertyPattern.test(dependentKey)) {
+ throw new Ember.Error("Nested @each properties not supported: " + dependentKey);
+ } else if (match = eachPropertyPattern.exec(dependentKey)) {
+ dependentArrayKey = match[1];
+
+
+ itemPropertyKey = match[2];
+ cp.itemPropertyKey(dependentArrayKey, itemPropertyKey);
+
+ propertyArgs.add(dependentArrayKey);
+ } else {
+ propertyArgs.add(dependentKey);
+ }
+ });
+
+ return ComputedProperty.prototype.property.apply(this, propertyArgs.toArray());
+
+};
+
+/**
+ 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 `someArray.@each.someProperty`),
+ `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.call(null, 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('@this.@each.reversedName', 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
+ // `content.@each.reversedName` above, we would be getting the objects
+ // directly and not have access to `reversedName`.
+ //
+ var reversedNameA = get(personA, 'reversedName'),
+ 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.
+
+ 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}
+*/
+Ember.reduceComputed = function (options) {
+ var args;
+
+ if (arguments.length > 1) {
+ args = a_slice.call(arguments, 0, -1);
+ options = a_slice.call(arguments, -1)[0];
+ }
+
+ if (typeof options !== "object") {
+ throw new Ember.Error("Reduce Computed Property declared without an options hash");
+ }
+
+ if (!('initialValue' in options)) {
+ throw new Ember.Error("Reduce Computed Property declared without an initial value");
+ }
+
+ var cp = new ReduceComputedProperty(options);
+
+ if (args) {
+ cp.property.apply(cp, args);
+ }
+
+ return cp;
+};
+
+})();
+
+
+
+(function() {
+var ReduceComputedProperty = Ember.ReduceComputedProperty,
+ a_slice = [].slice,
+ o_create = Ember.create,
+ forEach = Ember.EnumerableUtils.forEach;
+
+function ArrayComputedProperty() {
+ var cp = this;
+
+ ReduceComputedProperty.apply(this, arguments);
+
+ this.func = (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.
+ forEach(cp._dependentKeys, function(dependentKey) {
+ Ember.addObserver(this, dependentKey, function() {
+ cp.recomputeOnce.call(this, propertyName);
+ });
+ }, this);
+ }
+
+ return reduceFunc.apply(this, arguments);
+ };
+ })(this.func);
+
+ return this;
+}
+Ember.ArrayComputedProperty = ArrayComputedProperty;
+ArrayComputedProperty.prototype = o_create(ReduceComputedProperty.prototype);
+ArrayComputedProperty.prototype.initialValue = function () {
+ return Ember.A();
+};
+ArrayComputedProperty.prototype.resetValue = function (array) {
+ array.clear();
+ return array;
+};
+
+// This is a stopgap to keep the reference counts correct with lazy CPs.
+ArrayComputedProperty.prototype.didChange = function (obj, keyName) {
+ return;
+};
+
+/**
+ 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) an array computed only operates
+ on the change instead of re-evaluating the entire array. This should
+ return an array, if you'd like to use "one at a time" semantics and
+ compute some value other then an array look at
+ `Ember.reduceComputed`.
+
+ 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 three properties.
+
+ `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 (array, changeMeta, instanceMeta)
+ ```
+
+ `array` - The initial value of the arrayComputed, an empty array.
+
+ `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 an empty array.
+
+ `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 `someArray.@each.someProperty`),
+ `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.
+
+ Example
+
+ ```javascript
+ Ember.computed.map = function(dependentKey, callback) {
+ var options = {
+ addedItem: function(array, item, changeMeta, instanceMeta) {
+ var mapped = callback(item);
+ array.insertAt(changeMeta.index, mapped);
+ return array;
+ },
+ removedItem: function(array, item, changeMeta, instanceMeta) {
+ array.removeAt(changeMeta.index, 1);
+ return array;
+ }
+ };
+
+ return Ember.arrayComputed(dependentKey, options);
+ };
+ ```
+
+ @method arrayComputed
+ @for Ember
+ @param {String} [dependentKeys*]
+ @param {Object} options
+ @return {Ember.ComputedProperty}
+*/
+Ember.arrayComputed = function (options) {
+ var args;
+
+ if (arguments.length > 1) {
+ args = a_slice.call(arguments, 0, -1);
+ options = a_slice.call(arguments, -1)[0];
+ }
+
+ if (typeof options !== "object") {
+ throw new Ember.Error("Array Computed Property declared without an options hash");
+ }
+
+ var cp = new ArrayComputedProperty(options);
+
+ if (args) {
+ cp.property.apply(cp, args);
+ }
+
+ return cp;
+};
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
for (var prop in lookup) {
// These don't raise exceptions but can cause warnings
@@ -11490,6 +17883,7 @@ function findNamespaces() {
}
}
+<<<<<<< HEAD
var NAME_KEY = Ember.NAME_KEY = Ember.GUID_KEY + '_name';
function superClassString(mixin) {
@@ -11551,17 +17945,158 @@ function makeToString(ret) {
}
Ember.Mixin.prototype.toString = classToString;
+=======
+var get = Ember.get,
+ set = Ember.set,
+ guidFor = Ember.guidFor,
+ merge = Ember.merge,
+ a_slice = [].slice,
+ forEach = Ember.EnumerableUtils.forEach,
+ map = Ember.EnumerableUtils.map,
+ SearchProxy;
-})();
-
-
-
-(function() {
/**
-@module ember
-@submodule ember-runtime
-*/
+ A computed property that calculates the maximum value in the
+ dependent array. This will return `-Infinity` when the dependent
+ array is empty.
+ ```javascript
+ App.Person = Ember.Object.extend({
+ childAges: Ember.computed.mapBy('children', 'age'),
+ maxChildAge: Ember.computed.max('childAges')
+ });
+
+ var lordByron = App.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 computed.max
+ @for Ember
+ @param {String} dependentKey
+ @return {Ember.ComputedProperty} computes the largest value in the dependentKey's array
+*/
+Ember.computed.max = function (dependentKey) {
+ return Ember.reduceComputed.call(null, 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;
+ }
+ }
+ });
+};
+
+/**
+ A computed property that calculates the minimum value in the
+ dependent array. This will return `Infinity` when the dependent
+ array is empty.
+
+ ```javascript
+ App.Person = Ember.Object.extend({
+ childAges: Ember.computed.mapBy('children', 'age'),
+ minChildAge: Ember.computed.min('childAges')
+ });
+
+ var lordByron = App.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 computed.min
+ @for Ember
+ @param {String} dependentKey
+ @return {Ember.ComputedProperty} computes the smallest value in the dependentKey's array
+*/
+Ember.computed.min = function (dependentKey) {
+ return Ember.reduceComputed.call(null, dependentKey, {
+ initialValue: Infinity,
+
+ addedItem: function (accumulatedValue, item, changeMeta, instanceMeta) {
+ return Math.min(accumulatedValue, item);
+ },
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
+
+ removedItem: function (accumulatedValue, item, changeMeta, instanceMeta) {
+ if (item > accumulatedValue) {
+ return accumulatedValue;
+ }
+ }
+ });
+};
+
+/**
+ 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.
+
+ ```javascript
+ function(item);
+ ```
+
+ Example
+
+ ```javascript
+ App.Hamster = Ember.Object.extend({
+ excitingChores: Ember.computed.map('chores', function(chore) {
+ return chore.toUpperCase() + '!';
+ })
+ });
+
+ var hamster = App.Hamster.create({
+ chores: ['clean', 'write more unit tests']
+ });
+ hamster.get('excitingChores'); // ['CLEAN!', 'WRITE MORE UNIT TESTS!']
+ ```
+
+ @method computed.map
+ @for Ember
+ @param {String} dependentKey
+ @param {Function} callback
+ @return {Ember.ComputedProperty} an array mapped via the callback
+*/
+Ember.computed.map = function(dependentKey, callback) {
+ var options = {
+ addedItem: function(array, item, changeMeta, instanceMeta) {
+ var mapped = callback.call(this, item);
+ array.insertAt(changeMeta.index, mapped);
+ return array;
+ },
+ removedItem: function(array, item, changeMeta, instanceMeta) {
+ array.removeAt(changeMeta.index, 1);
+ return array;
+ }
+ };
+
+<<<<<<< HEAD
var get = Ember.get,
set = Ember.set,
fmt = Ember.String.fmt,
@@ -11704,17 +18239,142 @@ Ember.ObjectProxy = Ember.Object.extend(/** @scope Ember.ObjectProxy.prototype *
}
});
+=======
+ return Ember.arrayComputed(dependentKey, options);
+};
-})();
-
-
-
-(function() {
/**
-@module ember
-@submodule ember-runtime
-*/
+ Returns an array mapped to the specified key.
+ ```javascript
+ App.Person = Ember.Object.extend({
+ childAges: Ember.computed.mapBy('children', 'age')
+ });
+
+ var lordByron = App.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 computed.mapBy
+ @for Ember
+ @param {String} dependentKey
+ @param {String} propertyKey
+ @return {Ember.ComputedProperty} an array mapped to the specified key
+*/
+Ember.computed.mapBy = function(dependentKey, propertyKey) {
+ var callback = function(item) { return get(item, propertyKey); };
+ return Ember.computed.map(dependentKey + '.@each.' + propertyKey, callback);
+};
+
+/**
+ @method computed.mapProperty
+ @for Ember
+ @deprecated Use `Ember.computed.mapBy` instead
+ @param dependentKey
+ @param propertyKey
+*/
+Ember.computed.mapProperty = Ember.computed.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.
+
+ ```javascript
+ function(item);
+ ```
+
+ ```javascript
+ App.Hamster = Ember.Object.extend({
+ remainingChores: Ember.computed.filter('chores', function(chore) {
+ return !chore.done;
+ })
+ });
+
+ var hamster = App.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 computed.filter
+ @for Ember
+ @param {String} dependentKey
+ @param {Function} callback
+ @return {Ember.ComputedProperty} the filtered array
+*/
+Ember.computed.filter = function(dependentKey, callback) {
+ var options = {
+ initialize: function (array, changeMeta, instanceMeta) {
+ instanceMeta.filteredArrayIndexes = new Ember.SubArray();
+ },
+
+ addedItem: function(array, item, changeMeta, instanceMeta) {
+ var match = !!callback.call(this, item),
+ filterIndex = instanceMeta.filteredArrayIndexes.addItem(changeMeta.index, match);
+
+ if (match) {
+ array.insertAt(filterIndex, item);
+ }
+
+ return array;
+ },
+
+ removedItem: function(array, item, changeMeta, instanceMeta) {
+ var filterIndex = instanceMeta.filteredArrayIndexes.removeItem(changeMeta.index);
+
+ if (filterIndex > -1) {
+ array.removeAt(filterIndex);
+ }
+
+ return array;
+ }
+ };
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
+
+ return Ember.arrayComputed(dependentKey, options);
+};
+
+/**
+ Filters the array by the property and value
+
+ ```javascript
+ App.Hamster = Ember.Object.extend({
+ remainingChores: Ember.computed.filterBy('chores', 'done', false)
+ });
+
+ var hamster = App.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 computed.filterBy
+ @for Ember
+ @param {String} dependentKey
+ @param {String} propertyKey
+ @param {String} value
+ @return {Ember.ComputedProperty} the filtered array
+*/
+Ember.computed.filterBy = function(dependentKey, propertyKey, value) {
+ var callback;
+
+<<<<<<< HEAD
// ..........................................................
// HELPERS
//
@@ -11964,6 +18624,461 @@ Ember.Enumerable = Ember.Mixin.create({
set(item, key, value);
});
},
+=======
+ if (arguments.length === 2) {
+ callback = function(item) {
+ return get(item, propertyKey);
+ };
+ } else {
+ callback = function(item) {
+ return get(item, propertyKey) === value;
+ };
+ }
+
+ return Ember.computed.filter(dependentKey + '.@each.' + propertyKey, callback);
+};
+
+/**
+ @method computed.filterProperty
+ @for Ember
+ @param dependentKey
+ @param propertyKey
+ @param value
+ @deprecated Use `Ember.computed.filterBy` instead
+*/
+Ember.computed.filterProperty = Ember.computed.filterBy;
+
+/**
+ A computed property which returns a new array with all the unique
+ elements from one or more dependent arrays.
+
+ Example
+
+ ```javascript
+ App.Hamster = Ember.Object.extend({
+ uniqueFruits: Ember.computed.uniq('fruits')
+ });
+
+ var hamster = App.Hamster.create({fruits: [
+ 'banana',
+ 'grape',
+ 'kale',
+ 'banana'
+ ]});
+ hamster.get('uniqueFruits'); // ['banana', 'grape', 'kale']
+ ```
+
+ @method computed.uniq
+ @for Ember
+ @param {String} propertyKey*
+ @return {Ember.ComputedProperty} computes a new array with all the
+ unique elements from the dependent array
+*/
+Ember.computed.uniq = function() {
+ var args = a_slice.call(arguments);
+ args.push({
+ initialize: function(array, changeMeta, instanceMeta) {
+ instanceMeta.itemCounts = {};
+ },
+
+ addedItem: function(array, item, changeMeta, instanceMeta) {
+ var guid = guidFor(item);
+
+ if (!instanceMeta.itemCounts[guid]) {
+ instanceMeta.itemCounts[guid] = 1;
+ } else {
+ ++instanceMeta.itemCounts[guid];
+ }
+ array.addObject(item);
+ return array;
+ },
+ removedItem: function(array, item, _, instanceMeta) {
+ var guid = guidFor(item),
+ itemCounts = instanceMeta.itemCounts;
+
+ if (--itemCounts[guid] === 0) {
+ array.removeObject(item);
+ }
+ return array;
+ }
+ });
+ return Ember.arrayComputed.apply(null, args);
+};
+
+/**
+ Alias for [Ember.computed.uniq](/api/#method_computed_uniq).
+
+ @method computed.union
+ @for Ember
+ @param {String} propertyKey*
+ @return {Ember.ComputedProperty} computes a new array with all the
+ unique elements from the dependent array
+*/
+Ember.computed.union = Ember.computed.uniq;
+
+/**
+ A computed property which returns a new array with all the duplicated
+ elements from two or more dependeny 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 computed.intersect
+ @for Ember
+ @param {String} propertyKey*
+ @return {Ember.ComputedProperty} computes a new array with all the
+ duplicated elements from the dependent arrays
+*/
+Ember.computed.intersect = function () {
+ var getDependentKeyGuids = function (changeMeta) {
+ return map(changeMeta.property._dependentKeys, function (dependentKey) {
+ return guidFor(dependentKey);
+ });
+ };
+
+ var args = a_slice.call(arguments);
+ args.push({
+ initialize: function (array, changeMeta, instanceMeta) {
+ instanceMeta.itemCounts = {};
+ },
+
+ addedItem: function(array, item, changeMeta, instanceMeta) {
+ var itemGuid = guidFor(item),
+ dependentGuids = getDependentKeyGuids(changeMeta),
+ dependentGuid = guidFor(changeMeta.arrayChanged),
+ numberOfDependentArrays = changeMeta.property._dependentKeys.length,
+ itemCounts = instanceMeta.itemCounts;
+
+ if (!itemCounts[itemGuid]) { itemCounts[itemGuid] = {}; }
+ if (itemCounts[itemGuid][dependentGuid] === undefined) { itemCounts[itemGuid][dependentGuid] = 0; }
+
+ if (++itemCounts[itemGuid][dependentGuid] === 1 &&
+ numberOfDependentArrays === Ember.keys(itemCounts[itemGuid]).length) {
+
+ array.addObject(item);
+ }
+ return array;
+ },
+ removedItem: function(array, item, changeMeta, instanceMeta) {
+ var itemGuid = guidFor(item),
+ dependentGuids = getDependentKeyGuids(changeMeta),
+ dependentGuid = guidFor(changeMeta.arrayChanged),
+ numberOfDependentArrays = changeMeta.property._dependentKeys.length,
+ numberOfArraysItemAppearsIn,
+ itemCounts = instanceMeta.itemCounts;
+
+ if (itemCounts[itemGuid][dependentGuid] === undefined) { itemCounts[itemGuid][dependentGuid] = 0; }
+ if (--itemCounts[itemGuid][dependentGuid] === 0) {
+ delete itemCounts[itemGuid][dependentGuid];
+ numberOfArraysItemAppearsIn = Ember.keys(itemCounts[itemGuid]).length;
+
+ if (numberOfArraysItemAppearsIn === 0) {
+ delete itemCounts[itemGuid];
+ }
+ array.removeObject(item);
+ }
+ return array;
+ }
+ });
+ return Ember.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
+ App.Hamster = Ember.Object.extend({
+ likes: ['banana', 'grape', 'kale'],
+ wants: Ember.computed.setDiff('likes', 'fruits')
+ });
+
+ var hamster = App.Hamster.create({fruits: [
+ 'grape',
+ 'kale',
+ ]});
+ hamster.get('wants'); // ['banana']
+ ```
+
+ @method computed.setDiff
+ @for Ember
+ @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
+*/
+Ember.computed.setDiff = function (setAProperty, setBProperty) {
+ if (arguments.length !== 2) {
+ throw new Ember.Error("setDiff requires exactly two dependent arrays.");
+ }
+ return Ember.arrayComputed.call(null, setAProperty, setBProperty, {
+ addedItem: function (array, item, changeMeta, instanceMeta) {
+ var setA = get(this, setAProperty),
+ setB = get(this, setBProperty);
+
+ if (changeMeta.arrayChanged === setA) {
+ if (!setB.contains(item)) {
+ array.addObject(item);
+ }
+ } else {
+ array.removeObject(item);
+ }
+ return array;
+ },
+
+ removedItem: function (array, item, changeMeta, instanceMeta) {
+ var setA = get(this, setAProperty),
+ setB = get(this, setBProperty);
+
+ if (changeMeta.arrayChanged === setB) {
+ if (setA.contains(item)) {
+ array.addObject(item);
+ }
+ } else {
+ array.removeObject(item);
+ }
+ return array;
+ }
+ });
+};
+
+function binarySearch(array, item, low, high) {
+ var mid, midItem, res, guidMid, guidItem;
+
+ if (arguments.length < 4) { high = get(array, 'length'); }
+ if (arguments.length < 3) { low = 0; }
+
+ if (low === high) {
+ return low;
+ }
+
+ mid = low + Math.floor((high - low) / 2);
+ midItem = array.objectAt(mid);
+
+ guidMid = _guidFor(midItem);
+ guidItem = _guidFor(item);
+
+ if (guidMid === guidItem) {
+ return mid;
+ }
+
+ res = this.order(midItem, item);
+ if (res === 0) {
+ res = guidMid < guidItem ? -1 : 1;
+ }
+
+
+ if (res < 0) {
+ return this.binarySearch(array, item, mid+1, high);
+ } else if (res > 0) {
+ return this.binarySearch(array, item, low, mid);
+ }
+
+ return mid;
+
+ function _guidFor(item) {
+ if (SearchProxy.detectInstance(item)) {
+ return guidFor(get(item, 'content'));
+ }
+ return guidFor(item);
+ }
+}
+
+
+SearchProxy = Ember.ObjectProxy.extend();
+
+/**
+ 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 `-1` when `itemA` should come before
+ `itemB`. It should return `1` when `itemA` should come after
+ `itemB`. If the `itemA` and `itemB` are equal this function should return `0`.
+
+ Example
+
+ ```javascript
+ var ToDoList = Ember.Object.extend({
+ todosSorting: ['name'],
+ sortedTodos: Ember.computed.sort('todos', 'todosSorting'),
+ 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('priorityTodos'); // [{name:'Release', priority:1}, {name:'Unit Test', priority:2}, {name:'Documentation', priority:3}]
+ ```
+
+ @method computed.sort
+ @for Ember
+ @param {String} dependentKey
+ @param {String or Function} sortDefinition a dependent key to an
+ array of sort properties or a function to use when sorting
+ @return {Ember.ComputedProperty} computes a new sorted array based
+ on the sort property array or callback function
+*/
+Ember.computed.sort = function (itemsKey, sortDefinition) {
+ Ember.assert("Ember.computed.sort requires two arguments: an array key to sort and either a sort properties key or sort function", arguments.length === 2);
+
+ var initFn, sortPropertiesKey;
+
+ if (typeof sortDefinition === 'function') {
+ initFn = function (array, changeMeta, instanceMeta) {
+ instanceMeta.order = sortDefinition;
+ instanceMeta.binarySearch = binarySearch;
+ };
+ } else {
+ sortPropertiesKey = sortDefinition;
+ initFn = function (array, changeMeta, instanceMeta) {
+ function setupSortProperties() {
+ var sortPropertyDefinitions = get(this, sortPropertiesKey),
+ sortProperty,
+ sortProperties = instanceMeta.sortProperties = [],
+ sortPropertyAscending = instanceMeta.sortPropertyAscending = {},
+ idx,
+ asc;
+
+ Ember.assert("Cannot sort: '" + sortPropertiesKey + "' is not an array.", Ember.isArray(sortPropertyDefinitions));
+
+ changeMeta.property.clearItemPropertyKeys(itemsKey);
+
+ forEach(sortPropertyDefinitions, function (sortPropertyDefinition) {
+ if ((idx = sortPropertyDefinition.indexOf(':')) !== -1) {
+ sortProperty = sortPropertyDefinition.substring(0, idx);
+ asc = sortPropertyDefinition.substring(idx+1).toLowerCase() !== 'desc';
+ } else {
+ sortProperty = sortPropertyDefinition;
+ asc = true;
+ }
+
+ sortProperties.push(sortProperty);
+ sortPropertyAscending[sortProperty] = asc;
+ changeMeta.property.itemPropertyKey(itemsKey, sortProperty);
+ });
+
+ sortPropertyDefinitions.addObserver('@each', this, updateSortPropertiesOnce);
+ }
+
+ function updateSortPropertiesOnce() {
+ Ember.run.once(this, updateSortProperties, changeMeta.propertyName);
+ }
+
+ function updateSortProperties(propertyName) {
+ setupSortProperties.call(this);
+ changeMeta.property.recomputeOnce.call(this, propertyName);
+ }
+
+ Ember.addObserver(this, sortPropertiesKey, updateSortPropertiesOnce);
+
+ setupSortProperties.call(this);
+
+
+ instanceMeta.order = function (itemA, itemB) {
+ var sortProperty, result, asc;
+ for (var i = 0; i < this.sortProperties.length; ++i) {
+ sortProperty = this.sortProperties[i];
+ result = Ember.compare(get(itemA, sortProperty), get(itemB, sortProperty));
+
+ if (result !== 0) {
+ asc = this.sortPropertyAscending[sortProperty];
+ return asc ? result : (-1 * result);
+ }
+ }
+
+ return 0;
+ };
+
+ instanceMeta.binarySearch = binarySearch;
+ };
+ }
+
+ return Ember.arrayComputed.call(null, itemsKey, {
+ initialize: initFn,
+
+ addedItem: function (array, item, changeMeta, instanceMeta) {
+ var index = instanceMeta.binarySearch(array, item);
+ array.insertAt(index, item);
+ return array;
+ },
+
+ removedItem: function (array, item, changeMeta, instanceMeta) {
+ var proxyProperties, index, searchItem;
+
+ if (changeMeta.previousValues) {
+ proxyProperties = merge({ content: item }, changeMeta.previousValues);
+
+ searchItem = SearchProxy.create(proxyProperties);
+ } else {
+ searchItem = item;
+ }
+
+ index = instanceMeta.binarySearch(array, searchItem);
+ array.removeAt(index);
+ return array;
+ }
+ });
+};
+
+})();
+
+
+
+(function() {
+Ember.RSVP = requireModule('rsvp');
+
+Ember.RSVP.onerrorDefault = function(error) {
+ if (error instanceof Error) {
+ if (Ember.testing) {
+ if (Ember.Test && Ember.Test.adapter) {
+ Ember.Test.adapter.exception(error);
+ } else {
+ throw error;
+ }
+ } else {
+ Ember.Logger.error(error.stack);
+ Ember.assert(error, false);
+ }
+ }
+};
+
+Ember.RSVP.on('error', Ember.RSVP.onerrorDefault);
+
+})();
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
/**
Maps all of the items in the enumeration to another value, returning
@@ -11972,6 +19087,7 @@ Ember.Enumerable = Ember.Mixin.create({
The callback method you provide should have the following signature (all
parameters are optional):
+<<<<<<< HEAD
```javascript
function(item, index, enumerable);
```
@@ -12286,6 +19402,325 @@ Ember.Enumerable = Ember.Mixin.create({
@deprecated Use `everyBy` instead
*/
everyProperty: Ember.aliasMethod('everyBy'),
+=======
+(function() {
+/**
+@module ember
+@submodule ember-runtime
+*/
+
+var a_slice = Array.prototype.slice;
+
+
+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
+ `true`, which is the default.
+
+ Computed properties allow you to treat a function like a property:
+
+ ```javascript
+ MyApp.President = Ember.Object.extend({
+ firstName: '',
+ lastName: '',
+
+ fullName: function() {
+ return this.get('firstName') + ' ' + this.get('lastName');
+
+ // Call this flag to mark the function as a property
+ }.property()
+ });
+
+ var president = MyApp.President.create({
+ firstName: "Barack",
+ lastName: "Obama"
+ });
+
+ president.get('fullName'); // "Barack Obama"
+ ```
+
+ 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
+ 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
+ MyApp.President = Ember.Object.extend({
+ firstName: '',
+ lastName: '',
+
+ fullName: function() {
+ return this.get('firstName') + ' ' + this.get('lastName');
+
+ // 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
+ 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
+ @for Function
+ */
+ Function.prototype.property = function() {
+ var ret = Ember.computed(this);
+ // ComputedProperty.prototype.property expands properties; no need for us to
+ // do so here.
+ return ret.property.apply(ret, arguments);
+ };
+
+ /**
+ 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`
+ call to the end of your method declarations in classes that you write.
+ For example:
+
+ ```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
+ synchronous behavior, use `observesImmediately`.
+
+ See `Ember.observer`.
+
+ @method observes
+ @for Function
+ */
+ Function.prototype.observes = function() {
+
+ this.__ember_observes__ = a_slice.call(arguments);
+
+
+ return this;
+ };
+
+ /**
+ 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`
+ call to the end of your method declarations in classes that you write.
+ For example:
+
+ ```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,
+ `observesImmediately` will maintain the synchronous behavior.
+
+ See `Ember.immediateObserver`.
+
+ @method observesImmediately
+ @for Function
+ */
+ Function.prototype.observesImmediately = function() {
+ for (var i=0, l=arguments.length; i b`
+
+ 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
+ */
+ compare: Ember.required(Function)
+
+});
+
+
+})();
+
+
+
+(function() {
+/**
+@module ember
+@submodule ember-runtime
+*/
+
+
+
+var get = Ember.get, set = Ember.set;
+
+/**
+ Implements some standard methods for copying an object. Add this mixin to
+ any object you create that can create a copy of itself. This mixin is
+ added automatically to the built-in array.
+
+ You should generally implement the `copy()` method to return a copy of the
+ receiver.
+
+ Note that `frozenCopy()` will only work if you also implement
+ `Ember.Freezable`.
+
+ @class Copyable
+ @namespace Ember
+ @since Ember 0.9
+*/
+Ember.Copyable = Ember.Mixin.create({
+
+ /**
+ Override to return a copy of the receiver. Default implementation raises
+ an exception.
+
+ @method copy
+ @param {Boolean} deep if `true`, a deep copy of the object should be made
+ @return {Object} copy of receiver
+ */
+ copy: Ember.required(Function),
+
+ /**
+ 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
+ not support freezing.
+
+ 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
+ @return {Object} copy of receiver or receiver
+ */
+ frozenCopy: function() {
+ if (Ember.Freezable && Ember.Freezable.detect(this)) {
+ return get(this, 'isFrozen') ? this : this.copy().freeze();
+ } else {
+ throw new Ember.Error(Ember.String.fmt("%@ does not support freezing", [this]));
+ }
+ }
+});
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
/**
Returns `true` if the passed function returns true for any item in the
@@ -12302,6 +19737,7 @@ Ember.Enumerable = Ember.Mixin.create({
- `index` is the current index in the iteration.
- `enumerable` is the enumerable object itself.
+<<<<<<< HEAD
It should return the `true` to include the item in the results, `false`
otherwise.
@@ -12707,6 +20143,518 @@ Ember.Enumerable = Ember.Mixin.create({
}
});
+=======
+
+var get = Ember.get, set = Ember.set;
+
+/**
+ The `Ember.Freezable` mixin implements some basic methods for marking an
+ object as frozen. Once an object is frozen it should be read only. No changes
+ may be made the internal state of the object.
+
+ ## Enforcement
+
+ To fully support freezing in your subclass, you must include this mixin and
+ override any method that might alter any property on the object to instead
+ raise an exception. You can check the state of an object by checking the
+ `isFrozen` property.
+
+ Although future versions of JavaScript may support language-level freezing
+ object objects, that is not the case today. Even if an object is freezable,
+ it is still technically possible to modify the object, even though it could
+ break other parts of your application that do not expect a frozen object to
+ change. It is, therefore, very important that you always respect the
+ `isFrozen` property on all freezable objects.
+
+ ## Example Usage
+
+ The example below shows a simple object that implement the `Ember.Freezable`
+ protocol.
+
+ ```javascript
+ Contact = Ember.Object.extend(Ember.Freezable, {
+ firstName: null,
+ lastName: null,
+
+ // swaps the names
+ swapNames: function() {
+ if (this.get('isFrozen')) throw Ember.FROZEN_ERROR;
+ var tmp = this.get('firstName');
+ this.set('firstName', this.get('lastName'));
+ this.set('lastName', tmp);
+ return this;
+ }
+
+ });
+
+ c = Contact.create({ firstName: "John", lastName: "Doe" });
+ c.swapNames(); // returns c
+ c.freeze();
+ c.swapNames(); // EXCEPTION
+ ```
+
+ ## Copying
+
+ Usually the `Ember.Freezable` protocol is implemented in cooperation with the
+ `Ember.Copyable` protocol, which defines a `frozenCopy()` method that will
+ return a frozen object, if the object implements this method as well.
+
+ @class Freezable
+ @namespace Ember
+ @since Ember 0.9
+*/
+Ember.Freezable = Ember.Mixin.create({
+
+ /**
+ Set to `true` when the object is frozen. Use this property to detect
+ whether your object is frozen or not.
+
+ @property isFrozen
+ @type Boolean
+ */
+ isFrozen: false,
+
+ /**
+ Freezes the object. Once this method has been called the object should
+ no longer allow any properties to be edited.
+
+ @method freeze
+ @return {Object} receiver
+ */
+ freeze: function() {
+ if (get(this, 'isFrozen')) return this;
+ set(this, 'isFrozen', true);
+ return this;
+ }
+
+});
+
+Ember.FROZEN_ERROR = "Frozen object cannot be modified.";
+
+})();
+
+
+
+(function() {
+/**
+@module ember
+@submodule ember-runtime
+*/
+
+var forEach = Ember.EnumerableUtils.forEach;
+
+/**
+ This mixin defines the API for modifying generic enumerables. These methods
+ can be applied to an object regardless of whether it is ordered or
+ unordered.
+
+ Note that an Enumerable can change even if it does not implement this mixin.
+ For example, a MappedEnumerable cannot be directly modified but if its
+ underlying enumerable changes, it will change also.
+
+ ## Adding Objects
+
+ To add an object to an enumerable, use the `addObject()` method. This
+ method will only add the object to the enumerable if the object is not
+ already present and is of a type supported by the enumerable.
+
+ ```javascript
+ set.addObject(contact);
+ ```
+
+ ## Removing Objects
+
+ To remove an object from an enumerable, use the `removeObject()` method. This
+ will only remove the object if it is present in the enumerable, otherwise
+ this method has no effect.
+
+ ```javascript
+ set.removeObject(contact);
+ ```
+
+ ## Implementing In Your Own Code
+
+ If you are implementing an object and want to support this API, just include
+ this mixin in your class and implement the required methods. In your unit
+ tests, be sure to apply the Ember.MutableEnumerableTests to your object.
+
+ @class MutableEnumerable
+ @namespace Ember
+ @uses Ember.Enumerable
+*/
+Ember.MutableEnumerable = Ember.Mixin.create(Ember.Enumerable, {
+
+ /**
+ __Required.__ You must implement this method to apply this mixin.
+
+ 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,
+ then this method should raise an exception.
+
+ @method addObject
+ @param {Object} object The object to add to the enumerable.
+ @return {Object} the passed object
+ */
+ addObject: Ember.required(Function),
+
+ /**
+ Adds each object in the passed enumerable to the receiver.
+
+ @method addObjects
+ @param {Ember.Enumerable} objects the objects to add.
+ @return {Object} receiver
+ */
+ addObjects: function(objects) {
+ Ember.beginPropertyChanges(this);
+ forEach(objects, function(obj) { this.addObject(obj); }, this);
+ Ember.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
+ 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,
+ then this method should raise an exception.
+
+ @method removeObject
+ @param {Object} object The object to remove from the enumerable.
+ @return {Object} the passed object
+ */
+ removeObject: Ember.required(Function),
+
+
+ /**
+ Removes each object in the passed enumerable from the receiver.
+
+ @method removeObjects
+ @param {Ember.Enumerable} objects the objects to remove
+ @return {Object} receiver
+ */
+ removeObjects: function(objects) {
+ Ember.beginPropertyChanges(this);
+ forEach(objects, function(obj) { this.removeObject(obj); }, this);
+ Ember.endPropertyChanges(this);
+ return this;
+ }
+
+});
+
+})();
+
+
+
+(function() {
+/**
+@module ember
+@submodule ember-runtime
+*/
+// ..........................................................
+// CONSTANTS
+//
+
+var OUT_OF_RANGE_EXCEPTION = "Index out of range" ;
+var EMPTY = [];
+
+// ..........................................................
+// HELPERS
+//
+
+var get = Ember.get, set = Ember.set;
+
+/**
+ This mixin defines the API for modifying array-like objects. These methods
+ can be applied only to a collection that keeps its items in an ordered set.
+
+ Note that an Array can change even if it does not implement this mixin.
+ For example, one might implement a SparseArray that cannot be directly
+ modified, but if its underlying enumerable changes, it will change also.
+
+ @class MutableArray
+ @namespace Ember
+ @uses Ember.Array
+ @uses Ember.MutableEnumerable
+*/
+Ember.MutableArray = Ember.Mixin.create(Ember.Array, Ember.MutableEnumerable, {
+
+ /**
+ __Required.__ You must implement this method to apply this mixin.
+
+ 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
+ @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*
+ */
+ replace: Ember.required(),
+
+ /**
+ Remove all elements from self. This is useful if you
+ want to reuse an existing array without having to recreate it.
+
+ ```javascript
+ var colors = ["red", "green", "blue"];
+ color.length(); // 3
+ colors.clear(); // []
+ colors.length(); // 0
+ ```
+
+ @method clear
+ @return {Ember.Array} An empty Array.
+ */
+ clear: function () {
+ var len = get(this, 'length');
+ if (len === 0) return this;
+ this.replace(0, len, EMPTY);
+ return this;
+ },
+
+ /**
+ This will use the primitive `replace()` method to insert an object at the
+ specified index.
+
+ ```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
+ @param {Number} idx index of insert the object at.
+ @param {Object} object object to insert
+ @return this
+ */
+ insertAt: function(idx, object) {
+ if (idx > get(this, 'length')) throw new Ember.Error(OUT_OF_RANGE_EXCEPTION) ;
+ this.replace(idx, 0, [object]) ;
+ return this ;
+ },
+
+ /**
+ 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
+ length this method will throw an `OUT_OF_RANGE_EXCEPTION`.
+
+ ```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
+ @param {Number} start index, start of range
+ @param {Number} len length of passing range
+ @return {Object} receiver
+ */
+ removeAt: function(start, len) {
+ if ('number' === typeof start) {
+
+ if ((start < 0) || (start >= get(this, 'length'))) {
+ throw new Ember.Error(OUT_OF_RANGE_EXCEPTION);
+ }
+
+ // fast case
+ if (len === undefined) len = 1;
+ this.replace(start, len, EMPTY);
+ }
+
+ return this ;
+ },
+
+ /**
+ Push the object onto the end of the array. Works just like `push()` but it
+ is KVO-compliant.
+
+ ```javascript
+ var colors = ["red", "green"];
+ colors.pushObject("black"); // ["red", "green", "black"]
+ colors.pushObject(["yellow"]); // ["red", "green", ["yellow"]]
+ ```
+
+ @method pushObject
+ @param {*} obj object to push
+ @return The same obj passed as param
+ */
+ pushObject: function(obj) {
+ this.insertAt(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
+ var colors = ["red"];
+ colors.pushObjects(["yellow", "orange"]); // ["red", "yellow", "orange"]
+ ```
+
+ @method pushObjects
+ @param {Ember.Enumerable} objects the objects to add
+ @return {Ember.Array} receiver
+ */
+ pushObjects: function(objects) {
+ if (!(Ember.Enumerable.detect(objects) || Ember.isArray(objects))) {
+ throw new TypeError("Must pass Ember.Enumerable to Ember.MutableArray#pushObjects");
+ }
+ this.replace(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
+ var colors = ["red", "green", "blue"];
+ colors.popObject(); // "blue"
+ console.log(colors); // ["red", "green"]
+ ```
+
+ @method popObject
+ @return object
+ */
+ popObject: function() {
+ var len = get(this, 'length') ;
+ if (len === 0) return null ;
+
+ 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
+ var colors = ["red", "green", "blue"];
+ colors.shiftObject(); // "red"
+ console.log(colors); // ["green", "blue"]
+ ```
+
+ @method shiftObject
+ @return object
+ */
+ shiftObject: function() {
+ if (get(this, 'length') === 0) return null ;
+ var ret = this.objectAt(0) ;
+ this.removeAt(0) ;
+ return ret ;
+ },
+
+ /**
+ Unshift an object to start of array. Works just like `unshift()` but it is
+ KVO-compliant.
+
+ ```javascript
+ var colors = ["red"];
+ colors.unshiftObject("yellow"); // ["yellow", "red"]
+ colors.unshiftObject(["black"]); // [["black"], "yellow", "red"]
+ ```
+
+ @method unshiftObject
+ @param {*} obj object to unshift
+ @return The same obj passed as param
+ */
+ unshiftObject: function(obj) {
+ this.insertAt(0, obj) ;
+ return obj ;
+ },
+
+ /**
+ Adds the named objects to the beginning of the array. Defers notifying
+ observers until all objects have been added.
+
+ ```javascript
+ var colors = ["red"];
+ colors.unshiftObjects(["black", "white"]); // ["black", "white", "red"]
+ colors.unshiftObjects("yellow"); // Type Error: 'undefined' is not a function
+ ```
+
+ @method unshiftObjects
+ @param {Ember.Enumerable} objects the objects to add
+ @return {Ember.Array} receiver
+ */
+ unshiftObjects: function(objects) {
+ this.replace(0, 0, objects);
+ return this;
+ },
+
+ /**
+ Reverse objects in the array. Works just like `reverse()` but it is
+ KVO-compliant.
+
+ @method reverseObjects
+ @return {Ember.Array} receiver
+ */
+ reverseObjects: function() {
+ var len = get(this, 'length');
+ if (len === 0) return this;
+ var objects = this.toArray().reverse();
+ this.replace(0, len, objects);
+ return this;
+ },
+
+ /**
+ Replace all the the receiver's content with content of the argument.
+ If argument is an empty array receiver will be cleared.
+
+ ```javascript
+ var colors = ["red", "green", "blue"];
+ colors.setObjects(["black", "white"]); // ["black", "white"]
+ colors.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) {
+ if (objects.length === 0) return this.clear();
+
+ var len = get(this, 'length');
+ this.replace(0, len, objects);
+ return this;
+ },
+
+ // ..........................................................
+ // IMPLEMENT Ember.MutableEnumerable
+ //
+
+ removeObject: function(obj) {
+ var loc = get(this, 'length') || 0;
+ while(--loc >= 0) {
+ var curObject = this.objectAt(loc) ;
+ if (curObject === obj) this.removeAt(loc) ;
+ }
+ return this ;
+ },
+
+ addObject: function(obj) {
+ if (!this.contains(obj)) this.pushObject(obj);
+ return this ;
+ }
+
+});
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
})();
@@ -12791,10 +20739,39 @@ Ember.Array = Ember.Mixin.create(Ember.Enumerable, /** @scope Ember.Array.protot
@param {Number} idx The index of the item to return.
@return {*} item at index or undefined
*/
+<<<<<<< HEAD
objectAt: function(idx) {
if ((idx < 0) || (idx>=get(this, 'length'))) return undefined ;
return get(this, idx);
},
+=======
+ triggerAction: function(opts) {
+ opts = opts || {};
+ var action = opts.action || get(this, 'action'),
+ target = opts.target || get(this, 'targetObject'),
+ actionContext = opts.actionContext;
+
+ function args(options, actionName) {
+ var ret = [];
+ if (actionName) { ret.push(actionName); }
+
+ return ret.concat(options);
+ }
+
+ if (typeof actionContext === 'undefined') {
+ actionContext = get(this, 'actionContextObject') || this;
+ }
+
+ if (target && action) {
+ var ret;
+
+ if (target.send) {
+ ret = target.send.apply(target, args(actionContext, action));
+ } else {
+ Ember.assert("The action '" + action + "' did not exist on " + target, typeof target[action] === 'function');
+ ret = target[action].apply(target, args(actionContext));
+ }
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
/**
This returns the objects at the specified indexes, using `objectAt`.
@@ -12946,10 +20923,13 @@ Ember.Array = Ember.Mixin.create(Ember.Enumerable, /** @scope Ember.Array.protot
return -1;
},
+<<<<<<< HEAD
// ..........................................................
// ARRAY OBSERVERS
//
+=======
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
/**
Adds an array observer to the receiving array. The array observer object
normally must implement two methods:
@@ -13009,9 +20989,21 @@ Ember.Array = Ember.Mixin.create(Ember.Enumerable, /** @scope Ember.Array.protot
return this;
},
+<<<<<<< HEAD
/**
Becomes true whenever the array currently has observers watching changes
on the array.
+=======
+RSVP.Promise.prototype.fail = function(callback, label){
+ Ember.deprecate('RSVP.Promise.fail has been renamed as RSVP.Promise.catch');
+ return this['catch'](callback, label);
+};
+
+/**
+@module ember
+@submodule ember-runtime
+*/
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
@property Boolean
*/
@@ -13025,6 +21017,7 @@ Ember.Array = Ember.Mixin.create(Ember.Enumerable, /** @scope Ember.Array.protot
invalidate any related properties. Pass the starting index of the change
as well as a delta of the amounts to change.
+<<<<<<< HEAD
@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
@@ -13034,6 +21027,14 @@ Ember.Array = Ember.Mixin.create(Ember.Enumerable, /** @scope Ember.Array.protot
@return {Ember.Array} receiver
*/
arrayContentWillChange: function(startIdx, removeAmt, addAmt) {
+=======
+ @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) {
+ var deferred, promise, entity;
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
// if no args are passed assume everything changes
if (startIdx===undefined) {
@@ -13058,9 +21059,13 @@ Ember.Array = Ember.Mixin.create(Ember.Enumerable, /** @scope Ember.Array.protot
removing = removeAmt;
}
+<<<<<<< HEAD
this.enumerableContentWillChange(removing, addAmt);
return this;
+=======
+ return promise.then(resolve && fulfillmentHandler, reject, label);
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
},
/**
@@ -13125,6 +21130,7 @@ Ember.Array = Ember.Mixin.create(Ember.Enumerable, /** @scope Ember.Array.protot
return an enumerable that maps automatically to the named key on the
member objects.
+<<<<<<< HEAD
If you merely want to watch for any items being added or removed to the array,
use the `[]` property instead of `@each`.
@@ -13180,6 +21186,19 @@ function get(obj, key) {
function DependentArraysObserver(callbacks, cp, instanceMeta, context, propertyName, sugarMeta) {
// user specified callbacks for `addedItem` and `removedItem`
this.callbacks = callbacks;
+=======
+ @method reject
+ */
+ reject: function(value) {
+ get(this, '_deferred').reject(value);
+ },
+
+ _deferred: Ember.computed(function() {
+ return RSVP.defer('Ember: DeferredMixin - ' + this);
+ })
+});
+
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
// the computed property: remember these are shared across instances
this.cp = cp;
@@ -13199,6 +21218,7 @@ function DependentArraysObserver(callbacks, cp, instanceMeta, context, propertyN
// this to lazily recompute indexes for item property observers.
this.trackedArraysByGuid = {};
+<<<<<<< HEAD
// We suspend observers to ignore replacements from `reset` when totally
// recomputing. Unfortunately we cannot properly suspend the observers
// because we only have the key; instead we make the observers no-ops
@@ -14087,6 +22107,932 @@ Ember.arrayComputed = function (options) {
if (typeof options !== "object") {
throw new Ember.Error("Array Computed Property declared without an options hash");
}
+=======
+var get = Ember.get, typeOf = Ember.typeOf;
+
+/**
+ The `Ember.ActionHandler` mixin implements support for moving an `actions`
+ property to an `_actions` property at extend time, and adding `_actions`
+ to the object's mergedProperties list.
+
+ `Ember.ActionHandler` is used internally by Ember in `Ember.View`,
+ `Ember.Controller`, and `Ember.Route`.
+
+ @class ActionHandler
+ @namespace Ember
+*/
+Ember.ActionHandler = Ember.Mixin.create({
+ 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
+ from within a template and the application's current route is this route.
+
+ 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 defined on extended parent classes
+ or mixins rather than just replace the entire hash, e.g.:
+
+ ```js
+ App.CanDisplayBanner = Ember.Mixin.create({
+ actions: {
+ displayBanner: function(msg) {
+ // ...
+ }
+ }
+ });
+
+ App.WelcomeRoute = Ember.Route.extend(App.CanDisplayBanner, {
+ actions: {
+ playMusic: function() {
+ // ...
+ }
+ }
+ });
+
+ // `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,
+ the value of the `this` context is the Controller, Route, View or
+ Component object:
+
+ ```js
+ App.SongRoute = Ember.Route.extend({
+ actions: {
+ myAction: function() {
+ this.controllerFor("song");
+ this.transitionTo("other.route");
+ ...
+ }
+ }
+ });
+ ```
+
+ It is also possible to call `this._super()` from within an
+ action handler if it overrides a handler defined on a parent
+ class or mixin:
+
+ Take for example the following routes:
+
+ ```js
+ App.DebugRoute = Ember.Mixin.create({
+ actions: {
+ debugRouteInformation: function() {
+ console.debug("trololo");
+ }
+ }
+ });
+
+ App.AnnoyingDebugRoute = Ember.Route.extend(App.DebugRoute, {
+ actions: {
+ debugRouteInformation: function() {
+ // also call the debugRouteInformation of mixed in App.DebugRoute
+ this._super();
+
+ // show additional annoyance
+ window.alert(...);
+ }
+ }
+ });
+ ```
+
+ ## 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
+ App.Router.map(function() {
+ this.resource("album", function() {
+ this.route("song");
+ });
+ });
+
+ App.AlbumRoute = Ember.Route.extend({
+ actions: {
+ startPlaying: function() {
+ }
+ }
+ });
+
+ App.AlbumSongRoute = Ember.Route.extend({
+ actions: {
+ startPlaying: function() {
+ // ...
+
+ if (actionShouldAlsoBeTriggeredOnParentRoute) {
+ return true;
+ }
+ }
+ }
+ });
+ ```
+
+ @property actions
+ @type Hash
+ @default null
+ */
+
+ /**
+ 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
+ @method willMergeMixin
+ */
+ willMergeMixin: function(props) {
+ var hashName;
+
+ if (!props._actions) {
+ if (typeOf(props.actions) === 'object') {
+ hashName = 'actions';
+ } else if (typeOf(props.events) === 'object') {
+ Ember.deprecate('Action handlers contained in an `events` object are deprecated in favor of putting them in an `actions` object', false);
+ hashName = 'events';
+ }
+
+ if (hashName) {
+ props._actions = Ember.merge(props._actions || {}, props[hashName]);
+ }
+
+ delete props[hashName];
+ }
+ },
+
+ send: function(actionName) {
+ var args = [].slice.call(arguments, 1), target;
+
+ if (this._actions && this._actions[actionName]) {
+ if (this._actions[actionName].apply(this, args) === true) {
+ // handler returned true, so this action will bubble
+ } else {
+ return;
+ }
+ } else if (this.deprecatedSend && this.deprecatedSendHandles && this.deprecatedSendHandles(actionName)) {
+ if (this.deprecatedSend.apply(this, [].slice.call(arguments)) === true) {
+ // handler return true, so this action will bubble
+ } else {
+ return;
+ }
+ }
+
+ if (target = 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);
+ }
+ }
+
+});
+
+})();
+
+
+
+(function() {
+var set = Ember.set, get = Ember.get,
+ resolve = Ember.RSVP.resolve,
+ rethrow = Ember.RSVP.rethrow,
+ not = Ember.computed.not,
+ or = Ember.computed.or;
+
+/**
+ @module ember
+ @submodule ember-runtime
+ */
+
+function observePromise(proxy, promise) {
+ promise.then(function(value) {
+ set(proxy, 'isFulfilled', true);
+ set(proxy, 'content', value);
+ }, function(reason) {
+ set(proxy, 'isRejected', true);
+ set(proxy, 'reason', reason);
+ // don't re-throw, as we are merely observing
+ }, "Ember: PromiseProxy");
+}
+
+/**
+ A low level mixin making ObjectProxy, ObjectController or ArrayController's promise aware.
+
+ ```javascript
+ var ObjectPromiseController = Ember.ObjectController.extend(Ember.PromiseProxyMixin);
+
+ var controller = ObjectPromiseController.create({
+ promise: $.getJSON('/some/remote/data.json')
+ });
+
+ controller.then(function(json){
+ // the json
+ }, function(reason) {
+ // the reason why you have no json
+ });
+ ```
+
+ the controller has bindable attributes which
+ track the promises life cycle
+
+ ```javascript
+ controller.get('isPending') //=> true
+ controller.get('isSettled') //=> false
+ controller.get('isRejected') //=> false
+ controller.get('isFulfilled') //=> false
+ ```
+
+ When the the $.getJSON completes, and the promise is fulfilled
+ with json, the life cycle attributes will update accordingly.
+
+ ```javascript
+ controller.get('isPending') //=> false
+ controller.get('isSettled') //=> true
+ controller.get('isRejected') //=> false
+ controller.get('isFulfilled') //=> true
+ ```
+
+ As the controller is an ObjectController, and the json now its content,
+ all the json properties will be available directly from the controller.
+
+ ```javascript
+ // Assuming the following json:
+ {
+ firstName: 'Stefan',
+ lastName: 'Penner'
+ }
+
+ // both properties will accessible on the controller
+ controller.get('firstName') //=> 'Stefan'
+ controller.get('lastName') //=> 'Penner'
+ ```
+
+ If the controller is backing a template, the attributes are
+ bindable from within that template
+
+ ```handlebars
+ {{#if isPending}}
+ loading...
+ {{else}}
+ firstName: {{firstName}}
+ lastName: {{lastName}}
+ {{/if}}
+ ```
+ @class Ember.PromiseProxyMixin
+*/
+Ember.PromiseProxyMixin = Ember.Mixin.create({
+ /**
+ If the proxied promise is rejected this will contain the reason
+ provided.
+
+ @property reason
+ @default null
+ */
+ reason: null,
+
+ /**
+ Once the proxied promise has settled this will become `false`.
+
+ @property isPending
+ @default true
+ */
+ isPending: not('isSettled').readOnly(),
+
+ /**
+ Once the proxied promise has settled this will become `true`.
+
+ @property isSettled
+ @default false
+ */
+ isSettled: or('isRejected', 'isFulfilled').readOnly(),
+
+ /**
+ Will become `true` if the proxied promise is rejected.
+
+ @property isRejected
+ @default false
+ */
+ isRejected: false,
+
+ /**
+ Will become `true` if the proxied promise is fulfilled.
+
+ @property isFullfilled
+ @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
+ changed once created.
+
+ Example:
+
+ ```javascript
+ Ember.ObjectController.extend(Ember.PromiseProxyMixin).create({
+ promise:
+ });
+ ```
+
+ @property promise
+ */
+ promise: Ember.computed(function(key, promise) {
+ if (arguments.length === 2) {
+ promise = resolve(promise);
+ observePromise(this, promise);
+ return promise.then(); // fork the promise.
+ } else {
+ throw new Ember.Error("PromiseProxy's promise must be set");
+ }
+ }),
+
+ /**
+ An alias to the proxied promise's `then`.
+
+ See RSVP.Promise.then.
+
+ @method then
+ @param {Function} callback
+ @return {RSVP.Promise}
+ */
+ then: promiseAlias('then'),
+
+ /**
+ An alias to the proxied promise's `catch`.
+
+ See RSVP.Promise.catch.
+
+ @method catch
+ @param {Function} callback
+ @return {RSVP.Promise}
+ */
+ 'catch': promiseAlias('catch'),
+
+ /**
+ An alias to the proxied promise's `finally`.
+
+ See RSVP.Promise.finally.
+
+ @method finally
+ @param {Function} callback
+ @return {RSVP.Promise}
+ */
+ 'finally': promiseAlias('finally')
+
+});
+
+function promiseAlias(name) {
+ return function () {
+ var promise = get(this, 'promise');
+ return promise[name].apply(promise, arguments);
+ };
+}
+
+})();
+
+
+
+(function() {
+
+})();
+
+
+
+(function() {
+var get = Ember.get,
+ forEach = Ember.EnumerableUtils.forEach,
+ RETAIN = 'r',
+ INSERT = 'i',
+ DELETE = 'd';
+
+/**
+ An `Ember.TrackedArray` tracks array operations. It's useful when you want to
+ lazily compute the indexes of items in an array after they've been shifted by
+ subsequent operations.
+
+ @class TrackedArray
+ @namespace Ember
+ @param {array} [items=[]] The array to be tracked. This is used just to get
+ the initial items for the starting state of retain:n.
+*/
+Ember.TrackedArray = function (items) {
+ if (arguments.length < 1) { items = []; }
+
+ var length = get(items, 'length');
+
+ if (length) {
+ this._operations = [new ArrayOperation(RETAIN, length, items)];
+ } else {
+ this._operations = [];
+ }
+};
+
+Ember.TrackedArray.RETAIN = RETAIN;
+Ember.TrackedArray.INSERT = INSERT;
+Ember.TrackedArray.DELETE = DELETE;
+
+Ember.TrackedArray.prototype = {
+
+ /**
+ Track that `newItems` were added to the tracked array at `index`.
+
+ @method addItems
+ @param index
+ @param newItems
+ */
+ addItems: function (index, newItems) {
+ var count = get(newItems, 'length');
+ if (count < 1) { return; }
+
+ var match = this._findArrayOperation(index),
+ arrayOperation = match.operation,
+ arrayOperationIndex = match.index,
+ arrayOperationRangeStart = match.rangeStart,
+ composeIndex,
+ splitIndex,
+ splitItems,
+ splitArrayOperation,
+ newArrayOperation;
+
+ newArrayOperation = new ArrayOperation(INSERT, count, newItems);
+
+ if (arrayOperation) {
+ if (!match.split) {
+ // insert left of arrayOperation
+ this._operations.splice(arrayOperationIndex, 0, newArrayOperation);
+ composeIndex = arrayOperationIndex;
+ } else {
+ this._split(arrayOperationIndex, index - arrayOperationRangeStart, newArrayOperation);
+ composeIndex = arrayOperationIndex + 1;
+ }
+ } else {
+ // insert at end
+ this._operations.push(newArrayOperation);
+ composeIndex = arrayOperationIndex;
+ }
+
+ this._composeInsert(composeIndex);
+ },
+
+ /**
+ Track that `count` items were removed at `index`.
+
+ @method removeItems
+ @param index
+ @param count
+ */
+ removeItems: function (index, count) {
+ if (count < 1) { return; }
+
+ var match = this._findArrayOperation(index),
+ arrayOperation = match.operation,
+ arrayOperationIndex = match.index,
+ arrayOperationRangeStart = match.rangeStart,
+ newArrayOperation,
+ composeIndex;
+
+ newArrayOperation = new ArrayOperation(DELETE, count);
+ if (!match.split) {
+ // insert left of arrayOperation
+ this._operations.splice(arrayOperationIndex, 0, newArrayOperation);
+ composeIndex = arrayOperationIndex;
+ } else {
+ this._split(arrayOperationIndex, index - arrayOperationRangeStart, newArrayOperation);
+ composeIndex = arrayOperationIndex + 1;
+ }
+
+ return this._composeDelete(composeIndex);
+ },
+
+ /**
+ Apply all operations, reducing them to retain:n, for `n`, the number of
+ items in the array.
+
+ `callback` will be called for each operation and will be passed the following arguments:
+
+ * {array} items The items for the given operation
+ * {number} offset The computed offset of the items, ie the index in the
+ array of the first item for this operation.
+ * {string} operation The type of the operation. One of
+ `Ember.TrackedArray.{RETAIN, DELETE, INSERT}`
+
+ @method apply
+ @param {function} callback
+ */
+ apply: function (callback) {
+ var items = [],
+ offset = 0;
+
+ forEach(this._operations, function (arrayOperation) {
+ callback(arrayOperation.items, offset, arrayOperation.type);
+
+ if (arrayOperation.type !== DELETE) {
+ offset += arrayOperation.count;
+ items = items.concat(arrayOperation.items);
+ }
+ });
+
+ this._operations = [new ArrayOperation(RETAIN, items.length, items)];
+ },
+
+ /**
+ Return an `ArrayOperationMatch` for the operation that contains the item at `index`.
+
+ @method _findArrayOperation
+
+ @param {number} index the index of the item whose operation information
+ should be returned.
+ @private
+ */
+ _findArrayOperation: function (index) {
+ var arrayOperationIndex,
+ len,
+ split = false,
+ arrayOperation,
+ arrayOperationRangeStart,
+ arrayOperationRangeEnd;
+
+ // OPTIMIZE: we could search these faster if we kept a balanced tree.
+ // find leftmost arrayOperation to the right of `index`
+ for (arrayOperationIndex = arrayOperationRangeStart = 0, len = this._operations.length; arrayOperationIndex < len; ++arrayOperationIndex) {
+ arrayOperation = this._operations[arrayOperationIndex];
+
+ if (arrayOperation.type === DELETE) { continue; }
+
+ arrayOperationRangeEnd = arrayOperationRangeStart + arrayOperation.count - 1;
+
+ if (index === arrayOperationRangeStart) {
+ break;
+ } else if (index > arrayOperationRangeStart && index <= arrayOperationRangeEnd) {
+ split = true;
+ break;
+ } else {
+ arrayOperationRangeStart = arrayOperationRangeEnd + 1;
+ }
+ }
+
+ return new ArrayOperationMatch(arrayOperation, arrayOperationIndex, split, arrayOperationRangeStart);
+ },
+
+ _split: function (arrayOperationIndex, splitIndex, newArrayOperation) {
+ var arrayOperation = this._operations[arrayOperationIndex],
+ splitItems = arrayOperation.items.slice(splitIndex),
+ splitArrayOperation = new ArrayOperation(arrayOperation.type, splitItems.length, splitItems);
+
+ // truncate LHS
+ arrayOperation.count = splitIndex;
+ arrayOperation.items = arrayOperation.items.slice(0, splitIndex);
+
+ this._operations.splice(arrayOperationIndex + 1, 0, newArrayOperation, splitArrayOperation);
+ },
+
+ // see SubArray for a better implementation.
+ _composeInsert: function (index) {
+ var newArrayOperation = this._operations[index],
+ leftArrayOperation = this._operations[index-1], // may be undefined
+ rightArrayOperation = this._operations[index+1], // may be undefined
+ leftOp = leftArrayOperation && leftArrayOperation.type,
+ rightOp = rightArrayOperation && rightArrayOperation.type;
+
+ if (leftOp === INSERT) {
+ // merge left
+ leftArrayOperation.count += newArrayOperation.count;
+ leftArrayOperation.items = leftArrayOperation.items.concat(newArrayOperation.items);
+
+ if (rightOp === INSERT) {
+ // also merge right (we have split an insert with an insert)
+ leftArrayOperation.count += rightArrayOperation.count;
+ leftArrayOperation.items = leftArrayOperation.items.concat(rightArrayOperation.items);
+ this._operations.splice(index, 2);
+ } else {
+ // only merge left
+ this._operations.splice(index, 1);
+ }
+ } else if (rightOp === INSERT) {
+ // merge right
+ newArrayOperation.count += rightArrayOperation.count;
+ newArrayOperation.items = newArrayOperation.items.concat(rightArrayOperation.items);
+ this._operations.splice(index + 1, 1);
+ }
+ },
+
+ _composeDelete: function (index) {
+ var arrayOperation = this._operations[index],
+ deletesToGo = arrayOperation.count,
+ leftArrayOperation = this._operations[index-1], // may be undefined
+ leftOp = leftArrayOperation && leftArrayOperation.type,
+ nextArrayOperation,
+ nextOp,
+ nextCount,
+ removeNewAndNextOp = false,
+ removedItems = [];
+
+ if (leftOp === DELETE) {
+ arrayOperation = leftArrayOperation;
+ index -= 1;
+ }
+
+ for (var i = index + 1; deletesToGo > 0; ++i) {
+ nextArrayOperation = this._operations[i];
+ nextOp = nextArrayOperation.type;
+ nextCount = nextArrayOperation.count;
+
+ if (nextOp === DELETE) {
+ arrayOperation.count += nextCount;
+ continue;
+ }
+
+ if (nextCount > deletesToGo) {
+ // d:2 {r,i}:5 we reduce the retain or insert, but it stays
+ removedItems = removedItems.concat(nextArrayOperation.items.splice(0, deletesToGo));
+ nextArrayOperation.count -= deletesToGo;
+
+ // In the case where we truncate the last arrayOperation, we don't need to
+ // remove it; also the deletesToGo reduction is not the entirety of
+ // nextCount
+ i -= 1;
+ nextCount = deletesToGo;
+
+ deletesToGo = 0;
+ } else {
+ if (nextCount === deletesToGo) {
+ // Handle edge case of d:2 i:2 in which case both operations go away
+ // during composition.
+ removeNewAndNextOp = true;
+ }
+ removedItems = removedItems.concat(nextArrayOperation.items);
+ deletesToGo -= nextCount;
+ }
+
+ if (nextOp === INSERT) {
+ // d:2 i:3 will result in delete going away
+ arrayOperation.count -= nextCount;
+ }
+ }
+
+ if (arrayOperation.count > 0) {
+ // compose our new delete with possibly several operations to the right of
+ // disparate types
+ this._operations.splice(index+1, i-1-index);
+ } else {
+ // The delete operation can go away; it has merely reduced some other
+ // operation, as in d:3 i:4; it may also have eliminated that operation,
+ // as in d:3 i:3.
+ this._operations.splice(index, removeNewAndNextOp ? 2 : 1);
+ }
+
+ return removedItems;
+ },
+
+ toString: function () {
+ var str = "";
+ forEach(this._operations, function (operation) {
+ str += " " + operation.type + ":" + operation.count;
+ });
+ return str.substring(1);
+ }
+};
+
+/**
+ Internal data structure to represent an array operation.
+
+ @method ArrayOperation
+ @private
+ @param {string} type The type of the operation. One of
+ `Ember.TrackedArray.{RETAIN, INSERT, DELETE}`
+ @param {number} count The number of items in this operation.
+ @param {array} items The items of the operation, if included. RETAIN and
+ INSERT include their items, DELETE does not.
+*/
+function ArrayOperation (operation, count, items) {
+ this.type = operation; // RETAIN | INSERT | DELETE
+ this.count = count;
+ this.items = items;
+}
+
+/**
+ Internal data structure used to include information when looking up operations
+ by item index.
+
+ @method ArrayOperationMatch
+ @private
+ @param {ArrayOperation} operation
+ @param {number} index The index of `operation` in the array of operations.
+ @param {boolean} split Whether or not the item index searched for would
+ require a split for a new operation type.
+ @param {number} rangeStart The index of the first item in the operation,
+ with respect to the tracked array. The index of the last item can be computed
+ from `rangeStart` and `operation.count`.
+*/
+function ArrayOperationMatch(operation, index, split, rangeStart) {
+ this.operation = operation;
+ this.index = index;
+ this.split = split;
+ this.rangeStart = rangeStart;
+}
+
+})();
+
+
+
+(function() {
+var get = Ember.get,
+ forEach = Ember.EnumerableUtils.forEach,
+ RETAIN = 'r',
+ FILTER = 'f';
+
+function Operation (type, count) {
+ this.type = type;
+ this.count = count;
+}
+
+/**
+ An `Ember.SubArray` tracks an array in a way similar to, but more specialized
+ than, `Ember.TrackedArray`. It is useful for keeping track of the indexes of
+ items within a filtered array.
+
+ @class SubArray
+ @namespace Ember
+*/
+Ember.SubArray = function (length) {
+ if (arguments.length < 1) { length = 0; }
+
+ if (length > 0) {
+ this._operations = [new Operation(RETAIN, length)];
+ } else {
+ this._operations = [];
+ }
+};
+
+Ember.SubArray.prototype = {
+ /**
+ Track that an item was added to the tracked array.
+
+ @method addItem
+
+ @param {number} index The index of the item in the tracked array.
+ @param {boolean} match `true` iff the item is included in the subarray.
+
+ @return {number} The index of the item in the subarray.
+ */
+ addItem: function(index, match) {
+ var returnValue = -1,
+ itemType = match ? RETAIN : FILTER,
+ self = this;
+
+ this._findOperation(index, function(operation, operationIndex, rangeStart, rangeEnd, seenInSubArray) {
+ var newOperation, splitOperation;
+
+ if (itemType === operation.type) {
+ ++operation.count;
+ } else if (index === rangeStart) {
+ // insert to the left of `operation`
+ self._operations.splice(operationIndex, 0, new Operation(itemType, 1));
+ } else {
+ newOperation = new Operation(itemType, 1);
+ splitOperation = new Operation(operation.type, rangeEnd - index + 1);
+ operation.count = index - rangeStart;
+
+ self._operations.splice(operationIndex + 1, 0, newOperation, splitOperation);
+ }
+
+ if (match) {
+ if (operation.type === RETAIN) {
+ returnValue = seenInSubArray + (index - rangeStart);
+ } else {
+ returnValue = seenInSubArray;
+ }
+ }
+
+ self._composeAt(operationIndex);
+ }, function(seenInSubArray) {
+ self._operations.push(new Operation(itemType, 1));
+
+ if (match) {
+ returnValue = seenInSubArray;
+ }
+
+ self._composeAt(self._operations.length-1);
+ });
+
+ return returnValue;
+ },
+
+ /**
+ Track that an item was removed from the tracked array.
+
+ @method removeItem
+
+ @param {number} index The index of the item in the tracked array.
+
+ @return {number} The index of the item in the subarray, or `-1` if the item
+ was not in the subarray.
+ */
+ removeItem: function(index) {
+ var returnValue = -1,
+ self = this;
+
+ this._findOperation(index, function (operation, operationIndex, rangeStart, rangeEnd, seenInSubArray) {
+ if (operation.type === RETAIN) {
+ returnValue = seenInSubArray + (index - rangeStart);
+ }
+
+ if (operation.count > 1) {
+ --operation.count;
+ } else {
+ self._operations.splice(operationIndex, 1);
+ self._composeAt(operationIndex);
+ }
+ }, function() {
+ throw new Ember.Error("Can't remove an item that has never been added.");
+ });
+
+ return returnValue;
+ },
+
+
+ _findOperation: function (index, foundCallback, notFoundCallback) {
+ var operationIndex,
+ len,
+ operation,
+ rangeStart,
+ rangeEnd,
+ seenInSubArray = 0;
+
+ // OPTIMIZE: change to balanced tree
+ // find leftmost operation to the right of `index`
+ for (operationIndex = rangeStart = 0, len = this._operations.length; operationIndex < len; rangeStart = rangeEnd + 1, ++operationIndex) {
+ operation = this._operations[operationIndex];
+ rangeEnd = rangeStart + operation.count - 1;
+
+ if (index >= rangeStart && index <= rangeEnd) {
+ foundCallback(operation, operationIndex, rangeStart, rangeEnd, seenInSubArray);
+ return;
+ } else if (operation.type === RETAIN) {
+ seenInSubArray += operation.count;
+ }
+ }
+
+ notFoundCallback(seenInSubArray);
+ },
+
+ _composeAt: function(index) {
+ var op = this._operations[index],
+ otherOp;
+
+ if (!op) {
+ // Composing out of bounds is a no-op, as when removing the last operation
+ // in the list.
+ return;
+ }
+
+ if (index > 0) {
+ otherOp = this._operations[index-1];
+ if (otherOp.type === op.type) {
+ op.count += otherOp.count;
+ this._operations.splice(index-1, 1);
+ --index;
+ }
+ }
+
+ if (index < this._operations.length-1) {
+ otherOp = this._operations[index+1];
+ if (otherOp.type === op.type) {
+ op.count += otherOp.count;
+ this._operations.splice(index+1, 1);
+ }
+ }
+ },
+
+ toString: function () {
+ var str = "";
+ forEach(this._operations, function (operation) {
+ str += " " + operation.type + ":" + operation.count;
+ });
+ return str.substring(1);
+ }
+};
+
+})();
+
+
+
+(function() {
+Ember.Container = requireModule('container');
+Ember.Container.set = Ember.set;
+
+})();
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
var cp = new ArrayComputedProperty(options);
@@ -14184,9 +23130,17 @@ Ember.computed.max = function (dependentKey) {
@param {String} dependentKey
@return {Ember.ComputedProperty} computes the smallest value in the dependentKey's array
*/
+<<<<<<< HEAD
Ember.computed.min = function (dependentKey) {
return Ember.reduceComputed.call(null, dependentKey, {
initialValue: Infinity,
+=======
+Ember.ArrayProxy = Ember.Object.extend(Ember.MutableArray, {
+
+ /**
+ The content array. Must be an object that implements `Ember.Array` and/or
+ `Ember.MutableArray.`
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
addedItem: function (accumulatedValue, item, changeMeta, instanceMeta) {
return Math.min(accumulatedValue, item);
@@ -14224,6 +23178,7 @@ Ember.computed.min = function (dependentKey) {
hamster.get('excitingChores'); // ['COOK!', 'CLEAN!', 'WRITE MORE UNIT TESTS!']
```
+<<<<<<< HEAD
@method computed.map
@for Ember
@param {String} dependentKey
@@ -14248,6 +23203,18 @@ Ember.computed.map = function(dependentKey, callback) {
/**
Returns an array mapped to the specified key.
+=======
+ /**
+ Invoked when the content property is about to change. Notifies observers that the
+ entire array content will change.
+
+ @private
+ @method _contentWillChange
+ */
+ _contentWillChange: Ember.beforeObserver('content', function() {
+ this._teardownContent();
+ }),
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
Example
@@ -14264,6 +23231,7 @@ Ember.computed.map = function(dependentKey, callback) {
lordByron.get('childAges'); // [7, 5, 8]
```
+<<<<<<< HEAD
@method computed.mapBy
@for Ember
@param {String} dependentKey
@@ -14286,23 +23254,45 @@ Ember.computed.mapProperty = Ember.computed.mapBy;
/**
Filters the array by the callback.
+=======
+ /**
+ Invoked when the content property changes. Notifies observers that the
+ entire array content has changed.
+
+ @private
+ @method _contentDidChange
+ */
+ _contentDidChange: Ember.observer('content', function() {
+ var content = get(this, 'content');
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
The callback method you provide should have the following signature:
+<<<<<<< HEAD
```javascript
function(item);
```
+=======
+ this._setupContent();
+ }),
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
- `item` is the current item in the iteration.
Example
+<<<<<<< HEAD
```javascript
App.Hamster = Ember.Object.extend({
remainingChores: Ember.computed.filter('chores', function(chore) {
return !chore.done;
})
});
+=======
+ _arrangedContentWillChange: Ember.beforeObserver('arrangedContent', function() {
+ var arrangedContent = get(this, 'arrangedContent'),
+ len = arrangedContent ? get(arrangedContent, 'length') : 0;
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
var hamster = App.Hamster.create({chores: [
{name: 'cook', done: true},
@@ -14312,6 +23302,7 @@ Ember.computed.mapProperty = Ember.computed.mapBy;
hamster.get('remainingChores'); // [{name: 'write more unit tests', done: false}]
```
+<<<<<<< HEAD
@method computed.filter
@for Ember
@param {String} dependentKey
@@ -14327,6 +23318,14 @@ Ember.computed.filter = function(dependentKey, callback) {
addedItem: function(array, item, changeMeta, instanceMeta) {
var match = !!callback.call(this, item),
filterIndex = instanceMeta.filteredArrayIndexes.addItem(changeMeta.index, match);
+=======
+ this._teardownArrangedContent(arrangedContent);
+ }),
+
+ _arrangedContentDidChange: Ember.observer('arrangedContent', function() {
+ var arrangedContent = get(this, 'arrangedContent'),
+ len = arrangedContent ? get(arrangedContent, 'length') : 0;
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
if (match) {
array.insertAt(filterIndex, item);
@@ -14335,8 +23334,14 @@ Ember.computed.filter = function(dependentKey, callback) {
return array;
},
+<<<<<<< HEAD
removedItem: function(array, item, changeMeta, instanceMeta) {
var filterIndex = instanceMeta.filteredArrayIndexes.removeItem(changeMeta.index);
+=======
+ this.arrangedContentDidChange(this);
+ this.arrangedContentArrayDidChange(this, 0, undefined, len);
+ }),
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
if (filterIndex > -1) {
array.removeAt(filterIndex);
@@ -14387,8 +23392,16 @@ Ember.computed.filterBy = function(dependentKey, propertyKey, value) {
};
}
+<<<<<<< HEAD
return Ember.computed.filter(dependentKey + '.@each.' + propertyKey, callback);
};
+=======
+ _insertAt: function(idx, object) {
+ if (idx > get(this, 'content.length')) throw new Ember.Error(OUT_OF_RANGE_EXCEPTION);
+ this._replace(idx, 0, [object]);
+ return this;
+ },
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
/**
@method computed.filterProperty
@@ -14404,7 +23417,13 @@ Ember.computed.filterProperty = Ember.computed.filterBy;
A computed property which returns a new array with all the unique
elements from one or more dependent arrays.
+<<<<<<< HEAD
Example
+=======
+ if ((start < 0) || (start >= get(this, 'length'))) {
+ throw new Ember.Error(OUT_OF_RANGE_EXCEPTION);
+ }
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
```javascript
App.Hamster = Ember.Object.extend({
@@ -14627,6 +23646,7 @@ function binarySearch(array, item, low, high) {
return mid;
}
+<<<<<<< HEAD
res = this.order(midItem, item);
if (res === 0) {
res = guidMid < guidItem ? -1 : 1;
@@ -14792,6 +23812,21 @@ Ember.computed.sort = function (itemsKey, sortDefinition) {
if (changeMeta.previousValues) {
proxyProperties = merge({ content: item }, changeMeta.previousValues);
+=======
+
+var set = Ember.set, get = Ember.get, guidFor = Ember.guidFor;
+var forEach = Ember.EnumerableUtils.forEach,
+ indexOf = Ember.ArrayPolyfills.indexOf;
+
+var EachArray = Ember.Object.extend(Ember.Array, {
+
+ init: function(content, keyName, owner) {
+ this._super();
+ this._keyName = keyName;
+ this._owner = owner;
+ this._content = content;
+ },
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
searchItem = SearchProxy.create(proxyProperties);
} else {
@@ -14824,6 +23859,15 @@ Ember.RSVP = requireModule('rsvp');
})();
+<<<<<<< HEAD
+=======
+ guid = guidFor(item);
+ indicies = objects[guid];
+ indicies[indexOf.call(indicies, loc)] = null;
+ }
+ }
+}
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
(function() {
/**
@@ -14964,10 +24008,21 @@ if (Ember.EXTEND_PROTOTYPES === true || Ember.EXTEND_PROTOTYPES.Function) {
return this.observes.apply(this, arguments);
};
+<<<<<<< HEAD
/**
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.
+=======
+(function() {
+/**
+@module ember
+@submodule ember-runtime
+*/
+
+
+var get = Ember.get, set = Ember.set, replace = Ember.EnumerableUtils._replace;
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
You can get notified when a property change is about to happen by
by adding the `observesBefore` call to the end of your method
@@ -14991,14 +24046,19 @@ if (Ember.EXTEND_PROTOTYPES === true || Ember.EXTEND_PROTOTYPES.Function) {
return this;
};
+<<<<<<< HEAD
/**
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.
+=======
+ if (this.isFrozen) throw Ember.FROZEN_ERROR;
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
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:
+<<<<<<< HEAD
```javascript
Ember.Mixin.create({
doSomethingWithElement: function() {
@@ -15008,6 +24068,17 @@ if (Ember.EXTEND_PROTOTYPES === true || Ember.EXTEND_PROTOTYPES.Function) {
```
See `Ember.on`.
+=======
+ if (len === 0) {
+ this.splice(idx, amt);
+ } else {
+ replace(this, idx, amt, objects);
+ }
+
+ this.arrayContentDidChange(idx, amt, len);
+ return this;
+ },
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
@method on
@for Function
@@ -15047,15 +24118,58 @@ if (Ember.EXTEND_PROTOTYPES === true || Ember.EXTEND_PROTOTYPES.Function) {
@namespace Ember
@since Ember 0.9
*/
+<<<<<<< HEAD
Ember.Comparable = Ember.Mixin.create( /** @scope Ember.Comparable.prototype */{
+=======
+Ember.NativeArray = NativeArray;
+
+/**
+ Creates an `Ember.NativeArray` from an Array like object.
+ Does not modify the original object. Ember.A is not needed if
+ `Ember.EXTEND_PROTOTYPES` is `true` (the default value). However,
+ it is recommended that you use Ember.A when creating addons for
+ ember or when you can not guarantee that `Ember.EXTEND_PROTOTYPES`
+ will be `true`.
+
+ Example
+
+ ```js
+ var Pagination = Ember.CollectionView.extend({
+ tagName: 'ul',
+ classNames: ['pagination'],
+ init: function() {
+ this._super();
+ if (!this.get('content')) {
+ this.set('content', Ember.A([]));
+ }
+ }
+ });
+ ```
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
/**
Override to return the result of the comparison of the two parameters. The
compare method should return:
+<<<<<<< HEAD
- `-1` if `a < b`
- `0` if `a == b`
- `1` if `a > b`
+=======
+/**
+ Activates the mixin on the Array.prototype if not already applied. Calling
+ this method more than once is safe. This will be called when ember is loaded
+ unless you have `Ember.EXTEND_PROTOTYPES` or `Ember.EXTEND_PROTOTYPES.Array`
+ set to `false`.
+
+ Example
+
+ ```js
+ if (Ember.EXTEND_PROTOTYPES === true || Ember.EXTEND_PROTOTYPES.Array) {
+ Ember.NativeArray.activate();
+ }
+ ```
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
Default implementation raises an exception.
@@ -15153,10 +24267,18 @@ var get = Ember.get, set = Ember.set;
## Enforcement
+<<<<<<< HEAD
To fully support freezing in your subclass, you must include this mixin and
override any method that might alter any property on the object to instead
raise an exception. You can check the state of an object by checking the
`isFrozen` property.
+=======
+ When using `Ember.Set`, you can observe the `"[]"` property to be
+ alerted whenever the content changes. You can also add an enumerable
+ observer to the set to be notified of specific objects that are added and
+ removed from the set. See [Ember.Enumerable](/api/classes/Ember.Enumerable.html)
+ for more information on enumerables.
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
Although future versions of JavaScript may support language-level freezing
object objects, that is not the case today. Even if an object is freezable,
@@ -15202,7 +24324,16 @@ var get = Ember.get, set = Ember.set;
@namespace Ember
@since Ember 0.9
*/
+<<<<<<< HEAD
Ember.Freezable = Ember.Mixin.create(/** @scope Ember.Freezable.prototype */ {
+=======
+Ember.Set = Ember.CoreObject.extend(Ember.MutableEnumerable, Ember.Copyable, Ember.Freezable,
+ {
+
+ // ..........................................................
+ // IMPLEMENT ENUMERABLE APIS
+ //
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
/**
Set to `true` when the object is frozen. Use this property to detect
@@ -15220,11 +24351,16 @@ Ember.Freezable = Ember.Mixin.create(/** @scope Ember.Freezable.prototype */ {
@method freeze
@return {Object} receiver
*/
+<<<<<<< HEAD
freeze: function() {
if (get(this, 'isFrozen')) return this;
set(this, 'isFrozen', true);
return this;
}
+=======
+ clear: function() {
+ if (this.isFrozen) { throw new Ember.Error(Ember.FROZEN_ERROR); }
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
});
@@ -15306,11 +24442,19 @@ Ember.MutableEnumerable = Ember.Mixin.create(Ember.Enumerable, {
@param {Ember.Enumerable} objects the objects to add.
@return {Object} receiver
*/
+<<<<<<< HEAD
addObjects: function(objects) {
Ember.beginPropertyChanges(this);
forEach(objects, function(obj) { this.addObject(obj); }, this);
Ember.endPropertyChanges(this);
return this;
+=======
+ pop: function() {
+ if (get(this, 'isFrozen')) throw new Ember.Error(Ember.FROZEN_ERROR);
+ var obj = this.length > 0 ? this[this.length-1] : null;
+ this.remove(obj);
+ return obj;
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
},
/**
@@ -15486,6 +24630,7 @@ Ember.MutableArray = Ember.Mixin.create(Ember.Array, Ember.MutableEnumerable,/**
colors.pushObject(["yellow", "orange"]); // ["red", "green", "blue", "black", ["yellow", "orange"]]
```
+<<<<<<< HEAD
@method pushObject
@param {*} obj object to push
@return {*} the same obj passed as param
@@ -15494,6 +24639,12 @@ Ember.MutableArray = Ember.Mixin.create(Ember.Array, Ember.MutableEnumerable,/**
this.insertAt(get(this, 'length'), obj) ;
return obj ;
},
+=======
+ // implements Ember.MutableEnumerable
+ addObject: function(obj) {
+ if (get(this, 'isFrozen')) throw new Ember.Error(Ember.FROZEN_ERROR);
+ if (isNone(obj)) return this; // nothing to do
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
/**
Add the objects in the passed numerable to the end of the array. Defers
@@ -15539,9 +24690,16 @@ Ember.MutableArray = Ember.Mixin.create(Ember.Array, Ember.MutableEnumerable,/**
return ret ;
},
+<<<<<<< HEAD
/**
Shift an object from start of array or nil if none are left. Works just
like `shift()` but it is KVO-compliant.
+=======
+ // implements Ember.MutableEnumerable
+ removeObject: function(obj) {
+ if (get(this, 'isFrozen')) throw new Ember.Error(Ember.FROZEN_ERROR);
+ if (isNone(obj)) return this; // nothing to do
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
```javascript
var colors = ["red", "green", "blue"];
@@ -15661,25 +24819,61 @@ Ember.MutableArray = Ember.Mixin.create(Ember.Array, Ember.MutableEnumerable,/**
(function() {
/**
-@module ember
-@submodule ember-runtime
+ @module ember
+ @submodule ember-runtime
*/
var get = Ember.get, set = Ember.set;
/**
+<<<<<<< HEAD
`Ember.TargetActionSupport` is a mixin that can be included in a class
to add a `triggerAction` method with semantics similar to the Handlebars
`{{action}}` helper. In normal Ember usage, the `{{action}}` helper is
usually the best choice. This mixin is most often useful when you are
doing more complex event handling in View objects.
+=======
+ Detects when a specific package of Ember (e.g. 'Ember.Handlebars')
+ has fully loaded and is available for extension.
+
+ The provided `callback` will be called with the `name` passed
+ resolved from a string into the object:
+
+ ``` javascript
+ Ember.onLoad('Ember.Handlebars' function(hbars){
+ hbars.registerHelper(...);
+ });
+ ```
+
+ @method onLoad
+ @for Ember
+ @param name {String} name of hook
+ @param callback {Function} callback to be called
+*/
+Ember.onLoad = function(name, callback) {
+ var object;
+
+ loadHooks[name] = loadHooks[name] || Ember.A();
+ loadHooks[name].pushObject(callback);
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
See also `Ember.ViewTargetActionSupport`, which has
view-aware defaults for target and actionContext.
+<<<<<<< HEAD
@class TargetActionSupport
@namespace Ember
@extends Ember.Mixin
+=======
+/**
+ Called when an Ember.js package (e.g Ember.Handlebars) has finished
+ loading. Triggers any callbacks registered for this event.
+
+ @method runLoadHooks
+ @for Ember
+ @param name {String} name of hook
+ @param object {Object} object to pass to callbacks
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
*/
Ember.TargetActionSupport = Ember.Mixin.create({
target: null,
@@ -15714,6 +24908,7 @@ Ember.TargetActionSupport = Ember.Mixin.create({
Send an "action" with an "actionContext" to a "target". The action, actionContext
and target will be retrieved from properties of the object. For example:
+<<<<<<< HEAD
```javascript
App.SaveButtonView = Ember.View.extend(Ember.TargetActionSupport, {
target: Ember.computed.alias('controller'),
@@ -15745,6 +24940,31 @@ Ember.TargetActionSupport = Ember.Mixin.create({
The `actionContext` defaults to the object you mixing `TargetActionSupport` into.
But `target` and `action` must be specified either as properties or with the argument
to `triggerAction`, or a combination:
+=======
+/**
+@module ember
+@submodule ember-runtime
+*/
+
+/**
+ `Ember.ControllerMixin` provides a standard interface for all classes that
+ compose Ember's controller layer: `Ember.Controller`,
+ `Ember.ArrayController`, and `Ember.ObjectController`.
+
+ @class ControllerMixin
+ @namespace Ember
+ @uses Ember.ActionHandler
+*/
+Ember.ControllerMixin = Ember.Mixin.create(Ember.ActionHandler, {
+ /* ducktype as a controller */
+ isController: true,
+
+ /**
+ The object to which actions from the view should be sent.
+
+ For example, when a Handlebars template uses the `{{action}}` helper,
+ it will attempt to send the action to the view's controller's `target`.
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
```javascript
App.SaveButtonView = Ember.View.extend(Ember.TargetActionSupport, {
@@ -15782,6 +25002,7 @@ Ember.TargetActionSupport = Ember.Mixin.create({
if (target && action) {
var ret;
+<<<<<<< HEAD
if (target.send) {
ret = target.send.apply(target, args(actionContext, action));
} else {
@@ -15795,6 +25016,18 @@ Ember.TargetActionSupport = Ember.Mixin.create({
} else {
return false;
}
+=======
+ deprecatedSendHandles: function(actionName) {
+ return !!this[actionName];
+ },
+
+ deprecatedSend: function(actionName) {
+ var args = [].slice.call(arguments, 1);
+ Ember.assert('' + this + " has the action " + actionName + " but it is not a function", typeof this[actionName] === 'function');
+ Ember.deprecate('Action handlers implemented directly on controllers are deprecated in favor of action handlers on an `actions` object (' + actionName + ' on ' + this + ')', false);
+ this[actionName].apply(this, args);
+ return;
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
}
});
@@ -15830,6 +25063,7 @@ Ember.TargetActionSupport = Ember.Mixin.create({
// outputs: 'Our person has greeted'
```
+<<<<<<< HEAD
You can also chain multiple event subscriptions:
```javascript
@@ -15841,6 +25075,32 @@ Ember.TargetActionSupport = Ember.Mixin.create({
```
@class Evented
+=======
+ If you add or remove the properties to sort by or change the sort direction the content
+ sort order will be automatically updated.
+
+ ```javascript
+ songsController.set('sortProperties', ['title']);
+ songsController.get('firstObject'); // {trackNumber: 2, title: 'Back in the U.S.S.R.'}
+
+ songsController.toggleProperty('sortAscending');
+ songsController.get('firstObject'); // {trackNumber: 4, title: 'Ob-La-Di, Ob-La-Da'}
+ ```
+
+ SortableMixin works by sorting the arrangedContent array, which is the array that
+ arrayProxy displays. Due to the fact that the underlying 'content' array is not changed, that
+ array will not display the sorted list:
+
+ ```javascript
+ songsController.get('content').get('firstObject'); // Returns the unsorted original content
+ songsController.get('firstObject'); // Returns the sorted content.
+ ```
+
+ Although the sorted content can also be accessed through the arrangedContent property,
+ it is preferable to use the proxied class and not the arrangedContent array directly.
+
+ @class SortableMixin
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
@namespace Ember
*/
Ember.Evented = Ember.Mixin.create({
@@ -15848,11 +25108,20 @@ Ember.Evented = Ember.Mixin.create({
/**
Subscribes to a named event with given function.
+<<<<<<< HEAD
```javascript
person.on('didLoad', function() {
// fired once the person has loaded
});
```
+=======
+ When specifying multiple properties the sorting will use properties
+ from the `sortProperties` array prioritized from first to last.
+
+ @property {Array} sortProperties
+ */
+ sortProperties: null,
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
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
@@ -15871,9 +25140,18 @@ Ember.Evented = Ember.Mixin.create({
},
/**
+<<<<<<< HEAD
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.
+=======
+ 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 a negative value if the first parameter is smaller than the second or
+ return a positive value otherwise:
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
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
@@ -15924,6 +25202,7 @@ Ember.Evented = Ember.Mixin.create({
/**
Cancels subscription for given name, target, and method.
+<<<<<<< HEAD
@method off
@param {String} name The name of the event
@param {Object} target The target of the subscription
@@ -15934,6 +25213,20 @@ Ember.Evented = Ember.Mixin.create({
Ember.removeListener(this, name, target, method);
return this;
},
+=======
+ /**
+ 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
+ */
+
+ arrangedContent: Ember.computed('content', 'sortProperties.@each', function(key, value) {
+ var content = get(this, 'content'),
+ isSorted = get(this, 'isSorted'),
+ sortProperties = get(this, 'sortProperties'),
+ self = this;
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
/**
Checks to see if object has any subscriptions for named event.
@@ -15947,9 +25240,16 @@ Ember.Evented = Ember.Mixin.create({
}
});
+<<<<<<< HEAD
})();
+=======
+ _contentWillChange: Ember.beforeObserver('content', function() {
+ var content = get(this, 'content'),
+ sortProperties = get(this, 'sortProperties');
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
+<<<<<<< HEAD
(function() {
var RSVP = requireModule("rsvp");
@@ -15957,6 +25257,21 @@ var RSVP = requireModule("rsvp");
RSVP.configure('async', function(callback, promise) {
Ember.run.schedule('actions', promise, callback, promise);
});
+=======
+ this._super();
+ }),
+
+ sortAscendingWillChange: Ember.beforeObserver('sortAscending', function() {
+ this._lastSortAscending = get(this, 'sortAscending');
+ }),
+
+ sortAscendingDidChange: Ember.observer('sortAscending', function() {
+ if (get(this, 'sortAscending') !== this._lastSortAscending) {
+ var arrangedContent = get(this, 'arrangedContent');
+ arrangedContent.reverseObjects();
+ }
+ }),
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
/**
@module ember
@@ -16336,12 +25651,30 @@ Ember.TrackedArray.prototype = {
composeIndex = arrayOperationIndex + 1;
}
+<<<<<<< HEAD
return this._composeDelete(composeIndex);
},
/**
Apply all operations, reducing them to retain:n, for `n`, the number of
items in the array.
+=======
+ init: function() {
+ this._super();
+
+ this.set('_subControllers', Ember.A());
+ },
+
+ content: Ember.computed(function () {
+ return Ember.A();
+ }),
+
+ controllerAt: function(idx, object, controllerClass) {
+ var container = get(this, 'container'),
+ subControllers = get(this, '_subControllers'),
+ subController = subControllers[idx],
+ factory, fullName;
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
`callback` will be called for each operation and will be passed the following arguments:
* {array} items The items for the given operation
@@ -16357,8 +25690,14 @@ Ember.TrackedArray.prototype = {
var items = [],
offset = 0;
+<<<<<<< HEAD
forEach(this._operations, function (arrayOperation) {
callback(arrayOperation.items, offset, arrayOperation.type);
+=======
+ if (!container.has(fullName)) {
+ throw new Ember.Error('Could not resolve itemController: "' + controllerClass + '"');
+ }
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
if (arrayOperation.type !== DELETE) {
offset += arrayOperation.count;
@@ -16405,6 +25744,7 @@ Ember.TrackedArray.prototype = {
}
}
+<<<<<<< HEAD
return new ArrayOperationMatch(arrayOperation, arrayOperationIndex, split, arrayOperationRangeStart);
},
@@ -16412,6 +25752,15 @@ Ember.TrackedArray.prototype = {
var arrayOperation = this._operations[arrayOperationIndex],
splitItems = arrayOperation.items.slice(splitIndex),
splitArrayOperation = new ArrayOperation(arrayOperation.type, splitItems.length, splitItems);
+=======
+/**
+ `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
+ content 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.
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
// truncate LHS
arrayOperation.count = splitIndex;
@@ -16530,6 +25879,7 @@ Ember.TrackedArray.prototype = {
/**
Internal data structure to represent an array operation.
+<<<<<<< HEAD
@method ArrayOperation
@private
@property {string} type The type of the operation. One of
@@ -16543,6 +25893,14 @@ function ArrayOperation (operation, count, items) {
this.count = count;
this.items = items;
}
+=======
+var jQuery = this.jQuery || (Ember.imports && Ember.imports.jQuery);
+if (!jQuery && typeof require === 'function') {
+ jQuery = require('jquery');
+}
+
+Ember.assert("Ember Views require jQuery 1.7, 1.8, 1.9, 1.10, or 2.0", jQuery && (jQuery().jquery.match(/^((1\.(7|8|9|10))|2.0)(\.\d+)?(pre|rc\d?)?/) || Ember.ENV.FORCE_JQUERY));
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
/**
Internal data structure used to include information when looking up operations
@@ -16798,6 +26156,7 @@ var get = Ember.get, set = Ember.set;
an array, as they are accessed. This can be done by overriding
`objectAtContent`:
+<<<<<<< HEAD
```javascript
var pets = ['dog', 'cat', 'fish'];
var ap = Ember.ArrayProxy.create({
@@ -16823,6 +26182,60 @@ Ember.ArrayProxy = Ember.Object.extend(Ember.MutableArray,/** @scope Ember.Array
@property content
@type Ember.Array
+=======
+// IE 6/7 have bugs arond setting names on inputs during creation.
+// From http://msdn.microsoft.com/en-us/library/ie/ms536389(v=vs.85).aspx:
+// "To include the NAME attribute at run time on objects created with the createElement method, use the eTag."
+var canSetNameOnInputs = (function() {
+ var div = document.createElement('div'),
+ el = document.createElement('input');
+
+ el.setAttribute('name', 'foo');
+ div.appendChild(el);
+
+ return !!div.innerHTML.match('foo');
+})();
+
+/**
+ `Ember.RenderBuffer` gathers information regarding the a view and generates the
+ final representation. `Ember.RenderBuffer` will generate HTML which can be pushed
+ to the DOM.
+
+ ```javascript
+ var buffer = Ember.RenderBuffer('div');
+ ```
+
+ @class RenderBuffer
+ @namespace Ember
+ @constructor
+ @param {String} tagName tag name (such as 'div' or 'p') used for the buffer
+*/
+Ember.RenderBuffer = function(tagName) {
+ return new Ember._RenderBuffer(tagName);
+};
+
+Ember._RenderBuffer = function(tagName) {
+ this.tagNames = [tagName || null];
+ this.buffer = "";
+};
+
+Ember._RenderBuffer.prototype = {
+
+ // The root view's element
+ _element: null,
+
+ _hasElement: true,
+
+ /**
+ An internal set used to de-dupe class names when `addClass()` is
+ used. After each call to `addClass()`, the `classes` property
+ will be updated.
+
+ @private
+ @property elementClasses
+ @type Array
+ @default []
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
*/
content: null,
@@ -17043,9 +26456,60 @@ Ember.ArrayProxy = Ember.Object.extend(Ember.MutableArray,/** @scope Ember.Array
return obj ;
},
+<<<<<<< HEAD
pushObjects: function(objects) {
if (!(Ember.Enumerable.detect(objects) || Ember.isArray(objects))) {
throw new TypeError("Must pass Ember.Enumerable to Ember.MutableArray#pushObjects");
+=======
+ generateElement: function() {
+ var tagName = this.tagNames.pop(), // pop since we don't need to close
+ id = this.elementId,
+ classes = this.classes,
+ attrs = this.elementAttributes,
+ props = this.elementProperties,
+ style = this.elementStyle,
+ styleBuffer = '', attr, prop, tagString;
+
+ if (attrs && attrs.name && !canSetNameOnInputs) {
+ // IE allows passing a tag to createElement. See note on `canSetNameOnInputs` above as well.
+ tagString = '<'+stripTagName(tagName)+' name="'+escapeAttribute(attrs.name)+'">';
+ } else {
+ tagString = tagName;
+ }
+
+ var element = document.createElement(tagString),
+ $element = Ember.$(element);
+
+ if (id) {
+ $element.attr('id', id);
+ this.elementId = null;
+ }
+ if (classes) {
+ $element.attr('class', classes.join(' '));
+ this.classes = null;
+ }
+
+ if (style) {
+ for (prop in style) {
+ if (style.hasOwnProperty(prop)) {
+ styleBuffer += (prop + ':' + style[prop] + ';');
+ }
+ }
+
+ $element.attr('style', styleBuffer);
+
+ this.elementStyle = null;
+ }
+
+ if (attrs) {
+ for (attr in attrs) {
+ if (attrs.hasOwnProperty(attr)) {
+ $element.attr(attr, attrs[attr]);
+ }
+ }
+
+ this.elementAttributes = null;
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
}
this._replace(get(this, 'length'), 0, objects);
return this;
@@ -17105,9 +26569,30 @@ Ember.ArrayProxy = Ember.Object.extend(Ember.MutableArray,/** @scope Ember.Array
*/
+<<<<<<< HEAD
var set = Ember.set, get = Ember.get, guidFor = Ember.guidFor;
var forEach = Ember.EnumerableUtils.forEach,
indexOf = Ember.ArrayPolyfills.indexOf;
+=======
+/**
+ `Ember.EventDispatcher` handles delegating browser events to their
+ corresponding `Ember.Views.` For example, when you click on a view,
+ `Ember.EventDispatcher` ensures that that view's `mouseDown` method gets
+ called.
+
+ @class EventDispatcher
+ @namespace Ember
+ @private
+ @extends Ember.Object
+*/
+Ember.EventDispatcher = Ember.Object.extend({
+
+ /**
+ The set of events names (and associated handler function names) to be setup
+ and dispatched by the `EventDispatcher`. Custom events can added to this list at setup
+ time, generally via the `Ember.Application.customEvents` hash. Only override this
+ default set to prevent the EventDispatcher from listening on some events all together.
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
var EachArray = Ember.Object.extend(Ember.Array, {
@@ -17118,16 +26603,25 @@ var EachArray = Ember.Object.extend(Ember.Array, {
this._content = content;
},
+<<<<<<< HEAD
objectAt: function(idx) {
var item = this._content.objectAt(idx);
return item && get(item, this._keyName);
},
+=======
+ /**
+ The root DOM element to which event listeners should be attached. Event
+ listeners will be attached to the document unless this is overridden.
+
+ Can be specified as a DOMElement or a selector string.
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
length: Ember.computed(function() {
var content = this._content;
return content ? get(content, 'length') : 0;
})
+<<<<<<< HEAD
});
var IS_OBSERVER = /^.+:(before|change)$/;
@@ -17135,6 +26629,17 @@ var IS_OBSERVER = /^.+:(before|change)$/;
function addObserverForContentKey(content, keyName, proxy, idx, loc) {
var objects = proxy._objects, guid;
if (!objects) objects = proxy._objects = {};
+=======
+ @private
+ @property rootElement
+ @type DOMElement
+ @default 'body'
+ */
+ rootElement: 'body',
+
+ /**
+ Sets up event listeners for standard browser events.
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
while(--loc>=idx) {
var item = content.objectAt(loc);
@@ -17143,6 +26648,7 @@ function addObserverForContentKey(content, keyName, proxy, idx, loc) {
Ember.addBeforeObserver(item, keyName, proxy, 'contentKeyWillChange');
Ember.addObserver(item, keyName, proxy, 'contentKeyDidChange');
+<<<<<<< HEAD
// keep track of the index each item was found at so we can map
// it back when the obj changes.
guid = guidFor(item);
@@ -17151,6 +26657,14 @@ function addObserverForContentKey(content, keyName, proxy, idx, loc) {
}
}
}
+=======
+ @private
+ @method setup
+ @param addedEvents {Hash}
+ */
+ setup: function(addedEvents, rootElement) {
+ var event, events = get(this, 'events');
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
function removeObserverForContentKey(content, keyName, proxy, idx, loc) {
var objects = proxy._objects;
@@ -17195,12 +26709,34 @@ Ember.EachProxy = Ember.Object.extend({
},
/**
+<<<<<<< HEAD
You can directly access mapped properties by simply requesting them.
The `unknownProperty` handler will generate an EachArray of each item.
@method unknownProperty
@param keyName {String}
@param value {*}
+=======
+ Registers an event listener on the document. If the given event is
+ triggered, the provided event handler will be triggered on the target view.
+
+ If the target view does not implement the event handler, or if the handler
+ returns `false`, the parent view will be called. The event will continue to
+ bubble to each successive parent view until it reaches the top.
+
+ For example, to have the `mouseDown` method called on the target view when
+ a `mousedown` event is received from the browser, do the following:
+
+ ```javascript
+ setupHandler('mousedown', 'mouseDown');
+ ```
+
+ @private
+ @method setupHandler
+ @param {Element} rootElement
+ @param {String} event the browser-originated event to listen to
+ @param {String} eventName the name of the method to call on the view
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
*/
unknownProperty: function(keyName, value) {
var ret;
@@ -17210,9 +26746,16 @@ Ember.EachProxy = Ember.Object.extend({
return ret;
},
+<<<<<<< HEAD
// ..........................................................
// ARRAY CHANGES
// Invokes whenever the content array itself changes.
+=======
+ rootElement.on(event + '.ember', '.ember-view', function(evt, triggeringManager) {
+ return Ember.handleErrors(function handleViewEvent() {
+ var view = Ember.View.views[this.id],
+ result = true, manager = null;
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
arrayWillChange: function(content, idx, removedCnt, addedCnt) {
var keys = this._keys, key, lim;
@@ -17223,7 +26766,14 @@ Ember.EachProxy = Ember.Object.extend({
for(key in keys) {
if (!keys.hasOwnProperty(key)) { continue; }
+<<<<<<< HEAD
if (lim>0) { removeObserverForContentKey(content, key, this, idx, lim); }
+=======
+ rootElement.on(event + '.ember', '[data-ember-action]', function(evt) {
+ return Ember.handleErrors(function handleActionEvent() {
+ var actionId = Ember.$(evt.currentTarget).attr('data-ember-action'),
+ action = Ember.Handlebars.ActionHelper.registeredActions[actionId];
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
Ember.propertyWillChange(this, key);
}
@@ -17282,6 +26832,7 @@ Ember.EachProxy = Ember.Object.extend({
}
},
+<<<<<<< HEAD
stopObservingContentKey: function(keyName) {
var keys = this._keys;
if (keys && (keys[keyName]>0) && (--keys[keyName]<=0)) {
@@ -17289,6 +26840,12 @@ Ember.EachProxy = Ember.Object.extend({
len = get(content, 'length');
removeObserverForContentKey(content, keyName, this, 0, len);
}
+=======
+ _bubbleEvent: function(view, evt, eventName) {
+ return Ember.run(function bubbleEvent() {
+ return view.handleEvent(eventName, evt);
+ });
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
},
contentKeyWillChange: function(obj, keyName) {
@@ -17354,20 +26911,35 @@ var NativeArray = Ember.Mixin.create(Ember.MutableArray, Ember.Observable, Ember
return this;
},
+<<<<<<< HEAD
// If you ask for an unknown property, then try to collect the value
// from member items.
unknownProperty: function(key, value) {
var ret;// = this.reducedProperty(key, value) ;
if ((value !== undefined) && ret === undefined) {
ret = this[key] = value;
+=======
+ _modelDidChange: Ember.observer('model', function() {
+ var containers = get(this, '_childContainers');
+
+ for (var prop in containers) {
+ if (!containers.hasOwnProperty(prop)) { continue; }
+ containers[prop].destroy();
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
}
return ret ;
},
+<<<<<<< HEAD
// If browser did not implement indexOf natively, then override with
// specialized version
indexOf: function(object, startAt) {
var idx, len = this.length;
+=======
+ set(this, '_childContainers', {});
+ })
+});
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
if (startAt === undefined) startAt = 0;
else startAt = (startAt < 0) ? Math.ceil(startAt) : Math.floor(startAt);
@@ -17426,6 +26998,7 @@ if (ignore.length>0) {
*/
Ember.NativeArray = NativeArray;
+<<<<<<< HEAD
/**
Creates an `Ember.NativeArray` from an Array like object.
Does not modify the original object. Ember.A is not needed if
@@ -17433,6 +27006,13 @@ Ember.NativeArray = NativeArray;
it is recommended that you use Ember.A when creating addons for
ember or when you can not guarantee that `Ember.EXTEND_PROTOTYPES`
will be `true`.
+=======
+var get = Ember.get, set = Ember.set;
+var guidFor = Ember.guidFor;
+var a_forEach = Ember.EnumerableUtils.forEach;
+var a_addObject = Ember.EnumerableUtils.addObject;
+var meta = Ember.meta;
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
Example
@@ -17449,7 +27029,29 @@ Ember.NativeArray = NativeArray;
});
```
+<<<<<<< HEAD
@method A
+=======
+ ret.replace = function (idx, removedCount, addedViews) {
+ if (view instanceof Ember.ContainerView) {
+ Ember.deprecate("Manipulating an Ember.ContainerView through its childViews property is deprecated. Please use the ContainerView instance itself as an Ember.MutableArray.");
+ return view.replace(idx, removedCount, addedViews);
+ }
+ throw new Ember.Error("childViews is immutable");
+ };
+
+ return ret;
+});
+
+Ember.warn("The VIEW_PRESERVES_CONTEXT flag has been removed and the functionality can no longer be disabled.", Ember.ENV.VIEW_PRESERVES_CONTEXT !== false);
+
+/**
+ Global hash of shared templates. This will automatically be populated
+ by the build tools so that you can store your Handlebars templates in
+ separate files that get loaded into JavaScript at buildtime.
+
+ @property TEMPLATES
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
@for Ember
@return {Ember.NativeArray}
*/
@@ -17459,6 +27061,7 @@ Ember.A = function(arr) {
};
/**
+<<<<<<< HEAD
Activates the mixin on the Array.prototype if not already applied. Calling
this method more than once is safe. This will be called when ember is loaded
unless you have `Ember.EXTEND_PROTOTYPES` or `Ember.EXTEND_PROTOTYPES.Array`
@@ -17471,6 +27074,25 @@ Ember.A = function(arr) {
Ember.NativeArray.activate();
}
```
+=======
+ `Ember.CoreView` is an abstract class that exists to give view-like behavior
+ to both Ember's main view class `Ember.View` and other classes like
+ `Ember._SimpleMetamorphView` that don't need the fully functionaltiy of
+ `Ember.View`.
+
+ Unless you have specific needs for `CoreView`, you will use `Ember.View`
+ in your applications.
+
+ @class CoreView
+ @namespace Ember
+ @extends Ember.Object
+ @uses Ember.Evented
+ @uses Ember.ActionHandler
+*/
+
+Ember.CoreView = Ember.Object.extend(Ember.Evented, Ember.ActionHandler, {
+ isView: true,
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
@method activate
@for Ember.NativeArray
@@ -17503,6 +27125,7 @@ var get = Ember.get, set = Ember.set, guidFor = Ember.guidFor, isNone = Ember.is
/**
An unordered collection of objects.
+<<<<<<< HEAD
A Set works a bit like an array except that its items are not ordered. You
can create a set to efficiently test for membership for an object. You can
also iterate through a set just like an array, even accessing objects by
@@ -17510,20 +27133,47 @@ var get = Ember.get, set = Ember.set, guidFor = Ember.guidFor, isNone = Ember.is
All Sets are observable via the Enumerable Observer API - which works
on any enumerable object including both Sets and Arrays.
+=======
+ /**
+ Invoked by the view system when this view needs to produce an HTML
+ representation. This method will create a new render buffer, if needed,
+ then apply any default attributes, such as class names and visibility.
+ Finally, the `render()` method is invoked, which is responsible for
+ doing the bulk of the rendering.
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
## Creating a Set
+<<<<<<< HEAD
You can create a set like you would most objects using
`new Ember.Set()`. Most new sets you create will be empty, but you can
also initialize the set with some content by passing an array or other
enumerable of objects to the constructor.
+=======
+ @method renderToBuffer
+ @param {Ember.RenderBuffer} buffer the render buffer. If no buffer is
+ passed, a default buffer, using the current view's `tagName`, will
+ be used.
+ @private
+ */
+ renderToBuffer: function(parentBuffer, bufferOperation) {
+ var name = 'render.' + this.instrumentName,
+ details = {};
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
Finally, you can pass in an existing set and the set will be copied. You
can also create a copy of a set by calling `Ember.Set#copy()`.
+<<<<<<< HEAD
```javascript
// creates a new empty set
var foundNames = new Ember.Set();
+=======
+ return Ember.instrument(name, details, function instrumentRenderToBuffer() {
+ return this._renderToBuffer(parentBuffer, bufferOperation);
+ }, this);
+ },
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
// creates a set with four names in it.
var names = new Ember.Set(["Charles", "Tom", "Juan", "Alex"]); // :P
@@ -17541,6 +27191,7 @@ var get = Ember.get, set = Ember.set, guidFor = Ember.guidFor, isNone = Ember.is
`remove()`. You can add any type of object including primitives such as
numbers, strings, and booleans.
+<<<<<<< HEAD
Unlike arrays, objects can only exist one time in a set. If you call `add()`
on a set with the same object multiple times, the object will only be added
once. Likewise, calling `remove()` with the same object multiple times will
@@ -17556,6 +27207,43 @@ var get = Ember.get, set = Ember.set, guidFor = Ember.guidFor, isNone = Ember.is
queue when you don't care which order the jobs are executed in.
## Testing for an Object
+=======
+ /**
+ Override the default event firing from `Ember.Evented` to
+ also call methods with the given name.
+
+ @method trigger
+ @param name {String}
+ @private
+ */
+ trigger: function(name) {
+ this._super.apply(this, arguments);
+ var method = this[name];
+ if (method) {
+ var args = [], i, l;
+ for (i = 1, l = arguments.length; i < l; i++) {
+ args.push(arguments[i]);
+ }
+ return method.apply(this, args);
+ }
+ },
+
+ deprecatedSendHandles: function(actionName) {
+ return !!this[actionName];
+ },
+
+ deprecatedSend: function(actionName) {
+ var args = [].slice.call(arguments, 1);
+ Ember.assert('' + this + " has the action " + actionName + " but it is not a function", typeof this[actionName] === 'function');
+ Ember.deprecate('Action handlers implemented directly on views are deprecated in favor of action handlers on an `actions` object (' + actionName + ' on ' + this + ')', false);
+ this[actionName].apply(this, args);
+ return;
+ },
+
+ has: function(name) {
+ return Ember.typeOf(this[name]) === 'function' || this._super(name);
+ },
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
To test for an object's presence in a set you simply call
`Ember.Set#contains()`.
@@ -17654,9 +27342,15 @@ Ember.Set = Ember.CoreObject.extend(Ember.MutableEnumerable, Ember.Copyable, Emb
return this;
},
+<<<<<<< HEAD
/**
Returns true if the passed object is also an enumerable that contains the
same objects as the receiver.
+=======
+ The default HTML tag name used for a view's DOM representation is `div`. This
+ can be customized by setting the `tagName` property. The following view
+ class:
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
```javascript
var colors = ["red", "green", "blue"],
@@ -17848,10 +27542,16 @@ Ember.Set = Ember.CoreObject.extend(Ember.MutableEnumerable, Ember.Copyable, Emb
return this.length > 0 ? this[0] : undefined;
}),
+<<<<<<< HEAD
// more optimized version
lastObject: Ember.computed(function() {
return this.length > 0 ? this[this.length-1] : undefined;
}),
+=======
+ Both `classNames` and `classNameBindings` are concatenated properties. See
+ [Ember.Object](/api/classes/Ember.Object.html) documentation for more
+ information about concatenated properties.
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
// implements Ember.MutableEnumerable
addObject: function(obj) {
@@ -17897,9 +27597,14 @@ Ember.Set = Ember.CoreObject.extend(Ember.MutableEnumerable, Ember.Copyable, Emb
if (idx>=0 && idx>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
// swap items - basically move the item to the end so it can be removed
if (idx < len-1) {
@@ -17947,11 +27652,38 @@ Ember.Set = Ember.CoreObject.extend(Ember.MutableEnumerable, Ember.Copyable, Emb
})();
+<<<<<<< HEAD
(function() {
var DeferredMixin = Ember.DeferredMixin, // mixins/deferred
get = Ember.get;
+=======
+ If you have nested resources, your Handlebars template will look like this:
+
+ ```html
+
+ ```
+
+ And `templateName` property:
+
+ ```javascript
+ AView = Ember.View.extend({
+ templateName: 'posts/new'
+ });
+ ```
+
+ Using a value for `templateName` that does not have a Handlebars template
+ with a matching `data-template-name` attribute will throw an error.
+
+ For views classes that may have a template later defined (e.g. as the block
+ portion of a `{{view}}` Handlebars helper call in another template or in
+ a subclass), you can provide a `defaultTemplate` property set to compiled
+ template function. If a template is not later provided for the view instance
+ the `defaultTemplate` value will be used:
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
var Deferred = Ember.Object.extend(DeferredMixin);
@@ -18034,6 +27766,11 @@ Ember.runLoadHooks = function(name, object) {
})();
+<<<<<<< HEAD
+=======
+ See [Ember.Handlebars.helpers.yield](/api/classes/Ember.Handlebars.helpers.html#method_yield)
+ for more information.
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
(function() {
@@ -18079,7 +27816,11 @@ Ember.ControllerMixin = Ember.Mixin.create(Ember.ActionHandler, {
parentController: null,
+<<<<<<< HEAD
store: null,
+=======
+ See [Handlebars.helpers.action](/api/classes/Ember.Handlebars.helpers.html#method_action).
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
model: Ember.computed.alias('content'),
@@ -18135,18 +27876,40 @@ var get = Ember.get, set = Ember.set, forEach = Ember.EnumerableUtils.forEach;
sortAscending: true
});
+<<<<<<< HEAD
songsController.get('firstObject'); // {trackNumber: 2, title: 'Back in the U.S.S.R.'}
songsController.addObject({trackNumber: 1, title: 'Dear Prudence'});
songsController.get('firstObject'); // {trackNumber: 1, title: 'Dear Prudence'}
```
+=======
+ Other `Ember.View` instances can be included as part of a view's template by
+ using the `{{view}}` Handlebars helper. See [Ember.Handlebars.helpers.view](/api/classes/Ember.Handlebars.helpers.html#method_view)
+ for additional information.
+
+ @class View
+ @namespace Ember
+ @extends Ember.CoreView
+*/
+Ember.View = Ember.CoreView.extend({
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
If you add or remove the properties to sort by or change the sort direction the content
sort order will be automatically updated.
+<<<<<<< HEAD
```javascript
songsController.set('sortProperties', ['title']);
songsController.get('firstObject'); // {trackNumber: 2, title: 'Back in the U.S.S.R.'}
+=======
+ /**
+ @property isView
+ @type Boolean
+ @default true
+ @static
+ */
+ isView: true,
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
songsController.toggleProperty('sortAscending');
songsController.get('firstObject'); // {trackNumber: 4, title: 'Ob-La-Di, Ob-La-Da'}
@@ -18156,6 +27919,7 @@ var get = Ember.get, set = Ember.set, forEach = Ember.EnumerableUtils.forEach;
arrayProxy displays. Due to the fact that the underlying 'content' array is not changed, that
array will not display the sorted list:
+<<<<<<< HEAD
```javascript
songsController.get('content').get('firstObject'); // Returns the unsorted original content
songsController.get('firstObject'); // Returns the sorted content.
@@ -18163,6 +27927,10 @@ var get = Ember.get, set = Ember.set, forEach = Ember.EnumerableUtils.forEach;
Although the sorted content can also be accessed through the arrangedContent property,
it is preferable to use the proxied class and not the arrangedContent array directly.
+=======
+ By default `Ember.View` will lookup a template with this name in
+ `Ember.TEMPLATES` (a shared global object).
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
@class SortableMixin
@namespace Ember
@@ -18173,14 +27941,20 @@ Ember.SortableMixin = Ember.Mixin.create(Ember.MutableEnumerable, {
/**
Specifies which properties dictate the arrangedContent's sort order.
+<<<<<<< HEAD
When specifying multiple properties the sorting will use properties
from the `sortProperties` array prioritized from first to last.
+=======
+ By default `Ember.View` will lookup a template with this name in
+ `Ember.TEMPLATES` (a shared global object).
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
@property {Array} sortProperties
*/
sortProperties: null,
/**
+<<<<<<< HEAD
Specifies the arrangedContent's sort direction
@property {Boolean} sortAscending
@@ -18194,6 +27968,11 @@ Ember.SortableMixin = Ember.Mixin.create(Ember.MutableEnumerable, {
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:
+=======
+ The template used to render the view. This should be a function that
+ accepts an optional context parameter and returns a string of HTML that
+ will be inserted into the DOM relative to its parent view.
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
```javascript
function(x,y) { // These are assumed to be integers
@@ -18253,6 +28032,7 @@ Ember.SortableMixin = Ember.Mixin.create(Ember.MutableEnumerable, {
@property arrangedContent
*/
+<<<<<<< HEAD
arrangedContent: Ember.computed('content', 'sortProperties.@each', function(key, value) {
var content = get(this, 'content'),
isSorted = get(this, 'isSorted'),
@@ -18271,6 +28051,12 @@ Ember.SortableMixin = Ember.Mixin.create(Ember.MutableEnumerable, {
}, this);
return Ember.A(content);
}
+=======
+ /**
+ Private copy of the view's template context. This can be set directly
+ by Handlebars without triggering the observer that causes the view
+ to be re-rendered.
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
return content;
}),
@@ -18287,8 +28073,16 @@ Ember.SortableMixin = Ember.Mixin.create(Ember.MutableEnumerable, {
}, this);
}
+<<<<<<< HEAD
this._super();
}),
+=======
+ @property _context
+ @private
+ */
+ _context: Ember.computed(function(key) {
+ var parentView, controller;
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
sortAscendingWillChange: Ember.beforeObserver('sortAscending', function() {
this._lastSortAscending = get(this, 'sortAscending');
@@ -18301,6 +28095,7 @@ Ember.SortableMixin = Ember.Mixin.create(Ember.MutableEnumerable, {
}
}),
+<<<<<<< HEAD
contentArrayWillChange: function(array, idx, removedCount, addedCount) {
var isSorted = get(this, 'isSorted');
@@ -18324,10 +28119,43 @@ Ember.SortableMixin = Ember.Mixin.create(Ember.MutableEnumerable, {
contentArrayDidChange: function(array, idx, removedCount, addedCount) {
var isSorted = get(this, 'isSorted'),
sortProperties = get(this, 'sortProperties');
+=======
+ /**
+ If a value that affects template rendering changes, the view should be
+ re-rendered to reflect the new value.
+
+ @method _contextDidChange
+ @private
+ */
+ _contextDidChange: Ember.observer('context', function() {
+ this.rerender();
+ }),
+
+ /**
+ If `false`, the view will appear hidden in DOM.
+
+ @property isVisible
+ @type Boolean
+ @default null
+ */
+ isVisible: true,
+
+ /**
+ Array of child views. You should never edit this array directly.
+ Instead, use `appendChild` and `removeFromParent`.
+
+ @property childViews
+ @type Array
+ @default []
+ @private
+ */
+ childViews: childViewsProperty,
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
if (isSorted) {
var addedObjects = array.slice(idx, idx+addedCount);
+<<<<<<< HEAD
forEach(addedObjects, function(item) {
this.insertItemSorted(item);
@@ -18336,6 +28164,25 @@ Ember.SortableMixin = Ember.Mixin.create(Ember.MutableEnumerable, {
}, this);
}, this);
}
+=======
+ // When it's a virtual view, we need to notify the parent that their
+ // childViews will change.
+ _childViewsWillChange: Ember.beforeObserver('childViews', function() {
+ if (this.isVirtual) {
+ var parentView = get(this, 'parentView');
+ if (parentView) { Ember.propertyWillChange(parentView, 'childViews'); }
+ }
+ }),
+
+ // When it's a virtual view, we need to notify the parent that their
+ // childViews did change.
+ _childViewsDidChange: Ember.observer('childViews', function() {
+ if (this.isVirtual) {
+ var parentView = get(this, 'parentView');
+ if (parentView) { Ember.propertyDidChange(parentView, 'childViews'); }
+ }
+ }),
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
return this._super(array, idx, removedCount, addedCount);
},
@@ -18362,8 +28209,20 @@ Ember.SortableMixin = Ember.Mixin.create(Ember.MutableEnumerable, {
}
},
+<<<<<<< HEAD
_binarySearch: function(item, low, high) {
var mid, midItem, res, arrangedContent;
+=======
+ /**
+ Return the nearest ancestor that has a given property.
+
+ @function nearestWithProperty
+ @param {String} property A property name
+ @return Ember.View
+ */
+ nearestWithProperty: function(property) {
+ var view = get(this, 'parentView');
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
if (low === high) {
return low;
@@ -18371,8 +28230,17 @@ Ember.SortableMixin = Ember.Mixin.create(Ember.MutableEnumerable, {
arrangedContent = get(this, 'arrangedContent');
+<<<<<<< HEAD
mid = low + Math.floor((high - low) / 2);
midItem = arrangedContent.objectAt(mid);
+=======
+ @method nearestChildOf
+ @param {Class} klass Subclass of Ember.View (or Ember.View itself)
+ @return Ember.View
+ */
+ nearestChildOf: function(klass) {
+ var view = get(this, 'parentView');
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
res = this.orderBy(midItem, item);
@@ -18382,14 +28250,26 @@ Ember.SortableMixin = Ember.Mixin.create(Ember.MutableEnumerable, {
return this._binarySearch(item, low, mid);
}
+<<<<<<< HEAD
return mid;
}
});
})();
+=======
+ /**
+ When the parent view changes, recursively invalidate `controller`
+
+ @method _parentViewDidChange
+ @private
+ */
+ _parentViewDidChange: Ember.observer('_parentView', function() {
+ if (this.isDestroying) { return; }
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
+<<<<<<< HEAD
(function() {
/**
@module ember
@@ -18398,15 +28278,31 @@ Ember.SortableMixin = Ember.Mixin.create(Ember.MutableEnumerable, {
var get = Ember.get, set = Ember.set, forEach = Ember.EnumerableUtils.forEach,
replace = Ember.EnumerableUtils.replace;
+=======
+ if (get(this, 'parentView.controller') && !get(this, 'controller')) {
+ this.notifyPropertyChange('controller');
+ }
+ }),
+
+ _controllerDidChange: Ember.observer('controller', function() {
+ if (this.isDestroying) { return; }
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
/**
`Ember.ArrayController` provides a way for you to publish a collection of
objects so that you can easily bind to the collection from a Handlebars
`#each` helper, an `Ember.CollectionView`, or other controllers.
+<<<<<<< HEAD
The advantage of using an `ArrayController` is that you only have to set up
your view bindings once; to change what's displayed, simply swap out the
`content` property on the controller.
+=======
+ this.forEachChildView(function(view) {
+ view.propertyDidChange('controller');
+ });
+ }),
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
For example, imagine you wanted to display a list of items fetched via an XHR
request. Create an `Ember.ArrayController` and set its `content` property:
@@ -18491,11 +28387,21 @@ Ember.ArrayController = Ember.ArrayProxy.extend(Ember.ControllerMixin,
Ember.SortableMixin, {
/**
+<<<<<<< HEAD
The controller used to wrap items, if any.
@property itemController
@type String
@default null
+=======
+ Iterates over the view's `classNameBindings` array, inserts the value
+ of the specified property into the `classNames` array, then creates an
+ observer to update the view's element if the bound property ever changes
+ in the future.
+
+ @method _applyClassNameBindings
+ @private
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
*/
itemController: null,
@@ -18548,10 +28454,23 @@ Ember.ArrayController = Ember.ArrayProxy.extend(Ember.ControllerMixin,
return object;
},
+<<<<<<< HEAD
arrangedContentDidChange: function() {
this._super();
this._resetSubControllers();
},
+=======
+ /**
+ Iterates through the view's attribute bindings, sets up observers for each,
+ then applies the current value of the attributes to the passed render buffer.
+
+ @method _applyAttributeBindings
+ @param {Ember.RenderBuffer} buffer
+ @private
+ */
+ _applyAttributeBindings: function(buffer, attributeBindings) {
+ var attributeValue, elem;
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
arrayContentDidChange: function(idx, removedCnt, addedCnt) {
var subControllers = get(this, '_subControllers'),
@@ -18575,6 +28494,7 @@ Ember.ArrayController = Ember.ArrayProxy.extend(Ember.ControllerMixin,
this.set('_subControllers', Ember.A());
},
+<<<<<<< HEAD
content: Ember.computed(function () {
return Ember.A();
}),
@@ -18584,10 +28504,25 @@ Ember.ArrayController = Ember.ArrayProxy.extend(Ember.ControllerMixin,
subControllers = get(this, '_subControllers'),
subController = subControllers[idx],
factory, fullName;
+=======
+ /**
+ Given a property name, returns a dasherized version of that
+ property name if the property evaluates to a non-falsy value.
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
if (subController) { return subController; }
+<<<<<<< HEAD
fullName = "controller:" + controllerClass;
+=======
+ @method _classStringForProperty
+ @param property
+ @private
+ */
+ _classStringForProperty: function(property) {
+ var parsedPath = Ember.View._parsePropertyPath(property);
+ var path = parsedPath.path;
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
if (!container.has(fullName)) {
throw new Ember.Error('Could not resolve itemController: "' + controllerClass + '"');
@@ -18675,7 +28610,17 @@ if (!jQuery && typeof require === 'function') {
jQuery = require('jquery');
}
+<<<<<<< HEAD
Ember.assert("Ember Views require jQuery 1.7, 1.8, 1.9, 1.10, or 2.0", jQuery && (jQuery().jquery.match(/^((1\.(7|8|9|10))|2.0)(\.\d+)?(pre|rc\d?)?/) || Ember.ENV.FORCE_JQUERY));
+=======
+ @method replaceIn
+ @param {String|DOMElement|jQuery} target A selector, element, HTML string, or jQuery object
+ @return {Ember.View} received
+ */
+ replaceIn: function(target) {
+ Ember.assert("You tried to replace in (" + target + ") but that isn't in the DOM", Ember.$(target).length > 0);
+ Ember.assert("You cannot replace an existing Ember.View. Consider using Ember.ContainerView instead.", !Ember.$(target).is('.ember-view') && !Ember.$(target).parents().is('.ember-view'));
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
/**
Alias for jQuery
@@ -18685,8 +28630,15 @@ Ember.assert("Ember Views require jQuery 1.7, 1.8, 1.9, 1.10, or 2.0", jQuery &&
*/
Ember.$ = jQuery;
+<<<<<<< HEAD
})();
+=======
+ /**
+ Schedules a DOM operation to occur during the next render phase. This
+ ensures that all bindings have finished synchronizing before the view is
+ rendered.
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
(function() {
@@ -18705,7 +28657,17 @@ if (Ember.$) {
});
}
+<<<<<<< HEAD
})();
+=======
+ @method _insertElementLater
+ @param {Function} fn the function that inserts the element into the DOM
+ @private
+ */
+ _insertElementLater: function(fn) {
+ this._scheduledInsert = Ember.run.scheduleOnce('render', this, '_insertElement', fn);
+ },
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
@@ -18808,6 +28770,7 @@ var canSetInnerHTML = function(tagName) {
innerHTMLTags[tagName] = canSet;
+<<<<<<< HEAD
return canSet;
};
@@ -18820,6 +28783,19 @@ var setInnerHTML = function(element, html) {
// Firefox versions < 11 do not have support for element.outerHTML.
var outerHTML = element.outerHTML || new XMLSerializer().serializeToString(element);
Ember.assert("Can't set innerHTML on "+element.tagName+" in this browser", outerHTML);
+=======
+ /**
+ Run this callback on the current view (unless includeSelf is false) and recursively on child views.
+
+ @method invokeRecursively
+ @param fn {Function}
+ @param includeSelf {Boolean} Includes itself if true.
+ @private
+ */
+ invokeRecursively: function(fn, includeSelf) {
+ var childViews = (includeSelf === false) ? this._childViews : [this];
+ var currentViews, view, currentChildViews;
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
var startTag = outerHTML.match(new RegExp("<"+tagName+"([^>]*)>", 'i'))[0],
endTag = ''+tagName+'>';
@@ -18864,10 +28840,15 @@ var ClassSet = function() {
this.list = [];
};
+<<<<<<< HEAD
ClassSet.prototype = {
add: function(string) {
if (string in this.seen) { return; }
this.seen[string] = true;
+=======
+ You should not call or override this method yourself, but you may
+ want to implement the above callbacks.
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
this.list.push(string);
},
@@ -18880,6 +28861,7 @@ ClassSet.prototype = {
var BAD_TAG_NAME_TEST_REGEXP = /[^a-zA-Z0-9\-]/;
var BAD_TAG_NAME_REPLACE_REGEXP = /[^a-zA-Z0-9\-]/g;
+<<<<<<< HEAD
function stripTagName(tagName) {
if (!tagName) {
return tagName;
@@ -18888,10 +28870,17 @@ function stripTagName(tagName) {
if (!BAD_TAG_NAME_TEST_REGEXP.test(tagName)) {
return tagName;
}
+=======
+ /**
+ Triggers the `willDestroyElement` event (which invokes the
+ `willDestroyElement()` method if it exists) on this view and all child
+ views.
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
return tagName.replace(BAD_TAG_NAME_REPLACE_REGEXP, '');
}
+<<<<<<< HEAD
var BAD_CHARS_REGEXP = /&(?!\w+;)|[<>"'`]/g;
var POSSIBLE_CHARS_REGEXP = /[&<>"'`]/;
@@ -18911,6 +28900,31 @@ function escapeAttribute(value) {
};
var string = value.toString();
+=======
+ @method _notifyWillDestroyElement
+ @private
+ */
+ _notifyWillDestroyElement: function() {
+ var viewCollection = this.viewHierarchyCollection();
+ viewCollection.trigger('willClearRender');
+ viewCollection.trigger('willDestroyElement');
+ return viewCollection;
+ },
+
+ /**
+ If this view's element changes, we need to invalidate the caches of our
+ child views so that we do not retain references to DOM elements that are
+ no longer needed.
+
+ @method _elementDidChange
+ @private
+ */
+ _elementDidChange: Ember.observer('element', function() {
+ this.forEachChildView(function(view) {
+ delete meta(view).cache.element;
+ });
+ }),
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
if(!POSSIBLE_CHARS_REGEXP.test(string)) { return string; }
return string.replace(BAD_CHARS_REGEXP, escapeChar);
@@ -18988,8 +29002,13 @@ Ember._RenderBuffer.prototype =
/**
The id in of the element, to be applied in the id attribute.
+<<<<<<< HEAD
You should not set this property yourself, rather, you should use
the `id()` method of `Ember.RenderBuffer`.
+=======
+ The full list of valid WAI-ARIA roles is available at:
+ [http://www.w3.org/TR/wai-aria/roles#roles_categorization](http://www.w3.org/TR/wai-aria/roles#roles_categorization)
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
@property elementId
@type String
@@ -19044,6 +29063,7 @@ Ember._RenderBuffer.prototype =
elementTag: null,
/**
+<<<<<<< HEAD
A hash keyed on the name of the style attribute and whose value will
be applied to that attribute. For example, if you wanted to apply a
`background-color:black;` style to an element, you would set the
@@ -19055,6 +29075,16 @@ Ember._RenderBuffer.prototype =
@property elementStyle
@type Hash
@default {}
+=======
+ Setup a view, but do not finish waking it up.
+
+ * configure `childViews`
+ * register the view with the global views hash, which is used for event
+ dispatch
+
+ @method init
+ @private
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
*/
elementStyle: null,
@@ -19177,9 +29207,26 @@ Ember._RenderBuffer.prototype =
@param {String} name The name of the property
@chainable
*/
+<<<<<<< HEAD
removeProp: function(name) {
var properties = this.elementProperties;
if (properties) { delete properties[name]; }
+=======
+ createChildView: function(view, attrs) {
+ if (!view) {
+ throw new TypeError("createChildViews first argument must exist");
+ }
+
+ if (view.isView && view._parentView === this && view.container === this.container) {
+ return view;
+ }
+
+ attrs = attrs || {};
+ attrs._parentView = this;
+
+ if (Ember.CoreView.detect(view)) {
+ attrs.templateData = attrs.templateData || get(this, 'templateData');
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
return this;
},
@@ -19213,6 +29260,7 @@ Ember._RenderBuffer.prototype =
return;
}
+<<<<<<< HEAD
var buffer = this.buffer,
id = this.elementId,
classes = this.classes,
@@ -19231,6 +29279,24 @@ Ember._RenderBuffer.prototype =
buffer += ' class="' + escapeAttribute(classes.join(' ')) + '"';
this.classes = null;
}
+=======
+ return view;
+ },
+
+ becameVisible: Ember.K,
+ becameHidden: Ember.K,
+
+ /**
+ When the view's `isVisible` property changes, toggle the visibility
+ element of the actual DOM element.
+
+ @method _isVisibleDidChange
+ @private
+ */
+ _isVisibleDidChange: Ember.observer('isVisible', function() {
+ var $el = this.$();
+ if (!$el) { return; }
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
if (style) {
buffer += ' style="';
@@ -19245,6 +29311,16 @@ Ember._RenderBuffer.prototype =
this.elementStyle = null;
}
+<<<<<<< HEAD
+=======
+ }),
+
+ _notifyBecameVisible: function() {
+ this.trigger('becameVisible');
+
+ this.forEachChildView(function(view) {
+ var isVisible = get(view, 'isVisible');
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
if (attrs) {
for (attr in attrs) {
@@ -19282,6 +29358,7 @@ Ember._RenderBuffer.prototype =
if (tagName) { this.buffer += '' + stripTagName(tagName) + '>'; }
},
+<<<<<<< HEAD
currentTagName: function() {
return this.tagNames[this.tagNames.length-1];
},
@@ -19294,6 +29371,39 @@ Ember._RenderBuffer.prototype =
props = this.elementProperties,
style = this.elementStyle,
styleBuffer = '', attr, prop, tagString;
+=======
+ transitionTo: function(state, children) {
+ var priorState = this.currentState,
+ currentState = this.currentState = this.states[state];
+ this.state = state;
+
+ if (priorState && priorState.exit) { priorState.exit(this); }
+ if (currentState.enter) { currentState.enter(this); }
+ if (state === 'inDOM') { delete Ember.meta(this).cache.element; }
+
+ if (children !== false) {
+ this.forEachChildView(function(view) {
+ view.transitionTo(state);
+ });
+ }
+ },
+
+ // .......................................................
+ // EVENT HANDLING
+ //
+
+ /**
+ Handle events from `Ember.EventDispatcher`
+
+ @method handleEvent
+ @param eventName {String}
+ @param evt {Event}
+ @private
+ */
+ handleEvent: function(eventName, evt) {
+ return this.currentState.handleEvent(this, eventName, evt);
+ },
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
if (attrs && attrs.name && !canSetNameOnInputs) {
// IE allows passing a tag to createElement. See note on `canSetNameOnInputs` above as well.
@@ -19302,8 +29412,35 @@ Ember._RenderBuffer.prototype =
tagString = tagName;
}
+<<<<<<< HEAD
var element = document.createElement(tagString),
$element = Ember.$(element);
+=======
+ if (!root || typeof root !== 'object') {
+ return;
+ }
+
+ var view = this,
+ stateCheckedObserver = function() {
+ view.currentState.invokeObserver(this, observer);
+ },
+ scheduledObserver = function() {
+ Ember.run.scheduleOnce('render', this, stateCheckedObserver);
+ };
+
+ Ember.addObserver(root, path, target, scheduledObserver);
+
+ this.one('willClearRender', function() {
+ Ember.removeObserver(root, path, target, scheduledObserver);
+ });
+ }
+
+});
+
+/*
+ Describe how the specified actions should behave in the various
+ states that a view can exist in. Possible states:
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
if (id) {
$element.attr('id', id);
@@ -19391,6 +29528,7 @@ Ember._RenderBuffer.prototype =
})();
+<<<<<<< HEAD
(function() {
/**
@@ -19399,6 +29537,13 @@ Ember._RenderBuffer.prototype =
*/
var get = Ember.get, set = Ember.set, fmt = Ember.String.fmt;
+=======
+ /**
+ Parse a path and return an object which holds the parsed properties.
+
+ For example a path like "content.isEnabled:enabled:disabled" will return the
+ following object:
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
/**
`Ember.EventDispatcher` handles delegating browser events to their
@@ -19406,12 +29551,25 @@ var get = Ember.get, set = Ember.set, fmt = Ember.String.fmt;
`Ember.EventDispatcher` ensures that that view's `mouseDown` method gets
called.
+<<<<<<< HEAD
@class EventDispatcher
@namespace Ember
@private
@extends Ember.Object
*/
Ember.EventDispatcher = Ember.Object.extend(/** @scope Ember.EventDispatcher.prototype */{
+=======
+ @method _parsePropertyPath
+ @static
+ @private
+ */
+ _parsePropertyPath: function(path) {
+ var split = path.split(':'),
+ propertyPath = split[0],
+ classNames = "",
+ className,
+ falsyClassName;
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
/**
The set of events names (and associated handler function names) to be setup
@@ -19455,19 +29613,34 @@ Ember.EventDispatcher = Ember.Object.extend(/** @scope Ember.EventDispatcher.pro
},
/**
+<<<<<<< HEAD
@private
The root DOM element to which event listeners should be attached. Event
listeners will be attached to the document unless this is overridden.
+=======
+ Get the class name for a given value, based on the path, optional
+ `className` and optional `falsyClassName`.
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
Can be specified as a DOMElement or a selector string.
+<<<<<<< HEAD
The default body is a string since this may be evaluated before document.body
exists in the DOM.
@property rootElement
@type DOMElement
@default 'body'
+=======
+ @method _classStringForValue
+ @param path
+ @param val
+ @param className
+ @param falsyClassName
+ @static
+ @private
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
*/
rootElement: 'body',
@@ -19517,9 +29690,24 @@ Ember.EventDispatcher = Ember.Object.extend(/** @scope Ember.EventDispatcher.pro
Registers an event listener on the document. If the given event is
triggered, the provided event handler will be triggered on the target view.
+<<<<<<< HEAD
If the target view does not implement the event handler, or if the handler
returns `false`, the parent view will be called. The event will continue to
bubble to each successive parent view until it reaches the top.
+=======
+ if (!value) {
+ elem.removeAttr(name);
+ }
+
+ if (value !== elem.prop(name)) {
+ // value and booleans should always be properties
+ elem.prop(name, value);
+ }
+ } else if (!value) {
+ elem.removeAttr(name);
+ }
+};
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
For example, to have the `mouseDown` method called on the target view when
a `mousedown` event is received from the browser, do the following:
@@ -19624,12 +29812,53 @@ Ember.EventDispatcher = Ember.Object.extend(/** @scope Ember.EventDispatcher.pro
@submodule ember-views
*/
+<<<<<<< HEAD
// Add a new named queue for rendering views that happens
// after bindings have synced, and a queue for scheduling actions
// that that should occur after view rendering.
var queues = Ember.run.queues,
indexOf = Ember.ArrayPolyfills.indexOf;
queues.splice(indexOf.call(queues, 'actions')+1, 0, 'render', 'afterRender');
+=======
+var preRender = Ember.View.states.preRender = Ember.create(Ember.View.states._default);
+
+Ember.merge(preRender, {
+ // a view leaves the preRender state once its element has been
+ // created (createElement).
+ insertElement: function(view, fn) {
+ view.createElement();
+ var viewCollection = view.viewHierarchyCollection();
+
+ viewCollection.trigger('willInsertElement');
+
+ fn.call(view);
+
+ // We transition to `inDOM` if the element exists in the DOM
+ var element = view.get('element');
+ while (element = element.parentNode) {
+ if (element === document) {
+ viewCollection.transitionTo('inDOM', false);
+ viewCollection.trigger('didInsertElement');
+ }
+ }
+
+ },
+
+ renderToBufferIfNeeded: function(view, buffer) {
+ view.renderToBuffer(buffer);
+ return true;
+ },
+
+ empty: Ember.K,
+
+ setElement: function(view, value) {
+ if (value !== null) {
+ view.transitionTo('hasElement');
+ }
+ return value;
+ }
+});
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
})();
@@ -19682,7 +29911,16 @@ Ember.ControllerMixin.reopen({
(function() {
+<<<<<<< HEAD
})();
+=======
+ empty: function() {
+ Ember.assert("Emptying a view in the inBuffer state is not allowed and " +
+ "should not happen under normal circumstances. Most likely " +
+ "there is a bug in your application. This may be due to " +
+ "excessive property change notifications.");
+ },
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
@@ -19866,6 +30104,13 @@ Ember.CoreView = Ember.Object.extend(Ember.Evented, Ember.ActionHandler, {
}
return method.apply(this, args);
}
+<<<<<<< HEAD
+=======
+
+ view.addBeforeObserver('elementId', function() {
+ throw new Ember.Error("Changing a view's elementId after creation is not allowed");
+ });
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
},
deprecatedSendHandles: function(actionName) {
@@ -19973,9 +30218,14 @@ ViewCollection.prototype = {
var EMPTY_ARRAY = [];
/**
+<<<<<<< HEAD
`Ember.View` is the class in Ember responsible for encapsulating templates of
HTML content, combining templates with data to render as sections of a page's
DOM, and registering and responding to user-initiated events.
+=======
+ A `ContainerView` is an `Ember.View` subclass that implements `Ember.MutableArray`
+ allowing programmatic management of its child views.
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
## HTML Tag
@@ -20006,7 +30256,16 @@ var EMPTY_ARRAY = [];
});
```
+<<<<<<< HEAD
Will result in view instances with an HTML representation of:
+=======
+ Each child view's rendering will be inserted into the container's rendered
+ HTML in the same order as its position in the `childViews` property.
+
+ ## Adding and Removing Child Views
+
+ The container view implements `Ember.MutableArray` allowing programmatic management of its child views.
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
```html
@@ -20083,6 +30342,7 @@ var EMPTY_ARRAY = [];
```
+<<<<<<< HEAD
Class name bindings can also refer to object values that are found by
traversing a path relative to the view itself:
@@ -20104,6 +30364,21 @@ var EMPTY_ARRAY = [];
If you want to add a class name for a property which evaluates to true and
and a different class name if it evaluates to false, you can pass a binding
like this:
+=======
+ ## Templates and Layout
+
+ A `template`, `templateName`, `defaultTemplate`, `layout`, `layoutName` or
+ `defaultLayout` property on a container view will not result in the template
+ or layout being rendered. The HTML contents of a `Ember.ContainerView`'s DOM
+ representation will only be the rendered HTML of its child views.
+
+ @class ContainerView
+ @namespace Ember
+ @extends Ember.View
+*/
+Ember.ContainerView = Ember.View.extend(Ember.MutableArray, {
+ states: states,
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
```javascript
// Applies 'enabled' class when isEnabled is true and 'disabled' when isEnabled is false
@@ -20160,6 +30435,7 @@ var EMPTY_ARRAY = [];
## HTML Attributes
+<<<<<<< HEAD
The HTML attribute section of a view's tag can be set by providing an
`attributeBindings` property set to an array of property names on the view.
The return value of these properties will be used as the value of the view's
@@ -20178,11 +30454,30 @@ var EMPTY_ARRAY = [];
```html
```
+=======
+ length: Ember.computed(function () {
+ return this._childViews.length;
+ }).volatile(),
+
+ /**
+ Instructs each child view to render to the passed render buffer.
+
+ @private
+ @method render
+ @param {Ember.RenderBuffer} buffer the buffer to render to
+ */
+ render: function(buffer) {
+ this.forEachChildView(function(view) {
+ view.renderToBuffer(buffer);
+ });
+ },
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
If the return value of an `attributeBindings` monitored property is a boolean
the property will follow HTML's pattern of repeating the attribute's name as
its value:
+<<<<<<< HEAD
```javascript
MyTextInput = Ember.View.extend({
tagName: 'input',
@@ -20192,12 +30487,28 @@ var EMPTY_ARRAY = [];
```
Will result in view instances with an HTML representation of:
+=======
+ /**
+ When a child view is removed, destroy its element so that
+ it is removed from the DOM.
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
```html
```
+<<<<<<< HEAD
`attributeBindings` can refer to computed properties:
+=======
+ @private
+ @method childViewsWillChange
+ @param {Ember.Array} views the child views array before mutation
+ @param {Number} start the start position of the mutation
+ @param {Number} removed the number of child views removed
+ **/
+ childViewsWillChange: function(views, start, removed) {
+ this.propertyWillChange('childViews');
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
```javascript
MyTextInput = Ember.View.extend({
@@ -20216,10 +30527,15 @@ var EMPTY_ARRAY = [];
Updates to the the property of an attribute binding will result in automatic
update of the HTML attribute in the view's rendered HTML representation.
+<<<<<<< HEAD
`attributeBindings` is a concatenated property. See [Ember.Object](/api/classes/Ember.Object.html)
documentation for more information about concatenated properties.
## Templates
+=======
+ /**
+ When a child view is added, make sure the DOM gets updated appropriately.
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
The HTML contents of a view's rendered representation are determined by its
template. Templates can be any function that accepts an optional context
@@ -20227,11 +30543,29 @@ var EMPTY_ARRAY = [];
view's tag. Most typically in Ember this function will be a compiled
`Ember.Handlebars` template.
+<<<<<<< HEAD
```javascript
AView = Ember.View.extend({
template: Ember.Handlebars.compile('I am the template')
});
```
+=======
+ @private
+ @method childViewsDidChange
+ @param {Ember.Array} views the array of child views afte the mutation has occurred
+ @param {Number} start the start position of the mutation
+ @param {Number} removed the number of child views removed
+ @param {Number} the number of child views added
+ */
+ childViewsDidChange: function(views, start, removed, added) {
+ if (added > 0) {
+ var changedViews = views.slice(start, start+added);
+ this.initializeViews(changedViews, this, get(this, 'templateData'));
+ this.currentState.childViewsDidChange(this, views, start, added);
+ }
+ this.propertyDidChange('childViews');
+ },
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
Will result in view instances with an HTML representation of:
@@ -20248,6 +30582,7 @@ var EMPTY_ARRAY = [];
```
+<<<<<<< HEAD
And associate it by name using a view's `templateName` property:
```javascript
@@ -20255,6 +30590,22 @@ var EMPTY_ARRAY = [];
templateName: 'some-template'
});
```
+=======
+ _currentViewWillChange: Ember.beforeObserver('currentView', function() {
+ var currentView = get(this, 'currentView');
+ if (currentView) {
+ currentView.destroy();
+ }
+ }),
+
+ _currentViewDidChange: Ember.observer('currentView', function() {
+ var currentView = get(this, 'currentView');
+ if (currentView) {
+ Ember.assert("You tried to set a current view that already has a parent. Make sure you don't have multiple outlets in the same view.", !get(currentView, '_parentView'));
+ this.pushObject(currentView);
+ }
+ }),
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
Using a value for `templateName` that does not have a Handlebars template
with a matching `data-template-name` attribute will throw an error.
@@ -20265,6 +30616,7 @@ var EMPTY_ARRAY = [];
template function. If a template is not later provided for the view instance
the `defaultTemplate` value will be used:
+<<<<<<< HEAD
```javascript
AView = Ember.View.extend({
defaultTemplate: Ember.Handlebars.compile('I was the default'),
@@ -20272,6 +30624,13 @@ var EMPTY_ARRAY = [];
templateName: null
});
```
+=======
+Ember.merge(states.inBuffer, {
+ childViewsDidChange: function(parentView, views, start, added) {
+ throw new Ember.Error('You cannot modify child views while in the inBuffer state');
+ }
+});
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
Will result in instances with an HTML representation of:
@@ -20412,8 +30771,16 @@ var EMPTY_ARRAY = [];
});
```
+<<<<<<< HEAD
An event defined for an event manager takes precedence over events of the
same name handled through methods on the view.
+=======
+ ## Programmatic creation of child views
+
+ For cases where additional customization beyond the use of a single
+ `itemViewClass` or `tagName` matching is required CollectionView's
+ `createChildView` method can be overidden:
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
```javascript
AView = Ember.View.extend({
@@ -20471,6 +30838,7 @@ var EMPTY_ARRAY = [];
built-in events exists in `Ember.EventDispatcher`.) Additional, custom events
can be registered by using `Ember.Application.customEvents`.
+<<<<<<< HEAD
Touch events:
* `touchStart`
@@ -20479,6 +30847,15 @@ var EMPTY_ARRAY = [];
* `touchCancel`
Keyboard events
+=======
+
+ @class CollectionView
+ @namespace Ember
+ @extends Ember.ContainerView
+ @since Ember 0.9
+*/
+Ember.CollectionView = Ember.ContainerView.extend({
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
* `keyDown`
* `keyUp`
@@ -20486,6 +30863,7 @@ var EMPTY_ARRAY = [];
Mouse events
+<<<<<<< HEAD
* `mouseDown`
* `mouseUp`
* `contextMenu`
@@ -20504,6 +30882,17 @@ var EMPTY_ARRAY = [];
* `focusIn`
* `focusOut`
* `input`
+=======
+ /**
+ This provides metadata about what kind of empty view class this
+ collection would like if it is being instantiated from another
+ system (like Handlebars)
+
+ @private
+ @property emptyViewClass
+ */
+ emptyViewClass: Ember.View,
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
HTML5 drag and drop events:
@@ -20516,6 +30905,7 @@ var EMPTY_ARRAY = [];
## Handlebars `{{view}}` Helper
+<<<<<<< HEAD
Other `Ember.View` instances can be included as part of a view's template by
using the `{{view}}` Handlebars helper. See [Ember.Handlebars.helpers.view](/api/classes/Ember.Handlebars.helpers.html#method_view)
for additional information.
@@ -20536,11 +30926,51 @@ Ember.View = Ember.CoreView.extend(
@final
*/
isView: true,
+=======
+ /**
+ Setup a CollectionView
+
+ @method init
+ */
+ init: function() {
+ var ret = this._super();
+ this._contentDidChange();
+ return ret;
+ },
+
+ /**
+ Invoked when the content property is about to change. Notifies observers that the
+ entire array content will change.
+
+ @private
+ @method _contentWillChange
+ */
+ _contentWillChange: Ember.beforeObserver('content', function() {
+ var content = this.get('content');
+
+ if (content) { content.removeArrayObserver(this); }
+ var len = content ? get(content, 'length') : 0;
+ this.arrayWillChange(content, 0, len);
+ }),
+
+ /**
+ Check to make sure that the content has changed, and if so,
+ update the children directly. This is always scheduled
+ asynchronously, to allow the element to be created before
+ bindings have synchronized and vice versa.
+
+ @private
+ @method _contentDidChange
+ */
+ _contentDidChange: Ember.observer('content', function() {
+ var content = get(this, 'content');
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
// ..........................................................
// TEMPLATE SUPPORT
//
+<<<<<<< HEAD
/**
The name of the template to lookup if no template is provided.
@@ -20552,6 +30982,29 @@ Ember.View = Ember.CoreView.extend(
@default null
*/
templateName: null,
+=======
+ var len = content ? get(content, 'length') : 0;
+ this.arrayDidChange(content, 0, null, len);
+ }),
+
+ /**
+ Ensure that the content implements Ember.Array
+
+ @private
+ @method _assertArrayLike
+ */
+ _assertArrayLike: function(content) {
+ Ember.assert(fmt("an Ember.CollectionView's content must implement Ember.Array. You passed %@", [content]), Ember.Array.detect(content));
+ },
+
+ /**
+ Removes the content and content observers.
+
+ @method destroy
+ */
+ destroy: function() {
+ if (!this._super()) { return; }
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
/**
The name of the layout to lookup if no layout is provided.
@@ -20566,9 +31019,31 @@ Ember.View = Ember.CoreView.extend(
layoutName: null,
/**
+<<<<<<< HEAD
The template used to render the view. This should be a function that
accepts an optional context parameter and returns a string of HTML that
will be inserted into the DOM relative to its parent view.
+=======
+ Called when a mutation to the underlying content array will occur.
+
+ This method will remove any views that are no longer in the underlying
+ content array.
+
+ Invokes whenever the content array itself will change.
+
+ @method arrayWillChange
+ @param {Array} content the managed collection of objects
+ @param {Number} start the index at which the changes will occurr
+ @param {Number} removed number of object to be removed from content
+ */
+ arrayWillChange: function(content, start, removedCount) {
+ // If the contents were empty before and this template collection has an
+ // empty view remove it now.
+ var emptyView = get(this, 'emptyView');
+ if (emptyView && emptyView instanceof Ember.View) {
+ emptyView.removeFromParent();
+ }
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
In general, you should set the `templateName` property instead of setting
the template yourself.
@@ -20674,10 +31149,30 @@ Ember.View = Ember.CoreView.extend(
checks to see whether the view has a specified controller. This is
something of a hack and should be revisited.
+<<<<<<< HEAD
@property _context
*/
_context: Ember.computed(function(key) {
var parentView, controller;
+=======
+ /**
+ Instantiates a view to be added to the childViews array during view
+ initialization. You generally will not call this method directly unless
+ you are overriding `createChildViews()`. Note that this method will
+ automatically configure the correct settings on the new view instance to
+ act as a child of the parent.
+
+ The tag name for the view will be set to the tagName of the viewClass
+ passed in.
+
+ @method createChildView
+ @param {Class} viewClass
+ @param {Hash} [attrs] Attributes to add
+ @return {Ember.View} new instance
+ */
+ createChildView: function(view, attrs) {
+ view = this._super(view, attrs);
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
if (controller = get(this, 'controller')) {
return controller;
@@ -20697,20 +31192,37 @@ Ember.View = Ember.CoreView.extend(
If a value that affects template rendering changes, the view should be
re-rendered to reflect the new value.
+<<<<<<< HEAD
@method _contextDidChange
*/
_contextDidChange: Ember.observer('context', function() {
this.rerender();
}),
+=======
+(function() {
+var get = Ember.get, set = Ember.set, isNone = Ember.isNone,
+ a_slice = Array.prototype.slice;
+
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
/**
If `false`, the view will appear hidden in DOM.
+<<<<<<< HEAD
@property isVisible
@type Boolean
@default null
*/
isVisible: true,
+=======
+/**
+ An `Ember.Component` is a view that is completely
+ isolated. Property access in its templates go
+ to the view object and actions are targeted at
+ the view object. There is no access to the
+ surrounding context or outer controller; all
+ contextual information must be passed in.
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
/**
@private
@@ -20718,6 +31230,7 @@ Ember.View = Ember.CoreView.extend(
Array of child views. You should never edit this array directly.
Instead, use `appendChild` and `removeFromParent`.
+<<<<<<< HEAD
@property childViews
@type Array
@default []
@@ -20747,6 +31260,39 @@ Ember.View = Ember.CoreView.extend(
/**
Return the nearest ancestor that is an instance of the provided
class.
+=======
+ ```html
+
+
{{person.title}}
+
+
{{person.signature}}
+ ```
+
+ You can use `yield` inside a template to
+ include the **contents** of any block attached to
+ the component. The block will be executed in the
+ context of the surrounding context or outer controller:
+
+ ```handlebars
+ {{#app-profile person=currentUser}}
+
Admin mode
+ {{! Executed in the controllers context. }}
+ {{/app-profile}}
+ ```
+
+ ```handlebars
+
+
" ],
+ map: [ 1, "" ],
+ _default: [ 0, "", "" ]
+ };
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
This is not typically a function that you will need to call directly when
building your application. You might consider using `Ember.ContainerView`
@@ -21178,6 +31944,7 @@ Ember.View = Ember.CoreView.extend(
element will not be appended to the given element until all bindings have
finished synchronizing
+<<<<<<< HEAD
@method replaceIn
@param {String|DOMElement|jQuery} A selector, element, HTML string, or jQuery object
@return {Ember.View} received
@@ -21185,6 +31952,17 @@ Ember.View = Ember.CoreView.extend(
replaceIn: function(target) {
Ember.assert("You tried to replace in (" + target + ") but that isn't in the DOM", Ember.$(target).length > 0);
Ember.assert("You cannot replace an existing Ember.View. Consider using Ember.ContainerView instead.", !Ember.$(target).is('.ember-view') && !Ember.$(target).parents().is('.ember-view'));
+=======
+ /*
+ * Given a parent node and some HTML, generate a set of nodes. Return the first
+ * node, which will allow us to traverse the rest using nextSibling.
+ *
+ * We need to do this because innerHTML in IE does not really parse the nodes.
+ */
+ var firstNodeFor = function(parentNode, html) {
+ var arr = wrapMap[parentNode.tagName.toLowerCase()] || wrapMap._default;
+ var depth = arr[0], start = arr[1], end = arr[2];
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
this._insertElementLater(function() {
Ember.$(target).empty();
@@ -24070,6 +34848,10 @@ define("metamorph",
// swallow some of the content.
node = firstNodeFor(start.parentNode, html);
+ if (outerToo) {
+ start.parentNode.removeChild(start);
+ }
+
// copy the nodes for the HTML between the starting and ending
// placeholder.
while (node) {
@@ -24194,13 +34976,24 @@ var objectCreate = Object.create || function(parent) {
return new F();
};
-var Handlebars = this.Handlebars || (Ember.imports && Ember.imports.Handlebars);
+var Handlebars = (Ember.imports && Ember.imports.Handlebars) || (this && this.Handlebars);
if (!Handlebars && typeof require === 'function') {
Handlebars = require('handlebars');
}
+<<<<<<< HEAD
Ember.assert("Ember Handlebars requires Handlebars version 1.0 or 1.1. Include a SCRIPT tag in the HTML HEAD linking to the Handlebars file before you link to Ember.", Handlebars);
Ember.assert("Ember Handlebars requires Handlebars version 1.0 or 1.1, COMPILER_REVISION expected: 4, got: " + Handlebars.COMPILER_REVISION + " - Please note: Builds of master may have other COMPILER_REVISION values.", Handlebars.COMPILER_REVISION === 4);
+=======
+Ember.assert("Ember Handlebars requires Handlebars version 1.0 or 1.1. Include " +
+ "a SCRIPT tag in the HTML HEAD linking to the Handlebars file " +
+ "before you link to Ember.", Handlebars);
+
+Ember.assert("Ember Handlebars requires Handlebars version 1.0 or 1.1, " +
+ "COMPILER_REVISION expected: 4, got: " + Handlebars.COMPILER_REVISION +
+ " - Please note: Builds of master may have other COMPILER_REVISION values.",
+ Handlebars.COMPILER_REVISION === 4);
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
/**
Prepares the Handlebars templating library for use inside Ember's view
@@ -24282,20 +35075,31 @@ Ember.Handlebars.helper = function(name, value) {
};
/**
+<<<<<<< HEAD
@private
+=======
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
Returns a helper function that renders the provided ViewClass.
Used internally by Ember.Handlebars.helper and other methods
involving helper/component registration.
+<<<<<<< HEAD
+=======
+ @private
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
@method helper
@for Ember.Handlebars
@param {Function} ViewClass view class constructor
*/
Ember.Handlebars.makeViewHelper = function(ViewClass) {
return function(options) {
+<<<<<<< HEAD
Ember.assert("You can only pass attributes (such as name=value) not bare values to a helper for a View", arguments.length < 2);
+=======
+ Ember.assert("You can only pass attributes (such as name=value) not bare values to a helper for a View found in '" + ViewClass.toString() + "'", arguments.length < 2);
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
return Ember.Handlebars.helpers.view.call(this, ViewClass, options);
};
};
@@ -24345,12 +35149,11 @@ Ember.Handlebars.JavaScriptCompiler.prototype.initializeBuffer = function() {
};
/**
- @private
-
Override the default buffer for Ember Handlebars. By default, Handlebars
creates an empty String at the beginning of each invocation and appends to
it. Ember's Handlebars overrides this to append to a single shared buffer.
+ @private
@method appendToBuffer
@param string {String}
*/
@@ -24368,7 +35171,11 @@ Ember.Handlebars.JavaScriptCompiler.prototype.appendToBuffer = function(string)
// instead, as expected.
//
// This can go away once the following is closed:
+<<<<<<< HEAD
// https://github.com/wycats/handlebars.js/issues/617
+=======
+// https://github.com/wycats/handlebars.js/issues/634
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
var DOT_LOOKUP_REGEX = /helpers\.(.*?)\)/,
BRACKET_STRING_LOOKUP_REGEX = /helpers\['(.*?)'/,
@@ -24398,12 +35205,11 @@ Ember.Handlebars.JavaScriptCompiler.prototype.ambiguousBlockValue = function() {
var prefix = "ember" + (+new Date()), incr = 1;
/**
- @private
-
Rewrite simple mustaches from `{{foo}}` to `{{bind "foo"}}`. This means that
all simple mustaches in Ember's Handlebars will also set up an observer to
keep the DOM up to date when the underlying property changes.
+ @private
@method mustache
@for Ember.Handlebars.Compiler
@param mustache
@@ -24446,7 +35252,7 @@ Ember.Handlebars.precompile = function(string) {
knownHelpers: {
action: true,
unbound: true,
- bindAttr: true,
+ 'bind-attr': true,
template: true,
view: true,
_triageMustache: true
@@ -24493,11 +35299,10 @@ var slice = Array.prototype.slice,
originalTemplate = Ember.Handlebars.template;
/**
- @private
-
If a path starts with a reserved keyword, returns the root
that should be used.
+ @private
@method normalizePath
@for Ember
@param root {Object}
@@ -24551,19 +35356,17 @@ var handlebarsGet = Ember.Handlebars.get = function(root, path, options) {
normalizedPath = normalizePath(root, path, data),
value;
- // In cases where the path begins with a keyword, change the
- // root to the value represented by that keyword, and ensure
- // the path is relative to it.
- root = normalizedPath.root;
- path = normalizedPath.path;
+
+ root = normalizedPath.root;
+ path = normalizedPath.path;
- value = Ember.get(root, path);
+ value = Ember.get(root, path);
+
+ if (value === undefined && root !== Ember.lookup && Ember.isGlobalPath(path)) {
+ value = Ember.get(Ember.lookup, path);
+ }
+
- // If the path starts with a capital letter, look it up on Ember.lookup,
- // which defaults to the `window` object in browsers.
- if (value === undefined && root !== Ember.lookup && Ember.isGlobalPath(path)) {
- value = Ember.get(Ember.lookup, path);
- }
return value;
};
@@ -24603,8 +35406,6 @@ Ember.Handlebars.resolveHash = function(context, hash, options) {
};
/**
- @private
-
Registers a helper in Handlebars that will be called if no property with the
given name can be found on the current context object, and no helper with
that name is registered.
@@ -24612,6 +35413,7 @@ Ember.Handlebars.resolveHash = function(context, hash, options) {
This throws an exception with a more helpful error message so the user can
track down where the problem is happening.
+ @private
@method helperMissing
@for Ember.Handlebars.helpers
@param {String} path
@@ -24622,6 +35424,7 @@ Ember.Handlebars.registerHelper('helperMissing', function(path) {
var options = arguments[arguments.length - 1];
+<<<<<<< HEAD
var helper = Ember.Handlebars.resolveHelper(options.data.view.container, path);
@@ -24630,6 +35433,13 @@ Ember.Handlebars.registerHelper('helperMissing', function(path) {
return helper.apply(this, slice.call(arguments, 1));
}
+=======
+ var helper = Ember.Handlebars.resolveHelper(options.data.view.container, path);
+
+ if (helper) {
+ return helper.apply(this, slice.call(arguments, 1));
+ }
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
error = "%@ Handlebars error: Could not find property '%@' on object %@.";
if (options.data) {
@@ -24639,8 +35449,11 @@ Ember.Handlebars.registerHelper('helperMissing', function(path) {
});
/**
+<<<<<<< HEAD
@private
+=======
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
Registers a helper in Handlebars that will be called if no property with the
given name can be found on the current context object, and no helper with
that name is registered.
@@ -24648,6 +35461,10 @@ Ember.Handlebars.registerHelper('helperMissing', function(path) {
This throws an exception with a more helpful error message so the user can
track down where the problem is happening.
+<<<<<<< HEAD
+=======
+ @private
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
@method helperMissing
@for Ember.Handlebars.helpers
@param {String} path
@@ -24657,6 +35474,7 @@ Ember.Handlebars.registerHelper('blockHelperMissing', function(path) {
var options = arguments[arguments.length - 1];
+<<<<<<< HEAD
Ember.assert("`blockHelperMissing` was invoked without a helper name, which is most likely due to a mismatch between the version of Ember.js you're running now and the one used to precompile your templates. Please make sure the version of `ember-handlebars-compiler` you're using is up to date.", path);
@@ -24667,6 +35485,21 @@ Ember.Handlebars.registerHelper('blockHelperMissing', function(path) {
return helper.apply(this, slice.call(arguments, 1));
}
+=======
+ Ember.assert("`blockHelperMissing` was invoked without a helper name, which " +
+ "is most likely due to a mismatch between the version of " +
+ "Ember.js you're running now and the one used to precompile your " +
+ "templates. Please make sure the version of " +
+ "`ember-handlebars-compiler` you're using is up to date.", path);
+
+ var helper = Ember.Handlebars.resolveHelper(options.data.view.container, path);
+
+ if (helper) {
+ return helper.apply(this, slice.call(arguments, 1));
+ } else {
+ return Handlebars.helpers.helperMissing.call(this, path);
+ }
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
return Handlebars.helpers.blockHelperMissing.apply(this, arguments);
});
@@ -24787,8 +35620,11 @@ Ember.Handlebars.registerBoundHelper = function(name, fn) {
};
/**
+<<<<<<< HEAD
@private
+=======
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
A (mostly) private helper function to `registerBoundHelper`. Takes the
provided Handlebars helper function fn and returns it in wrapped
bound helper form.
@@ -24807,6 +35643,10 @@ Ember.Handlebars.registerBoundHelper = function(name, fn) {
In the above example, if the helper function hadn't been wrapped in
`makeBoundHelper`, the registered helper would be unbound.
+<<<<<<< HEAD
+=======
+ @private
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
@method makeBoundHelper
@for Ember.Handlebars
@param {Function} function
@@ -24822,6 +35662,7 @@ Ember.Handlebars.makeBoundHelper = function(fn) {
normalizedProperties = [],
types = options.types,
data = options.data,
+ types = data.isUnbound ? slice.call(options.types, 1) : options.types,
hash = options.hash,
view = data.view,
contexts = options.contexts,
@@ -24852,7 +35693,15 @@ Ember.Handlebars.makeBoundHelper = function(fn) {
normalizedProperties.push(normalizedProp);
watchedProperties.push(normalizedProp);
} else {
+<<<<<<< HEAD
normalizedProperties.push(null);
+=======
+ if(data.isUnbound) {
+ normalizedProperties.push({path: properties[loc]});
+ }else {
+ normalizedProperties.push(null);
+ }
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
}
}
@@ -24930,10 +35779,12 @@ Ember.Handlebars.makeBoundHelper = function(fn) {
};
/**
- @private
-
Renders the unbound form of an otherwise bound helper function.
+<<<<<<< HEAD
+=======
+ @private
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
@method evaluateUnboundHelper
@param {Function} fn
@param {Object} context
@@ -24941,7 +35792,15 @@ Ember.Handlebars.makeBoundHelper = function(fn) {
@param {String} options
*/
function evaluateUnboundHelper(context, fn, normalizedProperties, options) {
- var args = [], hash = options.hash, boundOptions = hash.boundOptions, loc, len, property, boundOption;
+ var args = [],
+ hash = options.hash,
+ boundOptions = hash.boundOptions,
+ types = slice.call(options.types, 1),
+ loc,
+ len,
+ property,
+ propertyType,
+ boundOption;
for (boundOption in boundOptions) {
if (!boundOptions.hasOwnProperty(boundOption)) { continue; }
@@ -24950,18 +35809,26 @@ function evaluateUnboundHelper(context, fn, normalizedProperties, options) {
for(loc = 0, len = normalizedProperties.length; loc < len; ++loc) {
property = normalizedProperties[loc];
+<<<<<<< HEAD
args.push(Ember.Handlebars.get(property.root, property.path, options));
+=======
+ propertyType = types[loc];
+ if(propertyType === "ID") {
+ args.push(Ember.Handlebars.get(property.root, property.path, options));
+ } else {
+ args.push(property.path);
+ }
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
}
args.push(options);
return fn.apply(context, args);
}
/**
- @private
-
Overrides Handlebars.template so that we can distinguish
user-created, top-level templates from inner contexts.
+ @private
@method template
@for Ember.Handlebars
@param {String} spec
@@ -25081,7 +35948,7 @@ var DOMManager = {
view.transitionTo('preRender');
- Ember.run.schedule('render', this, function() {
+ Ember.run.schedule('render', this, function renderMetamorphView() {
if (view.isDestroying) { return; }
view.clearRenderedChildren();
@@ -25513,6 +36380,7 @@ Ember._HandlebarsBoundView = Ember._MetamorphView.extend({
var get = Ember.get, set = Ember.set, fmt = Ember.String.fmt;
var handlebarsGet = Ember.Handlebars.get, normalizePath = Ember.Handlebars.normalizePath;
var forEach = Ember.ArrayPolyfills.forEach;
+var o_create = Ember.create;
var EmberHandlebars = Ember.Handlebars, helpers = EmberHandlebars.helpers;
@@ -25643,8 +36511,11 @@ function simpleBind(currentContext, property, options) {
}
/**
+<<<<<<< HEAD
@private
+=======
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
'_triageMustache' is used internally select between a binding, helper, or component for
the given context. Until this point, it would be hard to determine if the
mustache is a property reference or a regular helper reference. This triage
@@ -25652,6 +36523,7 @@ function simpleBind(currentContext, property, options) {
This would not be typically invoked by directly.
+ @private
@method _triageMustache
@for Ember.Handlebars.helpers
@param {String} property Property/helperID to triage
@@ -25663,6 +36535,7 @@ EmberHandlebars.registerHelper('_triageMustache', function(property, options) {
if (helpers[property]) {
return helpers[property].call(this, options);
+<<<<<<< HEAD
}
@@ -25676,6 +36549,37 @@ EmberHandlebars.registerHelper('_triageMustache', function(property, options) {
return helpers.bind.call(this, property, options);
});
+Ember.Handlebars.resolveHelper = function(container, name) {
+
+ if (!container || name.indexOf('-') === -1) {
+ return;
+ }
+
+ var helper = container.lookup('helper:' + name);
+ if (!helper) {
+ var componentLookup = container.lookup('component-lookup:main');
+ Ember.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) {
+ helper = EmberHandlebars.makeViewHelper(Component);
+ container.register('helper:' + name, helper);
+ }
+ }
+ return helper;
+};
+=======
+ }
+
+ var helper = Ember.Handlebars.resolveHelper(options.data.view.container, property);
+ if (helper) {
+ return helper.call(this, options);
+ }
+
+ return helpers.bind.call(this, property, options);
+});
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
+
Ember.Handlebars.resolveHelper = function(container, name) {
if (!container || name.indexOf('-') === -1) {
@@ -25697,8 +36601,6 @@ Ember.Handlebars.resolveHelper = function(container, name) {
};
/**
- @private
-
`bind` can be used to display a value, then update that value if it
changes. For example, if you wanted to print the `title` property of
`content`:
@@ -25714,13 +36616,14 @@ Ember.Handlebars.resolveHelper = function(container, name) {
relies on Ember's KVO system. For all other browsers this will be handled for
you automatically.
+ @private
@method bind
@for Ember.Handlebars.helpers
@param {String} property Property to bind
@param {Function} fn Context to provide for rendering
@return {String} HTML string
*/
-EmberHandlebars.registerHelper('bind', function(property, options) {
+EmberHandlebars.registerHelper('bind', function bindHelper(property, options) {
Ember.assert("You cannot pass more than one argument to the bind helper", arguments.length <= 2);
var context = (options.contexts && options.contexts.length) ? options.contexts[0] : this;
@@ -25733,8 +36636,6 @@ EmberHandlebars.registerHelper('bind', function(property, options) {
});
/**
- @private
-
Use the `boundIf` helper to create a conditional that re-evaluates
whenever the truthiness of the bound value changes.
@@ -25744,13 +36645,18 @@ EmberHandlebars.registerHelper('bind', function(property, options) {
{{/boundIf}}
```
+ @private
@method boundIf
@for Ember.Handlebars.helpers
@param {String} property Property to bind
@param {Function} fn Context to provide for rendering
@return {String} HTML string
*/
+<<<<<<< HEAD
EmberHandlebars.registerHelper('boundIf', function(property, fn) {
+=======
+EmberHandlebars.registerHelper('boundIf', function boundIfHelper(property, fn) {
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
var context = (fn.contexts && fn.contexts.length) ? fn.contexts[0] : this;
var func = function(result) {
var truthy = result && get(result, 'isTruthy');
@@ -25767,15 +36673,65 @@ EmberHandlebars.registerHelper('boundIf', function(property, fn) {
});
/**
+ Use the `{{with}}` helper when you want to scope context. Take the following code as an example:
+
+ ```handlebars
+
{{user.name}}
+
+
+
{{user.role.label}}
+ {{user.role.id}}
+
+
{{user.role.description}}
+
+ ```
+
+ `{{with}}` can be our best friend in these cases,
+ instead of writing `user.role.*` over and over, we use `{{#with user.role}}`.
+ Now the context within the `{{#with}} .. {{/with}}` block is `user.role` so you can do the following:
+
+ ```handlebars
+
{{user.name}}
+
+
+ {{#with user.role}}
+
{{label}}
+ {{id}}
+
+
{{description}}
+ {{/with}}
+
+ ```
+
+ ### `as` operator
+
+ This operator aliases the scope 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}}
+
+ There are {{blogPosts.length}} blog posts written by {{user.name}}.
+
+
+ {{#each post in blogPosts}}
+
{{post.title}}
+ {{/each}}
+ {{/with}}
+ ```
+
+ Without the `as` operator, it would be impossible to reference `user.name` in the example above.
+
@method with
@for Ember.Handlebars.helpers
@param {Function} context
@param {Hash} options
@return {String} HTML string
*/
-EmberHandlebars.registerHelper('with', function(context, options) {
+EmberHandlebars.registerHelper('with', function withHelper(context, options) {
if (arguments.length === 4) {
- var keywordName, path, rootPath, normalized;
+ var keywordName, path, rootPath, normalized, contextPath;
Ember.assert("If you pass more than one argument to the with helper, it must be in the form #with foo as bar", arguments[1] === "as");
options = arguments[3];
@@ -25784,8 +36740,12 @@ EmberHandlebars.registerHelper('with', function(context, options) {
Ember.assert("You must pass a block to the with helper", options.fn && options.fn !== Handlebars.VM.noop);
+ var localizedOptions = o_create(options);
+ localizedOptions.data = o_create(options.data);
+ localizedOptions.data.keywords = o_create(options.data.keywords || {});
+
if (Ember.isGlobalPath(path)) {
- Ember.bind(options.data.keywords, keywordName, path);
+ contextPath = path;
} else {
normalized = normalizePath(this, path, options.data);
path = normalized.path;
@@ -25794,14 +36754,14 @@ EmberHandlebars.registerHelper('with', function(context, options) {
// This is a workaround for the fact that you cannot bind separate objects
// together. When we implement that functionality, we should use it here.
var contextKey = Ember.$.expando + Ember.guidFor(rootPath);
- options.data.keywords[contextKey] = rootPath;
-
+ localizedOptions.data.keywords[contextKey] = rootPath;
// if the path is '' ("this"), just bind directly to the current context
- var contextPath = path ? contextKey + '.' + path : contextKey;
- Ember.bind(options.data.keywords, keywordName, contextPath);
+ contextPath = path ? contextKey + '.' + path : contextKey;
}
- return bind.call(this, path, options, true, exists);
+ Ember.bind(localizedOptions.data.keywords, keywordName, contextPath);
+
+ return bind.call(this, path, localizedOptions, true, exists);
} else {
Ember.assert("You must pass exactly one argument to the with helper", arguments.length === 2);
Ember.assert("You must pass a block to the with helper", options.fn && options.fn !== Handlebars.VM.noop);
@@ -25819,7 +36779,7 @@ EmberHandlebars.registerHelper('with', function(context, options) {
@param {Hash} options
@return {String} HTML string
*/
-EmberHandlebars.registerHelper('if', function(context, options) {
+EmberHandlebars.registerHelper('if', function ifHelper(context, options) {
Ember.assert("You must pass exactly one argument to the if helper", arguments.length === 2);
Ember.assert("You must pass a block to the if helper", options.fn && options.fn !== Handlebars.VM.noop);
@@ -25833,7 +36793,7 @@ EmberHandlebars.registerHelper('if', function(context, options) {
@param {Hash} options
@return {String} HTML string
*/
-EmberHandlebars.registerHelper('unless', function(context, options) {
+EmberHandlebars.registerHelper('unless', function unlessHelper(context, options) {
Ember.assert("You must pass exactly one argument to the unless helper", arguments.length === 2);
Ember.assert("You must pass a block to the unless helper", options.fn && options.fn !== Handlebars.VM.noop);
@@ -25968,7 +36928,11 @@ EmberHandlebars.registerHelper('unless', function(context, options) {
@param {Hash} options
@return {String} HTML string
*/
+<<<<<<< HEAD
EmberHandlebars.registerHelper('bind-attr', function(options) {
+=======
+EmberHandlebars.registerHelper('bind-attr', function bindAttrHelper(options) {
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
var attrs = options.hash;
@@ -26014,7 +36978,9 @@ EmberHandlebars.registerHelper('bind-attr', function(options) {
observer = function observer() {
var result = handlebarsGet(ctx, path, options);
- Ember.assert(fmt("Attributes must be numbers, strings or booleans, not %@", [result]), result === null || result === undefined || typeof result === 'number' || typeof result === 'string' || typeof result === 'boolean');
+ Ember.assert(fmt("Attributes must be numbers, strings or booleans, not %@", [result]),
+ result === null || result === undefined || typeof result === 'number' ||
+ typeof result === 'string' || typeof result === 'boolean');
var elem = view.$("[data-bindattr-" + dataId + "='" + dataId + "']");
@@ -26064,11 +37030,19 @@ EmberHandlebars.registerHelper('bind-attr', function(options) {
@param {Hash} options
@return {String} HTML string
*/
+<<<<<<< HEAD
EmberHandlebars.registerHelper('bindAttr', EmberHandlebars.helpers['bind-attr']);
/**
@private
+=======
+EmberHandlebars.registerHelper('bindAttr', function bindAttrHelper() {
+ Ember.warn("The 'bindAttr' view helper is deprecated in favor of 'bind-attr'");
+ return EmberHandlebars.helpers['bind-attr'].apply(this, arguments);
+});
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
+/**
Helper that, given a space-separated string of property paths and a context,
returns an array of class names. Calling this method also has the side
effect of setting up observers at those property paths, such that if they
@@ -26080,6 +37054,7 @@ EmberHandlebars.registerHelper('bindAttr', EmberHandlebars.helpers['bind-attr'])
"fooBar"). If the value is a string, it will add that string as the class.
Otherwise, it will not add any new class name.
+ @private
@method bindClasses
@for Ember.Handlebars
@param {Ember.Object} context The context from which to lookup properties
@@ -26327,7 +37302,7 @@ EmberHandlebars.ViewHelper = Ember.Object.create({
return 'templateData.keywords.' + path;
} else if (Ember.isGlobalPath(path)) {
return null;
- } else if (path === 'this') {
+ } else if (path === 'this' || path === '') {
return '_parentView.context';
} else {
return '_parentView.context.' + path;
@@ -26546,7 +37521,7 @@ EmberHandlebars.ViewHelper = Ember.Object.create({
@param {Hash} options
@return {String} HTML string
*/
-EmberHandlebars.registerHelper('view', function(path, options) {
+EmberHandlebars.registerHelper('view', function viewHelper(path, options) {
Ember.assert("The view helper only takes a single argument", arguments.length <= 2);
// If no path is provided, treat path param as options.
@@ -26564,8 +37539,6 @@ EmberHandlebars.registerHelper('view', function(path, options) {
(function() {
-/*globals Handlebars */
-
// TODO: Don't require all of this module
/**
@module ember
@@ -26696,7 +37669,7 @@ var get = Ember.get, handlebarsGet = Ember.Handlebars.get, fmt = Ember.String.fm
@return {String} HTML string
@deprecated Use `{{each}}` helper instead.
*/
-Ember.Handlebars.registerHelper('collection', function(path, options) {
+Ember.Handlebars.registerHelper('collection', function collectionHelper(path, options) {
Ember.deprecate("Using the {{collection}} helper without specifying a class has been deprecated as the {{each}} helper now supports the same functionality.", path !== 'collection');
// If no path is provided, treat path param as options.
@@ -26727,10 +37700,21 @@ Ember.Handlebars.registerHelper('collection', function(path, options) {
if (hash.itemView) {
var controller = data.keywords.controller;
- Ember.assert('You specified an itemView, but the current context has no container to look the itemView up in. This probably means that you created a view manually, instead of through the container. Instead, use container.lookup("view:viewName"), which will properly instantiate your view.', controller && controller.container);
+ Ember.assert('You specified an itemView, but the current context has no ' +
+ 'container to look the itemView up in. This probably means ' +
+ 'that you created a view manually, instead of through the ' +
+ 'container. Instead, use container.lookup("view:viewName"), ' +
+ 'which will properly instantiate your view.',
+ controller && controller.container);
var container = controller.container;
itemViewClass = container.resolve('view:' + hash.itemView);
+<<<<<<< HEAD
Ember.assert('You specified the itemView ' + hash.itemView + ", but it was not found at " + container.describe("view:" + hash.itemView) + " (and it was not registered in the container)", !!itemViewClass);
+=======
+ Ember.assert('You specified the itemView ' + hash.itemView + ", but it was " +
+ "not found at " + container.describe("view:" + hash.itemView) +
+ " (and it was not registered in the container)", !!itemViewClass);
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
} else if (hash.itemViewClass) {
itemViewClass = handlebarsGet(collectionPrototype, hash.itemViewClass, options);
} else {
@@ -26764,7 +37748,7 @@ Ember.Handlebars.registerHelper('collection', function(path, options) {
}
var emptyViewClass;
- if (inverse && inverse !== Handlebars.VM.noop) {
+ if (inverse && inverse !== Ember.Handlebars.VM.noop) {
emptyViewClass = get(collectionPrototype, 'emptyViewClass');
emptyViewClass = emptyViewClass.extend({
template: inverse,
@@ -26819,13 +37803,13 @@ var handlebarsGet = Ember.Handlebars.get;
@param {String} property
@return {String} HTML string
*/
-Ember.Handlebars.registerHelper('unbound', function(property, fn) {
+Ember.Handlebars.registerHelper('unbound', function unboundHelper(property, fn) {
var options = arguments[arguments.length - 1], helper, context, out;
if (arguments.length > 2) {
// Unbound helper call.
options.data.isUnbound = true;
- helper = Ember.Handlebars.helpers[arguments[0]] || Ember.Handlebars.helperMissing;
+ helper = Ember.Handlebars.helpers[arguments[0]] || Ember.Handlebars.helpers.helperMissing;
out = helper.apply(this, Array.prototype.slice.call(arguments, 1));
delete options.data.isUnbound;
return out;
@@ -26846,7 +37830,7 @@ Ember.Handlebars.registerHelper('unbound', function(property, fn) {
@submodule ember-handlebars
*/
-var handlebarsGet = Ember.Handlebars.get, normalizePath = Ember.Handlebars.normalizePath;
+var get = Ember.get, handlebarsGet = Ember.Handlebars.get, normalizePath = Ember.Handlebars.normalizePath;
/**
`log` allows you to output the value of a variable in the current rendering
@@ -26860,7 +37844,11 @@ var handlebarsGet = Ember.Handlebars.get, normalizePath = Ember.Handlebars.norma
@for Ember.Handlebars.helpers
@param {String} property
*/
+<<<<<<< HEAD
Ember.Handlebars.registerHelper('log', function(property, options) {
+=======
+Ember.Handlebars.registerHelper('log', function logHelper(property, options) {
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
var context = (options.contexts && options.contexts.length) ? options.contexts[0] : this,
normalized = normalizePath(context, property, options.data),
pathRoot = normalized.root,
@@ -26876,14 +37864,44 @@ Ember.Handlebars.registerHelper('log', function(property, options) {
{{debugger}}
```
+ Before invoking the `debugger` statement, there
+ are a few helpful variables defined in the
+ body of this helper that you can inspect while
+ debugging that describe how and where this
+ helper was invoked:
+
+ - templateContext: this is most likely a controller
+ from which this template looks up / displays properties
+ - typeOfTemplateContext: a string description of
+ what the templateContext is
+
+ 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 inspect
+ `templateContext`, determine if it's the object you
+ expect, and/or evaluate expressions in the console
+ to perform property lookups on the `templateContext`:
+
+ ```
+ > templateContext.get('foo') // -> ""
+ ```
+
@method debugger
@for Ember.Handlebars.helpers
@param {String} property
*/
-Ember.Handlebars.registerHelper('debugger', function(options) {
+Ember.Handlebars.registerHelper('debugger', function debuggerHelper(options) {
+
+ // These are helpful values you can inspect while debugging.
+ var templateContext = this;
+ var typeOfTemplateContext = Ember.inspect(templateContext);
+
debugger;
});
+
+
})();
@@ -27262,7 +38280,7 @@ GroupedEach.prototype = {
@param [options.itemController] {String} name of a controller to be created for each item
@param [options.groupedRows] {boolean} enable normal item-by-item rendering when inside a `#group` helper
*/
-Ember.Handlebars.registerHelper('each', function(path, options) {
+Ember.Handlebars.registerHelper('each', function eachHelper(path, options) {
if (arguments.length === 4) {
Ember.assert("If you pass more than one argument to the each helper, it must be in the form #each foo in bar", arguments[1] === "in");
@@ -27410,7 +38428,11 @@ Ember.Handlebars.registerHelper('template', function(name, options) {
@param {String} partialName the name of the template to render minus the leading underscore
*/
+<<<<<<< HEAD
Ember.Handlebars.registerHelper('partial', function(name, options) {
+=======
+Ember.Handlebars.registerHelper('partial', function partialHelper(name, options) {
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
var context = (options.contexts && options.contexts.length) ? options.contexts[0] : this;
@@ -27546,7 +38568,7 @@ var get = Ember.get, set = Ember.set;
@param {Hash} options
@return {String} HTML string
*/
-Ember.Handlebars.registerHelper('yield', function(options) {
+Ember.Handlebars.registerHelper('yield', function yieldHelper(options) {
var view = options.data.view;
while (view && !get(view, 'layout')) {
@@ -27590,7 +38612,7 @@ Ember.Handlebars.registerHelper('yield', function(options) {
@param {String} str The string to format
*/
-Ember.Handlebars.registerHelper('loc', function(str) {
+Ember.Handlebars.registerHelper('loc', function locHelper(str) {
return Ember.String.loc(str);
});
@@ -27622,7 +38644,11 @@ var set = Ember.set, get = Ember.get;
The internal class used to create text inputs when the `{{input}}`
helper is used with `type` of `checkbox`.
+<<<<<<< HEAD
See Handlebars.helpers.input for usage details.
+=======
+ See [handlebars.helpers.input](/api/classes/Ember.Handlebars.helpers.html#method_input) for usage details.
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
## Direct manipulation of `checked`
@@ -27870,7 +38896,11 @@ var get = Ember.get, set = Ember.set;
The internal class used to create text inputs when the `{{input}}`
helper is used with `type` of `text`.
+<<<<<<< HEAD
See [handlebars.helpers.input](Ember.Handlebars.helpers.html#method_input) for usage details.
+=======
+ See [Handlebars.helpers.input](/api/classes/Ember.Handlebars.helpers.html#method_input) for usage details.
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
## Layout and LayoutName properties
@@ -27883,8 +38913,12 @@ var get = Ember.get, set = Ember.set;
@extends Ember.Component
@uses Ember.TextSupport
*/
+<<<<<<< HEAD
Ember.TextField = Ember.Component.extend(Ember.TextSupport,
/** @scope Ember.TextField.prototype */ {
+=======
+Ember.TextField = Ember.Component.extend(Ember.TextSupport, {
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
classNames: ['ember-text-field'],
tagName: "input",
@@ -27906,6 +38940,7 @@ Ember.TextField = Ember.Component.extend(Ember.TextSupport,
@property type
@type String
@default "text"
+<<<<<<< HEAD
*/
type: "text",
@@ -27925,6 +38960,27 @@ Ember.TextField = Ember.Component.extend(Ember.TextSupport,
@type String
@default null
*/
+=======
+ */
+ type: "text",
+
+ /**
+ The `size` of the text field in characters.
+
+ @property size
+ @type String
+ @default null
+ */
+ size: null,
+
+ /**
+ The `pattern` the pattern attribute of input element.
+
+ @property pattern
+ @type String
+ @default null
+ */
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
pattern: null
});
@@ -28439,9 +39495,7 @@ Ember.SelectOptgroup = Ember.CollectionView.extend({
@namespace Ember
@extends Ember.View
*/
-Ember.Select = Ember.View.extend(
- /** @scope Ember.Select.prototype */ {
-
+Ember.Select = Ember.View.extend({
tagName: 'select',
classNames: ['ember-select'],
defaultTemplate: Ember.Handlebars.template(function anonymous(Handlebars,depth0,helpers,partials,data) {
@@ -28451,11 +39505,16 @@ helpers = this.merge(helpers, Ember.Handlebars.helpers); data = data || {};
function program1(depth0,data) {
+<<<<<<< HEAD
var buffer = '', hashTypes, hashContexts;
+=======
+ var buffer = '', stack1, hashTypes, hashContexts;
+>>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147
data.buffer.push("");
return buffer;
}
@@ -29058,10 +40117,288 @@ Ember.Handlebars.registerHelper('input', function(options) {
{{textarea value=twoWayWrittenWords}}
```
+<<<<<<< HEAD
+=======
+(function() {
+/**
+@module ember
+@submodule ember-handlebars-compiler
+*/
+
+/**
+
+ The `{{input}}` helper inserts an HTML `` 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:
+
+* `value`
+* `size`
+* `name`
+* `pattern`
+* `placeholder`
+* `disabled`
+* `maxlength`
+* `tabindex`
+
+
+ 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
+
+ ```
+
+ ## Bound:
+
+ ```javascript
+ App.ApplicationController = Ember.Controller.extend({
+ firstName: "Stanley",
+ entryNotAllowed: true
+ });
+ ```
+
+
+ ```handlebars
+ {{input type="text" value=firstName disabled=entryNotAllowed size="50"}}
+ ```
+
+
+ ```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
+ capablilties of text inputs in your applications by reopening this class. For example,
+ if you are deploying to browsers where the `required` attribute is used, you
+ can add this to the `TextField`'s `attributeBindings` property:
+
+
+ ```javascript
+ Ember.TextField.reopen({
+ attributeBindings: ['required']
+ });
+ ```
+
+ 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`
+
+
+ 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
+
+ ```
+
+ ## Bound:
+
+ ```javascript
+ App.ApplicationController = Ember.Controller.extend({
+ isAdmin: true
+ });
+ ```
+
+
+ ```handlebars
+ {{input type="checkbox" checked=isAdmin }}
+ ```
+
+
+ ```html
+
+ ```
+
+ ## 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
+*/
+Ember.Handlebars.registerHelper('input', function(options) {
+ Ember.assert('You can only pass attributes to the `input` helper, not arguments', arguments.length < 2);
+
+ var hash = options.hash,
+ types = options.hashTypes,
+ inputType = hash.type,
+ onEvent = hash.on;
+
+ delete hash.type;
+ delete hash.on;
+
+ if (inputType === 'checkbox') {
+ return Ember.Handlebars.helpers.view.call(this, Ember.Checkbox, options);
+ } else {
+ if (inputType) { hash.type = inputType; }
+ hash.onEvent = onEvent || 'enter';
+ return Ember.Handlebars.helpers.view.call(this, Ember.TextField, options);
+ }
+});
+
+/**
+ `{{textarea}}` inserts a new instance of `