sproutcore 0.9.1 → 0.9.2
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +233 -0
- data/Manifest.txt +67 -34
- data/bin/sc-build +12 -1
- data/bin/sc-gen +1 -1
- data/bin/sproutcore +14 -0
- data/clients/sc_docs/controllers/docs.js +38 -8
- data/clients/sc_docs/english.lproj/body.css +80 -127
- data/clients/sc_docs/english.lproj/body.rhtml +43 -23
- data/clients/sc_docs/english.lproj/no_docs.rhtml +2 -1
- data/clients/sc_docs/english.lproj/tabs.rhtml +16 -0
- data/clients/sc_docs/main.js +14 -9
- data/clients/sc_docs/models/doc.js +1 -1
- data/clients/sc_docs/tests/controllers/docs.rhtml +1 -2
- data/clients/sc_docs/tests/models/doc.rhtml +1 -2
- data/clients/sc_docs/tests/views/doc_frame.rhtml +1 -2
- data/clients/sc_docs/tests/views/doc_label_view.rhtml +1 -2
- data/clients/sc_docs/views/doc_frame.js +1 -1
- data/clients/sc_test_runner/controllers/runner.js +31 -8
- data/clients/sc_test_runner/english.lproj/body.css +62 -122
- data/clients/sc_test_runner/english.lproj/body.rhtml +62 -26
- data/clients/sc_test_runner/main.js +1 -6
- data/clients/sc_test_runner/models/test.js +14 -1
- data/clients/sc_test_runner/views/runner_frame.js +4 -2
- data/clients/view_builder/builders/builder.js +339 -0
- data/clients/view_builder/builders/button.js +81 -0
- data/clients/view_builder/controllers/document.js +21 -0
- data/clients/view_builder/core.js +19 -0
- data/clients/view_builder/english.lproj/body.css +77 -0
- data/clients/view_builder/english.lproj/body.rhtml +41 -0
- data/clients/{sc_docs → view_builder}/english.lproj/controls.css +0 -0
- data/clients/view_builder/english.lproj/strings.js +14 -0
- data/clients/view_builder/main.js +38 -0
- data/clients/view_builder/tests/controllers/document.rhtml +20 -0
- data/clients/view_builder/tests/views/builder.rhtml +20 -0
- data/clients/view_builder/views/builder.js +23 -0
- data/frameworks/prototype/prototype.js +1 -1
- data/frameworks/sproutcore/Core.js +32 -7
- data/frameworks/sproutcore/README +1 -1
- data/frameworks/sproutcore/animation/animation.js +411 -0
- data/frameworks/sproutcore/controllers/array.js +17 -9
- data/frameworks/sproutcore/controllers/collection.js +9 -110
- data/frameworks/sproutcore/controllers/controller.js +1 -1
- data/frameworks/sproutcore/controllers/object.js +2 -1
- data/frameworks/sproutcore/drag/drag.js +267 -56
- data/frameworks/sproutcore/drag/drag_data_source.js +24 -16
- data/frameworks/sproutcore/drag/drag_source.js +53 -42
- data/frameworks/sproutcore/drag/drop_target.js +2 -2
- data/frameworks/sproutcore/english.lproj/buttons.css +337 -236
- data/frameworks/sproutcore/english.lproj/core.css +115 -0
- data/frameworks/sproutcore/english.lproj/icons.css +227 -0
- data/{clients/sc_docs → frameworks/sproutcore}/english.lproj/images/indicator.gif +0 -0
- data/frameworks/sproutcore/english.lproj/images/sc-theme-sprite.png +0 -0
- data/frameworks/sproutcore/english.lproj/images/sc-theme-ysprite.png +0 -0
- data/frameworks/sproutcore/english.lproj/images/shared-icons.png +0 -0
- data/frameworks/sproutcore/english.lproj/menu.css +1 -1
- data/frameworks/sproutcore/english.lproj/strings.js +1 -1
- data/frameworks/sproutcore/english.lproj/theme.css +405 -31
- data/frameworks/sproutcore/foundation/application.js +15 -11
- data/frameworks/sproutcore/foundation/benchmark.js +1 -1
- data/frameworks/sproutcore/foundation/binding.js +2 -2
- data/frameworks/sproutcore/foundation/date.js +1 -1
- data/frameworks/sproutcore/foundation/error.js +1 -1
- data/frameworks/sproutcore/foundation/input_manager.js +32 -21
- data/frameworks/sproutcore/foundation/mock.js +1 -1
- data/frameworks/sproutcore/foundation/node_descriptor.js +9 -6
- data/frameworks/sproutcore/foundation/object.js +249 -177
- data/frameworks/sproutcore/foundation/page.js +5 -2
- data/frameworks/sproutcore/foundation/path_module.js +11 -10
- data/frameworks/sproutcore/foundation/responder.js +5 -2
- data/frameworks/sproutcore/foundation/routes.js +17 -13
- data/frameworks/sproutcore/foundation/run_loop.js +249 -11
- data/frameworks/sproutcore/foundation/server.js +1 -1
- data/frameworks/sproutcore/foundation/set.js +3 -3
- data/frameworks/sproutcore/foundation/string.js +5 -3
- data/frameworks/sproutcore/foundation/timer.js +371 -0
- data/frameworks/sproutcore/foundation/undo_manager.js +1 -1
- data/frameworks/sproutcore/foundation/unittest.js +3 -3
- data/frameworks/sproutcore/foundation/utils.js +161 -2
- data/frameworks/sproutcore/globals/panels.js +1 -1
- data/frameworks/sproutcore/globals/popups.js +4 -3
- data/frameworks/sproutcore/globals/window.js +44 -4
- data/frameworks/sproutcore/lib/button_views.rb +328 -0
- data/frameworks/sproutcore/lib/collection_view.rb +80 -0
- data/frameworks/sproutcore/lib/core_views.rb +281 -0
- data/frameworks/sproutcore/lib/form_views.rb +253 -0
- data/frameworks/sproutcore/lib/index.rhtml +2 -0
- data/frameworks/sproutcore/lib/menu_views.rb +88 -0
- data/frameworks/sproutcore/{foundation → mixins}/array.js +60 -29
- data/frameworks/sproutcore/mixins/control.js +265 -0
- data/frameworks/sproutcore/mixins/delegate_support.js +66 -0
- data/frameworks/sproutcore/{foundation → mixins}/observable.js +176 -6
- data/frameworks/sproutcore/mixins/scrollable.js +245 -0
- data/frameworks/sproutcore/mixins/selection_support.js +148 -0
- data/frameworks/sproutcore/mixins/validatable.js +152 -0
- data/frameworks/sproutcore/models/collection.js +5 -5
- data/frameworks/sproutcore/models/record.js +1 -1
- data/frameworks/sproutcore/models/store.js +1 -1
- data/frameworks/sproutcore/panes/dialog.js +1 -1
- data/frameworks/sproutcore/panes/manager.js +1 -1
- data/frameworks/sproutcore/panes/menu.js +1 -1
- data/frameworks/sproutcore/panes/overlay.js +2 -2
- data/frameworks/sproutcore/panes/panel.js +1 -1
- data/frameworks/sproutcore/panes/picker.js +1 -1
- data/frameworks/sproutcore/tests/controllers/array.rhtml +44 -4
- data/frameworks/sproutcore/tests/foundation/timer/invalidate.rhtml +33 -0
- data/frameworks/sproutcore/tests/foundation/timer/invokeLater.rhtml +145 -0
- data/frameworks/sproutcore/tests/foundation/timer/isPaused.rhtml +70 -0
- data/frameworks/sproutcore/tests/foundation/timer/schedule.rhtml +145 -0
- data/frameworks/sproutcore/tests/views/{scroll.rhtml → checkbox.rhtml} +3 -3
- data/frameworks/sproutcore/tests/views/{collection.rhtml → collection/base.rhtml} +33 -32
- data/frameworks/sproutcore/tests/views/collection/incremental_rendering.rhtml +260 -0
- data/frameworks/sproutcore/tests/views/image_cell.rhtml +19 -0
- data/frameworks/sproutcore/tests/views/label_item.rhtml +2 -4
- data/frameworks/sproutcore/tests/views/list.rhtml +2 -3
- data/frameworks/sproutcore/tests/views/list_item.rhtml +20 -0
- data/frameworks/sproutcore/tests/views/slider.rhtml +20 -0
- data/frameworks/sproutcore/tests/views/text_cell.rhtml +19 -0
- data/frameworks/sproutcore/tests/views/view/clippingFrame.rhtml +395 -0
- data/frameworks/sproutcore/tests/views/view/frame.rhtml +353 -0
- data/frameworks/sproutcore/tests/views/view/innerFrame.rhtml +347 -0
- data/frameworks/sproutcore/tests/views/view/isVisibleInWindow.rhtml +148 -0
- data/frameworks/sproutcore/tests/views/view/scrollFrame.rhtml +468 -0
- data/frameworks/sproutcore/validators/credit_card.js +33 -13
- data/frameworks/sproutcore/validators/date.js +26 -6
- data/frameworks/sproutcore/validators/email.js +21 -3
- data/frameworks/sproutcore/validators/not_empty.js +11 -1
- data/frameworks/sproutcore/validators/number.js +18 -4
- data/frameworks/sproutcore/validators/password.js +12 -1
- data/frameworks/sproutcore/validators/validator.js +204 -194
- data/frameworks/sproutcore/views/{button.js → button/button.js} +96 -94
- data/frameworks/sproutcore/views/button/checkbox.js +29 -0
- data/frameworks/sproutcore/views/button/disclosure.js +42 -0
- data/frameworks/sproutcore/views/button/radio.js +29 -0
- data/frameworks/sproutcore/views/{collection.js → collection/collection.js} +1373 -1024
- data/frameworks/sproutcore/views/collection/grid.js +124 -46
- data/frameworks/sproutcore/views/collection/image_cell.js +17 -46
- data/frameworks/sproutcore/views/collection/list.js +45 -35
- data/frameworks/sproutcore/views/collection/source_list.js +386 -0
- data/frameworks/sproutcore/views/collection/table.js +118 -0
- data/frameworks/sproutcore/views/container.js +7 -2
- data/frameworks/sproutcore/views/error_explanation.js +23 -10
- data/frameworks/sproutcore/views/{checkbox_field.js → field/checkbox_field.js} +16 -6
- data/frameworks/sproutcore/views/field/field.js +219 -0
- data/frameworks/sproutcore/views/{radio_field.js → field/radio_field.js} +27 -12
- data/frameworks/sproutcore/views/{select_field.js → field/select_field.js} +116 -90
- data/frameworks/sproutcore/views/{text_field.js → field/text_field.js} +57 -8
- data/frameworks/sproutcore/views/{textarea_field.js → field/textarea_field.js} +13 -3
- data/frameworks/sproutcore/views/filter_button.js +2 -2
- data/frameworks/sproutcore/views/form.js +3 -3
- data/frameworks/sproutcore/views/image.js +128 -21
- data/frameworks/sproutcore/views/inline_text_editor.js +1 -1
- data/frameworks/sproutcore/views/label.js +149 -92
- data/frameworks/sproutcore/views/list_item.js +225 -0
- data/frameworks/sproutcore/views/menu_item.js +10 -4
- data/frameworks/sproutcore/views/pagination.js +11 -4
- data/frameworks/sproutcore/views/popup_button.js +25 -21
- data/frameworks/sproutcore/views/popup_menu.js +10 -4
- data/frameworks/sproutcore/views/progress.js +29 -16
- data/frameworks/sproutcore/views/radio_group.js +1 -1
- data/frameworks/sproutcore/views/scroll.js +60 -20
- data/frameworks/sproutcore/views/segmented.js +1 -1
- data/frameworks/sproutcore/views/slider.js +132 -0
- data/frameworks/sproutcore/views/source_list_group.js +130 -0
- data/frameworks/sproutcore/views/spinner.js +1 -1
- data/frameworks/sproutcore/views/split.js +292 -0
- data/frameworks/sproutcore/views/split_divider.js +109 -0
- data/frameworks/sproutcore/views/tab.js +1 -1
- data/frameworks/sproutcore/views/toolbar.js +1 -1
- data/frameworks/sproutcore/views/view.js +1272 -591
- data/generators/client/templates/english.lproj/body.css +1 -1
- data/generators/controller/controller_generator.rb +1 -1
- data/generators/controller/templates/test.rhtml +2 -1
- data/generators/model/templates/test.rhtml +1 -1
- data/generators/test/templates/test.rhtml +1 -1
- data/generators/view/templates/test.rhtml +1 -1
- data/jsdoc/templates/sproutcore/class.tmpl +241 -338
- data/jsdoc/templates/sproutcore/default.css +105 -155
- data/jsdoc/templates/sproutcore/index.tmpl +43 -8
- data/jsdoc/templates/sproutcore/publish.js +9 -4
- data/lib/sproutcore/build_tools/html_builder.rb +29 -13
- data/lib/sproutcore/build_tools/resource_builder.rb +1 -1
- data/lib/sproutcore/bundle.rb +86 -25
- data/lib/sproutcore/jsdoc.rb +2 -0
- data/lib/sproutcore/version.rb +1 -1
- data/lib/sproutcore/view_helpers.rb +36 -3
- data/tasks/deployment.rake +1 -1
- metadata +69 -36
- data/clients/sc_docs/english.lproj/icons/small/next.png +0 -0
- data/clients/sc_docs/english.lproj/icons/small/reset.png +0 -0
- data/clients/sc_docs/english.lproj/images/gradients.png +0 -0
- data/clients/sc_docs/english.lproj/images/toolbar.png +0 -0
- data/clients/sc_docs/english.lproj/warning.rhtml +0 -6
- data/clients/sc_test_runner/english.lproj/warning.rhtml +0 -6
- data/frameworks/sproutcore/english.lproj/buttons.png +0 -0
- data/frameworks/sproutcore/english.lproj/collections.css +0 -82
- data/frameworks/sproutcore/english.lproj/images/buttons-sprite.png +0 -0
- data/frameworks/sproutcore/views/collection/collection_item.js +0 -36
- data/frameworks/sproutcore/views/collection/text_cell.js +0 -128
- data/frameworks/sproutcore/views/field.js +0 -214
- data/frameworks/sproutcore/views/workspace.js +0 -170
- data/generators/client/templates/english.lproj/controls.css +0 -0
- data/generators/framework/templates/english.lproj/body.css +0 -0
- data/generators/framework/templates/english.lproj/body.rhtml +0 -3
- data/generators/framework/templates/english.lproj/controls.css +0 -0
- data/lib/sproutcore/view_helpers/button_views.rb +0 -302
- data/lib/sproutcore/view_helpers/core_views.rb +0 -292
- data/lib/sproutcore/view_helpers/form_views.rb +0 -258
- data/lib/sproutcore/view_helpers/menu_views.rb +0 -94
@@ -0,0 +1,260 @@
|
|
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.View.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
|
+
Object.extend(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
|
+
Object.extend(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
|
+
Object.extend(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, arguments) ;
|
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
|
+
Object.extend(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, arguments) ;
|
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 %>
|
@@ -0,0 +1,19 @@
|
|
1
|
+
<% # ========================================================================
|
2
|
+
# SC.LabelItemView Unit Test
|
3
|
+
# ========================================================================
|
4
|
+
%>
|
5
|
+
<% content_for('final') do %>
|
6
|
+
|
7
|
+
<script>
|
8
|
+
|
9
|
+
Test.context("SC.ImageCellView",{
|
10
|
+
|
11
|
+
"TODO: Add your own tests here": function() {
|
12
|
+
true.shouldEqual(true) ;
|
13
|
+
}
|
14
|
+
|
15
|
+
}) ;
|
16
|
+
|
17
|
+
</script>
|
18
|
+
|
19
|
+
<% end %>
|
@@ -1,12 +1,12 @@
|
|
1
1
|
<% # ========================================================================
|
2
|
-
#
|
2
|
+
# SC.LabelItemView Unit Test
|
3
3
|
# ========================================================================
|
4
4
|
%>
|
5
5
|
<% content_for('final') do %>
|
6
6
|
|
7
7
|
<script>
|
8
8
|
|
9
|
-
Test.context("
|
9
|
+
Test.context("SC.LabelItemView",{
|
10
10
|
|
11
11
|
"TODO: Add your own tests here": function() {
|
12
12
|
true.shouldEqual(true) ;
|
@@ -14,8 +14,6 @@ Test.context("Sproutcore.LabelItemView",{
|
|
14
14
|
|
15
15
|
}) ;
|
16
16
|
|
17
|
-
appMain = main; main = null ; // Cancel main() so app does not start
|
18
|
-
|
19
17
|
</script>
|
20
18
|
|
21
19
|
<% end %>
|
@@ -1,12 +1,12 @@
|
|
1
1
|
<% # ========================================================================
|
2
|
-
#
|
2
|
+
# SC.ListView Unit Test
|
3
3
|
# ========================================================================
|
4
4
|
%>
|
5
5
|
<% content_for('final') do %>
|
6
6
|
|
7
7
|
<script>
|
8
8
|
|
9
|
-
Test.context("
|
9
|
+
Test.context("SC.ListView",{
|
10
10
|
|
11
11
|
"TODO: Add your own tests here": function() {
|
12
12
|
true.shouldEqual(true) ;
|
@@ -14,7 +14,6 @@ Test.context("Sproutcore.ListView",{
|
|
14
14
|
|
15
15
|
}) ;
|
16
16
|
|
17
|
-
appMain = main; main = null ; // Cancel main() so app does not start
|
18
17
|
|
19
18
|
</script>
|
20
19
|
|
@@ -0,0 +1,20 @@
|
|
1
|
+
<% # ========================================================================
|
2
|
+
# SC.ListItemView Unit Test
|
3
|
+
# ========================================================================
|
4
|
+
%>
|
5
|
+
<% content_for('final') do %>
|
6
|
+
|
7
|
+
<script>
|
8
|
+
|
9
|
+
Test.context("SC.ListItemView",{
|
10
|
+
|
11
|
+
"TODO: Add your own tests here": function() {
|
12
|
+
true.shouldEqual(true) ;
|
13
|
+
}
|
14
|
+
|
15
|
+
}) ;
|
16
|
+
|
17
|
+
if (window.main && (appMain = main)) main = null ;
|
18
|
+
</script>
|
19
|
+
|
20
|
+
<% end %>
|
@@ -0,0 +1,20 @@
|
|
1
|
+
<% # ========================================================================
|
2
|
+
# SC.SliderView Unit Test
|
3
|
+
# ========================================================================
|
4
|
+
%>
|
5
|
+
<% content_for('final') do %>
|
6
|
+
|
7
|
+
<script>
|
8
|
+
|
9
|
+
Test.context("SC.SliderView",{
|
10
|
+
|
11
|
+
"TODO: Add your own tests here": function() {
|
12
|
+
true.shouldEqual(true) ;
|
13
|
+
}
|
14
|
+
|
15
|
+
}) ;
|
16
|
+
|
17
|
+
if (window.main && (appMain = main)) main = null ;
|
18
|
+
</script>
|
19
|
+
|
20
|
+
<% end %>
|
@@ -0,0 +1,19 @@
|
|
1
|
+
<% # ========================================================================
|
2
|
+
# SC.LabelItemView Unit Test
|
3
|
+
# ========================================================================
|
4
|
+
%>
|
5
|
+
<% content_for('final') do %>
|
6
|
+
|
7
|
+
<script>
|
8
|
+
|
9
|
+
Test.context("SC.LabelView",{
|
10
|
+
|
11
|
+
"TODO: Add your own tests here": function() {
|
12
|
+
true.shouldEqual(true) ;
|
13
|
+
}
|
14
|
+
|
15
|
+
}) ;
|
16
|
+
|
17
|
+
</script>
|
18
|
+
|
19
|
+
<% end %>
|
@@ -0,0 +1,395 @@
|
|
1
|
+
<% # ========================================================================
|
2
|
+
# SC.View clippingFrame Unit Test
|
3
|
+
#
|
4
|
+
# The clippingFrame tells you what portion of the view is actually visible
|
5
|
+
# on screen. If the view is not on screen or is scrolled out of view,
|
6
|
+
# then the size of the clipping frame will be 0.
|
7
|
+
#
|
8
|
+
# ========================================================================
|
9
|
+
%>
|
10
|
+
<% content_for('final') do %>
|
11
|
+
|
12
|
+
<script>
|
13
|
+
|
14
|
+
VIEW_HEIGHT = 90 ;
|
15
|
+
CHILD_HEIGHT = 150;
|
16
|
+
NESTED_CHILD_HEIGHT = 40 ;
|
17
|
+
|
18
|
+
Test.context("CASE 1: Non-scrollable view - all view fits within content", {
|
19
|
+
|
20
|
+
"child clippingFrame should == child innerFrame": function() {
|
21
|
+
//debugger ;
|
22
|
+
var v = this.v.child ;
|
23
|
+
var f = v.get('frame') ;
|
24
|
+
var cf = v.get('clippingFrame') ;
|
25
|
+
|
26
|
+
SC.rectsEqual(f, cf).shouldEqual(true) ;
|
27
|
+
},
|
28
|
+
|
29
|
+
"resizing child frame should reflect child clippingFrame -also should notify change": function() {
|
30
|
+
var v = this.v.child ;
|
31
|
+
var f = v.get('frame') ;
|
32
|
+
var cf = v.get('clippingFrame') ; // give system a chance to cache
|
33
|
+
|
34
|
+
var didChange = false ;
|
35
|
+
v.addObserver('clippingFrame', function() { didChange = true; }) ;
|
36
|
+
v.set('frame', { width: 50, height: 50 });
|
37
|
+
didChange.shouldEqual(true) ;
|
38
|
+
|
39
|
+
var f = v.get('frame') ;
|
40
|
+
var cf = v.get('clippingFrame') ;
|
41
|
+
SC.rectsEqual(f, cf).shouldEqual(true) ;
|
42
|
+
},
|
43
|
+
|
44
|
+
"resizing parent frame should not change child clippingFrame - also should notify change": function() {
|
45
|
+
var v = this.v.child ;
|
46
|
+
var f = v.get('frame') ;
|
47
|
+
var cf = v.get('clippingFrame') ; // give system a chance to cache
|
48
|
+
|
49
|
+
var didChange = false ;
|
50
|
+
v.addObserver('clippingFrame', function() { didChange = true; }) ;
|
51
|
+
this.v.set('frame', { width: 80, height: 80 }) ;
|
52
|
+
didChange.shouldEqual(true) ;
|
53
|
+
|
54
|
+
|
55
|
+
var nf = v.get('frame') ;
|
56
|
+
var cf = v.get('clippingFrame') ;
|
57
|
+
SC.rectsEqual(nf, f).shouldEqual(false) ;
|
58
|
+
SC.rectsEqual(nf, cf).shouldEqual(true) ;
|
59
|
+
},
|
60
|
+
|
61
|
+
setup: function() { this.v = SC.page.get('case1'); }
|
62
|
+
|
63
|
+
});
|
64
|
+
|
65
|
+
Test.context("CASE 2: A scrollable view - child view cannot fit within visible area", {
|
66
|
+
|
67
|
+
"clippingFrame should reflect only the visible portion of the view": function() {
|
68
|
+
var v = this.v.child ;
|
69
|
+
var cf = v.get('clippingFrame') ;
|
70
|
+
var f = v.get('frame') ;
|
71
|
+
f.height = VIEW_HEIGHT ;
|
72
|
+
|
73
|
+
console.log('cf = %@ - f = %@ - pos = %@'.fmt($I(cf), $I(f), v.getStyle('position'))) ;
|
74
|
+
|
75
|
+
SC.rectsEqual(f,cf).shouldEqual(true) ;
|
76
|
+
},
|
77
|
+
|
78
|
+
"scrolling parent frame should change child clippingFrame (and notify)": function() {
|
79
|
+
var child = this.v.child ;
|
80
|
+
var cf = child.get('clippingFrame') ;
|
81
|
+
|
82
|
+
var didChange = false ;
|
83
|
+
child.addObserver('clippingFrame', function() { didChange = true; }) ;
|
84
|
+
|
85
|
+
// scroll
|
86
|
+
this.v.set('scrollFrame', { y: -20 }) ;
|
87
|
+
|
88
|
+
var ncf = child.get('clippingFrame') ;
|
89
|
+
cf.y = 20 ; // adjust expected frame
|
90
|
+
|
91
|
+
SC.rectsEqual(ncf, cf).shouldEqual(true) ;
|
92
|
+
didChange.shouldEqual(true) ;
|
93
|
+
|
94
|
+
this.v.set('scrollFrame', { y: 0 }) ;
|
95
|
+
},
|
96
|
+
|
97
|
+
"resizing parent frame should change child clippingFrame (and notify)": function() {
|
98
|
+
var child = this.v.child ;
|
99
|
+
var cf = child.get('clippingFrame') ;
|
100
|
+
|
101
|
+
var didChange = false ;
|
102
|
+
child.addObserver('clippingFrame', function() { didChange = true; }) ;
|
103
|
+
|
104
|
+
// scroll
|
105
|
+
this.v.set('frame', { height: 50 }) ;
|
106
|
+
|
107
|
+
var ncf = child.get('clippingFrame') ;
|
108
|
+
cf.height = 48 ; // adjust expected frame
|
109
|
+
|
110
|
+
SC.rectsEqual(ncf, cf).shouldEqual(true) ;
|
111
|
+
didChange.shouldEqual(true) ;
|
112
|
+
|
113
|
+
this.v.set('frame', { height: 90 }) ;
|
114
|
+
},
|
115
|
+
|
116
|
+
"resizing child should change clippingFrame (and notify)": function() {
|
117
|
+
var child = this.v.child ;
|
118
|
+
var cf = child.get('clippingFrame') ;
|
119
|
+
|
120
|
+
var didChange = false ;
|
121
|
+
child.addObserver('clippingFrame', function() { didChange = true; }) ;
|
122
|
+
|
123
|
+
// scroll
|
124
|
+
child.set('frame', { height: 50 }) ;
|
125
|
+
|
126
|
+
var ncf = child.get('clippingFrame') ;
|
127
|
+
cf.height = 50 ; // adjust expected frame
|
128
|
+
|
129
|
+
SC.rectsEqual(ncf, cf).shouldEqual(true) ;
|
130
|
+
didChange.shouldEqual(true) ;
|
131
|
+
|
132
|
+
// reset
|
133
|
+
child.set('frame', { height: 152 }) ;
|
134
|
+
},
|
135
|
+
|
136
|
+
"moving child should change clipping frame (and notify)": function() {
|
137
|
+
var child = this.v.child ;
|
138
|
+
var cf = child.get('clippingFrame') ;
|
139
|
+
|
140
|
+
var didChange = false ;
|
141
|
+
child.addObserver('clippingFrame', function() { didChange = true; }) ;
|
142
|
+
|
143
|
+
// scroll
|
144
|
+
child.set('frame', { y: 20 }) ;
|
145
|
+
|
146
|
+
var ncf = child.get('clippingFrame') ;
|
147
|
+
cf.y = 20; cf.height -= 20 ; // adjust expected frame
|
148
|
+
|
149
|
+
SC.rectsEqual(ncf, cf).shouldEqual(true) ;
|
150
|
+
didChange.shouldEqual(true) ;
|
151
|
+
|
152
|
+
// reset
|
153
|
+
child.set('frame', { y: 0 }) ;
|
154
|
+
},
|
155
|
+
|
156
|
+
"moving parent should NOT change child clipping frame": function() {
|
157
|
+
var child = this.v.child ;
|
158
|
+
var cf = child.get('clippingFrame') ;
|
159
|
+
|
160
|
+
// move parent frame -- make sure this does not exceed the parent or
|
161
|
+
// else the clipping frame will be miscalculated.
|
162
|
+
this.v.set('frame', { y: 5 }) ;
|
163
|
+
|
164
|
+
var ncf = child.get('clippingFrame') ;
|
165
|
+
SC.rectsEqual(ncf, cf).shouldEqual(true) ;
|
166
|
+
|
167
|
+
// reset
|
168
|
+
this.v.set('frame', { y: 0 }) ;
|
169
|
+
},
|
170
|
+
|
171
|
+
setup: function() { this.v = SC.page.get('case2'); }
|
172
|
+
|
173
|
+
});
|
174
|
+
|
175
|
+
Test.context("CASE 3: A scrollable view with extra height - nested child view can fit within visible area", {
|
176
|
+
|
177
|
+
"clippingFrame should == frame when view is entirely visible": function() {
|
178
|
+
var f = this.nested.get('frame') ;
|
179
|
+
var cf = this.nested.get('clippingFrame') ;
|
180
|
+
SC.rectsEqual(f,cf).shouldEqual(true) ;
|
181
|
+
},
|
182
|
+
|
183
|
+
"clippingFrame should be partial when view is partially scrolled out (and notify)": function() {
|
184
|
+
|
185
|
+
// register observer
|
186
|
+
var didChange = false ;
|
187
|
+
this.nested.addObserver('clippingFrame', function() { didChange = true; }) ;
|
188
|
+
|
189
|
+
// adjust expected. Note that this expects .case .child to be statically positioned
|
190
|
+
// so that clippingFrame is based on .case3.
|
191
|
+
var cf = this.nested.get('clippingFrame') ;
|
192
|
+
cf.y = 30; cf.height -= 20 ;
|
193
|
+
|
194
|
+
// scroll
|
195
|
+
this.v.set('scrollFrame', { y: -30 }) ;
|
196
|
+
|
197
|
+
// collect new frame and compare
|
198
|
+
var ncf = this.nested.get('clippingFrame') ;
|
199
|
+
|
200
|
+
console.log('ncf: %@'.fmt($H(ncf).inspect()));
|
201
|
+
console.log('cf: %@'.fmt($H(cf).inspect()));
|
202
|
+
window.case3 = this ;
|
203
|
+
|
204
|
+
SC.rectsEqual(ncf,cf).shouldEqual(true) ;
|
205
|
+
|
206
|
+
// force notifications
|
207
|
+
didChange.shouldEqual(true) ;
|
208
|
+
|
209
|
+
// reset
|
210
|
+
this.v.set('scrollFrame', { y: 0 }) ;
|
211
|
+
},
|
212
|
+
|
213
|
+
"clippingFrame should be 0 height when scroll completely out of view": function() {
|
214
|
+
this.v.set('scrollFrame', { y: -150 }) ;
|
215
|
+
this.nested.get('clippingFrame').height.shouldEqual(0) ;
|
216
|
+
this.v.set('scrollFrame', { y: 0 }) ; // reset
|
217
|
+
},
|
218
|
+
|
219
|
+
"clippingFrame should == frame when moved around within view (and notify)": function() {
|
220
|
+
var of= this.nested.get('frame') ;
|
221
|
+
this.nested.set('frame', { x: 20, y: 20 }) ;
|
222
|
+
|
223
|
+
var f = this.nested.get('frame') ;
|
224
|
+
var cf = this.nested.get('clippingFrame') ;
|
225
|
+
SC.rectsEqual(f,cf).shouldEqual(true) ;
|
226
|
+
|
227
|
+
// reset
|
228
|
+
this.nested.set('frame', of) ;
|
229
|
+
},
|
230
|
+
|
231
|
+
setup: function() { this.v = SC.page.get('case3'); this.nested = this.v.child.nestedChild; }
|
232
|
+
|
233
|
+
});
|
234
|
+
|
235
|
+
Test.context("CASE 4: Child view is not actually in window", {
|
236
|
+
|
237
|
+
"clippingFrame should have 0 width or height": function() {
|
238
|
+
|
239
|
+
// get clipping frame to force caching
|
240
|
+
this.child.get('clippingFrame') ;
|
241
|
+
|
242
|
+
// remove child and get clippingFrame again
|
243
|
+
this.child.removeFromParent() ;
|
244
|
+
var cf = this.child.get('clippingFrame') ;
|
245
|
+
cf.width.shouldEqual(0) ;
|
246
|
+
cf.height.shouldEqual(0) ;
|
247
|
+
},
|
248
|
+
|
249
|
+
setup: function() {
|
250
|
+
this.v = SC.page.get('case4');
|
251
|
+
this.child = this.v.child ;
|
252
|
+
}
|
253
|
+
|
254
|
+
});
|
255
|
+
|
256
|
+
|
257
|
+
Test.context("CASE 5: Child view's parent is not actually in window", {
|
258
|
+
|
259
|
+
"clippingFrame should have 0 width of height for nested view": function() {
|
260
|
+
|
261
|
+
// get clipping frame to cause caching
|
262
|
+
this.nested.get('clippingFrame') ;
|
263
|
+
|
264
|
+
this.v.child.removeFromParent() ;
|
265
|
+
var cf = this.nested.get('clippingFrame') ;
|
266
|
+
cf.width.shouldEqual(0) ;
|
267
|
+
cf.height.shouldEqual(0) ;
|
268
|
+
},
|
269
|
+
|
270
|
+
setup: function() {
|
271
|
+
this.v = SC.page.get('case5');
|
272
|
+
this.nested = this.v.child.nestedChild;
|
273
|
+
}
|
274
|
+
|
275
|
+
});
|
276
|
+
|
277
|
+
|
278
|
+
|
279
|
+
main = function() { SC.page.awake(); };
|
280
|
+
|
281
|
+
</script>
|
282
|
+
|
283
|
+
<% end %>
|
284
|
+
|
285
|
+
<% content_for('body') do %>
|
286
|
+
|
287
|
+
<style>
|
288
|
+
|
289
|
+
.case {
|
290
|
+
background-color: white;
|
291
|
+
position: absolute;
|
292
|
+
width: 190px;
|
293
|
+
height: 90px;
|
294
|
+
border: 1px blue solid;
|
295
|
+
overflow: auto;
|
296
|
+
border-left-width: 5px;
|
297
|
+
}
|
298
|
+
|
299
|
+
.case .child {
|
300
|
+
border: 1px red solid;
|
301
|
+
}
|
302
|
+
|
303
|
+
.case .nested_child {
|
304
|
+
border: 1px green solid;
|
305
|
+
width: 40px;
|
306
|
+
height: 40px;
|
307
|
+
position: absolute;
|
308
|
+
top: 10px;
|
309
|
+
left: 10px;
|
310
|
+
}
|
311
|
+
|
312
|
+
.base {
|
313
|
+
float: left;
|
314
|
+
width: 200px;
|
315
|
+
height: 100px;
|
316
|
+
border: 1px #aaa solid;
|
317
|
+
position: relative;
|
318
|
+
margin: 2px;
|
319
|
+
}
|
320
|
+
|
321
|
+
.cases {
|
322
|
+
position: absolute;
|
323
|
+
bottom: 0 ;
|
324
|
+
left: 0;
|
325
|
+
right: 0;
|
326
|
+
border-top: 1px #ccc solid;
|
327
|
+
}
|
328
|
+
|
329
|
+
.base label {
|
330
|
+
position: absolute;
|
331
|
+
bottom: 4px;
|
332
|
+
left: 4px;
|
333
|
+
}
|
334
|
+
|
335
|
+
.case1 .child { width: 60px; height: 60px; }
|
336
|
+
|
337
|
+
.case2 .child,
|
338
|
+
.case4 .child {
|
339
|
+
position: relative;
|
340
|
+
height: 150px;
|
341
|
+
}
|
342
|
+
|
343
|
+
/* case3 child is statically positioned, so offset parent of nested child should be .case3 */
|
344
|
+
.case3 .child,
|
345
|
+
.case5 .child {
|
346
|
+
height: 150px;
|
347
|
+
}
|
348
|
+
|
349
|
+
|
350
|
+
|
351
|
+
</style>
|
352
|
+
|
353
|
+
<div class="cases">
|
354
|
+
<div class="base">
|
355
|
+
<label>Case 1</label>
|
356
|
+
<% view :case1, :class => 'case' do %>
|
357
|
+
<%= view :child, :outlet => true, :inner_html => 'Child', :properties => { :needs_clipping_frame => true } %>
|
358
|
+
<% end %>
|
359
|
+
</div>
|
360
|
+
|
361
|
+
<div class="base">
|
362
|
+
<label>Case 2</label>
|
363
|
+
<% view :case2, :class => 'case', :properties => { :is_scrollable => true } do %>
|
364
|
+
<%= view :child, :outlet => true, :inner_html => 'Child', :properties => { :needs_clipping_frame => true } %>
|
365
|
+
<% end %>
|
366
|
+
</div>
|
367
|
+
|
368
|
+
<div class="base">
|
369
|
+
<label>Case 3</label>
|
370
|
+
<% view :case3, :class => 'case', :properties => { :is_scrollable => true } do %>
|
371
|
+
<% view :child, :outlet => true do %>
|
372
|
+
<%= view :nested_child, :outlet => true, :inner_html => 'Nested Child', :properties => { :needs_clipping_frame => true } %>
|
373
|
+
<% end %>
|
374
|
+
<% end %>
|
375
|
+
</div>
|
376
|
+
|
377
|
+
<div class="base">
|
378
|
+
<label>Case 4</label>
|
379
|
+
<% view :case4, :class => 'case', :properties => { :is_scrollable => true } do %>
|
380
|
+
<%= view :child, :outlet => true, :inner_html => 'Child', :properties => { :needs_clipping_frame => true } %>
|
381
|
+
<% end %>
|
382
|
+
</div>
|
383
|
+
|
384
|
+
<div class="base">
|
385
|
+
<label>Case 5</label>
|
386
|
+
<% view :case5, :class => 'case', :properties => { :is_scrollable => true } do %>
|
387
|
+
<% view :child, :outlet => true do %>
|
388
|
+
<%= view :nested_child, :outlet => true, :inner_html => 'Nested Child', :properties => { :needs_clipping_frame => true } %>
|
389
|
+
<% end %>
|
390
|
+
<% end %>
|
391
|
+
</div>
|
392
|
+
|
393
|
+
</div>
|
394
|
+
|
395
|
+
<% end %>
|