Update Ember

This commit is contained in:
Piotr Sarnacki 2013-03-13 00:05:34 +01:00
parent b1edd8e510
commit ab97ca0e78

View File

@ -1,5 +1,5 @@
// Version: v1.0.0-rc.1-134-gf13ef4c
// Last commit: f13ef4c (2013-03-08 16:46:38 +0100)
// Version: v1.0.0-rc.1-178-g7fdc957
// Last commit: 7fdc957 (2013-03-12 23:56:02 +0100)
(function() {
@ -150,8 +150,8 @@ Ember.deprecateFunc = function(message, func) {
})();
// Version: v1.0.0-rc.1-134-gf13ef4c
// Last commit: f13ef4c (2013-03-08 16:46:38 +0100)
// Version: v1.0.0-rc.1-178-g7fdc957
// Last commit: 7fdc957 (2013-03-12 23:56:02 +0100)
(function() {
@ -1813,7 +1813,7 @@ var MapWithDefault = Ember.MapWithDefault = function(options) {
@static
@param [options]
@param {anything} [options.defaultValue]
@return {Ember.MapWithDefault|Ember.Map} If options are passed, returns
@return {Ember.MapWithDefault|Ember.Map} If options are passed, returns
`Ember.MapWithDefault` otherwise returns `Ember.Map`
*/
MapWithDefault.create = function(options) {
@ -1876,7 +1876,7 @@ var FIRST_KEY = /^([^\.\*]+)/;
// ..........................................................
// GET AND SET
//
// If we are on a platform that supports accessors we can get use those.
// If we are on a platform that supports accessors we can use those.
// Otherwise simulate accessors by looking up the property directly on the
// object.
@ -1887,7 +1887,7 @@ var FIRST_KEY = /^([^\.\*]+)/;
If you plan to run on IE8 and older browsers then you should use this
method anytime you want to retrieve a property on an object that you don't
know for sure is private. (Properties beginning with an underscore '_'
know for sure is private. (Properties beginning with an underscore '_'
are considered private.)
On all newer browsers, you only need to use this method to retrieve
@ -1949,7 +1949,7 @@ get = function get(obj, keyName) {
If you plan to run on IE8 and older browsers then you should use this
method anytime you want to set a property on an object that you don't
know for sure is private. (Properties beginning with an underscore '_'
know for sure is private. (Properties beginning with an underscore '_'
are considered private.)
On all newer browsers, you only need to use this method to set
@ -2180,11 +2180,8 @@ Ember.isGlobalPath = function(path) {
@module ember-metal
*/
var GUID_KEY = Ember.GUID_KEY,
META_KEY = Ember.META_KEY,
EMPTY_META = Ember.EMPTY_META,
var META_KEY = Ember.META_KEY,
metaFor = Ember.meta,
o_create = Ember.create,
objectDefineProperty = Ember.platform.defineProperty;
var MANDATORY_SETTER = Ember.ENV.MANDATORY_SETTER;
@ -2604,7 +2601,6 @@ var guidFor = Ember.guidFor, // utils.js
META_KEY = Ember.META_KEY, // utils.js
// circular reference observer depends on Ember.watch
// we should move change events to this file or its own property_events.js
notifyObservers = Ember.notifyObservers, // observer.js
forEach = Ember.ArrayPolyfills.forEach, // array.js
FIRST_KEY = /^([^\.\*]+)/,
IS_PATH = /[\.\*]/;
@ -3144,7 +3140,7 @@ Ember.finishChains = function(obj) {
@param {String} keyName The property key (or path) that will change.
@return {void}
*/
function propertyWillChange(obj, keyName, value) {
function propertyWillChange(obj, keyName) {
var m = metaFor(obj, false),
watching = m.watching[keyName] > 0 || keyName === 'length',
proto = m.proto,
@ -3252,7 +3248,6 @@ Ember.warn("The CP_DEFAULT_CACHEABLE flag has been removed and computed properti
var get = Ember.get,
set = Ember.set,
metaFor = Ember.meta,
guidFor = Ember.guidFor,
a_slice = [].slice,
o_create = Ember.create,
META_KEY = Ember.META_KEY,
@ -3288,20 +3283,8 @@ function keysForDep(obj, depsMeta, depKey) {
return keys;
}
/* return obj[META_KEY].deps */
function metaForDeps(obj, meta) {
var deps = meta.deps;
// If the current object has no dependencies...
if (!deps) {
// initialize the dependencies with a pointer back to
// the current object
deps = meta.deps = {};
} else if (!meta.hasOwnProperty('deps')) {
// otherwise if the dependencies are inherited from the
// object's superclass, clone the deps
deps = meta.deps = o_create(deps);
}
return deps;
return keysForDep(obj, meta, 'deps');
}
function addDependentKeys(desc, obj, keyName, meta) {
@ -3729,7 +3712,6 @@ Ember.computed.alias = function(dependentKey) {
var o_create = Ember.create,
metaFor = Ember.meta,
metaPath = Ember.metaPath,
META_KEY = Ember.META_KEY;
/*
@ -4302,7 +4284,7 @@ Ember.RunLoop = RunLoop;
```javascript
Ember.run(function(){
// code to be execute within a RunLoop
// code to be execute within a RunLoop
});
```
@ -4318,8 +4300,7 @@ Ember.RunLoop = RunLoop;
@return {Object} return value from invoking the passed function.
*/
Ember.run = function(target, method) {
var loop,
args = arguments;
var args = arguments;
run.begin();
function tryable() {
@ -4341,7 +4322,7 @@ var run = Ember.run;
```javascript
Ember.run.begin();
// code to be execute within a RunLoop
// code to be execute within a RunLoop
Ember.run.end();
```
@ -4359,7 +4340,7 @@ Ember.run.begin = function() {
```javascript
Ember.run.begin();
// code to be execute within a RunLoop
// code to be execute within a RunLoop
Ember.run.end();
```
@ -4523,8 +4504,8 @@ function invokeLaterTimers() {
}
// schedule next timeout to fire when the earliest timer expires
if (earliest > 0) {
scheduledLater = setTimeout(invokeLaterTimers, earliest - now);
if (earliest > 0) {
scheduledLater = setTimeout(invokeLaterTimers, earliest - now);
scheduledLaterExpires = earliest;
}
});
@ -4575,18 +4556,18 @@ Ember.run.later = function(target, method) {
timer = { target: target, method: method, expires: expires, args: args };
guid = Ember.guidFor(timer);
timers[guid] = timer;
if(scheduledLater && expires < scheduledLaterExpires) {
// Cancel later timer (then reschedule earlier timer below)
clearTimeout(scheduledLater);
scheduledLater = null;
}
if (!scheduledLater) {
if (!scheduledLater) {
// Schedule later timers to be run.
scheduledLater = setTimeout(invokeLaterTimers, wait);
scheduledLaterExpires = expires;
}
}
return guid;
};
@ -4642,11 +4623,11 @@ function scheduleOnce(queue, target, method, args) {
// doFoo will only be executed once at the end of the RunLoop
});
```
Also note that passing an anonymous function to `Ember.run.once` will
not prevent additional calls with an identical anonymous function from
not prevent additional calls with an identical anonymous function from
scheduling the items multiple times, e.g.:
```javascript
function scheduleIt() {
Ember.run.once(myContext, function() { console.log("Closure"); });
@ -4654,7 +4635,7 @@ function scheduleOnce(queue, target, method, args) {
scheduleIt();
scheduleIt();
// "Closure" will print twice, even though we're using `Ember.run.once`,
// because the function we pass to it is anonymous and won't match the
// because the function we pass to it is anonymous and won't match the
// previously scheduled operation.
```
@ -4676,7 +4657,7 @@ Ember.run.scheduleOnce = function(queue, target, method, args) {
/**
Schedules an item to run after control has been returned to the system.
This is equivalent to calling `Ember.run.later` with a wait time of 1ms.
This is equivalent to calling `Ember.run.later` with a wait time of 1ms.
```javascript
Ember.run.next(myContext, function(){
@ -5200,7 +5181,6 @@ var Mixin, REQUIRED, Alias,
a_indexOf = Ember.ArrayPolyfills.indexOf,
a_forEach = Ember.ArrayPolyfills.forEach,
a_slice = [].slice,
EMPTY_META = {}, // dummy for non-writable meta
o_create = Ember.create,
defineProperty = Ember.defineProperty,
guidFor = Ember.guidFor;
@ -5571,7 +5551,7 @@ Ember.anyUnprocessedMixins = false;
/**
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() {
@ -6116,35 +6096,35 @@ define("rsvp",
}
function all(promises) {
var i, results = [];
var allPromise = new Promise();
var remaining = promises.length;
var i, results = [];
var allPromise = new Promise();
var remaining = promises.length;
if (remaining === 0) {
allPromise.resolve([]);
}
var resolver = function(index) {
return function(value) {
resolve(index, value);
};
};
var resolver = function(index) {
return function(value) {
resolve(index, value);
};
};
var resolve = function(index, value) {
results[index] = value;
if (--remaining === 0) {
allPromise.resolve(results);
}
};
var resolve = function(index, value) {
results[index] = value;
if (--remaining === 0) {
allPromise.resolve(results);
}
};
var reject = function(error) {
allPromise.reject(error);
};
var reject = function(error) {
allPromise.reject(error);
};
for (i = 0; i < remaining; i++) {
promises[i].then(resolver(i), reject);
}
return allPromise;
for (i = 0; i < remaining; i++) {
promises[i].then(resolver(i), reject);
}
return allPromise;
}
EventTarget.mixin(Promise.prototype);
@ -7407,8 +7387,7 @@ function iter(key, value) {
@extends Ember.Mixin
@since Ember 0.9
*/
Ember.Enumerable = Ember.Mixin.create(
/** @scope Ember.Enumerable.prototype */ {
Ember.Enumerable = Ember.Mixin.create({
// compatibility
isEnumerable: true,
@ -7441,7 +7420,7 @@ Ember.Enumerable = Ember.Mixin.create(
@method nextObject
@param {Number} index the current index of the iteration
@param {Object} previousObject the value returned by the last call to
@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
@ -8355,6 +8334,10 @@ Ember.Array = Ember.Mixin.create(Ember.Enumerable, /** @scope Ember.Array.protot
var length = get(this, 'length') ;
if (none(beginIndex)) beginIndex = 0 ;
if (none(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++) ;
}
@ -8508,9 +8491,9 @@ Ember.Array = Ember.Mixin.create(Ember.Enumerable, /** @scope Ember.Array.protot
@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
@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
@param {Number} addAmt The number of items that will be added If you
pass `null` assumes 0.
@return {Ember.Array} receiver
*/
@ -8871,8 +8854,7 @@ var forEach = Ember.EnumerableUtils.forEach;
@extends Ember.Mixin
@uses Ember.Enumerable
*/
Ember.MutableEnumerable = Ember.Mixin.create(Ember.Enumerable,
/** @scope Ember.MutableEnumerable.prototype */ {
Ember.MutableEnumerable = Ember.Mixin.create(Ember.Enumerable, {
/**
__Required.__ You must implement this method to apply this mixin.
@ -8984,11 +8966,11 @@ Ember.MutableArray = Ember.Mixin.create(Ember.Array, Ember.MutableEnumerable,
passed array. You should also call `this.enumerableContentDidChange()`
@method replace
@param {Number} idx Starting index in the array to replace. If
@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
@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
@param {Array} objects An array of zero or more objects that should be
inserted into the array at *idx*
*/
replace: Ember.required(),
@ -9851,6 +9833,16 @@ Ember.TargetActionSupport = Ember.Mixin.create({
// 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
@extends Ember.Mixin
@ -9878,6 +9870,7 @@ Ember.Evented = Ember.Mixin.create({
*/
on: function(name, target, method) {
Ember.addListener(this, name, target, method);
return this;
},
/**
@ -9901,6 +9894,7 @@ Ember.Evented = Ember.Mixin.create({
}
Ember.addListener(this, name, target, method, true);
return this;
},
/**
@ -9944,6 +9938,7 @@ Ember.Evented = Ember.Mixin.create({
*/
off: function(name, target, method) {
Ember.removeListener(this, name, target, method);
return this;
},
/**
@ -10274,14 +10269,14 @@ CoreObject.PrototypeMixin = Mixin.create({
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.
@ -11251,6 +11246,8 @@ Ember.Application = Ember.Namespace.extend();
@submodule ember-runtime
*/
var OUT_OF_RANGE_EXCEPTION = "Index out of range";
var EMPTY = [];
var get = Ember.get, set = Ember.set;
@ -11456,12 +11453,100 @@ Ember.ArrayProxy = Ember.Object.extend(Ember.MutableArray,
// No dependencies since Enumerable notifies length of change
}),
replace: function(idx, amt, objects) {
Ember.assert('The content property of '+ this.constructor + ' should be set before modifying it', this.get('content'));
if (get(this, 'content')) this.replaceContent(idx, amt, objects);
_replace: function(idx, amt, objects) {
var content = get(this, 'content');
Ember.assert('The content property of '+ this.constructor + ' should be set before modifying it', content);
if (content) this.replaceContent(idx, amt, objects);
return this;
},
replace: function() {
if (get(this, 'arrangedContent') === get(this, 'content')) {
this._replace.apply(this, arguments);
} else {
throw new Ember.Error("Using replace on an arranged ArrayProxy is not allowed.");
}
},
_insertAt: function(idx, object) {
var content = this.get('content');
if (idx > get(this, 'content.length')) throw new Error(OUT_OF_RANGE_EXCEPTION);
this._replace(idx, 0, [object]);
return this;
},
insertAt: function(idx, object) {
if (get(this, 'arrangedContent') === get(this, 'content')) {
return this._insertAt(idx, object);
} else {
throw new Ember.Error("Using insertAt on an arranged ArrayProxy is not allowed.");
}
},
removeAt: function(start, len) {
if ('number' === typeof start) {
var content = get(this, 'content'),
arrangedContent = get(this, 'arrangedContent'),
indices = [], i;
if ((start < 0) || (start >= get(this, 'length'))) {
throw new Error(OUT_OF_RANGE_EXCEPTION);
}
if (len === undefined) len = 1;
// Get a list of indices in original content to remove
for (i=start; i<start+len; i++) {
// Use arrangedContent here so we avoid confusion with objects transformed by objectAtContent
indices.push(content.indexOf(arrangedContent.objectAt(i)));
}
// Replace in reverse order since indices will change
indices.sort(function(a,b) { return b - a; });
Ember.beginPropertyChanges();
for (i=0; i<indices.length; i++) {
this._replace(indices[i], 1, EMPTY);
}
Ember.endPropertyChanges();
}
return this ;
},
pushObject: function(obj) {
this._insertAt(get(this, 'content.length'), obj) ;
return obj ;
},
pushObjects: function(objects) {
this._replace(get(this, 'length'), 0, objects);
return this;
},
setObjects: function(objects) {
if (objects.length === 0) return this.clear();
var len = get(this, 'length');
this._replace(0, len, objects);
return this;
},
unshiftObject: function(obj) {
this._insertAt(0, obj) ;
return obj ;
},
unshiftObjects: function(objects) {
this._replace(0, 0, objects);
return this;
},
slice: function() {
var arr = this.toArray();
return arr.slice.apply(arr, arguments);
},
arrangedContentArrayWillChange: function(item, idx, removedCnt, addedCnt) {
this.arrayContentWillChange(idx, removedCnt, addedCnt);
},
@ -12855,11 +12940,6 @@ Ember.ViewUtils = {
*/
var get = Ember.get, set = Ember.set;
var indexOf = Ember.ArrayPolyfills.indexOf;
var ClassSet = function() {
this.seen = {};
@ -13630,9 +13710,8 @@ var states = {};
@submodule ember-views
*/
var get = Ember.get, set = Ember.set, addObserver = Ember.addObserver, removeObserver = Ember.removeObserver;
var meta = Ember.meta, guidFor = Ember.guidFor, fmt = Ember.String.fmt;
var a_slice = [].slice;
var get = Ember.get, set = Ember.set;
var guidFor = Ember.guidFor;
var a_forEach = Ember.EnumerableUtils.forEach;
var a_addObject = Ember.EnumerableUtils.addObject;
@ -14354,7 +14433,7 @@ class:
* `mouseEnter`
* `mouseLeave`
Form events:
Form events:
* `submit`
* `change`
@ -14362,7 +14441,7 @@ class:
* `focusOut`
* `input`
HTML5 drag and drop events:
HTML5 drag and drop events:
* `dragStart`
* `drag`
@ -15101,7 +15180,7 @@ Ember.View = Ember.CoreView.extend(
Appends the view's element to the document body. If the view does
not have an HTML representation yet, `createElement()` will be called
automatically.
If your application uses the `rootElement` property, you must append
the view within that element. Rendering views outside of the `rootElement`
is not supported.
@ -15920,14 +15999,14 @@ Ember.View.reopenClass({
`className` and optional `falsyClassName`.
- if a `className` or `falsyClassName` has been specified:
- if the value is truthy and `className` has been specified,
- if the value is truthy and `className` has been specified,
`className` is returned
- if the value is falsy and `falsyClassName` has been specified,
- if the value is falsy and `falsyClassName` has been specified,
`falsyClassName` is returned
- otherwise `null` is returned
- if the value is `true`, the dasherized last part of the supplied path
- if the value is `true`, the dasherized last part of the supplied path
is returned
- if the value is not `false`, `undefined` or `null`, the `value`
- if the value is not `false`, `undefined` or `null`, the `value`
is returned
- if none of the above rules apply, `null` is returned
@ -16123,7 +16202,7 @@ Ember.merge(preRender, {
@submodule ember-views
*/
var get = Ember.get, set = Ember.set, meta = Ember.meta;
var get = Ember.get, set = Ember.set;
var inBuffer = Ember.View.states.inBuffer = Ember.create(Ember.View.states._default);
@ -16211,7 +16290,7 @@ Ember.merge(inBuffer, {
@submodule ember-views
*/
var get = Ember.get, set = Ember.set, meta = Ember.meta;
var get = Ember.get, set = Ember.set;
var hasElement = Ember.View.states.hasElement = Ember.create(Ember.View.states._default);
@ -16378,7 +16457,7 @@ var states = Ember.View.cloneStates(Ember.View.states);
@submodule ember-views
*/
var get = Ember.get, set = Ember.set, meta = Ember.meta;
var get = Ember.get, set = Ember.set;
var forEach = Ember.EnumerableUtils.forEach;
/**
@ -16803,7 +16882,7 @@ var get = Ember.get, set = Ember.set, fmt = Ember.String.fmt;
Given an empty `<body>` and the following code:
```javascript
```javascript
someItemsView = Ember.CollectionView.create({
classNames: ['a-collection'],
content: ['A','B','C'],
@ -17612,7 +17691,7 @@ define("metamorph",
(function() {
/**
@module ember
@submodule ember-handlebars
@submodule ember-handlebars-compiler
*/
// Eliminate dependency on any Ember to simplify precompilation workflow
@ -17979,7 +18058,7 @@ Ember.Handlebars.registerHelper('helperMissing', function(path, options) {
## Example with bound options
Bound hash options are also supported. Example:
Bound hash options are also supported. Example:
```handlebars
{{repeat text countBinding="numRepeats"}}
@ -18017,15 +18096,15 @@ Ember.Handlebars.registerHelper('helperMissing', function(path, options) {
{{concatenate prop1 prop2 prop3}}. If any of the properties change,
the helpr will re-render. Note that dependency keys cannot be
using in conjunction with multi-property helpers, since it is ambiguous
which property the dependent keys would belong to.
which property the dependent keys would belong to.
## Use with unbound helper
The {{unbound}} helper can be used with bound helper invocations
The {{unbound}} helper can be used with bound helper invocations
to render them in their unbound form, e.g.
```handlebars
{{unbound capitalize name}}
{{unbound capitalize name}}
```
In this example, if the name property changes, the helper
@ -18051,7 +18130,7 @@ Ember.Handlebars.registerBoundHelper = function(name, fn) {
view = data.view,
currentContext = (options.contexts && options.contexts[0]) || this,
normalized,
pathRoot, path,
pathRoot, path,
loc, hashOption;
// Detect bound options (e.g. countBinding="otherCount")
@ -18157,7 +18236,7 @@ function evaluateMultiPropertyBoundHelper(context, fn, normalizedProperties, opt
// Assemble liast of watched properties that'll re-render this helper.
watchedProperties = [];
for (boundOption in boundOptions) {
if (boundOptions.hasOwnProperty(boundOption)) {
if (boundOptions.hasOwnProperty(boundOption)) {
watchedProperties.push(normalizePath(context, boundOptions[boundOption], data));
}
}
@ -18360,6 +18439,7 @@ Ember._Metamorph = Ember.Mixin.create({
init: function() {
this._super();
this.morph = Metamorph();
Ember.deprecate('Supplying a tagName to Metamorph views is unreliable and is deprecated. You may be setting the tagName on a Handlebars helper that creates a Metamorph.', !this.tagName);
},
beforeRender: function(buffer) {
@ -19102,14 +19182,14 @@ EmberHandlebars.registerHelper('unless', function(context, options) {
Result in the following rendered output:
```html
```html
<img class="aValue">
```
A boolean return value will insert a specified class name if the property
returns `true` and remove the class name if the property returns `false`.
A class name is provided via the syntax
A class name is provided via the syntax
`somePropertyName:class-name-if-true`.
```javascript
@ -19268,9 +19348,9 @@ EmberHandlebars.registerHelper('bindAttr', function(options) {
@method bindClasses
@for Ember.Handlebars
@param {Ember.Object} context The context from which to lookup properties
@param {String} classBindings A string, space-separated, of class bindings
@param {String} classBindings A string, space-separated, of class bindings
to use
@param {Ember.View} view The view in which observers should look for the
@param {Ember.View} view The view in which observers should look for the
element to update
@param {Srting} bindAttrId Optional bindAttr id used to lookup elements
@return {Array} An array of class names to add
@ -19960,7 +20040,7 @@ Ember.Handlebars.registerHelper('unbound', function(property, fn) {
// Unbound helper call.
options.data.isUnbound = true;
helper = Ember.Handlebars.helpers[arguments[0]] || Ember.Handlebars.helperMissing;
out = helper.apply(this, Array.prototype.slice.call(arguments, 1));
out = helper.apply(this, Array.prototype.slice.call(arguments, 1));
delete options.data.isUnbound;
return out;
}
@ -20405,6 +20485,41 @@ Ember.Handlebars.registerHelper('template', function(name, options) {
Ember.TEMPLATES[name](this, { data: options.data });
});
})();
(function() {
/**
@module ember
@submodule ember-handlebars
*/
/**
`partial` renders a template directly using the current context.
If needed the context can be set using the `{{#with foo}}` helper.
```html
<script type="text/x-handlebars" data-template-name="header_bar">
{{#with currentUser}}
{{partial user_info}}
{{/with}}
</script>
The `data-template-name` attribute of a partial template
is prefixed with an underscore.
```html
<script type="text/x-handlebars" data-template-name="_user_info">
<span>Hello {{username}}!</span>
</script>
```
@method partial
@for Ember.Handlebars.helpers
@param {String} partialName the name of the template to render minus the leading underscore
*/
Ember.Handlebars.registerHelper('partial', function(name, options) {
var nameParts = name.split("/"),
lastPart = nameParts[nameParts.length - 1];
@ -22911,7 +23026,7 @@ Ember.generateController = function(container, controllerName, context) {
*/
var Router = requireModule("router");
var get = Ember.get, set = Ember.set, classify = Ember.String.classify;
var get = Ember.get, set = Ember.set;
var DefaultView = Ember._MetamorphView;
function setupLocation(router) {
@ -23171,8 +23286,7 @@ Ember.Router.reopenClass({
*/
var get = Ember.get, set = Ember.set,
classify = Ember.String.classify,
decamelize = Ember.String.decamelize;
classify = Ember.String.classify;
/**
The `Ember.Route` class is used to define individual routes. Refer to
@ -23921,42 +24035,52 @@ var get = Ember.get, set = Ember.set;
Ember.onLoad('Ember.Handlebars', function(Handlebars) {
/**
@module ember
@submodule ember-handlebars
@submodule ember-routing
*/
Handlebars.OutletView = Ember.ContainerView.extend(Ember._Metamorph);
/**
The `outlet` helper allows you to specify that the current
view's controller will fill in the view for a given area.
The `outlet` helper is a placeholder that the router will fill in with
the appropriate template based on the current state of the application.
``` handlebars
{{outlet}}
```
By default, when the the current controller's `view` property changes, the
outlet will replace its current view with the new view. You can set the
`view` property directly, but it's normally best to use `connectOutlet`.
By default, a template based on Ember's naming conventions will be rendered
into the `outlet` (e.g. `App.PostsRoute` will render the `posts` template).
You can render a different template by using the `render()` method in the
route's `renderTemplate` hook. The following will render the `favoritePost`
template into the `outlet`.
``` javascript
# Instantiate App.PostsView and assign to `view`, so as to render into outlet.
controller.connectOutlet('posts');
App.PostsRoute = Ember.Route.extend({
renderTemplate: function() {
this.render('favoritePost');
}
});
```
You can also specify a particular name other than `view`:
You can create custom named outlets for more control.
``` handlebars
{{outlet masterView}}
{{outlet detailView}}
{{outlet favoritePost}}
{{outlet posts}}
```
Then, you can control several outlets from a single controller.
Then you can define what template is rendered into each outlet in your
route.
``` javascript
# Instantiate App.PostsView and assign to controller.masterView.
controller.connectOutlet('masterView', 'posts');
# Also, instantiate App.PostInfoView and assign to controller.detailView.
controller.connectOutlet('detailView', 'postInfo');
App.PostsRoute = Ember.Route.extend({
renderTemplate: function() {
this.render('favoritePost', { outlet: 'favoritePost' });
this.render('posts', { outlet: 'posts' });
}
});
```
@method outlet
@ -24103,13 +24227,32 @@ Ember.onLoad('Ember.Handlebars', function(Handlebars) {
registeredActions: {}
};
ActionHelper.registerAction = function(actionName, options) {
var keys = ["alt", "shift", "meta", "ctrl"];
var isAllowedClick = function(event, allowedKeys) {
if (typeof allowedKeys === "undefined") {
return isSimpleClick(event);
}
var allowed = true;
keys.forEach(function(key) {
if (event[key + "Key"] && allowedKeys.indexOf(key) === -1) {
allowed = false;
}
});
return allowed;
};
ActionHelper.registerAction = function(actionName, options, allowedKeys) {
var actionId = (++Ember.uuid).toString();
ActionHelper.registeredActions[actionId] = {
eventName: options.eventName,
handler: function(event) {
if (!isSimpleClick(event)) { return true; }
if (!isAllowedClick(event, allowedKeys)) { return true; }
event.preventDefault();
if (options.bubbles === false) {
@ -24241,6 +24384,21 @@ Ember.onLoad('Ember.Handlebars', function(Handlebars) {
is created. Having an instance of `Ember.Application` will satisfy this
requirement.
### Specifying whitelisted modifier keys
By default the `{{action}}` helper will ignore click event with pressed modifier
keys. You can supply an `allowedKeys` option to specify which keys should not be ignored.
```handlebars
<script type="text/x-handlebars" data-template-name='a-template'>
<div {{action anActionName allowedKeys="alt"}}>
click me
</div>
</script>
```
This way the `{{action}}` will fire when clicking with the alt key pressed down.
### Specifying a Target
There are several possible target objects for `{{action}}` helpers:
@ -24349,7 +24507,7 @@ Ember.onLoad('Ember.Handlebars', function(Handlebars) {
action.target = { root: root, target: target, options: options };
action.bubbles = hash.bubbles;
var actionId = ActionHelper.registerAction(actionName, action);
var actionId = ActionHelper.registerAction(actionName, action, hash.allowedKeys);
return new SafeString('data-ember-action="' + actionId + '"');
});
@ -25349,7 +25507,7 @@ var Application = Ember.Application = Ember.Namespace.extend({
Automatically initialize the application once the DOM has
become ready.
The initialization itself is deferred using Ember.run.once,
The initialization itself is scheduled on the actions queue
which ensures that application loading finishes before
booting.
@ -25363,8 +25521,8 @@ var Application = Ember.Application = Ember.Namespace.extend({
scheduleInitialize: function() {
var self = this;
this.$().ready(function() {
if (self.isDestroyed || self.isInitialized) return;
Ember.run(self, 'initialize');
if (self.isDestroyed || self.isInitialized) { return; }
Ember.run.schedule('actions', self, 'initialize');
});
},
@ -25473,7 +25631,7 @@ var Application = Ember.Application = Ember.Namespace.extend({
this.isInitialized = true;
// At this point, the App.Router must already be assigned
this.__container__.register('router', 'main', this.Router);
this.register('router', 'main', this.Router);
this.runInitializers();
Ember.runLoadHooks('application', this);
@ -25513,6 +25671,7 @@ var Application = Ember.Application = Ember.Namespace.extend({
graph.topsort(function (vertex) {
var initializer = vertex.value;
Ember.assert("No application initializer named '"+vertex.name+"'", initializer);
initializer(container, namespace);
});
},
@ -25763,7 +25922,7 @@ Ember.runLoadHooks('Ember.Application', Ember.Application);
(function() {
/**
@module ember
@submodule ember-routing
@submodule ember-application
*/
var get = Ember.get, set = Ember.set;
@ -27095,8 +27254,8 @@ Ember States
})();
// Version: v1.0.0-rc.1-134-gf13ef4c
// Last commit: f13ef4c (2013-03-08 16:46:38 +0100)
// Version: v1.0.0-rc.1-178-g7fdc957
// Last commit: 7fdc957 (2013-03-12 23:56:02 +0100)
(function() {