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
@@ -1,472 +0,0 @@
1
- // ==========================================================================
2
- // Project: SproutCore
3
- // Copyright: @2013 7x7 Software, Inc.
4
- // License: Licensed under MIT license (see license.js)
5
- // ==========================================================================
6
- sc_require('views/view');
7
-
8
-
9
- SC.mixin(SC.View,
10
- /** @scope SC.View */ {
11
-
12
- /**
13
- This child layout plugin automatically positions the view's child views in a
14
- vertical stack and optionally adjusts the view's height to fit. It does this
15
- by checking the height of each child view and positioning the following child
16
- view accordingly. Afterwards, by default, any time that a child view's
17
- height or visibility changes, the view will use this plugin to re-adjust all
18
- following child views' positions and potentially its own height appropriately.
19
-
20
- This allows you to stack absolutely positioned views that dynamically change
21
- their height and/or visibility without having to resort to using browser
22
- flow layout.
23
-
24
- A typical usage scenario is a long "form" made of multiple subsection
25
- views. If we want to adjust the height of a subsection, to make space for
26
- an error label for example, it would be a lot of work to manually
27
- reposition all the following sections below it. A much easier to code and
28
- cleaner solution is to just set the childViewLayout plugin on the wrapper
29
- view.
30
-
31
- For example,
32
-
33
- MyApp.MyView = SC.View.extend({
34
-
35
- // Child views will be stacked in order vertically.
36
- childViewLayout: SC.View.VERTICAL_STACK,
37
-
38
- // The order of child views is important!
39
- childViews: ['sectionA', 'sectionB', 'sectionC'],
40
-
41
- // The view will resize itself to fit its children.
42
- // i.e. We don't need to specify layout.height, this is automatic.
43
- // The actual layout will become { left: 10, right: 10, top: 20, height: 270 } initially.
44
- layout: { left: 10, right: 10, top: 20 },
45
-
46
- sectionA: SC.View.design({
47
-
48
- // We don't need to specify layout.top, this is automatic.
49
- // The actual layout will become { left: 0, right: 0, top: 0, height: 100 } initially.
50
- layout: { height: 100 }
51
-
52
- }),
53
-
54
- sectionB: SC.View.design({
55
-
56
- // We don't need to specify layout.top, this is automatic.
57
- // The actual layout will become { border: 1, left: 0, right: 0, top: 100, height: 50 } initially.
58
- layout: { border: 1, height: 50 }
59
-
60
- }),
61
-
62
- sectionC: SC.View.design({
63
-
64
- // We don't need to specify layout.top, this is automatic.
65
- // The actual layout will become { left: 10, right: 10, top: 150, height: 120 } initially.
66
- layout: { left: 10, right: 10, height: 120 }
67
-
68
- })
69
-
70
- });
71
-
72
- ## Modify the default behavior with `childViewLayoutOptions`
73
-
74
- To modify the plugin behavior for all child view layouts, you can set the
75
- following child view layout options in `childViewLayoutOptions` on the view:
76
-
77
- - paddingBefore - Adds padding before the first child view. Default: 0
78
- - paddingAfter - Adds padding after the last child view. Default: 0
79
- - spacing - Adds spacing between each child view. Default: 0
80
- - resizeToFit - Whether to resize the view to fit the child views (requires that each child view has a layout height). Default: true
81
-
82
- For example,
83
-
84
- MyApp.MyView = SC.View.extend({
85
-
86
- // Child views will be stacked in order vertically.
87
- childViewLayout: SC.View.VERTICAL_STACK,
88
-
89
- // Change the behavior of the VERTICAL_STACK plugin
90
- childViewLayoutOptions: {
91
- paddingBefore: 10,
92
- paddingAfter: 20,
93
- spacing: 5
94
- },
95
-
96
- // The order of child views is important!
97
- childViews: ['sectionA', 'sectionB', 'sectionC'],
98
-
99
- // The actual layout will become { left: 10, right: 10, top: 20, height: 310 } initially.
100
- layout: { left: 10, right: 10, top: 20 }, // Don't need to specify layout.height, this is automatic.
101
-
102
- sectionA: SC.View.design({
103
-
104
- // We don't need to specify layout.top, this is automatic.
105
- // The actual layout will become { left: 0, right: 0, top: 10, height: 100 } initially.
106
- layout: { height: 100 }
107
-
108
- }),
109
-
110
- sectionB: SC.View.design({
111
-
112
- // We don't need to specify layout.top, this is automatic.
113
- // The actual layout will become { border: 1, left: 0, right: 0, top: 115, height: 50 } initially.
114
- layout: { border: 1, height: 50 }
115
-
116
- }),
117
-
118
- sectionC: SC.View.design({
119
-
120
- // We don't need to specify layout.top, this is automatic.
121
- // The actual layout will become { left: 10, right: 10, top: 170, height: 120 } initially.
122
- layout: { left: 10, right: 10, height: 120 }
123
-
124
- })
125
-
126
- });
127
-
128
- If `resizeToFit` is set to `false`, the view will not adjust itself to fit
129
- its child views. This means that when `resizeToFit` is false, the view should
130
- specify its height component in its layout. A direct effect is the possibility for
131
- the child views to automatically extend or shrink in order to fill the empty, unclaimed space.
132
- This available space is shared between the children not specifying a fixed height
133
- and their final dimension is calculated proportionally to the value of the
134
- property `fillRatio`.
135
- For simplicity, when none of the children specifies `fillRatio`,
136
- you can ignore the last child view's layout height if you want the last child view
137
- to stretch to fill the parent view.
138
-
139
- For example,
140
-
141
- MyApp.MyView = SC.View.extend({
142
-
143
- // Child views will be stacked in order vertically.
144
- childViewLayout: SC.View.VERTICAL_STACK,
145
-
146
- // Change the behavior of the VERTICAL_STACK plugin
147
- childViewLayoutOptions: {
148
- paddingBefore: 10,
149
- paddingAfter: 20,
150
- spacing: 5,
151
- resizeToFit: false
152
- },
153
-
154
- // The order of child views is important!
155
- childViews: ['sectionA', 'sectionB', 'sectionC'],
156
-
157
- // Actual layout will become { left: 10, right: 10, top: 20, height: 500 }
158
- layout: { left: 10, right: 10, top: 20, height: 500 }, // Need to specify layout.height.
159
-
160
- sectionA: SC.View.design({
161
-
162
- // We don't need to specify layout.top, this is automatic. This child will not stretch, its height is set.
163
- // The actual layout will become { left: 0, right: 0, top: 10, height: 100 } initially.
164
- layout: { height: 100 }
165
-
166
- }),
167
-
168
- sectionB: SC.View.design({
169
-
170
- // The unclaimed space so far is 500 - 10 - 100 - 5 - 5 - 20, or 360px. This space will be shared between
171
- // the two last sections, because we won't specity a height on them.
172
- // This view will get 1/3 of the available space, because the other flexibile view has a ratio of 2.
173
- fillRatio: 1,
174
-
175
- // This section will take 1/3 * 360px = 120px.
176
- // Actual layout will become { border: 1, left: 0, right: 0, top: 115, bottom: 265 }, in other words, height == 120
177
- // We don't need to specify layout.top, layout.bottom or layout.height, this is automatic.
178
- layout: { border: 1 }
179
-
180
- }),
181
-
182
- sectionC: SC.View.design({
183
-
184
- // This view will get 2/3 of the available space, because the other flexibile view has a ratio of 1.
185
- fillRatio: 2,
186
-
187
- // This section will take 2/3 * 360px = 240px.
188
- // Actual layout will become { left: 10, right: 10, top: 240, bottom: 20 }, in other words, height == 240
189
- // We don't need to specify layout.top, layout.bottom or layout.height, this is automatic.
190
- layout: { left: 10, right: 10 }
191
-
192
- })
193
-
194
- });
195
-
196
- ## Modify specific child view layouts
197
-
198
- To adjust the child layout on a granular level per child view, you can
199
- also set the following properties on each child view:
200
-
201
- - marginBefore - Specify the minimum spacing above the child view.
202
- - marginAfter - Specify the minimum spacing below the child view.
203
- - useAbsoluteLayout - Don't include this child view in automatic layout, use absolute positioning based on the child view's `layout` property.
204
- - useStaticLayout - Don't include this child view in automatic layout. This child view uses relative positioning and is not eligible for automatic layout.
205
- - isVisible - Non-visible child views are not included in the stack.
206
- - fillRatio - When the parent view is configured with a fixed dimension, children not specifying a height but specifying fillRatio will be resized to fill the unclaimed space proportionally to this ratio.
207
-
208
- For example,
209
-
210
- MyApp.MyView = SC.View.extend({
211
-
212
- // Child views will be stacked in order vertically.
213
- childViewLayout: SC.View.VERTICAL_STACK,
214
-
215
- // Actual layout will become { left: 10, right: 10, top: 20, height: 570 }
216
- layout: { left: 10, right: 10, top: 20 },
217
-
218
- // Keep the child views ordered!
219
- childViews: ['sectionA', 'float', 'sectionB', 'sectionC'],
220
-
221
- sectionA: SC.View.design({
222
- // Actual layout will become { left: 0, right: 50, top: 0, height: 100 }
223
- layout: { right: 50, height: 100 },
224
- // The following child view will be at least 50px further down.
225
- marginAfter: 50
226
- }),
227
-
228
- float: SC.View.design({
229
- // This view will not be included in automatic layout and will not effect the stack.
230
- layout: { top: 5, right: 5, width: 50, height: 50 },
231
- useAbsoluteLayout: true
232
- }),
233
-
234
- sectionB: SC.View.design({
235
- // Actual layout will become { left: 0, right: 0, top: 150, height: 120 }
236
- layout: { height: 120 }
237
- }),
238
-
239
- sectionC: SC.View.design({
240
- // Actual layout will become { left: 0, bottom: 0, top: 470, height: 100 }
241
- layout: { height: 100 },
242
- // This child view will be at least 200px below the previous.
243
- marginBefore: 200
244
- })
245
-
246
- });
247
-
248
- ### A Note About Spacing
249
-
250
- Note that the spacing attribute in `childViewLayoutOptions` becomes the
251
- _minimum margin between child views, without explicitly overriding it from
252
- both sides using `marginAfter` and `marginBefore`_. For example, if `spacing`
253
- is 25, setting `marginAfter` to 10 on a child view will not result in the
254
- next child view being 10px below it, unless the next child view also
255
- specified `marginBefore` as 10.
256
-
257
- What this means is that it takes less configuration if you set `spacing` to
258
- be the _smallest margin you wish to exist between child views_ and then use
259
- the overrides to grow the margin if necessary. For example, if `spacing`
260
- is 5, setting `marginAfter` to 10 on a child view will result in the next
261
- child view being 10px below it, without having to also specify `marginBefore`
262
- on that next child view.
263
-
264
- @extends SC.ChildViewLayoutProtocol
265
- @since Version 1.10
266
- */
267
- VERTICAL_STACK: {
268
-
269
- /** @private Properties to observe on child views that affect the overall child view layout. */
270
- childLayoutProperties: ['marginBefore', 'marginAfter', 'isVisible'],
271
-
272
- /** @private When resizeToFit is false, then we need to know when the view's frame changes. */
273
- layoutDependsOnSize: function (view) {
274
- var options = view.get('childViewLayoutOptions');
275
-
276
- if (options) {
277
- return SC.none(options.resizeToFit) ? false : !options.resizeToFit;
278
- } else {
279
- return false;
280
- }
281
- },
282
-
283
- /** @private */
284
- layoutChildViews: function (view) {
285
- var childViews = view.get('childViews'),
286
- options = view.get('childViewLayoutOptions') || {},
287
- resizeToFit = SC.none(options.resizeToFit) ? true : options.resizeToFit,
288
- lastMargin = 0, // Used to avoid adding spacing to the final margin.
289
- marginAfter = options.paddingBefore || 0,
290
- paddingAfter = options.paddingAfter || 0,
291
- topPosition = 0,
292
- provisionedSpace = 0,
293
- autoFillAvailableSpace = 0,
294
- totalAvailableSpace = 0,
295
- totalFillAvailableSpaceRatio = 0,
296
- spacing = options.spacing || 0,
297
- childView,
298
- fillRatio,
299
- layout,
300
- marginBefore,
301
- i, len;
302
-
303
- // if the view is not configured to resize to fit content, then we give a chance to the children to fill the available space
304
- // we make a 1st pass to check the conditions, to evaluate the available space and the proportions between children
305
- if (!resizeToFit) {
306
-
307
- totalAvailableSpace = view.get('frame').height;
308
-
309
- // if the view is not configured to resize and it doesn't have yet a height, it doesn't make sense to layout children
310
- if (!totalAvailableSpace) {
311
- return;
312
- }
313
-
314
- for (i = 0, len = childViews.get('length'); i < len; i++) {
315
- childView = childViews.objectAt(i);
316
-
317
- // Ignore child views with useAbsoluteLayout true, useStaticLayout true or that are not visible.
318
- if (!childView.get('isVisible') ||
319
- childView.get('useAbsoluteLayout') ||
320
- childView.get('useStaticLayout')) {
321
- continue;
322
- }
323
-
324
- layout = childView.get('layout');
325
-
326
- // Determine the top margin.
327
- marginBefore = childView.get('marginBefore') || 0;
328
- provisionedSpace += Math.max(marginAfter, marginBefore);
329
-
330
- // if the height is not set, let's check if is possible to resize the view
331
- if (SC.none(layout.height)) {
332
- fillRatio = childView.get('fillRatio');
333
-
334
- if (!SC.none(fillRatio)) {
335
- totalFillAvailableSpaceRatio += fillRatio;
336
- } else {
337
- // if none of the child views has fillRatio defined, allow the last one to stretch and fill the available space.
338
- if (i == len - 1 && totalFillAvailableSpaceRatio === 0) {
339
- totalFillAvailableSpaceRatio = 1;
340
- }
341
- //@if(debug)
342
- // Add some developer support.
343
- else {
344
- // even if we don't have a height set, as last instance we accept the presence of minHeight
345
- if (SC.none(layout.minHeight))
346
- {
347
- SC.warn('Developer Warning: The SC.View.VERTICAL_STACK plugin requires that each childView layout contains at least a height or has a configured fillRatio. The layout may also optionally contain left and right, left and width, right and width or centerX and width. The childView %@ has an invalid layout/fillRatio: %@'.fmt(childView, SC.stringFromLayout(layout)));
348
- return;
349
- }
350
- }
351
- //@endif
352
- }
353
- } else {
354
- provisionedSpace += childView.getPath('borderFrame.height');
355
- }
356
-
357
- // Determine the right margin.
358
- lastMargin = childView.get('marginAfter') || 0;
359
- marginAfter = lastMargin || spacing;
360
- }
361
-
362
- // consider the end padding when calculating the provisionedSpace
363
- if (provisionedSpace !== 0 || totalFillAvailableSpaceRatio !== 0) {
364
- provisionedSpace += Math.max(lastMargin, paddingAfter);
365
- }
366
-
367
- autoFillAvailableSpace = Math.max(0, totalAvailableSpace - provisionedSpace);
368
- }
369
-
370
- // reset the references for the effective layout
371
- lastMargin = 0;
372
- marginAfter = options.paddingBefore || 0;
373
- paddingAfter = options.paddingAfter || 0;
374
-
375
- for (i = 0, len = childViews.get('length'); i < len; i++) {
376
- var height,
377
- adjustTop,
378
- adjustBottom;
379
-
380
- childView = childViews.objectAt(i);
381
-
382
- // Ignore child views with useAbsoluteLayout true, useStaticLayout true or that are not visible.
383
- if (!childView.get('isVisible') ||
384
- childView.get('useAbsoluteLayout') ||
385
- childView.get('useStaticLayout')) {
386
- continue;
387
- }
388
-
389
- layout = childView.get('layout');
390
-
391
- //@if(debug)
392
- // Add some developer support. The case of !resizeToFit was already checked above
393
- if (resizeToFit && SC.none(layout.height) && SC.none(layout.minHeight)) {
394
- SC.warn('Developer Warning: The SC.View.VERTICAL_STACK plugin, when configured with resizeToFit, requires that each childView layout contains at least a height/minHeight and optionally also left and right, left and width, right and width or centerX and width. The childView %@ has an invalid layout: %@'.fmt(childView, SC.stringFromLayout(layout)));
395
- return;
396
- }
397
- //@endif
398
-
399
- // Determine the top margin.
400
- marginBefore = childView.get('marginBefore') || 0;
401
- topPosition += Math.max(marginAfter, marginBefore);
402
-
403
- // Try to avoid useless adjustments top or bottom or top then bottom.
404
- // The required adjustments will be merged into a single call
405
- adjustTop = layout.top !== topPosition;
406
-
407
- childView.beginPropertyChanges();
408
- if (!resizeToFit && !layout.height) {
409
- var bottomPosition;
410
-
411
- fillRatio = childView.get('fillRatio');
412
-
413
- // if the last child doesn't define fillRatio, default it to 1 as above during the 1st pass
414
- if (i == len - 1 && SC.none(fillRatio)) {
415
- fillRatio = 1;
416
- }
417
-
418
- // we should get here only in two cases: 1. child defines fillRatio, 2. child defines a minHeight
419
- // if both defined, we prefer to handle fillRatio, the other case being handled below by the normal adjustment to top
420
- if (!SC.none(fillRatio)) {
421
- var currentAvailableSpaceRatio = (fillRatio / totalFillAvailableSpaceRatio);
422
-
423
- // calculate the height according to fillRatio and totalFillAvailableSpaceRatio
424
- // but set the "bottom" position so any subsequent layout is not considering the height as fixed
425
- height = Math.ceil(autoFillAvailableSpace * currentAvailableSpaceRatio);
426
-
427
- // INCOMPLETE: We need to flag this view as constrained and re-compute all the auto-fill amounts
428
- // Constrain the height to the maximum height allowed.
429
- // var maxHeight = layout.maxHeight;
430
- // if (!SC.none(maxHeight)) {
431
- // // Constrain the height according to maxHeight. Which frees up additional available space for further child views.
432
- // if (height > maxHeight) {
433
- // height = maxHeight;
434
- // }
435
- // }
436
-
437
- // Determine the bottom position. If the position overflows (i.e. goes negative) because of rounding up, stop at 0.
438
- bottomPosition = Math.max(0, totalAvailableSpace - topPosition - height);
439
- adjustBottom = layout.bottom !== bottomPosition;
440
-
441
- if (adjustBottom) {
442
- childView.adjust('bottom', bottomPosition);
443
- }
444
- }
445
- }
446
-
447
- if (adjustTop) {
448
- childView.adjust('top', topPosition);
449
- }
450
- childView.endPropertyChanges();
451
-
452
- topPosition += childView.getPath('borderFrame.height');
453
-
454
- // Determine the right margin.
455
- lastMargin = childView.get('marginAfter') || 0;
456
- marginAfter = lastMargin || spacing;
457
- }
458
-
459
- // If the current size is 0 (all children are hidden), it doesn't make sense to add the padding
460
- if (topPosition !== 0) {
461
- topPosition += Math.max(lastMargin, paddingAfter);
462
- }
463
-
464
- // Adjust our frame to fit as well, this ensures that scrolling works.
465
- if (resizeToFit && view.getPath('layout.height') !== topPosition) {
466
- view.adjust('height', topPosition);
467
- }
468
- }
469
-
470
- }
471
-
472
- });