sproutit-sproutcore 1.0.20090721145251 → 1.0.20090721145280

Sign up to get free protection for your applications and to get access to all the features.
Files changed (55) hide show
  1. data/Rakefile +3 -3
  2. data/VERSION.yml +2 -2
  3. data/frameworks/sproutcore/Buildfile +0 -1
  4. data/gen/app/templates/apps/@target_name@/core.js +27 -0
  5. data/gen/app/templates/apps/@target_name@/english.lproj/loading.rhtml +9 -0
  6. data/gen/app/templates/apps/@target_name@/english.lproj/main_page.js +22 -0
  7. data/gen/app/templates/apps/@target_name@/english.lproj/strings.js +15 -0
  8. data/gen/app/templates/apps/@target_name@/main.js +30 -0
  9. data/gen/controller/templates/controllers/@filename@.js +18 -0
  10. data/gen/controller/templates/tests/controllers/@filename@.js +15 -0
  11. data/gen/framework/templates/frameworks/@target_name@/core.js +21 -0
  12. data/gen/framework/templates/frameworks/@target_name@/english.lproj/strings.js +15 -0
  13. data/gen/language/templates/@filename@/strings.js +14 -0
  14. data/gen/model/templates/fixtures/@filename@.js +35 -0
  15. data/gen/model/templates/models/@filename@.js +19 -0
  16. data/gen/model/templates/tests/models/@filename@.js +15 -0
  17. data/gen/project/templates/@filename@/Buildfile +7 -0
  18. data/gen/project/templates/@filename@/README +7 -0
  19. data/gen/test/templates/tests/@filename@.js +15 -0
  20. data/gen/theme/templates/themes/@target_name@/english.lproj/strings.js +15 -0
  21. data/gen/view/templates/tests/views/@filename@.js +15 -0
  22. data/gen/view/templates/views/@filename@.js +18 -0
  23. data/lib/sproutcore/models/generator.rb +2 -2
  24. metadata +21 -33
  25. data/frameworks/sproutcore/frameworks/deprecated/core.js +0 -59
  26. data/frameworks/sproutcore/frameworks/deprecated/lib/button_views.rb +0 -330
  27. data/frameworks/sproutcore/frameworks/deprecated/lib/collection_view.rb +0 -83
  28. data/frameworks/sproutcore/frameworks/deprecated/lib/core_views.rb +0 -326
  29. data/frameworks/sproutcore/frameworks/deprecated/lib/form_views.rb +0 -253
  30. data/frameworks/sproutcore/frameworks/deprecated/lib/index.rhtml +0 -75
  31. data/frameworks/sproutcore/frameworks/deprecated/lib/menu_views.rb +0 -93
  32. data/frameworks/sproutcore/frameworks/deprecated/server/rails_server.js +0 -80
  33. data/frameworks/sproutcore/frameworks/deprecated/server/rest_server.js +0 -178
  34. data/frameworks/sproutcore/frameworks/deprecated/server/server.js +0 -673
  35. data/frameworks/sproutcore/frameworks/deprecated/system/animator.js +0 -679
  36. data/frameworks/sproutcore/frameworks/deprecated/system/binding.js +0 -36
  37. data/frameworks/sproutcore/frameworks/deprecated/system/browser.js +0 -75
  38. data/frameworks/sproutcore/frameworks/deprecated/system/classic_responder.js +0 -312
  39. data/frameworks/sproutcore/frameworks/deprecated/system/event.js +0 -58
  40. data/frameworks/sproutcore/frameworks/deprecated/system/globals.js +0 -20
  41. data/frameworks/sproutcore/frameworks/deprecated/system/misc.js +0 -58
  42. data/frameworks/sproutcore/frameworks/deprecated/system/node_descriptor.js +0 -72
  43. data/frameworks/sproutcore/frameworks/deprecated/system/object.js +0 -122
  44. data/frameworks/sproutcore/frameworks/deprecated/system/path_module.js +0 -432
  45. data/frameworks/sproutcore/frameworks/deprecated/system/string.js +0 -107
  46. data/frameworks/sproutcore/frameworks/deprecated/tests/application/application.rhtml +0 -125
  47. data/frameworks/sproutcore/frameworks/deprecated/tests/views/classic_view/clippingFrame.rhtml +0 -401
  48. data/frameworks/sproutcore/frameworks/deprecated/tests/views/classic_view/frame.rhtml +0 -357
  49. data/frameworks/sproutcore/frameworks/deprecated/tests/views/classic_view/isVisibleInWindow.rhtml +0 -147
  50. data/frameworks/sproutcore/frameworks/deprecated/tests/views/collection/base.rhtml +0 -298
  51. data/frameworks/sproutcore/frameworks/deprecated/tests/views/collection/incremental_rendering.rhtml +0 -260
  52. data/frameworks/sproutcore/frameworks/deprecated/tests/views/collection/source_list_rendering.rhtml +0 -143
  53. data/frameworks/sproutcore/frameworks/deprecated/tests/views/popup_button.rhtml +0 -128
  54. data/frameworks/sproutcore/frameworks/deprecated/tests/views/text_field.rhtml +0 -37
  55. data/frameworks/sproutcore/frameworks/deprecated/views/collection.js +0 -24
@@ -1,298 +0,0 @@
1
- <% content_for('final') do %>
2
- <script>
3
-
4
- // create some item data...
5
- [
6
- { guid: '1001', name: 'item one' },
7
- { guid: '1002', name: 'item two' },
8
- { guid: '1003', name: 'item three' },
9
- { guid: '1004', name: 'item four' },
10
- { guid: '1005', name: 'item five' },
11
- { guid: '1006', name: 'item six' }
12
- ].each(function(o){ SC.Store.addRecord(SC.Record.create(o)); });
13
-
14
- // a collection to hold the items...
15
- testCollection = SC.Record.collection();
16
- testCollection.refresh();
17
-
18
- // a controller for the collection...
19
- testController = SC.CollectionController.create();
20
-
21
- Test.context("A SC.CollectionView with it's content set to a SC.CollectionController 1", {
22
-
23
- "Should scroll to the selected item": function()
24
- {
25
- equals(0, testCollectionView.get('rootElement').scrollTop, "scrollTop") ;
26
- testCollectionView.scrollToContent( testCollection.get('records').last() );
27
-
28
- equals(3, testCollectionView.get('itemViews').length, 'itemViews.length') ;
29
- equals(30, scrollView.get('rootElement').scrollTop, "scrollTop 2") ;
30
- },
31
-
32
- setup: function()
33
- {
34
- // add a scroll view wrapper.
35
- scrollView = SC.ScrollView.create() ;
36
- scrollView.set('frame', { x: 10, y: 10, width: 100, height: 30 }) ;
37
- SC.window.appendChild(scrollView) ;
38
-
39
- // create the view...
40
- testCollectionView = SC.ListView.create({
41
- contentValueKey: 'name',
42
- contentBinding: 'testController.arrangedObjects',
43
- selectionBinding: 'testController.selection'
44
- }) ;
45
- scrollView.set('content', testCollectionView) ;
46
-
47
- testController.set('content', testCollection) ;
48
- SC.Binding.flushPendingChanges();
49
- },
50
-
51
- teardown: function()
52
- {
53
- // remove the view from SC.window
54
- testCollectionView.removeFromParent() ;
55
- scrollView.removeFromParent() ;
56
-
57
- delete testCollectionView ;
58
- delete scrollView ;
59
-
60
- testController.set('content', null) ;
61
- SC.Binding.flushPendingChanges();
62
- }
63
-
64
- });
65
-
66
- Test.context("A SC.CollectionView with it's content set to a SC.CollectionController 2", {
67
-
68
- "Should not scroll to the selected item if it's already fully visible": function()
69
- {
70
- scrollView.get('rootElement').scrollTop.shouldEqual(0);
71
- testCollectionView.scrollToContent( testCollection.get('records')[1] );
72
- scrollView.get('rootElement').scrollTop.shouldEqual(0);
73
- },
74
-
75
- setup: function()
76
- {
77
- // add a scroll view wrapper.
78
- scrollView = SC.ScrollView.create() ;
79
- scrollView.set('frame', { x: 10, y: 10, width: 100, height: 30 }) ;
80
- SC.window.appendChild(scrollView) ;
81
-
82
- // create the view...
83
- testCollectionView = SC.ListView.create({
84
- contentValueKey: 'name',
85
- contentBinding: 'testController.arrangedObjects',
86
- selectionBinding: 'testController.selection'
87
- }) ;
88
- scrollView.set('content', testCollectionView) ;
89
-
90
- testController.set('content', testCollection) ;
91
- },
92
-
93
- teardown: function()
94
- {
95
- // remove the view from SC.window
96
- testCollectionView.removeFromParent() ;
97
- scrollView.removeFromParent() ;
98
-
99
- delete testCollectionView ;
100
- delete scrollView ;
101
-
102
- testController.set('content', null) ;
103
- }
104
-
105
- });
106
-
107
- Test.context("A SC.CollectionView with it's content set to a SC.CollectionController 3", {
108
-
109
- "Should contain the same number of visible item views as it's controller has records": function()
110
- {
111
- equals(2, testCollectionView.get("itemViews").length, "itemViews.length") ;
112
- },
113
-
114
- "Should update it's item views as it's controller is updated": function()
115
- {
116
- var valueOfFirstItemView = function() {
117
- var itemView = testCollectionView.get('itemViews')[0] ;
118
- return (itemView) ? itemView.get('content').get('guid') : null ;
119
- } ;
120
-
121
- equals('1001', valueOfFirstItemView(), 'valueOfFirstItemView'); ;
122
-
123
- var rec = SC.Record.create({ guid: '0999', name: 'item zero' });
124
- SC.Store.addRecord( rec );
125
- SC.Binding.flushPendingChanges();
126
-
127
- equals('0999', valueOfFirstItemView(), 'valueOfFirstItemView'); ;
128
- equals(2, testCollectionView.get('itemViews').length, 'itemViews.length 2') ;
129
-
130
- rec.destroy();
131
- SC.Store.removeRecord(rec);
132
- SC.Binding.flushPendingChanges();
133
-
134
- delete rec;
135
- },
136
-
137
- setup: function()
138
- {
139
- // add a scroll view wrapper.
140
- scrollView = SC.ScrollView.create() ;
141
- scrollView.set('frame', { x: 10, y: 10, width: 100, height: 30 }) ;
142
- SC.window.appendChild(scrollView) ;
143
-
144
- // create the view...
145
- testCollectionView = SC.ListView.create({
146
- contentValueKey: 'name',
147
- contentBinding: 'testController.arrangedObjects',
148
- selectionBinding: 'testController.selection'
149
- }) ;
150
- scrollView.set('content', testCollectionView) ;
151
-
152
- testController.set('content', testCollection) ;
153
- SC.Binding.flushPendingChanges() ;
154
- },
155
-
156
- teardown: function()
157
- {
158
- // remove the view from SC.window
159
- testCollectionView.removeFromParent() ;
160
- scrollView.removeFromParent() ;
161
-
162
- delete testCollectionView ;
163
- delete scrollView ;
164
-
165
- testController.set('content', null) ;
166
- }
167
-
168
- });
169
-
170
- Test.context("A SC.CollectionView with it's content set to a SC.ArrayController", {
171
- "Should contain the same number of item views as it's controller has records": function()
172
- {
173
- this.controller.get('length').shouldEqual(6);
174
- this.view.get('itemViews').length.shouldEqual(6);
175
- },
176
- "Should update it's item views as it's controller is updated": function()
177
- {
178
- this.view.get('itemViews').length.shouldEqual(6);
179
- this.controller.pushObject({ guid: '1007', name: 'item seven' });
180
- this.view.get('itemViews').length.shouldEqual(7);
181
- this.controller.popObject();
182
- this.view.get('itemViews').length.shouldEqual(6);
183
- },
184
-
185
- setup: function()
186
- {
187
- // create the view...
188
- this.view = SC.CollectionView.create();
189
- SC.window.appendChild(this.view);
190
-
191
- // create some item data...
192
- this.array = [
193
- { guid: '1001', name: 'item one' },
194
- { guid: '1002', name: 'item two' },
195
- { guid: '1003', name: 'item three' },
196
- { guid: '1004', name: 'item four' },
197
- { guid: '1005', name: 'item five' },
198
- { guid: '1006', name: 'item six' }
199
- ];
200
-
201
- this.controller = SC.ArrayController.create();
202
- this.controller.set('content', this.array);
203
- this.view.set('content', this.controller);
204
- },
205
- teardown: function()
206
- {
207
- // remove the view from SC.window
208
- this.view.removeFromParent();
209
-
210
- delete this.view;
211
- delete this.array;
212
- delete this.controller;
213
- }
214
- });
215
-
216
- Test.context("SC.CollectionView selection delegate support", {
217
- "Should use isSelectable to determine selectability in the absence of a delegate": function () {
218
- this.view.set('delegate', null);
219
- this.view.set('isSelectable', NO);
220
- this.view.selectItems([this.array[0], this.array[1]]);
221
- this.view.get('selection').length.shouldEqual(0);
222
-
223
- this.view.set('isSelectable', YES);
224
- this.view.selectItems([this.array[0], this.array[1]]);
225
- this.view.get('selection').length.shouldEqual(2);
226
- },
227
-
228
- "Should query the delegate for selectability": function () {
229
- this.view.selectItems([this.array[0], this.array[1]]);
230
- this.view.get('selection').shouldEqualEnum([this.array[1]]);
231
- },
232
-
233
- "Should select the next selectable item": function () {
234
- this.view.selectItems([this.array[2]]);
235
- this.view.selectNextItem();
236
- this.view.get('selection').shouldEqualEnum([this.array[4]]);
237
- },
238
-
239
- "Should select the previous selectable item": function () {
240
- this.view.selectItems([this.array[2]]);
241
- this.view.selectPreviousItem();
242
- this.view.get('selection').shouldEqualEnum([this.array[1]]);
243
- },
244
-
245
- "Should retain selection when no previous item is selectable": function () {
246
- this.view.selectItems([this.array[1]]);
247
- this.view.selectPreviousItem();
248
- this.view.get('selection').shouldEqualEnum([this.array[1]]);
249
- },
250
-
251
- "Should retain selection when no further item is selectable": function () {
252
- this.view.selectItems([this.array[4]]);
253
- this.view.selectNextItem();
254
- this.view.get('selection').shouldEqualEnum([this.array[4]]);
255
- },
256
-
257
- setup: function () {
258
- // create the view...
259
- this.view = SC.CollectionView.create();
260
- SC.window.appendChild(this.view);
261
-
262
- // create some item data...
263
- this.array = [
264
- { guid: '1001', name: 'item one', canSelect: NO },
265
- { guid: '1002', name: 'item two', canSelect: YES },
266
- { guid: '1003', name: 'item three', canSelect: YES },
267
- { guid: '1004', name: 'item four', canSelect: NO },
268
- { guid: '1005', name: 'item five', canSelect: YES },
269
- { guid: '1006', name: 'item six', canSelect: NO }
270
- ];
271
-
272
- this.delegate = SC.Object.create({
273
- collectionViewShouldSelectItem: function (view, item) {
274
- return item.canSelect;
275
- }
276
- });
277
-
278
- this.controller = SC.ArrayController.create();
279
- this.controller.set('content', this.array);
280
- this.view.set('isSelectable', YES);
281
- this.view.set('content', this.controller);
282
- this.view.set('delegate', this.delegate);
283
- },
284
-
285
- teardown: function () {
286
- // remove the view from SC.window
287
- this.view.removeFromParent();
288
-
289
- delete this.view;
290
- delete this.array;
291
- delete this.delegate;
292
- delete this.controller;
293
- }
294
- });
295
-
296
- </script>
297
-
298
- <% end %>
@@ -1,260 +0,0 @@
1
- <% content_for('final') do %>
2
- <script>
3
-
4
- /*
5
- This set of tests verifies that the collection view can render content and pass a
6
- battery of functional tests for four different supported configurations:
7
-
8
- - No scrolling, no incremental rendering, no custom layout: all views are rendered and view expands
9
- - no scrolling, no incremental rendering, custom layout
10
-
11
- - autoscroll, no incremental rendering, no custom layout: all views are rendered and view has overlow: auto
12
- - autoscroll, no incremental rendering, custom layout
13
-
14
- -
15
- - scrollview, no incremental rendering, no custom layout: all views are rendered and lives in scrollview.
16
- - scrollview, no incremental rendering, custom layout: all views are rendered and lives in scrollview.
17
- - scrollview, incremental rendering: incrementally rendered views; lives in scroll view
18
-
19
- The standard tests are below. The actual contexts setup at the end of this code
20
- configure the above four scenarios.
21
- */
22
- SC.StandardTests = {
23
-
24
- "dummy test": function() {
25
- }
26
-
27
- };
28
-
29
- // Common methods to setup the collection views for testing
30
- SC.CollectionViewTest = {
31
- setup: function(that, props) { this._setup.call(that, props) ; },
32
-
33
- _setup: function(props) {
34
-
35
- // create the controller
36
- this.controller = SC.ArrayController.create();
37
-
38
- // create the view, bind it to the controller
39
- props = props || {} ;
40
- props.contentBinding = [this.controller, 'arrangedObjects'];
41
- props.selectionBinding = [this.controller, 'selection'];
42
- props.delegate = this.controller ;
43
-
44
- if (!props.exampleView) props.exampleView = SC.LabelView ;
45
- if (!props.contentValueKey) props.contentValueKey = 'name' ;
46
-
47
- // create the view with the props
48
- this.view = SC.CollectionView.create(props);
49
- this.view.addClassName('test-collection') ;
50
-
51
- var container = SC.ClassicView.extend({
52
- emptyElement: '<div class="test-container"></div>'
53
- }).create() ;
54
-
55
- container.appendChild(this.view) ;
56
- SC.page.get('root').appendChild(container);
57
-
58
- // create some item data... use a lot.
59
- this.data = [] ;
60
- var idx = 100 ;
61
- while(--idx >= 0) {
62
- this.data[this.data.length] = SC.Object.create({
63
- guid: (1000 + idx).toString(),
64
- name: "Item %@".fmt(1000 + idx)
65
- }) ;
66
- }
67
-
68
- // set the content to the array
69
- this.controller.set('content', this.data);
70
- },
71
-
72
- teardown: function(that) { this._teardown.call(that); },
73
- _teardown: function() {
74
-
75
- // remove view from the parent
76
- this.view.removeFromParent() ;
77
-
78
- // unhook some things
79
- this.controller.set('content', null) ;
80
-
81
- // delete the view, controller, etc.
82
- delete this.view ;
83
- delete this.controller ;
84
- delete this.data ;
85
- }
86
-
87
- } ;
88
-
89
- Test.context("CASE 1: No scrolling, no incremental rendering, no custom layout",
90
- SC.mixin(SC.StandardTests,{
91
-
92
- setup: function() {
93
- SC.CollectionViewTest.setup(this, {
94
- exampleView: SC.LabelView.extend({
95
- emptyElement: '<div class="text-cell sc-collection-item" style="position: relative;"></div>'
96
- })
97
- }) ;
98
-
99
- window.context = this ;
100
- },
101
-
102
- teardown: function() {
103
- //SC.CollectionViewTest.teardown(this) ;
104
- }
105
-
106
- }));
107
-
108
- Test.context("CASE 2: No scrolling, no incremental rendering, custom layout",
109
- SC.mixin(SC.StandardTests,{
110
-
111
- setup: function() {
112
- SC.CollectionViewTest.setup(this, {
113
-
114
- rowHeight: 22,
115
-
116
- layoutItemViewsFor: function(parentView, startingView) {
117
- var rowHeight = this.get('rowHeight') ;
118
- if (rowHeight == null) return false ;
119
-
120
- if (!startingView) startingView = parentView.firstChild ;
121
- var y = (startingView && startingView.previousSibling) ? SC.maxY(startingView.previousSibling.get('frame')) : 0;
122
- var f = (parentView || this).get('innerFrame') ;
123
- f = { x: 0, height: rowHeight, width: f.width } ;
124
- var view = startingView || parentView.firstChild;
125
- while(view) {
126
- f.y = y ;
127
- if (!SC.rectsEqual(view.get('frame'), f)) view.set('frame', f) ;
128
- y += rowHeight;
129
- view = view.nextSibling ;
130
- }
131
- return true;
132
- },
133
-
134
- computeFrame: function() {
135
- return { height: this.get('content') * this.get('rowHeight') } ;
136
- }
137
-
138
- }) ;
139
- },
140
-
141
- teardown: function() {
142
- //SC.CollectionViewTest.teardown(this) ;
143
- }
144
-
145
- }));
146
-
147
-
148
- Test.context("CASE 3: Autoscrolling, no incremental rendering, no custom layout",
149
- SC.mixin(SC.StandardTests,{
150
-
151
- setup: function() {
152
- SC.CollectionViewTest.setup(this, {
153
- exampleView: SC.LabelView.extend({
154
- emptyElement: '<div class="text-cell sc-collection-item" style="position: relative;"></div>'
155
- }),
156
-
157
- init: function() {
158
- arguments.callee.base.apply(this) ;
159
- this.setStyle({ overflow: "auto", height: '200px' }) ;
160
- }
161
- }) ;
162
- },
163
-
164
- teardown: function() {
165
- //SC.CollectionViewTest.teardown(this) ;
166
- }
167
-
168
- }));
169
-
170
- Test.context("CASE 4: Autoscrolling, no incremental rendering, custom layout",
171
- SC.mixin(SC.StandardTests,{
172
-
173
- setup: function() {
174
- SC.CollectionViewTest.setup(this, {
175
-
176
- rowHeight: 22,
177
-
178
- layoutItemViewsFor: function(parentView, startingView) {
179
- var rowHeight = this.get('rowHeight') ;
180
- if (rowHeight == null) return false ;
181
-
182
- if (!startingView) startingView = parentView.firstChild ;
183
- var y = (startingView && startingView.previousSibling) ? SC.maxY(startingView.previousSibling.get('frame')) : 0;
184
- var f = (parentView || this).get('innerFrame') ;
185
- f = { x: 0, height: rowHeight, width: f.width } ;
186
- var view = startingView || parentView.firstChild;
187
- while(view) {
188
- f.y = y ;
189
- if (!SC.rectsEqual(view.get('frame'), f)) view.set('frame', f) ;
190
- y += rowHeight;
191
- view = view.nextSibling ;
192
- }
193
- return true;
194
- },
195
-
196
- computeFrame: function() {
197
- return { height: 200 } ;
198
- },
199
-
200
- init: function() {
201
- arguments.callee.base.apply(this) ;
202
- this.setStyle({ overflow: "auto", height: '200px' }) ;
203
- }
204
-
205
- }) ;
206
- },
207
-
208
- teardown: function() {
209
- //SC.CollectionViewTest.teardown(this) ;
210
- }
211
-
212
- }));
213
-
214
-
215
-
216
- main = function() { SC.page.awake(); } ;
217
-
218
- </script>
219
-
220
- <% end %>
221
-
222
- <% content_for('body') do %>
223
- <style>
224
-
225
- .test-collection {
226
- position: relative;
227
- width: 180px;
228
- border: 1px #ccc solid;
229
- background-color: white;
230
- }
231
-
232
- .root {
233
- position: fixed;
234
- bottom: 0;
235
- left: 0 ;
236
- width: 100%;
237
- border-top: 1px #ccc solid;
238
- padding: 10px;
239
- height: 220px;
240
- overflow: auto;
241
- z-index: 10000000;
242
- background-color: #f0f0f0;
243
- }
244
-
245
- .test-container {
246
- float: left;
247
- width: 200px;
248
- padding: 10px;
249
- border: 1px #ccc solid;
250
- position: relative;
251
- overflow: auto;
252
- height: 200px;
253
- border: 1px red dotted;
254
- }
255
-
256
- </style>
257
-
258
- <%= view :root %>
259
-
260
- <% end %>