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
@@ -34,7 +34,7 @@ SC.MediaControlsView = SC.View.extend(
34
34
  icon: 'play',
35
35
  layout: { top: 0, left: 0, width: 20, height:20},
36
36
  action: "playPause",
37
- targetBinding: "*owner.target"
37
+ targetBinding: ".parentView.target"
38
38
  }),
39
39
 
40
40
  progressView: SC.MediaSlider.extend({
@@ -42,15 +42,15 @@ SC.MediaControlsView = SC.View.extend(
42
42
  value:0,
43
43
  minimum: 0,
44
44
  step:0.1,
45
- valueBinding: "*owner.target.currentTime" ,
46
- maximumBinding: "*owner.target.duration",
47
- mediaViewBinding: "*owner.target"
45
+ valueBinding: ".parentView*target.currentTime" ,
46
+ maximumBinding: ".parentView*target.duration",
47
+ mediaViewBinding: ".parentView.target"
48
48
  }),
49
49
 
50
50
  timeView: SC.LabelView.extend({
51
51
  layout: { top: 0, right: 160, width: 60, height:20},
52
52
  classNames: 'time',
53
- valueBinding: '*owner.target.time'
53
+ valueBinding: '.parentView*target.time'
54
54
  }),
55
55
 
56
56
  theaterButton: SC.ButtonView.extend({
@@ -59,7 +59,7 @@ SC.MediaControlsView = SC.View.extend(
59
59
  titleMinWidth: 35,
60
60
  layout: { top: 0, right: 140, width: 20, height:20},
61
61
  action: "fullScreen",
62
- targetBinding: "*owner.target"
62
+ targetBinding: ".parentView.target"
63
63
  }),
64
64
 
65
65
  minusLabelView: SC.LabelView.extend({
@@ -71,7 +71,7 @@ SC.MediaControlsView = SC.View.extend(
71
71
  volumeView: SC.MediaSlider.extend({
72
72
  layout: { top: 0, right: 25, width: 90, height:20},
73
73
  value:0,
74
- valueBinding: "*owner.target.volume" ,
74
+ valueBinding: ".parentView*target.volume" ,
75
75
  minimum: 0,
76
76
  maximum: 1,
77
77
  step: 0.01
@@ -34,7 +34,7 @@ SC.MiniMediaControlsView = SC.View.extend(
34
34
  noStyle: YES,
35
35
  layout: { top: 0, left: 0, width: 20, height:20},
36
36
  action: "playPause",
37
- targetBinding: "*owner.target",
37
+ targetBinding: ".parentView.target",
38
38
  renderStyle: 'renderImage',
39
39
  theme: ''
40
40
  }),
@@ -42,7 +42,7 @@ SC.MiniMediaControlsView = SC.View.extend(
42
42
  timeView: SC.LabelView.design({
43
43
  layout: { top: 0, left: 20, width: 60, height:20},
44
44
  classNames: 'time',
45
- valueBinding: '*owner.target.time'
45
+ valueBinding: '.parentView*target.time'
46
46
  }),
47
47
 
48
48
  minusLabelView: SC.LabelView.design({
@@ -54,7 +54,7 @@ SC.MiniMediaControlsView = SC.View.extend(
54
54
  volumeView: SC.MediaSlider.design({
55
55
  layout: { top: 0, left: 100, right: 10, height:20},
56
56
  value:0,
57
- valueBinding: "*owner.target.volume" ,
57
+ valueBinding: ".parentView*target.volume" ,
58
58
  minimum: 0,
59
59
  maximum: 1,
60
60
  step: 0.01
@@ -14,11 +14,11 @@ SC.SimpleMediaControlsView = SC.View.extend(
14
14
  /** @scope SC.SimpleMediaControlsView.prototype */{
15
15
 
16
16
  target: null,
17
-
17
+
18
18
  childViews: ['playButton', 'progressView'],
19
-
19
+
20
20
  classNames: ['sc-media-controls'],
21
-
21
+
22
22
  playObserver: function(){
23
23
  if(this.getPath('target.paused')){
24
24
  this.get('playButton').set('icon', 'play');
@@ -26,23 +26,23 @@ SC.SimpleMediaControlsView = SC.View.extend(
26
26
  this.get('playButton').set('icon', 'stop');
27
27
  }
28
28
  }.observes('*target.paused'),
29
-
29
+
30
30
  playButton: SC.ButtonView.design({
31
31
  title: '',
32
32
  titleMinWidth: 35,
33
33
  icon: 'play',
34
34
  layout: { top: 0, left: 0, width: 20, height:20 },
35
35
  action: "playPause",
36
- targetBinding: "*owner.target"
36
+ targetBinding: ".parentView.target"
37
37
  }),
38
-
38
+
39
39
  progressView: SC.MediaSlider.design({
40
40
  layout: { top: 0, left: 25, right: 10, height:20 },
41
41
  value:0,
42
42
  minimum: 0,
43
43
  step:0.1,
44
- valueBinding: "*owner.target.currentTime" ,
45
- maximumBinding: "*owner.target.duration",
46
- mediaViewBinding: "*owner.target"
44
+ valueBinding: ".parentView*target.currentTime" ,
45
+ maximumBinding: ".parentView*target.duration",
46
+ mediaViewBinding: ".parentView.target"
47
47
  })
48
48
  });
@@ -39,7 +39,7 @@ window.SproutCore = window.SproutCore || SC;
39
39
  // rest of the methods go into the mixin defined below.
40
40
 
41
41
  /**
42
- @version 1.11.0.rc3
42
+ @version 1.11.0
43
43
  @namespace
44
44
 
45
45
  All SproutCore methods and functions are defined
@@ -56,7 +56,7 @@ window.SproutCore = window.SproutCore || SC;
56
56
  */
57
57
  SC = window.SC; // This is dumb but necessary for jsdoc to get it right
58
58
 
59
- SC.VERSION = '1.11.0.rc3';
59
+ SC.VERSION = '1.11.0';
60
60
 
61
61
  /**
62
62
  @private
@@ -34,7 +34,7 @@ SC.ArraySuite.define(function(T) {
34
34
  try {
35
35
  obj.insertAt(200, T.expected(1));
36
36
  } catch (e) {
37
- equals(e, SC.OUT_OF_RANGE_EXCEPTION, 'should throw SC.OUT_OF_RANGE_EXCEPTION');
37
+ equals(e.message, SC.OUT_OF_RANGE_EXCEPTION, 'should throw SC.OUT_OF_RANGE_EXCEPTION');
38
38
  didThrow = YES ;
39
39
  }
40
40
  ok(didThrow, 'should raise exception');
@@ -73,7 +73,7 @@ SC.ArraySuite.define(function(T) {
73
73
  try {
74
74
  obj.insertAt(200, T.expected(1));
75
75
  } catch (e) {
76
- equals(e, SC.OUT_OF_RANGE_EXCEPTION, 'should throw SC.OUT_OF_RANGE_EXCEPTION');
76
+ equals(e.message, SC.OUT_OF_RANGE_EXCEPTION, 'should throw SC.OUT_OF_RANGE_EXCEPTION');
77
77
  didThrow = YES ;
78
78
  }
79
79
  ok(didThrow, 'should raise exception');
@@ -35,7 +35,7 @@ SC.ArraySuite.define(function(T) {
35
35
  try {
36
36
  obj.removeAt(200);
37
37
  } catch (e) {
38
- equals(e, SC.OUT_OF_RANGE_EXCEPTION, 'should throw SC.OUT_OF_RANGE_EXCEPTION');
38
+ equals(e.message, SC.OUT_OF_RANGE_EXCEPTION, 'should throw SC.OUT_OF_RANGE_EXCEPTION');
39
39
  didThrow = YES ;
40
40
  }
41
41
  ok(didThrow, 'should raise exception');
@@ -16,7 +16,7 @@ SC.mixin(Array.prototype,
16
16
 
17
17
  // primitive for array support.
18
18
  replace: function (idx, amt, objects) {
19
- if (this.isFrozen) { throw SC.FROZEN_ERROR; }
19
+ if (this.isFrozen) { throw new Error(SC.FROZEN_ERROR); }
20
20
 
21
21
  var args;
22
22
  var len = objects ? (objects.get ? objects.get('length') : objects.length) : 0;
@@ -138,7 +138,7 @@ SC.CoreArray = /** @lends SC.Array.prototype */ {
138
138
  @param {Object} object object to insert
139
139
  */
140
140
  insertAt: function (idx, object) {
141
- if (idx > this.get('length')) throw SC.OUT_OF_RANGE_EXCEPTION;
141
+ if (idx > this.get('length')) throw new Error(SC.OUT_OF_RANGE_EXCEPTION);
142
142
  this.replace(idx, 0, [object]);
143
143
  return this;
144
144
  },
@@ -162,7 +162,7 @@ SC.CoreArray = /** @lends SC.Array.prototype */ {
162
162
  if (typeof start === SC.T_NUMBER) {
163
163
 
164
164
  if ((start < 0) || (start >= this.get('length'))) {
165
- throw SC.OUT_OF_RANGE_EXCEPTION;
165
+ throw new Error(SC.OUT_OF_RANGE_EXCEPTION);
166
166
  }
167
167
 
168
168
  // fast case
@@ -11,7 +11,7 @@
11
11
 
12
12
  @type Error
13
13
  */
14
- SC.FROZEN_ERROR = new Error("Cannot modify a frozen object");
14
+ SC.FROZEN_ERROR = "Cannot modify a frozen object";
15
15
 
16
16
  /**
17
17
  @class
@@ -48,7 +48,7 @@ SC.FROZEN_ERROR = new Error("Cannot modify a frozen object");
48
48
 
49
49
  // swaps the names
50
50
  swapNames: function() {
51
- if (this.get('isFrozen')) throw SC.FROZEN_ERROR;
51
+ if (this.get('isFrozen')) throw new Error(SC.FROZEN_ERROR);
52
52
  var tmp = this.get('firstName');
53
53
  this.set('firstName', this.get('lastName'));
54
54
  this.set('lastName', tmp);
@@ -918,18 +918,79 @@ SC.Observable = /** @scope SC.Observable.prototype */ {
918
918
  an expensive action until someone begins observing a particular property
919
919
  on the object.
920
920
 
921
+ Optionally, you may pass a target and method to check for the
922
+ presence of a particular observer. You can use this to avoid creating
923
+ duplicate observers in situations where that's likely.
924
+
921
925
  @param {String} key key to check
926
+ @param {Object} [target] the target that the observer uses
927
+ @param {Function|String} [method]) the method on the target that the observer uses
922
928
  @returns {Boolean}
923
929
  */
924
- hasObserverFor: function (key) {
930
+ hasObserverFor: function (key, target, method) {
925
931
  SC.Observers.flush(this); // hookup as many observers as possible.
926
932
 
927
933
  var observers = this[SC.keyFor('_kvo_observers', key)],
928
- locals = this[SC.keyFor('_kvo_local', key)];
934
+ chains = this._kvo_for(SC.keyFor('_kvo_chains', key)),
935
+ locals = this[SC.keyFor('_kvo_local', key)],
936
+ isChain = key.indexOf('.') >= 0;
937
+
938
+ // Fast path: no target/method.
939
+ if (target === undefined) {
940
+ if (isChain) {
941
+ if (chains && chains.length > 0) return YES;
942
+ } else {
943
+ // Found locally.
944
+ if (locals && locals.length > 0) return YES;
945
+ if (observers && observers.getMembers().length > 0) return YES;
946
+ }
947
+ return NO;
948
+
949
+ // Slow path: target/method.
950
+ } else {
951
+ if (method === undefined) {
952
+ method = target;
953
+ target = this;
954
+ }
955
+ if (typeof method === "string") method = target[method];
956
+ if (!method) throw new Error("Developer Error: If present, the `method` argument of hasObserverFor must be (or refer to) a function.");
957
+
958
+ // Declare our iterators.
959
+ var i, len;
960
+
961
+ // Check remote chains.
962
+ if (isChain) {
963
+ if (!chains || !chains.length) return NO;
964
+ len = chains.length;
965
+ for (i = 0; i < len; i++) {
966
+ if (chains[i].masterTarget === target && chains[i].masterMethod === method) return YES;
967
+ }
968
+ return NO;
969
+
970
+ // Check locals.
971
+ } else if (target === this) {
972
+ if (!locals) return NO;
973
+ len = locals.length;
974
+ for (i = 0; i < len; i++) {
975
+ if (this[locals[i]] === method) return YES;
976
+ }
977
+ return NO;
929
978
 
930
- if (locals && locals.length > 0) return YES;
931
- if (observers && observers.getMembers().length > 0) return YES;
932
- return NO;
979
+ // Check remotes.
980
+ } else {
981
+ if (!observers || !observers.members) return NO;
982
+
983
+ len = observers.members.length;
984
+ var member;
985
+ for (i = 0; i < len; i++) {
986
+ member = observers.members[i];
987
+ // If this is a non-chained observer, the first item is the target and the second is the method.
988
+ if (member[0] === target && member[1] === method) return YES;
989
+ }
990
+ return NO;
991
+ }
992
+ // TODO: Remote chains.
993
+ }
933
994
  },
934
995
 
935
996
  /**
@@ -0,0 +1,44 @@
1
+ // ==========================================================================
2
+ // Project: SproutCore Costello - Property Observing Library
3
+ // Copyright: ©2006-2011 Strobe Inc. and contributors.
4
+ // Portions ©2008-2011 Apple Inc. All rights reserved.
5
+ // License: Licensed under MIT license (see license.js)
6
+ // ==========================================================================
7
+
8
+ /** @private */
9
+ SC.Tree = /** @scope SC.Tree.prototype */ {
10
+
11
+ /** @private Call the method recursively on all child views. */
12
+ invoke: function (methodName, isTopDown, context) {
13
+ var childView,
14
+ childViews = this.get('childViews'),
15
+ method,
16
+ shouldContinue;
17
+
18
+ for (var i = childViews.length - 1; i >= 0; i--) {
19
+ childView = childViews[i];
20
+
21
+ // We allow missing childViews in the array so ignore them.
22
+ if (!childView) { continue; }
23
+
24
+ // Look up the method on the child.
25
+ method = childView[methodName];
26
+
27
+ // Call the method on this view *before* its children.
28
+ if (isTopDown === undefined || isTopDown) {
29
+ shouldContinue = method.call(childView, context);
30
+ }
31
+
32
+ // Recurse.
33
+ if (shouldContinue === undefined || shouldContinue) {
34
+ childView._callOnChildViews(methodName, isTopDown, context);
35
+ }
36
+
37
+ // Call the method on this view *after* its children.
38
+ if (isTopDown === false) {
39
+ method.call(childView, context);
40
+ }
41
+ }
42
+ }
43
+
44
+ };
@@ -81,7 +81,10 @@ SC.Observers = {
81
81
  // it is fastest to set to null then loop over again to collapse, but for all other browsers
82
82
  // it is not. Plus, this code shouldn't get hit very often anyway (it may not ever get hit
83
83
  // for some apps).
84
- idx = this.queue.length; queue = this.queue, newQueue = undefined;
84
+ idx = this.queue.length;
85
+ queue = this.queue;
86
+
87
+ var newQueue;
85
88
  while(--idx >= 0) {
86
89
  item = queue[idx];
87
90
 
@@ -967,31 +967,6 @@ SC.Binding = /** @scope SC.Binding.prototype */{
967
967
  });
968
968
  },
969
969
 
970
- /**
971
- Adds a transform that will return YES if the value is equal to equalValue, NO otherwise.
972
-
973
- isVisibleBinding: SC.Binding.oneWay("MyApp.someController.title").equalTo(comparisonValue)
974
-
975
- Or:
976
-
977
- isVisibleBinding: SC.Binding.equalTo("MyApp.someController.title", comparisonValue)
978
-
979
- @param {String} fromPath from path or null
980
- @param {Object} equalValue the value to compare with
981
- @returns {SC.Binding} this
982
- */
983
- equalTo: function(fromPath, equalValue) {
984
- // Normalize arguments.
985
- if (equalValue === undefined) {
986
- equalValue = fromPath;
987
- fromPath = null;
988
- }
989
-
990
- return this.from(fromPath).transform(function(value, binding) {
991
- return value === equalValue;
992
- });
993
- },
994
-
995
970
  /**
996
971
  Adds a transform that will *always* return an integer Number value. Null and undefined values will
997
972
  return 0 while String values will be transformed using the parseInt method (according to the
@@ -57,7 +57,7 @@ SC.Enumerator.prototype = /** @scope SC.Enumerator.prototype */{
57
57
  */
58
58
  reset: function() {
59
59
  var e = this.enumerable ;
60
- if (!e) throw SC.$error("Enumerator has been destroyed");
60
+ if (!e) SC.throw("Enumerator has been destroyed");
61
61
  this._length = e.get ? e.get('length') : e.length ;
62
62
  var len = this._length;
63
63
  this._index = 0;
@@ -32,7 +32,7 @@ sc_require('ext/function');
32
32
  set isError to YES, then calling SC.ok(obj) on your object will return NO.
33
33
  If isError is YES, then SC.val(obj) will return your errorValue property
34
34
  instead of the receiver.
35
-
35
+
36
36
  When using SC.typeOf(obj), SC.T_ERROR will only be returned if the obj
37
37
  is an instance of SC.Error
38
38
 
@@ -76,6 +76,27 @@ SC.Error = SC.Object.extend(
76
76
  return this;
77
77
  }.property().cacheable(),
78
78
 
79
+ /**
80
+ Throw the error.
81
+
82
+ @type SC.Error
83
+ */
84
+ 'throw': function() {
85
+ var error = this.toString();
86
+ SC.Logger.error(error);
87
+
88
+ throw new Error(error);
89
+ },
90
+
91
+ /**
92
+ The error stacktrace.
93
+
94
+ @type SC.Error
95
+ */
96
+ trace: function() {
97
+ return (new Error()).trace;
98
+ }.property().cacheable(),
99
+
79
100
  /**
80
101
  Human readable name of the item with the error.
81
102
 
@@ -94,37 +115,68 @@ SC.Error = SC.Object.extend(
94
115
  @type Boolean
95
116
  */
96
117
  isError: YES
97
- }) ;
118
+ });
119
+
120
+ SC.Error.mixin({
121
+
122
+ /**
123
+ Creates a new SC.Error instance with the passed description, label, and
124
+ code. All parameters are optional.
125
+
126
+ @param description {String} human readable description of the error
127
+ @param label {String} human readable name of the item with the error
128
+ @param code {Number} an error code to use for testing.
129
+ @returns {SC.Error} new error instance.
130
+ */
131
+ desc: function(description, label, value, code) {
132
+ var opts = { message: description } ;
133
+ if (label !== undefined) opts.label = label ;
134
+ if (code !== undefined) opts.code = code ;
135
+ if (value !== undefined) opts.errorValue = value ;
136
+ return this.create(opts) ;
137
+ },
138
+
139
+ /**
140
+ Throw a new SC.Error instance with the passed description, label, and
141
+ code. All parameters are optional.
142
+
143
+ @param description {String} human readable description of the error
144
+ @param label {String} human readable name of the item with the error
145
+ @param code {Number} an error code to use for testing.
146
+ @returns {SC.Error} new error instance.
147
+ */
148
+ 'throw': function(description, label, value, code) {
149
+ this.desc.apply(this, arguments).throw();
150
+ }
151
+
152
+ });
98
153
 
99
154
  /**
100
- Creates a new SC.Error instance with the passed description, label, and
101
- code. All parameters are optional.
155
+ Shorthand form of the SC.Error.desc method.
102
156
 
103
157
  @param description {String} human readable description of the error
104
158
  @param label {String} human readable name of the item with the error
105
159
  @param code {Number} an error code to use for testing.
106
160
  @returns {SC.Error} new error instance.
107
161
  */
108
- SC.Error.desc = function(description, label, value, code) {
109
- var opts = { message: description } ;
110
- if (label !== undefined) opts.label = label ;
111
- if (code !== undefined) opts.code = code ;
112
- if (value !== undefined) opts.errorValue = value ;
113
- return this.create(opts) ;
114
- } ;
162
+ SC.$error = function(description, label, value, c) {
163
+ return SC.Error.desc(description, label, value, c);
164
+ };
115
165
 
116
166
  /**
117
- Shorthand form of the SC.Error.desc method.
167
+ Shorthand form of the SC.Error.throw method.
118
168
 
119
169
  @param description {String} human readable description of the error
120
170
  @param label {String} human readable name of the item with the error
121
171
  @param code {Number} an error code to use for testing.
122
172
  @returns {SC.Error} new error instance.
123
173
  */
174
+ SC.throw = function(description, label, value, c) {
175
+ SC.Error.throw(description, label, value, c);
176
+ };
124
177
 
125
- SC.$error = function(description, label, value, c) {
126
- return SC.Error.desc(description,label, value, c);
127
- } ;
178
+ /** @private */
179
+ SC.$throw = SC.throw;
128
180
 
129
181
  /**
130
182
  Returns NO if the passed value is an error object or false.