dist/ember.prod.js in ember-source-1.7.0.beta.1 vs dist/ember.prod.js in ember-source-1.7.0.beta.2

- old
+ new

@@ -3,11 +3,11 @@ * @copyright Copyright 2011-2014 Tilde Inc. and contributors * Portions Copyright 2006-2011 Strobe Inc. * Portions Copyright 2008-2011 Apple Inc. All rights reserved. * @license Licensed under MIT license * See https://raw.github.com/emberjs/ember.js/master/LICENSE - * @version 1.7.0-beta.1 + * @version 1.7.0-beta.2 */ (function() { var define, requireModule, require, requirejs, Ember; @@ -1843,11 +1843,11 @@ @requires ember-views, ember-routing */ var DAG = __dependency3__["default"]; var Resolver = __dependency4__.Resolver; - var DefaultResolver = __dependency4__.default; + var DefaultResolver = __dependency4__["default"]; var Application = __dependency5__["default"]; // side effect of extending ControllerMixin Ember.Application = Application; Ember.DAG = DAG; @@ -7236,11 +7236,11 @@ localizedOptions.hash.keywordName = keywordName; localizedOptions.hash.keywordPath = contextPath; bindContext = this; - context = path; + context = contextPath; options = localizedOptions; preserveContext = true; } else { helperName += ' ' + context; @@ -9141,14 +9141,14 @@ @return {String} HTML string */ function viewHelper(path, options) { // If no path is provided, treat path param as options - // and get an instance of the registered `view:default` + // and get an instance of the registered `view:toplevel` if (path && path.data && path.data.isRenderData) { options = path; - path = options.data.view.container.lookupFactory('view:default'); + path = options.data.view.container.lookupFactory('view:toplevel'); } options.helperName = options.helperName || 'view'; return ViewHelper.helper(this, path, options); @@ -9915,12 +9915,12 @@ */ var _SimpleMetamorphView = CoreView.extend(_Metamorph); __exports__._SimpleMetamorphView = _SimpleMetamorphView;__exports__["default"] = View.extend(_Metamorph); }); define("ember-metal", - ["ember-metal/core","ember-metal/merge","ember-metal/instrumentation","ember-metal/utils","ember-metal/error","ember-metal/enumerable_utils","ember-metal/platform","ember-metal/array","ember-metal/logger","ember-metal/property_get","ember-metal/events","ember-metal/observer_set","ember-metal/property_events","ember-metal/properties","ember-metal/property_set","ember-metal/map","ember-metal/get_properties","ember-metal/set_properties","ember-metal/watch_key","ember-metal/chains","ember-metal/watch_path","ember-metal/watching","ember-metal/expand_properties","ember-metal/computed","ember-metal/observer","ember-metal/mixin","ember-metal/binding","ember-metal/run_loop","ember-metal/libraries","ember-metal/is_none","ember-metal/is_empty","ember-metal/is_blank","exports"], - function(__dependency1__, __dependency2__, __dependency3__, __dependency4__, __dependency5__, __dependency6__, __dependency7__, __dependency8__, __dependency9__, __dependency10__, __dependency11__, __dependency12__, __dependency13__, __dependency14__, __dependency15__, __dependency16__, __dependency17__, __dependency18__, __dependency19__, __dependency20__, __dependency21__, __dependency22__, __dependency23__, __dependency24__, __dependency25__, __dependency26__, __dependency27__, __dependency28__, __dependency29__, __dependency30__, __dependency31__, __dependency32__, __exports__) { + ["ember-metal/core","ember-metal/merge","ember-metal/instrumentation","ember-metal/utils","ember-metal/error","ember-metal/enumerable_utils","ember-metal/platform","ember-metal/array","ember-metal/logger","ember-metal/property_get","ember-metal/events","ember-metal/observer_set","ember-metal/property_events","ember-metal/properties","ember-metal/property_set","ember-metal/map","ember-metal/get_properties","ember-metal/set_properties","ember-metal/watch_key","ember-metal/chains","ember-metal/watch_path","ember-metal/watching","ember-metal/expand_properties","ember-metal/computed","ember-metal/computed_macros","ember-metal/observer","ember-metal/mixin","ember-metal/binding","ember-metal/run_loop","ember-metal/libraries","ember-metal/is_none","ember-metal/is_empty","ember-metal/is_blank","exports"], + function(__dependency1__, __dependency2__, __dependency3__, __dependency4__, __dependency5__, __dependency6__, __dependency7__, __dependency8__, __dependency9__, __dependency10__, __dependency11__, __dependency12__, __dependency13__, __dependency14__, __dependency15__, __dependency16__, __dependency17__, __dependency18__, __dependency19__, __dependency20__, __dependency21__, __dependency22__, __dependency23__, __dependency24__, __dependency25__, __dependency26__, __dependency27__, __dependency28__, __dependency29__, __dependency30__, __dependency31__, __dependency32__, __dependency33__, __exports__) { "use strict"; /** Ember Metal @module ember @@ -10018,39 +10018,41 @@ var expandProperties = __dependency23__["default"]; var ComputedProperty = __dependency24__.ComputedProperty; var computed = __dependency24__.computed; var cacheFor = __dependency24__.cacheFor; - var addObserver = __dependency25__.addObserver; - var observersFor = __dependency25__.observersFor; - var removeObserver = __dependency25__.removeObserver; - var addBeforeObserver = __dependency25__.addBeforeObserver; - var _suspendBeforeObserver = __dependency25__._suspendBeforeObserver; - var _suspendObserver = __dependency25__._suspendObserver; - var _suspendBeforeObservers = __dependency25__._suspendBeforeObservers; - var _suspendObservers = __dependency25__._suspendObservers; - var beforeObserversFor = __dependency25__.beforeObserversFor; - var removeBeforeObserver = __dependency25__.removeBeforeObserver; - var IS_BINDING = __dependency26__.IS_BINDING; - var mixin = __dependency26__.mixin; - var Mixin = __dependency26__.Mixin; - var required = __dependency26__.required; - var aliasMethod = __dependency26__.aliasMethod; - var observer = __dependency26__.observer; - var immediateObserver = __dependency26__.immediateObserver; - var beforeObserver = __dependency26__.beforeObserver; - var Binding = __dependency27__.Binding; - var isGlobalPath = __dependency27__.isGlobalPath; - var bind = __dependency27__.bind; - var oneWay = __dependency27__.oneWay; - var run = __dependency28__["default"]; - var libraries = __dependency29__["default"]; - var isNone = __dependency30__.isNone; - var none = __dependency30__.none; - var isEmpty = __dependency31__.isEmpty; - var empty = __dependency31__.empty; - var isBlank = __dependency32__["default"]; + // side effect of defining the computed.* macros + + var addObserver = __dependency26__.addObserver; + var observersFor = __dependency26__.observersFor; + var removeObserver = __dependency26__.removeObserver; + var addBeforeObserver = __dependency26__.addBeforeObserver; + var _suspendBeforeObserver = __dependency26__._suspendBeforeObserver; + var _suspendObserver = __dependency26__._suspendObserver; + var _suspendBeforeObservers = __dependency26__._suspendBeforeObservers; + var _suspendObservers = __dependency26__._suspendObservers; + var beforeObserversFor = __dependency26__.beforeObserversFor; + var removeBeforeObserver = __dependency26__.removeBeforeObserver; + var IS_BINDING = __dependency27__.IS_BINDING; + var mixin = __dependency27__.mixin; + var Mixin = __dependency27__.Mixin; + var required = __dependency27__.required; + var aliasMethod = __dependency27__.aliasMethod; + var observer = __dependency27__.observer; + var immediateObserver = __dependency27__.immediateObserver; + var beforeObserver = __dependency27__.beforeObserver; + var Binding = __dependency28__.Binding; + var isGlobalPath = __dependency28__.isGlobalPath; + var bind = __dependency28__.bind; + var oneWay = __dependency28__.oneWay; + var run = __dependency29__["default"]; + var libraries = __dependency30__["default"]; + var isNone = __dependency31__.isNone; + var none = __dependency31__.none; + var isEmpty = __dependency32__.isEmpty; + var empty = __dependency32__.empty; + var isBlank = __dependency33__["default"]; // END IMPORTS // BEGIN EXPORTS var EmberInstrumentation = Ember.Instrumentation = {}; EmberInstrumentation.instrument = instrument; @@ -10229,10 +10231,85 @@ requireModule('ember-debug'); } __exports__["default"] = Ember; }); +define("ember-metal/alias", + ["ember-metal/property_get","ember-metal/property_set","ember-metal/error","ember-metal/properties","ember-metal/platform","ember-metal/utils","ember-metal/dependent_keys","exports"], + function(__dependency1__, __dependency2__, __dependency3__, __dependency4__, __dependency5__, __dependency6__, __dependency7__, __exports__) { + "use strict"; + var get = __dependency1__.get; + var set = __dependency2__.set; + var EmberError = __dependency3__["default"]; + var Descriptor = __dependency4__.Descriptor; + var defineProperty = __dependency4__.defineProperty; + var create = __dependency5__.create; + var meta = __dependency6__.meta; + var inspect = __dependency6__.inspect; + var addDependentKeys = __dependency7__.addDependentKeys; + var removeDependentKeys = __dependency7__.removeDependentKeys; + + function alias(altKey) { + return new AliasedProperty(altKey); + } + + __exports__.alias = alias;function AliasedProperty(altKey) { + this.altKey = altKey; + this._dependentKeys = [ altKey ]; + } + + __exports__.AliasedProperty = AliasedProperty;AliasedProperty.prototype = create(Descriptor.prototype); + + AliasedProperty.prototype.get = function AliasedProperty_get(obj, keyName) { + return get(obj, this.altKey); + }; + + AliasedProperty.prototype.set = function AliasedProperty_set(obj, keyName, value) { + return set(obj, this.altKey, value); + }; + + AliasedProperty.prototype.willWatch = function(obj, keyName) { + addDependentKeys(this, obj, keyName, meta(obj)); + }; + + AliasedProperty.prototype.didUnwatch = function(obj, keyName) { + removeDependentKeys(this, obj, keyName, meta(obj)); + }; + + AliasedProperty.prototype.setup = function(obj, keyName) { + var m = meta(obj); + if (m.watching[keyName]) { + addDependentKeys(this, obj, keyName, m); + } + }; + + AliasedProperty.prototype.teardown = function(obj, keyName) { + var m = meta(obj); + if (m.watching[keyName]) { + removeDependentKeys(this, obj, keyName, m); + } + }; + + AliasedProperty.prototype.readOnly = function() { + this.set = AliasedProperty_readOnlySet; + return this; + }; + + function AliasedProperty_readOnlySet(obj, keyName, value) { + throw new EmberError('Cannot set read-only property "' + keyName + '" on object: ' + inspect(obj)); + } + + AliasedProperty.prototype.oneWay = function() { + this.set = AliasedProperty_oneWaySet; + return this; + }; + + function AliasedProperty_oneWaySet(obj, keyName, value) { + defineProperty(obj, keyName, null); + return set(obj, keyName, value); + } + }); define("ember-metal/array", ["exports"], function(__exports__) { "use strict"; /** @@ -11174,120 +11251,40 @@ __exports__.finishChains = finishChains;__exports__.removeChainWatcher = removeChainWatcher; __exports__.ChainNode = ChainNode; }); define("ember-metal/computed", - ["ember-metal/core","ember-metal/property_get","ember-metal/property_set","ember-metal/utils","ember-metal/enumerable_utils","ember-metal/platform","ember-metal/watching","ember-metal/expand_properties","ember-metal/error","ember-metal/properties","ember-metal/property_events","ember-metal/is_empty","ember-metal/is_none","exports"], - function(__dependency1__, __dependency2__, __dependency3__, __dependency4__, __dependency5__, __dependency6__, __dependency7__, __dependency8__, __dependency9__, __dependency10__, __dependency11__, __dependency12__, __dependency13__, __exports__) { + ["ember-metal/core","ember-metal/property_get","ember-metal/property_set","ember-metal/utils","ember-metal/expand_properties","ember-metal/error","ember-metal/properties","ember-metal/property_events","ember-metal/dependent_keys","exports"], + function(__dependency1__, __dependency2__, __dependency3__, __dependency4__, __dependency5__, __dependency6__, __dependency7__, __dependency8__, __dependency9__, __exports__) { "use strict"; var Ember = __dependency1__["default"]; var get = __dependency2__.get; var set = __dependency3__.set; var meta = __dependency4__.meta; var META_KEY = __dependency4__.META_KEY; - var guidFor = __dependency4__.guidFor; - var typeOf = __dependency4__.typeOf; var inspect = __dependency4__.inspect; - var EnumerableUtils = __dependency5__["default"]; - var create = __dependency6__.create; - var watch = __dependency7__.watch; - var unwatch = __dependency7__.unwatch; - var expandProperties = __dependency8__["default"]; - var EmberError = __dependency9__["default"]; - var Descriptor = __dependency10__.Descriptor; - var defineProperty = __dependency10__.defineProperty; - var propertyWillChange = __dependency11__.propertyWillChange; - var propertyDidChange = __dependency11__.propertyDidChange; - var isEmpty = __dependency12__["default"]; - var isNone = __dependency13__.isNone; + var expandProperties = __dependency5__["default"]; + var EmberError = __dependency6__["default"]; + var Descriptor = __dependency7__.Descriptor; + var defineProperty = __dependency7__.defineProperty; + var propertyWillChange = __dependency8__.propertyWillChange; + var propertyDidChange = __dependency8__.propertyDidChange; + var addDependentKeys = __dependency9__.addDependentKeys; + var removeDependentKeys = __dependency9__.removeDependentKeys; /** @module ember-metal */ var metaFor = meta, - a_slice = [].slice, - o_create = create; + a_slice = [].slice; function UNDEFINED() { } - var lengthPattern = /\.(length|\[\])$/; - // .......................................................... - // DEPENDENT KEYS - // - - // data structure: - // meta.deps = { - // 'depKey': { - // 'keyName': count, - // } - // } - - /* - This function returns a map of unique dependencies for a - given object and key. - */ - function keysForDep(depsMeta, depKey) { - var keys = depsMeta[depKey]; - if (!keys) { - // if there are no dependencies yet for a the given key - // create a new empty list of dependencies for the key - keys = depsMeta[depKey] = {}; - } else if (!depsMeta.hasOwnProperty(depKey)) { - // otherwise if the dependency list is inherited from - // a superclass, clone the hash - keys = depsMeta[depKey] = o_create(keys); - } - return keys; - } - - function metaForDeps(meta) { - return keysForDep(meta, 'deps'); - } - - function addDependentKeys(desc, obj, keyName, meta) { - // the descriptor has a list of dependent keys, so - // add all of its dependent keys. - var depKeys = desc._dependentKeys, depsMeta, idx, len, depKey, keys; - if (!depKeys) return; - - depsMeta = metaForDeps(meta); - - for(idx = 0, len = depKeys.length; idx < len; idx++) { - depKey = depKeys[idx]; - // Lookup keys meta for depKey - keys = keysForDep(depsMeta, depKey); - // Increment the number of times depKey depends on keyName. - keys[keyName] = (keys[keyName] || 0) + 1; - // Watch the depKey - watch(obj, depKey, meta); - } - } - - function removeDependentKeys(desc, obj, keyName, meta) { - // the descriptor has a list of dependent keys, so - // remove all of its dependent keys. - var depKeys = desc._dependentKeys, depsMeta, idx, len, depKey, keys; - if (!depKeys) return; - - depsMeta = metaForDeps(meta); - - for(idx = 0, len = depKeys.length; idx < len; idx++) { - depKey = depKeys[idx]; - // Lookup keys meta for depKey - keys = keysForDep(depsMeta, depKey); - // Decrement the number of times depKey depends on keyName. - keys[keyName] = (keys[keyName] || 0) - 1; - // Unwatch the depKey - unwatch(obj, depKey, meta); - } - } - - // .......................................................... // COMPUTED PROPERTY // /** A computed property transforms an objects function into a property. @@ -11420,11 +11417,11 @@ @method volatile @return {Ember.ComputedProperty} this @chainable */ - ComputedPropertyPrototype.volatile = function() { + ComputedPropertyPrototype["volatile"] = function() { return this.cacheable(false); }; /** Call on a computed property to set it into read-only mode. When in this @@ -11776,10 +11773,32 @@ cacheFor.remove = function(cache, key) { cache[key] = undefined; }; + __exports__.ComputedProperty = ComputedProperty; + __exports__.computed = computed; + __exports__.cacheFor = cacheFor; + }); +define("ember-metal/computed_macros", + ["ember-metal/core","ember-metal/property_get","ember-metal/property_set","ember-metal/computed","ember-metal/is_empty","ember-metal/is_none","ember-metal/alias"], + function(__dependency1__, __dependency2__, __dependency3__, __dependency4__, __dependency5__, __dependency6__, __dependency7__) { + "use strict"; + var Ember = __dependency1__["default"]; + var get = __dependency2__.get; + var set = __dependency3__.set; + var computed = __dependency4__.computed; + var isEmpty = __dependency5__["default"]; + var isNone = __dependency6__.isNone; + var alias = __dependency7__.alias; + + /** + @module ember-metal + */ + + var a_slice = [].slice; + function getProperties(self, propertyNames) { var ret = {}; for(var i = 0; i < propertyNames.length; i++) { ret[propertyNames[i]] = get(self, propertyNames[i]); } @@ -12313,20 +12332,12 @@ @for Ember @param {String} dependentKey @return {Ember.ComputedProperty} computed property which creates an alias to the original value for property. */ - computed.alias = function(dependentKey) { - return computed(dependentKey, function(key, value) { - if (arguments.length > 1) { - set(this, dependentKey, value); - } + computed.alias = alias; - return get(this, dependentKey); - }); - }; - /** Where `computed.alias` aliases `get` and `set`, and allows for bidirectional data flow, `computed.oneWay` only provides an aliased `get`. The `set` will not mutate the upstream property, rather causes the current property to become the value set. This causes the downstream property to permanently @@ -12356,13 +12367,11 @@ @param {String} dependentKey @return {Ember.ComputedProperty} computed property which creates a one way computed property to the original value for property. */ computed.oneWay = function(dependentKey) { - return computed(dependentKey, function() { - return get(this, dependentKey); - }); + return alias(dependentKey).oneWay(); }; /** This is a more semantically meaningful alias of `computed.oneWay`, @@ -12410,13 +12419,11 @@ @return {Ember.ComputedProperty} computed property which creates a one way computed property to the original value for property. @since 1.5.0 */ computed.readOnly = function(dependentKey) { - return computed(dependentKey, function() { - return get(this, dependentKey); - }).readOnly(); + return alias(dependentKey).readOnly(); }; /** A computed property that acts like a standard getter and setter, but returns the value at the provided `defaultPath` if the property itself has not been set to a value @@ -12473,14 +12480,10 @@ } else { return get(this, dependentKey); } }); }; - - __exports__.ComputedProperty = ComputedProperty; - __exports__.computed = computed; - __exports__.cacheFor = cacheFor; }); define("ember-metal/core", ["exports"], function(__exports__) { "use strict"; @@ -12506,11 +12509,11 @@ The core Runtime framework is based on the jQuery API with a number of performance optimizations. @class Ember @static - @version 1.7.0-beta.1 + @version 1.7.0-beta.2 */ if ('undefined' === typeof Ember) { // Create core object. Make it act like an instance of Ember.Namespace so that // objects assigned to it are given a sane string representation. @@ -12533,14 +12536,14 @@ /** @property VERSION @type String - @default '1.7.0-beta.1' + @default '1.7.0-beta.2' @static */ - Ember.VERSION = '1.7.0-beta.1'; + Ember.VERSION = '1.7.0-beta.2'; /** Standard environmental variables. You can define these in a global `EmberENV` variable before loading Ember to control various configuration settings. @@ -12693,10 +12696,96 @@ Ember.deprecateFunc = function(_, func) { return func; }; } __exports__["default"] = Ember; }); +define("ember-metal/dependent_keys", + ["ember-metal/platform","ember-metal/watching","exports"], + function(__dependency1__, __dependency2__, __exports__) { + "use strict"; + var create = __dependency1__.create; + var watch = __dependency2__.watch; + var unwatch = __dependency2__.unwatch; + + /** + @module ember-metal + */ + + var o_create = create; + + // .......................................................... + // DEPENDENT KEYS + // + + // data structure: + // meta.deps = { + // 'depKey': { + // 'keyName': count, + // } + // } + + /* + This function returns a map of unique dependencies for a + given object and key. + */ + function keysForDep(depsMeta, depKey) { + var keys = depsMeta[depKey]; + if (!keys) { + // if there are no dependencies yet for a the given key + // create a new empty list of dependencies for the key + keys = depsMeta[depKey] = {}; + } else if (!depsMeta.hasOwnProperty(depKey)) { + // otherwise if the dependency list is inherited from + // a superclass, clone the hash + keys = depsMeta[depKey] = o_create(keys); + } + return keys; + } + + function metaForDeps(meta) { + return keysForDep(meta, 'deps'); + } + + function addDependentKeys(desc, obj, keyName, meta) { + // the descriptor has a list of dependent keys, so + // add all of its dependent keys. + var depKeys = desc._dependentKeys, depsMeta, idx, len, depKey, keys; + if (!depKeys) return; + + depsMeta = metaForDeps(meta); + + for(idx = 0, len = depKeys.length; idx < len; idx++) { + depKey = depKeys[idx]; + // Lookup keys meta for depKey + keys = keysForDep(depsMeta, depKey); + // Increment the number of times depKey depends on keyName. + keys[keyName] = (keys[keyName] || 0) + 1; + // Watch the depKey + watch(obj, depKey, meta); + } + } + + __exports__.addDependentKeys = addDependentKeys;function removeDependentKeys(desc, obj, keyName, meta) { + // the descriptor has a list of dependent keys, so + // remove all of its dependent keys. + var depKeys = desc._dependentKeys, depsMeta, idx, len, depKey, keys; + if (!depKeys) return; + + depsMeta = metaForDeps(meta); + + for(idx = 0, len = depKeys.length; idx < len; idx++) { + depKey = depKeys[idx]; + // Lookup keys meta for depKey + keys = keysForDep(depsMeta, depKey); + // Decrement the number of times depKey depends on keyName. + keys[keyName] = (keys[keyName] || 0) - 1; + // Unwatch the depKey + unwatch(obj, depKey, meta); + } + } + __exports__.removeDependentKeys = removeDependentKeys; + }); define("ember-metal/enumerable_utils", ["ember-metal/array","exports"], function(__dependency1__, __exports__) { "use strict"; var _filter = __dependency1__.filter; @@ -15718,10 +15807,11 @@ value: undefined // make enumerable }); } else { obj[keyName] = undefined; // make enumerable } + if (desc.setup) { desc.setup(obj, keyName); } } else { descs[keyName] = undefined; // shadow descriptor in proto if (desc == null) { value = data; @@ -17825,10 +17915,13 @@ // activate watching first time if (!watching[keyName]) { watching[keyName] = 1; + var desc = m.descs[keyName]; + if (desc && desc.willWatch) { desc.willWatch(obj, keyName); } + if ('function' === typeof obj.willWatchProperty) { obj.willWatchProperty(keyName); } if (MANDATORY_SETTER && keyName in obj) { @@ -17849,10 +17942,13 @@ var m = meta || metaFor(obj), watching = m.watching; if (watching[keyName] === 1) { watching[keyName] = 0; + var desc = m.descs[keyName]; + if (desc && desc.didUnwatch) { desc.didUnwatch(obj, keyName); } + if ('function' === typeof obj.didUnwatchProperty) { obj.didUnwatchProperty(keyName); } if (MANDATORY_SETTER && keyName in obj) { @@ -19510,11 +19606,11 @@ var EmberError = __dependency2__["default"]; var get = __dependency3__.get; var set = __dependency4__.set; var camelize = __dependency5__.camelize; var generateControllerFactory = __dependency6__.generateControllerFactory; - var generateController = __dependency6__.default; + var generateController = __dependency6__["default"]; var handlebarsGet = __dependency7__.handlebarsGet; var viewHelper = __dependency8__.viewHelper; /** @@ -19769,12 +19865,12 @@ } __exports__.resolvePaths = resolvePaths; }); define("ember-routing", - ["ember-handlebars","ember-metal/core","ember-routing/ext/run_loop","ember-routing/ext/controller","ember-routing/ext/view","ember-routing/location/api","ember-routing/location/none_location","ember-routing/location/hash_location","ember-routing/location/history_location","ember-routing/location/auto_location","ember-routing/system/controller_for","ember-routing/system/dsl","ember-routing/system/router","ember-routing/system/route","exports"], - function(__dependency1__, __dependency2__, __dependency3__, __dependency4__, __dependency5__, __dependency6__, __dependency7__, __dependency8__, __dependency9__, __dependency10__, __dependency11__, __dependency12__, __dependency13__, __dependency14__, __exports__) { + ["ember-handlebars","ember-metal/core","ember-routing/ext/run_loop","ember-routing/ext/controller","ember-routing/ext/view","ember-routing/location/api","ember-routing/location/none_location","ember-routing/location/hash_location","ember-routing/location/history_location","ember-routing/location/auto_location","ember-routing/system/generate_controller","ember-routing/system/controller_for","ember-routing/system/dsl","ember-routing/system/router","ember-routing/system/route","exports"], + function(__dependency1__, __dependency2__, __dependency3__, __dependency4__, __dependency5__, __dependency6__, __dependency7__, __dependency8__, __dependency9__, __dependency10__, __dependency11__, __dependency12__, __dependency13__, __dependency14__, __dependency15__, __exports__) { "use strict"; /** Ember Routing @module ember @@ -19791,16 +19887,16 @@ var NoneLocation = __dependency7__["default"]; var HashLocation = __dependency8__["default"]; var HistoryLocation = __dependency9__["default"]; var AutoLocation = __dependency10__["default"]; - var controllerFor = __dependency11__.controllerFor; var generateControllerFactory = __dependency11__.generateControllerFactory; - var generateController = __dependency11__.generateController; - var RouterDSL = __dependency12__["default"]; - var Router = __dependency13__["default"]; - var Route = __dependency14__["default"]; + var generateController = __dependency11__["default"]; + var controllerFor = __dependency12__["default"]; + var RouterDSL = __dependency13__["default"]; + var Router = __dependency14__["default"]; + var Route = __dependency15__["default"]; Ember.Location = EmberLocation; Ember.AutoLocation = AutoLocation; Ember.HashLocation = HashLocation; Ember.HistoryLocation = HistoryLocation; @@ -22871,59 +22967,126 @@ renderTemplate: function(controller, model) { this.render(); }, /** - Renders a template into an outlet. + `render` is used to render a template into a region of another template + (indicated by an `{{outlet}}`). `render` is used both during the entry + phase of routing (via the `renderTemplate` hook) and later in response to + user interaction. - This method has a number of defaults, based on the name of the - route specified in the router. + For example, given the following minimal router and templates: - For example: + ```js + Router.map(function() { + this.resource('photos'); + }); + ``` + ```handlebars + <!-- application.hbs --> + <div class='something-in-the-app-hbs'> + {{outlet "anOutletName"}} + </div> + ``` + + ```handlebars + <!-- photos.hbs --> + <h1>Photos</h1> + ``` + + You can render `photos.hbs` into the `"anOutletName"` outlet of + `application.hbs` by calling `render`: + ```js - App.Router.map(function() { - this.route('index'); - this.resource('post', {path: '/posts/:post_id'}); + // posts route + Ember.Route.extend({ + renderTemplate: function(){ + this.render('posts', { + into: 'application', + outlet: 'anOutletName' + }) + } }); + ``` - App.PostRoute = App.Route.extend({ - renderTemplate: function() { - this.render(); + `render` additionally allows you to supply which `view`, `controller`, and + `model` objects should be loaded and associated with the rendered template. + + + ```js + // posts route + Ember.Route.extend({ + renderTemplate: function(controller, model){ + this.render('posts', { // the template to render, referenced by name + into: 'application', // the template to render into, referenced by name + outlet: 'anOutletName', // the outlet inside `options.template` to render into. + view: 'aViewName', // the view to use for this template, referenced by name + controller: 'someControllerName', // the controller to use for this template, referenced by name + model: model // the model to set on `options.controller`. + }) } }); ``` - The name of the `PostRoute`, as defined by the router, is `post`. + The string values provided for the template name, view, and controller + will eventually pass through to the resolver for lookup. See + Ember.Resolver for how these are mapped to JavaScript objects in your + application. - By default, render will: + Not all options need to be passed to `render`. Default values will be used + based on the name of the route specified in the router or the Route's + `controllerName`, `viewName` and and `templateName` properties. - * render the `post` template - * with the `post` view (`PostView`) for event handling, if one exists - * and the `post` controller (`PostController`), if one exists - * into the `main` outlet of the `application` template + For example: - You can override this behavior: + ```js + // router + Router.map(function() { + this.route('index'); + this.resource('post', {path: '/posts/:post_id'}); + }); + ``` ```js - App.PostRoute = App.Route.extend({ + // post route + PostRoute = App.Route.extend({ renderTemplate: function() { - this.render('myPost', { // the template to render - into: 'index', // the template to render into - outlet: 'detail', // the name of the outlet in that template - controller: 'blogPost' // the controller to use for the template - }); + this.render(); // all defaults apply } }); ``` - Remember that the controller's `model` will be the route's model. In - this case, the default model will be `App.Post.find(params.post_id)`. + The name of the `PostRoute`, defined by the router, is `post`. + The following equivalent default options will be applied when + the Route calls `render`: + + ```js + // + this.render('post', { // the template name associated with 'post' Route + into: 'application', // the parent route to 'post' Route + outlet: 'main', // {{outlet}} and {{outlet 'main' are synonymous}}, + view: 'post', // the view associated with the 'post' Route + controller: 'post', // the controller associated with the 'post' Route + }) + ``` + + By default the controller's `model` will be the route's model, so it does not + need to be passed unless you wish to change which model is being used. + @method render @param {String} name the name of the template to render @param {Object} options the options + @param {String} options.into the template to render into, + referenced by name. Defaults to the parent template + @param {String} options.outlet the outlet inside `options.template` to render into. + Defaults to 'main' + @param {String} options.controller the controller to use for this template, + referenced by name. Defaults to the Route's paired controller + @param {String} options.model the model object to set on `options.controller` + Defaults to the return value of the Route's model hook */ render: function(name, options) { var namePassed = typeof name === 'string' && !!name; @@ -22931,10 +23094,11 @@ options = name; name = this.routeName; } options = options || {}; + options.namePassed = namePassed; var templateName; if (name) { name = name.replace(/\//g, '.'); @@ -23357,14 +23521,14 @@ model = options.model, namedController; if (options.controller) { controller = options.controller; - } else if (namedController = route.container.lookup('controller:' + name)) { - controller = namedController; + } else if (options.namePassed) { + controller = route.container.lookup('controller:' + name) || route.controllerName || route.routeName; } else { - controller = route.controllerName || route.routeName; + controller = route.controllerName || route.container.lookup('controller:' + name); } if (typeof controller === 'string') { var controllerName = controller; controller = route.container.lookup('controller:' + controllerName); @@ -23727,11 +23891,11 @@ _setupLocation: function() { var location = get(this, 'location'); var rootURL = get(this, 'rootURL'); - if (rootURL && !this.container.has('-location-setting:root-url')) { + if (rootURL && this.container && !this.container.has('-location-setting:root-url')) { this.container.register('-location-setting:root-url', rootURL, { instantiate: false }); } if ('string' === typeof location && this.container) { var resolvedLocation = this.container.lookup('location:' + location); @@ -24046,20 +24210,11 @@ } else { // Don't fire an assertion if we found an error substate. return; } - var errorArgs = ['Error while processing route: ' + transition.targetName]; - - if (error) { - if (error.message) { errorArgs.push(error.message); } - if (error.stack) { errorArgs.push(error.stack); } - - if (typeof error === "string") { errorArgs.push(error); } - } - - Ember.Logger.error.apply(this, errorArgs); + logError(error, 'Error while processing route: ' + transition.targetName); }, loading: function(transition, originRoute) { // Attempt to find an appropriate loading substate to enter. var router = originRoute.router; @@ -24086,10 +24241,25 @@ } } } }; + function logError(error, initialMessage) { + var errorArgs = []; + + if (initialMessage) { errorArgs.push(initialMessage); } + + if (error) { + if (error.message) { errorArgs.push(error.message); } + if (error.stack) { errorArgs.push(error.stack); } + + if (typeof error === "string") { errorArgs.push(error); } + } + + Ember.Logger.error.apply(this, errorArgs); + } + function findChildRouteName(parentRoute, originatingChildRoute, name) { var router = parentRoute.router; var childName; var targetChildRouteName = originatingChildRoute.routeName.split('.').pop(); var namespace = parentRoute.routeName === 'application' ? '' : parentRoute.routeName + '.'; @@ -24257,11 +24427,11 @@ if (error.name === "UnrecognizedURLError") { } else if (error.name === 'TransitionAborted') { // just ignore TransitionAborted here } else { - throw error; + logError(error); } return error; }, 'Ember: Process errors from Router'); } @@ -34759,15 +34929,15 @@ delete router['initialURL']; } else { run(app, app.handleURL, url); } - return wait(app); + return app.testHelpers.wait(); } function click(app, selector, context) { - var $el = findWithAssert(app, selector, context); + var $el = app.testHelpers.findWithAssert(selector, context); run($el, 'mousedown'); if ($el.is(':input')) { var type = $el.prop('type'); if (type !== 'checkbox' && type !== 'radio' && type !== 'hidden') { @@ -34785,57 +34955,58 @@ } run($el, 'mouseup'); run($el, 'click'); - return wait(app); + return app.testHelpers.wait(); } function triggerEvent(app, selector, context, type, options){ if (arguments.length === 3) { + options = type; type = context; context = null; } if (typeof options === 'undefined') { options = {}; } - var $el = findWithAssert(app, selector, context); + var $el = app.testHelpers.findWithAssert(selector, context); var event = jQuery.Event(type, options); run($el, 'trigger', event); - return wait(app); + return app.testHelpers.wait(); } function keyEvent(app, selector, context, type, keyCode) { if (typeof keyCode === 'undefined') { keyCode = type; type = context; context = null; } - return triggerEvent(app, selector, context, type, { keyCode: keyCode, which: keyCode }); + return app.testHelpers.triggerEvent(selector, context, type, { keyCode: keyCode, which: keyCode }); } function fillIn(app, selector, context, text) { var $el; if (typeof text === 'undefined') { text = context; context = null; } - $el = findWithAssert(app, selector, context); + $el = app.testHelpers.findWithAssert(selector, context); run(function() { $el.val(text).change(); }); - return wait(app); + return app.testHelpers.wait(); } function findWithAssert(app, selector, context) { - var $el = find(app, selector, context); + var $el = app.testHelpers.find(selector, context); if ($el.length === 0) { throw new EmberError("Element " + selector + " not found."); } return $el; } @@ -34847,11 +35018,11 @@ return $el; } function andThen(app, callback) { - return wait(app, callback(app)); + return app.testHelpers.wait(callback(app)); } function wait(app, value) { return Test.promise(function(resolve) { // If this is the first async promise, kick off the async test @@ -35014,11 +35185,11 @@ visit('secured/path/here') .fillIn('#username', username) .fillIn('#password', username) .click('.submit') - return wait(); + return app.testHelpers.wait(); }); @method wait @param {Object} value The value to be returned. @return {RSVP.Promise} @@ -35083,11 +35254,11 @@ @since 1.5.0 */ helper('currentURL', currentURL); /** - Triggers the given event on the element identified by the provided selector. + Triggers the given DOM event on the element identified by the provided selector. Example: ```javascript triggerEvent('#some-elem-id', 'blur'); @@ -35099,12 +35270,14 @@ triggerEvent('#some-elem-id', 'keypress', { keyCode: 13 }); ``` @method triggerEvent @param {String} selector jQuery selector for finding element on the DOM + @param {String} [context] jQuery selector that will limit the selector + argument to find only within the context's children @param {String} type The event type to be triggered. - @param {String} options The options to be passed to jQuery.Event. + @param {Object} options The options to be passed to jQuery.Event. @return {RSVP.Promise} @since 1.5.0 */ asyncHelper('triggerEvent', triggerEvent); }); @@ -35274,11 +35447,18 @@ @class Test @namespace Ember */ var Test = { + /** + Hash containing all known test helpers. + @property _helpers + @private + */ + _helpers: helpers, + /** `registerHelper` is used to register a test helper that will be injected when `App.injectTestHelpers` is called. The helper method will always be called with the current Application as @@ -37951,11 +38131,11 @@ return this._childViews[idx]; }, length: computed(function () { return this._childViews.length; - }).volatile(), + })["volatile"](), /** Instructs each child view to render to the passed render buffer. @private @@ -39591,11 +39771,11 @@ set(this, '_context', value); return value; } else { return get(this, '_context'); } - }).volatile(), + })["volatile"](), /** 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. @@ -41133,11 +41313,16 @@ } } else if (name === 'value' || type === 'boolean') { if (isNone(value) || value === false) { // `null`, `undefined` or `false` should remove attribute elem.removeAttr(name); - elem.prop(name, ''); + // In IE8 `prop` couldn't remove attribute when name is `required`. + if (name === 'required') { + elem.removeProp(name); + } else { + elem.prop(name, ''); + } } else if (value !== elem.prop(name)) { // value should always be properties elem.prop(name, value); } } else if (!value) { @@ -43363,10 +43548,10 @@ log(router, transition.sequence, "TRANSITION COMPLETE."); // Resolve with the final handler. return handlerInfos[handlerInfos.length - 1].handler; } catch(e) { - if (!(e instanceof TransitionAborted)) { + if (!((e instanceof TransitionAborted))) { //var erroneousHandler = handlerInfos.pop(); var infos = transition.state.handlerInfos; transition.trigger(true, 'error', e, transition, infos[infos.length-1].handler); transition.abort(); } \ No newline at end of file