From 2c6c09e88bc561848336e2890022929b0c7f1db8 Mon Sep 17 00:00:00 2001 From: Piotr Sarnacki Date: Fri, 10 Jan 2014 18:04:49 +0100 Subject: [PATCH] Update ember.js with 1.3.0 without conflicts --- assets/scripts/vendor/ember.js | 15693 +------------------------------ 1 file changed, 432 insertions(+), 15261 deletions(-) diff --git a/assets/scripts/vendor/ember.js b/assets/scripts/vendor/ember.js index c5b93786..2758331a 100644 --- a/assets/scripts/vendor/ember.js +++ b/assets/scripts/vendor/ember.js @@ -1,13 +1,3 @@ -<<<<<<< HEAD -// ========================================================================== -// Project: Ember - JavaScript Application Framework -// Copyright: Copyright 2011-2013 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 -// ========================================================================== -======= /*! * @overview Ember - JavaScript Application Framework * @copyright Copyright 2011-2014 Tilde Inc. and contributors @@ -17,11 +7,8 @@ * See https://raw.github.com/emberjs/ember.js/master/LICENSE * @version 1.3.0 */ ->>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147 - // Version: 1.2.0 - (function() { /*global __fail__*/ @@ -209,16 +196,6 @@ if (!Ember.testing) { })(); -<<<<<<< HEAD -// ========================================================================== -// Project: Ember - JavaScript Application Framework -// Copyright: Copyright 2011-2013 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 -// ========================================================================== -======= /*! * @overview Ember - JavaScript Application Framework * @copyright Copyright 2011-2014 Tilde Inc. and contributors @@ -228,11 +205,8 @@ if (!Ember.testing) { * See https://raw.github.com/emberjs/ember.js/master/LICENSE * @version 1.3.0 */ ->>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147 - // Version: 1.2.0 - (function() { var define, requireModule, require, requirejs; @@ -312,11 +286,7 @@ var define, requireModule, require, requirejs; @class Ember @static -<<<<<<< HEAD - @version 1.2.0 -======= @version 1.3.0 ->>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147 */ if ('undefined' === typeof Ember) { @@ -343,17 +313,10 @@ 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 `EmberENV` @@ -430,45 +393,6 @@ Ember.FEATURES.isEnabled = function(feature) { } }; -/** - 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 // @@ -911,8 +835,6 @@ 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 @@ -923,7 +845,6 @@ Ember.Error = function() { 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]]; @@ -957,16 +878,9 @@ 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 @@ -996,15 +910,8 @@ 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'; @@ -2344,11 +2251,7 @@ function suspendListener(obj, eventName, target, method, callback) { /** Suspends multiple listeners during a callback. -<<<<<<< HEAD - -======= @private ->>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147 @method suspendListeners @for Ember @param obj @@ -2415,7 +2318,7 @@ function watchedEvents(obj) { 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 @@ -2951,20 +2854,12 @@ 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); @@ -3374,11 +3269,7 @@ 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') { @@ -3390,17 +3281,11 @@ 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, ', '); @@ -3445,10 +3330,7 @@ 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. @@ -3462,14 +3344,9 @@ 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 @@ -3481,10 +3358,7 @@ 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. @@ -3499,10 +3373,7 @@ 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. @@ -3517,15 +3388,9 @@ 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 @@ -4177,13 +4042,6 @@ Ember.finishChains = function(obj) { (function() { -<<<<<<< HEAD -/** - @module ember-metal -*/ - -======= ->>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147 })(); @@ -4252,7 +4110,6 @@ var metaFor = Ember.meta, // utils.js generateGuid = Ember.generateGuid, IS_PATH = /[\.\*]/; - // returns true if the passed path is just a keyName function isKeyName(path) { return path==='*' || !IS_PATH.test(path); @@ -4275,21 +4132,11 @@ 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); - } else { - watchPath(obj, _keyPath); - } - -======= if (isKeyName(_keyPath)) { watchKey(obj, _keyPath); } else { watchPath(obj, _keyPath); } ->>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147 }; Ember.isWatching = function isWatching(obj, key) { @@ -4303,21 +4150,11 @@ 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); - } else { - unwatchPath(obj, _keyPath); - } - -======= if (isKeyName(_keyPath)) { unwatchKey(obj, _keyPath); } else { unwatchPath(obj, _keyPath); } ->>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147 }; /** @@ -4670,24 +4507,12 @@ ComputedPropertyPrototype.readOnly = function(readOnly) { @chainable */ ComputedPropertyPrototype.property = function() { -<<<<<<< HEAD - var addArg; - - - var args = []; - for (var i = 0, l = arguments.length; i < l; i++) { - - args.push(arguments[i]); - - } -======= var args; args = a_slice.call(arguments); ->>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147 this._dependentKeys = args; return this; }; @@ -5001,22 +4826,15 @@ 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 @@ -5396,11 +5214,7 @@ 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] @@ -5409,11 +5223,7 @@ 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 @@ -5558,10 +5368,6 @@ Ember.computed.defaultTo = function(defaultPath) { var AFTER_OBSERVERS = ':change', BEFORE_OBSERVERS = ':before'; -<<<<<<< HEAD - -======= ->>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147 function changeEvent(keyName) { return keyName+AFTER_OBSERVERS; @@ -5579,15 +5385,8 @@ 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; }; @@ -5604,16 +5403,9 @@ 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; }; @@ -5625,16 +5417,9 @@ 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; }; @@ -5674,16 +5459,9 @@ 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; }; @@ -6111,13 +5889,9 @@ define("backburner", var self = this, args = arguments, wait = parseInt(pop.call(args), 10), -<<<<<<< HEAD - throttler; -======= throttler, index, timer; ->>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147 index = findThrottler(target, method); if (index > -1) { return throttlers[index]; } // throttled @@ -6162,11 +5936,7 @@ define("backburner", clearTimeout(debouncee[2]); } -<<<<<<< HEAD - var timer = global.setTimeout(function() { -======= timer = global.setTimeout(function() { ->>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147 if (!immediate) { self.run.apply(self, args); } @@ -6342,7 +6112,6 @@ define("backburner", __exports__.Backburner = Backburner; }); - })(); @@ -8019,16 +7788,6 @@ Ember.aliasMethod = function(methodName) { */ Ember.observer = function() { var func = a_slice.call(arguments, -1)[0]; -<<<<<<< HEAD - var 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); - } -======= var paths; @@ -8041,7 +7800,6 @@ Ember.observer = function() { paths = a_slice.call(arguments, 1); } ->>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147 if (typeof func !== "function") { throw new Ember.Error("Ember.observer called without a function"); @@ -8128,16 +7886,6 @@ 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") { - // revert to old, soft-deprecated argument ordering - - func = arguments[0]; - paths = a_slice.call(arguments, 1); - } -======= var paths; @@ -8150,7 +7898,6 @@ Ember.beforeObserver = function() { paths = a_slice.call(arguments, 1); } ->>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147 if (typeof func !== "function") { throw new Ember.Error("Ember.beforeObserver called without a function"); @@ -8168,8 +7915,6 @@ 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 = []; @@ -8215,56 +7960,6 @@ 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 @@ -8275,10 +7970,6 @@ Ember Metal })(); -(function() { -define("rsvp/all", - ["rsvp/promise","exports"], -======= (function() { /** @class RSVP @@ -8286,7 +7977,6 @@ define("rsvp/all", */ define("rsvp/all", ["./promise","exports"], ->>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147 function(__dependency1__, __exports__) { "use strict"; var Promise = __dependency1__["default"]; @@ -8424,23 +8114,7 @@ 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; - var local = (typeof global !== 'undefined') ? global : this; - - // old node - function useNextTick() { - return function(callback, arg) { - process.nextTick(function() { - callback(arg); - }); - }; - } -======= var EventTarget = __dependency1__["default"]; ->>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147 var config = { instrument: false @@ -8480,21 +8154,11 @@ define("rsvp/defer", The object returned from `RSVP.defer` is a plain object with three properties: -<<<<<<< HEAD - function useSetTimeout() { - return function(callback, arg) { - local.setTimeout(function() { - callback(arg); - }, 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 Example: @@ -8991,13 +8655,6 @@ define("rsvp/instrument", var config = __dependency1__.config; 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 { @@ -9014,7 +8671,6 @@ define("rsvp/instrument", setTimeout(function(){ throw error; }, 0); ->>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147 } }; }); @@ -9127,44 +8783,11 @@ define("rsvp/map", }); }; }); -<<<<<<< HEAD -define("rsvp/rethrow", - ["exports"], - function(__exports__) { - "use strict"; - var local = (typeof global === "undefined") ? this : global; - - function rethrow(reason) { - local.setTimeout(function() { - throw reason; - }); - throw reason; - } - - - __exports__.rethrow = rethrow; - }); -define("rsvp", - ["rsvp/events","rsvp/promise","rsvp/node","rsvp/all","rsvp/hash","rsvp/rethrow","rsvp/defer","rsvp/config","rsvp/resolve","rsvp/reject","exports"], - function(__dependency1__, __dependency2__, __dependency3__, __dependency4__, __dependency5__, __dependency6__, __dependency7__, __dependency8__, __dependency9__, __dependency10__, __exports__) { - "use strict"; - var EventTarget = __dependency1__.EventTarget; - var Promise = __dependency2__.Promise; - var denodeify = __dependency3__.denodeify; - var all = __dependency4__.all; - var hash = __dependency5__.hash; - var rethrow = __dependency6__.rethrow; - var defer = __dependency7__.defer; - 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 var slice = Array.prototype.slice; @@ -9186,45 +8809,6 @@ define("rsvp/node", 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; - __exports__.hash = hash; - __exports__.rethrow = rethrow; - __exports__.defer = defer; - __exports__.denodeify = denodeify; - __exports__.configure = configure; - __exports__.resolve = resolve; - __exports__.reject = reject; - }); -})(); - -(function() { -/** -@private -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 -*/ - -/* - 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() { - - // A safe and simple inheriting object. - function InheritingDict(parent) { - this.parent = parent; - this.dict = {}; - } -======= ```javascript var fs = require('fs'); @@ -9240,7 +8824,6 @@ define("container", var fs = require('fs'); var readFile = RSVP.denodeify(fs.readFile); ->>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147 readFile('myfile.txt').then(handleData, handleError); ``` @@ -9355,19 +8938,10 @@ define("rsvp/promise", 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 @@ -9424,15 +8998,6 @@ define("rsvp/promise", }); } -<<<<<<< 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) { @@ -9441,7 +9006,6 @@ define("rsvp/promise", ``` Unlike callbacks, promises are great composable primitives. ->>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147 ```js Promise.all([ @@ -9539,20 +9103,9 @@ define("rsvp/promise", 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, @@ -9592,26 +9145,6 @@ define("rsvp/promise", // 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) { @@ -9639,22 +9172,12 @@ define("rsvp/promise", 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); @@ -9662,7 +9185,6 @@ define("rsvp/promise", // The user's comments are now available }); ``` ->>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147 If the assimliated promise rejects, then the downstream promise will also reject. @@ -9679,24 +9201,11 @@ define("rsvp/promise", 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 @@ -9704,7 +9213,6 @@ define("rsvp/promise", // failure } ``` ->>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147 Errback Example @@ -9736,15 +9244,6 @@ define("rsvp/promise", ```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); @@ -9753,7 +9252,6 @@ define("rsvp/promise", // failure } ``` ->>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147 Errback Example @@ -9765,23 +9263,7 @@ define("rsvp/promise", 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) { @@ -9885,11 +9367,7 @@ define("rsvp/promise", `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() { @@ -10019,15 +9497,10 @@ define("rsvp/promise", } } -<<<<<<< HEAD - /** - @private -======= function fulfill(promise, value) { if (promise._state !== PENDING) { return; } promise._state = SEALED; promise._detail = value; ->>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147 config.async(publishFulfillment, promise); } @@ -10082,12 +9555,7 @@ define("rsvp/promise/all", 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); @@ -10102,10 +9570,6 @@ define("rsvp/promise/all", }); ``` -<<<<<<< HEAD - * Injecting one fullName on another fullName - * Injecting one fullName on a type -======= @method all @for RSVP.Promise @param {Array} entries array of promises @@ -10116,7 +9580,6 @@ define("rsvp/promise/all", @static */ __exports__["default"] = function all(entries, label) { ->>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147 /*jshint validthis:true */ var Constructor = this; @@ -10190,13 +9653,8 @@ define("rsvp/promise/cast", 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 @@ -10258,14 +9716,9 @@ define("rsvp/promise/race", "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 @@ -10280,16 +9733,11 @@ define("rsvp/promise/race", }, 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 @@ -10441,14 +9889,6 @@ define("rsvp/promise/resolve", }); ``` -<<<<<<< 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. @@ -10460,7 +9900,6 @@ define("rsvp/promise/resolve", __exports__["default"] = function resolve(value, label) { /*jshint validthis:true */ var Constructor = this; ->>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147 return new Constructor(function(resolve, reject) { resolve(value); @@ -10549,36 +9988,6 @@ define("rsvp/rethrow", 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(); @@ -10591,7 +10000,6 @@ define("rsvp/rethrow", // 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 @@ -14192,47 +13600,6 @@ Ember.Enumerable = Ember.Mixin.create({ - `index` is the current index in the iteration. - `enumerable` is the enumerable object itself. -<<<<<<< HEAD -if (!Ember.keys || Ember.create.isSimulated) { - var prototypeProperties = [ - 'constructor', - 'hasOwnProperty', - 'isPrototypeOf', - 'propertyIsEnumerable', - 'valueOf', - 'toLocaleString', - 'toString' - ], - pushPropertyName = function(obj, array, key) { - // Prevents browsers that don't respect non-enumerability from - // copying internal Ember properties - if (key.substring(0,2) === '__') return; - if (key === '_super') return; - if (indexOf(array, key) >= 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 @@ -14313,7 +13680,6 @@ if (!Ember.keys || Ember.create.isSimulated) { }); return ret ; }, ->>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147 /** Returns an array with all of the items in the enumeration where the passed @@ -14326,18 +13692,9 @@ if (!Ember.keys || Ember.create.isSimulated) { 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. @@ -14490,15 +13847,11 @@ var STRING_UNDERSCORE_REGEXP_2 = (/\-|\s+/g); findProperty: Ember.aliasMethod('findBy'), /** -<<<<<<< HEAD - Replaces underscores, spaces, or camelCase with dashes. -======= Returns `true` if the passed function returns true for every item in the enumeration. This corresponds with the `every()` method in JavaScript 1.6. The callback method you provide should have the following signature (all parameters are optional): ->>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147 ```javascript function(item, index, enumerable); @@ -14595,22 +13948,10 @@ var STRING_UNDERSCORE_REGEXP_2 = (/\-|\s+/g); @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'; }, @@ -14630,31 +13971,18 @@ var STRING_UNDERSCORE_REGEXP_2 = (/\-|\s+/g); - `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 @@ -14665,12 +13993,8 @@ if (Ember.EXTEND_PROTOTYPES === true || Ember.EXTEND_PROTOTYPES.String) { 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 @@ -14682,82 +14006,49 @@ if (Ember.EXTEND_PROTOTYPES === true || Ember.EXTEND_PROTOTYPES.String) { }, /** -<<<<<<< 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 @@ -14765,17 +14056,8 @@ if (Ember.EXTEND_PROTOTYPES === true || Ember.EXTEND_PROTOTYPES.String) { @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; @@ -14800,159 +14082,6 @@ if (Ember.EXTEND_PROTOTYPES === true || Ember.EXTEND_PROTOTYPES.String) { 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) { @@ -15207,162 +14336,21 @@ Ember.Observable = Ember.Mixin.create({ }); } }); ->>>>>>> 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. +(function() { +/** +@module ember +@submodule ember-runtime +*/ - ### Chaining +// .......................................................... +// HELPERS +// -<<<<<<< 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; // .......................................................... @@ -15486,378 +14474,10 @@ Ember.Array = Ember.Mixin.create(Ember.Enumerable, { // 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 -@submodule ember-runtime -*/ - - -// NOTE: this object should never be included directly. Instead use `Ember.Object`. -// We only define this separately so that `Ember.Set` can depend on it. - - -var set = Ember.set, get = Ember.get, - o_create = Ember.create, - o_defineProperty = Ember.platform.defineProperty, - GUID_KEY = Ember.GUID_KEY, - guidFor = Ember.guidFor, - generateGuid = Ember.generateGuid, - meta = Ember.meta, - rewatch = Ember.rewatch, - finishChains = Ember.finishChains, - sendEvent = Ember.sendEvent, - destroy = Ember.destroy, - schedule = Ember.run.schedule, - Mixin = Ember.Mixin, - applyMixin = Mixin._apply, - finishPartial = Mixin.finishPartial, - reopen = Mixin.prototype.reopen, - MANDATORY_SETTER = Ember.ENV.MANDATORY_SETTER, - indexOf = Ember.EnumerableUtils.indexOf; - -var undefinedDescriptor = { - configurable: true, - writable: true, - enumerable: false, - value: undefined -}; - -function makeCtor() { - - // Note: avoid accessing any properties on the object since it makes the - // method a lot faster. This is glue code so we want it to be as fast as - // possible. - - var wasApplied = false, initMixins, initProperties; - - var Class = function() { - if (!wasApplied) { - Class.proto(); // prepare prototype... - } - o_defineProperty(this, GUID_KEY, undefinedDescriptor); - o_defineProperty(this, '_super', undefinedDescriptor); - var m = meta(this), proto = m.proto; - m.proto = this; - if (initMixins) { - // capture locally so we can clear the closed over variable - var mixins = initMixins; - initMixins = null; - this.reopen.apply(this, mixins); - } - if (initProperties) { - // capture locally so we can clear the closed over variable - var props = initProperties; - initProperties = null; - - var concatenatedProperties = this.concatenatedProperties; - - for (var i = 0, l = props.length; i < l; i++) { - var properties = props[i]; - - Ember.assert("Ember.Object.create no longer supports mixing in other definitions, use createWithMixins instead.", !(properties instanceof Ember.Mixin)); - - if (properties === null || typeof properties !== 'object') { - Ember.assert("Ember.Object.create only accepts objects."); - continue; - } - - var keyNames = Ember.keys(properties); - for (var j = 0, ll = keyNames.length; j < ll; j++) { - var keyName = keyNames[j]; - if (!properties.hasOwnProperty(keyName)) { continue; } - - var value = properties[keyName], - IS_BINDING = Ember.IS_BINDING; - - if (IS_BINDING.test(keyName)) { - var bindings = m.bindings; - if (!bindings) { - bindings = m.bindings = {}; - } else if (!m.hasOwnProperty('bindings')) { - bindings = m.bindings = o_create(m.bindings); - } - bindings[keyName] = value; - } - - var desc = m.descs[keyName]; - - Ember.assert("Ember.Object.create no longer supports defining computed properties.", !(value instanceof Ember.ComputedProperty)); - Ember.assert("Ember.Object.create no longer supports defining methods that call _super.", !(typeof value === 'function' && value.toString().indexOf('._super') !== -1)); - Ember.assert("`actions` must be provided at extend time, not at create time, when Ember.ActionHandler is used (i.e. views, controllers & routes).", !((keyName === 'actions') && Ember.ActionHandler.detect(this))); - - if (concatenatedProperties && indexOf(concatenatedProperties, keyName) >= 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')); - } -======= 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. @@ -16314,709 +14934,9 @@ DependentArraysObserver.prototype = { removeObserver(item, propertyKey, dependentArrayObserver, observer); }); }); ->>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147 }); - -<<<<<<< HEAD - 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, - - /** - @private - - Invoked by the run loop to actually destroy the object. This is - scheduled for execution by the `destroy` method. - - @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. - - 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: - - 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. - - 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; } -======= createPropertyObserverContext: function (dependentArray, index, trackedArray) { var observerContext = new ItemPropertyObserverContext(dependentArray, index, trackedArray); @@ -17855,97 +15775,17 @@ Ember.arrayComputed = function (options) { return cp; }; ->>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147 - 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; - } - } -} +(function() { +/** +@module ember +@submodule ember-runtime +*/ -<<<<<<< HEAD -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>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147 removedItem: function (accumulatedValue, item, changeMeta, instanceMeta) { if (item > accumulatedValue) { @@ -18096,150 +15935,6 @@ Ember.computed.map = function(dependentKey, callback) { } }; -<<<<<<< HEAD -var get = Ember.get, - set = Ember.set, - fmt = Ember.String.fmt, - addBeforeObserver = Ember.addBeforeObserver, - addObserver = Ember.addObserver, - removeBeforeObserver = Ember.removeBeforeObserver, - removeObserver = Ember.removeObserver, - propertyWillChange = Ember.propertyWillChange, - propertyDidChange = Ember.propertyDidChange, - meta = Ember.meta, - defineProperty = Ember.defineProperty; - -function contentPropertyWillChange(content, contentKey) { - var key = contentKey.slice(8); // remove "content." - if (key in this) { return; } // if shadowed in proxy - propertyWillChange(this, key); -} - -function contentPropertyDidChange(content, contentKey) { - var key = contentKey.slice(8); // remove "content." - if (key in this) { return; } // if shadowed in proxy - propertyDidChange(this, key); -} - -/** - `Ember.ObjectProxy` forwards all properties not defined by the proxy itself - to a proxied `content` object. - - ```javascript - object = Ember.Object.create({ - name: 'Foo' - }); - - proxy = Ember.ObjectProxy.create({ - content: object - }); - - // Access and change existing properties - proxy.get('name') // 'Foo' - proxy.set('name', 'Bar'); - object.get('name') // 'Bar' - - // Create new 'description' property on `object` - proxy.set('description', 'Foo is a whizboo baz'); - object.get('description') // 'Foo is a whizboo baz' - ``` - - While `content` is unset, setting a property to be delegated will throw an - Error. - - ```javascript - proxy = Ember.ObjectProxy.create({ - content: null, - flag: null - }); - proxy.set('flag', true); - proxy.get('flag'); // true - proxy.get('foo'); // undefined - proxy.set('foo', 'data'); // throws Error - ``` - - Delegated properties can be bound to and will change when content is updated. - - Computed properties on the proxy itself can depend on delegated properties. - - ```javascript - ProxyWithComputedProperty = Ember.ObjectProxy.extend({ - fullName: function () { - var firstName = this.get('firstName'), - lastName = this.get('lastName'); - if (firstName && lastName) { - return firstName + ' ' + lastName; - } - return firstName || lastName; - }.property('firstName', 'lastName') - }); - - proxy = ProxyWithComputedProperty.create(); - - proxy.get('fullName'); // undefined - proxy.set('content', { - firstName: 'Tom', lastName: 'Dale' - }); // triggers property change for fullName on proxy - - proxy.get('fullName'); // 'Tom Dale' - ``` - - @class ObjectProxy - @namespace Ember - @extends Ember.Object -*/ -Ember.ObjectProxy = Ember.Object.extend(/** @scope Ember.ObjectProxy.prototype */ { - /** - The object whose properties will be forwarded. - - @property content - @type Ember.Object - @default null - */ - content: null, - _contentDidChange: Ember.observer('content', function() { - Ember.assert("Can't set ObjectProxy's content to itself", this.get('content') !== this); - }), - - isTruthy: Ember.computed.bool('content'), - - _debugContainerKey: null, - - willWatchProperty: function (key) { - var contentKey = 'content.' + key; - addBeforeObserver(this, contentKey, null, contentPropertyWillChange); - addObserver(this, contentKey, null, contentPropertyDidChange); - }, - - didUnwatchProperty: function (key) { - var contentKey = 'content.' + key; - removeBeforeObserver(this, contentKey, null, contentPropertyWillChange); - removeObserver(this, contentKey, null, contentPropertyDidChange); - }, - - unknownProperty: function (key) { - var content = get(this, 'content'); - if (content) { - return get(content, key); - } - }, - - setUnknownProperty: function (key, value) { - var m = meta(this); - if (m.proto === this) { - // if marked as prototype then just defineProperty - // rather than delegate - defineProperty(this, key, null, value); - return value; - } - - var content = get(this, 'content'); - Ember.assert(fmt("Cannot delegate set('%@', %@) to the 'content' property of object proxy %@: its 'content' is undefined.", [key, value, this]), content); - return set(content, key, value); - } - -}); -======= return Ember.arrayComputed(dependentKey, options); }; @@ -18343,7 +16038,6 @@ Ember.computed.filter = function(dependentKey, callback) { return array; } }; ->>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147 return Ember.arrayComputed(dependentKey, options); }; @@ -18374,257 +16068,6 @@ Ember.computed.filter = function(dependentKey, callback) { Ember.computed.filterBy = function(dependentKey, propertyKey, value) { var callback; -<<<<<<< HEAD -// .......................................................... -// HELPERS -// - -var get = Ember.get, set = Ember.set; -var a_slice = Array.prototype.slice; -var a_indexOf = Ember.EnumerableUtils.indexOf; - -var contexts = []; - -function popCtx() { - return contexts.length===0 ? {} : contexts.pop(); -} - -function pushCtx(ctx) { - contexts.push(ctx); - return null; -} - -function iter(key, value) { - var valueProvided = arguments.length === 2; - - function i(item) { - var cur = get(item, key); - return valueProvided ? value===cur : !!cur; - } - return i ; -} - -/** - This mixin defines the common interface implemented by enumerable objects - in Ember. Most of these methods follow the standard Array iteration - API defined up to JavaScript 1.8 (excluding language-specific features that - cannot be emulated in older versions of JavaScript). - - This mixin is applied automatically to the Array class on page load, so you - can use any of these methods on simple arrays. If Array already implements - one of these methods, the mixin will not override them. - - ## Writing Your Own Enumerable - - To make your own custom class enumerable, you need two items: - - 1. You must have a length property. This property should change whenever - the number of items in your enumerable object changes. If you using this - with an `Ember.Object` subclass, you should be sure to change the length - property using `set().` - - 2. If you must implement `nextObject().` See documentation. - - Once you have these two methods implement, apply the `Ember.Enumerable` mixin - to your class and you will be able to enumerate the contents of your object - like any other collection. - - ## Using Ember Enumeration with Other Libraries - - Many other libraries provide some kind of iterator or enumeration like - facility. This is often where the most common API conflicts occur. - Ember's API is designed to be as friendly as possible with other - libraries by implementing only methods that mostly correspond to the - JavaScript 1.8 API. - - @class Enumerable - @namespace Ember - @since Ember 0.9 -*/ -Ember.Enumerable = Ember.Mixin.create({ - - /** - Implement this method to make your class enumerable. - - This method will be call repeatedly during enumeration. The index value - will always begin with 0 and increment monotonically. You don't have to - rely on the index value to determine what object to return, but you should - always check the value and start from the beginning when you see the - requested index is 0. - - The `previousObject` is the object that was returned from the last call - to `nextObject` for the current iteration. This is a useful way to - manage iteration if you are tracing a linked list, for example. - - Finally the context parameter will always contain a hash you can use as - a "scratchpad" to maintain any other state you need in order to iterate - properly. The context object is reused and is not reset between - iterations so make sure you setup the context with a fresh state whenever - the index parameter is 0. - - Generally iterators will continue to call `nextObject` until the index - reaches the your current length-1. If you run out of data before this - time for some reason, you should simply return undefined. - - The default implementation of this method simply looks up the index. - This works great on any Array-like objects. - - @method nextObject - @param {Number} index the current index of the iteration - @param {Object} previousObject the value returned by the last call to - `nextObject`. - @param {Object} context a context object you can use to maintain state. - @return {Object} the next object in the iteration or undefined - */ - nextObject: Ember.required(Function), - - /** - Helper method returns the first object from a collection. This is usually - used by bindings and other parts of the framework to extract a single - object if the enumerable contains only one item. - - If you override this method, you should implement it so that it will - always return the same value each time it is called. If your enumerable - contains only one object, this method should always return that object. - If your enumerable is empty, this method should return `undefined`. - - ```javascript - var arr = ["a", "b", "c"]; - arr.get('firstObject'); // "a" - - var arr = []; - arr.get('firstObject'); // undefined - ``` - - @property firstObject - @return {Object} the object or undefined - */ - firstObject: Ember.computed(function() { - if (get(this, 'length')===0) return undefined ; - - // handle generic enumerables - var context = popCtx(), ret; - ret = this.nextObject(0, null, context); - pushCtx(context); - return ret ; - }).property('[]'), - - /** - Helper method returns the last object from a collection. If your enumerable - contains only one object, this method should always return that object. - If your enumerable is empty, this method should return `undefined`. - - ```javascript - var arr = ["a", "b", "c"]; - arr.get('lastObject'); // "c" - - var arr = []; - arr.get('lastObject'); // undefined - ``` - - @property lastObject - @return {Object} the last object or undefined - */ - lastObject: Ember.computed(function() { - var len = get(this, 'length'); - if (len===0) return undefined ; - var context = popCtx(), idx=0, cur, last = null; - do { - last = cur; - cur = this.nextObject(idx++, last, context); - } while (cur !== undefined); - pushCtx(context); - return last; - }).property('[]'), - - /** - Returns `true` if the passed object can be found in the receiver. The - default version will iterate through the enumerable until the object - is found. You may want to override this with a more efficient version. - - ```javascript - var arr = ["a", "b", "c"]; - arr.contains("a"); // true - arr.contains("z"); // false - ``` - - @method contains - @param {Object} obj The object to search for. - @return {Boolean} `true` if object is found in enumerable. - */ - contains: function(obj) { - return this.find(function(item) { return item===obj; }) !== undefined; - }, - - /** - Iterates through the enumerable, calling the passed function on each - item. This method corresponds to the `forEach()` method defined in - JavaScript 1.6. - - The callback method you provide should have the following signature (all - 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. - - Note that in addition to a callback, you can also pass an optional target - object that will be set as `this` on the context. This is a good way - to give your iterator function access to the current object. - - @method forEach - @param {Function} callback The callback to execute - @param {Object} [target] The target object to use - @return {Object} receiver - */ - forEach: function(callback, target) { - if (typeof callback !== "function") throw new TypeError() ; - var len = get(this, 'length'), last = null, context = popCtx(); - - if (target === undefined) target = null; - - for(var idx=0;idx>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147 - /** - Maps all of the items in the enumeration to another value, returning - a new array. This method corresponds to `map()` defined in JavaScript 1.6. - The callback method you provide should have the following signature (all - parameters are optional): -<<<<<<< HEAD - ```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 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 ; - }, - - /** - 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): - - 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 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 - /** - 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. +(function() { +/** +@module ember +@submodule ember-runtime +*/ -<<<<<<< HEAD - 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 - */ - any: function(callback, target) { - var found = this.find(function(x, idx, i) { - return !!callback.call(target, x, idx, i); - }); - - 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. - - 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.some(isManager)) { Paychecks.addBiggerBonus(); } - ``` - - @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'), - - /** - Returns `true` if the passed property resolves to `true` for any item in - the enumerable. This method is often simpler/faster than using a callback. - - @method 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 - */ - anyBy: function(key, value) { - return this.any(iter.apply(this, arguments)); - }, - - /** - Returns `true` if the passed property resolves to `true` for any item in - the enumerable. This method is often simpler/faster than using a callback. - - @method 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 `anyBy` instead - */ - someProperty: Ember.aliasMethod('anyBy'), - - /** - This will combine the values of the enumerator into a single value. It - is a useful way to collect a summary value from an enumeration. This - corresponds to the `reduce()` method defined in JavaScript 1.8. - - The callback method you provide should have the following signature (all - parameters are optional): - - ```javascript - function(previousValue, item, index, enumerable); - ``` - - - `previousValue` is the value returned by the last call to the iterator. - - `item` is the current item in the iteration. - - `index` is the current index in the iteration. - - `enumerable` is the enumerable object itself. - - Return the new cumulative value. - - In addition to the callback you can also pass an `initialValue`. An error - will be raised if you do not pass an initial value and the enumerator is - empty. - - Note that unlike the other methods, this method does not allow you to - pass a target object to set as this for the callback. It's part of the - spec. Sorry. - - @method reduce - @param {Function} callback The callback to execute - @param {Object} initialValue Initial value for the reduce - @param {String} reducerProperty internal use only. - @return {Object} The reduced value. - */ - reduce: function(callback, initialValue, reducerProperty) { - if (typeof callback !== "function") { throw new TypeError(); } - - 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); - - 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 ; - } - -}); - - - Ember.Enumerable.reopen({ - /** - 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; - }); - } - }); - -======= var get = Ember.get, set = Ember.set; @@ -20654,7 +17362,6 @@ Ember.MutableArray = Ember.Mixin.create(Ember.Array, Ember.MutableEnumerable, { } }); ->>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147 })(); @@ -20666,85 +17373,103 @@ Ember.MutableArray = Ember.Mixin.create(Ember.Array, Ember.MutableEnumerable, { @submodule ember-runtime */ -// .......................................................... -// HELPERS -// +var get = Ember.get, set = Ember.set; -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. +`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. - 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. +See also `Ember.ViewTargetActionSupport`, which has +view-aware defaults for target and actionContext. - 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 +@class TargetActionSupport +@namespace Ember +@extends Ember.Mixin */ -Ember.Array = Ember.Mixin.create(Ember.Enumerable, /** @scope Ember.Array.prototype */ { +Ember.TargetActionSupport = Ember.Mixin.create({ + target: null, + action: null, + actionContext: null, + + targetObject: Ember.computed(function() { + var target = get(this, 'target'); + + if (Ember.typeOf(target) === "string") { + var value = get(this, target); + if (value === undefined) { value = get(Ember.lookup, target); } + return value; + } else { + return target; + } + }).property('target'), + + actionContextObject: Ember.computed(function() { + var actionContext = get(this, 'actionContext'); + + if (Ember.typeOf(actionContext) === "string") { + var value = get(this, actionContext); + if (value === undefined) { value = get(Ember.lookup, actionContext); } + return value; + } else { + return actionContext; + } + }).property('actionContext'), /** - Your array must support the `length` property. Your replace methods should - set this property whenever it changes. + Send an "action" with an "actionContext" to a "target". The action, actionContext + and target will be retrieved from properties of the object. For example: - @property {Number} length + ```javascript + App.SaveButtonView = Ember.View.extend(Ember.TargetActionSupport, { + target: Ember.computed.alias('controller'), + action: 'save', + actionContext: Ember.computed.alias('context'), + click: function() { + this.triggerAction(); // Sends the `save` action, along with the current context + // to the current controller + } + }); + ``` + + The `target`, `action`, and `actionContext` can be provided as properties of + an optional object argument to `triggerAction` as well. + + ```javascript + App.SaveButtonView = Ember.View.extend(Ember.TargetActionSupport, { + click: function() { + this.triggerAction({ + action: 'save', + target: this.get('controller'), + actionContext: this.get('context'), + }); // Sends the `save` action, along with the current context + // to the current controller + } + }); + ``` + + 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: + + ```javascript + App.SaveButtonView = Ember.View.extend(Ember.TargetActionSupport, { + target: Ember.computed.alias('controller'), + click: function() { + this.triggerAction({ + action: 'save' + }); // Sends the `save` action, along with a reference to `this`, + // to the current controller + } + }); + ``` + + @method triggerAction + @param opts {Hash} (optional, with the optional keys action, target and/or actionContext) + @return {Boolean} true if the action was sent successfully and did not return false */ - 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 - */ -<<<<<<< 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'), @@ -20771,229 +17496,176 @@ Ember.Array = Ember.Mixin.create(Ember.Enumerable, /** @scope Ember.Array.protot Ember.assert("The action '" + action + "' did not exist on " + target, typeof target[action] === 'function'); ret = target[action].apply(target, args(actionContext)); } ->>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147 + + if (ret !== false) ret = true; + + return ret; + } else { + return false; + } + } +}); + +})(); + + + +(function() { +/** +@module ember +@submodule ember-runtime +*/ + +/** + This mixin allows for Ember objects to subscribe to and emit events. + + ```javascript + App.Person = Ember.Object.extend(Ember.Evented, { + greet: function() { + // ... + this.trigger('greet'); + } + }); + + var person = App.Person.create(); + + person.on('greet', function() { + console.log('Our person has greeted'); + }); + + person.greet(); + + // outputs: 'Our person has greeted' + ``` + + You can also chain multiple event subscriptions: + + ```javascript + person.on('greet', function() { + console.log('Our person has greeted'); + }).one('greet', function() { + console.log('Offer one-time special'); + }).off('event', this, forgetThis); + ``` + + @class Evented + @namespace Ember + */ +Ember.Evented = Ember.Mixin.create({ /** - This returns the objects at the specified indexes, using `objectAt`. + Subscribes to a named event with given function. - ```javascript - var arr = ['a', 'b', 'c', 'd']; - arr.objectsAt([0, 1, 2]); // ["a", "b", "c"] - arr.objectsAt([2, 3, 4]); // ["c", "d", undefined] - ``` + ```javascript + person.on('didLoad', function() { + // fired once the person has loaded + }); + ``` - @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); }); - }, + An optional target can be passed in as the 2nd argument that will + be set as the "this" for the callback. This is a good way to give your + function access to the object triggering the event. When the target + parameter is used the callback becomes the third argument. - // overrides Ember.Enumerable version - nextObject: function(idx) { - return this.objectAt(idx); + @method on + @param {String} name The name of the event + @param {Object} [target] The "this" binding for the callback + @param {Function} method The callback to execute + @return this + */ + on: function(name, target, method) { + Ember.addListener(this, name, target, method); + return this; }, /** - 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. + Subscribes a function to a named event and then cancels the subscription + after the first time the event is triggered. It is good to use ``one`` when + you only care about the first time an event has taken place. - This property overrides the default property defined in `Ember.Enumerable`. + This function takes an optional 2nd argument that will become the "this" + value for the callback. If this argument is passed then the 3rd argument + becomes the function. - @property [] + @method one + @param {String} name The name of the event + @param {Object} [target] The "this" binding for the callback + @param {Function} method The callback to execute @return this */ - '[]': 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; - }, - - // Add any extra methods to Ember.Array that are native to the built-in Array. - /** - 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++) ; + one: function(name, target, method) { + if (!method) { + method = target; + target = null; } - 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; - }, - -<<<<<<< HEAD - // .......................................................... - // ARRAY OBSERVERS - // - -======= ->>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147 - /** - 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'); + Ember.addListener(this, name, target, method, true); 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. + Triggers a named event for the object. Any additional arguments + will be passed as parameters to the functions that are subscribed to the + event. - @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 + ```javascript + person.on('didEat', function(food) { + console.log('person ate some ' + food); + }); + + person.trigger('didEat', 'broccoli'); + + // outputs: person ate some broccoli + ``` + @method trigger + @param {String} name The name of the event + @param {Object...} args Optional arguments to pass on */ - removeArrayObserver: function(target, opts) { - var willChange = (opts && opts.willChange) || 'arrayWillChange', - didChange = (opts && opts.didChange) || 'arrayDidChange'; + trigger: function(name) { + var args = [], i, l; + for (i = 1, l = arguments.length; i < l; i++) { + args.push(arguments[i]); + } + Ember.sendEvent(this, name, args); + }, - 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'); + /** + Cancels subscription for given name, target, and method. + + @method off + @param {String} name The name of the event + @param {Object} target The target of the subscription + @param {Function} method The function of the subscription + @return this + */ + off: function(name, target, method) { + Ember.removeListener(this, name, target, method); return this; }, -<<<<<<< HEAD /** - Becomes true whenever the array currently has observers watching changes - on the array. -======= + Checks to see if object has any subscriptions for named event. + + @method has + @param {String} name The name of the event + @return {Boolean} does the object have a subscription for event + */ + has: function(name) { + return Ember.hasListeners(this, name); + } +}); + +})(); + + + +(function() { +var RSVP = requireModule("rsvp"); + +RSVP.configure('async', function(callback, promise) { + Ember.run.schedule('actions', promise, callback, promise); +}); + RSVP.Promise.prototype.fail = function(callback, label){ Ember.deprecate('RSVP.Promise.fail has been renamed as RSVP.Promise.catch'); return this['catch'](callback, label); @@ -21003,190 +17675,60 @@ RSVP.Promise.prototype.fail = function(callback, label){ @module ember @submodule ember-runtime */ ->>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147 - @property Boolean - */ - hasArrayObservers: Ember.computed(function() { - return Ember.hasListeners(this, '@array:change') || Ember.hasListeners(this, '@array:before'); - }), +var get = Ember.get; +/** + @class Deferred + @namespace Ember + */ +Ember.DeferredMixin = Ember.Mixin.create({ /** - 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. + Add handlers to be called when the Deferred object is resolved or rejected. -<<<<<<< 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 - 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) { -======= @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) { - startIdx = 0; - removeAmt = addAmt = -1; - } else { - if (removeAmt === undefined) removeAmt=-1; - if (addAmt === undefined) addAmt=-1; + entity = this; + deferred = get(this, '_deferred'); + promise = deferred.promise; + + function fulfillmentHandler(fulfillment) { + if (fulfillment === promise) { + return resolve(entity); + } else { + return resolve(fulfillment); + } } - // 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>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147 }, /** - If you are implementing an object that supports `Ember.Array`, call this - method just after the array content changes to notify any observers and - invalidate any related properties. Pass the starting index of the change - as well as a delta of the amounts to change. + Resolve a Deferred object and call any `doneCallbacks` with the given args. - @method arrayContentDidChange - @param {Number} startIdx The starting index in the array that did change. - @param {Number} removeAmt The number of items that were removed. If you - pass `null` assumes 0 - @param {Number} addAmt The number of items that were added. If you - pass `null` assumes 0. - @return {Ember.Array} receiver + @method resolve */ - arrayContentDidChange: function(startIdx, removeAmt, addAmt) { + resolve: function(value) { + var deferred, promise; - // if no args are passed assume everything changes - if (startIdx===undefined) { - startIdx = 0; - removeAmt = addAmt = -1; + deferred = get(this, '_deferred'); + promise = deferred.promise; + + if (value === this) { + deferred.resolve(promise); } else { - if (removeAmt === undefined) removeAmt=-1; - if (addAmt === undefined) addAmt=-1; + deferred.resolve(value); } - - var adding, lim; - if (startIdx>=0 && addAmt>=0 && get(this, 'hasEnumerableObservers')) { - adding = []; - lim = startIdx+addAmt; - for(var idx=startIdx;idx>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147 - - // the computed property: remember these are shared across instances - this.cp = cp; - - // the ReduceComputedPropertyInstanceMeta this DependentArraysObserver is - // associated with - this.instanceMeta = instanceMeta; - - // A map of array guids to dependentKeys, for the given context. We track - // this because we want to set up the computed property potentially before the - // dependent array even exists, but when the array observer fires, we lack - // enough context to know what to update: we can recover that context by - // getting the dependentKey. - this.dependentKeysByGuid = {}; - - // a map of dependent array guids -> Ember.TrackedArray instances. We use - // 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 - 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); - }); - }); - }); - }, - - 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 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) { - 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) { - 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') - }) - ``` - - @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; -}; - /** - 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} +@module ember +@submodule ember-runtime */ -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 get = Ember.get, typeOf = Ember.typeOf; /** @@ -23027,3088 +18670,6 @@ Ember.SubArray.prototype = { -(function() { -Ember.Container = requireModule('container'); -Ember.Container.set = Ember.set; - -})(); ->>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147 - - var cp = new ArrayComputedProperty(options); - - if (args) { - cp.property.apply(cp, args); - } - - return cp; -}; - -})(); - - - -(function() { -/** -@module ember -@submodule ember-runtime -*/ - -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; - -/** - A computed property that calculates the maximum value in the - dependent array. This will return `-Infinity` when the dependent - array is empty. - - Example - - ```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. - - Example - - ```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 -*/ -<<<<<<< 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); - }, - - 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: - - ```javascript - function(item); - ``` - - - `item` is the current item in the iteration. - - Example - - ```javascript - App.Hamster = Ember.Object.extend({ - excitingChores: Ember.computed.map('chores', function(chore) { - return chore.toUpperCase() + '!'; - }) - }); - - var hamster = App.Hamster.create({chores: ['cook', 'clean', 'write more unit tests']}); - hamster.get('excitingChores'); // ['COOK!', 'CLEAN!', 'WRITE MORE UNIT TESTS!'] - ``` - -<<<<<<< HEAD - @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; - } - }; - - return Ember.arrayComputed(dependentKey, options); -}; - -/** - 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 - - ```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] - ``` - -<<<<<<< HEAD - @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. -======= - /** - 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}, - {name: 'clean', done: true}, - {name: 'write more unit tests', done: false} - ]}); - hamster.get('remainingChores'); // [{name: 'write more unit tests', done: false}] - ``` - -<<<<<<< HEAD - @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); -======= - 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); - } - - 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); - } - - return array; - } - }; - - return Ember.arrayComputed(dependentKey, options); -}; - -/** - Filters the array by the property and value - - Example - - ```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; - - if (arguments.length === 2) { - callback = function(item) { - return get(item, propertyKey); - }; - } else { - callback = function(item) { - return get(item, 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 - @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. - -<<<<<<< HEAD - Example -======= - if ((start < 0) || (start >= get(this, 'length'))) { - throw new Ember.Error(OUT_OF_RANGE_EXCEPTION); - } ->>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147 - - ```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; - } - -<<<<<<< HEAD - 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); -======= - -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 { - searchItem = item; - } - - index = instanceMeta.binarySearch(array, searchItem); - array.removeAt(index); - return array; - } - }); -}; - -})(); - - - -(function() { -/** - Expose RSVP implementation - - Documentation can be found here: https://github.com/tildeio/rsvp.js/blob/master/README.md - - @class RSVP - @namespace Ember - @constructor -*/ -Ember.RSVP = requireModule('rsvp'); - -})(); - - -<<<<<<< HEAD -======= - guid = guidFor(item); - indicies = objects[guid]; - indicies[indexOf.call(indicies, loc)] = null; - } - } -} ->>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147 - -(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); - 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>>>>>> 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 - declarations in classes that you write. For example: - - ```javascript - Ember.Object.extend({ - valueObserver: function() { - // Executes whenever the "value" property is about to change - }.observesBefore('value') - }); - ``` - - See `Ember.beforeObserver`. - - @method observesBefore - @for Function - */ - Function.prototype.observesBefore = function() { - this.__ember_observesBefore__ = a_slice.call(arguments); - 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() { - // Executes whenever the "didInsertElement" event fires - }.on('didInsertElement') - }); - ``` - - 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 - */ - Function.prototype.on = function() { - var events = a_slice.call(arguments); - this.__ember_listens__ = events; - return this; - }; -} - - -})(); - - - -(function() { - -})(); - - - -(function() { -/** -@module ember -@submodule ember-runtime -*/ - - -/** - Implements some standard methods for comparing objects. Add this mixin to - any class you create that can compare its instances. - - You should implement the `compare()` method. - - @class Comparable - @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. - - @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(/** @scope Ember.Copyable.prototype */ { - - /** - 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])); - } - } -}); - -})(); - - - -(function() { -/** -@module ember -@submodule ember-runtime -*/ - - -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 - -<<<<<<< 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, - 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 -*/ -<<<<<<< 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 - 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 - */ -<<<<<<< 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 - -}); - -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 - */ -<<<<<<< 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 - }, - - /** - __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,/** @scope Ember.MutableArray.prototype */ { - - /** - __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", "blue"]; - colors.pushObject("black"); // ["red", "green", "blue", "black"] - 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 - */ - pushObject: function(obj) { - 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 - notifying observers of the change until all objects are added. - - ```javascript - var colors = ["red", "green", "blue"]; - colors.pushObjects(["black"]); // ["red", "green", "blue", "black"] - colors.pushObjects(["yellow", "orange"]); // ["red", "green", "blue", "black", "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 ; - }, - -<<<<<<< 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"]; - 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", "green", "blue"]; - colors.unshiftObject("yellow"); // ["yellow", "red", "green", "blue"] - colors.unshiftObject(["black", "white"]); // [["black", "white"], "yellow", "red", "green", "blue"] - ``` - - @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", "green", "blue"]; - colors.unshiftObjects(["black", "white"]); // ["black", "white", "red", "green", "blue"] - 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 ; - } - -}); - -})(); - - - -(function() { -/** - @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, - action: null, - actionContext: null, - - targetObject: Ember.computed(function() { - var target = get(this, 'target'); - - if (Ember.typeOf(target) === "string") { - var value = get(this, target); - if (value === undefined) { value = get(Ember.lookup, target); } - return value; - } else { - return target; - } - }).property('target'), - - actionContextObject: Ember.computed(function() { - var actionContext = get(this, 'actionContext'); - - if (Ember.typeOf(actionContext) === "string") { - var value = get(this, actionContext); - if (value === undefined) { value = get(Ember.lookup, actionContext); } - return value; - } else { - return actionContext; - } - }).property('actionContext'), - - /** - Send an "action" with an "actionContext" to a "target". The action, actionContext - and target will be retrieved from properties of the object. For example: - -<<<<<<< HEAD - ```javascript - App.SaveButtonView = Ember.View.extend(Ember.TargetActionSupport, { - target: Ember.computed.alias('controller'), - action: 'save', - actionContext: Ember.computed.alias('context'), - click: function() { - this.triggerAction(); // Sends the `save` action, along with the current context - // to the current controller - } - }); - ``` - - The `target`, `action`, and `actionContext` can be provided as properties of - an optional object argument to `triggerAction` as well. - - ```javascript - App.SaveButtonView = Ember.View.extend(Ember.TargetActionSupport, { - click: function() { - this.triggerAction({ - action: 'save', - target: this.get('controller'), - actionContext: this.get('context'), - }); // Sends the `save` action, along with the current context - // to the current controller - } - }); - ``` - - 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, { - target: Ember.computed.alias('controller'), - click: function() { - this.triggerAction({ - action: 'save' - }); // Sends the `save` action, along with a reference to `this`, - // to the current controller - } - }); - ``` - - @method triggerAction - @param opts {Hash} (optional, with the optional keys action, target and/or actionContext) - @return {Boolean} true if the action was sent successfully and did not return false - */ - triggerAction: function(opts) { - 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; - -<<<<<<< HEAD - 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)); - } - - if (ret !== false) ret = true; - - return ret; - } 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 - } -}); - -})(); - - - -(function() { -/** -@module ember -@submodule ember-runtime -*/ - -/** - This mixin allows for Ember objects to subscribe to and emit events. - - ```javascript - App.Person = Ember.Object.extend(Ember.Evented, { - greet: function() { - // ... - this.trigger('greet'); - } - }); - - var person = App.Person.create(); - - person.on('greet', function() { - console.log('Our person has greeted'); - }); - - person.greet(); - - // outputs: 'Our person has greeted' - ``` - -<<<<<<< HEAD - You can also chain multiple event subscriptions: - - ```javascript - person.on('greet', function() { - console.log('Our person has greeted'); - }).one('greet', function() { - console.log('Offer one-time special'); - }).off('event', this, forgetThis); - ``` - - @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({ - - /** - 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 - function access to the object triggering the event. When the target - parameter is used the callback becomes the third argument. - - @method on - @param {String} name The name of the event - @param {Object} [target] The "this" binding for the callback - @param {Function} method The callback to execute - @return this - */ - on: function(name, target, method) { - Ember.addListener(this, name, target, method); - return this; - }, - - /** -<<<<<<< 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 - becomes the function. - - @method one - @param {String} name The name of the event - @param {Object} [target] The "this" binding for the callback - @param {Function} method The callback to execute - @return this - */ - one: function(name, target, method) { - if (!method) { - method = target; - target = null; - } - - Ember.addListener(this, name, target, method, true); - return this; - }, - - /** - Triggers a named event for the object. Any additional arguments - will be passed as parameters to the functions that are subscribed to the - event. - - ```javascript - person.on('didEat', function(food) { - console.log('person ate some ' + food); - }); - - person.trigger('didEat', 'broccoli'); - - // outputs: person ate some broccoli - ``` - @method trigger - @param {String} name The name of the event - @param {Object...} args Optional arguments to pass on - */ - trigger: function(name) { - var args = [], i, l; - for (i = 1, l = arguments.length; i < l; i++) { - args.push(arguments[i]); - } - Ember.sendEvent(this, name, args); - }, - - /** - 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 - @param {Function} method The function of the subscription - @return this - */ - off: function(name, target, method) { - 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. - - @method has - @param {String} name The name of the event - @return {Boolean} does the object have a subscription for event - */ - has: function(name) { - return Ember.hasListeners(this, name); - } -}); - -<<<<<<< HEAD -})(); -======= - _contentWillChange: Ember.beforeObserver('content', function() { - var content = get(this, 'content'), - sortProperties = get(this, 'sortProperties'); ->>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147 - - -<<<<<<< HEAD - -(function() { -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 -@submodule ember-runtime -*/ - -var get = Ember.get; - -/** - @class Deferred - @namespace Ember - */ -Ember.DeferredMixin = Ember.Mixin.create({ - /** - Add handlers to be called when the Deferred object is resolved or rejected. - - @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) { - var deferred, promise, entity; - - entity = this; - deferred = get(this, '_deferred'); - promise = deferred.promise; - - function fulfillmentHandler(fulfillment) { - if (fulfillment === promise) { - return resolve(entity); - } else { - return resolve(fulfillment); - } - } - - return promise.then(resolve && fulfillmentHandler, reject); - }, - - /** - Resolve a Deferred object and call any `doneCallbacks` with the given args. - - @method resolve - */ - resolve: function(value) { - var deferred, promise; - - deferred = get(this, '_deferred'); - promise = deferred.promise; - - if (value === this) { - deferred.resolve(promise); - } else { - deferred.resolve(value); - } - }, - - /** - Reject a Deferred object and call any `failCallbacks` with the given args. - - @method reject - */ - reject: function(value) { - get(this, '_deferred').reject(value); - }, - - _deferred: Ember.computed(function() { - return RSVP.defer(); - }) -}); - - -})(); - - - -(function() { -/** -@module ember -@submodule ember-runtime -*/ - -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'], - - /** - @private - - 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. - - @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 - }); -} - -/** - 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({ - reason: null, - isPending: not('isSettled').readOnly(), - isSettled: or('isRejected', 'isFulfilled').readOnly(), - isRejected: false, - isFulfilled: false, - - 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"); - } - }), - - then: function(fulfill, reject) { - return get(this, 'promise').then(fulfill, reject); - } -}); - - - -})(); - - - -(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; - } - -<<<<<<< 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 - * {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; - -<<<<<<< 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; - 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; - } - } - -<<<<<<< HEAD - 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); -======= -/** - `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; - 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. - -<<<<<<< HEAD - @method ArrayOperation - @private - @property {string} type The type of the operation. One of - `Ember.TrackedArray.{RETAIN, INSERT, DELETE}` - @property {number} count The number of items in this operation. - @property {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; -} -======= -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 - by item index. - - @method ArrayOperationMatch - @private - @property {ArrayOperation} operation - @property {number} index The index of `operation` in the array of operations. - @property {boolean} split Whether or not the item index searched for would - require a split for a new operation type. - @property {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; @@ -26156,7 +18717,6 @@ 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({ @@ -26174,7 +18734,7 @@ var get = Ember.get, set = Ember.set; @extends Ember.Object @uses Ember.MutableArray */ -Ember.ArrayProxy = Ember.Object.extend(Ember.MutableArray,/** @scope Ember.ArrayProxy.prototype */ { +Ember.ArrayProxy = Ember.Object.extend(Ember.MutableArray, { /** The content array. Must be an object that implements `Ember.Array` and/or @@ -26182,60 +18742,6 @@ 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, @@ -26282,11 +18788,10 @@ Ember._RenderBuffer.prototype = { }, /** - @private - 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() { @@ -26308,11 +18813,10 @@ Ember._RenderBuffer.prototype = { contentArrayDidChange: Ember.K, /** - @private - Invoked when the content property changes. Notifies observers that the entire array content has changed. + @private @method _contentDidChange */ _contentDidChange: Ember.observer('content', function() { @@ -26456,60 +18960,9 @@ Ember._RenderBuffer.prototype = { 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; @@ -26569,30 +19022,9 @@ Ember._RenderBuffer.prototype = { */ -<<<<<<< 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, { @@ -26603,25 +19035,16 @@ 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)$/; @@ -26629,17 +19052,6 @@ 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); @@ -26648,7 +19060,6 @@ 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); @@ -26657,14 +19068,6 @@ 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; @@ -26709,34 +19112,12 @@ 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; @@ -26746,16 +19127,9 @@ 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; @@ -26766,14 +19140,7 @@ 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); } @@ -26832,7 +19199,6 @@ Ember.EachProxy = Ember.Object.extend({ } }, -<<<<<<< HEAD stopObservingContentKey: function(keyName) { var keys = this._keys; if (keys && (keys[keyName]>0) && (--keys[keyName]<=0)) { @@ -26840,12 +19206,6 @@ 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) { @@ -26911,35 +19271,20 @@ 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); @@ -26998,7 +19343,6 @@ 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 @@ -27006,13 +19350,6 @@ 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 @@ -27029,29 +19366,7 @@ var meta = Ember.meta; }); ``` -<<<<<<< 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} */ @@ -27061,7 +19376,6 @@ 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` @@ -27074,25 +19388,6 @@ 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 @@ -27125,7 +19420,6 @@ 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 @@ -27133,47 +19427,20 @@ 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 @@ -27191,7 +19458,6 @@ 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 @@ -27207,43 +19473,6 @@ 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()`. @@ -27286,7 +19515,7 @@ var get = Ember.get, set = Ember.set, guidFor = Ember.guidFor, isNone = Ember.is @since Ember 0.9 */ Ember.Set = Ember.CoreObject.extend(Ember.MutableEnumerable, Ember.Copyable, Ember.Freezable, - /** @scope Ember.Set.prototype */ { + { // .......................................................... // IMPLEMENT ENUMERABLE APIS @@ -27342,15 +19571,9 @@ 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"], @@ -27542,16 +19765,10 @@ 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) { @@ -27597,14 +19814,9 @@ 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) { @@ -27652,38 +19864,11 @@ 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); @@ -27705,32 +19890,30 @@ Ember.Deferred = Deferred; var forEach = Ember.ArrayPolyfills.forEach; /** -@module ember -@submodule ember-runtime + @module ember + @submodule ember-runtime */ var loadHooks = Ember.ENV.EMBER_LOAD_HOOKS || {}; var loaded = {}; /** + Detects when a specific package of Ember (e.g. 'Ember.Handlebars') + has fully loaded and is available for extension. -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: -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(...); + }); + ``` -```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 + @method onLoad + @for Ember + @param name {String} name of hook + @param callback {Function} callback to be called */ Ember.onLoad = function(name, callback) { var object; @@ -27744,14 +19927,13 @@ Ember.onLoad = function(name, callback) { }; /** + Called when an Ember.js package (e.g Ember.Handlebars) has finished + loading. Triggers any callbacks registered for this event. -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 + @method runLoadHooks + @for Ember + @param name {String} name of hook + @param object {Object} object to pass to callbacks */ Ember.runLoadHooks = function(name, object) { loaded[name] = object; @@ -27766,11 +19948,6 @@ Ember.runLoadHooks = function(name, object) { })(); -<<<<<<< HEAD -======= - See [Ember.Handlebars.helpers.yield](/api/classes/Ember.Handlebars.helpers.html#method_yield) - for more information. ->>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147 (function() { @@ -27793,6 +19970,7 @@ var get = Ember.get; @class ControllerMixin @namespace Ember + @uses Ember.ActionHandler */ Ember.ControllerMixin = Ember.Mixin.create(Ember.ActionHandler, { /* ducktype as a controller */ @@ -27816,11 +19994,7 @@ 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'), @@ -27876,40 +20050,18 @@ 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'} @@ -27919,7 +20071,6 @@ Ember.View = Ember.CoreView.extend({ 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. @@ -27927,10 +20078,6 @@ Ember.View = Ember.CoreView.extend({ 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 @@ -27941,20 +20088,14 @@ 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 @@ -27968,11 +20109,6 @@ 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 @@ -28032,7 +20168,6 @@ 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'), @@ -28051,12 +20186,6 @@ 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; }), @@ -28073,16 +20202,8 @@ 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'); @@ -28095,7 +20216,6 @@ Ember.SortableMixin = Ember.Mixin.create(Ember.MutableEnumerable, { } }), -<<<<<<< HEAD contentArrayWillChange: function(array, idx, removedCount, addedCount) { var isSorted = get(this, 'isSorted'); @@ -28119,43 +20239,10 @@ 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); @@ -28164,25 +20251,6 @@ 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); }, @@ -28209,20 +20277,8 @@ 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; @@ -28230,17 +20286,8 @@ 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); @@ -28250,26 +20297,14 @@ 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 @@ -28278,31 +20313,15 @@ 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: @@ -28387,21 +20406,11 @@ 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, @@ -28454,23 +20463,10 @@ 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'), @@ -28494,7 +20490,6 @@ Ember.ArrayController = Ember.ArrayProxy.extend(Ember.ControllerMixin, this.set('_subControllers', Ember.A()); }, -<<<<<<< HEAD content: Ember.computed(function () { return Ember.A(); }), @@ -28504,25 +20499,10 @@ 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 + '"'); @@ -28610,17 +20590,7 @@ 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 @@ -28630,15 +20600,8 @@ 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() { @@ -28657,17 +20620,7 @@ 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 @@ -28770,7 +20723,6 @@ var canSetInnerHTML = function(tagName) { innerHTMLTags[tagName] = canSet; -<<<<<<< HEAD return canSet; }; @@ -28783,19 +20735,6 @@ 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 = ''; @@ -28840,15 +20779,10 @@ 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); }, @@ -28861,7 +20795,6 @@ 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; @@ -28870,17 +20803,10 @@ 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 = /[&<>"'`]/; @@ -28900,31 +20826,6 @@ 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); @@ -28966,8 +20867,7 @@ Ember._RenderBuffer = function(tagName) { this.buffer = ""; }; -Ember._RenderBuffer.prototype = -/** @scope Ember.RenderBuffer.prototype */ { +Ember._RenderBuffer.prototype = { // The root view's element _element: null, @@ -28975,12 +20875,11 @@ Ember._RenderBuffer.prototype = _hasElement: true, /** - @private - 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 [] @@ -29002,13 +20901,8 @@ 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 @@ -29063,7 +20957,6 @@ 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 @@ -29075,16 +20968,6 @@ 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, @@ -29207,26 +21090,9 @@ 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; }, @@ -29260,7 +21126,6 @@ Ember._RenderBuffer.prototype = return; } -<<<<<<< HEAD var buffer = this.buffer, id = this.elementId, classes = this.classes, @@ -29279,24 +21144,6 @@ 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="'; @@ -29311,16 +21158,6 @@ 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) { @@ -29358,7 +21195,6 @@ Ember._RenderBuffer.prototype = if (tagName) { this.buffer += ''; } }, -<<<<<<< HEAD currentTagName: function() { return this.tagNames[this.tagNames.length-1]; }, @@ -29371,39 +21207,6 @@ 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. @@ -29412,35 +21215,8 @@ 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); @@ -29528,7 +21304,6 @@ Ember._RenderBuffer.prototype = })(); -<<<<<<< HEAD (function() { /** @@ -29537,13 +21312,6 @@ 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 @@ -29551,25 +21319,12 @@ 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 +Ember.EventDispatcher = Ember.Object.extend({ /** The set of events names (and associated handler function names) to be setup @@ -29613,40 +21368,22 @@ 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. + @private @property rootElement @type DOMElement @default 'body' -======= - @method _classStringForValue - @param path - @param val - @param className - @param falsyClassName - @static - @private ->>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147 */ rootElement: 'body', /** - @private - Sets up event listeners for standard browser events. This will be called after the browser sends a `DOMContentReady` event. By @@ -29654,6 +21391,7 @@ Ember.EventDispatcher = Ember.Object.extend(/** @scope Ember.EventDispatcher.pro would like to register the listeners on a different element, set the event dispatcher's `root` property. + @private @method setup @param addedEvents {Hash} */ @@ -29685,29 +21423,12 @@ Ember.EventDispatcher = Ember.Object.extend(/** @scope Ember.EventDispatcher.pro }, /** - @private - 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: @@ -29716,6 +21437,7 @@ Ember.EventDispatcher = Ember.Object.extend(/** @scope Ember.EventDispatcher.pro setupHandler('mousedown', 'mouseDown'); ``` + @private @method setupHandler @param {Element} rootElement @param {String} event the browser-originated event to listen to @@ -29725,7 +21447,7 @@ Ember.EventDispatcher = Ember.Object.extend(/** @scope Ember.EventDispatcher.pro var self = this; rootElement.on(event + '.ember', '.ember-view', function(evt, triggeringManager) { - return Ember.handleErrors(function() { + return Ember.handleErrors(function handleViewEvent() { var view = Ember.View.views[this.id], result = true, manager = null; @@ -29744,7 +21466,7 @@ Ember.EventDispatcher = Ember.Object.extend(/** @scope Ember.EventDispatcher.pro }); rootElement.on(event + '.ember', '[data-ember-action]', function(evt) { - return Ember.handleErrors(function() { + return Ember.handleErrors(function handleActionEvent() { var actionId = Ember.$(evt.currentTarget).attr('data-ember-action'), action = Ember.Handlebars.ActionHelper.registeredActions[actionId]; @@ -29790,7 +21512,7 @@ Ember.EventDispatcher = Ember.Object.extend(/** @scope Ember.EventDispatcher.pro }, _bubbleEvent: function(view, evt, eventName) { - return Ember.run(function() { + return Ember.run(function bubbleEvent() { return view.handleEvent(eventName, evt); }); }, @@ -29812,53 +21534,12 @@ 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 })(); @@ -29911,16 +21592,7 @@ 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 @@ -29989,6 +21661,7 @@ Ember.TEMPLATES = {}; @namespace Ember @extends Ember.Object @uses Ember.Evented + @uses Ember.ActionHandler */ Ember.CoreView = Ember.Object.extend(Ember.Evented, Ember.ActionHandler, { @@ -30036,8 +21709,6 @@ Ember.CoreView = Ember.Object.extend(Ember.Evented, Ember.ActionHandler, { }, /** - @private - 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. @@ -30052,6 +21723,7 @@ Ember.CoreView = Ember.Object.extend(Ember.Evented, Ember.ActionHandler, { @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, @@ -30059,7 +21731,7 @@ Ember.CoreView = Ember.Object.extend(Ember.Evented, Ember.ActionHandler, { this.instrumentDetails(details); - return Ember.instrument(name, details, function() { + return Ember.instrument(name, details, function instrumentRenderToBuffer() { return this._renderToBuffer(parentBuffer, bufferOperation); }, this); }, @@ -30086,13 +21758,12 @@ Ember.CoreView = Ember.Object.extend(Ember.Evented, Ember.ActionHandler, { }, /** - @private - 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); @@ -30104,13 +21775,6 @@ 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) { @@ -30218,14 +21882,9 @@ 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 @@ -30256,16 +21915,7 @@ 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
@@ -30342,7 +21992,6 @@ 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: @@ -30364,21 +22013,6 @@ 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 @@ -30435,7 +22069,6 @@ Ember.ContainerView = Ember.View.extend(Ember.MutableArray, { ## 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 @@ -30454,30 +22087,11 @@ Ember.ContainerView = Ember.View.extend(Ember.MutableArray, { ```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', @@ -30487,28 +22101,12 @@ Ember.ContainerView = Ember.View.extend(Ember.MutableArray, { ``` 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({ @@ -30527,15 +22125,10 @@ Ember.ContainerView = Ember.View.extend(Ember.MutableArray, { 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 @@ -30543,29 +22136,11 @@ Ember.ContainerView = Ember.View.extend(Ember.MutableArray, { 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: @@ -30582,7 +22157,6 @@ Ember.ContainerView = Ember.View.extend(Ember.MutableArray, { ``` -<<<<<<< HEAD And associate it by name using a view's `templateName` property: ```javascript @@ -30590,22 +22164,22 @@ Ember.ContainerView = Ember.View.extend(Ember.MutableArray, { 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 + 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. @@ -30616,7 +22190,6 @@ Ember.ContainerView = Ember.View.extend(Ember.MutableArray, { 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'), @@ -30624,13 +22197,6 @@ Ember.ContainerView = Ember.View.extend(Ember.MutableArray, { 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: @@ -30771,16 +22337,8 @@ Ember.merge(states.inBuffer, { }); ``` -<<<<<<< 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({ @@ -30838,7 +22396,6 @@ Ember.merge(states.inBuffer, { built-in events exists in `Ember.EventDispatcher`.) Additional, custom events can be registered by using `Ember.Application.customEvents`. -<<<<<<< HEAD Touch events: * `touchStart` @@ -30847,15 +22404,6 @@ Ember.merge(states.inBuffer, { * `touchCancel` Keyboard events -======= - - @class CollectionView - @namespace Ember - @extends Ember.ContainerView - @since Ember 0.9 -*/ -Ember.CollectionView = Ember.ContainerView.extend({ ->>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147 * `keyDown` * `keyUp` @@ -30863,7 +22411,6 @@ Ember.CollectionView = Ember.ContainerView.extend({ Mouse events -<<<<<<< HEAD * `mouseDown` * `mouseUp` * `contextMenu` @@ -30882,17 +22429,6 @@ Ember.CollectionView = Ember.ContainerView.extend({ * `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: @@ -30905,7 +22441,6 @@ Ember.CollectionView = Ember.ContainerView.extend({ ## 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. @@ -30914,8 +22449,7 @@ Ember.CollectionView = Ember.ContainerView.extend({ @namespace Ember @extends Ember.CoreView */ -Ember.View = Ember.CoreView.extend( -/** @scope Ember.View.prototype */ { +Ember.View = Ember.CoreView.extend({ concatenatedProperties: ['classNames', 'classNameBindings', 'attributeBindings'], @@ -30923,54 +22457,14 @@ Ember.View = Ember.CoreView.extend( @property isView @type Boolean @default true - @final + @static */ 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. @@ -30982,29 +22476,6 @@ 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. @@ -31019,31 +22490,9 @@ 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. @@ -31133,8 +22582,6 @@ Ember.View = Ember.CoreView.extend( }).volatile(), /** - @private - 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. @@ -31149,30 +22596,11 @@ 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 + @private */ _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; @@ -31187,53 +22615,33 @@ Ember.View = Ember.CoreView.extend( }), /** - @private - If a value that affects template rendering changes, the view should be re-rendered to reflect the new value. -<<<<<<< HEAD @method _contextDidChange + @private */ _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 - Array of child views. You should never edit this array directly. Instead, use `appendChild` and `removeFromParent`. -<<<<<<< HEAD @property childViews @type Array @default [] + @private */ childViews: childViewsProperty, @@ -31260,39 +22668,6 @@ var get = Ember.get, set = Ember.set, isNone = Ember.isNone, /** 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 - -

{{person.title}}

- {{! Executed in the components context. }} - {{yield}} {{! block contents }} - ``` - - If you want to customize the component, in order to - handle events or actions, you implement a subclass - of `Ember.Component` named after the name of the - component. Note that `Component` needs to be appended to the name of - your subclass like `AppProfileComponent`. ->>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147 @property nearestInstanceOf @param {Class} klass Subclass of Ember.View (or Ember.View itself) @@ -31303,18 +22678,9 @@ var get = Ember.get, set = Ember.set, isNone = Ember.isNone, Ember.deprecate("nearestInstanceOf is deprecated and will be removed from future releases. Use nearestOfType."); var view = get(this, 'parentView'); -<<<<<<< HEAD while (view) { if (view instanceof klass) { return view; } view = get(view, 'parentView'); -======= - ```javascript - App.AppProfileComponent = Ember.Component.extend({ - actions: { - hello: function(name) { - console.log("Hello", name); - } ->>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147 } }, @@ -31342,45 +22708,30 @@ var get = Ember.get, set = Ember.set, isNone = Ember.isNone, /** Return the nearest ancestor that has a given property. - @property nearestWithProperty + @function nearestWithProperty @param {String} property A property name @return Ember.View */ nearestWithProperty: function(property) { var view = get(this, 'parentView'); -<<<<<<< HEAD while (view) { if (property in view) { return view; } view = get(view, 'parentView'); } -======= - defaultLayout: function(options){ - options.data = {view: options._context}; - Ember.Handlebars.helpers['yield'].apply(this, [options]); - }, - - // during render, isolate keywords - cloneKeywords: function() { - return { - view: this, - controller: this - }; ->>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147 }, /** Return the nearest ancestor whose parent is an instance of `klass`. - @property nearestChildOf + @method nearestChildOf @param {Class} klass Subclass of Ember.View (or Ember.View itself) @return Ember.View */ nearestChildOf: function(klass) { var view = get(this, 'parentView'); -<<<<<<< HEAD while (view) { if (get(view, 'parentView') instanceof klass) { return view; } view = get(view, 'parentView'); @@ -31388,11 +22739,10 @@ var get = Ember.get, set = Ember.set, isNone = Ember.isNone, }, /** - @private - When the parent view changes, recursively invalidate `controller` @method _parentViewDidChange + @private */ _parentViewDidChange: Ember.observer('_parentView', function() { if (this.isDestroying) { return; } @@ -31429,136 +22779,11 @@ var get = Ember.get, set = Ember.set, isNone = Ember.isNone, Called on your view when it should push strings of HTML into a `Ember.RenderBuffer`. Most users will want to override the `template` or `templateName` properties instead of this method. -======= - view.appendChild(Ember.View, { - isVirtual: true, - tagName: '', - _contextView: parentView, - template: template, - context: get(parentView, 'context'), - controller: get(parentView, 'controller'), - templateData: { keywords: parentView.cloneKeywords() } - }); - } - }, - - /** - If the component is currently inserted into the DOM of a parent view, this - property will point to the controller of the parent view. - - @property targetObject - @type Ember.Controller - @default null - */ - targetObject: Ember.computed(function(key) { - var parentView = get(this, '_parentView'); - return parentView ? get(parentView, 'controller') : null; - }).property('_parentView'), - - /** - Triggers a named action on the controller context where the component is used if - this controller has registered for notifications of the action. - - For example a component for playing or pausing music may translate click events - into action notifications of "play" or "stop" depending on some internal state - of the component: - - - ```javascript - App.PlayButtonComponent = Ember.Component.extend({ - click: function(){ - if (this.get('isPlaying')) { - this.triggerAction('play'); - } else { - this.triggerAction('stop'); - } - } - }); - ``` - - When used inside a template these component actions are configured to - trigger actions in the outer application context: - - ```handlebars - {{! application.hbs }} - {{play-button play="musicStarted" stop="musicStopped"}} - ``` - - When the component receives a browser `click` event it translate this - interaction into application-specific semantics ("play" or "stop") and - triggers the specified action name on the controller for the template - where the component is used: - - - ```javascript - App.ApplicationController = Ember.Controller.extend({ - actions: { - musicStarted: function(){ - // called when the play button is clicked - // and the music started playing - }, - musicStopped: function(){ - // called when the play button is clicked - // and the music stopped playing - } - } - }); - ``` - - If no action name is passed to `sendAction` a default name of "action" - is assumed. - - ```javascript - App.NextButtonComponent = Ember.Component.extend({ - click: function(){ - this.sendAction(); - } - }); - ``` - - ```handlebars - {{! application.hbs }} - {{next-button action="playNextSongInAlbum"}} - ``` - - ```javascript - App.ApplicationController = Ember.Controller.extend({ - actions: { - playNextSongInAlbum: function(){ - ... - } - } - }); - ``` - - @method sendAction - @param [action] {String} the action to trigger - @param [context] {*} a context to send with the action - */ - sendAction: function(action) { - var actionName, - contexts = a_slice.call(arguments, 1); - - // Send the default action - if (action === undefined) { - actionName = get(this, 'action'); - Ember.assert("The default action was triggered on the component " + this.toString() + - ", but the action name (" + actionName + ") was not a string.", - isNone(actionName) || typeof actionName === 'string'); - } else { - actionName = get(this, action); - Ember.assert("The " + action + " action was triggered on the component " + - this.toString() + ", but the action name (" + actionName + - ") was not a string.", - isNone(actionName) || typeof actionName === 'string'); - } ->>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147 By default, `Ember.View` will look for a function in the `template` property and invoke it with the value of `context`. The value of `context` will be the view's controller unless you override it. -<<<<<<< HEAD @method render @param {Ember.RenderBuffer} buffer The render buffer */ @@ -31567,16 +22792,6 @@ var get = Ember.get, set = Ember.set, isNone = Ember.isNone, // the layout to render the view's template. Otherwise, render the template // directly. var template = get(this, 'layout') || get(this, 'template'); -======= - this.triggerAction({ - action: actionName, - actionContext: contexts - }); - } -}); - -})(); ->>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147 if (template) { var context = get(this, 'context'); @@ -31642,14 +22857,13 @@ var get = Ember.get, set = Ember.set, isNone = Ember.isNone, }, /** - @private - 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 */ _applyClassNameBindings: function(classBindings) { var classNames = this.classNames, @@ -31706,7 +22920,6 @@ var get = Ember.get, set = Ember.set, isNone = Ember.isNone, oldClass = dasherizedClass; } -<<<<<<< HEAD this.registerObserver(this, parsedPath.path, observer); // Remove className so when the view is rerendered, // the className is added based on binding reevaluation @@ -31719,38 +22932,14 @@ var get = Ember.get, set = Ember.set, isNone = Ember.isNone, }, this); }, -======= -(function() { -define("metamorph", - [], - function() { - "use strict"; - // ========================================================================== - // Project: metamorph - // Copyright: ©2014 Tilde, Inc. All rights reserved. - // ========================================================================== - - var K = function() {}, - guid = 0, - disableRange = (function(){ - if ('undefined' !== typeof MetamorphENV) { - return MetamorphENV.DISABLE_RANGE_API; - } else if ('undefined' !== ENV) { - return ENV.DISABLE_RANGE_API; - } else { - return false; - } - })(), ->>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147 /** - @private - 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; @@ -31780,8 +22969,6 @@ define("metamorph", }, /** - @private - Given a property name, returns a dasherized version of that property name if the property evaluates to a non-falsy value. @@ -31790,6 +22977,7 @@ define("metamorph", @method _classStringForProperty @param property + @private */ _classStringForProperty: function(property) { var parsedPath = Ember.View._parsePropertyPath(property); @@ -31842,25 +23030,10 @@ define("metamorph", idx = childViews.length, view; -<<<<<<< HEAD while(--idx >= 0) { view = childViews[idx]; callback(this, view, idx); } -======= - /** - * @public - * - * Remove this object (including starting and ending - * placeholders). - * - * @method remove - */ - removeFunc = function() { - // get a range for the current metamorph object including - // the starting and ending placeholders. - var range = rangeFor(this, true); ->>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147 return this; }, @@ -31887,31 +23060,9 @@ define("metamorph", If the view does not have an HTML representation yet, `createElement()` will be called automatically. -<<<<<<< HEAD Note that this method just schedules the view to be appended; the DOM element will not be appended to the given element until all bindings have finished synchronizing. -======= - } else { - /* - * This code is mostly taken from jQuery, with one exception. In jQuery's case, we - * have some HTML and we need to figure out how to convert it into some nodes. - * - * In this case, jQuery needs to scan the HTML looking for an opening tag and use - * that as the key for the wrap map. In our case, we know the parent node, and - * can use its type as the key for the wrap map. - **/ - var wrapMap = { - select: [ 1, "" ], - fieldset: [ 1, "
", "
" ], - table: [ 1, "", "
" ], - tbody: [ 2, "", "
" ], - tr: [ 3, "", "
" ], - colgroup: [ 2, "", "
" ], - 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` @@ -31944,25 +23095,13 @@ define("metamorph", 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 + @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')); -======= - /* - * 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(); @@ -31973,8 +23112,6 @@ define("metamorph", }, /** - @private - Schedules a DOM operation to occur during the next render phase. This ensures that all bindings have finished synchronizing before the view is rendered. @@ -31994,6 +23131,7 @@ define("metamorph", @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); @@ -32105,13 +23243,12 @@ define("metamorph", willClearRender: Ember.K, /** - @private - Run this callback on the current view (unless includeSelf is false) and recursively on child views. @method invokeRecursively @param fn {Function} - @param includeSelf (optional, default true) + @param includeSelf {Boolean} Includes itself if true. + @private */ invokeRecursively: function(fn, includeSelf) { var childViews = (includeSelf === false) ? this._childViews : [this]; @@ -32196,8 +23333,6 @@ define("metamorph", willDestroyElement: Ember.K, /** - @private - Triggers the `willDestroyElement` event (which invokes the `willDestroyElement()` method if it exists) on this view and all child views. @@ -32206,6 +23341,7 @@ define("metamorph", `willClearRender` event recursively. @method _notifyWillDestroyElement + @private */ _notifyWillDestroyElement: function() { var viewCollection = this.viewHierarchyCollection(); @@ -32215,13 +23351,12 @@ define("metamorph", }, /** - @private - 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) { @@ -32415,14 +23550,14 @@ define("metamorph", // /** - @private - 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 + + * configure `childViews` + * register the view with the global views hash, which is used for event dispatch @method init + @private */ init: function() { this.elementId = this.elementId || guidFor(this); @@ -32601,12 +23736,11 @@ define("metamorph", becameHidden: Ember.K, /** - @private - 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.$(); @@ -32687,13 +23821,12 @@ define("metamorph", // /** - @private - 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); @@ -32800,8 +23933,6 @@ Ember.View.reopen({ Ember.View.reopenClass({ /** - @private - Parse a path and return an object which holds the parsed properties. For example a path like "content.isEnabled:enabled:disabled" will return the @@ -32818,6 +23949,7 @@ Ember.View.reopenClass({ @method _parsePropertyPath @static + @private */ _parsePropertyPath: function(path) { var split = path.split(':'), @@ -32844,8 +23976,6 @@ Ember.View.reopenClass({ }, /** - @private - Get the class name for a given value, based on the path, optional `className` and optional `falsyClassName`. @@ -32867,6 +23997,7 @@ Ember.View.reopenClass({ @param className @param falsyClassName @static + @private */ _classStringForValue: function(path, val, className, falsyClassName) { // When using the colon syntax, evaluate the truthiness or falsiness @@ -32946,6 +24077,10 @@ Ember.View.applyAttributeBindings = function(elem, name, value) { // We can't set properties to undefined or null if (Ember.isNone(value)) { value = ''; } + if (!value) { + elem.removeAttr(name); + } + if (value !== elem.prop(name)) { // value and booleans should always be properties elem.prop(name, value); @@ -33113,7 +24248,10 @@ Ember.merge(inBuffer, { }, 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."); + 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."); }, renderToBufferIfNeeded: function (view, buffer) { @@ -33341,7 +24479,7 @@ var ViewCollection = Ember._ViewCollection; /** A `ContainerView` is an `Ember.View` subclass that implements `Ember.MutableArray` - allowing programatic management of its child views. + allowing programmatic management of its child views. ## Setting Initial Child Views @@ -33381,7 +24519,7 @@ var ViewCollection = Ember._ViewCollection; ## Adding and Removing Child Views - The container view implements `Ember.MutableArray` allowing programatic management of its child views. + The container view implements `Ember.MutableArray` allowing programmatic management of its child views. To remove a view, pass that view into a `removeObject` call on the container view. @@ -33554,10 +24692,9 @@ Ember.ContainerView = Ember.View.extend(Ember.MutableArray, { }).volatile(), /** - @private - Instructs each child view to render to the passed render buffer. + @private @method render @param {Ember.RenderBuffer} buffer the buffer to render to */ @@ -33570,14 +24707,13 @@ Ember.ContainerView = Ember.View.extend(Ember.MutableArray, { instrumentName: 'container', /** - @private - When a child view is removed, destroy its element so that it is removed from the DOM. The array observer that triggers this action is set up in the `renderToBuffer` method. + @private @method childViewsWillChange @param {Ember.Array} views the child views array before mutation @param {Number} start the start position of the mutation @@ -33600,8 +24736,6 @@ Ember.ContainerView = Ember.View.extend(Ember.MutableArray, { }, /** - @private - When a child view is added, make sure the DOM gets updated appropriately. If the view has already rendered an element, we tell the child view to @@ -33610,6 +24744,7 @@ Ember.ContainerView = Ember.View.extend(Ember.MutableArray, { into an element, we insert the string representation of the child into the appropriate place in the buffer. + @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 @@ -33827,7 +24962,7 @@ var get = Ember.get, set = Ember.set, fmt = Ember.String.fmt; Ember.CollectionView.CONTAINER_MAP['article'] = 'section' ``` - ## Programatic creation of child views + ## Programmatic creation of child views For cases where additional customization beyond the use of a single `itemViewClass` or `tagName` matching is required CollectionView's @@ -33887,7 +25022,7 @@ var get = Ember.get, set = Ember.set, fmt = Ember.String.fmt; @extends Ember.ContainerView @since Ember 0.9 */ -Ember.CollectionView = Ember.ContainerView.extend(/** @scope Ember.CollectionView.prototype */ { +Ember.CollectionView = Ember.ContainerView.extend({ /** A list of items to be displayed by the `Ember.CollectionView`. @@ -33899,12 +25034,11 @@ Ember.CollectionView = Ember.ContainerView.extend(/** @scope Ember.CollectionVie content: null, /** - @private - 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, @@ -33937,11 +25071,10 @@ Ember.CollectionView = Ember.ContainerView.extend(/** @scope Ember.CollectionVie }, /** - @private - 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() { @@ -33953,13 +25086,12 @@ Ember.CollectionView = Ember.ContainerView.extend(/** @scope Ember.CollectionVie }), /** - @private - 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() { @@ -33975,10 +25107,9 @@ Ember.CollectionView = Ember.ContainerView.extend(/** @scope Ember.CollectionVie }), /** - @private - Ensure that the content implements Ember.Array + @private @method _assertArrayLike */ _assertArrayLike: function(content) { @@ -34176,7 +25307,7 @@ var get = Ember.get, set = Ember.set, isNone = Ember.isNone, 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 is passed in. + contextual information must be passed in. The easiest way to create an `Ember.Component` is via a template. If you name a template @@ -34195,19 +25326,23 @@ var get = Ember.get, set = Ember.set, isNone = Ember.isNone,

{{person.signature}}

``` - You can also use `yield` inside a template to - include the **contents** of the custom tag: + 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: - ```html + ```handlebars {{#app-profile person=currentUser}}

Admin mode

+ {{! Executed in the controllers context. }} {{/app-profile}} ``` - ```html + ```handlebars

{{person.title}}

- {{yield}} + {{! Executed in the components context. }} + {{yield}} {{! block contents }} ``` If you want to customize the component, in order to @@ -34258,6 +25393,11 @@ Ember.Component = Ember.View.extend(Ember.TargetActionSupport, { set(this, 'controller', this); }, + defaultLayout: function(options){ + options.data = {view: options._context}; + Ember.Handlebars.helpers['yield'].apply(this, [options]); + }, + // during render, isolate keywords cloneKeywords: function() { return { @@ -34386,10 +25526,15 @@ Ember.Component = Ember.View.extend(Ember.TargetActionSupport, { // Send the default action if (action === undefined) { actionName = get(this, 'action'); - Ember.assert("The default action was triggered on the component " + this.toString() + ", but the action name (" + actionName + ") was not a string.", isNone(actionName) || typeof actionName === 'string'); + Ember.assert("The default action was triggered on the component " + this.toString() + + ", but the action name (" + actionName + ") was not a string.", + isNone(actionName) || typeof actionName === 'string'); } else { actionName = get(this, action); - Ember.assert("The " + action + " action was triggered on the component " + this.toString() + ", but the action name (" + actionName + ") was not a string.", isNone(actionName) || typeof actionName === 'string'); + Ember.assert("The " + action + " action was triggered on the component " + + this.toString() + ", but the action name (" + actionName + + ") was not a string.", + isNone(actionName) || typeof actionName === 'string'); } // If no action name for that action could be found, just abort. @@ -34494,13 +25639,20 @@ define("metamorph", "use strict"; // ========================================================================== // Project: metamorph - // Copyright: ©2011 My Company Inc. All rights reserved. + // Copyright: ©2014 Tilde, Inc. All rights reserved. // ========================================================================== var K = function() {}, guid = 0, - document = this.document, - disableRange = ('undefined' === typeof ENV ? {} : ENV).DISABLE_RANGE_API, + disableRange = (function(){ + if ('undefined' !== typeof MetamorphENV) { + return MetamorphENV.DISABLE_RANGE_API; + } else if ('undefined' !== ENV) { + return ENV.DISABLE_RANGE_API; + } else { + return false; + } + })(), // Feature-detect the W3C range API, the extended check is for IE9 which only partially supports ranges supportsRange = (!disableRange) && document && ('createRange' in document) && (typeof Range !== 'undefined') && Range.prototype.createContextualFragment, @@ -34612,7 +25764,7 @@ define("metamorph", /** * @public - * + * * Remove this object (including starting and ending * placeholders). * @@ -34981,10 +26133,6 @@ 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); @@ -34993,7 +26141,6 @@ 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 @@ -35075,31 +26222,19 @@ 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); }; }; @@ -35171,11 +26306,7 @@ 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\['(.*?)'/, @@ -35424,22 +26555,11 @@ Ember.Handlebars.registerHelper('helperMissing', function(path) { var options = arguments[arguments.length - 1]; -<<<<<<< HEAD - - - var helper = Ember.Handlebars.resolveHelper(options.data.view.container, path); - - if (helper) { - 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) { @@ -35449,11 +26569,6 @@ 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. @@ -35461,10 +26576,7 @@ 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 @@ -35474,18 +26586,6 @@ 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); - - var helper = Ember.Handlebars.resolveHelper(options.data.view.container, path); - - if (helper) { - 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 " + @@ -35499,7 +26599,6 @@ Ember.Handlebars.registerHelper('blockHelperMissing', function(path) { } else { return Handlebars.helpers.helperMissing.call(this, path); } ->>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147 return Handlebars.helpers.blockHelperMissing.apply(this, arguments); }); @@ -35620,11 +26719,6 @@ 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. @@ -35643,10 +26737,7 @@ 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 @@ -35660,7 +26751,6 @@ Ember.Handlebars.makeBoundHelper = function(fn) { numProperties = properties.length, options = arguments[arguments.length - 1], normalizedProperties = [], - types = options.types, data = options.data, types = data.isUnbound ? slice.call(options.types, 1) : options.types, hash = options.hash, @@ -35693,15 +26783,11 @@ 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 } } @@ -35781,10 +26867,7 @@ Ember.Handlebars.makeBoundHelper = function(fn) { /** Renders the unbound form of an otherwise bound helper function. -<<<<<<< HEAD -======= @private ->>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147 @method evaluateUnboundHelper @param {Function} fn @param {Object} context @@ -35809,16 +26892,12 @@ 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); @@ -36511,11 +27590,6 @@ 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 @@ -36535,40 +27609,6 @@ EmberHandlebars.registerHelper('_triageMustache', function(property, options) { if (helpers[property]) { return helpers[property].call(this, options); -<<<<<<< HEAD - } - - - - var helper = Ember.Handlebars.resolveHelper(options.data.view.container, property); - if (helper) { - return helper.call(this, 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); @@ -36578,7 +27618,6 @@ Ember.Handlebars.resolveHelper = function(container, name) { return helpers.bind.call(this, property, options); }); ->>>>>>> 60d42738019a33cc73008e81dd0a80eaa6eac147 Ember.Handlebars.resolveHelper = function(container, name) { @@ -36652,11 +27691,7 @@ EmberHandlebars.registerHelper('bind', function bindHelper(property, options) { @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'); @@ -36928,11 +27963,7 @@ EmberHandlebars.registerHelper('unless', function unlessHelper(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; @@ -37030,17 +28061,10 @@ EmberHandlebars.registerHelper('bind-attr', function bindAttrHelper(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, @@ -37708,13 +28732,9 @@ Ember.Handlebars.registerHelper('collection', function collectionHelper(path, op 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 { @@ -37844,11 +28864,7 @@ var get = Ember.get, handlebarsGet = Ember.Handlebars.get, normalizePath = Ember @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, @@ -38428,11 +29444,7 @@ 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; @@ -38644,11 +29656,7 @@ 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` @@ -38896,11 +29904,7 @@ 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 @@ -38913,12 +29917,7 @@ 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", @@ -38940,7 +29939,6 @@ Ember.TextField = Ember.Component.extend(Ember.TextSupport, { @property type @type String @default "text" -<<<<<<< HEAD */ type: "text", @@ -38960,27 +29958,6 @@ 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 }); @@ -39505,11 +30482,7 @@ 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("