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
@@ -8,108 +8,125 @@
8
8
 
9
9
  /**
10
10
  @class
11
-
11
+
12
12
  An SC.Gesture analyzes SC.Touch objects and determines if they are part
13
13
  of a gesture. If they are, SC.Gestures keep the views that own them up-to-date
14
14
  as that gesture progresses, informing it when it starts, when some aspect of
15
15
  it changes, when it ends, and—for convenience—when it is considered to have
16
16
  been "triggered".
17
-
17
+
18
18
  Gestures can call the following methods on their views:
19
-
20
- - [gestureName](gesture, args...): called when the gesture has occurred. This is
19
+
20
+ - [gestureName](args...): called when the gesture has occurred. This is
21
21
  useful for event-style gestures, where you aren't interested in when it starts or
22
22
  ends, but just that it has occurred. SC.SwipeGesture triggers this after the
23
23
  swipe has moved a minimum amount—40px by default.
24
24
 
25
- - [gestureName]Start(gesture, args...): called when the gesture is first recognized.
26
- For instance, a swipe gesture may be recognized after the finger has moved a
25
+ - [gestureName]Start(args...): called when the gesture is first recognized.
26
+ For instance, a swipe gesture may be recognized after the finger has moved a
27
27
  minimum distance in a horizontal.
28
-
29
- - [gestureName]Changed(gesture, args...): called when some property of the gesture
30
- has changed. For instance, this may be called continuously as the user swipes as
28
+
29
+ - [gestureName]Changed(args...): called when some property of the gesture
30
+ has changed. For instance, this may be called continuously as the user swipes as
31
31
  the swipe's distance changes.
32
-
33
- - [gestureName]Cancelled(gesture, args...): called when a gesture, for one reason
34
- or another, is no longer recognized. For instance, a horizontal swipe gesture
32
+
33
+ - [gestureName]Cancelled(args...): called when a gesture, for one reason
34
+ or another, is no longer recognized. For instance, a horizontal swipe gesture
35
35
  could cancel if the user moves too far in a vertical direction.
36
-
37
- - [gestureName]End(gesture, args...): called when a gesture ends. A swipe would end
36
+
37
+ - [gestureName]End(args...): called when a gesture ends. A swipe would end
38
38
  when the user lifts their finger.
39
-
39
+
40
40
  Gesture Lifecycle
41
41
  ------------------------
42
42
  Gestures start receiving events when their view—usually mixing in SC.Gesturable—tells it
43
43
  about activities with "unassigned" touches. "Unassigned" touches are touches that have
44
44
  not _yet_ been assigned to a gesture.
45
-
45
+
46
46
  The touch becomes "assigned" when the gesture's touchIsInGesture method returns YES.
47
- When a tocuh is assigned to a gesture, the gesture becomes the touch's touch responder;
47
+ When a touch is assigned to a gesture, the gesture becomes the touch's touch responder;
48
48
  this means that it will receive a touchStart event (to which it must return YES), and
49
49
  then, all further touch events will be sent _directly_ to the gesture—the gesture's view
50
50
  will not receive them at all.
51
-
51
+
52
52
  At any point, the gesture may tell the view that it has started, ended, or changed. In
53
53
  addition, the gesture may tell the view it has been "triggered." A gesture is not
54
54
  necessarily "triggered" when it starts and ends; for instance, a swipe gesture might
55
55
  only be triggered if the swipe moves more than a specified amount. The ability to track
56
56
  when the gesture has been triggered allows views to easily handle the gesture as its own
57
57
  event, rather than as the individual events that are part of it.
58
-
58
+
59
59
  If, at some point, the gesture must release the touch back (perhaps the gesture had _thought_
60
60
  the touch was a part of it, but turned out to be incorrect), the release(touch) method releases
61
61
  it back to the view.
62
-
62
+
63
63
  Exclusivity
64
64
  ---------------------------------
65
65
  The concept described above gives the gestures a way to be either exclusive or inclusive as-needed:
66
66
  they can choose to take exclusive control of a touch if they think it is theirs, but if they are
67
67
  not sure, they can wait and see.
68
-
68
+
69
69
  Status Object
70
70
  ---------------------------------
71
71
  It is a common need to track some data related to the touch, but without modifying the touch itself.
72
72
  SC.Gesture is able to keep track of simple hashes for you, mapping them to the SC.Touch object,
73
73
  so that you can maintain some state related to the touch.
74
-
74
+
75
75
  For instance, you could set status.failed in touchesDragged, if a touch that you previously
76
- thought may have been part of the gesture turned out not to be, and then check for
76
+ thought may have been part of the gesture turned out not to be, and then check for
77
77
  status.failed in touchIsInGesture, returning NO if present. This would cause the touch
78
78
  to never be considered for your gesture again.
79
-
79
+
80
80
  touchIsInGesture is called with the status hash provided in the second argument. You may look
81
81
  up the status hash for a touch at any time by calling this.statusForTouch(touch).
82
-
83
-
82
+
83
+
84
84
  Implementing a Gesture
85
85
  ---------------------------------
86
86
  To write a gesture, you would generally implement the following methods:
87
-
87
+
88
88
  - touchIsInGesture: Return YES when the touch is—or is likely enough to be that you
89
89
  want your gesture to have exclusive control over the touch. You usually do not
90
90
  perform much gesture logic here—instead, you save it for touchStart, which will
91
91
  get called after you return YES from this method.
92
-
92
+
93
93
  - touchStart: Return YES to accept control of the touch. If you do not return YES,
94
94
  your gesture will not receive touchesDragged nor touchEnd events. At this point,
95
95
  you may (or may not) wish to tell the view that the gesture has started by using the
96
96
  start(args...) method.
97
-
97
+
98
98
  - touchesDragged: Use this as you would use it in an SC.View to track the touches
99
99
  assigned to the gesture. At this point, you might want to tell the view that the
100
100
  gesture has updated by using the change(args...) method.
101
-
101
+
102
102
  - touchEnd: Again, use this like you would in an SC.View to track when touches
103
103
  assigned to the gesture have ended. This is also a potential time to alert the view
104
104
  that the gesture has ended, by using the end(args...) method. Further, this may
105
105
  also be the time to "trigger" the gesture.
106
-
106
+
107
107
  */
108
108
  SC.Gesture = SC.Object.extend({
109
+
110
+ /** @private Tracks when the gesture is active or not. */
111
+ _sc_isActive: false,
112
+
113
+ /**
114
+ Whether to receive touch events for each distinct touch (rather than only the first touch start
115
+ and last touch end).
116
+
117
+ @type Boolean
118
+ @default false
119
+ @see SC.View#acceptsMultitouch
120
+ */
121
+ acceptsMultitouch: false,
122
+
109
123
  /**
110
124
  The gesture's name. When calling events on the owning SC.View, this name will
111
125
  be prefixed to the methods. For instance, if the method to be called is
112
126
  'Start', and the gesture's name is 'swipe', SC.Gesture will call 'swipeStart'.
127
+
128
+ @type String
129
+ @default "gesture"
113
130
  */
114
131
  name: "gesture",
115
132
 
@@ -117,102 +134,140 @@ SC.Gesture = SC.Object.extend({
117
134
  Return YES to take exclusive control over the touch. In addition to the
118
135
  SC.Touch object you may take control of, you are also provided a "status"
119
136
  hash, which is unique for both the gesture instance and the touch instance,
120
- which you may use for your own purposes.
137
+ which you may use for your own purposes.
138
+
139
+ @param {SC.Touch} touch The touch.
140
+ @param {Object} status A unique status hash for the given touch.
141
+ @returns {Boolean} true if the gesture should claim the touch; false to leave it unclaimed.
121
142
  */
122
143
  touchIsInGesture: function(touch, status) {
123
144
  return NO;
124
145
  },
125
-
146
+
126
147
  /**
127
148
  After you return YES from touchIsInGesture (or otherwise 'take' a touch, perhaps
128
149
  using the 'take' method), touchStart will be called.
129
-
150
+
130
151
  This is where you do any logic needed now that the touch is part of the gesture.
131
152
  For instance, you could inform the view that the gesture has started by calling
132
153
  this.start().
133
-
154
+
134
155
  NOTE: SC.Gesture is just like SC.View in that it has an acceptsMultitouch property.
135
156
  If NO (the default), the gesture will only receive touchStart for the first touch
136
157
  assigned to it, and only receive touchEnd for the last touch that ends.
158
+
159
+ @param {SC.Touch} touch The touch that started.
160
+ @returns {Boolean} true if the gesture should respond to the touch; false otherwise (this should always return true)
161
+ @see SC.ResponderProtocol#touchStart
137
162
  */
138
163
  touchStart: function(touch) {
139
-
164
+ return true;
140
165
  },
141
-
142
- /**
143
- Called when touches assigned to the gesture have moved.
144
-
145
- This is where you update the gesture's state, potentially calling change() to
146
- notify the view.
147
- */
148
- touchesDragged: function(evt, touches) {
149
-
150
- },
151
-
166
+
152
167
  /**
153
168
  Called when a touch assigned to the gesture ends.
154
-
169
+
155
170
  If there are no remaining touches on the gesture, you may want to call end() to
156
171
  notify the view that the gesture has ended (if you haven't ended the gesture
157
172
  already).
158
-
173
+
159
174
  NOTE: SC.Gesture is just like SC.View in that it has an acceptsMultitouch property.
160
175
  If NO (the default), the gesture will only receive touchStart for the first touch
161
176
  assigned to it, and only receive touchEnd for the last touch that ends.
177
+
178
+ @name touchEnd
179
+ @function
180
+ @param {SC.Touch} touch The touch that ended.
162
181
  */
163
- touchEnd: function(touch) {
164
-
165
- },
166
-
182
+
167
183
  /**
168
184
  Starts the gesture (marking it as "active"), and notifies the view.
169
-
185
+
170
186
  You can pass any number of arguments to start. They will, along with
171
- the gesture instance itself, will be passed to the appropriate gesture
187
+ the gesture instance itself, will be passed to the appropriate gesture
172
188
  event on the SC.View.
173
189
  */
174
190
  start: function() {
175
- if (!this.get("isActive")) {
176
- this.set("isActive", YES);
177
-
178
- var args = SC.$A(arguments);
179
- args.unshift(this);
180
-
191
+ if (!this._sc_isActive) {
192
+ this._sc_isActive = true;
193
+
194
+ // var argumentsLength = arguments.length,
195
+ // args = new Array(argumentsLength + 1);
196
+
197
+ // // Unshift this to the front of arguments.
198
+ // args[0] = this;
199
+ // for (var i = 0, len = argumentsLength; i < len; i++) { args[i + 1] = arguments[i]; }
200
+
201
+ // var act = this.name + "Start";
202
+ // if (this.view[act]) this.view[act].apply(this.view, args);
203
+
204
+ // Fast arguments access. Don't materialize the `arguments` object, it is costly.
205
+ var argumentsLength = arguments.length,
206
+ args = new Array(argumentsLength);
207
+
208
+ for (var i = 0, len = argumentsLength; i < len; i++) { args[i] = arguments[i]; }
209
+
181
210
  var act = this.name + "Start";
182
211
  if (this.view[act]) this.view[act].apply(this.view, args);
183
212
  }
184
213
  },
185
-
214
+
186
215
  /**
187
216
  Ends the gesture, if it is active (marking it as not active), and notifies
188
217
  the view.
189
-
218
+
190
219
  You may pass any number of arguments to end(). They, along with your gesture
191
220
  instance itself, will be passed to the appropriate gesture event on the SC.View.
192
221
  */
193
222
  end: function() {
194
- if (this.get("isActive")) {
195
- this.set("isActive", NO);
223
+ if (this._sc_isActive) {
224
+ this._sc_isActive = false;
225
+
226
+ // var argumentsLength = arguments.length,
227
+ // args = new Array(argumentsLength + 1);
228
+
229
+ // // Unshift this to the front of arguments.
230
+ // args[0] = this;
231
+ // for (var i = 0, len = argumentsLength; i < len; i++) { args[i + 1] = arguments[i]; }
232
+
233
+ // var act = this.name + "End";
234
+ // if (this.view[act]) this.view[act].apply(this.view, args);
235
+
236
+ // Fast arguments access. Don't materialize the `arguments` object, it is costly.
237
+ var argumentsLength = arguments.length,
238
+ args = new Array(argumentsLength);
239
+
240
+ for (var i = 0, len = argumentsLength; i < len; i++) { args[i] = arguments[i]; }
196
241
 
197
- var args = SC.$A(arguments);
198
- args.unshift(this);
199
-
200
242
  var act = this.name + "End";
201
243
  if (this.view[act]) this.view[act].apply(this.view, args);
202
244
  }
203
245
  },
204
-
246
+
205
247
  /**
206
248
  If the gesture is active, notifies the view that the gesture has
207
249
  changed.
208
-
250
+
209
251
  The gesture, along with any arguments to change(), will be passed to
210
252
  the appropriate method on the SC.View.
211
253
  */
212
254
  change: function() {
213
- if (this.get('isActive')) {
214
- var args = SC.$A(arguments);
215
- args.unshift(this);
255
+ if (this._sc_isActive) {
256
+ // var argumentsLength = arguments.length,
257
+ // args = new Array(argumentsLength + 1);
258
+
259
+ // // Unshift this to the front of arguments.
260
+ // args[0] = this;
261
+ // for (var i = 0, len = argumentsLength; i < len; i++) { args[i + 1] = arguments[i]; }
262
+
263
+ // var act = this.name + "Changed";
264
+ // if (this.view[act]) this.view[act].apply(this.view, args);
265
+
266
+ // Fast arguments access. Don't materialize the `arguments` object, it is costly.
267
+ var argumentsLength = arguments.length,
268
+ args = new Array(argumentsLength);
269
+
270
+ for (var i = 0, len = argumentsLength; i < len; i++) { args[i] = arguments[i]; }
216
271
 
217
272
  var act = this.name + "Changed";
218
273
  if (this.view[act]) this.view[act].apply(this.view, args);
@@ -222,142 +277,188 @@ SC.Gesture = SC.Object.extend({
222
277
  /**
223
278
  Cancels the gesture, if it is active, and notifies the view that the
224
279
  gesture has been cancelled.
225
-
280
+
226
281
  Gestures are cancelled when they have ended, but any action that would
227
282
  normally be appropriate due to their ending should not be performed.
228
-
283
+
229
284
  The gesture, along with any arguments to cancel(), will be passed to the
230
285
  appropriate method on the SC.View.
231
286
  */
232
287
  cancel: function(){
233
- if (this.get('isActive')) {
234
- this.set('isActive', NO);
288
+ if (this._sc_isActive) {
289
+ this._sc_isActive = false;
290
+
291
+ // var argumentsLength = arguments.length,
292
+ // args = new Array(argumentsLength + 1);
235
293
 
236
- var args = SC.$A(arguments);
237
- args.unshift(this);
294
+ // // Unshift this to the front of arguments.
295
+ // args[0] = this;
296
+ // for (var i = 0, len = argumentsLength; i < len; i++) { args[i + 1] = arguments[i]; }
297
+
298
+ // var act = this.name + "Cancelled";
299
+ // if (this.view[act]) this.view[act].apply(this.view, args);
300
+
301
+ // Fast arguments access. Don't materialize the `arguments` object, it is costly.
302
+ var argumentsLength = arguments.length,
303
+ args = new Array(argumentsLength);
304
+
305
+ for (var i = 0, len = argumentsLength; i < len; i++) { args[i] = arguments[i]; }
238
306
 
239
307
  var act = this.name + "Cancelled";
240
308
  if (this.view[act]) this.view[act].apply(this.view, args);
241
309
  }
242
310
  },
243
-
311
+
244
312
  /**
245
313
  Triggers the gesture, notifying the view that the gesture has happened.
246
-
314
+
247
315
  You should trigger a gesture where it would be natural to say it has "happened";
248
316
  for instance, if a touch moves a couple of pixels, you probably wouldn't say
249
317
  a swipe has occurred—though you might say it has "begun." And you wouldn't necessarily
250
318
  wait until the touch has ended either. Once the touch has moved a certain amount,
251
319
  there has definitely been a swipe. By calling trigger() at this point, you will
252
320
  tell the view that it has occurred.
253
-
254
- For SC.SwipeGesture, this allows a view to implement only swipe(), and then be
321
+
322
+ For SC.SwipeGesture, this allows a view to implement only swipe(), and then be
255
323
  automatically notified whenever any swipe has occurred.
256
324
  */
257
325
  trigger: function() {
258
- var args = SC.$A(arguments);
259
- args.unshift(this);
260
-
326
+ // Fast arguments access. Don't materialize the `arguments` object, it is costly.
327
+ var argumentsLength = arguments.length,
328
+ // args = new Array(argumentsLength + 1);
329
+ args = new Array(argumentsLength);
330
+
331
+ // // Unshift this to the front of arguments.
332
+ // args[0] = this;
333
+ // for (var i = 0, len = argumentsLength; i < len; i++) { args[i + 1] = arguments[i]; }
334
+
335
+ for (var i = 0, len = argumentsLength; i < len; i++) { args[i] = arguments[i]; }
336
+
261
337
  var act = this.name;
262
338
  if (this.view[act]) this.view[act].apply(this.view, args);
263
339
  },
264
340
 
265
341
  /**
266
- Takes possession of a touch. This does not take effect immediately; it takes effect after
267
- the run loop finishes to prevent it from being called during another makeTouchResponder.
268
-
342
+ Takes possession of a touch.
343
+
269
344
  This is called automatically when you return YES from touchIsInGesture.
270
345
  */
271
- take: function(touch) {
272
- touch.isTaken = YES; // because even changing responder won't prevent it from being used this cycle.
273
- if (SC.none(touch.touchResponder) || touch.touchResponder !== this) touch.makeTouchResponder(this, YES);
274
- },
275
-
346
+ // take: function(touch) {
347
+ // if (!touch.isTaken) {
348
+ // touch.isTaken = YES; // because even changing responder won't prevent it from being used this cycle.
349
+ // if (SC.none(touch.touchResponder) || touch.touchResponder !== this) touch.makeTouchResponder(this, YES);
350
+ // }
351
+ // //@if(debug)
352
+ // else {
353
+ // SC.warn("Developer Warning: A gesture tried to take a touch that was already taken: %@".fmt(this));
354
+ // }
355
+ // //@endif
356
+ // },
357
+
276
358
  /**
277
359
  Releases a touch back to its previous owner, which is usually the view. This allows
278
- you to give back control of a touch that it turns out is not part of the gesture.
279
-
360
+ you to give back control of a touch that it turns out is not part of the gesture.
361
+
280
362
  This takes effect immediately, because you would usually call this from
281
363
  touchesDragged or such.
282
364
  */
283
- release: function(touch) {
284
- touch.isTaken = NO;
285
- if (touch.nextTouchResponder) touch.makeTouchResponder(touch.nextTouchResponder);
286
- },
287
-
365
+ // release: function(touch) {
366
+ // if (touch.isTaken) {
367
+ // touch.isTaken = NO;
368
+ // if (touch.nextTouchResponder) touch.makeTouchResponder(touch.nextTouchResponder);
369
+ // }
370
+ // //@if(debug)
371
+ // else {
372
+ // SC.warn("Developer Warning: A gesture tried to release a touch that was not taken: %@".fmt(this));
373
+ // }
374
+ // //@endif
375
+ // },
376
+
288
377
  /**
289
378
  Discards a touch, making its responder null. This makes the touch go away and never
290
379
  come back—not to this gesture, nor to any other, nor to the view, nor to any other
291
380
  view.
292
381
  */
293
- discardTouch: function(touch) {
294
- touch.isTaken = YES; // because even changing responder won't prevent it from being used this cycle.
295
- touch.makeTouchResponder(null);
382
+ // discardTouch: function(touch) {
383
+ // touch.isTaken = YES; // because even changing responder won't prevent it from being used this cycle.
384
+ // touch.makeTouchResponder(null);
385
+ // },
386
+
387
+ /**
388
+ Called by the view when a touch session has begun.
389
+
390
+ You should override this method in your custom SC.Gesturable subclasses to set up any touch
391
+ session state. For example, you may want to track the initial touch start time in order to
392
+ decide how to react when or if additional touches start later.
393
+
394
+ @param {SC.Touch} touch The touch that started the session.
395
+ @returns {void}
396
+ */
397
+ touchSessionStarted: function (touch) {
296
398
  },
297
-
399
+
298
400
  /**
299
- Returns a status hash (which gestures may and should modify) for a given touch, for tracking
300
- whether it is a potential match, etc.
301
- */
302
- statusForTouch: function(touch) {
303
- var key = SC.guidFor(touch.view) + this.name;
304
- var status = touch[key];
305
- if (!status) status = touch[key] = {};
306
- return status;
401
+ Called by the view when the touch session has ended.
402
+
403
+ This will occur because all touches in the session have finished.
404
+
405
+ You should override this method in your custom SC.Gesturable subclasses to clean up any state
406
+ variables used in the touch session.
407
+
408
+ @returns {void}
409
+ */
410
+ touchSessionEnded: function () {
307
411
  },
308
-
412
+
309
413
  /**
310
- Called when an unassigned touch has started. By default, this calls touchIsInGesture, and,
311
- if it returns YES, takes possesion of the touch (causing touchStart to be called).
312
- */
313
- unassignedTouchDidStart: function(touch) {
314
- if (touch.isTaken) return;
315
- if (this.touchIsInGesture(touch, this.statusForTouch(touch))) {
316
- this.take(touch);
317
- }
414
+ Called by the view when the touch session was cancelled.
415
+
416
+ This will occur because this gesture returned `false` in any of `touchAddedToSession`,
417
+ `touchesMovedInSession`, `touchEndedInSession`, `touchCancelledInSession` to indicate that the
418
+ gesture is no longer interested in the session or because another gesture claimed the touch
419
+ session for itself, forcing all other gestures out (rare).
420
+
421
+ You should override this method in your custom SC.Gesturable subclasses to clean up any state
422
+ variables used in the touch session.
423
+
424
+ @returns {void}
425
+ */
426
+ touchSessionCancelled: function () {
318
427
  },
319
-
428
+
320
429
  /**
321
- This is called when the unassigned touches (touches not in a gesture) change or move
322
- in some way. By default, this calls touchIsInGesture(touch, status) for each touch.
323
- */
324
- unassignedTouchesDidChange: function(evt, touches) {
325
- touches.forEach(function(touch) {
326
- if (touch.isTaken) return;
327
- if (this.touchIsInGesture(touch, this.statusForTouch(touch))) {
328
- this.take(touch);
329
- }
330
- }, this);
430
+ @param {SC.Touch} touch The touch to be added to the session.
431
+ @param {Array} touchesInSession The touches already in the session.
432
+ @returns {Boolean} True if the gesture is still interested in the touch session; false to stop getting notified for any further touch changes in the touch session.
433
+ */
434
+ touchAddedToSession: function (touch, touchesInSession) {
435
+ return true; // Most gestures should theoretically be interested in a new touch session.
331
436
  },
332
-
437
+
333
438
  /**
334
- This is called when the unassigned touches (touches not in the gesture) have ended.
335
- Default does nothing. Some gestures may want to implement this even if they don't implement
336
- unassignedTouchesDidChange.
337
- */
338
- unassignedTouchDidEnd: function(touch) {
339
-
439
+ @param {SC.Touch} touch The touch to be removed from the session.
440
+ @param {Array} touchesInSession The touches still remaining in the session.
441
+ @returns {Boolean} True if the gesture is still interested in the touch session; false to stop getting notified for any further touch changes in the touch session.
442
+ */
443
+ touchCancelledInSession: function (touch, touchesInSession) {
444
+ return true;
340
445
  },
341
-
446
+
342
447
  /**
343
- Marks the touch as "interesting" to this gesture. A view could then check the 'isInteresting'
344
- property of the touch to see if any gestures are interested in it, potentially delaying any
345
- action of releasing the touch to another view.
346
- */
347
- interestedInTouch: function(touch) {
348
- var status = this.statusForTouch(touch);
349
- if (status.isInterested) return;
350
- status.isInterested = YES;
351
- touch.isInteresting++;
448
+ @param {SC.Touch} touch The touch to be removed from the session.
449
+ @param {Array} touchesInSession The touches still remaining in the session.
450
+ @returns {Boolean} True if the gesture is still interested in the touch session; false to stop getting notified for any further touch changes in the touch session.
451
+ */
452
+ touchEndedInSession: function (touch, touchesInSession) {
453
+ return true;
352
454
  },
353
-
455
+
354
456
  /**
355
- Marks the touch as "uninteresting" to this gesture.
356
- */
357
- uninterestedInTouch: function(touch) {
358
- var status = this.statusForTouch(touch);
359
- if (!status.isInterested) return;
360
- status.isInterested = NO;
361
- touch.isInteresting--;
457
+ @param {Array} touchesInSession The touches in the session.
458
+ @returns {Boolean} True if the gesture is still interested in the touch session; false to stop getting notified for any further touch changes in the touch session.
459
+ */
460
+ touchesMovedInSession: function (touchesInSession) {
461
+ return true;
362
462
  }
463
+
363
464
  });