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() {
@ -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.
@ -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;
/*
@ -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() {
@ -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;
@ -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,
@ -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++) ;
}
@ -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.
@ -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;
},
/**
@ -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;
@ -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;
/**
@ -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
@ -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) {
@ -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() {