sproutcore 1.11.0.rc3 → 1.11.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (98) hide show
  1. checksums.yaml +6 -14
  2. data/CHANGELOG +5 -0
  3. data/VERSION.yml +1 -1
  4. data/lib/frameworks/sproutcore/Buildfile +3 -2
  5. data/lib/frameworks/sproutcore/CHANGELOG.md +59 -10
  6. data/lib/frameworks/sproutcore/apps/showcase/resources/main_page.js +1 -0
  7. data/lib/frameworks/sproutcore/apps/showcase/resources/stylesheet.css +9 -4
  8. data/lib/frameworks/sproutcore/frameworks/core_foundation/panes/manipulation.js +1 -1
  9. data/lib/frameworks/sproutcore/frameworks/core_foundation/system/event.js +0 -10
  10. data/lib/frameworks/sproutcore/frameworks/core_foundation/system/locale.js +1 -1
  11. data/lib/frameworks/sproutcore/frameworks/core_foundation/system/root_responder.js +10 -45
  12. data/lib/frameworks/sproutcore/frameworks/core_foundation/system/selection_set.js +3 -3
  13. data/lib/frameworks/sproutcore/frameworks/core_foundation/system/touch.js +76 -0
  14. data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/system/{touch.js → touch_test.js} +64 -0
  15. data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/pane/append_remove.js +1 -1
  16. data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/pane/design_mode_test.js +61 -24
  17. data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/createChildViews.js +1 -2
  18. data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/destroy.js +0 -3
  19. data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/{layoutStyle.js → layout_style_test.js} +4 -4
  20. data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/layout_test.js +602 -0
  21. data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/viewDidResize.js +0 -23
  22. data/lib/frameworks/sproutcore/frameworks/core_foundation/views/view.js +18 -17
  23. data/lib/frameworks/sproutcore/frameworks/core_foundation/views/view/animation.js +5 -5
  24. data/lib/frameworks/sproutcore/frameworks/core_foundation/views/view/design_mode.js +64 -24
  25. data/lib/frameworks/sproutcore/frameworks/core_foundation/views/view/layout.js +904 -871
  26. data/lib/frameworks/sproutcore/frameworks/core_foundation/views/view/layout_style.js +1 -3
  27. data/lib/frameworks/sproutcore/frameworks/core_foundation/views/view/statechart.js +40 -24
  28. data/lib/frameworks/sproutcore/frameworks/datastore/data_sources/fixtures.js +2 -2
  29. data/lib/frameworks/sproutcore/frameworks/datastore/models/record.js +5 -5
  30. data/lib/frameworks/sproutcore/frameworks/datastore/system/nested_store.js +14 -14
  31. data/lib/frameworks/sproutcore/frameworks/datastore/system/query.js +1 -1
  32. data/lib/frameworks/sproutcore/frameworks/datastore/system/record_array.js +2 -2
  33. data/lib/frameworks/sproutcore/frameworks/datastore/system/store.js +36 -33
  34. data/lib/frameworks/sproutcore/frameworks/datastore/tests/models/record/writeAttribute.js +1 -1
  35. data/lib/frameworks/sproutcore/frameworks/datastore/tests/system/nested_store/autonomous_dataSourceCallbacks.js +6 -6
  36. data/lib/frameworks/sproutcore/frameworks/datastore/tests/system/store/commitChangesFromNestedStore.js +1 -1
  37. data/lib/frameworks/sproutcore/frameworks/datastore/tests/system/store/commitRecord.js +1 -1
  38. data/lib/frameworks/sproutcore/frameworks/datastore/tests/system/store/dataSourceCallbacks.js +7 -7
  39. data/lib/frameworks/sproutcore/frameworks/datastore/tests/system/store/destroyRecord.js +2 -2
  40. data/lib/frameworks/sproutcore/frameworks/datastore/tests/system/store/recordDidChange.js +2 -2
  41. data/lib/frameworks/sproutcore/frameworks/datastore/tests/system/store/retrieveRecord.js +4 -4
  42. data/lib/frameworks/sproutcore/frameworks/datetime/frameworks/core/system/datetime.js +11 -11
  43. data/lib/frameworks/sproutcore/frameworks/designer/coders/object.js +1 -1
  44. data/lib/frameworks/sproutcore/frameworks/desktop/panes/menu.js +30 -1
  45. data/lib/frameworks/sproutcore/frameworks/desktop/panes/picker.js +12 -1
  46. data/lib/frameworks/sproutcore/frameworks/desktop/views/menu_scroll.js +5 -3
  47. data/lib/frameworks/sproutcore/frameworks/desktop/views/menu_scroller_view.js +0 -36
  48. data/lib/frameworks/sproutcore/frameworks/desktop/views/scroll_view.js +3 -3
  49. data/lib/frameworks/sproutcore/frameworks/desktop/views/segmented.js +1 -1
  50. data/lib/frameworks/sproutcore/frameworks/desktop/views/static_content.js +1 -1
  51. data/lib/frameworks/sproutcore/frameworks/foundation/gestures/pinch_gesture.js +286 -0
  52. data/lib/frameworks/sproutcore/frameworks/foundation/gestures/swipe_gesture.js +449 -0
  53. data/lib/frameworks/sproutcore/frameworks/foundation/gestures/tap_gesture.js +259 -0
  54. data/lib/frameworks/sproutcore/frameworks/foundation/mixins/gesturable.js +218 -30
  55. data/lib/frameworks/sproutcore/frameworks/foundation/system/gesture.js +259 -158
  56. data/lib/frameworks/sproutcore/frameworks/foundation/system/string.js +58 -50
  57. data/lib/frameworks/sproutcore/frameworks/foundation/system/utils/string_measurement.js +1 -1
  58. data/lib/frameworks/sproutcore/frameworks/foundation/tests/gestures/pinch_gesture_test.js +321 -0
  59. data/lib/frameworks/sproutcore/frameworks/foundation/tests/gestures/swipe_gesture_test.js +154 -0
  60. data/lib/frameworks/sproutcore/frameworks/foundation/tests/gestures/tap_gesture_test.js +55 -0
  61. data/lib/frameworks/sproutcore/frameworks/foundation/tests/mixins/gesturable_test.js +233 -0
  62. data/lib/frameworks/sproutcore/frameworks/foundation/tests/mixins/staticLayout.js +2 -2
  63. data/lib/frameworks/sproutcore/frameworks/foundation/tests/system/gesture_test.js +254 -0
  64. data/lib/frameworks/sproutcore/frameworks/foundation/views/container.js +1 -0
  65. data/lib/frameworks/sproutcore/frameworks/foundation/views/text_field.js +1 -1
  66. data/lib/frameworks/sproutcore/frameworks/legacy/object_keys_polyfill.js +51 -0
  67. data/lib/frameworks/sproutcore/frameworks/{core_foundation/system/req_anim_frame.js → legacy/request_animation_frame_polyfill.js} +10 -3
  68. data/lib/frameworks/sproutcore/frameworks/media/views/audio.js +19 -25
  69. data/lib/frameworks/sproutcore/frameworks/media/views/controls.js +7 -7
  70. data/lib/frameworks/sproutcore/frameworks/media/views/mini_controls.js +3 -3
  71. data/lib/frameworks/sproutcore/frameworks/media/views/simple_controls.js +9 -9
  72. data/lib/frameworks/sproutcore/frameworks/runtime/core.js +2 -2
  73. data/lib/frameworks/sproutcore/frameworks/runtime/debug/test_suites/array/insertAt.js +2 -2
  74. data/lib/frameworks/sproutcore/frameworks/runtime/debug/test_suites/array/removeAt.js +1 -1
  75. data/lib/frameworks/sproutcore/frameworks/runtime/ext/array.js +1 -1
  76. data/lib/frameworks/sproutcore/frameworks/runtime/mixins/array.js +2 -2
  77. data/lib/frameworks/sproutcore/frameworks/runtime/mixins/freezable.js +2 -2
  78. data/lib/frameworks/sproutcore/frameworks/runtime/mixins/observable.js +66 -5
  79. data/lib/frameworks/sproutcore/frameworks/runtime/mixins/tree.js +44 -0
  80. data/lib/frameworks/sproutcore/frameworks/runtime/private/observer_queue.js +4 -1
  81. data/lib/frameworks/sproutcore/frameworks/runtime/system/binding.js +0 -25
  82. data/lib/frameworks/sproutcore/frameworks/runtime/system/enumerator.js +1 -1
  83. data/lib/frameworks/sproutcore/frameworks/runtime/system/error.js +67 -15
  84. data/lib/frameworks/sproutcore/frameworks/runtime/system/index_set.js +6 -11
  85. data/lib/frameworks/sproutcore/frameworks/runtime/system/set.js +6 -6
  86. data/lib/frameworks/sproutcore/frameworks/runtime/system/string.js +1 -1
  87. data/lib/frameworks/sproutcore/frameworks/runtime/tests/mixins/observable/{observable.js → observable_test.js} +110 -16
  88. data/lib/frameworks/sproutcore/frameworks/runtime/tests/system/error.js +21 -0
  89. data/lib/frameworks/sproutcore/frameworks/statechart/system/statechart.js +2 -2
  90. data/lib/frameworks/sproutcore/frameworks/template_view/ext/handlebars.js +1 -1
  91. data/lib/frameworks/sproutcore/frameworks/testing/system/plan.js +1 -1
  92. data/lib/sproutcore/render_engines/haml.rb +1 -1
  93. metadata +610 -604
  94. data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/layout.js +0 -210
  95. data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/layoutDidChange.js +0 -275
  96. data/lib/frameworks/sproutcore/frameworks/foundation/gestures/pinch.js +0 -119
  97. data/lib/frameworks/sproutcore/frameworks/foundation/gestures/swipe.js +0 -234
  98. data/lib/frameworks/sproutcore/frameworks/foundation/gestures/tap.js +0 -157
@@ -159,9 +159,7 @@ SC.View.LayoutStyleCalculator = {
159
159
 
160
160
  // handles the case where you do width:auto or height:auto and are not using "staticLayout"
161
161
  _invalidAutoValue: function (view, property) {
162
- var error = SC.Error.desc("%@.layout() you cannot use %@:auto if staticLayout is disabled".fmt(view, property), "%@".fmt(view), -1);
163
- SC.Logger.error(error.toString());
164
- throw error;
162
+ SC.throw("%@.layout() you cannot use %@:auto if staticLayout is disabled".fmt(view, property), "%@".fmt(view), -1);
165
163
  },
166
164
 
167
165
  /** @private */
@@ -332,11 +332,12 @@ SC.CoreView.reopen(
332
332
  /** @private Adopt this view action. */
333
333
  _doAdopt: function (parentView, beforeView) {
334
334
  var curParentView = this.get('parentView'),
335
- handled = true;
335
+ handled = true,
336
+ state = this.get('viewState');
336
337
 
337
338
  //@if (debug)
338
339
  if (SC.LOG_VIEW_STATES || this.SC_LOG_VIEW_STATE) {
339
- SC.Logger.log('%c%@ — _doAdopt(%@, %@)'.fmt(this, parentView, beforeView), SC.LOG_VIEW_STATES_STYLE[this.get('viewState')]);
340
+ SC.Logger.log('%c%@ — _doAdopt(%@, %@): curParentView: %@'.fmt(this, parentView, beforeView, curParentView), SC.LOG_VIEW_STATES_STYLE[this.get('viewState')]);
340
341
  }
341
342
  //@endif
342
343
 
@@ -353,11 +354,11 @@ SC.CoreView.reopen(
353
354
 
354
355
  // You can adopt childViews that have you set as their parent (i.e. created
355
356
  // with createChildView()), but have not yet been fully adopted.
356
- if (!curParentView || this.get('childViews').indexOf(this) < 0) {
357
+ var siblings = parentView.get('childViews');
358
+ if (!curParentView || siblings.indexOf(this) < 0) {
357
359
  var idx,
358
- childViews = parentView.get('childViews'),
359
360
  parentViewState = parentView.get('viewState'),
360
- parentNode, nextNode, nextView, siblings;
361
+ parentNode, nextNode, nextView;
361
362
 
362
363
  // Notify that the child view will be added to the parent view.
363
364
  if (parentView.willAddChild) { parentView.willAddChild(this, beforeView); }
@@ -367,10 +368,10 @@ SC.CoreView.reopen(
367
368
  this.set('parentView', parentView);
368
369
 
369
370
  // Add to the new parent's childViews array.
370
- if (childViews.needsClone) { parentView.set(childViews = []); }
371
- idx = (beforeView) ? childViews.indexOf(beforeView) : childViews.length;
372
- if (idx < 0) { idx = childViews.length; }
373
- childViews.insertAt(idx, this);
371
+ if (siblings.needsClone) { parentView.set('childViews', []); }
372
+ idx = (beforeView) ? siblings.indexOf(beforeView) : siblings.length;
373
+ if (idx < 0) { idx = siblings.length; }
374
+ siblings.insertAt(idx, this);
374
375
 
375
376
  // Pass the current designMode to the view (and its children).
376
377
  this.updateDesignMode(this.get('designMode'), parentView.get('designMode'));
@@ -379,7 +380,7 @@ SC.CoreView.reopen(
379
380
  this._adopted(beforeView);
380
381
 
381
382
  // When a view is adopted, it should go to the same state as its new parent.
382
- switch (this.get('viewState')) {
383
+ switch (state) {
383
384
  case SC.CoreView.UNRENDERED:
384
385
  switch (parentViewState) {
385
386
  case SC.CoreView.UNRENDERED:
@@ -397,7 +398,6 @@ SC.CoreView.reopen(
397
398
  break;
398
399
  default:
399
400
  parentNode = parentView.get('containerLayer');
400
- siblings = parentView.get('childViews');
401
401
  nextView = siblings.objectAt(siblings.indexOf(this) + 1);
402
402
  nextNode = (nextView) ? nextView.get('layer') : null;
403
403
 
@@ -412,13 +412,18 @@ SC.CoreView.reopen(
412
412
  break;
413
413
  default:
414
414
  parentNode = parentView.get('containerLayer');
415
- siblings = parentView.get('childViews');
416
415
  nextView = siblings.objectAt(siblings.indexOf(this) + 1);
417
416
  nextNode = (nextView) ? nextView.get('layer') : null;
418
417
 
419
418
  this._doAttach(parentNode, nextNode);
420
419
  }
421
420
  }
421
+
422
+ // Adopting a view that is building out.
423
+ } else if (state === SC.CoreView.ATTACHED_BUILDING_OUT) {
424
+ this._doAttach();
425
+
426
+ // Can't do anything.
422
427
  } else {
423
428
  handled = false;
424
429
  }
@@ -481,7 +486,14 @@ SC.CoreView.reopen(
481
486
  // Note: We can be in ATTACHED_BUILDING_OUT state without a transition out while we wait for child views.
482
487
  if (this.get('transitionOut')) {
483
488
  // Cancel the building out transition (in place if we are going to switch to transitioning back in).
484
- this.cancelAnimation(transitionIn ? SC.LayoutState.CURRENT : undefined);
489
+ // this.cancelAnimation(transitionIn ? SC.LayoutState.CURRENT : undefined);
490
+ this.cancelAnimation();
491
+
492
+ //@if (debug)
493
+ if (SC.LOG_VIEW_STATES || this.SC_LOG_VIEW_STATE) {
494
+ SC.Logger.log('%c — cancelling build out outright'.fmt(this), SC.LOG_VIEW_STATES_STYLE[this.get('viewState')]);
495
+ }
496
+ //@endif
485
497
 
486
498
  // Set the proper state.
487
499
  this._gotoAttachedShownState();
@@ -635,15 +647,15 @@ SC.CoreView.reopen(
635
647
  // Result: If it has a build out transition, swap to it. Otherwise, cancel.
636
648
  case SC.CoreView.ATTACHED_BUILDING_IN:
637
649
  // Cancel the build in transition.
638
- if (transitionOut) {
639
- //@if (debug)
640
- if (SC.LOG_VIEW_STATES || this.SC_LOG_VIEW_STATE) {
641
- SC.Logger.log('%c — cancelling build in in place'.fmt(this), SC.LOG_VIEW_STATES_STYLE[this.get('viewState')]);
642
- }
643
- //@endif
644
-
645
- this.cancelAnimation(SC.LayoutState.CURRENT);
646
- } else {
650
+ // if (transitionOut) {
651
+ // //@if (debug)
652
+ // if (SC.LOG_VIEW_STATES || this.SC_LOG_VIEW_STATE) {
653
+ // SC.Logger.log('%c — cancelling build in in place'.fmt(this), SC.LOG_VIEW_STATES_STYLE[this.get('viewState')]);
654
+ // }
655
+ // //@endif
656
+
657
+ // this.cancelAnimation(SC.LayoutState.CURRENT);
658
+ // } else {
647
659
  //@if (debug)
648
660
  if (SC.LOG_VIEW_STATES || this.SC_LOG_VIEW_STATE) {
649
661
  SC.Logger.log('%c — cancelling build in outright'.fmt(this), SC.LOG_VIEW_STATES_STYLE[this.get('viewState')]);
@@ -651,7 +663,7 @@ SC.CoreView.reopen(
651
663
  //@endif
652
664
 
653
665
  this.cancelAnimation();
654
- }
666
+ // }
655
667
 
656
668
  // Set the proper state.
657
669
  this._gotoAttachedShownState();
@@ -1390,7 +1402,11 @@ SC.CoreView.reopen(
1390
1402
 
1391
1403
  // Update the state and children state. The children are updated top-down so that invalid state
1392
1404
  // children allow us to bail out early.
1393
- this._gotoUnattachedState();
1405
+ // if (this.get('parentView')) {
1406
+ // this._gotoAttachedPartialState();
1407
+ this._gotoUnattachedState();
1408
+ // }
1409
+
1394
1410
  this._callOnChildViews('_parentDidRender', true, notifyStack);
1395
1411
 
1396
1412
  this._sc_addRenderedStateObservers();
@@ -67,11 +67,11 @@ SC.FixturesDataSource = SC.DataSource.extend(
67
67
 
68
68
  // can only handle local queries out of the box
69
69
  if (query.get('location') !== SC.Query.LOCAL) {
70
- throw SC.$error('SC.Fixture data source can only fetch local queries');
70
+ SC.throw('SC.Fixture data source can only fetch local queries');
71
71
  }
72
72
 
73
73
  if (!query.get('recordType') && !query.get('recordTypes')) {
74
- throw SC.$error('SC.Fixture data source can only fetch queries with one or more record types');
74
+ SC.throw('SC.Fixture data source can only fetch queries with one or more record types');
75
75
  }
76
76
 
77
77
  if (this.get('simulateRemoteResponse')) {
@@ -542,7 +542,7 @@ SC.Record = SC.Object.extend(
542
542
  attrs;
543
543
 
544
544
  attrs = store.readEditableDataHash(storeKey);
545
- if (!attrs) throw SC.Record.BAD_STATE_ERROR;
545
+ if (!attrs) SC.Record.BAD_STATE_ERROR.throw();
546
546
 
547
547
  // if value is the same, do not flag record as dirty
548
548
  if (value !== attrs[key]) {
@@ -1346,7 +1346,7 @@ SC.Record.mixin( /** @scope SC.Record */ {
1346
1346
  @constant
1347
1347
  @type SC.Error
1348
1348
  */
1349
- BAD_STATE_ERROR: SC.$error("Internal Inconsistency"),
1349
+ BAD_STATE_ERROR: SC.$error("Internal Inconsistency"),
1350
1350
 
1351
1351
  /**
1352
1352
  Error for when you try to create a new record that already exists.
@@ -1364,7 +1364,7 @@ SC.Record.mixin( /** @scope SC.Record */ {
1364
1364
  @constant
1365
1365
  @type SC.Error
1366
1366
  */
1367
- NOT_FOUND_ERROR: SC.$error("Not found "),
1367
+ NOT_FOUND_ERROR: SC.$error("Not found "),
1368
1368
 
1369
1369
  /**
1370
1370
  Error for when you try to modify a record that is currently busy
@@ -1373,7 +1373,7 @@ SC.Record.mixin( /** @scope SC.Record */ {
1373
1373
  @constant
1374
1374
  @type SC.Error
1375
1375
  */
1376
- BUSY_ERROR: SC.$error("Busy"),
1376
+ BUSY_ERROR: SC.$error("Busy"),
1377
1377
 
1378
1378
  /**
1379
1379
  Generic unknown record error
@@ -1382,7 +1382,7 @@ SC.Record.mixin( /** @scope SC.Record */ {
1382
1382
  @constant
1383
1383
  @type SC.Error
1384
1384
  */
1385
- GENERIC_ERROR: SC.$error("Generic Error"),
1385
+ GENERIC_ERROR: SC.$error("Generic Error"),
1386
1386
 
1387
1387
  /**
1388
1388
  If true, then searches for records of this type will return subclass instances. For example:
@@ -278,7 +278,7 @@ SC.NestedStore = SC.Store.extend(
278
278
  reset: function() {
279
279
  // requires a pstore to reset
280
280
  var parentStore = this.get('parentStore');
281
- if (!parentStore) throw SC.Store.NO_PARENT_STORE_ERROR;
281
+ if (!parentStore) SC.Store.NO_PARENT_STORE_ERROR.throw();
282
282
 
283
283
  // inherit data store from parent store.
284
284
  this.dataHashes = SC.beget(parentStore.dataHashes);
@@ -337,7 +337,7 @@ SC.NestedStore = SC.Store.extend(
337
337
 
338
338
  /** @private - adapt for nested store */
339
339
  chainAutonomousStore: function(attrs, newStoreClass) {
340
- throw SC.Store.NESTED_STORE_UNSUPPORTED_ERROR;
340
+ SC.Store.NESTED_STORE_UNSUPPORTED_ERROR.throw();
341
341
  },
342
342
 
343
343
  // ..........................................................
@@ -616,7 +616,7 @@ SC.NestedStore = SC.Store.extend(
616
616
  // status hierarchy, so even though lower stores would complete the
617
617
  // retrieval, the upper layers would never inherit the new statuses.
618
618
  if (status & K.DIRTY) {
619
- throw SC.Store.NESTED_STORE_RETRIEVE_DIRTY_ERROR;
619
+ SC.Store.NESTED_STORE_RETRIEVE_DIRTY_ERROR.throw();
620
620
  }
621
621
  else {
622
622
  // Not dirty? Then abandon any status we had set (to re-establish
@@ -661,7 +661,7 @@ SC.NestedStore = SC.Store.extend(
661
661
  if( this.get( "dataSource" ) )
662
662
  return sc_super();
663
663
  else
664
- throw SC.Store.NESTED_STORE_UNSUPPORTED_ERROR;
664
+ SC.Store.NESTED_STORE_UNSUPPORTED_ERROR.throw();
665
665
  },
666
666
 
667
667
  /** @private - adapt for nested store */
@@ -669,7 +669,7 @@ SC.NestedStore = SC.Store.extend(
669
669
  if( this.get( "dataSource" ) )
670
670
  return sc_super();
671
671
  else
672
- throw SC.Store.NESTED_STORE_UNSUPPORTED_ERROR;
672
+ SC.Store.NESTED_STORE_UNSUPPORTED_ERROR.throw();
673
673
  },
674
674
 
675
675
  /** @private - adapt for nested store */
@@ -677,7 +677,7 @@ SC.NestedStore = SC.Store.extend(
677
677
  if( this.get( "dataSource" ) )
678
678
  return sc_super();
679
679
  else
680
- throw SC.Store.NESTED_STORE_UNSUPPORTED_ERROR;
680
+ SC.Store.NESTED_STORE_UNSUPPORTED_ERROR.throw();
681
681
  },
682
682
 
683
683
  /** @private - adapt for nested store */
@@ -685,7 +685,7 @@ SC.NestedStore = SC.Store.extend(
685
685
  if( this.get( "dataSource" ) )
686
686
  return sc_super();
687
687
  else
688
- throw SC.Store.NESTED_STORE_UNSUPPORTED_ERROR;
688
+ SC.Store.NESTED_STORE_UNSUPPORTED_ERROR.throw();
689
689
  },
690
690
 
691
691
  // ..........................................................
@@ -698,7 +698,7 @@ SC.NestedStore = SC.Store.extend(
698
698
  if( this.get( "dataSource" ) )
699
699
  return sc_super();
700
700
  else
701
- throw SC.Store.NESTED_STORE_UNSUPPORTED_ERROR;
701
+ SC.Store.NESTED_STORE_UNSUPPORTED_ERROR.throw();
702
702
  },
703
703
 
704
704
  /** @private - adapt for nested store */
@@ -706,7 +706,7 @@ SC.NestedStore = SC.Store.extend(
706
706
  if( this.get( "dataSource" ) )
707
707
  return sc_super();
708
708
  else
709
- throw SC.Store.NESTED_STORE_UNSUPPORTED_ERROR;
709
+ SC.Store.NESTED_STORE_UNSUPPORTED_ERROR.throw();
710
710
  },
711
711
 
712
712
  /** @private - adapt for nested store */
@@ -714,7 +714,7 @@ SC.NestedStore = SC.Store.extend(
714
714
  if( this.get( "dataSource" ) )
715
715
  return sc_super();
716
716
  else
717
- throw SC.Store.NESTED_STORE_UNSUPPORTED_ERROR;
717
+ SC.Store.NESTED_STORE_UNSUPPORTED_ERROR.throw();
718
718
  },
719
719
 
720
720
  /** @private - adapt for nested store */
@@ -722,7 +722,7 @@ SC.NestedStore = SC.Store.extend(
722
722
  if( this.get( "dataSource" ) )
723
723
  return sc_super();
724
724
  else
725
- throw SC.Store.NESTED_STORE_UNSUPPORTED_ERROR;
725
+ SC.Store.NESTED_STORE_UNSUPPORTED_ERROR.throw();
726
726
  },
727
727
 
728
728
  // ..........................................................
@@ -734,7 +734,7 @@ SC.NestedStore = SC.Store.extend(
734
734
  if( this.get( "dataSource" ) )
735
735
  return sc_super();
736
736
  else
737
- throw SC.Store.NESTED_STORE_UNSUPPORTED_ERROR;
737
+ SC.Store.NESTED_STORE_UNSUPPORTED_ERROR.throw();
738
738
  },
739
739
 
740
740
  /** @private - adapt for nested store */
@@ -742,7 +742,7 @@ SC.NestedStore = SC.Store.extend(
742
742
  if( this.get( "dataSource" ) )
743
743
  return sc_super();
744
744
  else
745
- throw SC.Store.NESTED_STORE_UNSUPPORTED_ERROR;
745
+ SC.Store.NESTED_STORE_UNSUPPORTED_ERROR.throw();
746
746
  },
747
747
 
748
748
  /** @private - adapt for nested store */
@@ -750,7 +750,7 @@ SC.NestedStore = SC.Store.extend(
750
750
  if( this.get( "dataSource" ) )
751
751
  return sc_super();
752
752
  else
753
- throw SC.Store.NESTED_STORE_UNSUPPORTED_ERROR;
753
+ SC.Store.NESTED_STORE_UNSUPPORTED_ERROR.throw();
754
754
  }
755
755
 
756
756
  }) ;
@@ -517,7 +517,7 @@ SC.Query = SC.Object.extend(SC.Copyable, SC.Freezable,
517
517
  this._order = this.buildOrder(this.get('orderBy'));
518
518
 
519
519
  this._isReady = !!tree && !tree.error;
520
- if (tree && tree.error) throw tree.error;
520
+ if (tree && tree.error) SC.throw(tree.error);
521
521
  return this._isReady;
522
522
  },
523
523
 
@@ -272,7 +272,7 @@ SC.RecordArray = SC.Object.extend(SC.Enumerable, SC.Array,
272
272
 
273
273
  if (!storeKeys) throw new Error("Unable to edit an SC.RecordArray that does not have its storeKeys property set.");
274
274
 
275
- if (!this.get('isEditable')) throw SC.RecordArray.NOT_EDITABLE;
275
+ if (!this.get('isEditable')) SC.RecordArray.NOT_EDITABLE.throw();
276
276
 
277
277
  // map to store keys
278
278
  keys = [] ;
@@ -814,7 +814,7 @@ SC.RecordArray.mixin(/** @scope SC.RecordArray.prototype */{
814
814
 
815
815
  @type SC.Error
816
816
  */
817
- NOT_EDITABLE: SC.Error.desc("SC.RecordArray is not editable"),
817
+ NOT_EDITABLE: SC.$error("SC.RecordArray is not editable"),
818
818
 
819
819
  /**
820
820
  Number of milliseconds to allow a query matching to run for. If this number
@@ -643,7 +643,7 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
643
643
 
644
644
  } else if (status & SC.Record.BUSY) {
645
645
  // make sure nested store does not have any changes before resetting
646
- if(store.get('hasChanges')) throw K.CHAIN_CONFLICT_ERROR;
646
+ if(store.get('hasChanges')) K.CHAIN_CONFLICT_ERROR.throw();
647
647
  store.reset();
648
648
  }
649
649
  }
@@ -812,7 +812,7 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
812
812
  commitChangesFromNestedStore: function (nestedStore, changes, force) {
813
813
  // first, check for optimistic locking problems
814
814
  if (!force && nestedStore.get('conflictedStoreKeys')) {
815
- throw SC.Store.CHAIN_CONFLICT_ERROR;
815
+ SC.Store.CHAIN_CONFLICT_ERROR.throw();
816
816
  }
817
817
 
818
818
  // OK, no locking issues. So let's just copy them changes.
@@ -1230,11 +1230,11 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
1230
1230
  if ((status & K.BUSY) ||
1231
1231
  (status & K.READY) ||
1232
1232
  (status === K.DESTROYED_DIRTY)) {
1233
- throw id ? K.RECORD_EXISTS_ERROR : K.BAD_STATE_ERROR;
1233
+ (id ? K.RECORD_EXISTS_ERROR : K.BAD_STATE_ERROR).throw();
1234
1234
 
1235
1235
  // allow error or destroyed state only with id
1236
1236
  } else if (!id && (status===SC.DESTROYED_CLEAN || status===SC.ERROR)) {
1237
- throw K.BAD_STATE_ERROR;
1237
+ K.BAD_STATE_ERROR.throw();
1238
1238
  }
1239
1239
 
1240
1240
  // Store the dataHash and setup initial status.
@@ -1343,7 +1343,7 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
1343
1343
 
1344
1344
  // error out if empty
1345
1345
  } else if (status & K.BUSY) {
1346
- throw K.BUSY_ERROR ;
1346
+ K.BUSY_ERROR.throw();
1347
1347
 
1348
1348
  // otherwise, destroy in dirty state
1349
1349
  } else status = newStatus ;
@@ -1384,8 +1384,8 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
1384
1384
  unload records this way.
1385
1385
 
1386
1386
  @param {SC.Record|Array} recordTypes class or array of classes
1387
- @param {Array} ids (optional) ids to unload
1388
- @param {Array} storeKeys (optional) store keys to unload
1387
+ @param {Array} [ids] ids to unload
1388
+ @param {Array} [storeKeys] store keys to unload
1389
1389
  @returns {SC.Store} receiver
1390
1390
  */
1391
1391
  unloadRecords: function(recordTypes, ids, storeKeys, newStatus) {
@@ -1441,11 +1441,11 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
1441
1441
 
1442
1442
  // error out if empty
1443
1443
  } else if (status === K.EMPTY) {
1444
- throw K.NOT_FOUND_ERROR ;
1444
+ K.NOT_FOUND_ERROR.throw();
1445
1445
 
1446
1446
  // error out if busy
1447
1447
  } else if (status & K.BUSY) {
1448
- throw K.BUSY_ERROR ;
1448
+ K.BUSY_ERROR.throw();
1449
1449
 
1450
1450
  // if new status, destroy in clean state
1451
1451
  } else if (status === K.READY_NEW) {
@@ -1655,12 +1655,12 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
1655
1655
  // BUSY_LOADING, BUSY_CREATING, BUSY_COMMITTING, BUSY_REFRESH_CLEAN
1656
1656
  // BUSY_REFRESH_DIRTY, BUSY_DESTROYING
1657
1657
  if (status & K.BUSY) {
1658
- throw K.BUSY_ERROR ;
1658
+ K.BUSY_ERROR.throw();
1659
1659
 
1660
1660
  // if record is not in ready state, then it is not found.
1661
1661
  // ERROR, EMPTY, DESTROYED_CLEAN, DESTROYED_DIRTY
1662
1662
  } else if (!(status & K.READY)) {
1663
- throw K.NOT_FOUND_ERROR ;
1663
+ K.NOT_FOUND_ERROR.throw();
1664
1664
 
1665
1665
  // otherwise, make new status READY_DIRTY unless new.
1666
1666
  // K.READY_CLEAN, K.READY_DIRTY, ignore K.READY_NEW
@@ -1790,11 +1790,11 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
1790
1790
  this._setCallbackForStoreKey(storeKey, callback, hasCallbackArray, storeKeys);
1791
1791
  // K.BUSY_DESTROYING, K.BUSY_COMMITTING, K.BUSY_CREATING
1792
1792
  } else if ((status === K.BUSY_DESTROYING) || (status === K.BUSY_CREATING) || (status === K.BUSY_COMMITTING)) {
1793
- throw K.BUSY_ERROR ;
1793
+ K.BUSY_ERROR.throw();
1794
1794
 
1795
1795
  // K.DESTROY_DIRTY, bad state...
1796
1796
  } else if (status === K.DESTROYED_DIRTY) {
1797
- throw K.BAD_STATE_ERROR ;
1797
+ K.BAD_STATE_ERROR.throw();
1798
1798
 
1799
1799
  // ignore K.BUSY_LOADING, K.BUSY_REFRESH_CLEAN, K.BUSY_REFRESH_DIRTY
1800
1800
  }
@@ -2007,7 +2007,7 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
2007
2007
  status = this.readStatus(storeKey);
2008
2008
 
2009
2009
  if (status === K.ERROR) {
2010
- throw K.NOT_FOUND_ERROR ;
2010
+ K.NOT_FOUND_ERROR.throw();
2011
2011
  }
2012
2012
  else {
2013
2013
  if(status === K.READY_NEW) {
@@ -2117,7 +2117,7 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
2117
2117
  status = this.readStatus(storeKey);
2118
2118
 
2119
2119
  if ((status === K.EMPTY) || (status === K.ERROR)) {
2120
- throw K.NOT_FOUND_ERROR ;
2120
+ K.NOT_FOUND_ERROR.throw();
2121
2121
  }
2122
2122
  ret.push(storeKey);
2123
2123
  this._cancelCallback(storeKey);
@@ -2225,35 +2225,38 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
2225
2225
 
2226
2226
  @param {SC.Record} recordTypes the record type or array of record types
2227
2227
  @param {Array} dataHashes array of data hashes to update
2228
- @param {Array} ids optional array of ids. if not passed lookup on hashes
2228
+ @param {Array} [ids] array of ids. if not passed lookup on hashes
2229
2229
  @returns {Array} store keys assigned to these ids
2230
2230
  */
2231
- loadRecords: function(recordTypes, dataHashes, ids) {
2231
+ // TODO: No reason for first argument to be an array. The developer can just call loadRecords multiple times with different record type each time. Would save us the need to check if recordTypes is an Array or not.
2232
+ loadRecords: function (recordTypes, dataHashes, ids) {
2232
2233
  var isArray = SC.typeOf(recordTypes) === SC.T_ARRAY,
2233
2234
  len = dataHashes.get('length'),
2234
2235
  ret = [],
2235
- recordType, id, primaryKey, idx, dataHash;
2236
+ recordType,
2237
+ id, primaryKey, idx, dataHash;
2236
2238
 
2237
2239
  // save lookup info
2238
2240
  if (!isArray) {
2239
2241
  recordType = recordTypes || SC.Record;
2240
- primaryKey = recordType.prototype.primaryKey ;
2242
+ primaryKey = recordType.prototype.primaryKey;
2241
2243
  }
2242
2244
 
2243
2245
  // push each record
2244
- for(idx=0;idx<len;idx++) {
2246
+ for (idx = 0; idx < len; idx++) {
2245
2247
  dataHash = dataHashes.objectAt(idx);
2246
2248
  if (isArray) {
2247
2249
  recordType = recordTypes.objectAt(idx) || SC.Record;
2248
2250
  primaryKey = recordType.prototype.primaryKey ;
2249
2251
  }
2252
+
2250
2253
  id = (ids) ? ids.objectAt(idx) : dataHash[primaryKey];
2251
- ret[idx] = this.loadRecord(recordType, dataHash, id);
2252
2254
 
2255
+ ret[idx] = this.loadRecord(recordType, dataHash, id);
2253
2256
  }
2254
2257
 
2255
2258
  // return storeKeys
2256
- return ret ;
2259
+ return ret;
2257
2260
  },
2258
2261
 
2259
2262
  /**
@@ -2299,7 +2302,7 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
2299
2302
  // EMPTY, ERROR, READY_CLEAN, READY_NEW, READY_DIRTY, DESTROYED_CLEAN,
2300
2303
  // DESTROYED_DIRTY
2301
2304
  if (!(status & K.BUSY)) {
2302
- throw K.BAD_STATE_ERROR; // should never be called in this state
2305
+ K.BAD_STATE_ERROR.throw(); // should never be called in this state
2303
2306
  }
2304
2307
 
2305
2308
  // otherwise, determine proper state transition
@@ -2329,7 +2332,7 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
2329
2332
  break;
2330
2333
 
2331
2334
  default:
2332
- throw K.BAD_STATE_ERROR ;
2335
+ K.BAD_STATE_ERROR.throw() ;
2333
2336
  }
2334
2337
  this.writeStatus(storeKey, status) ;
2335
2338
  this.dataHashDidChange(storeKey, null, YES);
@@ -2354,12 +2357,12 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
2354
2357
  // EMPTY, ERROR, READY_CLEAN, READY_NEW, READY_DIRTY, DESTROYED_CLEAN,
2355
2358
  // DESTROYED_DIRTY
2356
2359
  if (!(status & K.BUSY)) {
2357
- throw K.BAD_STATE_ERROR; // should never be called in this state
2360
+ K.BAD_STATE_ERROR.throw(); // should never be called in this state
2358
2361
  }
2359
2362
 
2360
2363
  // otherwise, determine proper state transition
2361
2364
  if(status === K.BUSY_DESTROYING) {
2362
- throw K.BAD_STATE_ERROR ;
2365
+ K.BAD_STATE_ERROR.throw();
2363
2366
  } else status = K.READY_CLEAN;
2364
2367
 
2365
2368
  this.writeStatus(storeKey, status);
@@ -2395,7 +2398,7 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
2395
2398
  // EMPTY, ERROR, READY_CLEAN, READY_NEW, READY_DIRTY, DESTROYED_CLEAN,
2396
2399
  // DESTROYED_DIRTY
2397
2400
  if (!(status & K.BUSY)) {
2398
- throw K.BAD_STATE_ERROR; // should never be called in this state
2401
+ K.BAD_STATE_ERROR.throw(); // should never be called in this state
2399
2402
  }
2400
2403
  // otherwise, determine proper state transition
2401
2404
  else{
@@ -2427,7 +2430,7 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
2427
2430
 
2428
2431
  // EMPTY, ERROR, READY_CLEAN, READY_NEW, READY_DIRTY, DESTROYED_CLEAN,
2429
2432
  // DESTROYED_DIRTY
2430
- if (!(status & K.BUSY)) { throw K.BAD_STATE_ERROR; }
2433
+ if (!(status & K.BUSY)) { K.BAD_STATE_ERROR.throw(); }
2431
2434
 
2432
2435
  // otherwise, determine proper state transition
2433
2436
  else status = K.ERROR ;
@@ -2590,7 +2593,7 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
2590
2593
 
2591
2594
  For example,
2592
2595
 
2593
- storeKeys = store.loadRecords(body.contacts);
2596
+ storeKeys = store.loadRecords(MyApp.SomeType, body.contacts);
2594
2597
  store.dataSourceDidFetchQuery(query, storeKeys);
2595
2598
 
2596
2599
  # Automatic updates
@@ -2853,7 +2856,7 @@ SC.Store.mixin(/** @scope SC.Store.prototype */{
2853
2856
 
2854
2857
  @type Error
2855
2858
  */
2856
- CHAIN_CONFLICT_ERROR: new Error("Nested Store Conflict"),
2859
+ CHAIN_CONFLICT_ERROR: SC.$error("Nested Store Conflict"),
2857
2860
 
2858
2861
  /**
2859
2862
  Standard error if you try to perform an operation on a nested store
@@ -2861,7 +2864,7 @@ SC.Store.mixin(/** @scope SC.Store.prototype */{
2861
2864
 
2862
2865
  @type Error
2863
2866
  */
2864
- NO_PARENT_STORE_ERROR: new Error("Parent Store Required"),
2867
+ NO_PARENT_STORE_ERROR: SC.$error("Parent Store Required"),
2865
2868
 
2866
2869
  /**
2867
2870
  Standard error if you try to perform an operation on a nested store that
@@ -2869,7 +2872,7 @@ SC.Store.mixin(/** @scope SC.Store.prototype */{
2869
2872
 
2870
2873
  @type Error
2871
2874
  */
2872
- NESTED_STORE_UNSUPPORTED_ERROR: new Error("Unsupported In Nested Store"),
2875
+ NESTED_STORE_UNSUPPORTED_ERROR: SC.$error("Unsupported In Nested Store"),
2873
2876
 
2874
2877
  /**
2875
2878
  Standard error if you try to retrieve a record in a nested store that is
@@ -2877,7 +2880,7 @@ SC.Store.mixin(/** @scope SC.Store.prototype */{
2877
2880
 
2878
2881
  @type Error
2879
2882
  */
2880
- NESTED_STORE_RETRIEVE_DIRTY_ERROR: new Error("Cannot Retrieve Dirty Record in Nested Store"),
2883
+ NESTED_STORE_RETRIEVE_DIRTY_ERROR: SC.$error("Cannot Retrieve Dirty Record in Nested Store"),
2881
2884
 
2882
2885
  /**
2883
2886
  Data hash state indicates the data hash is currently editable