sproutcore 1.11.0.rc1 → 1.11.0.rc2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (42) hide show
  1. checksums.yaml +8 -8
  2. data/VERSION.yml +1 -1
  3. data/lib/frameworks/sproutcore/CHANGELOG.md +93 -65
  4. data/lib/frameworks/sproutcore/apps/showcase/controllers/source_tree_controller.js +17 -7
  5. data/lib/frameworks/sproutcore/apps/showcase/resources/main_page.js +22 -2
  6. data/lib/frameworks/sproutcore/apps/showcase/resources/stylesheet.css +14 -0
  7. data/lib/frameworks/sproutcore/apps/showcase/resources/views_page.js +2 -2
  8. data/lib/frameworks/sproutcore/frameworks/ajax/system/request.js +20 -8
  9. data/lib/frameworks/sproutcore/frameworks/ajax/system/websocket.js +58 -43
  10. data/lib/frameworks/sproutcore/frameworks/core_foundation/mixins/action_support.js +192 -35
  11. data/lib/frameworks/sproutcore/frameworks/core_foundation/mixins/delegate_support.js +7 -3
  12. data/lib/frameworks/sproutcore/frameworks/core_foundation/mixins/responder_context.js +27 -7
  13. data/lib/frameworks/sproutcore/frameworks/core_foundation/system/browser.js +20 -63
  14. data/lib/frameworks/sproutcore/frameworks/core_foundation/system/color.js +16 -7
  15. data/lib/frameworks/sproutcore/frameworks/core_foundation/system/event.js +279 -159
  16. data/lib/frameworks/sproutcore/frameworks/core_foundation/system/render_context.js +1 -1
  17. data/lib/frameworks/sproutcore/frameworks/core_foundation/system/root_responder.js +21 -10
  18. data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/mixins/action_support.js +32 -28
  19. data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/system/root_responder/targetForAction.js +107 -90
  20. data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/system/root_responder/touch.js +33 -25
  21. data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/system/touch.js +23 -15
  22. data/lib/frameworks/sproutcore/frameworks/core_foundation/views/view/animation.js +1 -1
  23. data/lib/frameworks/sproutcore/frameworks/core_foundation/views/view/layout.js +12 -6
  24. data/lib/frameworks/sproutcore/frameworks/core_foundation/views/view/layout_style.js +55 -33
  25. data/lib/frameworks/sproutcore/frameworks/datastore/system/store.js +7 -1
  26. data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/scroll/methods.js +228 -72
  27. data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/scroll/touch.js +54 -100
  28. data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/segmented/ui.js +15 -0
  29. data/lib/frameworks/sproutcore/frameworks/desktop/views/button.js +57 -45
  30. data/lib/frameworks/sproutcore/frameworks/desktop/views/collection.js +9 -16
  31. data/lib/frameworks/sproutcore/frameworks/desktop/views/scroll_view.js +111 -44
  32. data/lib/frameworks/sproutcore/frameworks/desktop/views/segmented.js +2 -0
  33. data/lib/frameworks/sproutcore/frameworks/foundation/system/module.js +51 -5
  34. data/lib/frameworks/sproutcore/frameworks/runtime/core.js +2 -2
  35. data/lib/frameworks/sproutcore/frameworks/runtime/mixins/observable.js +13 -10
  36. data/lib/frameworks/sproutcore/frameworks/runtime/system/index_set.js +2 -1
  37. data/lib/frameworks/sproutcore/frameworks/runtime/system/object.js +28 -9
  38. data/lib/frameworks/sproutcore/frameworks/runtime/system/set.js +7 -5
  39. data/lib/frameworks/sproutcore/frameworks/statechart/ext/function.js +51 -46
  40. data/lib/frameworks/sproutcore/frameworks/statechart/system/state.js +8 -5
  41. data/lib/frameworks/sproutcore/frameworks/statechart/system/statechart.js +12 -3
  42. metadata +2 -2
@@ -79,8 +79,11 @@ module("SC.ScrollView touch", {
79
79
  evt.pageY = 50;
80
80
  evt.changedTouches = [evt];
81
81
  },
82
+
82
83
  teardown: function() {
83
84
  SC.run(pane.destroy, pane);
85
+
86
+ pane = scrollView = inner = targetLayer = evt = null;
84
87
  }
85
88
  });
86
89
 
@@ -89,25 +92,19 @@ module("SC.ScrollView touch", {
89
92
  // but since there was no scroll, it will give inner views a chance to respond to it on touchEnd.
90
93
  test("Tapping with delaysContentTouches: YES", function() {
91
94
  // Trigger touchstart
92
- SC.run(function() {
93
- SC.Event.trigger(targetLayer, 'touchstart', [evt]);
94
- });
95
+ SC.Event.trigger(targetLayer, 'touchstart', evt);
95
96
 
96
97
  equals(scrollStart, 1, "After touchstart, the scroll view's touchStart should have been called once");
97
98
  equals(innerStart, 0, "After touchstart, the inner view's touchStart should not have been called, as the touch was captured by the scroll view");
98
99
 
99
100
  // Trigger touchmove:
100
- SC.run(function() {
101
- SC.Event.trigger(targetLayer, 'touchmove', [evt]);
102
- });
101
+ SC.Event.trigger(targetLayer, 'touchmove', evt);
103
102
 
104
103
  equals(scrollDragged, 1, "After touchmove, the scroll view's touchesDragged should have been called once");
105
104
  equals(innerDragged, 0, "After touchmove, the inner view's touchesDragged should not have been called, as the touch is still owned by the scroll view");
106
105
 
107
106
  // Trigger touchend:
108
- SC.run(function() {
109
- SC.Event.trigger(targetLayer, 'touchend', [evt]);
110
- });
107
+ SC.Event.trigger(targetLayer, 'touchend', evt);
111
108
 
112
109
  equals(scrollEnd, 1, "After touchend, the scroll view's touchEnd should have been called once");
113
110
  equals(innerStart, 1, "Once the scroll view has handled touchEnd, it passes the touch to the inner view, so innerStart should have run");
@@ -120,9 +117,7 @@ test("Tapping with delaysContentTouches: YES", function() {
120
117
  // touch, and since there was a scroll, the inner view will not receive any notifications whatsoever.
121
118
  test("Dragging with delaysContentTouches: YES", function() {
122
119
  // Trigger touchstart
123
- SC.run(function() {
124
- SC.Event.trigger(targetLayer, 'touchstart', [evt]);
125
- });
120
+ SC.Event.trigger(targetLayer, 'touchstart', evt);
126
121
 
127
122
  equals(scrollStart, 1, "After touchstart, the scroll view's touchStart should have been called once");
128
123
  equals(innerStart, 0, "After touchstart, the inner view's touchStart should not have been called, as the touch was captured by the scroll view");
@@ -130,17 +125,13 @@ test("Dragging with delaysContentTouches: YES", function() {
130
125
  // Give the event some vertical delta:
131
126
  evt.pageY += 16;
132
127
  // Trigger touchmove:
133
- SC.run(function() {
134
- SC.Event.trigger(targetLayer, 'touchmove', [evt]);
135
- });
128
+ SC.Event.trigger(targetLayer, 'touchmove', evt);
136
129
 
137
130
  equals(scrollDragged, 1, "After touchmove, the scroll view's touchesDragged should have been called once");
138
131
  equals(innerDragged, 0, "After touchmove, the inner view's touchesDragged should not have been called, as the touch is still owned by the scroll view");
139
132
 
140
133
  // Trigger touchend:
141
- SC.run(function() {
142
- SC.Event.trigger(targetLayer, 'touchend', [evt]);
143
- });
134
+ SC.Event.trigger(targetLayer, 'touchend', evt);
144
135
 
145
136
  equals(scrollEnd, 1, "After touchend, the scroll view's touchEnd should have been called once");
146
137
  equals(innerStart, 0, "inner view's touchStart will not have run, as the touch has moved enough to begin scrolling and will bypass the inner view entirely");
@@ -154,25 +145,19 @@ test("Tapping with delaysContentTouches: NO", function() {
154
145
  scrollView.set('delaysContentTouches', NO);
155
146
 
156
147
  // Trigger touchstart
157
- SC.run(function() {
158
- SC.Event.trigger(targetLayer, 'touchstart', [evt]);
159
- });
148
+ SC.Event.trigger(targetLayer, 'touchstart', evt);
160
149
 
161
150
  equals(scrollStart, 0, "We're not capturing touches, so scroll view's touchStart will not have fired after touchstart");
162
151
  equals(innerStart, 1, "After touchstart, inner view's touchStart will have been called once");
163
152
 
164
153
  // Trigger touchmove:
165
- SC.run(function() {
166
- SC.Event.trigger(targetLayer, 'touchmove', [evt]);
167
- });
154
+ SC.Event.trigger(targetLayer, 'touchmove', evt);
168
155
 
169
156
  equals(scrollDragged, 0, "Scroll view's touchesDragged will not have fired, as it is not the touch responder");
170
157
  equals(innerDragged, 1, "After touchmove, inner view's touchDragged gets straightforwardly called because it is the touch responder");
171
158
 
172
159
  // Trigger touchend:
173
- SC.run(function() {
174
- SC.Event.trigger(targetLayer, 'touchend', [evt]);
175
- });
160
+ SC.Event.trigger(targetLayer, 'touchend', evt);
176
161
 
177
162
  equals(scrollEnd, 0, "Again, the scroll view is completely uninvolved in this touch, so its touchEnd doesn't get called");
178
163
  equals(innerEnd, 1, "The inner view's touchEnd gets called because of how it's responding to the touch");
@@ -186,9 +171,7 @@ test("Dragging with delaysContentTouches: NO", function() {
186
171
  scrollView.set('delaysContentTouches', NO);
187
172
 
188
173
  // Trigger touchstart
189
- SC.run(function() {
190
- SC.Event.trigger(targetLayer, 'touchstart', [evt]);
191
- });
174
+ SC.Event.trigger(targetLayer, 'touchstart', evt);
192
175
 
193
176
  equals(scrollStart, 0, "Since the scroll view isn't capturing touches, it gets no touchStart love");
194
177
  equals(innerStart, 1, "After touchstart, the inner view's touchStart should have been straightforwardly called");
@@ -196,9 +179,7 @@ test("Dragging with delaysContentTouches: NO", function() {
196
179
  // Give the event some vertical delta:
197
180
  evt.pageY += 16;
198
181
  // Trigger touchmove:
199
- SC.run(function() {
200
- SC.Event.trigger(targetLayer, 'touchmove', [evt]);
201
- });
182
+ SC.Event.trigger(targetLayer, 'touchmove', evt);
202
183
 
203
184
  equals(scrollDragged, 0, "The scroll view's touchDragged should not have been called, since at the time of the event it was not the touch's responder");
204
185
  equals(innerDragged, 1, "The inner view's touchesDragged should have straightforwardly handled the event");
@@ -206,9 +187,7 @@ test("Dragging with delaysContentTouches: NO", function() {
206
187
  equals(innerCancel, 1, "Having passed the touch back to the scroll view, the inner view's touchCancelled should have run");
207
188
 
208
189
  // Trigger touchend:
209
- SC.run(function() {
210
- SC.Event.trigger(targetLayer, 'touchend', [evt]);
211
- });
190
+ SC.Event.trigger(targetLayer, 'touchend', evt);
212
191
 
213
192
  equals(scrollEnd, 1, "After touchend, the scroll view's touchEnd should have been called once");
214
193
  });
@@ -259,13 +238,13 @@ module("SC.ScrollView touch thresholds and locks", {
259
238
 
260
239
  // // Start touch
261
240
  // SC.run(function() {
262
- // SC.Event.trigger(targetLayer, 'touchstart', [evt]);
241
+ // SC.Event.trigger(targetLayer, 'touchstart', evt);
263
242
  // });
264
243
 
265
244
  // // Move touch up less than touchScrollThreshold.
266
245
  // evt.pageY = initialPageY - 9;
267
246
  // SC.run(function() {
268
- // SC.Event.trigger(targetLayer, 'touchmove', [evt]);
247
+ // SC.Event.trigger(targetLayer, 'touchmove', evt);
269
248
  // });
270
249
  // equals(scrollView.get('verticalScrollOffset'), 0, "Scrolling less than touchScrollThreshold results in no scrolling");
271
250
  // if (scrollView.get('horizontalScrollOffset') !== 0) ok(false, "A touch with no horizontal change shouldn't trigger a horizontal scroll!");
@@ -273,7 +252,7 @@ module("SC.ScrollView touch thresholds and locks", {
273
252
  // // Move touch up more than touchScrollThreshold.
274
253
  // evt.pageY = initialPageY - 11;
275
254
  // SC.run(function() {
276
- // SC.Event.trigger(targetLayer, 'touchmove', [evt]);
255
+ // SC.Event.trigger(targetLayer, 'touchmove', evt);
277
256
  // });
278
257
  // equals(scrollView.get('verticalScrollOffset'), 11, "Scrolling more than touchScrollThreshold results in scrolling");
279
258
  // if (scrollView.get('horizontalScrollOffset') !== 0) ok(false, "A touch with no horizontal change shouldn't trigger a horizontal scroll!");
@@ -281,7 +260,7 @@ module("SC.ScrollView touch thresholds and locks", {
281
260
  // // Move touch sideways less than touchSecondaryScrollThreshold.
282
261
  // evt.pageX = initialPageX - 19;
283
262
  // SC.run(function() {
284
- // SC.Event.trigger(targetLayer, 'touchmove', [evt]);
263
+ // SC.Event.trigger(targetLayer, 'touchmove', evt);
285
264
  // });
286
265
  // if (scrollView.get('verticalScrollOffset') !== 11) ok(false, "A touch with no vertical change shouldn't trigger a vertical scroll!");
287
266
  // equals(scrollView.get('horizontalScrollOffset'), 0, "With a vertical scroll in motion, scrolling horizontally less than touchSecondaryScrollThreshold results in no scrolling");
@@ -289,7 +268,7 @@ module("SC.ScrollView touch thresholds and locks", {
289
268
  // // Move touch sideways more than touchSecondaryScrollThreshold.
290
269
  // evt.pageX = initialPageX - 21;
291
270
  // SC.run(function() {
292
- // SC.Event.trigger(targetLayer, 'touchmove', [evt]);
271
+ // SC.Event.trigger(targetLayer, 'touchmove', evt);
293
272
  // });
294
273
  // if (scrollView.get('verticalScrollOffset') !== 11) ok(false, "A touch with no vertical change shouldn't trigger a vertical scroll!");
295
274
  // equals(scrollView.get('horizontalScrollOffset'), 21, "With a vertical scroll in motion, scrolling horizontally by more than touchSecondaryScrollThreshold results in scrolling");
@@ -301,26 +280,21 @@ test("Touch scroll lock", function() {
301
280
  equals(scrollView.get('horizontalScrollOffset'), 0, "PRELIM: Horizontal offset starts at");
302
281
 
303
282
  // Start touch
304
- SC.run(function() {
305
- SC.Event.trigger(targetLayer, 'touchstart', [evt]);
306
- });
283
+ SC.Event.trigger(targetLayer, 'touchstart', evt);
307
284
 
308
285
  // Move touch up more than touchSecondaryScrollLock.
309
286
  evt.pageY = initialPageY - SC.SCROLL.SCROLL_LOCK_GESTURE_THRESHOLD;
310
- SC.run(function() {
311
- SC.Event.trigger(targetLayer, 'touchmove', [evt]);
312
- });
287
+ SC.Event.trigger(targetLayer, 'touchmove', evt);
288
+
313
289
  equals(scrollView.get('verticalScrollOffset'), SC.SCROLL.SCROLL_LOCK_GESTURE_THRESHOLD, "PRELIM: Scrolling more than touchScrollThreshold results in scrolling");
314
290
  equals(scrollView.get('horizontalScrollOffset'), 0, "A touch with no horizontal change shouldn't trigger a horizontal scroll!");
315
291
 
316
292
  // Move touch sideways.
317
293
  evt.pageX = initialPageX - 50;
318
- SC.run(function() {
319
- SC.Event.trigger(targetLayer, 'touchmove', [evt]);
320
- });
294
+ SC.Event.trigger(targetLayer, 'touchmove', evt);
295
+
321
296
  equals(scrollView.get('verticalScrollOffset'), SC.SCROLL.SCROLL_LOCK_GESTURE_THRESHOLD, "A touch with no vertical change shouldn't trigger a vertical scroll!");
322
297
  equals(scrollView.get('horizontalScrollOffset'), 0, "Having scrolled vertically past the scrollGestureSecondaryThreshold, horizontal touch movements are ignored");
323
-
324
298
  });
325
299
 
326
300
  module("SC.ScrollView touch scale", {
@@ -388,19 +362,16 @@ test("Basic touch scale", function() {
388
362
  // Start touches.
389
363
  evt.touches = [];
390
364
  evt.changedTouches = [evt, evt2];
391
- SC.run(function() {
392
- SC.Event.trigger(targetLayer, 'touchstart', [evt]);
393
- });
365
+ SC.Event.trigger(targetLayer, 'touchstart', evt);
366
+
394
367
  equals(SC.RootResponder.responder.touchesForView(scrollView).length, 2, "Two touches should result in two touches");
395
368
 
396
369
  // Pinch out to 2x.
397
- evt.touches = [evt, evt2];
398
- evt.changedTouches = [evt, evt2];
399
370
  evt.pageX = evt.pageY -= 100;
400
371
  evt2.pageX = evt2.pageY += 100;
401
- SC.run(function() {
402
- SC.Event.trigger(targetLayer, 'touchmove', [evt]);
403
- });
372
+ evt.touches = [evt, evt2];
373
+ // evt.changedTouches = [touch1, touch2];
374
+ SC.Event.trigger(targetLayer, 'touchmove', evt);
404
375
 
405
376
  // SC.ScrollView's touch-pinching depends heavily on SC.RootResponder#averagedTouchesForView. If these tests
406
377
  // are misbehaving, first verify that SC.RootResponder's touch tests are passing.
@@ -411,9 +382,7 @@ test("Basic touch scale", function() {
411
382
  // Move the gesture.
412
383
  evt.pageX = evt.pageY += 100;
413
384
  evt2.pageX = evt2.pageY += 100;
414
- SC.run(function() {
415
- SC.Event.trigger(targetLayer, 'touchmove', [evt]);
416
- });
385
+ SC.Event.trigger(targetLayer, 'touchmove', evt);
417
386
 
418
387
  equals(scrollView.get('scale'), 2, "A gesture change with no change in distance should not change scale");
419
388
  equals(scrollView.get('horizontalScrollOffset'), 400, "Gesture change in position by 100 should move offsets by 100");
@@ -422,9 +391,7 @@ test("Basic touch scale", function() {
422
391
  // Move and pinch (back to 1x) in the same gesture.
423
392
  evt.pageX = evt.pageY = 400;
424
393
  evt2.pageX = evt2.pageY = 600;
425
- SC.run(function() {
426
- SC.Event.trigger(targetLayer, 'touchmove', [evt]);
427
- });
394
+ SC.Event.trigger(targetLayer, 'touchmove', evt);
428
395
 
429
396
  equals(scrollView.get('scale'), 1, "A pinch + move gesture should change the scale");
430
397
  equals(scrollView.get('horizontalScrollOffset'), 0, "A pinch + move gesture should update the horizontal offset correctly");
@@ -443,45 +410,38 @@ test("Adding and removing touches (no scaling).", function() {
443
410
  // Start touches.
444
411
  evt.touches = [];
445
412
  evt.changedTouches = [evt, evt2];
446
- SC.run(function() {
447
- SC.Event.trigger(targetLayer, 'touchstart', [evt]);
448
- });
413
+ SC.Event.trigger(targetLayer, 'touchstart', evt);
414
+
449
415
  equals(SC.RootResponder.responder.touchesForView(scrollView).length, 2, "Two touches should result in two touches");
450
416
 
451
- // Update the touch lists.
452
- evt.touches = [evt, evt2];
453
- evt.changedTouches = [evt, evt2];
454
- // Move touches up in tandem.
455
417
  evt.pageY -= 100;
456
418
  evt2.pageY -= 100;
457
- SC.run(function() {
458
- SC.Event.trigger(targetLayer, 'touchmove', [evt]);
459
- });
419
+ evt.touches = [evt, evt2];
420
+ SC.Event.trigger(targetLayer, 'touchmove', evt);
421
+
460
422
  equals(SC.RootResponder.responder.touchesForView(scrollView).length, 2, "There should still be two touches");
461
423
  equals(scrollView.get('scale'), 1, "A two-touch gesture with no pinching should result in no scaling");
462
424
  equals(scrollView.get('horizontalScrollOffset'), 0, "A two-touch vertical scroll gesture should not scroll horizontally");
463
425
  equals(scrollView.get('verticalScrollOffset'), 100, "A two-touch vertical scroll gesture should successfully scroll vertically");
464
426
 
465
427
  // Add a third touch.
466
- evt3.touches = [evt, evt2];
467
- evt3.changedTouches = [evt3];
468
- SC.run(function() {
469
- SC.Event.trigger(targetLayer, 'touchstart', [evt3]);
470
- });
428
+ evt.touches = [evt, evt2];
429
+ evt.changedTouches = [evt3];
430
+ SC.Event.trigger(targetLayer, 'touchstart', evt);
431
+
471
432
  equals(SC.RootResponder.responder.touchesForView(scrollView).length, 3, "Adding a third touch should result in three touches");
472
433
  equals(scrollView.get('scale'), 1, "Adding a third touch should not impact scaling");
473
434
  equals(scrollView.get('horizontalScrollOffset'), 0, "Adding a third touch should not impact horizontal offset");
474
435
  equals(scrollView.get('verticalScrollOffset'), 100, "Adding a third touch should not impact vertical offset");
475
436
 
476
437
  // Move all three touches up in tandem.
477
- evt.touches = [evt, evt2, evt3];
478
- evt.changedTouches = [evt, evt2, evt3];
479
438
  evt.pageY -= 100;
480
439
  evt2.pageY -= 100;
481
440
  evt3.pageY -= 100;
482
- SC.run(function() {
483
- SC.Event.trigger(targetLayer, 'touchmove', [evt]);
484
- });
441
+ evt.touches = [evt, evt2, evt3];
442
+ evt.changedTouches = [evt, evt2, evt3];
443
+ SC.Event.trigger(targetLayer, 'touchmove', evt);
444
+
485
445
  equals(scrollView.get('scale'), 1, "A three-touch gesture with no pinching should result in no scaling");
486
446
  equals(scrollView.get('horizontalScrollOffset'), 0, "A now-three-touch vertical scroll gesture should not scroll horizontally");
487
447
  equals(scrollView.get('verticalScrollOffset'), 200, "A now-three-touch vertical scroll gesture should successfully scroll vertically");
@@ -495,18 +455,15 @@ test("Adding and removing touches while scaling.", function() {
495
455
  // Start touches.
496
456
  evt.touches = [];
497
457
  evt.changedTouches = [evt, evt2];
498
- SC.run(function() {
499
- SC.Event.trigger(targetLayer, 'touchstart', [evt]);
500
- });
458
+ SC.Event.trigger(targetLayer, 'touchstart', evt);
501
459
  equals(SC.RootResponder.responder.touchesForView(scrollView).length, 2, "Two touches should result in two touches");
502
460
 
503
461
  // Pinch out to 2x to begin scaling.
504
462
  evt.touches = [evt, evt2];
505
463
  evt.pageX = evt.pageY = 300;
506
464
  evt2.pageX = evt2.pageY = 700;
507
- SC.run(function() {
508
- SC.Event.trigger(targetLayer, 'touchmove', [evt]);
509
- });
465
+ SC.Event.trigger(targetLayer, 'touchmove', evt);
466
+
510
467
  equals(scrollView.get('scale'), 2, "A 2x pinch gesture should double the scroll's scale");
511
468
  equals(scrollView.get('horizontalScrollOffset'), 500, "A centered pinch gesture should move the horizontal offset by half the content view's change in width");
512
469
  equals(scrollView.get('verticalScrollOffset'), 500, "A centered pinch gesture should move the vertical offset by half the content view's change in height");
@@ -514,9 +471,8 @@ test("Adding and removing touches while scaling.", function() {
514
471
  // Remove our second touch.
515
472
  evt2.touches = [evt, evt2];
516
473
  evt2.changedTouches = [evt2];
517
- SC.run(function() {
518
- SC.Event.trigger(targetLayer, 'touchend', [evt2]);
519
- });
474
+ SC.Event.trigger(targetLayer, 'touchend', evt2);
475
+
520
476
  equals(SC.RootResponder.responder.touchesForView(scrollView).length, 1, "Removing one of two touches should leave one touch");
521
477
  equals(scrollView.get('scale'), 2, "Removing a touch shouldn't change scale");
522
478
  equals(scrollView.get('horizontalScrollOffset'), 500, "Removing a touch shouldn't change the horizontal offset");
@@ -527,9 +483,8 @@ test("Adding and removing touches while scaling.", function() {
527
483
  evt3.changedTouches = [evt3];
528
484
  evt3.pageX = 700;
529
485
  evt3.pageY = 700;
530
- SC.run(function() {
531
- SC.Event.trigger(targetLayer, 'touchstart', [evt3]);
532
- });
486
+ SC.Event.trigger(targetLayer, 'touchstart', evt3);
487
+
533
488
  equals(SC.RootResponder.responder.touchesForView(scrollView).length, 2, "Adding one touch to one touch should result in two touches");
534
489
  equals(scrollView.get('scale'), 2, "Adding a touch shouldn't change scale");
535
490
  equals(scrollView.get('horizontalScrollOffset'), 500, "Adding a touch shouldn't change the horizontal offset");
@@ -540,9 +495,8 @@ test("Adding and removing touches while scaling.", function() {
540
495
  evt.changedTouches = [evt, evt3];
541
496
  evt.pageX = evt.pageY = 400;
542
497
  evt3.pageX = evt3.pageY = 600;
543
- SC.run(function() {
544
- SC.Event.trigger(targetLayer, 'touchmove', [evt]);
545
- });
498
+ SC.Event.trigger(targetLayer, 'touchmove', evt);
499
+
546
500
  equals(scrollView.get('scale'), 1, "Pinching back down by half should reverse doubling of scaling");
547
501
  equals(scrollView.get('horizontalScrollOffset'), 0, "Pinching back down by half should reverse horizontal offset change");
548
502
  equals(scrollView.get('verticalScrollOffset'), 0, "Pinching back down by half should reverse vertical offset change");
@@ -605,5 +605,20 @@ var pane;
605
605
  ok(SC.none(segmentedView.getPath('layout.width')), "Having flexible layout prevents view from auto-resizing.");
606
606
  });
607
607
 
608
+ test("Check adjusting a segment views layout updates its frame", function() {
609
+ var segmentedView;
610
+
611
+ segmentedView = pane.view('3_empty');
612
+
613
+ equals(segmentedView.get('layout').height, 25, '3_empty.layout should have a height of 25');
614
+ equals(segmentedView.get('frame').height, 25, '3_empty.layout should have a height of 25');
615
+
616
+ // adjust the views height
617
+ segmentedView.adjust('height', 30);
618
+
619
+ equals(segmentedView.get('layout').height, 30, '3_empty.layout should have a height of 30');
620
+ equals(segmentedView.get('frame').height, 30, '3_empty.layout should have a height of 30');
621
+ })
622
+
608
623
 
609
624
  })();
@@ -57,7 +57,7 @@ SC.HOLD_BEHAVIOR = 'hold';
57
57
  @extends SC.Control
58
58
  @since SproutCore 1.0
59
59
  */
60
- SC.ButtonView = SC.View.extend(SC.Control,
60
+ SC.ButtonView = SC.View.extend(SC.ActionSupport, SC.Control,
61
61
  /** @scope SC.ButtonView.prototype */ {
62
62
 
63
63
  /**
@@ -71,6 +71,32 @@ SC.ButtonView = SC.View.extend(SC.Control,
71
71
  return NO;
72
72
  }.property('isEnabledInPane'),
73
73
 
74
+ /**
75
+ The name of the method to call when the button is pressed.
76
+
77
+ This property is used in conjunction with the `target` property to execute a method when a
78
+ regular button is pressed. If you do not set a target, then pressing the button will cause a
79
+ search of the responder chain for a view that implements the action named. If you do set a
80
+ target, then the button will only try to call the method on that target.
81
+
82
+ The action method of the target should implement the following signature:
83
+
84
+ action: function (sender) {
85
+ // Return value is ignored by SC.ButtonView.
86
+ }
87
+
88
+ Therefore, if a target needs to know which button called its action, it should look to the
89
+ `sender` argument.
90
+
91
+ *NOTE:* This property is not relevant when the button is used in toggle mode. Toggle mode only
92
+ modifies the `value` of the button without triggering actions.
93
+
94
+ @type String
95
+ @default null
96
+ @see SC.ActionSupport
97
+ */
98
+ action: null,
99
+
74
100
  /**
75
101
  @type Array
76
102
  @default ['sc-button-view']
@@ -93,6 +119,31 @@ SC.ButtonView = SC.View.extend(SC.Control,
93
119
  */
94
120
  escapeHTML: true,
95
121
 
122
+ /**
123
+ The target to invoke the action on when the button is pressed.
124
+
125
+ If you set this target, the action will be called on the target object directly when the button
126
+ is clicked. If you leave this property set to `null`, then the responder chain will be
127
+ searched for a view that implements the action when the button is pressed.
128
+
129
+ The action method of the target should implement the following signature:
130
+
131
+ action: function (sender) {
132
+ // Return value is ignored by SC.ButtonView.
133
+ }
134
+
135
+ Therefore, if a target needs to know which button called its action, it should look to the
136
+ `sender` argument.
137
+
138
+ *NOTE:* This property is not relevant when the button is used in toggle mode. Toggle mode only
139
+ modifies the `value` of the button without triggering actions.
140
+
141
+ @type Object
142
+ @default null
143
+ @see SC.ActionSupport
144
+ */
145
+ target: null,
146
+
96
147
  /**
97
148
  The theme to apply to the button. By default, a subtheme with the name of
98
149
  'square' is created for backwards-compatibility.
@@ -299,41 +350,6 @@ SC.ButtonView = SC.View.extend(SC.Control,
299
350
  isCancel: NO,
300
351
  isCancelBindingDefault: SC.Binding.oneWay().bool(),
301
352
 
302
- /**
303
- The name of the action you want triggered when the button is pressed.
304
-
305
- This property is used in conjunction with the target property to execute
306
- a method when a regular button is pressed. These properties are not
307
- relevant when the button is used in toggle mode.
308
-
309
- If you do not set a target, then pressing a button will cause the
310
- responder chain to search for a view that implements the action you name
311
- here. If you set a target, then the button will try to call the method
312
- on the target itself.
313
-
314
- For legacy support, you can also set the action property to a function.
315
- Doing so will cause the function itself to be called when the button is
316
- clicked. It is generally better to use the target/action approach and
317
- to implement your code in a controller of some type.
318
-
319
- @type String
320
- @default null
321
- */
322
- action: null,
323
-
324
- /**
325
- The target object to invoke the action on when the button is pressed.
326
-
327
- If you set this target, the action will be called on the target object
328
- directly when the button is clicked. If you leave this property set to
329
- null, then the button will search the responder chain for a view that
330
- implements the action when the button is pressed instead.
331
-
332
- @type Object
333
- @default null
334
- */
335
- target: null,
336
-
337
353
  /*
338
354
  TODO When is this property ever changed? Is this redundant with
339
355
  render delegates since it can now be turned on on a theme-by-theme
@@ -804,20 +820,16 @@ SC.ButtonView = SC.View.extend(SC.Control,
804
820
 
805
821
  /** @private */
806
822
  _runAction: function(evt) {
807
- var action = this.get('action'),
808
- target = this.get('target') || null,
809
- rootResponder;
823
+ var action = this.get('action');
810
824
 
811
825
  if (action) {
826
+ // Legacy support for action functions.
812
827
  if (action && (SC.typeOf(action) === SC.T_FUNCTION)) {
813
828
  this.action(evt);
814
- return;
829
+
830
+ // Use SC.ActionSupport.
815
831
  } else {
816
- rootResponder = this.getPath('pane.rootResponder');
817
- if (rootResponder) {
818
- // newer action method + optional target syntax...
819
- rootResponder.sendAction(action, target, this, this.get('pane'), null, this);
820
- }
832
+ this.fireAction();
821
833
  }
822
834
  }
823
835
  },