ember-source 1.0.0.pre4.2 → 1.0.0.rc1.0.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of ember-source might be problematic. Click here for more details.

@@ -1,5 +1,5 @@
1
- // Version: v1.0.0-pre.4-228-gcabc05e
2
- // Last commit: cabc05e (2013-02-21 10:31:18 -0500)
1
+ // Version: v1.0.0-pre.4-293-ge707ffa
2
+ // Last commit: e707ffa (2013-02-23 17:35:13 -0500)
3
3
 
4
4
 
5
5
  (function() {
@@ -150,8 +150,8 @@ Ember.deprecateFunc = function(message, func) {
150
150
 
151
151
  })();
152
152
 
153
- // Version: v1.0.0-pre.4-228-gcabc05e
154
- // Last commit: cabc05e (2013-02-21 10:31:18 -0500)
153
+ // Version: v1.0.0-pre.4-293-ge707ffa
154
+ // Last commit: e707ffa (2013-02-23 17:35:13 -0500)
155
155
 
156
156
 
157
157
  (function() {
@@ -211,7 +211,7 @@ var define, requireModule;
211
211
 
212
212
  @class Ember
213
213
  @static
214
- @version 1.0.0-pre.4
214
+ @version 1.0.0-rc.1
215
215
  */
216
216
 
217
217
  if ('undefined' === typeof Ember) {
@@ -238,10 +238,10 @@ Ember.toString = function() { return "Ember"; };
238
238
  /**
239
239
  @property VERSION
240
240
  @type String
241
- @default '1.0.0-pre.4'
241
+ @default '1.0.0-rc.1'
242
242
  @final
243
243
  */
244
- Ember.VERSION = '1.0.0-pre.4';
244
+ Ember.VERSION = '1.0.0-rc.1';
245
245
 
246
246
  /**
247
247
  Standard environmental variables. You can define these in a global `ENV`
@@ -651,7 +651,7 @@ Ember.generateGuid = function generateGuid(obj, prefix) {
651
651
 
652
652
  @method guidFor
653
653
  @for Ember
654
- @param obj {Object} any object, string, number, Element, or primitive
654
+ @param {Object} obj any object, string, number, Element, or primitive
655
655
  @return {String} the unique guid for this instance.
656
656
  */
657
657
  Ember.guidFor = function guidFor(obj) {
@@ -1001,8 +1001,8 @@ var needsFinallyFix = (function() {
1001
1001
 
1002
1002
  @method tryFinally
1003
1003
  @for Ember
1004
- @param {Function} function The function to run the try callback
1005
- @param {Function} function The function to run the finally callback
1004
+ @param {Function} tryable The function to run the try callback
1005
+ @param {Function} finalizer The function to run the finally callback
1006
1006
  @param [binding]
1007
1007
  @return {anything} The return value is the that of the finalizer,
1008
1008
  unless that valueis undefined, in which case it is the return value
@@ -1051,9 +1051,9 @@ if (needsFinallyFix) {
1051
1051
 
1052
1052
  @method tryCatchFinally
1053
1053
  @for Ember
1054
- @param {Function} function The function to run the try callback
1055
- @param {Function} function The function to run the catchable callback
1056
- @param {Function} function The function to run the finally callback
1054
+ @param {Function} tryable The function to run the try callback
1055
+ @param {Function} catchable The function to run the catchable callback
1056
+ @param {Function} finalizer The function to run the finally callback
1057
1057
  @param [binding]
1058
1058
  @return {anything} The return value is the that of the finalizer,
1059
1059
  unless that value is undefined, in which case it is the return value
@@ -1565,8 +1565,8 @@ OrderedSet.prototype = {
1565
1565
 
1566
1566
  /**
1567
1567
  @method forEach
1568
- @param {Function} function
1569
- @param target
1568
+ @param {Function} fn
1569
+ @param self
1570
1570
  */
1571
1571
  forEach: function(fn, self) {
1572
1572
  // allow mutation during iteration
@@ -2087,7 +2087,7 @@ Ember.setPath = Ember.deprecateFunc('setPath is deprecated since set now support
2087
2087
  @method trySet
2088
2088
  @for Ember
2089
2089
  @param {Object} obj The object to modify.
2090
- @param {String} keyName The property key to set
2090
+ @param {String} path The property path to set
2091
2091
  @param {Object} value The value to set
2092
2092
  */
2093
2093
  Ember.trySet = function(root, path, value) {
@@ -3757,6 +3757,7 @@ function actionsDiff(obj, eventName, otherActions) {
3757
3757
  @param {String} eventName
3758
3758
  @param {Object|Function} targetOrMethod A target object or a function
3759
3759
  @param {Function|String} method A function or the name of a function to be called on `target`
3760
+ @param {Boolean} once A flag whether a function should only be called once
3760
3761
  */
3761
3762
  function addListener(obj, eventName, target, method, once) {
3762
3763
  Ember.assert("You must pass at least an object and event name to Ember.addListener", !!obj && !!eventName);
@@ -3942,6 +3943,7 @@ function watchedEvents(obj) {
3942
3943
  @param obj
3943
3944
  @param {String} eventName
3944
3945
  @param {Array} params
3946
+ @param {Array} actions
3945
3947
  @return true
3946
3948
  */
3947
3949
  function sendEvent(obj, eventName, params, actions) {
@@ -4729,7 +4731,7 @@ Binding.prototype = {
4729
4731
  `get()` - see that method for more information.
4730
4732
 
4731
4733
  @method from
4732
- @param {String} propertyPath the property path to connect to
4734
+ @param {String} path the property path to connect to
4733
4735
  @return {Ember.Binding} `this`
4734
4736
  */
4735
4737
  from: function(path) {
@@ -4747,7 +4749,7 @@ Binding.prototype = {
4747
4749
  `get()` - see that method for more information.
4748
4750
 
4749
4751
  @method to
4750
- @param {String|Tuple} propertyPath A property path or tuple
4752
+ @param {String|Tuple} path A property path or tuple
4751
4753
  @return {Ember.Binding} `this`
4752
4754
  */
4753
4755
  to: function(path) {
@@ -6047,12 +6049,6 @@ define("container",
6047
6049
  [],
6048
6050
  function() {
6049
6051
 
6050
- var objectCreate = Object.create || function(parent) {
6051
- function F() {}
6052
- F.prototype = parent;
6053
- return new F();
6054
- };
6055
-
6056
6052
  function InheritingDict(parent) {
6057
6053
  this.parent = parent;
6058
6054
  this.dict = {};
@@ -6127,7 +6123,6 @@ define("container",
6127
6123
  register: function(type, name, factory, options) {
6128
6124
  var fullName;
6129
6125
 
6130
-
6131
6126
  if (type.indexOf(':') !== -1){
6132
6127
  options = factory;
6133
6128
  factory = name;
@@ -6137,16 +6132,26 @@ define("container",
6137
6132
  fullName = type + ":" + name;
6138
6133
  }
6139
6134
 
6140
- this.registry.set(fullName, factory);
6141
- this._options.set(fullName, options || {});
6135
+ var normalizedName = this.normalize(fullName);
6136
+
6137
+ this.registry.set(normalizedName, factory);
6138
+ this._options.set(normalizedName, options || {});
6142
6139
  },
6143
6140
 
6144
6141
  resolve: function(fullName) {
6145
6142
  return this.resolver(fullName) || this.registry.get(fullName);
6146
6143
  },
6147
6144
 
6148
- lookup: function(fullName) {
6149
- if (this.cache.has(fullName)) {
6145
+ normalize: function(fullName) {
6146
+ return fullName;
6147
+ },
6148
+
6149
+ lookup: function(fullName, options) {
6150
+ fullName = this.normalize(fullName);
6151
+
6152
+ options = options || {};
6153
+
6154
+ if (this.cache.has(fullName) && options.singleton !== false) {
6150
6155
  return this.cache.get(fullName);
6151
6156
  }
6152
6157
 
@@ -6154,7 +6159,7 @@ define("container",
6154
6159
 
6155
6160
  if (!value) { return; }
6156
6161
 
6157
- if (isSingleton(this, fullName)) {
6162
+ if (isSingleton(this, fullName) && options.singleton !== false) {
6158
6163
  this.cache.set(fullName, value);
6159
6164
  }
6160
6165
 
@@ -6272,7 +6277,8 @@ define("container",
6272
6277
  }
6273
6278
 
6274
6279
  function factoryFor(container, fullName) {
6275
- return container.resolve(fullName);
6280
+ var name = container.normalize(fullName);
6281
+ return container.resolve(name);
6276
6282
  }
6277
6283
 
6278
6284
  function instantiate(container, fullName) {
@@ -6358,8 +6364,8 @@ var toString = Object.prototype.toString;
6358
6364
  | 'undefined' | Undefined value |
6359
6365
  | 'function' | A function |
6360
6366
  | 'array' | An instance of Array |
6361
- | 'class' | A Ember class (created using Ember.Object.extend()) |
6362
- | 'instance' | A Ember object instance |
6367
+ | 'class' | An Ember class (created using Ember.Object.extend()) |
6368
+ | 'instance' | An Ember object instance |
6363
6369
  | 'error' | An instance of the Error object |
6364
6370
  | 'object' | A JavaScript object not inheriting from Ember.Object |
6365
6371
 
@@ -6384,7 +6390,7 @@ var toString = Object.prototype.toString;
6384
6390
 
6385
6391
  @method typeOf
6386
6392
  @for Ember
6387
- @param item {Object} the item to check
6393
+ @param {Object} item the item to check
6388
6394
  @return {String} the type
6389
6395
  */
6390
6396
  Ember.typeOf = function(item) {
@@ -6618,7 +6624,7 @@ function _copy(obj, deep, seen, copies) {
6618
6624
 
6619
6625
  @method copy
6620
6626
  @for Ember
6621
- @param {Object} object The object to clone
6627
+ @param {Object} obj The object to clone
6622
6628
  @param {Boolean} deep If true, a deep copy of the object is made
6623
6629
  @return {Object} The cloned object
6624
6630
  */
@@ -6915,6 +6921,7 @@ Ember.String = {
6915
6921
  'action_name'.camelize(); // 'actionName'
6916
6922
  'css-class-name'.camelize(); // 'cssClassName'
6917
6923
  'my favorite items'.camelize(); // 'myFavoriteItems'
6924
+ 'My Favorite Items'.camelize(); // 'myFavoriteItems'
6918
6925
  ```
6919
6926
 
6920
6927
  @method camelize
@@ -6924,6 +6931,8 @@ Ember.String = {
6924
6931
  camelize: function(str) {
6925
6932
  return str.replace(STRING_CAMELIZE_REGEXP, function(match, separator, chr) {
6926
6933
  return chr ? chr.toUpperCase() : '';
6934
+ }).replace(/^([A-Z])/, function(match, separator, chr) {
6935
+ return match.toLowerCase();
6927
6936
  });
6928
6937
  },
6929
6938
 
@@ -6935,7 +6944,7 @@ Ember.String = {
6935
6944
  'action_name'.classify(); // 'ActionName'
6936
6945
  'css-class-name'.classify(); // 'CssClassName'
6937
6946
  'my favorite items'.classify(); // 'MyFavoriteItems'
6938
- ```
6947
+ ```
6939
6948
 
6940
6949
  @method classify
6941
6950
  @param {String} str the string to classify
@@ -7983,8 +7992,8 @@ Ember.Enumerable = Ember.Mixin.create(
7983
7992
  mixin.
7984
7993
 
7985
7994
  @method addEnumerableObserver
7986
- @param target {Object}
7987
- @param opts {Hash}
7995
+ @param {Object} target
7996
+ @param {Hash} opts
7988
7997
  */
7989
7998
  addEnumerableObserver: function(target, opts) {
7990
7999
  var willChange = (opts && opts.willChange) || 'enumerableWillChange',
@@ -8002,8 +8011,8 @@ Ember.Enumerable = Ember.Mixin.create(
8002
8011
  Removes a registered enumerable observer.
8003
8012
 
8004
8013
  @method removeEnumerableObserver
8005
- @param target {Object}
8006
- @param [opts] {Hash}
8014
+ @param {Object} target
8015
+ @param {Hash} [opts]
8007
8016
  */
8008
8017
  removeEnumerableObserver: function(target, opts) {
8009
8018
  var willChange = (opts && opts.willChange) || 'enumerableWillChange',
@@ -8368,7 +8377,7 @@ Ember.Array = Ember.Mixin.create(Ember.Enumerable, /** @scope Ember.Array.protot
8368
8377
  @method addArrayObserver
8369
8378
  @param {Object} target The observer object.
8370
8379
  @param {Hash} opts Optional hash of configuration options including
8371
- `willChange`, `didChange`, and a `context` option.
8380
+ `willChange` and `didChange` option.
8372
8381
  @return {Ember.Array} receiver
8373
8382
  */
8374
8383
  addArrayObserver: function(target, opts) {
@@ -8390,6 +8399,8 @@ Ember.Array = Ember.Mixin.create(Ember.Enumerable, /** @scope Ember.Array.protot
8390
8399
 
8391
8400
  @method removeArrayObserver
8392
8401
  @param {Object} target The object observing the array.
8402
+ @param {Hash} opts Optional hash of configuration options including
8403
+ `willChange` and `didChange` option.
8393
8404
  @return {Ember.Array} receiver
8394
8405
  */
8395
8406
  removeArrayObserver: function(target, opts) {
@@ -8606,7 +8617,7 @@ Ember.Copyable = Ember.Mixin.create(
8606
8617
  an exception.
8607
8618
 
8608
8619
  @method copy
8609
- @param deep {Boolean} if `true`, a deep copy of the object should be made
8620
+ @param {Boolean} deep if `true`, a deep copy of the object should be made
8610
8621
  @return {Object} copy of receiver
8611
8622
  */
8612
8623
  copy: Ember.required(Function),
@@ -9272,7 +9283,7 @@ Ember.Observable = Ember.Mixin.create(/** @scope Ember.Observable.prototype */ {
9272
9283
  not defined upfront.
9273
9284
 
9274
9285
  @method get
9275
- @param {String} key The property to retrieve
9286
+ @param {String} keyName The property to retrieve
9276
9287
  @return {Object} The property value or undefined.
9277
9288
  */
9278
9289
  get: function(keyName) {
@@ -9353,7 +9364,7 @@ Ember.Observable = Ember.Mixin.create(/** @scope Ember.Observable.prototype */ {
9353
9364
  ```
9354
9365
 
9355
9366
  @method set
9356
- @param {String} key The property to set
9367
+ @param {String} keyName The property to set
9357
9368
  @param {Object} value The value to set or `null`.
9358
9369
  @return {Ember.Observable}
9359
9370
  */
@@ -9430,7 +9441,7 @@ Ember.Observable = Ember.Mixin.create(/** @scope Ember.Observable.prototype */ {
9430
9441
  like.
9431
9442
 
9432
9443
  @method propertyWillChange
9433
- @param {String} key The property key that is about to change.
9444
+ @param {String} keyName The property key that is about to change.
9434
9445
  @return {Ember.Observable}
9435
9446
  */
9436
9447
  propertyWillChange: function(keyName){
@@ -10971,16 +10982,28 @@ var Namespace = Ember.Namespace = Ember.Object.extend({
10971
10982
 
10972
10983
  Namespace.reopenClass({
10973
10984
  NAMESPACES: [Ember],
10985
+ NAMESPACES_BY_ID: {},
10974
10986
  PROCESSED: false,
10975
- processAll: processAllNamespaces
10987
+ processAll: processAllNamespaces,
10988
+ byName: function(name) {
10989
+ if (!Ember.BOOTED) {
10990
+ processAllNamespaces();
10991
+ }
10992
+
10993
+ return NAMESPACES_BY_ID[name];
10994
+ }
10976
10995
  });
10977
10996
 
10997
+ var NAMESPACES_BY_ID = Namespace.NAMESPACES_BY_ID;
10998
+
10978
10999
  var hasOwnProp = ({}).hasOwnProperty,
10979
11000
  guidFor = Ember.guidFor;
10980
11001
 
10981
11002
  function processNamespace(paths, root, seen) {
10982
11003
  var idx = paths.length;
10983
11004
 
11005
+ NAMESPACES_BY_ID[paths.join('.')] = root;
11006
+
10984
11007
  // Loop over all of the keys in the namespace, looking for classes
10985
11008
  for(var key in root) {
10986
11009
  if (!hasOwnProp.call(root, key)) { continue; }
@@ -11080,12 +11103,15 @@ function classToString() {
11080
11103
  }
11081
11104
 
11082
11105
  function processAllNamespaces() {
11083
- if (!Namespace.PROCESSED) {
11106
+ var unprocessedNamespaces = !Namespace.PROCESSED,
11107
+ unprocessedMixins = Ember.anyUnprocessedMixins;
11108
+
11109
+ if (unprocessedNamespaces) {
11084
11110
  findNamespaces();
11085
11111
  Namespace.PROCESSED = true;
11086
11112
  }
11087
11113
 
11088
- if (Ember.anyUnprocessedMixins) {
11114
+ if (unprocessedNamespaces || unprocessedMixins) {
11089
11115
  var namespaces = Namespace.NAMESPACES, namespace;
11090
11116
  for (var i=0, l=namespaces.length; i<l; i++) {
11091
11117
  namespace = namespaces[i];
@@ -11107,40 +11133,8 @@ Ember.Mixin.prototype.toString = classToString;
11107
11133
 
11108
11134
 
11109
11135
  (function() {
11110
- /**
11111
- @module ember
11112
- @submodule ember-runtime
11113
- */
11114
-
11115
- /**
11116
- Defines a namespace that will contain an executable application. This is
11117
- very similar to a normal namespace except that it is expected to include at
11118
- least a 'ready' function which can be run to initialize the application.
11119
-
11120
- Currently `Ember.Application` is very similar to `Ember.Namespace.` However,
11121
- this class may be augmented by additional frameworks so it is important to
11122
- use this instance when building new applications.
11123
-
11124
- # Example Usage
11125
-
11126
- ```javascript
11127
- MyApp = Ember.Application.create({
11128
- VERSION: '1.0.0',
11129
- store: Ember.Store.create().from(Ember.fixtures)
11130
- });
11131
-
11132
- MyApp.ready = function() {
11133
- //..init code goes here...
11134
- }
11135
- ```
11136
-
11137
- @class Application
11138
- @namespace Ember
11139
- @extends Ember.Namespace
11140
- */
11141
11136
  Ember.Application = Ember.Namespace.extend();
11142
11137
 
11143
-
11144
11138
  })();
11145
11139
 
11146
11140
 
@@ -12422,7 +12416,8 @@ Ember.ArrayController = Ember.ArrayProxy.extend(Ember.ControllerMixin,
12422
12416
 
12423
12417
  objectAtContent: function(idx) {
12424
12418
  var length = get(this, 'length'),
12425
- object = get(this,'arrangedContent').objectAt(idx);
12419
+ arrangedContent = get(this,'arrangedContent'),
12420
+ object = arrangedContent && arrangedContent.objectAt(idx);
12426
12421
 
12427
12422
  if (idx >= 0 && idx < length) {
12428
12423
  var controllerClass = this.lookupItemController(object);
@@ -12442,20 +12437,20 @@ Ember.ArrayController = Ember.ArrayProxy.extend(Ember.ControllerMixin,
12442
12437
 
12443
12438
  arrangedContentDidChange: function() {
12444
12439
  this._super();
12445
- this._resetSubContainers();
12440
+ this._resetSubControllers();
12446
12441
  },
12447
12442
 
12448
12443
  arrayContentDidChange: function(idx, removedCnt, addedCnt) {
12449
- var subContainers = get(this, 'subContainers'),
12450
- subContainersToRemove = subContainers.slice(idx, idx+removedCnt);
12444
+ var subControllers = get(this, '_subControllers'),
12445
+ subControllersToRemove = subControllers.slice(idx, idx+removedCnt);
12451
12446
 
12452
- forEach(subContainersToRemove, function(subContainer) {
12453
- if (subContainer) { subContainer.destroy(); }
12447
+ forEach(subControllersToRemove, function(subController) {
12448
+ if (subController) { subController.destroy(); }
12454
12449
  });
12455
12450
 
12456
- replace(subContainers, idx, removedCnt, new Array(addedCnt));
12451
+ replace(subControllers, idx, removedCnt, new Array(addedCnt));
12457
12452
 
12458
- // The shadow array of subcontainers must be updated before we trigger
12453
+ // The shadow array of subcontrollers must be updated before we trigger
12459
12454
  // observers, otherwise observers will get the wrong subcontainer when
12460
12455
  // calling `objectAt`
12461
12456
  this._super(idx, removedCnt, addedCnt);
@@ -12463,43 +12458,40 @@ Ember.ArrayController = Ember.ArrayProxy.extend(Ember.ControllerMixin,
12463
12458
 
12464
12459
  init: function() {
12465
12460
  this._super();
12466
- if (!this.get('content')) { this.set('content', Ember.A()); }
12467
- this._resetSubContainers();
12461
+ if (!this.get('content')) { Ember.defineProperty(this, 'content', undefined, Ember.A()); }
12462
+ this.set('_subControllers', Ember.A());
12468
12463
  },
12469
12464
 
12470
12465
  controllerAt: function(idx, object, controllerClass) {
12471
12466
  var container = get(this, 'container'),
12472
- subContainers = get(this, 'subContainers'),
12473
- subContainer = subContainers[idx],
12474
- controller;
12467
+ subControllers = get(this, '_subControllers'),
12468
+ subController = subControllers[idx];
12475
12469
 
12476
- if (!subContainer) {
12477
- subContainer = subContainers[idx] = container.child();
12470
+ if (!subController) {
12471
+ subController = container.lookup("controller:" + controllerClass, { singleton: false });
12472
+ subControllers[idx] = subController;
12478
12473
  }
12479
12474
 
12480
- controller = subContainer.lookup("controller:" + controllerClass);
12481
- if (!controller) {
12475
+ if (!subController) {
12482
12476
  throw new Error('Could not resolve itemController: "' + controllerClass + '"');
12483
12477
  }
12484
12478
 
12485
- controller.set('target', this);
12486
- controller.set('content', object);
12479
+ subController.set('target', this);
12480
+ subController.set('content', object);
12487
12481
 
12488
- return controller;
12482
+ return subController;
12489
12483
  },
12490
12484
 
12491
- subContainers: null,
12485
+ _subControllers: null,
12492
12486
 
12493
- _resetSubContainers: function() {
12494
- var subContainers = get(this, 'subContainers');
12487
+ _resetSubControllers: function() {
12488
+ var subControllers = get(this, '_subControllers');
12495
12489
 
12496
- if (subContainers) {
12497
- forEach(subContainers, function(subContainer) {
12498
- if (subContainer) { subContainer.destroy(); }
12499
- });
12500
- }
12490
+ forEach(subControllers, function(subController) {
12491
+ if (subController) { subController.destroy(); }
12492
+ });
12501
12493
 
12502
- this.set('subContainers', Ember.A());
12494
+ this.set('_subControllers', Ember.A());
12503
12495
  }
12504
12496
  });
12505
12497