You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by rl...@apache.org on 2017/06/23 13:29:04 UTC
[09/42] ambari git commit: AMBARI-21330.Remove slider view from
Ambari-3.0.0(Venkata Sairam)
http://git-wip-us.apache.org/repos/asf/ambari/blob/ec8deeba/contrib/views/slider/src/main/resources/ui/vendor/scripts/production/ember.js
----------------------------------------------------------------------
diff --git a/contrib/views/slider/src/main/resources/ui/vendor/scripts/production/ember.js b/contrib/views/slider/src/main/resources/ui/vendor/scripts/production/ember.js
deleted file mode 100644
index 043755d..0000000
--- a/contrib/views/slider/src/main/resources/ui/vendor/scripts/production/ember.js
+++ /dev/null
@@ -1,41620 +0,0 @@
-/*!
- * @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.5.1+pre.ff8c6bbb
- */
-
-
-(function() {
-var define, requireModule, require, requirejs;
-
-(function() {
- var registry = {}, seen = {};
-
- define = function(name, deps, callback) {
- registry[name] = { deps: deps, callback: callback };
- };
-
- requirejs = require = requireModule = function(name) {
- requirejs._eak_seen = registry;
-
- if (seen[name]) { return seen[name]; }
- seen[name] = {};
-
- if (!registry[name]) {
- throw new Error("Could not find module " + name);
- }
-
- var mod = registry[name],
- deps = mod.deps,
- callback = mod.callback,
- reified = [],
- exports;
-
- for (var i=0, l=deps.length; i<l; i++) {
- if (deps[i] === 'exports') {
- reified.push(exports = {});
- } else {
- reified.push(requireModule(resolve(deps[i])));
- }
- }
-
- var value = callback.apply(this, reified);
- return seen[name] = exports || value;
-
- function resolve(child) {
- if (child.charAt(0) !== '.') { return child; }
- var parts = child.split("/");
- var parentBase = name.split("/").slice(0, -1);
-
- for (var i=0, l=parts.length; i<l; i++) {
- var part = parts[i];
-
- if (part === '..') { parentBase.pop(); }
- else if (part === '.') { continue; }
- else { parentBase.push(part); }
- }
-
- return parentBase.join("/");
- }
- };
-})();
-(function() {
-/*globals Em:true ENV EmberENV MetamorphENV:true */
-
-/**
-@module ember
-@submodule ember-metal
-*/
-
-/**
- All Ember methods and functions are defined inside of this namespace. You
- generally should not add new properties to this namespace as it may be
- overwritten by future versions of Ember.
-
- You can also use the shorthand `Em` instead of `Ember`.
-
- Ember-Runtime is a framework that provides core functions for Ember including
- cross-platform functions, support for property observing and objects. Its
- focus is on small size and performance. You can use this in place of or
- along-side other cross-platform libraries such as jQuery.
-
- The core Runtime framework is based on the jQuery API with a number of
- performance optimizations.
-
- @class Ember
- @static
- @version 1.5.1+pre.ff8c6bbb
-*/
-
-if ('undefined' === typeof Ember) {
- // Create core object. Make it act like an instance of Ember.Namespace so that
- // objects assigned to it are given a sane string representation.
- Ember = {};
-}
-
-// Default imports, exports and lookup to the global object;
-var imports = Ember.imports = Ember.imports || this;
-var exports = Ember.exports = Ember.exports || this;
-var lookup = Ember.lookup = Ember.lookup || this;
-
-// aliases needed to keep minifiers from removing the global context
-exports.Em = exports.Ember = Em = Ember;
-
-// Make sure these are set whether Ember was already defined or not
-
-Ember.isNamespace = true;
-
-Ember.toString = function() { return "Ember"; };
-
-
-/**
- @property VERSION
- @type String
- @default '1.5.1+pre.ff8c6bbb'
- @static
-*/
-Ember.VERSION = '1.5.1+pre.ff8c6bbb';
-
-/**
- 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
-*/
-
-// 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 = {};
-}
-
-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;
- }
-};
-
-// ..........................................................
-// BOOTSTRAP
-//
-
-/**
- Determines whether Ember should enhances some built-in object prototypes to
- provide a more friendly API. If enabled, a few methods will be added to
- `Function`, `String`, and `Array`. `Object.prototype` will not be enhanced,
- which is the one that causes most trouble for people.
-
- In general we recommend leaving this option set to true since it rarely
- conflicts with other code. If you need to turn it off however, you can
- define an `ENV.EXTEND_PROTOTYPES` config to disable it.
-
- @property EXTEND_PROTOTYPES
- @type Boolean
- @default true
-*/
-Ember.EXTEND_PROTOTYPES = Ember.ENV.EXTEND_PROTOTYPES;
-
-if (typeof Ember.EXTEND_PROTOTYPES === 'undefined') {
- Ember.EXTEND_PROTOTYPES = true;
-}
-
-/**
- Determines whether Ember logs a full stack trace during deprecation warnings
-
- @property LOG_STACKTRACE_ON_DEPRECATION
- @type Boolean
- @default true
-*/
-Ember.LOG_STACKTRACE_ON_DEPRECATION = (Ember.ENV.LOG_STACKTRACE_ON_DEPRECATION !== false);
-
-/**
- Determines whether Ember should add ECMAScript 5 shims to older browsers.
-
- @property SHIM_ES5
- @type Boolean
- @default Ember.EXTEND_PROTOTYPES
-*/
-Ember.SHIM_ES5 = (Ember.ENV.SHIM_ES5 === false) ? false : Ember.EXTEND_PROTOTYPES;
-
-/**
- Determines whether Ember logs info about version of used libraries
-
- @property LOG_VERSION
- @type Boolean
- @default true
-*/
-Ember.LOG_VERSION = (Ember.ENV.LOG_VERSION === false) ? false : true;
-
-/**
- Empty function. Useful for some operations. Always returns `this`.
-
- @method K
- @private
- @return {Object}
-*/
-Ember.K = function() { return this; };
-
-
-// Stub out the methods defined by the ember-debug package in case it's not loaded
-
-if ('undefined' === typeof Ember.assert) { Ember.assert = Ember.K; }
-if ('undefined' === typeof Ember.warn) { Ember.warn = Ember.K; }
-if ('undefined' === typeof Ember.debug) { Ember.debug = Ember.K; }
-if ('undefined' === typeof Ember.runInDebug) { Ember.runInDebug = Ember.K; }
-if ('undefined' === typeof Ember.deprecate) { Ember.deprecate = Ember.K; }
-if ('undefined' === typeof Ember.deprecateFunc) {
- Ember.deprecateFunc = function(_, func) { return func; };
-}
-
-/**
- Previously we used `Ember.$.uuid`, however `$.uuid` has been removed from
- jQuery master. We'll just bootstrap our own uuid now.
-
- @property uuid
- @type Number
- @private
-*/
-Ember.uuid = 0;
-
-/**
- Merge the contents of two objects together into the first object.
-
- ```javascript
- Ember.merge({first: 'Tom'}, {last: 'Dale'}); // {first: 'Tom', last: 'Dale'}
- var a = {first: 'Yehuda'}, b = {last: 'Katz'};
- Ember.merge(a, b); // a == {first: 'Yehuda', last: 'Katz'}, b == {last: 'Katz'}
- ```
-
- @method merge
- @for Ember
- @param {Object} original The object to merge into
- @param {Object} updates The object to copy properties from
- @return {Object}
-*/
-Ember.merge = function(original, updates) {
- for (var prop in updates) {
- if (!updates.hasOwnProperty(prop)) { continue; }
- original[prop] = updates[prop];
- }
- return original;
-};
-
-/**
- Returns true if the passed value is null or undefined. This avoids errors
- from JSLint complaining about use of ==, which can be technically
- confusing.
-
- ```javascript
- Ember.isNone(); // true
- Ember.isNone(null); // true
- Ember.isNone(undefined); // true
- Ember.isNone(''); // false
- Ember.isNone([]); // false
- Ember.isNone(function() {}); // false
- ```
-
- @method isNone
- @for Ember
- @param {Object} obj Value to test
- @return {Boolean}
-*/
-Ember.isNone = function(obj) {
- return obj === null || obj === undefined;
-};
-Ember.none = Ember.deprecateFunc("Ember.none is deprecated. Please use Ember.isNone instead.", Ember.isNone);
-
-/**
- Verifies that a value is `null` or an empty string, empty array,
- or empty function.
-
- Constrains the rules on `Ember.isNone` by returning false for empty
- string and empty arrays.
-
- ```javascript
- Ember.isEmpty(); // true
- Ember.isEmpty(null); // true
- Ember.isEmpty(undefined); // true
- Ember.isEmpty(''); // true
- Ember.isEmpty([]); // true
- Ember.isEmpty('Adam Hawkins'); // false
- Ember.isEmpty([0,1,2]); // false
- ```
-
- @method isEmpty
- @for Ember
- @param {Object} obj Value to test
- @return {Boolean}
-*/
-Ember.isEmpty = function(obj) {
- return Ember.isNone(obj) || (obj.length === 0 && typeof obj !== 'function') || (typeof obj === 'object' && Ember.get(obj, 'length') === 0);
-};
-Ember.empty = Ember.deprecateFunc("Ember.empty is deprecated. Please use Ember.isEmpty instead.", Ember.isEmpty);
-
-
- /**
- A value is blank if it is empty or a whitespace string.
-
- ```javascript
- Ember.isBlank(); // true
- Ember.isBlank(null); // true
- Ember.isBlank(undefined); // true
- Ember.isBlank(''); // true
- Ember.isBlank([]); // true
- Ember.isBlank('\n\t'); // true
- Ember.isBlank(' '); // true
- Ember.isBlank({}); // false
- Ember.isBlank('\n\t Hello'); // false
- Ember.isBlank('Hello world'); // false
- Ember.isBlank([1,2,3]); // false
- ```
-
- @method isBlank
- @for Ember
- @param {Object} obj Value to test
- @return {Boolean}
- */
- Ember.isBlank = function(obj) {
- return Ember.isEmpty(obj) || (typeof obj === 'string' && obj.match(/\S/) === null);
- };
-
-
-})();
-
-
-
-(function() {
-/*globals Node */
-/**
-@module ember-metal
-*/
-
-/**
- Platform specific methods and feature detectors needed by the framework.
-
- @class platform
- @namespace Ember
- @static
-*/
-var platform = Ember.platform = {};
-
-
-/**
- Identical to `Object.create()`. Implements if not available natively.
-
- @method create
- @for Ember
-*/
-Ember.create = Object.create;
-
-// IE8 has Object.create but it couldn't treat property descriptors.
-if (Ember.create) {
- if (Ember.create({a: 1}, {a: {value: 2}}).a !== 2) {
- Ember.create = null;
- }
-}
-
-// STUB_OBJECT_CREATE allows us to override other libraries that stub
-// Object.create different than we would prefer
-if (!Ember.create || Ember.ENV.STUB_OBJECT_CREATE) {
- var K = function() {};
-
- Ember.create = function(obj, props) {
- K.prototype = obj;
- obj = new K();
- if (props) {
- K.prototype = obj;
- for (var prop in props) {
- K.prototype[prop] = props[prop].value;
- }
- obj = new K();
- }
- K.prototype = null;
-
- return obj;
- };
-
- Ember.create.isSimulated = true;
-}
-
-var defineProperty = Object.defineProperty;
-var canRedefineProperties, canDefinePropertyOnDOM;
-
-// Catch IE8 where Object.defineProperty exists but only works on DOM elements
-if (defineProperty) {
- try {
- defineProperty({}, 'a',{get:function() {}});
- } catch (e) {
- defineProperty = null;
- }
-}
-
-if (defineProperty) {
- // Detects a bug in Android <3.2 where you cannot redefine a property using
- // Object.defineProperty once accessors have already been set.
- canRedefineProperties = (function() {
- var obj = {};
-
- defineProperty(obj, 'a', {
- configurable: true,
- enumerable: true,
- get: function() { },
- set: function() { }
- });
-
- defineProperty(obj, 'a', {
- configurable: true,
- enumerable: true,
- writable: true,
- value: true
- });
-
- return obj.a === true;
- })();
-
- // This is for Safari 5.0, which supports Object.defineProperty, but not
- // on DOM nodes.
- canDefinePropertyOnDOM = (function() {
- try {
- defineProperty(document.createElement('div'), 'definePropertyOnDOM', {});
- return true;
- } catch(e) { }
-
- return false;
- })();
-
- if (!canRedefineProperties) {
- defineProperty = null;
- } else if (!canDefinePropertyOnDOM) {
- defineProperty = function(obj, keyName, desc) {
- var isNode;
-
- if (typeof Node === "object") {
- isNode = obj instanceof Node;
- } else {
- isNode = typeof obj === "object" && typeof obj.nodeType === "number" && typeof obj.nodeName === "string";
- }
-
- if (isNode) {
- // TODO: Should we have a warning here?
- return (obj[keyName] = desc.value);
- } else {
- return Object.defineProperty(obj, keyName, desc);
- }
- };
- }
-}
-
-/**
-@class platform
-@namespace Ember
-*/
-
-/**
- Identical to `Object.defineProperty()`. Implements as much functionality
- as possible if not available natively.
-
- @method defineProperty
- @param {Object} obj The object to modify
- @param {String} keyName property name to modify
- @param {Object} desc descriptor hash
- @return {void}
-*/
-platform.defineProperty = defineProperty;
-
-/**
- Set to true if the platform supports native getters and setters.
-
- @property hasPropertyAccessors
- @final
-*/
-platform.hasPropertyAccessors = true;
-
-if (!platform.defineProperty) {
- platform.hasPropertyAccessors = false;
-
- platform.defineProperty = function(obj, keyName, desc) {
- if (!desc.get) { obj[keyName] = desc.value; }
- };
-
- platform.defineProperty.isSimulated = true;
-}
-
-if (Ember.ENV.MANDATORY_SETTER && !platform.hasPropertyAccessors) {
- Ember.ENV.MANDATORY_SETTER = false;
-}
-
-})();
-
-
-
-(function() {
-/*jshint newcap:false*/
-/**
-@module ember-metal
-*/
-
-// NOTE: There is a bug in jshint that doesn't recognize `Object()` without `new`
-// as being ok unless both `newcap:false` and not `use strict`.
-// https://github.com/jshint/jshint/issues/392
-
-// Testing this is not ideal, but we want to use native functions
-// if available, but not to use versions created by libraries like Prototype
-var isNativeFunc = function(func) {
- // This should probably work in all browsers likely to have ES5 array methods
- return func && Function.prototype.toString.call(func).indexOf('[native code]') > -1;
-};
-
-// From: https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/array/map
-var arrayMap = isNativeFunc(Array.prototype.map) ? Array.prototype.map : function(fun /*, thisp */) {
- //"use strict";
-
- if (this === void 0 || this === null) {
- throw new TypeError();
- }
-
- var t = Object(this);
- var len = t.length >>> 0;
- if (typeof fun !== "function") {
- throw new TypeError();
- }
-
- var res = new Array(len);
- var thisp = arguments[1];
- for (var i = 0; i < len; i++) {
- if (i in t) {
- res[i] = fun.call(thisp, t[i], i, t);
- }
- }
-
- return res;
-};
-
-// From: https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/array/foreach
-var arrayForEach = isNativeFunc(Array.prototype.forEach) ? Array.prototype.forEach : function(fun /*, thisp */) {
- //"use strict";
-
- if (this === void 0 || this === null) {
- throw new TypeError();
- }
-
- var t = Object(this);
- var len = t.length >>> 0;
- if (typeof fun !== "function") {
- throw new TypeError();
- }
-
- var thisp = arguments[1];
- for (var i = 0; i < len; i++) {
- if (i in t) {
- fun.call(thisp, t[i], i, t);
- }
- }
-};
-
-var arrayIndexOf = isNativeFunc(Array.prototype.indexOf) ? Array.prototype.indexOf : function (obj, fromIndex) {
- if (fromIndex === null || fromIndex === undefined) { fromIndex = 0; }
- else if (fromIndex < 0) { fromIndex = Math.max(0, this.length + fromIndex); }
- for (var i = fromIndex, j = this.length; i < j; i++) {
- if (this[i] === obj) { return i; }
- }
- return -1;
-};
-
-var arrayFilter = isNativeFunc(Array.prototype.filter) ? Array.prototype.filter : function (fn, context) {
- var i,
- value,
- result = [],
- length = this.length;
-
- for (i = 0; i < length; i++) {
- if (this.hasOwnProperty(i)) {
- value = this[i];
- if (fn.call(context, value, i, this)) {
- result.push(value);
- }
- }
- }
- return result;
-};
-
-/**
- Array polyfills to support ES5 features in older browsers.
-
- @namespace Ember
- @property ArrayPolyfills
-*/
-Ember.ArrayPolyfills = {
- map: arrayMap,
- forEach: arrayForEach,
- filter: arrayFilter,
- indexOf: arrayIndexOf
-};
-
-if (Ember.SHIM_ES5) {
- if (!Array.prototype.map) {
- Array.prototype.map = arrayMap;
- }
-
- if (!Array.prototype.forEach) {
- Array.prototype.forEach = arrayForEach;
- }
-
- if (!Array.prototype.filter) {
- Array.prototype.filter = arrayFilter;
- }
-
- if (!Array.prototype.indexOf) {
- Array.prototype.indexOf = arrayIndexOf;
- }
-}
-
-})();
-
-
-
-(function() {
-var errorProps = ['description', 'fileName', 'lineNumber', 'message', 'name', 'number', 'stack'];
-
-/**
- A subclass of the JavaScript Error object for use in Ember.
-
- @class Error
- @namespace Ember
- @extends Error
- @constructor
-*/
-Ember.Error = function() {
- var tmp = Error.apply(this, arguments);
-
- // 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);
- }
- // 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]];
- }
-};
-
-Ember.Error.prototype = Ember.create(Error.prototype);
-
-// ..........................................................
-// ERROR HANDLING
-//
-
-/**
- A function may be assigned to `Ember.onerror` to be called when Ember
- internals encounter an error. This is useful for specialized error handling
- and reporting code.
-
- ```javascript
- Ember.onerror = function(error) {
- Em.$.ajax('/report-error', 'POST', {
- stack: error.stack,
- otherInformation: 'whatever app state you want to provide'
- });
- };
- ```
-
- @event onerror
- @for Ember
- @param {Exception} error the error object
-*/
-Ember.onerror = null;
-
-})();
-
-
-
-(function() {
-/**
-@module ember-metal
-*/
-
-/**
- Prefix used for guids through out Ember.
- @private
-*/
-Ember.GUID_PREFIX = 'ember';
-
-
-var o_defineProperty = Ember.platform.defineProperty,
- o_create = Ember.create,
- // Used for guid generation...
- GUID_KEY = '__ember'+ (+ new Date()),
- numberCache = [],
- stringCache = {},
- uuid = 0;
-
-var MANDATORY_SETTER = Ember.ENV.MANDATORY_SETTER;
-
-/**
- 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.
-
- 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
- @final
-*/
-Ember.GUID_KEY = GUID_KEY;
-
-var GUID_DESC = {
- writable: false,
- configurable: false,
- enumerable: false,
- value: null
-};
-
-/**
- Generates a new guid, optionally saving the guid to the object that you
- pass in. You will rarely need to use this method. Instead you should
- call `Ember.guidFor(obj)`, which return an existing guid if available.
-
- @private
- @method generateGuid
- @for Ember
- @param {Object} [obj] Object the guid will be used for. If passed in, the guid will
- be saved on the object and reused whenever you pass the same object
- again.
-
- If no object is passed, just generate a new guid.
- @param {String} [prefix] Prefix to place in front of the guid. Useful when you want to
- separate the guid into separate namespaces.
- @return {String} the guid
-*/
-Ember.generateGuid = function generateGuid(obj, prefix) {
- if (!prefix) prefix = Ember.GUID_PREFIX;
- var ret = (prefix + (uuid++));
- if (obj) {
- if (obj[GUID_KEY] === null) {
- obj[GUID_KEY] = ret;
- } else {
- GUID_DESC.value = ret;
- o_defineProperty(obj, GUID_KEY, GUID_DESC);
- }
- }
- return ret;
-};
-
-/**
- Returns a unique id for the object. If the object does not yet have a guid,
- one will be assigned to it. You can call this on any object,
- `Ember.Object`-based or not, but be aware that it will add a `_guid`
- property.
-
- You can also use this method on DOM Element objects.
-
- @private
- @method guidFor
- @for Ember
- @param {Object} obj any object, string, number, Element, or primitive
- @return {String} the unique guid for this instance.
-*/
-Ember.guidFor = function guidFor(obj) {
-
- // special cases where we don't want to add a key to object
- if (obj === undefined) return "(undefined)";
- if (obj === null) return "(null)";
-
- var ret;
- var type = typeof obj;
-
- // Don't allow prototype changes to String etc. to change the guidFor
- switch(type) {
- case 'number':
- ret = numberCache[obj];
- if (!ret) ret = numberCache[obj] = 'nu'+obj;
- return ret;
-
- case 'string':
- ret = stringCache[obj];
- if (!ret) ret = stringCache[obj] = 'st'+(uuid++);
- return ret;
-
- case 'boolean':
- return obj ? '(true)' : '(false)';
-
- default:
- if (obj[GUID_KEY]) return obj[GUID_KEY];
- if (obj === Object) return '(Object)';
- if (obj === Array) return '(Array)';
- ret = 'ember' + (uuid++);
-
- if (obj[GUID_KEY] === null) {
- obj[GUID_KEY] = ret;
- } else {
- GUID_DESC.value = ret;
- o_defineProperty(obj, GUID_KEY, GUID_DESC);
- }
- return ret;
- }
-};
-
-// ..........................................................
-// META
-//
-
-var META_DESC = Ember.META_DESC = {
- writable: true,
- configurable: false,
- enumerable: false,
- value: null
-};
-
-var META_KEY = Ember.GUID_KEY+'_meta';
-
-/**
- The key used to store meta information on object for property observing.
-
- @property META_KEY
- @for Ember
- @private
- @final
- @type String
-*/
-Ember.META_KEY = META_KEY;
-
-var isDefinePropertySimulated = Ember.platform.defineProperty.isSimulated;
-
-function Meta(obj) {
- this.descs = {};
- this.watching = {};
- this.cache = {};
- this.cacheMeta = {};
- this.source = obj;
-}
-
-Meta.prototype = {
- descs: null,
- deps: null,
- watching: null,
- listeners: null,
- cache: null,
- cacheMeta: null,
- source: null,
- mixins: null,
- bindings: null,
- chains: null,
- chainWatchers: null,
- values: null,
- proto: null
-};
-
-if (isDefinePropertySimulated) {
- // on platforms that don't support enumerable false
- // make meta fail jQuery.isPlainObject() to hide from
- // jQuery.extend() by having a property that fails
- // hasOwnProperty check.
- Meta.prototype.__preventPlainObject__ = true;
-
- // Without non-enumerable properties, meta objects will be output in JSON
- // unless explicitly suppressed
- 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.
-
- The meta object contains information about computed property descriptors as
- well as any watched properties and other information. You generally will
- not access this information directly but instead work with higher level
- methods that manipulate this hash indirectly.
-
- @method meta
- @for Ember
- @private
-
- @param {Object} obj The object to retrieve meta for
- @param {Boolean} [writable=true] Pass `false` if you do not intend to modify
- the meta hash, allowing the method to avoid making an unnecessary copy.
- @return {Object} the meta hash for an object
-*/
-Ember.meta = function meta(obj, writable) {
-
- var ret = obj[META_KEY];
- if (writable===false) return ret || EMPTY_META;
-
- if (!ret) {
- if (!isDefinePropertySimulated) o_defineProperty(obj, META_KEY, META_DESC);
-
- ret = new Meta(obj);
-
- if (MANDATORY_SETTER) { ret.values = {}; }
-
- obj[META_KEY] = ret;
-
- // make sure we don't accidentally try to create constructor like desc
- ret.descs.constructor = null;
-
- } else if (ret.source !== obj) {
- if (!isDefinePropertySimulated) o_defineProperty(obj, META_KEY, META_DESC);
-
- ret = o_create(ret);
- ret.descs = o_create(ret.descs);
- ret.watching = o_create(ret.watching);
- ret.cache = {};
- ret.cacheMeta = {};
- ret.source = obj;
-
- if (MANDATORY_SETTER) { ret.values = o_create(ret.values); }
-
- obj[META_KEY] = ret;
- }
- return ret;
-};
-
-Ember.getMeta = function getMeta(obj, property) {
- var meta = Ember.meta(obj, false);
- return meta[property];
-};
-
-Ember.setMeta = function setMeta(obj, property, value) {
- var meta = Ember.meta(obj, true);
- meta[property] = value;
- return value;
-};
-
-/**
- @deprecated
- @private
-
- In order to store defaults for a class, a prototype may need to create
- a default meta object, which will be inherited by any objects instantiated
- from the class's constructor.
-
- However, the properties of that meta object are only shallow-cloned,
- so if a property is a hash (like the event system's `listeners` hash),
- it will by default be shared across all instances of that class.
-
- This method allows extensions to deeply clone a series of nested hashes or
- other complex objects. For instance, the event system might pass
- `['listeners', 'foo:change', 'ember157']` to `prepareMetaPath`, which will
- walk down the keys provided.
-
- For each key, if the key does not exist, it is created. If it already
- exists and it was inherited from its constructor, the constructor's
- key is cloned.
-
- You can also pass false for `writable`, which will simply return
- undefined if `prepareMetaPath` discovers any part of the path that
- shared or undefined.
-
- @method metaPath
- @for Ember
- @param {Object} obj The object whose meta we are examining
- @param {Array} path An array of keys to walk down
- @param {Boolean} writable whether or not to create a new meta
- (or meta property) if one does not already exist or if it's
- shared with its constructor
-*/
-Ember.metaPath = function metaPath(obj, path, writable) {
- var meta = Ember.meta(obj, writable), keyName, value;
-
- for (var i=0, l=path.length; i<l; i++) {
- keyName = path[i];
- value = meta[keyName];
-
- if (!value) {
- if (!writable) { return undefined; }
- value = meta[keyName] = { __ember_source__: obj };
- } else if (value.__ember_source__ !== obj) {
- if (!writable) { return undefined; }
- value = meta[keyName] = o_create(value);
- value.__ember_source__ = obj;
- }
-
- meta = value;
- }
-
- return value;
-};
-
-/**
- Wraps the passed function so that `this._super` will point to the superFunc
- when the function is invoked. This is the primitive we use to implement
- calls to super.
-
- @private
- @method wrap
- @for Ember
- @param {Function} func The function to call
- @param {Function} superFunc The super function.
- @return {Function} wrapped function.
-*/
-Ember.wrap = function(func, superFunc) {
- function superWrapper() {
- var ret, sup = this.__nextSuper;
- this.__nextSuper = superFunc;
- ret = func.apply(this, arguments);
- this.__nextSuper = sup;
- return ret;
- }
-
- superWrapper.wrappedFunction = func;
- superWrapper.__ember_observes__ = func.__ember_observes__;
- superWrapper.__ember_observesBefore__ = func.__ember_observesBefore__;
- superWrapper.__ember_listens__ = func.__ember_listens__;
-
- return superWrapper;
-};
-
-/**
- Returns true if the passed object is an array or Array-like.
-
- Ember Array Protocol:
-
- - the object has an objectAt property
- - the object is a native Array
- - the object is an Object, and has a length property
-
- Unlike `Ember.typeOf` this method returns true even if the passed object is
- not formally array but appears to be array-like (i.e. implements `Ember.Array`)
-
- ```javascript
- Ember.isArray(); // false
- Ember.isArray([]); // true
- Ember.isArray( Ember.ArrayProxy.create({ content: [] }) ); // true
- ```
-
- @method isArray
- @for Ember
- @param {Object} obj The object to test
- @return {Boolean} true if the passed object is an array or Array-like
-*/
-Ember.isArray = function(obj) {
- if (!obj || obj.setInterval) { return false; }
- if (Array.isArray && Array.isArray(obj)) { return true; }
- if (Ember.Array && Ember.Array.detect(obj)) { return true; }
- if ((obj.length !== undefined) && 'object'===typeof obj) { return true; }
- return false;
-};
-
-/**
- Forces the passed object to be part of an array. If the object is already
- an array or array-like, returns the object. Otherwise adds the object to
- an array. If obj is `null` or `undefined`, returns an empty array.
-
- ```javascript
- Ember.makeArray(); // []
- Ember.makeArray(null); // []
- Ember.makeArray(undefined); // []
- Ember.makeArray('lindsay'); // ['lindsay']
- Ember.makeArray([1,2,42]); // [1,2,42]
-
- var controller = Ember.ArrayProxy.create({ content: [] });
- Ember.makeArray(controller) === controller; // true
- ```
-
- @method makeArray
- @for Ember
- @param {Object} obj the object
- @return {Array}
-*/
-Ember.makeArray = function(obj) {
- if (obj === null || obj === undefined) { return []; }
- return Ember.isArray(obj) ? obj : [obj];
-};
-
-function canInvoke(obj, methodName) {
- return !!(obj && typeof obj[methodName] === 'function');
-}
-
-/**
- Checks to see if the `methodName` exists on the `obj`.
-
- ```javascript
- var foo = {bar: Ember.K, baz: null};
- Ember.canInvoke(foo, 'bar'); // true
- Ember.canInvoke(foo, 'baz'); // false
- Ember.canInvoke(foo, 'bat'); // false
- ```
-
- @method canInvoke
- @for Ember
- @param {Object} obj The object to check for the method
- @param {String} methodName The method name to check for
- @return {Boolean}
-*/
-Ember.canInvoke = canInvoke;
-
-/**
- Checks to see if the `methodName` exists on the `obj`,
- and if it does, invokes it with the arguments passed.
-
- ```javascript
- var d = new Date('03/15/2013');
- Ember.tryInvoke(d, 'getTime'); // 1363320000000
- Ember.tryInvoke(d, 'setFullYear', [2014]); // 1394856000000
- Ember.tryInvoke(d, 'noSuchMethod', [2014]); // undefined
- ```
-
- @method tryInvoke
- @for Ember
- @param {Object} obj The object to check for the method
- @param {String} methodName The method name to check for
- @param {Array} [args] The arguments to pass to the method
- @return {*} the return value of the invoked method or undefined if it cannot be invoked
-*/
-Ember.tryInvoke = function(obj, methodName, args) {
- if (canInvoke(obj, methodName)) {
- return obj[methodName].apply(obj, args || []);
- }
-};
-
-// https://github.com/emberjs/ember.js/pull/1617
-var needsFinallyFix = (function() {
- var count = 0;
- try{
- try { }
- finally {
- count++;
- throw new Error('needsFinallyFixTest');
- }
- } catch (e) {}
-
- return count !== 1;
-})();
-
-/**
- Provides try { } finally { } functionality, while working
- around Safari's double finally bug.
-
- ```javascript
- var tryable = function() {
- someResource.lock();
- runCallback(); // May throw error.
- };
- var finalizer = function() {
- someResource.unlock();
- };
- Ember.tryFinally(tryable, finalizer);
- ```
-
- @method tryFinally
- @for Ember
- @param {Function} tryable The function to run the try callback
- @param {Function} finalizer The function to run the finally callback
- @param {Object} [binding] The optional calling object. Defaults to 'this'
- @return {*} The return value is the that of the finalizer,
- unless that value is undefined, in which case it is the return value
- of the tryable
-*/
-
-if (needsFinallyFix) {
- Ember.tryFinally = function(tryable, finalizer, binding) {
- var result, finalResult, finalError;
-
- binding = binding || this;
-
- try {
- result = tryable.call(binding);
- } finally {
- try {
- finalResult = finalizer.call(binding);
- } catch (e) {
- finalError = e;
- }
- }
-
- if (finalError) { throw finalError; }
-
- return (finalResult === undefined) ? result : finalResult;
- };
-} else {
- Ember.tryFinally = function(tryable, finalizer, binding) {
- var result, finalResult;
-
- binding = binding || this;
-
- try {
- result = tryable.call(binding);
- } finally {
- finalResult = finalizer.call(binding);
- }
-
- return (finalResult === undefined) ? result : finalResult;
- };
-}
-
-/**
- Provides try { } catch finally { } functionality, while working
- around Safari's double finally bug.
-
- ```javascript
- var tryable = function() {
- for (i=0, l=listeners.length; i<l; i++) {
- listener = listeners[i];
- beforeValues[i] = listener.before(name, time(), payload);
- }
-
- return callback.call(binding);
- };
-
- var catchable = function(e) {
- payload = payload || {};
- payload.exception = e;
- };
-
- var finalizer = function() {
- for (i=0, l=listeners.length; i<l; i++) {
- listener = listeners[i];
- listener.after(name, time(), payload, beforeValues[i]);
- }
- };
- Ember.tryCatchFinally(tryable, catchable, finalizer);
- ```
-
- @method tryCatchFinally
- @for Ember
- @param {Function} tryable The function to run the try callback
- @param {Function} catchable The function to run the catchable callback
- @param {Function} finalizer The function to run the finally callback
- @param {Object} [binding] The optional calling object. Defaults to 'this'
- @return {*} The return value is the that of the finalizer,
- unless that value is undefined, in which case it is the return value
- of the tryable.
-*/
-if (needsFinallyFix) {
- Ember.tryCatchFinally = function(tryable, catchable, finalizer, binding) {
- var result, finalResult, finalError;
-
- binding = binding || this;
-
- try {
- result = tryable.call(binding);
- } catch(error) {
- result = catchable.call(binding, error);
- } finally {
- try {
- finalResult = finalizer.call(binding);
- } catch (e) {
- finalError = e;
- }
- }
-
- if (finalError) { throw finalError; }
-
- return (finalResult === undefined) ? result : finalResult;
- };
-} else {
- Ember.tryCatchFinally = function(tryable, catchable, finalizer, binding) {
- var result, finalResult;
-
- binding = binding || this;
-
- try {
- result = tryable.call(binding);
- } catch(error) {
- result = catchable.call(binding, error);
- } finally {
- finalResult = finalizer.call(binding);
- }
-
- return (finalResult === undefined) ? result : finalResult;
- };
-}
-
-// ........................................
-// TYPING & ARRAY MESSAGING
-//
-
-var TYPE_MAP = {};
-var t = "Boolean Number String Function Array Date RegExp Object".split(" ");
-Ember.ArrayPolyfills.forEach.call(t, function(name) {
- TYPE_MAP[ "[object " + name + "]" ] = name.toLowerCase();
-});
-
-var toString = Object.prototype.toString;
-
-/**
- Returns a consistent type for the passed item.
-
- Use this instead of the built-in `typeof` to get the type of an item.
- It will return the same result across all browsers and includes a bit
- more detail. Here is what will be returned:
-
- | Return Value | Meaning |
- |---------------|------------------------------------------------------|
- | 'string' | String primitive or String object. |
- | 'number' | Number primitive or Number object. |
- | 'boolean' | Boolean primitive or Boolean object. |
- | 'null' | Null value |
- | '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 |
- | 'object' | A JavaScript object not inheriting from Ember.Object |
-
- Examples:
-
- ```javascript
- Ember.typeOf(); // 'undefined'
- Ember.typeOf(null); // 'null'
- Ember.typeOf(undefined); // 'undefined'
- Ember.typeOf('michael'); // 'string'
- Ember.typeOf(new String('michael')); // 'string'
- Ember.typeOf(101); // 'number'
- Ember.typeOf(new Number(101)); // 'number'
- Ember.typeOf(true); // 'boolean'
- 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'
-
- // "normal" JavaScript object
- Ember.typeOf({a: 'b'}); // 'object'
- ```
-
- @method typeOf
- @for Ember
- @param {Object} item the item to check
- @return {String} the type
-*/
-Ember.typeOf = function(item) {
- var ret;
-
- ret = (item === null || item === undefined) ? String(item) : TYPE_MAP[toString.call(item)] || 'object';
-
- if (ret === 'function') {
- if (Ember.Object && Ember.Object.detect(item)) ret = 'class';
- } else if (ret === 'object') {
- if (item instanceof Error) ret = 'error';
- else if (Ember.Object && item instanceof Ember.Object) ret = 'instance';
- else if (item instanceof Date) ret = 'date';
- }
-
- return ret;
-};
-
-/**
- Convenience method to inspect an object. This method will attempt to
- convert the object into a useful string description.
-
- It is a pretty simple implementation. If you want something more robust,
- use something like JSDump: https://github.com/NV/jsDump
-
- @method inspect
- @for Ember
- @param {Object} obj The object you want to inspect.
- @return {String} A description of the object
-*/
-Ember.inspect = function(obj) {
- var type = Ember.typeOf(obj);
- if (type === 'array') {
- return '[' + obj + ']';
- }
- if (type !== 'object') {
- return obj + '';
- }
-
- var v, ret = [];
- for(var key in obj) {
- if (obj.hasOwnProperty(key)) {
- v = obj[key];
- if (v === 'toString') { continue; } // ignore useless items
- if (Ember.typeOf(v) === 'function') { v = "function() { ... }"; }
- ret.push(key + ": " + v);
- }
- }
- return "{" + ret.join(", ") + "}";
-};
-
-
-
-})();
-
-
-
-(function() {
-// Ember.tryCatchFinally
-
-/**
- The purpose of the Ember Instrumentation module is
- to provide efficient, general-purpose instrumentation
- for Ember.
-
- Subscribe to a listener by using `Ember.subscribe`:
-
- ```javascript
- Ember.subscribe("render", {
- before: function(name, timestamp, payload) {
-
- },
-
- after: function(name, timestamp, payload) {
-
- }
- });
- ```
-
- If you return a value from the `before` callback, that same
- value will be passed as a fourth parameter to the `after`
- callback.
-
- Instrument a block of code by using `Ember.instrument`:
-
- ```javascript
- Ember.instrument("render.handlebars", payload, function() {
- // rendering logic
- }, binding);
- ```
-
- Event names passed to `Ember.instrument` are namespaced
- by periods, from more general to more specific. Subscribers
- can listen for events by whatever level of granularity they
- are interested in.
-
- In the above example, the event is `render.handlebars`,
- and the subscriber listened for all events beginning with
- `render`. It would receive callbacks for events named
- `render`, `render.handlebars`, `render.container`, or
- even `render.handlebars.layout`.
-
- @class Instrumentation
- @namespace Ember
- @static
-*/
-Ember.Instrumentation = {};
-
-var subscribers = [], cache = {};
-
-var populateListeners = function(name) {
- var listeners = [], subscriber;
-
- for (var i=0, l=subscribers.length; i<l; i++) {
- subscriber = subscribers[i];
- if (subscriber.regex.test(name)) {
- listeners.push(subscriber.object);
- }
- }
-
- cache[name] = listeners;
- return listeners;
-};
-
-var time = (function() {
- var perf = 'undefined' !== typeof window ? window.performance || {} : {};
- var fn = perf.now || perf.mozNow || perf.webkitNow || perf.msNow || perf.oNow;
- // fn.bind will be available in all the browsers that support the advanced window.performance... ;-)
- return fn ? fn.bind(perf) : function() { return +new Date(); };
-})();
-
-/**
- Notifies event's subscribers, calls `before` and `after` hooks.
-
- @method instrument
- @namespace Ember.Instrumentation
-
- @param {String} [name] Namespaced event name.
- @param {Object} payload
- @param {Function} callback Function that you're instrumenting.
- @param {Object} binding Context that instrument function is called with.
-*/
-Ember.Instrumentation.instrument = function(name, payload, callback, binding) {
- var listeners = cache[name], timeName, ret;
-
- if (Ember.STRUCTURED_PROFILE) {
- timeName = name + ": " + payload.object;
- console.time(timeName);
- }
-
- if (!listeners) {
- listeners = populateListeners(name);
- }
-
- if (listeners.length === 0) {
- ret = callback.call(binding);
- if (Ember.STRUCTURED_PROFILE) { console.timeEnd(timeName); }
- return ret;
- }
-
- var beforeValues = [], listener, i, l;
-
- function tryable() {
- for (i=0, l=listeners.length; i<l; i++) {
- listener = listeners[i];
- beforeValues[i] = listener.before(name, time(), payload);
- }
-
- return callback.call(binding);
- }
-
- function catchable(e) {
- payload = payload || {};
- payload.exception = e;
- }
-
- function finalizer() {
- for (i=0, l=listeners.length; i<l; i++) {
- listener = listeners[i];
- listener.after(name, time(), payload, beforeValues[i]);
- }
-
- if (Ember.STRUCTURED_PROFILE) {
- console.timeEnd(timeName);
- }
- }
-
- return Ember.tryCatchFinally(tryable, catchable, finalizer);
-};
-
-/**
- Subscribes to a particular event or instrumented block of code.
-
- @method subscribe
- @namespace Ember.Instrumentation
-
- @param {String} [pattern] Namespaced event name.
- @param {Object} [object] Before and After hooks.
-
- @return {Subscriber}
-*/
-Ember.Instrumentation.subscribe = function(pattern, object) {
- var paths = pattern.split("."), path, regex = [];
-
- for (var i=0, l=paths.length; i<l; i++) {
- path = paths[i];
- if (path === "*") {
- regex.push("[^\\.]*");
- } else {
- regex.push(path);
- }
- }
-
- regex = regex.join("\\.");
- regex = regex + "(\\..*)?";
-
- var subscriber = {
- pattern: pattern,
- regex: new RegExp("^" + regex + "$"),
- object: object
- };
-
- subscribers.push(subscriber);
- cache = {};
-
- return subscriber;
-};
-
-/**
- Unsubscribes from a particular event or instrumented block of code.
-
- @method unsubscribe
- @namespace Ember.Instrumentation
-
- @param {Object} [subscriber]
-*/
-Ember.Instrumentation.unsubscribe = function(subscriber) {
- var index;
-
- for (var i=0, l=subscribers.length; i<l; i++) {
- if (subscribers[i] === subscriber) {
- index = i;
- }
- }
-
- subscribers.splice(index, 1);
- cache = {};
-};
-
-/**
- Resets `Ember.Instrumentation` by flushing list of subscribers.
-
- @method reset
- @namespace Ember.Instrumentation
-*/
-Ember.Instrumentation.reset = function() {
- subscribers = [];
- cache = {};
-};
-
-Ember.instrument = Ember.Instrumentation.instrument;
-Ember.subscribe = Ember.Instrumentation.subscribe;
-})();
-
-
-
-(function() {
-var map, forEach, indexOf, splice, filter;
-map = Array.prototype.map || Ember.ArrayPolyfills.map;
-forEach = Array.prototype.forEach || Ember.ArrayPolyfills.forEach;
-indexOf = Array.prototype.indexOf || Ember.ArrayPolyfills.indexOf;
-filter = Array.prototype.filter || Ember.ArrayPolyfills.filter;
-splice = Array.prototype.splice;
-
-/**
- * Defines some convenience methods for working with Enumerables.
- * `Ember.EnumerableUtils` uses `Ember.ArrayPolyfills` when necessary.
- *
- * @class EnumerableUtils
- * @namespace Ember
- * @static
- * */
-var utils = Ember.EnumerableUtils = {
- /**
- * Calls the map function on the passed object with a specified callback. This
- * uses `Ember.ArrayPolyfill`'s-map method when necessary.
- *
- * @method map
- * @param {Object} obj The object that should be mapped
- * @param {Function} callback The callback to execute
- * @param {Object} thisArg Value to use as this when executing *callback*
- *
- * @return {Array} An array of mapped values.
- */
- map: function(obj, callback, thisArg) {
- return obj.map ? obj.map.call(obj, callback, thisArg) : map.call(obj, callback, thisArg);
- },
-
- /**
- * Calls the forEach function on the passed object with a specified callback. This
- * uses `Ember.ArrayPolyfill`'s-forEach method when necessary.
- *
- * @method forEach
- * @param {Object} obj The object to call forEach on
- * @param {Function} callback The callback to execute
- * @param {Object} thisArg Value to use as this when executing *callback*
- *
- */
- forEach: function(obj, callback, thisArg) {
- return obj.forEach ? obj.forEach.call(obj, callback, thisArg) : forEach.call(obj, callback, thisArg);
- },
-
- /**
- * Calls the filter function on the passed object with a specified callback. This
- * uses `Ember.ArrayPolyfill`'s-filter method when necessary.
- *
- * @method filter
- * @param {Object} obj The object to call filter on
- * @param {Function} callback The callback to execute
- * @param {Object} thisArg Value to use as this when executing *callback*
- *
- * @return {Array} An array containing the filtered values
- */
- filter: function(obj, callback, thisArg) {
- return obj.filter ? obj.filter.call(obj, callback, thisArg) : filter.call(obj, callback, thisArg);
- },
-
- /**
- * Calls the indexOf function on the passed object with a specified callback. This
- * uses `Ember.ArrayPolyfill`'s-indexOf method when necessary.
- *
- * @method indexOf
- * @param {Object} obj The object to call indexOn on
- * @param {Function} callback The callback to execute
- * @param {Object} index The index to start searching from
- *
- */
- indexOf: function(obj, element, index) {
- return obj.indexOf ? obj.indexOf.call(obj, element, index) : indexOf.call(obj, element, index);
- },
-
- /**
- * Returns an array of indexes of the first occurrences of the passed elements
- * on the passed object.
- *
- * ```javascript
- * var array = [1, 2, 3, 4, 5];
- * Ember.EnumerableUtils.indexesOf(array, [2, 5]); // [1, 4]
- *
- * var fubar = "Fubarr";
- * Ember.EnumerableUtils.indexesOf(fubar, ['b', 'r']); // [2, 4]
- * ```
- *
- * @method indexesOf
- * @param {Object} obj The object to check for element indexes
- * @param {Array} elements The elements to search for on *obj*
- *
- * @return {Array} An array of indexes.
- *
- */
- indexesOf: function(obj, elements) {
- return elements === undefined ? [] : utils.map(elements, function(item) {
- return utils.indexOf(obj, item);
- });
- },
-
- /**
- * Adds an object to an array. If the array already includes the object this
- * method has no effect.
- *
- * @method addObject
- * @param {Array} array The array the passed item should be added to
- * @param {Object} item The item to add to the passed array
- *
- * @return 'undefined'
- */
- addObject: function(array, item) {
- var index = utils.indexOf(array, item);
- if (index === -1) { array.push(item); }
- },
-
- /**
- * Removes an object from an array. If the array does not contain the passed
- * object this method has no effect.
- *
- * @method removeObject
- * @param {Array} array The array to remove the item from.
- * @param {Object} item The item to remove from the passed array.
- *
- * @return 'undefined'
- */
- removeObject: function(array, item) {
- var index = utils.indexOf(array, item);
- if (index !== -1) { array.splice(index, 1); }
- },
-
- _replace: function(array, idx, amt, objects) {
- var args = [].concat(objects), chunk, ret = [],
- // https://code.google.com/p/chromium/issues/detail?id=56588
- size = 60000, start = idx, ends = amt, count;
-
- while (args.length) {
- count = ends > size ? size : ends;
- if (count <= 0) { count = 0; }
-
- chunk = args.splice(0, size);
- chunk = [start, count].concat(chunk);
-
- start += size;
- ends -= count;
-
- ret = ret.concat(splice.apply(array, chunk));
- }
- return ret;
- },
-
- /**
- * Replaces objects in an array with the passed objects.
- *
- * ```javascript
- * var array = [1,2,3];
- * Ember.EnumerableUtils.replace(array, 1, 2, [4, 5]); // [1, 4, 5]
- *
- * var array = [1,2,3];
- * Ember.EnumerableUtils.replace(array, 1, 1, [4, 5]); // [1, 4, 5, 3]
- *
- * var array = [1,2,3];
- * Ember.EnumerableUtils.replace(array, 10, 1, [4, 5]); // [1, 2, 3, 4, 5]
- * ```
- *
- * @method replace
- * @param {Array} array The array the objects should be inserted into.
- * @param {Number} idx Starting index in the array to replace. If *idx* >=
- * length, then append to the end of the array.
- * @param {Number} amt Number of elements that should be removed from the array,
- * starting at *idx*
- * @param {Array} objects An array of zero or more objects that should be
- * inserted into the array at *idx*
- *
- * @return {Array} The modified array.
- */
- replace: function(array, idx, amt, objects) {
- if (array.replace) {
- return array.replace(idx, amt, objects);
- } else {
- return utils._replace(array, idx, amt, objects);
- }
- },
-
- /**
- * Calculates the intersection of two arrays. This method returns a new array
- * filled with the records that the two passed arrays share with each other.
- * If there is no intersection, an empty array will be returned.
- *
- * ```javascript
- * var array1 = [1, 2, 3, 4, 5];
- * var array2 = [1, 3, 5, 6, 7];
- *
- * Ember.EnumerableUtils.intersection(array1, array2); // [1, 3, 5]
- *
- * var array1 = [1, 2, 3];
- * var array2 = [4, 5, 6];
- *
- * Ember.EnumerableUtils.intersection(array1, array2); // []
- * ```
- *
- * @method intersection
- * @param {Array} array1 The first array
- * @param {Array} array2 The second array
- *
- * @return {Array} The intersection of the two passed arrays.
- */
- intersection: function(array1, array2) {
- var intersection = [];
-
- utils.forEach(array1, function(element) {
- if (utils.indexOf(array2, element) >= 0) {
- intersection.push(element);
- }
- });
-
- return intersection;
- }
-};
-
-})();
-
-
-
-(function() {
-/**
-@module ember-metal
-*/
-
-var META_KEY = Ember.META_KEY, get;
-
-var MANDATORY_SETTER = Ember.ENV.MANDATORY_SETTER;
-
-var IS_GLOBAL_PATH = /^([A-Z$]|([0-9][A-Z$])).*[\.\*]/;
-var HAS_THIS = /^this[\.\*]/;
-var FIRST_KEY = /^([^\.\*]+)/;
-
-// ..........................................................
-// GET AND SET
-//
-// If we are on a platform that supports accessors we can use those.
-// Otherwise simulate accessors by looking up the property directly on the
-// object.
-
-/**
- Gets the value of a property on an object. If the property is computed,
- the function will be invoked. If the property is not defined but the
- object implements the `unknownProperty` method then that will be invoked.
-
- If you plan to run on IE8 and older browsers then you should use this
- method anytime you want to retrieve a property on an object that you don't
- know for sure is private. (Properties beginning with an underscore '_'
- are considered private.)
-
- On all newer browsers, you only need to use this method to retrieve
- properties if the property might not be defined on the object and you want
- to respect the `unknownProperty` handler. Otherwise you can ignore this
- method.
-
- Note that if the object itself is `undefined`, this method will throw
- an error.
-
- @method get
- @for Ember
- @param {Object} obj The object to retrieve from.
- @param {String} keyName The property key to retrieve
- @return {Object} the property value or `null`.
-*/
-get = function get(obj, keyName) {
- // Helpers that operate with 'this' within an #each
- if (keyName === '') {
- return obj;
- }
-
- if (!keyName && 'string'===typeof obj) {
- keyName = obj;
- obj = null;
- }
-
-
- if (obj === null || keyName.indexOf('.') !== -1) {
- return getPath(obj, keyName);
- }
-
- var meta = obj[META_KEY], desc = meta && meta.descs[keyName], ret;
- if (desc) {
- return desc.get(obj, keyName);
- } else {
- if (MANDATORY_SETTER && meta && meta.watching[keyName] > 0) {
- ret = meta.values[keyName];
- } else {
- ret = obj[keyName];
- }
-
- if (ret === undefined &&
- 'object' === typeof obj && !(keyName in obj) && 'function' === typeof obj.unknownProperty) {
- return obj.unknownProperty(keyName);
- }
-
- return ret;
- }
-};
-
-// Currently used only by Ember Data tests
-if (Ember.config.overrideAccessors) {
- Ember.get = get;
- Ember.config.overrideAccessors();
- get = Ember.get;
-}
-
-/**
- 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`.
- @param {String} path A path on the target or a global property path.
- @return {Array} a temporary array with the normalized target/path pair.
-*/
-var normalizeTuple = Ember.normalizeTuple = function(target, path) {
- var hasThis = HAS_THIS.test(path),
- isGlobal = !hasThis && IS_GLOBAL_PATH.test(path),
- key;
-
- if (!target || isGlobal) target = Ember.lookup;
- if (hasThis) path = path.slice(5);
-
- if (target === Ember.lookup) {
- key = path.match(FIRST_KEY)[0];
- target = get(target, key);
- path = path.slice(key.length+1);
- }
-
- // must return some kind of path to be valid else other things will break.
- if (!path || path.length===0) throw new Ember.Error('Path cannot be empty');
-
- return [ target, path ];
-};
-
-var getPath = Ember._getPath = function(root, path) {
- var hasThis, parts, tuple, idx, len;
-
- // If there is no root and path is a key name, return that
- // property from the global object.
- // E.g. get('Ember') -> Ember
- if (root === null && path.indexOf('.') === -1) { return get(Ember.lookup, path); }
-
- // detect complicated paths and normalize them
- hasThis = HAS_THIS.test(path);
-
- if (!root || hasThis) {
- tuple = normalizeTuple(root, path);
- root = tuple[0];
- path = tuple[1];
- tuple.length = 0;
- }
-
- parts = path.split(".");
- len = parts.length;
- for (idx = 0; root != null && idx < len; idx++) {
- root = get(root, parts[idx], true);
- if (root && root.isDestroyed) { return undefined; }
- }
- return root;
-};
-
-Ember.getWithDefault = function(root, key, defaultValue) {
- var value = get(root, key);
-
- if (value === undefined) { return defaultValue; }
- return value;
-};
-
-
-Ember.get = get;
-
-})();
-
-
-
-(function() {
-/**
-@module ember-metal
-*/
-
-var o_create = Ember.create,
- metaFor = Ember.meta,
- META_KEY = Ember.META_KEY,
- a_slice = [].slice,
- /* listener flags */
- ONCE = 1, SUSPENDED = 2;
-
-/*
- The event system uses a series of nested hashes to store listeners on an
- object. When a listener is registered, or when an event arrives, these
- hashes are consulted to determine which target and action pair to invoke.
-
- The hashes are stored in the object's meta hash, and look like this:
-
- // Object's meta hash
- {
- listeners: { // variable name: `listenerSet`
- "foo:changed": [ // variable name: `actions`
- target, method, flags
- ]
- }
- }
-
-*/
-
-function indexOf(array, target, method) {
- var index = -1;
- // hashes are added to the end of the event array
- // so it makes sense to start searching at the end
- // of the array and search in reverse
- for (var i = array.length - 3 ; i >=0; i -= 3) {
- if (target === array[i] && method === array[i + 1]) {
- index = i; break;
- }
- }
- return index;
-}
-
-function actionsFor(obj, eventName) {
- var meta = metaFor(obj, true),
- actions;
-
- if (!meta.listeners) { meta.listeners = {}; }
-
- if (!meta.hasOwnProperty('listeners')) {
- // setup inherited copy of the listeners object
- meta.listeners = o_create(meta.listeners);
- }
-
- actions = meta.listeners[eventName];
-
- // if there are actions, but the eventName doesn't exist in our listeners, then copy them from the prototype
- if (actions && !meta.listeners.hasOwnProperty(eventName)) {
- actions = meta.listeners[eventName] = meta.listeners[eventName].slice();
- } else if (!actions) {
- actions = meta.listeners[eventName] = [];
- }
-
- return actions;
-}
-
-function actionsUnion(obj, eventName, otherActions) {
- var meta = obj[META_KEY],
- actions = meta && meta.listeners && meta.listeners[eventName];
-
- if (!actions) { return; }
- for (var i = actions.length - 3; i >= 0; i -= 3) {
- var target = actions[i],
- method = actions[i+1],
- flags = actions[i+2],
- actionIndex = indexOf(otherActions, target, method);
-
- if (actionIndex === -1) {
- otherActions.push(target, method, flags);
- }
- }
-}
-
-function actionsDiff(obj, eventName, otherActions) {
- var meta = obj[META_KEY],
- actions = meta && meta.listeners && meta.listeners[eventName],
- diffActions = [];
-
- if (!actions) { return; }
- for (var i = actions.length - 3; i >= 0; i -= 3) {
- var target = actions[i],
- method = actions[i+1],
- flags = actions[i+2],
- actionIndex = indexOf(otherActions, target, method);
-
- if (actionIndex !== -1) { continue; }
-
- otherActions.push(target, method, flags);
- diffActions.push(target, method, flags);
- }
-
- return diffActions;
-}
-
-/**
- Add an event listener
-
- @method addListener
- @for Ember
- @param obj
- @param {String} eventName
- @param {Object|Function} targetOrMethod A target object or a function
- @param {Function|String} method A function or the name of a function to be called on `target`
- @param {Boolean} once A flag whether a function should only be called once
-*/
-function addListener(obj, eventName, target, method, once) {
-
- if (!method && 'function' === typeof target) {
- method = target;
- target = null;
- }
-
- var actions = actionsFor(obj, eventName),
- actionIndex = indexOf(actions, target, method),
- flags = 0;
-
- if (once) flags |= ONCE;
-
- if (actionIndex !== -1) { return; }
-
- actions.push(target, method, flags);
-
- if ('function' === typeof obj.didAddListener) {
- obj.didAddListener(eventName, target, method);
- }
-}
-
-/**
- Remove an event listener
-
- Arguments should match those passed to `Ember.addListener`.
-
- @method removeListener
- @for Ember
- @param obj
- @param {String} eventName
- @param {Object|Function} targetOrMethod A target object or a function
- @param {Function|String} method A function or the name of a function to be called on `target`
-*/
-function removeListener(obj, eventName, target, method) {
-
- if (!method && 'function' === typeof target) {
- method = target;
- target = null;
- }
-
- function _removeListener(target, method) {
- var actions = actionsFor(obj, eventName),
- actionIndex = indexOf(actions, target, method);
-
- // action doesn't exist, give up silently
- if (actionIndex === -1) { return; }
-
- actions.splice(actionIndex, 3);
-
- if ('function' === typeof obj.didRemoveListener) {
- obj.didRemoveListener(eventName, target, method);
- }
- }
-
- if (method) {
- _removeListener(target, method);
- } else {
- var meta = obj[META_KEY],
- actions = meta && meta.listeners && meta.listeners[eventName];
-
- if (!actions) { return; }
- for (var i = actions.length - 3; i >= 0; i -= 3) {
- _removeListener(actions[i], actions[i+1]);
- }
- }
-}
-
-/**
- Suspend listener during callback.
-
- This should only be used by the target of the event listener
- when it is taking an action that would cause the event, e.g.
- an object might suspend its property change listener while it is
- setting that property.
-
- @method suspendListener
- @for Ember
-
- @private
- @param obj
- @param {String} eventName
- @param {Object|Function} targetOrMethod A target object or a function
- @param {Function|String} method A function or the name of a function to be called on `target`
- @param {Function} callback
-*/
-function suspendListener(obj, eventName, target, method, callback) {
- if (!method && 'function' === typeof target) {
- method = target;
- target = null;
- }
-
- var actions = actionsFor(obj, eventName),
- actionIndex = indexOf(actions, target, method);
-
- if (actionIndex !== -1) {
- actions[actionIndex+2] |= SUSPENDED; // mark the action as suspended
- }
-
- function tryable() { return callback.call(target); }
- function finalizer() { if (actionIndex !== -1) { actions[actionIndex+2] &= ~SUSPENDED; } }
-
- return Ember.tryFinally(tryable, finalizer);
-}
-
-/**
- Suspends multiple listeners during a callback.
-
- @method suspendListeners
- @for Ember
-
- @private
- @param obj
- @param {Array} eventName Array of event names
- @param {Object|Function} targetOrMethod A target object or a function
- @param {Function|String} method A function or the name of a function to be called on `target`
- @param {Function} callback
-*/
-function suspendListeners(obj, eventNames, target, method, callback) {
- if (!method && 'function' === typeof target) {
- method = target;
- target = null;
- }
-
- var suspendedActions = [],
- actionsList = [],
- eventName, actions, i, l;
-
- for (i=0, l=eventNames.length; i<l; i++) {
- eventName = eventNames[i];
- actions = actionsFor(obj, eventName);
- var actionIndex = indexOf(actions, target, method);
-
- if (actionIndex !== -1) {
- actions[actionIndex+2] |= SUSPENDED;
- suspendedActions.push(actionIndex);
- actionsList.push(actions);
- }
- }
-
- function tryable() { return callback.call(target); }
-
- function finalizer() {
- for (var i = 0, l = suspendedActions.length; i < l; i++) {
- var actionIndex = suspendedActions[i];
- actionsList[i][actionIndex+2] &= ~SUSPENDED;
- }
- }
-
- return Ember.tryFinally(tryable, finalizer);
-}
-
-/**
- Return a list of currently watched events
-
- @private
- @method watchedEvents
- @for Ember
- @param obj
-*/
-function watchedEvents(obj) {
- var listeners = obj[META_KEY].listeners, ret = [];
-
- if (listeners) {
- for(var eventName in listeners) {
- if (listeners[eventName]) { ret.push(eventName); }
- }
- }
- return ret;
-}
-
-/**
- Send an event. The execution of suspended listeners
- is skipped, and once listeners are removed. A listener without
- a target is executed on the passed object. If an array of actions
- is not passed, the actions stored on the passed object are invoked.
-
- @method sendEvent
- @for Ember
- @param obj
- @param {String} eventName
- @param {Array} params Optional parameters for each listener.
- @param {Array} actions Optional array of actions (listeners).
- @return true
-*/
-function sendEvent(obj, eventName, params, actions) {
- // first give object a chance to handle it
- if (obj !== Ember && 'function' === typeof obj.sendEvent) {
- obj.sendEvent(eventName, params);
- }
-
- if (!actions) {
- var meta = obj[META_KEY];
- actions = meta && meta.listeners && meta.listeners[eventName];
- }
-
- if (!actions) { return; }
-
- for (var i = actions.length - 3; i >= 0; i -= 3) { // looping in reverse for once listeners
- var target = actions[i], method = actions[i+1], flags = actions[i+2];
- if (!method) { continue; }
- if (flags & SUSPENDED) { continue; }
- if (flags & ONCE) { removeListener(obj, eventName, target, method); }
- if (!target) { target = obj; }
- if ('string' === typeof method) { method = target[method]; }
- if (params) {
- method.apply(target, params);
- } else {
- method.call(target);
- }
- }
- return true;
-}
-
-/**
- @private
- @method hasListeners
- @for Ember
- @param obj
- @param {String} eventName
-*/
-function hasListeners(obj, eventName) {
- var meta = obj[META_KEY],
- actions = meta && meta.listeners && meta.listeners[eventName];
-
- return !!(actions && actions.length);
-}
-
-/**
- @private
- @method listenersFor
- @for Ember
- @param obj
- @param {String} eventName
-*/
-function listenersFor(obj, eventName) {
- var ret = [];
- var meta = obj[META_KEY],
- actions = meta && meta.listeners && meta.listeners[eventName];
-
- if (!actions) { return ret; }
-
- for (var i = 0, l = actions.length; i < l; i += 3) {
- var target = actions[i],
- method = actions[i+1];
- ret.push([target, method]);
- }
-
- return ret;
-}
-
-/**
- Define a property as a function that should be executed when
- a specified event or events are triggered.
-
-
- ``` javascript
- var Job = Ember.Object.extend({
- logCompleted: Ember.on('completed', function(){
- console.log('Job completed!');
- })
- });
- var job = Job.create();
- Ember.sendEvent(job, 'completed'); // Logs "Job completed!"
- ```
-
- @method on
- @for Ember
- @param {String} eventNames*
- @param {Function} func
- @return func
-*/
-Ember.on = function(){
- var func = a_slice.call(arguments, -1)[0],
- events = a_slice.call(arguments, 0, -1);
- func.__ember_listens__ = events;
- return func;
-};
-
-Ember.addListener = addListener;
-Ember.removeListener = removeListener;
-Ember._suspendListener = suspendListener;
-Ember._suspendListeners = suspendListeners;
-Ember.sendEvent = sendEvent;
-Ember.hasListeners = hasListeners;
-Ember.watchedEvents = watchedEvents;
-Ember.listenersFor = listenersFor;
-Ember.listenersDiff = actionsDiff;
-Ember.listenersUnion = actionsUnion;
-
-})();
-
-
-
-(function() {
-var guidFor = Ember.guidFor,
- sendEvent = Ember.sendEvent;
-
-/*
- this.observerSet = {
- [senderGuid]: { // variable name: `keySet`
- [keyName]: listIndex
- }
- },
- this.observers = [
- {
- sender: obj,
- keyName: keyName,
- eventName: eventName,
- listeners: [
- [target, method, flags]
- ]
- },
- ...
- ]
-*/
-var ObserverSet = Ember._ObserverSet = function() {
- this.clear();
-};
-
-ObserverSet.prototype.add = function(sender, keyName, eventName) {
- var observerSet = this.observerSet,
- observers = this.observers,
- senderGuid = guidFor(sender),
- keySet = observerSet[senderGuid],
- index;
-
- if (!keySet) {
- observerSet[senderGuid] = keySet = {};
- }
- index = keySet[keyName];
- if (index === undefined) {
- index = observers.push({
- sender: sender,
- keyName: keyName,
- eventName: eventName,
- listeners: []
- }) - 1;
- keySet[keyName] = index;
- }
- return observers[index].listeners;
-};
-
-ObserverSet.prototype.flush = function() {
- var observers = this.observers, i, len, observer, sender;
- this.clear();
- for (i=0, len=observers.length; i < len; ++i) {
- observer = observers[i];
- sender = observer.sender;
- if (sender.isDestroying || sender.isDestroyed) { continue; }
- sendEvent(sender, observer.eventName, [sender, observer.keyName], observer.listeners);
- }
-};
-
-ObserverSet.prototype.clear = function() {
- this.observerSet = {};
- this.observers = [];
-};
-})();
-
-
-
-(function() {
-var META_KEY = Ember.META_KEY,
- guidFor = Ember.guidFor,
- tryFinally = Ember.tryFinally,
- sendEvent = Ember.sendEvent,
- listenersUnion = Ember.listenersUnion,
- listenersDiff = Ember.listenersDiff,
- ObserverSet = Ember._ObserverSet,
- beforeObserverSet = new ObserverSet(),
- observerSet = new ObserverSet(),
- deferred = 0;
-
-// ..........................................................
-// PROPERTY CHANGES
-//
-
-/**
- This function is called just before an object property is about to change.
- It will notify any before observers and prepare caches among other things.
-
- Normally you will not need to call this method directly but if for some
- reason you can't directly watch a property you can invoke this method
- manually along with `Ember.propertyDidChange()` which you should call just
- after the property value changes.
-
- @method propertyWillChange
- @for Ember
- @param {Object} obj The object with the property that will change
- @param {String} keyName The property key (or path) that will change.
- @return {void}
-*/
-function propertyWillChange(obj, keyName) {
- var m = obj[META_KEY],
- watching = (m && m.watching[keyName] > 0) || keyName === 'length',
- proto = m && m.proto,
- desc = m && m.descs[keyName];
-
- if (!watching) { return; }
- if (proto === obj) { return; }
- if (desc && desc.willChange) { desc.willChange(obj, keyName); }
- dependentKeysWillChange(obj, keyName, m);
- chainsWillChange(obj, keyName, m);
- notifyBeforeObservers(obj, keyName);
-}
-Ember.propertyWillChange = propertyWillChange;
-
-/**
- This function is called just after an object property has changed.
- It will notify any observers and clear caches among other things.
-
- Normally you will not need to call this method directly but if for some
- reason you can't directly watch a property you can invoke this method
- manually along with `Ember.propertyWillChange()` which you should call just
- before the property value changes.
-
- @method propertyDidChange
- @for Ember
- @param {Object} obj The object with the property that will change
- @param {String} keyName The property key (or path) that will change.
- @return {void}
-*/
-function propertyDidChange(obj, keyName) {
- var m = obj[META_KEY],
- watching = (m && m.watching[keyName] > 0) || keyName === 'length',
- proto = m && m.proto,
- desc = m && m.descs[keyName];
-
- if (proto === obj) { return; }
-
- // shouldn't this mean that we're watching this key?
- if (desc && desc.didChange) { desc.didChange(obj, keyName); }
- if (!watching && keyName !== 'length') { return; }
-
- dependentKeysDidChange(obj, keyName, m);
- chainsDidChange(obj, keyName, m, false);
- notifyObservers(obj, keyName);
-}
-Ember.propertyDidChange = propertyDidChange;
-
-var WILL_SEEN, DID_SEEN;
-
-// called whenever a property is about to change to clear the cache of any dependent keys (and notify those properties of changes, etc...)
-function dependentKeysWillChange(obj, depKey, meta) {
- if (obj.isDestroying) { return; }
-
- var seen = WILL_SEEN, top = !seen;
- if (top) { seen = WILL_SEEN = {}; }
- iterDeps(propertyWillChange, obj, depKey, seen, meta);
- if (top) { WILL_SEEN = null; }
-}
-
-// called whenever a property has just changed to update dependent keys
-function dependentKeysDidChange(obj, depKey, meta) {
- if (obj.isDestroying) { return; }
-
- var seen = DID_SEEN, top = !seen;
- if (top) { seen = DID_SEEN = {}; }
- iterDeps(propertyDidChange, obj, depKey, seen, meta);
- if (top) { DID_SEEN = null; }
-}
-
-function iterDeps(method, obj, depKey, seen, meta) {
- var guid = guidFor(obj);
- if (!seen[guid]) seen[guid] = {};
- if (seen[guid][depKey]) return;
- seen[guid][depKey] = true;
-
- var deps = meta.deps;
- deps = deps && deps[depKey];
- if (deps) {
- for(var key in deps) {
- var desc = meta.descs[key];
- if (desc && desc._suspended === obj) continue;
- method(obj, key);
- }
- }
-}
-
-function chainsWillChange(obj, keyName, m) {
- if (!(m.hasOwnProperty('chainWatchers') &&
- m.chainWatchers[keyName])) {
- return;
- }
-
- var nodes = m.chainWatchers[keyName],
- events = [],
- i, l;
-
- for(i = 0, l = nodes.length; i < l; i++) {
- nodes[i].willChange(events);
- }
-
- for (i = 0, l = events.length; i < l; i += 2) {
- propertyWillChange(events[i], events[i+1]);
- }
-}
-
-function chainsDidChange(obj, keyName, m, suppressEvents) {
- if (!(m && m.hasOwnProperty('chainWatchers') &&
- m.chainWatchers[keyName])) {
- return;
- }
-
- var nodes = m.chainWatchers[keyName],
- events = suppressEvents ? null : [],
- i, l;
-
- for(i = 0, l = nodes.length; i < l; i++) {
- nodes[i].didChange(events);
- }
-
- if (suppressEvents) {
- return;
- }
-
- for (i = 0, l = events.length; i < l; i += 2) {
- propertyDidChange(events[i], events[i+1]);
- }
-}
-
-Ember.overrideChains = function(obj, keyName, m) {
- chainsDidChange(obj, keyName, m, true);
-};
-
-/**
- @method beginPropertyChanges
- @chainable
- @private
-*/
-function beginPropertyChanges() {
- deferred++;
-}
-
-Ember.beginPropertyChanges = beginPropertyChanges;
-
-/**
- @method endPropertyChanges
- @private
-*/
-function endPropertyChanges() {
- deferred--;
- if (deferred<=0) {
- beforeObserverSet.clear();
- observerSet.flush();
- }
-}
-
-Ember.endPropertyChanges = endPropertyChanges;
-
-/**
- Make a series of property changes together in an
- exception-safe way.
-
- ```javascript
- Ember.changeProperties(function() {
- obj1.set('foo', mayBlowUpWhenSet);
- obj2.set('bar', baz);
- });
- ```
-
- @method changeProperties
- @param {Function} callback
- @param [binding]
-*/
-Ember.changeProperties = function(cb, binding) {
- beginPropertyChanges();
- tryFinally(cb, endPropertyChanges, binding);
-};
-
-function notifyBeforeObservers(obj, keyName) {
- if (obj.isDestroying) { return; }
-
- var eventName = keyName + ':before', listeners, diff;
- if (deferred) {
- listeners = beforeObserverSet.add(obj, keyName, eventName);
- diff = listenersDiff(obj, eventName, listeners);
- sendEvent(obj, eventName, [obj, keyName], diff);
- } else {
- sendEvent(obj, eventName, [obj, keyName]);
- }
-}
-
-function notifyObservers(obj, keyName) {
- if (obj.isDestroying) { return; }
-
- var eventName = keyName + ':change', listeners;
- if (deferred) {
- listeners = observerSet.add(obj, keyName, eventName);
- listenersUnion(obj, eventName, listeners);
- } else {
- sendEvent(obj, eventName, [obj, keyName]);
- }
-}
-
-})();
-
-
-
-(function() {
-// META_KEY
-// _getPath
-// propertyWillChange, propertyDidChange
-
-var META_KEY = Ember.META_KEY,
- MANDATORY_SETTER = Ember.ENV.MANDATORY_SETTER,
- IS_GLOBAL = /^([A-Z$]|([0-9][A-Z$]))/,
- getPath = Ember._getPath;
-
-/**
- Sets the value of a property on an object, respecting computed properties
- and notifying observers and other listeners of the change. If the
- property is not defined but the object implements the `setUnknownProperty`
- method then that will be invoked as well.
-
- @method set
- @for Ember
- @param {Object} obj The object to modify.
- @param {String} keyName The property key to set
- @param {Object} value The value to set
- @return {Object} the passed value.
-*/
-var set = function set(obj, keyName, value, tolerant) {
- if (typeof obj === 'string') {
- value = keyName;
- keyName = obj;
- obj = null;
- }
-
-
- if (!obj || keyName.indexOf('.') !== -1) {
- return setPath(obj, keyName, value, tolerant);
- }
-
-
- var meta = obj[META_KEY], desc = meta && meta.descs[keyName],
- isUnknown, currentValue;
- if (desc) {
- desc.set(obj, keyName, value);
- } else {
- isUnknown = 'object' === typeof obj && !(keyName in obj);
-
- // setUnknownProperty is called if `obj` is an object,
- // the property does not already exist, and the
- // `setUnknownProperty` method exists on the object
- if (isUnknown && 'function' === typeof obj.setUnknownProperty) {
- obj.setUnknownProperty(keyName, value);
- } else if (meta && meta.watching[keyName] > 0) {
- if (MANDATORY_SETTER) {
- currentValue = meta.values[keyName];
- } else {
- currentValue = obj[keyName];
- }
- // only trigger a change if the value has changed
- if (value !== currentValue) {
- Ember.propertyWillChange(obj, keyName);
- if (MANDATORY_SETTER) {
- if ((currentValue === undefined && !(keyName in obj)) || !obj.propertyIsEnumerable(keyName)) {
- Ember.defineProperty(obj, keyName, null, value); // setup mandatory setter
- } else {
- meta.values[keyName] = value;
- }
- } else {
- obj[keyName] = value;
- }
- Ember.propertyDidChange(obj, keyName);
- }
- } else {
- obj[keyName] = value;
- }
- }
- return value;
-};
-
-// Currently used only by Ember Data tests
-if (Ember.config.overrideAccessors) {
- Ember.set = set;
- Ember.config.overrideAccessors();
- set = Ember.set;
-}
-
-function setPath(root, path, value, tolerant) {
- var keyName;
-
- // get the last part of the path
- keyName = path.slice(path.lastIndexOf('.') + 1);
-
- // get the first part of the part
- path = (path === keyName) ? keyName : path.slice(0, path.length-(keyName.length+1));
-
- // unless the path is this, look up the first part to
- // get the root
- if (path !== 'this') {
- root = getPath(root, path);
- }
-
- if (!keyName || keyName.length === 0) {
- throw new Ember.Error('Property set failed: You passed an empty path');
- }
-
- if (!root) {
- if (tolerant) { return; }
- else { throw new Ember.Error('Property set failed: object in path "'+path+'" could not be found or was destroyed.'); }
- }
-
- return set(root, keyName, value);
-}
-
-Ember.set = set;
-
-/**
- Error-tolerant form of `Ember.set`. Will not blow up if any part of the
- chain is `undefined`, `null`, or destroyed.
-
- This is primarily used when syncing bindings, which may try to update after
- an object has been destroyed.
-
- @method trySet
- @for Ember
- @param {Object} obj The object to modify.
- @param {String} path The property path to set
- @param {Object} value The value to set
-*/
-Ember.trySet = function(root, path, value) {
- return set(root, path, value, true);
-};
-
-})();
-
-
-
-(function() {
-/**
-@module ember-metal
-*/
-
-/*
- JavaScript (before ES6) does not have a Map implementation. Objects,
- which are often used as dictionaries, may only have Strings as keys.
-
- Because Ember has a way to get a unique identifier for every object
- via `Ember.guidFor`, we can implement a performant Map with arbitrary
- keys. Because it is commonly used in low-level bookkeeping, Map is
- implemented as a pure JavaScript object for performance.
-
- This implementation follows the current iteration of the ES6 proposal for
- maps (http://wiki.ecmascript.org/doku.php?id=harmony:simple_maps_and_sets),
- with two exceptions. First, because we need our implementation to be pleasant
- on older browsers, we do not use the `delete` name (using `remove` instead).
- Second, as we do not have the luxury of in-VM iteration, we implement a
- forEach method for iteration.
-
- Map is mocked out to look like an Ember object, so you can do
- `Ember.Map.create()` for symmetry with other Ember classes.
-*/
-var set = Ember.set,
- guidFor = Ember.guidFor,
- indexOf = Ember.ArrayPolyfills.indexOf;
-
-var copy = function(obj) {
- var output = {};
-
- for (var prop in obj) {
- if (obj.hasOwnProperty(prop)) { output[prop] = obj[prop]; }
- }
-
- return output;
-};
-
-var copyMap = function(original, newObject) {
- var keys = original.keys.copy(),
- values = copy(original.values);
-
- newObject.keys = keys;
- newObject.values = values;
- newObject.length = original.length;
-
- return newObject;
-};
-
-/**
- This class is used internally by Ember and Ember Data.
- Please do not use it at this time. We plan to clean it up
- and add many tests soon.
-
- @class OrderedSet
- @namespace Ember
- @constructor
- @private
-*/
-var OrderedSet = Ember.OrderedSet = function() {
- this.clear();
-};
-
-/**
- @method create
- @static
- @return {Ember.OrderedSet}
-*/
-OrderedSet.create = function() {
- return new OrderedSet();
-};
-
-
-OrderedSet.prototype = {
- /**
- @method clear
- */
- clear: function() {
- this.presenceSet = {};
- this.list = [];
- },
-
- /**
- @method add
- @param obj
- */
- add: function(obj) {
- var guid = guidFor(obj),
- presenceSet = this.presenceSet,
- list = this.list;
-
- if (guid in presenceSet) { return; }
-
- presenceSet[guid] = true;
- list.push(obj);
- },
-
- /**
- @method remove
- @param obj
- */
- remove: function(obj) {
- var guid = guidFor(obj),
- presenceSet = this.presenceSet,
- list = this.list;
-
- delete presenceSet[guid];
-
- var index = indexOf.call(list, obj);
- if (index > -1) {
- list.splice(index, 1);
- }
- },
-
- /**
- @method isEmpty
- @return {Boolean}
- */
- isEmpty: function() {
- return this.list.length === 0;
- },
-
- /**
- @method has
- @param obj
- @return {Boolean}
- */
- has: function(obj) {
- var guid = guidFor(obj),
- presenceSet = this.presenceSet;
-
- return guid in presenceSet;
- },
-
- /**
- @method forEach
- @param {Function} fn
- @param self
- */
- forEach: function(fn, self) {
- // allow mutation during iteration
- var list = this.toArray();
-
- for (var i = 0, j = list.length; i < j; i++) {
- fn.call(self, list[i]);
- }
- },
-
- /**
- @method toArray
- @return {Array}
- */
- toArray: function() {
- return this.list.slice();
- },
-
- /**
- @method copy
- @return {Ember.OrderedSet}
- */
- copy: function() {
- var set = new OrderedSet();
-
- set.presenceSet = copy(this.presenceSet);
- set.list = this.toArray();
-
- return set;
- }
-};
-
-/**
- A Map stores values indexed by keys. Unlike JavaScript's
- default Objects, the keys of a Map can be any JavaScript
- object.
-
- Internally, a Map has two data structures:
-
- 1. `keys`: an OrderedSet of all of the existing keys
- 2. `values`: a JavaScript Object indexed by the `Ember.guidFor(key)`
-
- When a key/value pair is added for the first time, we
- add the key to the `keys` OrderedSet, and create or
- replace an entry in `values`. When an entry is deleted,
- we delete its entry in `keys` and `values`.
-
- @class Map
- @namespace Ember
- @private
- @constructor
-*/
-var Map = Ember.Map = function() {
- this.keys = Ember.OrderedSet.create();
- this.values = {};
-};
-
-/**
- @method create
- @static
-*/
-Map.create = function() {
- return new Map();
-};
-
-Map.prototype = {
- /**
- This property will change as the number of objects in the map changes.
-
- @property length
- @type number
- @default 0
- */
- length: 0,
-
-
- /**
- Retrieve the value associated with a given key.
-
- @method get
- @param {*} key
- @return {*} the value associated with the key, or `undefined`
- */
- get: function(key) {
- var values = this.values,
- guid = guidFor(key);
-
- return values[guid];
- },
-
- /**
- Adds a value to the map. If a value for the given key has already been
- provided, the new value will replace the old value.
-
- @method set
- @param {*} key
- @param {*} value
- */
- set: function(key, value) {
- var keys = this.keys,
- values = this.values,
- guid = guidFor(key);
-
- keys.add(key);
- values[guid] = value;
- set(this, 'length', keys.list.length);
- },
-
- /**
- Removes a value from the map for an associated key.
-
- @method remove
- @param {*} key
- @return {Boolean} true if an item was removed, false otherwise
- */
- remove: function(key) {
- // don't use ES6 "delete" because it will be annoying
- // to use in browsers that are not ES6 friendly;
- var keys = this.keys,
- values = this.values,
- guid = guidFor(key);
-
- if (values.hasOwnProperty(guid)) {
- keys.remove(key);
- delete values[guid];
- set(this, 'length', keys.list.length);
- return true;
- } else {
- return false;
- }
- },
-
- /**
- Check whether a key is present.
-
- @method has
- @param {*} key
- @return {Boolean} true if the item was present, false otherwise
- */
- has: function(key) {
- var values = this.values,
- guid = guidFor(key);
-
- return values.hasOwnProperty(guid);
- },
-
- /**
- Iterate over all the keys and values. Calls the function once
- for each key, passing in the key and value, in that order.
-
- The keys are guaranteed to be iterated over in insertion order.
-
- @method forEach
- @param {Function} callback
- @param {*} self if passed, the `this` value inside the
- callback. By default, `this` is the map.
- */
- forEach: function(callback, self) {
- var keys = this.keys,
- values = this.values;
-
- keys.forEach(function(key) {
- var guid = guidFor(key);
- callback.call(self, key, values[guid]);
- });
- },
-
- /**
- @method copy
- @return {Ember.Map}
- */
- copy: function() {
- return copyMap(this, new Map());
- }
-};
-
-/**
- @class MapWithDefault
- @namespace Ember
- @extends Ember.Map
- @private
- @constructor
- @param [options]
- @param {*} [options.defaultValue]
-*/
-var MapWithDefault = Ember.MapWithDefault = function(options) {
- Map.call(this);
- this.defaultValue = options.defaultValue;
-};
-
-/**
- @method create
- @static
- @param [optio
<TRUNCATED>