update ember.js

This commit is contained in:
Sven Fuchs 2012-06-27 16:39:02 +02:00
parent c7b561a80e
commit a42b3f133c
2 changed files with 480 additions and 230 deletions

View File

@ -1,5 +1,5 @@
// Version: v0.9.8.1-437-g68d406e
// Last commit: 68d406e (2012-06-25 14:59:55 -0700)
// Version: v0.9.8.1-451-g50ee26d
// Last commit: 50ee26d (2012-06-26 18:06:44 -0700)
(function() {
@ -136,8 +136,8 @@ window.ember_deprecateFunc = Ember.deprecateFunc("ember_deprecateFunc is deprec
})();
// Version: v0.9.8.1-437-g68d406e
// Last commit: 68d406e (2012-06-25 14:59:55 -0700)
// Version: v0.9.8.1-451-g50ee26d
// Last commit: 50ee26d (2012-06-26 18:06:44 -0700)
(function() {
@ -6018,9 +6018,11 @@ function xform(target, method, params) {
libraries by implementing only methods that mostly correspond to the
JavaScript 1.8 API.
@extends Ember.Mixin
@since Ember 0.9
*/
Ember.Enumerable = Ember.Mixin.create( /** @lends Ember.Enumerable */ {
Ember.Enumerable = Ember.Mixin.create(
/** @scope Ember.Enumerable.prototype */ {
/** @private - compatibility */
isEnumerable: true,
@ -6051,9 +6053,9 @@ Ember.Enumerable = Ember.Mixin.create( /** @lends Ember.Enumerable */ {
The default implementation of this method simply looks up the index.
This works great on any Array-like objects.
@param index {Number} the current index of the iteration
@param previousObject {Object} the value returned by the last call to nextObject.
@param context {Object} a context object you can use to maintain state.
@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.
@returns {Object} the next object in the iteration or undefined
*/
nextObject: Ember.required(Function),
@ -6148,7 +6150,7 @@ Ember.Enumerable = Ember.Mixin.create( /** @lends Ember.Enumerable */ {
to give your iterator function access to the current object.
@param {Function} callback The callback to execute
@param {Object} target The target object to use
@param {Object} [target] The target object to use
@returns {Object} receiver
*/
forEach: function(callback, target) {
@ -6170,7 +6172,7 @@ Ember.Enumerable = Ember.Mixin.create( /** @lends Ember.Enumerable */ {
/**
Alias for mapProperty
@params key {String} name of the property
@param {String} key name of the property
@returns {Array} The mapped array.
*/
getEach: function(key) {
@ -6213,7 +6215,7 @@ Ember.Enumerable = Ember.Mixin.create( /** @lends Ember.Enumerable */ {
to give your iterator function access to the current object.
@param {Function} callback The callback to execute
@param {Object} target The target object to use
@param {Object} [target] The target object to use
@returns {Array} The mapped array.
*/
map: function(callback, target) {
@ -6228,7 +6230,7 @@ Ember.Enumerable = Ember.Mixin.create( /** @lends Ember.Enumerable */ {
Similar to map, this specialized function returns the value of the named
property on all items in the enumeration.
@params key {String} name of the property
@param {String} key name of the property
@returns {Array} The mapped array.
*/
mapProperty: function(key) {
@ -6258,7 +6260,7 @@ Ember.Enumerable = Ember.Mixin.create( /** @lends Ember.Enumerable */ {
to give your iterator function access to the current object.
@param {Function} callback The callback to execute
@param {Object} target The target object to use
@param {Object} [target] The target object to use
@returns {Array} A filtered array.
*/
filter: function(callback, target) {
@ -6274,8 +6276,8 @@ Ember.Enumerable = Ember.Mixin.create( /** @lends Ember.Enumerable */ {
can pass an optional second argument with the target value. Otherwise
this will match any property that evaluates to true.
@params key {String} the property to test
@param value {String} optional value to test against.
@param {String} key the property to test
@param {String} [value] optional value to test against.
@returns {Array} filtered array
*/
filterProperty: function(key, value) {
@ -6303,7 +6305,7 @@ Ember.Enumerable = Ember.Mixin.create( /** @lends Ember.Enumerable */ {
to give your iterator function access to the current object.
@param {Function} callback The callback to execute
@param {Object} target The target object to use
@param {Object} [target] The target object to use
@returns {Object} Found item or null.
*/
find: function(callback, target) {
@ -6329,8 +6331,8 @@ Ember.Enumerable = Ember.Mixin.create( /** @lends Ember.Enumerable */ {
This method works much like the more generic find() method.
@params key {String} the property to test
@param value {String} optional value to test against.
@param {String} key the property to test
@param {String} [value] optional value to test against.
@returns {Object} found item or null
*/
findProperty: function(key, value) {
@ -6361,7 +6363,7 @@ Ember.Enumerable = Ember.Mixin.create( /** @lends Ember.Enumerable */ {
if (people.every(isEngineer)) { Paychecks.addBigBonus(); }
@param {Function} callback The callback to execute
@param {Object} target The target object to use
@param {Object} [target] The target object to use
@returns {Boolean}
*/
every: function(callback, target) {
@ -6374,8 +6376,8 @@ Ember.Enumerable = Ember.Mixin.create( /** @lends Ember.Enumerable */ {
Returns true if the passed property resolves to true for all items in the
enumerable. This method is often simpler/faster than using a callback.
@params key {String} the property to test
@param value {String} optional value to test against.
@param {String} key the property to test
@param {String} [value] optional value to test against.
@returns {Array} filtered array
*/
everyProperty: function(key, value) {
@ -6407,7 +6409,7 @@ Ember.Enumerable = Ember.Mixin.create( /** @lends Ember.Enumerable */ {
if (people.some(isManager)) { Paychecks.addBiggerBonus(); }
@param {Function} callback The callback to execute
@param {Object} target The target object to use
@param {Object} [target] The target object to use
@returns {Array} A filtered array.
*/
some: function(callback, target) {
@ -6420,8 +6422,8 @@ Ember.Enumerable = Ember.Mixin.create( /** @lends Ember.Enumerable */ {
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.
@params key {String} the property to test
@param value {String} optional value to test against.
@param {String} key the property to test
@param {String} [value] optional value to test against.
@returns {Boolean} true
*/
someProperty: function(key, value) {
@ -6475,8 +6477,8 @@ Ember.Enumerable = Ember.Mixin.create( /** @lends Ember.Enumerable */ {
implements it. This method corresponds to the implementation in
Prototype 1.6.
@param methodName {String} the name of the method
@param args {Object...} optional arguments to pass as well.
@param {String} methodName the name of the method
@param {Object...} args optional arguments to pass as well.
@returns {Array} return values from calling invoke.
*/
invoke: function(methodName) {
@ -6666,7 +6668,7 @@ Ember.Enumerable = Ember.Mixin.create( /** @lends Ember.Enumerable */ {
An enumerable of the objects to be removed or the number of items to
be removed.
@param {Ember.Enumerable|Numbe} adding
@param {Ember.Enumerable|Number} adding
An enumerable of the objects to be added or the number of items to be
added.
@ -7125,6 +7127,7 @@ Ember.Array = Ember.Mixin.create(Ember.Enumerable, /** @scope Ember.Array.protot
You should implement the compare() method.
@extends Ember.Mixin
@since Ember 0.9
*/
Ember.Comparable = Ember.Mixin.create( /** @scope Ember.Comparable.prototype */{
@ -7182,6 +7185,7 @@ var get = Ember.get, set = Ember.set;
Note that frozenCopy() will only work if you also implement Ember.Freezable.
@extends Ember.Mixin
@since Ember 0.9
*/
Ember.Copyable = Ember.Mixin.create(
@ -7293,6 +7297,7 @@ var get = Ember.get, set = Ember.set;
Ember.Copyable protocol, which defines a frozenCopy() method that will return
a frozen object, if the object implements this method as well.
@extends Ember.Mixin
@since Ember 0.9
*/
Ember.Freezable = Ember.Mixin.create(
@ -8260,7 +8265,13 @@ function xform(target, method, params) {
method.apply(target, args);
}
Ember.Evented = Ember.Mixin.create({
/**
@class
@extends Ember.Mixin
*/
Ember.Evented = Ember.Mixin.create(
/** @scope Ember.Evented.prototype */ {
on: function(name, target, method) {
if (!method) {
method = target;
@ -8483,7 +8494,7 @@ if (Ember.config.overridePrototypeMixin) {
CoreObject.__super__ = null;
var ClassMixin = Ember.Mixin.create(
/** @scope Ember.CoreObject */ {
/** @scope Ember.ClassMixin.prototype */ {
ClassMixin: Ember.required(),
@ -9969,7 +9980,14 @@ Ember.Controller = Ember.Object.extend(Ember.ControllerMixin);
(function() {
var get = Ember.get, set = Ember.set, forEach = Ember.EnumerableUtils.forEach;
Ember.SortableMixin = Ember.Mixin.create(Ember.MutableEnumerable, {
/**
@class
@extends Ember.Mixin
@extends Ember.MutableEnumerable
*/
Ember.SortableMixin = Ember.Mixin.create(Ember.MutableEnumerable,
/** @scope Ember.Observable.prototype */ {
sortProperties: null,
sortAscending: true,
@ -10451,7 +10469,7 @@ Ember.Application.registerInjection({
injection: function(app, router, property) {
if (!/^[A-Z].*Controller$/.test(property)) { return; }
var name = property[0].toLowerCase() + property.substr(1),
var name = property.charAt(0).toLowerCase() + property.substr(1),
controller = app[property].create();
router.set(name, controller);
@ -11948,6 +11966,7 @@ var invokeForState = {
Handlebars helper. See `Handlebars.helpers.view` for additional information.
@extends Ember.Object
@extends Ember.Evented
*/
Ember.View = Ember.Object.extend(Ember.Evented,
/** @scope Ember.View.prototype */ {
@ -14649,6 +14668,8 @@ var get = Ember.get, set = Ember.set, getPath = Ember.getPath;
/**
@class
@extends Ember.Object
*/
Ember.State = Ember.Object.extend(Ember.Evented,
/** @scope Ember.State.prototype */{
@ -14657,7 +14678,7 @@ Ember.State = Ember.Object.extend(Ember.Evented,
/**
A reference to the parent state.
@type {Ember.State}
@type Ember.State
*/
parentState: null,
start: null,
@ -15631,7 +15652,7 @@ Ember.Routable = Ember.Mixin.create({
In general, this will update the browser's URL.
*/
updateRoute: function(manager, location) {
if (get(this, 'isLeaf')) {
if (get(this, 'isLeafRoute')) {
var path = this.absoluteRoute(manager);
location.setURL(path);
}
@ -15683,6 +15704,16 @@ Ember.Routable = Ember.Mixin.create({
return typeof get(this, 'route') === 'string';
}).cacheable(),
/**
@private
Determine if this is the last routeable state
*/
isLeafRoute: Ember.computed(function() {
if (get(this, 'isLeaf')) { return true; }
return !get(this, 'childStates').findProperty('isRoutable');
}).cacheable(),
/**
@private
@ -15825,10 +15856,12 @@ Ember.Routable = Ember.Mixin.create({
on the state whose path is `/posts` with the path `/2/comments`.
*/
routePath: function(manager, path) {
if (get(this, 'isLeaf')) { return; }
if (get(this, 'isLeafRoute')) { return; }
var childStates = get(this, 'childStates'), match;
childStates = Ember.A(childStates.filterProperty('isRoutable'));
childStates = childStates.sort(function(a, b) {
var aDynamicSegments = getPath(a, 'routeMatcher.identifiers.length'),
bDynamicSegments = getPath(b, 'routeMatcher.identifiers.length'),
@ -16142,12 +16175,12 @@ var get = Ember.get, getPath = Ember.getPath, set = Ember.set;
}
Within `deserialize` you should use this information to retrieve or create an appropriate context
object for the given url (e.g. by loading from a remote API or accessing the browser's
`localStorage`). This object must be the `return` value for `deserialize` and will be
object for the given URL (e.g. by loading from a remote API or accessing the browser's
`localStorage`). This object must be the `return` value of `deserialize` and will be
passed to the Route's `connectOutlets` and `serialize` methods.
When an application's state is changed from within the application itself, the context provided for
the transiton will be passed and `deserialize` is not called (see 'Transitions Between States').
the transition will be passed and `deserialize` is not called (see 'Transitions Between States').
### Serializing An Object For URLs with Dynamic Segments
When transitioning into a Route whose `route` property contains dynamic segments the Route's
@ -16206,7 +16239,7 @@ var get = Ember.get, getPath = Ember.getPath, set = Ember.set;
App.get('router').send('moveElsewhere');
Will transition the application's state to 'root.bRoute' and trigger an update of the URL to
'#/someOtherLocation
'#/someOtherLocation'.
For URL patterns with dynamic segments a context can be supplied as the second argument to `send`.
The router will match dynamic segments names to keys on this object and fill in the URL with the
@ -16244,7 +16277,7 @@ var get = Ember.get, getPath = Ember.getPath, set = Ember.set;
During application initialization Ember will detect properties of the application ending in 'Controller',
create singleton instances of each class, and assign them as a properties on the router. The property name
will be the UpperCamel name converted to lowerCamel format. These controller classes should be subclasses
of Ember.ObjectController, Ember.ArrayController, or a custom Ember.Object that includes the
of Ember.ObjectController, Ember.ArrayController, Ember.Controller, or a custom Ember.Object that includes the
Ember.ControllerMixin mixin.
App = Ember.Application.create({
@ -16377,13 +16410,19 @@ Ember.Router = Ember.StateManager.extend(
route: function(path) {
set(this, 'isRouting', true);
var routableState;
try {
path = path.replace(/^(?=[^\/])/, "/");
this.send('navigateAway');
this.send('unroutePath', path);
var currentURL = get(this, 'currentState').absoluteRoute(this);
routableState = get(this, 'currentState');
while (routableState && !routableState.get('isRoutable')) {
routableState = get(routableState, 'parentState');
}
var currentURL = routableState ? routableState.absoluteRoute(this) : '';
var rest = path.substr(currentURL.length);
this.send('routePath', rest);
@ -16391,13 +16430,21 @@ Ember.Router = Ember.StateManager.extend(
set(this, 'isRouting', false);
}
get(this, 'currentState').updateRoute(this, get(this, 'location'));
routableState = get(this, 'currentState');
while (routableState && !routableState.get('isRoutable')) {
routableState = get(routableState, 'parentState');
}
if (routableState) {
routableState.updateRoute(this, get(this, 'location'));
}
},
urlFor: function(path, hash) {
var currentState = get(this, 'currentState') || this,
state = this.findStateByPath(currentState, path);
Ember.assert(Ember.String.fmt("Could not find route with path '%@'", [path]), !!state);
Ember.assert("To get a URL for a state, it must have a `route` property.", !!get(state, 'routeMatcher'));
var location = get(this, 'location'),
@ -19616,7 +19663,85 @@ var indexOf = Ember.EnumerableUtils.indexOf, indexesOf = Ember.EnumerableUtils.i
The Ember.Select view class renders a
[select](https://developer.mozilla.org/en/HTML/Element/select) HTML element,
allowing the user to choose from a list of options. The selected option(s)
are updated live in the `selection` property.
are updated live in the `selection` property, while the corresponding value
is updated in the `value` property.
### Using Strings
The simplest version of an Ember.Select takes an array of strings for the options
of a select box and a valueBinding to set the value.
Example:
App.controller = Ember.Object.create({
selected: null,
content: [
"Yehuda",
"Tom"
]
})
{{view Ember.Select
contentBinding="App.controller.content"
valueBinding="App.controller.selected"
}}
Would result in the following HTML:
<select class="ember-select">
<option value="Yehuda">Yehuda</option>
<option value="Tom">Tom</option>
</select>
Selecting Yehuda from the select box will set `App.controller.selected` to "Yehuda"
### Using Objects
An Ember.Select can also take an array of JS or Ember objects.
When using objects you need to supply optionLabelPath and optionValuePath parameters
which will be used to get the label and value for each of the options.
Usually you will bind to either the selection or the value attribute of the select.
Use selectionBinding if you would like to set the whole object as a property on the target.
Use valueBinding if you would like to set just the value.
Example using selectionBinding:
App.controller = Ember.Object.create({
selectedPerson: null,
selectedPersonId: null,
content: [
Ember.Object.create({firstName: "Yehuda", id: 1}),
Ember.Object.create({firstName: "Tom", id: 2})
]
})
{{view Ember.Select
contentBinding="App.controller.content"
optionLabelPath="content.firstName"
optionValuePath="content.id"
selectionBinding="App.controller.selectedPerson"
prompt="Please Select"}}
<select class="ember-select">
<option value>Please Select</option>
<option value="1">Yehuda</option>
<option value="2">Tom</option>
</select>
Selecting Yehuda here will set `App.controller.selectedPerson` to
the Yehuda object.
Example using valueBinding:
{{view Ember.Select
contentBinding="App.controller.content"
optionLabelPath="content.firstName"
optionValuePath="content.id"
valueBinding="App.controller.selectedPersonId"
prompt="Please Select"}}
Selecting Yehuda in this case will set `App.controller.selectedPersonId` to 1.
@extends Ember.View
*/
@ -19987,8 +20112,8 @@ Ember.$(document).ready(
})();
// Version: v0.9.8.1-437-g68d406e
// Last commit: 68d406e (2012-06-25 14:59:55 -0700)
// Version: v0.9.8.1-451-g50ee26d
// Last commit: 50ee26d (2012-06-26 18:06:44 -0700)
(function() {

View File

@ -1952,8 +1952,8 @@ Handlebars.VM = {
Handlebars.template = Handlebars.VM.template;
;
// Version: v0.9.8.1-437-g68d406e
// Last commit: 68d406e (2012-06-25 14:59:55 -0700)
// Version: v0.9.8.1-451-g50ee26d
// Last commit: 50ee26d (2012-06-26 18:06:44 -0700)
(function() {
@ -2090,8 +2090,8 @@ window.ember_deprecateFunc = Ember.deprecateFunc("ember_deprecateFunc is deprec
})();
// Version: v0.9.8.1-437-g68d406e
// Last commit: 68d406e (2012-06-25 14:59:55 -0700)
// Version: v0.9.8.1-451-g50ee26d
// Last commit: 50ee26d (2012-06-26 18:06:44 -0700)
(function() {
@ -7972,9 +7972,11 @@ function xform(target, method, params) {
libraries by implementing only methods that mostly correspond to the
JavaScript 1.8 API.
@extends Ember.Mixin
@since Ember 0.9
*/
Ember.Enumerable = Ember.Mixin.create( /** @lends Ember.Enumerable */ {
Ember.Enumerable = Ember.Mixin.create(
/** @scope Ember.Enumerable.prototype */ {
/** @private - compatibility */
isEnumerable: true,
@ -8005,9 +8007,9 @@ Ember.Enumerable = Ember.Mixin.create( /** @lends Ember.Enumerable */ {
The default implementation of this method simply looks up the index.
This works great on any Array-like objects.
@param index {Number} the current index of the iteration
@param previousObject {Object} the value returned by the last call to nextObject.
@param context {Object} a context object you can use to maintain state.
@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.
@returns {Object} the next object in the iteration or undefined
*/
nextObject: Ember.required(Function),
@ -8102,7 +8104,7 @@ Ember.Enumerable = Ember.Mixin.create( /** @lends Ember.Enumerable */ {
to give your iterator function access to the current object.
@param {Function} callback The callback to execute
@param {Object} target The target object to use
@param {Object} [target] The target object to use
@returns {Object} receiver
*/
forEach: function(callback, target) {
@ -8124,7 +8126,7 @@ Ember.Enumerable = Ember.Mixin.create( /** @lends Ember.Enumerable */ {
/**
Alias for mapProperty
@params key {String} name of the property
@param {String} key name of the property
@returns {Array} The mapped array.
*/
getEach: function(key) {
@ -8167,7 +8169,7 @@ Ember.Enumerable = Ember.Mixin.create( /** @lends Ember.Enumerable */ {
to give your iterator function access to the current object.
@param {Function} callback The callback to execute
@param {Object} target The target object to use
@param {Object} [target] The target object to use
@returns {Array} The mapped array.
*/
map: function(callback, target) {
@ -8182,7 +8184,7 @@ Ember.Enumerable = Ember.Mixin.create( /** @lends Ember.Enumerable */ {
Similar to map, this specialized function returns the value of the named
property on all items in the enumeration.
@params key {String} name of the property
@param {String} key name of the property
@returns {Array} The mapped array.
*/
mapProperty: function(key) {
@ -8212,7 +8214,7 @@ Ember.Enumerable = Ember.Mixin.create( /** @lends Ember.Enumerable */ {
to give your iterator function access to the current object.
@param {Function} callback The callback to execute
@param {Object} target The target object to use
@param {Object} [target] The target object to use
@returns {Array} A filtered array.
*/
filter: function(callback, target) {
@ -8228,8 +8230,8 @@ Ember.Enumerable = Ember.Mixin.create( /** @lends Ember.Enumerable */ {
can pass an optional second argument with the target value. Otherwise
this will match any property that evaluates to true.
@params key {String} the property to test
@param value {String} optional value to test against.
@param {String} key the property to test
@param {String} [value] optional value to test against.
@returns {Array} filtered array
*/
filterProperty: function(key, value) {
@ -8257,7 +8259,7 @@ Ember.Enumerable = Ember.Mixin.create( /** @lends Ember.Enumerable */ {
to give your iterator function access to the current object.
@param {Function} callback The callback to execute
@param {Object} target The target object to use
@param {Object} [target] The target object to use
@returns {Object} Found item or null.
*/
find: function(callback, target) {
@ -8283,8 +8285,8 @@ Ember.Enumerable = Ember.Mixin.create( /** @lends Ember.Enumerable */ {
This method works much like the more generic find() method.
@params key {String} the property to test
@param value {String} optional value to test against.
@param {String} key the property to test
@param {String} [value] optional value to test against.
@returns {Object} found item or null
*/
findProperty: function(key, value) {
@ -8315,7 +8317,7 @@ Ember.Enumerable = Ember.Mixin.create( /** @lends Ember.Enumerable */ {
if (people.every(isEngineer)) { Paychecks.addBigBonus(); }
@param {Function} callback The callback to execute
@param {Object} target The target object to use
@param {Object} [target] The target object to use
@returns {Boolean}
*/
every: function(callback, target) {
@ -8328,8 +8330,8 @@ Ember.Enumerable = Ember.Mixin.create( /** @lends Ember.Enumerable */ {
Returns true if the passed property resolves to true for all items in the
enumerable. This method is often simpler/faster than using a callback.
@params key {String} the property to test
@param value {String} optional value to test against.
@param {String} key the property to test
@param {String} [value] optional value to test against.
@returns {Array} filtered array
*/
everyProperty: function(key, value) {
@ -8361,7 +8363,7 @@ Ember.Enumerable = Ember.Mixin.create( /** @lends Ember.Enumerable */ {
if (people.some(isManager)) { Paychecks.addBiggerBonus(); }
@param {Function} callback The callback to execute
@param {Object} target The target object to use
@param {Object} [target] The target object to use
@returns {Array} A filtered array.
*/
some: function(callback, target) {
@ -8374,8 +8376,8 @@ Ember.Enumerable = Ember.Mixin.create( /** @lends Ember.Enumerable */ {
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.
@params key {String} the property to test
@param value {String} optional value to test against.
@param {String} key the property to test
@param {String} [value] optional value to test against.
@returns {Boolean} true
*/
someProperty: function(key, value) {
@ -8429,8 +8431,8 @@ Ember.Enumerable = Ember.Mixin.create( /** @lends Ember.Enumerable */ {
implements it. This method corresponds to the implementation in
Prototype 1.6.
@param methodName {String} the name of the method
@param args {Object...} optional arguments to pass as well.
@param {String} methodName the name of the method
@param {Object...} args optional arguments to pass as well.
@returns {Array} return values from calling invoke.
*/
invoke: function(methodName) {
@ -8620,7 +8622,7 @@ Ember.Enumerable = Ember.Mixin.create( /** @lends Ember.Enumerable */ {
An enumerable of the objects to be removed or the number of items to
be removed.
@param {Ember.Enumerable|Numbe} adding
@param {Ember.Enumerable|Number} adding
An enumerable of the objects to be added or the number of items to be
added.
@ -9079,6 +9081,7 @@ Ember.Array = Ember.Mixin.create(Ember.Enumerable, /** @scope Ember.Array.protot
You should implement the compare() method.
@extends Ember.Mixin
@since Ember 0.9
*/
Ember.Comparable = Ember.Mixin.create( /** @scope Ember.Comparable.prototype */{
@ -9136,6 +9139,7 @@ var get = Ember.get, set = Ember.set;
Note that frozenCopy() will only work if you also implement Ember.Freezable.
@extends Ember.Mixin
@since Ember 0.9
*/
Ember.Copyable = Ember.Mixin.create(
@ -9247,6 +9251,7 @@ var get = Ember.get, set = Ember.set;
Ember.Copyable protocol, which defines a frozenCopy() method that will return
a frozen object, if the object implements this method as well.
@extends Ember.Mixin
@since Ember 0.9
*/
Ember.Freezable = Ember.Mixin.create(
@ -10214,7 +10219,13 @@ function xform(target, method, params) {
method.apply(target, args);
}
Ember.Evented = Ember.Mixin.create({
/**
@class
@extends Ember.Mixin
*/
Ember.Evented = Ember.Mixin.create(
/** @scope Ember.Evented.prototype */ {
on: function(name, target, method) {
if (!method) {
method = target;
@ -10437,7 +10448,7 @@ if (Ember.config.overridePrototypeMixin) {
CoreObject.__super__ = null;
var ClassMixin = Ember.Mixin.create(
/** @scope Ember.CoreObject */ {
/** @scope Ember.ClassMixin.prototype */ {
ClassMixin: Ember.required(),
@ -11923,7 +11934,14 @@ Ember.Controller = Ember.Object.extend(Ember.ControllerMixin);
(function() {
var get = Ember.get, set = Ember.set, forEach = Ember.EnumerableUtils.forEach;
Ember.SortableMixin = Ember.Mixin.create(Ember.MutableEnumerable, {
/**
@class
@extends Ember.Mixin
@extends Ember.MutableEnumerable
*/
Ember.SortableMixin = Ember.Mixin.create(Ember.MutableEnumerable,
/** @scope Ember.Observable.prototype */ {
sortProperties: null,
sortAscending: true,
@ -12405,7 +12423,7 @@ Ember.Application.registerInjection({
injection: function(app, router, property) {
if (!/^[A-Z].*Controller$/.test(property)) { return; }
var name = property[0].toLowerCase() + property.substr(1),
var name = property.charAt(0).toLowerCase() + property.substr(1),
controller = app[property].create();
router.set(name, controller);
@ -13902,6 +13920,7 @@ var invokeForState = {
Handlebars helper. See `Handlebars.helpers.view` for additional information.
@extends Ember.Object
@extends Ember.Evented
*/
Ember.View = Ember.Object.extend(Ember.Evented,
/** @scope Ember.View.prototype */ {
@ -16603,6 +16622,8 @@ var get = Ember.get, set = Ember.set, getPath = Ember.getPath;
/**
@class
@extends Ember.Object
*/
Ember.State = Ember.Object.extend(Ember.Evented,
/** @scope Ember.State.prototype */{
@ -16611,7 +16632,7 @@ Ember.State = Ember.Object.extend(Ember.Evented,
/**
A reference to the parent state.
@type {Ember.State}
@type Ember.State
*/
parentState: null,
start: null,
@ -17585,7 +17606,7 @@ Ember.Routable = Ember.Mixin.create({
In general, this will update the browser's URL.
*/
updateRoute: function(manager, location) {
if (get(this, 'isLeaf')) {
if (get(this, 'isLeafRoute')) {
var path = this.absoluteRoute(manager);
location.setURL(path);
}
@ -17637,6 +17658,16 @@ Ember.Routable = Ember.Mixin.create({
return typeof get(this, 'route') === 'string';
}).cacheable(),
/**
@private
Determine if this is the last routeable state
*/
isLeafRoute: Ember.computed(function() {
if (get(this, 'isLeaf')) { return true; }
return !get(this, 'childStates').findProperty('isRoutable');
}).cacheable(),
/**
@private
@ -17779,10 +17810,12 @@ Ember.Routable = Ember.Mixin.create({
on the state whose path is `/posts` with the path `/2/comments`.
*/
routePath: function(manager, path) {
if (get(this, 'isLeaf')) { return; }
if (get(this, 'isLeafRoute')) { return; }
var childStates = get(this, 'childStates'), match;
childStates = Ember.A(childStates.filterProperty('isRoutable'));
childStates = childStates.sort(function(a, b) {
var aDynamicSegments = getPath(a, 'routeMatcher.identifiers.length'),
bDynamicSegments = getPath(b, 'routeMatcher.identifiers.length'),
@ -18096,12 +18129,12 @@ var get = Ember.get, getPath = Ember.getPath, set = Ember.set;
}
Within `deserialize` you should use this information to retrieve or create an appropriate context
object for the given url (e.g. by loading from a remote API or accessing the browser's
`localStorage`). This object must be the `return` value for `deserialize` and will be
object for the given URL (e.g. by loading from a remote API or accessing the browser's
`localStorage`). This object must be the `return` value of `deserialize` and will be
passed to the Route's `connectOutlets` and `serialize` methods.
When an application's state is changed from within the application itself, the context provided for
the transiton will be passed and `deserialize` is not called (see 'Transitions Between States').
the transition will be passed and `deserialize` is not called (see 'Transitions Between States').
### Serializing An Object For URLs with Dynamic Segments
When transitioning into a Route whose `route` property contains dynamic segments the Route's
@ -18160,7 +18193,7 @@ var get = Ember.get, getPath = Ember.getPath, set = Ember.set;
App.get('router').send('moveElsewhere');
Will transition the application's state to 'root.bRoute' and trigger an update of the URL to
'#/someOtherLocation
'#/someOtherLocation'.
For URL patterns with dynamic segments a context can be supplied as the second argument to `send`.
The router will match dynamic segments names to keys on this object and fill in the URL with the
@ -18198,7 +18231,7 @@ var get = Ember.get, getPath = Ember.getPath, set = Ember.set;
During application initialization Ember will detect properties of the application ending in 'Controller',
create singleton instances of each class, and assign them as a properties on the router. The property name
will be the UpperCamel name converted to lowerCamel format. These controller classes should be subclasses
of Ember.ObjectController, Ember.ArrayController, or a custom Ember.Object that includes the
of Ember.ObjectController, Ember.ArrayController, Ember.Controller, or a custom Ember.Object that includes the
Ember.ControllerMixin mixin.
App = Ember.Application.create({
@ -18331,13 +18364,19 @@ Ember.Router = Ember.StateManager.extend(
route: function(path) {
set(this, 'isRouting', true);
var routableState;
try {
path = path.replace(/^(?=[^\/])/, "/");
this.send('navigateAway');
this.send('unroutePath', path);
var currentURL = get(this, 'currentState').absoluteRoute(this);
routableState = get(this, 'currentState');
while (routableState && !routableState.get('isRoutable')) {
routableState = get(routableState, 'parentState');
}
var currentURL = routableState ? routableState.absoluteRoute(this) : '';
var rest = path.substr(currentURL.length);
this.send('routePath', rest);
@ -18345,13 +18384,21 @@ Ember.Router = Ember.StateManager.extend(
set(this, 'isRouting', false);
}
get(this, 'currentState').updateRoute(this, get(this, 'location'));
routableState = get(this, 'currentState');
while (routableState && !routableState.get('isRoutable')) {
routableState = get(routableState, 'parentState');
}
if (routableState) {
routableState.updateRoute(this, get(this, 'location'));
}
},
urlFor: function(path, hash) {
var currentState = get(this, 'currentState') || this,
state = this.findStateByPath(currentState, path);
Ember.assert(Ember.String.fmt("Could not find route with path '%@'", [path]), !!state);
Ember.assert("To get a URL for a state, it must have a `route` property.", !!get(state, 'routeMatcher'));
var location = get(this, 'location'),
@ -21570,7 +21617,85 @@ var indexOf = Ember.EnumerableUtils.indexOf, indexesOf = Ember.EnumerableUtils.i
The Ember.Select view class renders a
[select](https://developer.mozilla.org/en/HTML/Element/select) HTML element,
allowing the user to choose from a list of options. The selected option(s)
are updated live in the `selection` property.
are updated live in the `selection` property, while the corresponding value
is updated in the `value` property.
### Using Strings
The simplest version of an Ember.Select takes an array of strings for the options
of a select box and a valueBinding to set the value.
Example:
App.controller = Ember.Object.create({
selected: null,
content: [
"Yehuda",
"Tom"
]
})
{{view Ember.Select
contentBinding="App.controller.content"
valueBinding="App.controller.selected"
}}
Would result in the following HTML:
<select class="ember-select">
<option value="Yehuda">Yehuda</option>
<option value="Tom">Tom</option>
</select>
Selecting Yehuda from the select box will set `App.controller.selected` to "Yehuda"
### Using Objects
An Ember.Select can also take an array of JS or Ember objects.
When using objects you need to supply optionLabelPath and optionValuePath parameters
which will be used to get the label and value for each of the options.
Usually you will bind to either the selection or the value attribute of the select.
Use selectionBinding if you would like to set the whole object as a property on the target.
Use valueBinding if you would like to set just the value.
Example using selectionBinding:
App.controller = Ember.Object.create({
selectedPerson: null,
selectedPersonId: null,
content: [
Ember.Object.create({firstName: "Yehuda", id: 1}),
Ember.Object.create({firstName: "Tom", id: 2})
]
})
{{view Ember.Select
contentBinding="App.controller.content"
optionLabelPath="content.firstName"
optionValuePath="content.id"
selectionBinding="App.controller.selectedPerson"
prompt="Please Select"}}
<select class="ember-select">
<option value>Please Select</option>
<option value="1">Yehuda</option>
<option value="2">Tom</option>
</select>
Selecting Yehuda here will set `App.controller.selectedPerson` to
the Yehuda object.
Example using valueBinding:
{{view Ember.Select
contentBinding="App.controller.content"
optionLabelPath="content.firstName"
optionValuePath="content.id"
valueBinding="App.controller.selectedPersonId"
prompt="Please Select"}}
Selecting Yehuda in this case will set `App.controller.selectedPersonId` to 1.
@extends Ember.View
*/
@ -21941,8 +22066,8 @@ Ember.$(document).ready(
})();
// Version: v0.9.8.1-437-g68d406e
// Last commit: 68d406e (2012-06-25 14:59:55 -0700)
// Version: v0.9.8.1-451-g50ee26d
// Last commit: 50ee26d (2012-06-26 18:06:44 -0700)
(function() {