sproutcore 1.11.0.rc2 → 1.11.0.rc3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (104) hide show
  1. checksums.yaml +8 -8
  2. data/CHANGELOG +10 -0
  3. data/VERSION.yml +1 -1
  4. data/lib/frameworks/sproutcore/CHANGELOG.md +114 -1
  5. data/lib/frameworks/sproutcore/apps/showcase/views/views_item_view.js +1 -7
  6. data/lib/frameworks/sproutcore/apps/showcase/views/views_list_view.js +9 -9
  7. data/lib/frameworks/sproutcore/frameworks/ajax/system/request.js +167 -5
  8. data/lib/frameworks/sproutcore/frameworks/ajax/system/response.js +24 -8
  9. data/lib/frameworks/sproutcore/frameworks/core_foundation/child_view_layouts/stack_layout.js +737 -0
  10. data/lib/frameworks/sproutcore/frameworks/core_foundation/panes/layout.js +0 -6
  11. data/lib/frameworks/sproutcore/frameworks/core_foundation/panes/pane.js +11 -7
  12. data/lib/frameworks/sproutcore/frameworks/core_foundation/panes/pane_statechart.js +7 -11
  13. data/lib/frameworks/sproutcore/frameworks/core_foundation/protocols/child_view_layout_protocol.js +8 -3
  14. data/lib/frameworks/sproutcore/frameworks/core_foundation/protocols/observable_protocol.js +9 -6
  15. data/lib/frameworks/sproutcore/frameworks/{desktop/protocols/responder.js → core_foundation/protocols/responder_protocol.js} +83 -17
  16. data/lib/frameworks/sproutcore/frameworks/core_foundation/protocols/{sparse_array_delegate.js → sparse_array_delegate_protocol.js} +11 -7
  17. data/lib/frameworks/sproutcore/frameworks/core_foundation/protocols/view_transition_protocol.js +11 -6
  18. data/lib/frameworks/sproutcore/frameworks/core_foundation/system/color.js +2 -2
  19. data/lib/frameworks/sproutcore/frameworks/core_foundation/system/page.js +0 -22
  20. data/lib/frameworks/sproutcore/frameworks/core_foundation/system/root_responder.js +61 -56
  21. data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/main_pane.js +2 -2
  22. data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/pane/append_remove.js +3 -3
  23. data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/animation.js +63 -39
  24. data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/border_frame_test.js +28 -28
  25. data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/createLayer.js +10 -4
  26. data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/layout.js +102 -1
  27. data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/layoutDidChange.js +4 -4
  28. data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/layoutStyle.js +103 -103
  29. data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/replaceAllChildren_test.js +1 -1
  30. data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/view.js +77 -1
  31. data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/view_states_test.js +18 -17
  32. data/lib/frameworks/sproutcore/frameworks/core_foundation/views/view.js +42 -49
  33. data/lib/frameworks/sproutcore/frameworks/core_foundation/views/view/animation.js +5 -6
  34. data/lib/frameworks/sproutcore/frameworks/core_foundation/views/view/enabled.js +16 -5
  35. data/lib/frameworks/sproutcore/frameworks/core_foundation/views/view/layout.js +241 -102
  36. data/lib/frameworks/sproutcore/frameworks/core_foundation/views/view/layout_style.js +1 -4
  37. data/lib/frameworks/sproutcore/frameworks/core_foundation/views/view/manipulation.js +0 -11
  38. data/lib/frameworks/sproutcore/frameworks/core_foundation/views/view/statechart.js +993 -610
  39. data/lib/frameworks/sproutcore/frameworks/core_foundation/views/view/theming.js +3 -2
  40. data/lib/frameworks/sproutcore/frameworks/datastore/data_sources/data_source.js +6 -11
  41. data/lib/frameworks/sproutcore/frameworks/datastore/system/nested_store.js +94 -27
  42. data/lib/frameworks/sproutcore/frameworks/datastore/system/query.js +133 -53
  43. data/lib/frameworks/sproutcore/frameworks/datastore/system/store.js +30 -35
  44. data/lib/frameworks/sproutcore/frameworks/datastore/tests/models/record/writeAttribute.js +3 -2
  45. data/lib/frameworks/sproutcore/frameworks/datastore/tests/system/nested_store/writeDataHash.js +73 -29
  46. data/lib/frameworks/sproutcore/frameworks/datastore/tests/system/store/conflictedStoreKeys_test.js +156 -0
  47. data/lib/frameworks/sproutcore/frameworks/datastore/tests/system/store/dataSourceCallbacks.js +61 -37
  48. data/lib/frameworks/sproutcore/frameworks/datastore/tests/system/store/find.js +2 -2
  49. data/lib/frameworks/sproutcore/frameworks/datetime/frameworks/core/system/datetime.js +68 -39
  50. data/lib/frameworks/sproutcore/frameworks/designer/tests/coders/page.js +1 -2
  51. data/lib/frameworks/sproutcore/frameworks/desktop/panes/panel.js +8 -6
  52. data/lib/frameworks/sproutcore/frameworks/desktop/panes/picker.js +80 -14
  53. data/lib/frameworks/sproutcore/frameworks/desktop/panes/sheet.js +2 -2
  54. data/lib/frameworks/sproutcore/frameworks/desktop/protocols/{drag_data_source.js → drag_data_source_protocol.js} +16 -10
  55. data/lib/frameworks/sproutcore/frameworks/desktop/protocols/{drag_source.js → drag_source_protocol.js} +28 -26
  56. data/lib/frameworks/sproutcore/frameworks/desktop/protocols/{drop_target.js → drop_target_protocol.js} +73 -75
  57. data/lib/frameworks/sproutcore/frameworks/desktop/system/drag.js +4 -4
  58. data/lib/frameworks/sproutcore/frameworks/desktop/tests/panes/panel/ui.js +39 -23
  59. data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/collection/mouse.js +120 -97
  60. data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/list/rowSizeForContentIndex.js +26 -25
  61. data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/scroll/ui.js +3 -3
  62. data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/segmented/ui.js +5 -0
  63. data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/split/{dividers.js → dividers_test.js} +38 -38
  64. data/lib/frameworks/sproutcore/frameworks/desktop/views/collection.js +29 -14
  65. data/lib/frameworks/sproutcore/frameworks/desktop/views/menu_scroll.js +2 -1
  66. data/lib/frameworks/sproutcore/frameworks/desktop/views/scroll_view.js +13 -18
  67. data/lib/frameworks/sproutcore/frameworks/desktop/views/segmented.js +41 -35
  68. data/lib/frameworks/sproutcore/frameworks/desktop/views/slider.js +14 -14
  69. data/lib/frameworks/sproutcore/frameworks/desktop/views/split.js +41 -26
  70. data/lib/frameworks/sproutcore/frameworks/desktop/views/static_content.js +2 -12
  71. data/lib/frameworks/sproutcore/frameworks/foundation/gestures/tap.js +2 -2
  72. data/lib/frameworks/sproutcore/frameworks/foundation/mixins/auto_resize.js +14 -10
  73. data/lib/frameworks/sproutcore/frameworks/foundation/mixins/gesturable.js +104 -63
  74. data/lib/frameworks/sproutcore/frameworks/foundation/protocols/swap_transition_protocol.js +9 -4
  75. data/lib/frameworks/sproutcore/frameworks/foundation/tests/mixins/auto_mixin_tests.js +1 -2
  76. data/lib/frameworks/sproutcore/frameworks/foundation/tests/mixins/auto_resize_test.js +33 -33
  77. data/lib/frameworks/sproutcore/frameworks/foundation/tests/transitions/view_transitions_test.js +5 -5
  78. data/lib/frameworks/sproutcore/frameworks/foundation/tests/views/container/methods.js +0 -4
  79. data/lib/frameworks/sproutcore/frameworks/foundation/tests/views/container/transition_test.js +0 -4
  80. data/lib/frameworks/sproutcore/frameworks/foundation/tests/views/container/ui.js +0 -2
  81. data/lib/frameworks/sproutcore/frameworks/foundation/views/text_field.js +12 -8
  82. data/lib/frameworks/sproutcore/frameworks/media/resources/silence.mp3 +0 -0
  83. data/lib/frameworks/sproutcore/frameworks/media/tests/audio.js +69 -0
  84. data/lib/frameworks/sproutcore/frameworks/media/views/audio.js +1 -0
  85. data/lib/frameworks/sproutcore/frameworks/runtime/core.js +2 -2
  86. data/lib/frameworks/sproutcore/frameworks/runtime/mixins/observable.js +11 -4
  87. data/lib/frameworks/sproutcore/frameworks/runtime/protocols/mixin_protocol.js +150 -0
  88. data/lib/frameworks/sproutcore/frameworks/runtime/system/binding.js +447 -137
  89. data/lib/frameworks/sproutcore/frameworks/runtime/system/object.js +9 -15
  90. data/lib/frameworks/sproutcore/frameworks/runtime/system/set.js +19 -17
  91. data/lib/frameworks/sproutcore/frameworks/runtime/tests/system/binding.js +188 -16
  92. data/lib/frameworks/sproutcore/frameworks/statechart/system/state.js +1 -1
  93. data/lib/frameworks/sproutcore/frameworks/template_view/panes/template.js +0 -3
  94. data/lib/frameworks/sproutcore/frameworks/template_view/tests/panes/template.js +0 -17
  95. data/lib/frameworks/sproutcore/frameworks/template_view/tests/views/template/collection.js +43 -26
  96. data/lib/frameworks/sproutcore/frameworks/template_view/views/bindable_span.js +9 -2
  97. data/lib/frameworks/sproutcore/themes/ace/resources/collection/normal/list.css +0 -1
  98. data/lib/frameworks/sproutcore/themes/ace/resources/scroll/scroll.css +3 -0
  99. data/sproutcore.gemspec +3 -3
  100. metadata +19 -17
  101. data/lib/frameworks/sproutcore/frameworks/core_foundation/child_view_layouts/horizontal_stack_layout.js +0 -465
  102. data/lib/frameworks/sproutcore/frameworks/core_foundation/child_view_layouts/vertical_stack_layout.js +0 -472
  103. data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/build.js +0 -87
  104. data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/build_children.js +0 -89
@@ -108,7 +108,7 @@ SC.View.reopen(
108
108
  - `dataSource` -- Optional object that will provide the data for the drag to
109
109
  be consumed by the drop target. If you do not pass this parameter or the
110
110
  data hash, then the source object will be used if it implements the
111
- SC.DragDataSource protocol.
111
+ SC.DragDataSourceProtocol protocol.
112
112
 
113
113
  - `anchorView` -- if you pass this optional view, then the drag will only be
114
114
  allowed to happen within this view. The ghostView will actually be added
@@ -294,7 +294,7 @@ SC.Drag = SC.Object.extend(
294
294
  a drag dynamically. The data source can and often is the drag source
295
295
  object itself.
296
296
 
297
- Data Source objects must comply with the `SC.DragDataSource` interface. If
297
+ Data Source objects must comply with the `SC.DragDataSourceProtocol` interface. If
298
298
  you do not want to implement this interface, you can provide the data
299
299
  directly with the data property.
300
300
 
@@ -303,7 +303,7 @@ SC.Drag = SC.Object.extend(
303
303
  these properties.
304
304
 
305
305
  @readOnly
306
- @type SC.DragDataSource
306
+ @type SC.DragDataSourceProtocol
307
307
  */
308
308
  dataSource: null,
309
309
 
@@ -1054,7 +1054,7 @@ SC.Drag.mixin(
1054
1054
  isDropTarget property set to `YES`. You generally will not need to call it
1055
1055
  yourself.
1056
1056
 
1057
- @param {SC.View} target a view implementing the SC.DropTarget protocol
1057
+ @param {SC.View} target a view implementing the SC.DropTargetProtocol protocol
1058
1058
  */
1059
1059
  addDropTarget: function (target) {
1060
1060
  this._dropTargets[SC.guidFor(target)] = target;
@@ -116,27 +116,43 @@ test("Verify SC.PanelPane#isModal", function() {
116
116
  SC.run(function () {
117
117
  pane.destroy();
118
118
  });
119
-
120
- // Tests an edge case where isModal turns YES during a transition out.
121
- pane = SC.PanelPane.create({
122
- contentView: SC.View,
123
- modalPane: SC.ModalPane.create(),
124
- isModal: NO,
125
- transitionOut: SC.View.FADE_OUT,
126
- transitionOutOptions: { duration: 0.1 }
127
- });
128
-
129
- SC.run(function () {
130
- pane.append();
131
-
132
- pane.remove(); // trigger transition and then willRemoveFromDocument
133
- });
134
- pane.set('isModal', YES);
135
- equals(pane.getPath('modalPane.viewState'), SC.CoreView.UNRENDERED, "Panel pane does not add modal pane when isModal becomes YES while transitioning out");
136
-
137
- SC.run(function () {
138
- pane.destroy();
139
-
140
- equals(pane.get('viewState'), SC.CoreView.UNRENDERED);
141
- });
142
119
  });
120
+
121
+ test("Should changing isModal when a pane is transitioning out not append the modal pane?");
122
+ /*
123
+ Previously, if the panel pane was not shown it would simply not append the modal pane to it. Which
124
+ causes issues, because what if a pane is hidden and then isModal changes to true? When the view
125
+ becomes visible, isModal will still be true, but there won't be a modal view. This would need to
126
+ be more minutely handled in the pane (i.e. each time it re-shows it has to check if isModal is
127
+ true and if it does have a modal pane or not) or more minutely handled by the developer (i.e. when
128
+ they are transitioning views out they should take care not to change isModal until the view is
129
+ done transitioning). We should probably do the former, but it opens a bigger question, how should
130
+ all views respond when they are modified in transitioning out states?
131
+ */
132
+ // , function () {
133
+
134
+ // // Tests an edge case where isModal turns YES during a transition out.
135
+ // pane = SC.PanelPane.create({
136
+ // contentView: SC.View,
137
+ // modalPane: SC.ModalPane.create(),
138
+ // isModal: NO,
139
+ // transitionOut: SC.View.FADE_OUT,
140
+ // transitionOutOptions: { duration: 0.1 }
141
+ // });
142
+
143
+ // SC.run(function () {
144
+ // pane.append();
145
+
146
+ // pane.remove(); // trigger transition and then willRemoveFromDocument
147
+ // });
148
+
149
+ // pane.set('isModal', YES);
150
+
151
+ // equals(pane.getPath('modalPane.viewState'), SC.CoreView.UNRENDERED, "Panel pane does not add modal pane when isModal becomes YES while transitioning out");
152
+
153
+ // SC.run(function () {
154
+ // pane.destroy();
155
+
156
+ // equals(pane.get('viewState'), SC.CoreView.UNRENDERED);
157
+ // });
158
+ // });
@@ -4,49 +4,49 @@
4
4
  // portions copyright @2011 Apple Inc.
5
5
  // License: Licensed under MIT license (see license.js)
6
6
  // ==========================================================================
7
-
7
+ /* globals equals, ok, test, module, start, stop */
8
8
  var view, content, contentController, pane, actionCalled = 0;
9
9
 
10
10
  module("SC.CollectionView Mouse Events", {
11
11
  setup: function() {
12
-
13
- SC.RunLoop.begin();
14
-
15
- content = "1 2 3 4 5 6 7 8 9 10".w().map(function(x) {
16
- return SC.Object.create({ value: x });
17
- });
18
-
19
- contentController = SC.ArrayController.create({
20
- content: content,
21
- allowsMultipleSelection: YES
22
- });
23
-
24
- view = SC.CollectionView.create({
25
- content: contentController,
26
-
27
- layout: { top: 0, left: 0, width: 300, height: 500 },
28
-
29
- layoutForContentIndex: function(idx) {
30
- return { left: 0, right: 0, top: idx * 50, height: 50 };
31
- },
32
-
33
- isVisibleInWindow: YES,
34
- acceptsFirstResponder: YES,
35
- action: function() {
36
- actionCalled++;
37
- }
12
+ SC.run(function () {
13
+ content = "1 2 3 4 5 6 7 8 9 10".w().map(function(x) {
14
+ return SC.Object.create({ value: x });
15
+ });
16
+
17
+ contentController = SC.ArrayController.create({
18
+ content: content,
19
+ allowsMultipleSelection: YES
20
+ });
21
+
22
+ view = SC.CollectionView.create({
23
+ content: contentController,
24
+
25
+ layout: { top: 0, left: 0, width: 300, height: 500 },
26
+
27
+ layoutForContentIndex: function(idx) {
28
+ return { left: 0, right: 0, top: idx * 50, height: 50 };
29
+ },
30
+
31
+ isVisibleInWindow: YES,
32
+ acceptsFirstResponder: YES,
33
+ action: function() {
34
+ actionCalled++;
35
+ }
36
+ });
37
+
38
+ pane = SC.MainPane.create();
39
+ pane.appendChild(view);
40
+ pane.append();
38
41
  });
39
-
40
- pane = SC.MainPane.create();
41
- pane.appendChild(view);
42
- pane.append();
43
-
44
- SC.RunLoop.end();
45
42
  },
46
43
 
47
44
  teardown: function() {
48
- pane.destroy();
49
- actionCalled = 0;
45
+ SC.run(function () {
46
+ pane.destroy();
47
+ pane = view = content = contentController = null;
48
+ actionCalled = 0;
49
+ });
50
50
  }
51
51
  });
52
52
 
@@ -88,7 +88,7 @@ function clickOn(view, index, shiftKey, ctrlKey, expected, delay) {
88
88
 
89
89
  ok(expected ? expected.isEqual(sel) : expected === sel, 'should have selection: %@ after click with %@ on item[%@], actual: %@'.fmt(expected, modifiers, index, sel));
90
90
  SC.RunLoop.end();
91
- if (delay) window.start() ; // starts the test runner
91
+ if (delay) { start(); }// starts the test runner
92
92
  };
93
93
 
94
94
  if (delay) {
@@ -136,13 +136,16 @@ test("clicking on an item should select it", function() {
136
136
  });
137
137
 
138
138
  test("clicking on a selected item should clear selection after 300ms and reselect it", function() {
139
- view.select(SC.IndexSet.create(1,5));
140
- SC.RootResponder.responder._lastMouseUpAt = null ; // HACK: don't want a doubleClick from previous tests
139
+ SC.run(function () {
140
+ view.select(SC.IndexSet.create(1,5));
141
+ });
141
142
  clickOn(view, 3, NO, NO, selectionFromIndex(3), 500);
142
143
  });
143
144
 
144
145
  test("clicking on unselected item should clear selection and select it", function() {
145
- view.select(SC.IndexSet.create(1,5));
146
+ SC.run(function () {
147
+ view.select(SC.IndexSet.create(1,5));
148
+ });
146
149
  clickOn(view, 7, NO, NO, selectionFromIndex(7));
147
150
  });
148
151
 
@@ -153,7 +156,10 @@ test("first responder", function() {
153
156
 
154
157
  test("clicking on a collection view with null content should not throw an error", function() {
155
158
  var failed = NO;
156
- view.set('content', null);
159
+ SC.run(function () {
160
+ view.set('content', null);
161
+ });
162
+
157
163
  try {
158
164
  var l = view.get('layer'),
159
165
  evt = SC.Event.simulateEvent(l, 'mousedown');
@@ -163,61 +169,6 @@ test("clicking on a collection view with null content should not throw an error"
163
169
  ok(!failed, "clicking on a collection view with null content should not throw an error");
164
170
  });
165
171
 
166
-
167
- // ..........................................................
168
- // ctrl-click mouse down
169
- //
170
-
171
- test("ctrl-clicking on unselected item should add to selection", function() {
172
- clickOn(view,3, NO, YES, selectionFromIndex(3));
173
- clickOn(view,5, NO, YES, selectionFromIndex(3).addObject(content.objectAt(5)));
174
- });
175
-
176
- test("ctrl-clicking on selected item should remove from selection", function() {
177
- clickOn(view,3, NO, YES, selectionFromIndex(3));
178
- clickOn(view,5, NO, YES, selectionFromIndex(3).addObject(content.objectAt(5)));
179
- clickOn(view,3, NO, YES, selectionFromIndex(5));
180
- clickOn(view,5, NO, YES, SC.SelectionSet.create());
181
- });
182
-
183
- // ..........................................................
184
- // shift-click mouse down
185
- //
186
-
187
- test("shift-clicking on an item below should extend the selection", function() {
188
- clickOn(view, 3, NO, NO, selectionFromIndex(3));
189
- clickOn(view, 5, YES, NO, selectionFromIndexSet(SC.IndexSet.create(3,3)));
190
- });
191
-
192
-
193
- test("shift-clicking on an item above should extend the selection", function() {
194
- clickOn(view, 3, NO, NO, selectionFromIndex(3));
195
- clickOn(view, 1, YES, NO, selectionFromIndexSet(SC.IndexSet.create(1,3)));
196
- });
197
-
198
- test("shift-clicking inside selection first time should reduce selection from top", function() {
199
- view.select(SC.IndexSet.create(3,4));
200
- clickOn(view,4, YES, NO, selectionFromIndexSet(SC.IndexSet.create(3,2)));
201
- });
202
-
203
- test("shift-click below to extend selection down then shift-click inside selection should reduce selection", function() {
204
- clickOn(view, 3, NO, NO, selectionFromIndex(3));
205
- clickOn(view, 5, YES, NO, selectionFromIndexSet(SC.IndexSet.create(3,3)));
206
- clickOn(view,4, YES, NO, selectionFromIndexSet(SC.IndexSet.create(3,2)));
207
- });
208
-
209
- test("shift-click above to extend selection down then shift-click inside selection should reduce top of selection", function() {
210
- clickOn(view, 3, NO, NO, selectionFromIndex(3));
211
- clickOn(view, 1, YES, NO, selectionFromIndexSet(SC.IndexSet.create(1,3)));
212
- clickOn(view,2, YES, NO, selectionFromIndexSet(SC.IndexSet.create(2,2)));
213
- });
214
-
215
- test("shift-click below bottom of selection then shift click on top of selection should select only top item", function() {
216
- clickOn(view, 3, NO, NO, selectionFromIndex(3));
217
- clickOn(view, 5, YES, NO, selectionFromIndexSet(SC.IndexSet.create(3,3)));
218
- clickOn(view,3, YES, NO, selectionFromIndex(3));
219
- });
220
-
221
172
  test("clicking on an item should select it when useToggleSelection is true", function() {
222
173
  view.set('useToggleSelection', YES);
223
174
  clickOn(view, 3, NO, NO, selectionFromIndex(3));
@@ -230,7 +181,9 @@ test("clicking on an unselected item should select it when useToggleSelection is
230
181
 
231
182
  test("clicking on a selected item should deselect it when useToggleSelection is true", function() {
232
183
  view.set('useToggleSelection', YES);
233
- view.select(SC.IndexSet.create(3,1));
184
+ SC.run(function () {
185
+ view.select(SC.IndexSet.create(3,1));
186
+ });
234
187
  clickOn(view, 3, NO, NO, SC.SelectionSet.create());
235
188
  });
236
189
 
@@ -242,7 +195,9 @@ test("clicking on an unselected item should select it and add it to the selectio
242
195
 
243
196
  test("clicking on a selected item should remove it from the selection when useToggleSelection is true", function() {
244
197
  view.set('useToggleSelection', YES);
245
- view.select(SC.IndexSet.create(1,5));
198
+ SC.run(function () {
199
+ view.select(SC.IndexSet.create(1,5));
200
+ });
246
201
  clickOn(view, 5, NO, NO, selectionFromIndexSet(SC.IndexSet.create(1,4)));
247
202
  });
248
203
 
@@ -291,3 +246,71 @@ test("click on an item when isEnabled is false doesn't do anything", function()
291
246
  });
292
247
  clickOn(view, 1, NO, NO, null);
293
248
  });
249
+
250
+ // ..........................................................
251
+ // double click
252
+ //
253
+
254
+ test("double-clicking on an unselected item should fire action when actOnSelect is false", function() {
255
+ equals(actionCalled, 0, "precond - action hasn't been called");
256
+ clickOn(view, 1, NO, NO);
257
+ equals(actionCalled, 0, "No action is called on first click");
258
+ clickOn(view, 1, NO, NO);
259
+ equals(actionCalled, 1, "Action called when item receives second click");
260
+ });
261
+
262
+ // ..........................................................
263
+ // ctrl-click mouse down
264
+ //
265
+
266
+ test("ctrl-clicking on unselected item should add to selection", function() {
267
+ clickOn(view,3, NO, YES, selectionFromIndex(3));
268
+ clickOn(view,5, NO, YES, selectionFromIndex(3).addObject(content.objectAt(5)));
269
+ });
270
+
271
+ test("ctrl-clicking on selected item should remove from selection", function() {
272
+ clickOn(view,3, NO, YES, selectionFromIndex(3));
273
+ clickOn(view,5, NO, YES, selectionFromIndex(3).addObject(content.objectAt(5)));
274
+ clickOn(view,3, NO, YES, selectionFromIndex(5));
275
+ clickOn(view,5, NO, YES, SC.SelectionSet.create());
276
+ });
277
+
278
+ // ..........................................................
279
+ // shift-click mouse down
280
+ //
281
+
282
+ test("shift-clicking on an item below should extend the selection", function() {
283
+ clickOn(view, 3, NO, NO, selectionFromIndex(3));
284
+ clickOn(view, 5, YES, NO, selectionFromIndexSet(SC.IndexSet.create(3,3)));
285
+ });
286
+
287
+
288
+ test("shift-clicking on an item above should extend the selection", function() {
289
+ clickOn(view, 3, NO, NO, selectionFromIndex(3));
290
+ clickOn(view, 1, YES, NO, selectionFromIndexSet(SC.IndexSet.create(1,3)));
291
+ });
292
+
293
+ test("shift-clicking inside selection first time should reduce selection from top", function() {
294
+ SC.run(function () {
295
+ view.select(SC.IndexSet.create(3,4));
296
+ });
297
+ clickOn(view,4, YES, NO, selectionFromIndexSet(SC.IndexSet.create(3,2)));
298
+ });
299
+
300
+ test("shift-click below to extend selection down then shift-click inside selection should reduce selection", function() {
301
+ clickOn(view, 3, NO, NO, selectionFromIndex(3));
302
+ clickOn(view, 5, YES, NO, selectionFromIndexSet(SC.IndexSet.create(3,3)));
303
+ clickOn(view,4, YES, NO, selectionFromIndexSet(SC.IndexSet.create(3,2)));
304
+ });
305
+
306
+ test("shift-click above to extend selection down then shift-click inside selection should reduce top of selection", function() {
307
+ clickOn(view, 3, NO, NO, selectionFromIndex(3));
308
+ clickOn(view, 1, YES, NO, selectionFromIndexSet(SC.IndexSet.create(1,3)));
309
+ clickOn(view,2, YES, NO, selectionFromIndexSet(SC.IndexSet.create(2,2)));
310
+ });
311
+
312
+ test("shift-click below bottom of selection then shift click on top of selection should select only top item", function() {
313
+ clickOn(view, 3, NO, NO, selectionFromIndex(3));
314
+ clickOn(view, 5, YES, NO, selectionFromIndexSet(SC.IndexSet.create(3,3)));
315
+ clickOn(view,3, YES, NO, selectionFromIndex(3));
316
+ });
@@ -4,13 +4,14 @@
4
4
  // portions copyright @2011 Apple Inc.
5
5
  // License: Licensed under MIT license (see license.js)
6
6
  // ==========================================================================
7
+ /* globals module, test, equals, ok */
8
+ var content, delegate;
7
9
 
8
- var content, delegate ;
9
10
  var Delegate = SC.Object.extend(SC.CollectionRowDelegate, {
10
- rowHeight: 40,
11
- customRowHeightIndexes: SC.IndexSet.create(3).add(5,2),
12
- contentIndexRowHeight: function(view, content, index) {
13
- return this.get('customRowHeightIndexes').contains(index) ? view.get('customRowHeight') : this.get('rowHeight');
11
+ rowSize: 40,
12
+ customRowSizeIndexes: SC.IndexSet.create(3).add(5,2),
13
+ contentIndexRowSize: function(view, content, index) {
14
+ return this.get('customRowSizeIndexes').contains(index) ? view.get('customRowSize') : this.get('rowSize');
14
15
  },
15
16
 
16
17
  expected: function(view) {
@@ -19,7 +20,7 @@ var Delegate = SC.Object.extend(SC.CollectionRowDelegate, {
19
20
  loc = view.get('length');
20
21
 
21
22
  while(--loc>=0) {
22
- ret[loc] = this.contentIndexRowHeight(view,content,loc);
23
+ ret[loc] = this.contentIndexRowSize(view,content,loc);
23
24
  }
24
25
 
25
26
  return ret ;
@@ -28,7 +29,7 @@ var Delegate = SC.Object.extend(SC.CollectionRowDelegate, {
28
29
 
29
30
  module("SC.ListView.rowSizeForContentIndex", {
30
31
  setup: function() {
31
- content = "1 2 3 4 5 6 7 8 9 0".w().map(function(x) {
32
+ content = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '0'].map(function(x) {
32
33
  return SC.Object.create({ value: x });
33
34
  }, this);
34
35
 
@@ -38,12 +39,12 @@ module("SC.ListView.rowSizeForContentIndex", {
38
39
  }
39
40
  });
40
41
 
41
- function verifyRowHeights(view, rowHeight, expected) {
42
+ function verifyRowHeights(view, rowSize, expected) {
42
43
  var loc = view.get('length'), actual, totalExpected = 0,
43
44
  rowSpacing = view.get('rowSpacing') || 0;
44
45
 
45
46
  ok(loc>0, 'content should have some length');
46
- equals(view.rowSizeForContentIndex(loc+1), rowHeight, 'content.rowSizeForContentIndex(length+1) should be rowHeight');
47
+ equals(view.rowSizeForContentIndex(loc+1), rowSize, 'content.rowSizeForContentIndex(length+1) should be rowSize');
47
48
 
48
49
  while(--loc>=0) {
49
50
  actual = view.rowSizeForContentIndex(loc);
@@ -51,15 +52,15 @@ function verifyRowHeights(view, rowHeight, expected) {
51
52
  totalExpected += expected[loc];
52
53
  equals(actual, expected[loc], "content.rowSizeForContentIndex(%@) should be custom row height".fmt(loc));
53
54
  } else {
54
- totalExpected += rowHeight;
55
- equals(actual, rowHeight, 'content.rowSizeForContentIndex(%@) should be rowHeight'.fmt(loc));
55
+ totalExpected += rowSize;
56
+ equals(actual, rowSize, 'content.rowSizeForContentIndex(%@) should be rowSize'.fmt(loc));
56
57
  }
57
58
 
58
59
  totalExpected += rowSpacing;
59
60
  }
60
61
 
61
62
  // Don't include spacing after the last item.
62
- equals(totalExpected - rowSpacing, view.get('layout').height, "The height of the list should match the total height of the rows including row spacing.")
63
+ equals(totalExpected - rowSpacing, view.get('layout').height, "The height of the list should match the total height of the rows including row spacing.");
63
64
  }
64
65
 
65
66
  // ..........................................................
@@ -69,7 +70,7 @@ function verifyRowHeights(view, rowHeight, expected) {
69
70
  test("constant row heights", function() {
70
71
  var view;
71
72
  SC.run(function() {
72
- view = SC.ListView.create({ content: content, rowHeight: 40, customRowHeightIndexes: null });
73
+ view = SC.ListView.create({ content: content, rowSize: 40, customRowSizeIndexes: null });
73
74
  });
74
75
  verifyRowHeights(view, 40);
75
76
  });
@@ -77,7 +78,7 @@ test("constant row heights", function() {
77
78
  test("constant row heights with rowSpacing", function() {
78
79
  var view;
79
80
  SC.run(function() {
80
- view = SC.ListView.create({ content: content, rowHeight: 40, rowSpacing: 2, customRowHeightIndexes: null });
81
+ view = SC.ListView.create({ content: content, rowSize: 40, rowSpacing: 2, customRowSizeIndexes: null });
81
82
  });
82
83
  verifyRowHeights(view, 40);
83
84
  });
@@ -87,7 +88,7 @@ test("custom row heights", function() {
87
88
  SC.run(function() {
88
89
  view = SC.ListView.create({
89
90
  content: content,
90
- customRowHeight: 50,
91
+ customRowSize: 50,
91
92
  delegate: delegate
92
93
  });
93
94
  });
@@ -100,8 +101,8 @@ test("adding delegate should update calculation", function() {
100
101
  SC.run(function() {
101
102
  view = SC.ListView.create({
102
103
  content: content,
103
- rowHeight: 30,
104
- customRowHeight: 50
104
+ rowSize: 30,
105
+ customRowSize: 50
105
106
  });
106
107
  });
107
108
 
@@ -118,15 +119,15 @@ test("changing delegate from custom to not custom should update", function() {
118
119
  SC.run(function() {
119
120
  view = SC.ListView.create({
120
121
  content: content,
121
- rowHeight: 30,
122
- customRowHeight: 50,
122
+ rowSize: 30,
123
+ customRowSize: 50,
123
124
  delegate: delegate
124
125
  });
125
126
  });
126
127
  verifyRowHeights(view, 40, delegate.expected(view));
127
128
 
128
129
  SC.run(function() {
129
- delegate.set('customRowHeightIndexes', null);
130
+ delegate.set('customRowSizeIndexes', null);
130
131
  });
131
132
  verifyRowHeights(view, 40);
132
133
  });
@@ -135,13 +136,13 @@ test("changing delegate from custom to not custom should update", function() {
135
136
  // SPECIAL CASES
136
137
  //
137
138
 
138
- test("computed custom row height indexes", function() {
139
+ test("computed custom row size indexes", function() {
139
140
 
140
141
  delegate = Delegate.create({
141
- indexes: Delegate.prototype.customRowHeightIndexes,
142
+ indexes: Delegate.prototype.customRowSizeIndexes,
142
143
  useIndexes: NO,
143
144
 
144
- customRowHeightIndexes: function() {
145
+ customRowSizeIndexes: function() {
145
146
  return this.get('useIndexes') ? this.get('indexes') : null;
146
147
  }.property('useIndexes').cacheable()
147
148
  });
@@ -150,8 +151,8 @@ test("computed custom row height indexes", function() {
150
151
  SC.run(function() {
151
152
  view = SC.ListView.create({
152
153
  content: content,
153
- rowHeight: 15,
154
- customRowHeight: 50,
154
+ rowSize: 15,
155
+ customRowSize: 50,
155
156
  delegate: delegate
156
157
  });
157
158
  });