sproutcore 1.6.0.rc.2-x86-mingw32 → 1.6.0.1-x86-mingw32
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +12 -0
- data/VERSION.yml +1 -1
- data/bin/sc-docs +6 -1
- data/lib/buildtasks/target.rake +1 -1
- data/lib/frameworks/sproutcore/Buildfile +5 -1
- data/lib/frameworks/sproutcore/CHANGELOG.md +175 -1
- data/lib/frameworks/sproutcore/apps/test_controls/controllers/select.js +12 -0
- data/lib/frameworks/sproutcore/apps/test_controls/resources/select_page.js +19 -5
- data/lib/frameworks/sproutcore/frameworks/ajax/system/request.js +28 -31
- data/lib/frameworks/sproutcore/frameworks/ajax/system/response.js +9 -2
- data/lib/frameworks/sproutcore/frameworks/core_foundation/controllers/controller.js +21 -1
- data/lib/frameworks/sproutcore/frameworks/core_foundation/mixins/responder_context.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/core_foundation/mixins/template_helpers/checkbox_support.js +6 -1
- data/lib/frameworks/sproutcore/frameworks/core_foundation/mixins/template_helpers/text_field_support.js +26 -8
- data/lib/frameworks/sproutcore/frameworks/core_foundation/panes/keyboard.js +2 -0
- data/lib/frameworks/sproutcore/frameworks/core_foundation/panes/pane.js +12 -5
- data/lib/frameworks/sproutcore/frameworks/core_foundation/panes/template.js +25 -9
- data/lib/frameworks/sproutcore/frameworks/core_foundation/system/locale.js +157 -5
- data/lib/frameworks/sproutcore/frameworks/core_foundation/system/render_context.js +7 -6
- data/lib/frameworks/sproutcore/frameworks/core_foundation/system/root_responder.js +9 -3
- data/lib/frameworks/sproutcore/frameworks/core_foundation/system/sparse_array.js +8 -8
- data/lib/frameworks/sproutcore/frameworks/core_foundation/system/string.js +104 -4
- data/lib/frameworks/sproutcore/frameworks/core_foundation/system/theme.js +3 -56
- data/lib/frameworks/sproutcore/frameworks/core_foundation/system/utils.js +4 -2
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/controllers/object/content_destroyed.js +59 -0
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/mixins/string.js +41 -1
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/mixins/template_helpers/text_field_support.js +10 -2
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/panes/template.js +16 -1
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/template/handlebars.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/clippingFrame.js +11 -0
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/didAppendToDocument.js +18 -2
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/insertBefore.js +10 -6
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/keyboard.js +18 -1
- data/lib/frameworks/sproutcore/frameworks/core_foundation/views/template_collection.js +9 -1
- data/lib/frameworks/sproutcore/frameworks/core_foundation/views/view.js +9 -4
- data/lib/frameworks/sproutcore/frameworks/core_foundation/views/view/keyboard.js +15 -3
- data/lib/frameworks/sproutcore/frameworks/core_foundation/views/view/manipulation.js +14 -8
- data/lib/frameworks/sproutcore/frameworks/core_foundation/views/view/theming.js +8 -18
- data/lib/frameworks/sproutcore/frameworks/datastore/data_sources/fixtures.js +12 -2
- data/lib/frameworks/sproutcore/frameworks/datastore/mixins/relationship_support.js +296 -0
- data/lib/frameworks/sproutcore/frameworks/datastore/models/child_record.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/datastore/models/record.js +330 -326
- data/lib/frameworks/sproutcore/frameworks/datastore/models/record_attribute.js +22 -1
- data/lib/frameworks/sproutcore/frameworks/datastore/system/nested_store.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/datastore/system/store.js +614 -614
- data/lib/frameworks/sproutcore/frameworks/datastore/tests/data_sources/data_source.js +14 -1
- data/lib/frameworks/sproutcore/frameworks/datastore/tests/models/nested_records/nested_record.js +3 -1
- data/lib/frameworks/sproutcore/frameworks/datastore/tests/models/nested_records/nested_record_array_complex.js +2 -0
- data/lib/frameworks/sproutcore/frameworks/datastore/tests/models/nested_records/nested_record_complex.js +2 -0
- data/lib/frameworks/sproutcore/frameworks/datastore/tests/models/record/core_methods.js +20 -13
- data/lib/frameworks/sproutcore/frameworks/datastore/tests/models/record_attribute.js +61 -46
- data/lib/frameworks/sproutcore/frameworks/datastore/tests/system/nested_store/commitChangesFromNestedStore.js +30 -30
- data/lib/frameworks/sproutcore/frameworks/datastore/tests/system/store/commitChangesFromNestedStore.js +24 -24
- data/lib/frameworks/sproutcore/frameworks/datastore/tests/system/store/connectDataSource.js +31 -0
- data/lib/frameworks/sproutcore/frameworks/datastore/tests/system/store/pushRelationships.js +1177 -0
- data/lib/frameworks/sproutcore/frameworks/datetime/frameworks/localized/system/datetime.js +4 -63
- data/lib/frameworks/sproutcore/frameworks/desktop/mixins/border.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/desktop/mixins/scrollable.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/desktop/panes/alert.js +7 -8
- data/lib/frameworks/sproutcore/frameworks/desktop/panes/menu.js +18 -1
- data/lib/frameworks/sproutcore/frameworks/desktop/panes/panel.js +9 -0
- data/lib/frameworks/sproutcore/frameworks/desktop/protocols/drag_data_source.js +3 -3
- data/lib/frameworks/sproutcore/frameworks/desktop/protocols/drop_target.js +3 -3
- data/lib/frameworks/sproutcore/frameworks/desktop/render_delegates/button.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/desktop/render_delegates/checkbox.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/desktop/render_delegates/collection.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/desktop/render_delegates/disclosure.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/desktop/render_delegates/image_button.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/desktop/render_delegates/master_detail.js +3 -2
- data/lib/frameworks/sproutcore/frameworks/desktop/render_delegates/menu.js +12 -2
- data/lib/frameworks/sproutcore/frameworks/desktop/render_delegates/panel.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/desktop/render_delegates/picker.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/desktop/render_delegates/progress.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/desktop/render_delegates/radio.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/desktop/render_delegates/radio_group.js +2 -2
- data/lib/frameworks/sproutcore/frameworks/desktop/render_delegates/segment.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/desktop/render_delegates/segmented.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/desktop/render_delegates/slider.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/desktop/render_delegates/toolbar.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/desktop/render_delegates/well.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/desktop/render_delegates/workspace.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/desktop/resources/segmented.css +1 -0
- data/lib/frameworks/sproutcore/frameworks/desktop/tests/panes/alert/ui.js +33 -22
- data/lib/frameworks/sproutcore/frameworks/desktop/tests/panes/panel/methods.js +20 -1
- data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/checkbox/methods.js +10 -3
- data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/date_field/methods.js +34 -7
- data/lib/frameworks/sproutcore/frameworks/desktop/views/button.js +14 -15
- data/lib/frameworks/sproutcore/frameworks/desktop/views/checkbox.js +40 -14
- data/lib/frameworks/sproutcore/frameworks/desktop/views/collection.js +699 -700
- data/lib/frameworks/sproutcore/frameworks/desktop/views/list_item.js +2 -2
- data/lib/frameworks/sproutcore/frameworks/desktop/views/master_detail.js +11 -1
- data/lib/frameworks/sproutcore/frameworks/desktop/views/menu_item.js +16 -6
- data/lib/frameworks/sproutcore/frameworks/desktop/views/progress.js +0 -1
- data/lib/frameworks/sproutcore/frameworks/desktop/views/radio.js +49 -7
- data/lib/frameworks/sproutcore/frameworks/desktop/views/select_button.js +9 -0
- data/lib/frameworks/sproutcore/frameworks/desktop/views/select_field.js +6 -2
- data/lib/frameworks/sproutcore/frameworks/desktop/views/slider.js +4 -26
- data/lib/frameworks/sproutcore/frameworks/desktop/views/web.js +20 -19
- data/lib/frameworks/sproutcore/frameworks/experimental/Buildfile +2 -0
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/designer/designers/view_designer.js +249 -249
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/forms/mixins/edit_mode.js +13 -5
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/forms/mixins/emptiness.js +53 -37
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/forms/render_delegates/form.js +2 -1
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/forms/render_delegates/form_row.js +3 -11
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/forms/tests/mixins/edit_mode.js +53 -0
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/forms/tests/mixins/emptiness.js +114 -0
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/forms/tests/views/form.js +174 -6
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/forms/tests/views/form_row.js +86 -6
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/forms/views/form.js +80 -110
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/forms/views/form_row.js +96 -97
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/polymorphism/README.md +2 -1
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/polymorphism/models/record.js +20 -36
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/select_view/ext/menu.js +121 -0
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/select_view/ext/menu_item.js +90 -0
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/select_view/mixins/select_view_menu.js +139 -0
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/select_view/render_delegates/select_button.js +14 -0
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/select_view/tests/ext/menu_resizing.js +25 -0
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/select_view/tests/mixins/select_view_menu/bindings.js +43 -0
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/select_view/tests/mixins/select_view_menu/check_selected.js +32 -0
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/select_view/tests/views/popup_button/menu_setup.js +40 -0
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/select_view/tests/views/popup_button/show_menu.js +45 -0
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/select_view/tests/views/select/menu_width.js +49 -0
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/select_view/tests/views/select/selected_item.js +191 -0
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/select_view/views/popup_button.js +264 -0
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/select_view/views/select.js +450 -0
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/split_view/mixins/split_child.js +14 -6
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/split_view/mixins/split_thumb.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/split_view/render_delegates/split.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/split_view/render_delegates/split_divider.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/split_view/views/split.js +9 -0
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/split_view/views/thumb.js +3 -2
- data/lib/frameworks/sproutcore/frameworks/foundation/mixins/auto_resize.js +7 -17
- data/lib/frameworks/sproutcore/frameworks/foundation/mixins/content_value_support.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/foundation/mixins/flowed_layout.js +35 -8
- data/lib/frameworks/sproutcore/frameworks/foundation/mixins/inline_editable.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/foundation/mixins/inline_editor.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/foundation/mixins/inline_editor_delegate.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/foundation/mixins/inner_frame.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/foundation/render_delegates/canvas_image.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/foundation/render_delegates/helpers/sizing.js +2 -0
- data/lib/frameworks/sproutcore/frameworks/foundation/render_delegates/image.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/foundation/render_delegates/label.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/foundation/render_delegates/render_delegate.js +6 -6
- data/lib/frameworks/sproutcore/frameworks/foundation/resources/images/favicon.ico +0 -0
- data/lib/frameworks/sproutcore/frameworks/foundation/resources/text_field.css +0 -5
- data/lib/frameworks/sproutcore/frameworks/foundation/system/exception_handler.js +4 -2
- data/lib/frameworks/sproutcore/frameworks/foundation/system/math.js +2 -1
- data/lib/frameworks/sproutcore/frameworks/foundation/system/module.js +13 -0
- data/lib/frameworks/sproutcore/frameworks/foundation/system/utils/string_measurement.js +6 -9
- data/lib/frameworks/sproutcore/frameworks/foundation/tests/mixins/flowed_layout/tests.js +912 -0
- data/lib/frameworks/sproutcore/frameworks/foundation/tests/views/text_field/methods.js +36 -7
- data/lib/frameworks/sproutcore/frameworks/foundation/tests/views/text_field/ui.js +58 -4
- data/lib/frameworks/sproutcore/frameworks/foundation/validators/validator.js +1 -3
- data/lib/frameworks/sproutcore/frameworks/foundation/views/field.js +0 -15
- data/lib/frameworks/sproutcore/frameworks/foundation/views/label.js +2 -2
- data/lib/frameworks/sproutcore/frameworks/foundation/views/text_field.js +25 -14
- data/lib/frameworks/sproutcore/frameworks/handlebars/handlebars.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/runtime/core.js +15 -9
- data/lib/frameworks/sproutcore/frameworks/runtime/debug/test_suites/array/flatten.js +24 -0
- data/lib/frameworks/sproutcore/frameworks/runtime/ext/array.js +2 -1
- data/lib/frameworks/sproutcore/frameworks/runtime/ext/function.js +5 -5
- data/lib/frameworks/sproutcore/frameworks/runtime/mixins/array.js +19 -0
- data/lib/frameworks/sproutcore/frameworks/runtime/mixins/copyable.js +3 -2
- data/lib/frameworks/sproutcore/frameworks/runtime/mixins/freezable.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/runtime/mixins/observable.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/runtime/system/binding.js +14 -14
- data/lib/frameworks/sproutcore/frameworks/runtime/system/error.js +3 -0
- data/lib/frameworks/sproutcore/frameworks/runtime/system/logger.js +2 -2
- data/lib/frameworks/sproutcore/frameworks/runtime/system/object.js +2 -2
- data/lib/frameworks/sproutcore/frameworks/runtime/system/range_observer.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/runtime/system/run_loop.js +3 -3
- data/lib/frameworks/sproutcore/frameworks/runtime/system/set.js +15 -16
- data/lib/frameworks/sproutcore/frameworks/runtime/tests/core/itemType.js +6 -2
- data/lib/frameworks/sproutcore/frameworks/runtime/tests/system/object/enhance.js +30 -0
- data/lib/frameworks/sproutcore/frameworks/runtime/tests/system/range_observer/create.js +17 -0
- data/lib/frameworks/sproutcore/frameworks/statechart/system/state.js +9 -2
- data/lib/frameworks/sproutcore/frameworks/statechart/system/statechart.js +3 -1
- data/lib/frameworks/sproutcore/frameworks/testing/resources/runner.css +0 -1
- data/lib/frameworks/sproutcore/frameworks/yuireset/resources/base.css +80 -0
- data/lib/frameworks/sproutcore/frameworks/yuireset/resources/core.css +0 -4
- data/lib/frameworks/sproutcore/lib/index.rhtml +2 -1
- data/lib/frameworks/sproutcore/themes/ace/resources/collection/normal/list.css +3 -3
- data/lib/frameworks/sproutcore/themes/ace/resources/collection/normal/list_item.css +2 -2
- data/lib/frameworks/sproutcore/themes/ace/resources/form/form.css +9 -0
- data/lib/frameworks/sproutcore/themes/ace/resources/menu/menu.css +3 -1
- data/lib/frameworks/sproutcore/themes/ace/resources/picker/popover/picker.js +1 -1
- data/lib/frameworks/sproutcore/themes/ace/resources/picker/popover/workspace.js +1 -1
- data/lib/frameworks/sproutcore/themes/legacy_theme/render_delegates/button.js +1 -1
- data/lib/frameworks/sproutcore/themes/legacy_theme/render_delegates/panel.js +1 -1
- data/lib/frameworks/sproutcore/themes/legacy_theme/render_delegates/progress.js +2 -0
- data/lib/frameworks/sproutcore/themes/legacy_theme/render_delegates/slider.js +1 -1
- data/lib/frameworks/sproutcore/themes/legacy_theme/render_delegates/well.js +1 -1
- data/lib/sproutcore/builders/base.rb +5 -1
- data/lib/sproutcore/builders/handlebars.rb +12 -1
- data/lib/sproutcore/models/target.rb +1 -9
- data/lib/sproutcore/rack/proxy.rb +238 -92
- data/lib/sproutcore/tools/docs.rb +1 -7
- data/spec/fixtures/builder_tests/apps/handlebars_test/Buildfile +1 -0
- data/spec/fixtures/builder_tests/apps/handlebars_test/{template.handlebars → templates/template.handlebars} +2 -0
- data/spec/lib/builders/handlebars_spec.rb +10 -4
- data/sproutcore.gemspec +3 -1
- metadata +73 -44
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/forms/english.lproj/default_styles.css +0 -5
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/forms/english.lproj/strings.js +0 -15
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/forms/tests/views/form_checkbox_field.js +0 -17
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/forms/tests/views/form_field.js +0 -17
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/forms/tests/views/form_label.js +0 -17
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/forms/tests/views/form_radio_field.js +0 -17
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/forms/tests/views/form_text_field.js +0 -17
@@ -211,6 +211,19 @@ SC.Module = SC.Object.create(/** @scope SC.Module */ {
|
|
211
211
|
jQuery.globalEval(moduleSource);
|
212
212
|
delete module.source;
|
213
213
|
|
214
|
+
if (module.cssSource) {
|
215
|
+
var el = document.createElement('style');
|
216
|
+
el.setAttribute('type', 'text/css');
|
217
|
+
if (el.styleSheet) {
|
218
|
+
el.styleSheet.cssText = module.cssSource;
|
219
|
+
} else {
|
220
|
+
var content = document.createTextNode(module.cssSource);
|
221
|
+
el.appendChild(content);
|
222
|
+
}
|
223
|
+
|
224
|
+
document.getElementsByTagName('head')[0].appendChild(el);
|
225
|
+
}
|
226
|
+
|
214
227
|
module.isReady = YES;
|
215
228
|
},
|
216
229
|
|
@@ -118,15 +118,12 @@ SC.mixin( /** @scope SC */ {
|
|
118
118
|
if (!element) {
|
119
119
|
var parentElement = document.createElement("div");
|
120
120
|
|
121
|
-
//
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
right: '0px',
|
128
|
-
overflow: 'hidden'
|
129
|
-
});
|
121
|
+
// To have effectively unbounded widths when no max-width is set,
|
122
|
+
// give the metricsCalculationElement a very wide sandbox.
|
123
|
+
// To make sure it's never visible, position it way, way offscreen.
|
124
|
+
parentElement.style.cssText = "position:absolute; left:-10010px; top:-10px;"+
|
125
|
+
"width:10000px; height:0px; overflow:hidden;"+
|
126
|
+
"visibility:hidden;";
|
130
127
|
|
131
128
|
element = this._metricsCalculationElement = document.createElement("div");
|
132
129
|
|
@@ -0,0 +1,912 @@
|
|
1
|
+
/**
|
2
|
+
The FlowedLaoyut test engine takes expected layouts for a set of conditions. All units
|
3
|
+
are expected in the horizontal orientation; they will be flipped automatically for vertical
|
4
|
+
tests (and the view's width/height/fillWidth/etc. settings changed likewise).
|
5
|
+
|
6
|
+
- With Wrap, 600x400.
|
7
|
+
- With wrap, 400x600.
|
8
|
+
- No wrap, 600x400.
|
9
|
+
- No wrap, 400x600
|
10
|
+
|
11
|
+
The expected positioning should be supplied to the checkPositions method:
|
12
|
+
|
13
|
+
{
|
14
|
+
wrap: {
|
15
|
+
// these are by width (600x400 should use '600')
|
16
|
+
'400': [ { left: ..., top: ..., width: ..., height: ... } ],
|
17
|
+
'600': ...
|
18
|
+
},
|
19
|
+
noWrap: {
|
20
|
+
...
|
21
|
+
}
|
22
|
+
}
|
23
|
+
|
24
|
+
It is a recursive process; each step has multiple possible varieties, and ALL
|
25
|
+
combinations are tested. The first variety is always tested twice.
|
26
|
+
|
27
|
+
For instance, it tests 600x400, then 400x600, then 600x400 again.
|
28
|
+
|
29
|
+
- 600x400 or 400x600
|
30
|
+
- Wrap on and wrap off
|
31
|
+
- Horizontal or Vertical
|
32
|
+
*/
|
33
|
+
|
34
|
+
// helper to make a string from a hash
|
35
|
+
var str = function(obj) {
|
36
|
+
var s = [];
|
37
|
+
for (var i in obj) {
|
38
|
+
s.push("" + i + ": " + obj[i]);
|
39
|
+
}
|
40
|
+
return "{ " + s.join(", ") + "}";
|
41
|
+
};
|
42
|
+
|
43
|
+
var checkSteps = [
|
44
|
+
function wrap(view, positions, context) {
|
45
|
+
SC.RunLoop.begin();
|
46
|
+
view.set('canWrap', YES);
|
47
|
+
SC.RunLoop.end();
|
48
|
+
|
49
|
+
context.performNext(positions.wrap);
|
50
|
+
|
51
|
+
SC.RunLoop.begin();
|
52
|
+
view.set('canWrap', NO);
|
53
|
+
SC.RunLoop.end();
|
54
|
+
|
55
|
+
context.performNext(positions.noWrap);
|
56
|
+
|
57
|
+
SC.RunLoop.begin();
|
58
|
+
view.set('canWrap', YES);
|
59
|
+
SC.RunLoop.end();
|
60
|
+
|
61
|
+
context.performNext(positions.wrap);
|
62
|
+
},
|
63
|
+
|
64
|
+
function dimensions(view, positions, context) {
|
65
|
+
SC.RunLoop.begin();
|
66
|
+
view.set('layout', { left: 0, top: 0, width: 600, height: 400 });
|
67
|
+
SC.RunLoop.end();
|
68
|
+
|
69
|
+
context.performNext(positions['600']);
|
70
|
+
|
71
|
+
SC.RunLoop.begin();
|
72
|
+
view.set('layout', { left: 0, top: 0, width: 400, height: 600});
|
73
|
+
SC.RunLoop.end();
|
74
|
+
|
75
|
+
context.performNext(positions['400']);
|
76
|
+
|
77
|
+
SC.RunLoop.begin();
|
78
|
+
view.set('layout', { left: 0, top: 0, width: 600, height: 400 });
|
79
|
+
SC.RunLoop.end();
|
80
|
+
|
81
|
+
context.performNext(positions['600']);
|
82
|
+
},
|
83
|
+
|
84
|
+
function orientation(view, positions, context) {
|
85
|
+
// we have to convert the positions. By now they should be a simple array,
|
86
|
+
// so we just swap width and height.
|
87
|
+
var verticalPositions = [];
|
88
|
+
for (var idx = 0, len = positions.length; idx < len; idx++) {
|
89
|
+
verticalPositions[idx] = {
|
90
|
+
left: positions[idx].top,
|
91
|
+
top: positions[idx].left,
|
92
|
+
width: positions[idx].height,
|
93
|
+
height: positions[idx].width
|
94
|
+
};
|
95
|
+
}
|
96
|
+
|
97
|
+
function flipChildViews() {
|
98
|
+
var cvs = view.get('childViews');
|
99
|
+
for (var idx = 0, len = cvs.length; idx < len; idx++) {
|
100
|
+
var layout = cvs[idx].get('layout');
|
101
|
+
layout = SC.clone(layout);
|
102
|
+
|
103
|
+
var tmp = layout.width;
|
104
|
+
layout.width = layout.height;
|
105
|
+
layout.height = tmp;
|
106
|
+
|
107
|
+
cvs[idx].set('layout', layout);
|
108
|
+
|
109
|
+
var fillWidth = cvs[idx].get('fillWidth');
|
110
|
+
cvs[idx].set('fillWidth', cvs[idx].get('fillHeight'));
|
111
|
+
cvs[idx].set('fillHeight', fillWidth);
|
112
|
+
}
|
113
|
+
}
|
114
|
+
|
115
|
+
function flipLayout() {
|
116
|
+
var l = SC.clone(view.get('layout'));
|
117
|
+
var w = l.width;
|
118
|
+
l.width= l.height;
|
119
|
+
l.height = w;
|
120
|
+
view.set('layout', l);
|
121
|
+
|
122
|
+
if (view.get('flowPadding')) {
|
123
|
+
l = SC.clone(view.get('flowPadding'));
|
124
|
+
var tmp = l.left;
|
125
|
+
l.left = l.top;
|
126
|
+
l.top = tmp;
|
127
|
+
|
128
|
+
tmp = l.right;
|
129
|
+
l.right = l.bottom;
|
130
|
+
l.bottom = tmp;
|
131
|
+
view.set('flowPadding', l);
|
132
|
+
}
|
133
|
+
}
|
134
|
+
|
135
|
+
SC.RunLoop.begin();
|
136
|
+
view.set('layoutDirection', SC.LAYOUT_HORIZONTAL);
|
137
|
+
SC.RunLoop.end();
|
138
|
+
|
139
|
+
context.performNext(positions);
|
140
|
+
|
141
|
+
SC.RunLoop.begin();
|
142
|
+
view.set('layoutDirection', SC.LAYOUT_VERTICAL);
|
143
|
+
flipChildViews();
|
144
|
+
flipLayout();
|
145
|
+
SC.RunLoop.end();
|
146
|
+
|
147
|
+
context.performNext(verticalPositions);
|
148
|
+
|
149
|
+
SC.RunLoop.begin();
|
150
|
+
view.set('layoutDirection', SC.LAYOUT_HORIZONTAL);
|
151
|
+
flipChildViews();
|
152
|
+
flipLayout();
|
153
|
+
SC.RunLoop.end();
|
154
|
+
|
155
|
+
context.performNext(positions);
|
156
|
+
},
|
157
|
+
|
158
|
+
function final(view, positions, context) {
|
159
|
+
var cvs = view.get('childViews');
|
160
|
+
equals(cvs.length, positions.length, "PRECONDITION: number of child views is the same.");
|
161
|
+
|
162
|
+
for (var idx = 0; idx < positions.length; idx++) {
|
163
|
+
var cv = cvs[idx], expect = positions[idx], equal = YES;
|
164
|
+
for (var i in expect) {
|
165
|
+
if (expect.hasOwnProperty(i)) {
|
166
|
+
if (cv.get('layout')[i] !== expect[i]) {
|
167
|
+
equal = NO;
|
168
|
+
break;
|
169
|
+
}
|
170
|
+
}
|
171
|
+
}
|
172
|
+
|
173
|
+
ok(
|
174
|
+
equal,
|
175
|
+
"Actual: " +
|
176
|
+
str(cv.get('layout')) + "; expected: " +
|
177
|
+
str(expect) + "; canWrap: " + view.get('canWrap') + "; " +
|
178
|
+
"orientation: " + view.get('layoutDirection') + "; " +
|
179
|
+
"layout: " + str(view.get('layout'))
|
180
|
+
);
|
181
|
+
}
|
182
|
+
}
|
183
|
+
];
|
184
|
+
|
185
|
+
function checkPositions(view, positions) {
|
186
|
+
var context = {
|
187
|
+
position: 0,
|
188
|
+
performNext: function(positions) {
|
189
|
+
var next = checkSteps[this.position];
|
190
|
+
this.position++;
|
191
|
+
next(view, positions, this);
|
192
|
+
this.position--;
|
193
|
+
}
|
194
|
+
};
|
195
|
+
|
196
|
+
context.performNext(positions);
|
197
|
+
}
|
198
|
+
|
199
|
+
|
200
|
+
|
201
|
+
module("FlowedLayout");
|
202
|
+
|
203
|
+
test("Basic flow", function() {
|
204
|
+
var view = SC.View.create(SC.FlowedLayout, {
|
205
|
+
childViews: 'a b c'.w(),
|
206
|
+
|
207
|
+
a: SC.View.create({
|
208
|
+
layout: { width: 100, height: 100 }
|
209
|
+
}),
|
210
|
+
|
211
|
+
b: SC.View.create({
|
212
|
+
layout: { width: 300, height: 100 }
|
213
|
+
}),
|
214
|
+
|
215
|
+
c: SC.View.create({
|
216
|
+
layout: { width: 200, height: 100 }
|
217
|
+
})
|
218
|
+
});
|
219
|
+
|
220
|
+
var expect = {
|
221
|
+
wrap: {
|
222
|
+
400: [
|
223
|
+
{ left: 0, top: 0, width: 100, height: 100 },
|
224
|
+
{ left: 100, top: 0, width: 300, height: 100 },
|
225
|
+
{ left: 0, top: 100, width: 200, height: 100 }
|
226
|
+
],
|
227
|
+
600: [
|
228
|
+
{ left: 0, top: 0, width: 100, height: 100 },
|
229
|
+
{ left: 100, top: 0, width: 300, height: 100 },
|
230
|
+
{ left: 400, top: 0, width: 200, height: 100 }
|
231
|
+
]
|
232
|
+
},
|
233
|
+
|
234
|
+
noWrap: {
|
235
|
+
400: [
|
236
|
+
{ left: 0, top: 0, width: 100, height: 100 },
|
237
|
+
{ left: 100, top: 0, width: 300, height: 100 },
|
238
|
+
{ left: 400, top: 0, width: 200, height: 100 }
|
239
|
+
],
|
240
|
+
600: [
|
241
|
+
{ left: 0, top: 0, width: 100, height: 100 },
|
242
|
+
{ left: 100, top: 0, width: 300, height: 100 },
|
243
|
+
{ left: 400, top: 0, width: 200, height: 100 }
|
244
|
+
]
|
245
|
+
}
|
246
|
+
};
|
247
|
+
|
248
|
+
checkPositions(view, expect);
|
249
|
+
});
|
250
|
+
|
251
|
+
module("FlowedLayout -- Alignment");
|
252
|
+
test("Align center", function() {
|
253
|
+
var view = SC.View.create(SC.FlowedLayout, {
|
254
|
+
align: SC.ALIGN_LEFT,
|
255
|
+
|
256
|
+
childViews: 'a b c'.w(),
|
257
|
+
|
258
|
+
a: SC.View.create({
|
259
|
+
layout: { width: 100, height: 100 }
|
260
|
+
}),
|
261
|
+
|
262
|
+
b: SC.View.create({
|
263
|
+
layout: { width: 300, height: 100 }
|
264
|
+
}),
|
265
|
+
|
266
|
+
c: SC.View.create({
|
267
|
+
layout: { width: 200, height: 100 }
|
268
|
+
})
|
269
|
+
});
|
270
|
+
|
271
|
+
var expect = {
|
272
|
+
wrap: {
|
273
|
+
400: [
|
274
|
+
{ left: 0, top: 0, width: 100, height: 100 },
|
275
|
+
{ left: 100, top: 0, width: 300, height: 100 },
|
276
|
+
{ left: 0, top: 100, width: 200, height: 100 }
|
277
|
+
],
|
278
|
+
600: [
|
279
|
+
{ left: 0, top: 0, width: 100, height: 100 },
|
280
|
+
{ left: 100, top: 0, width: 300, height: 100 },
|
281
|
+
{ left: 400, top: 0, width: 200, height: 100 }
|
282
|
+
]
|
283
|
+
},
|
284
|
+
|
285
|
+
noWrap: {
|
286
|
+
400: [
|
287
|
+
{ left: 0, top: 0, width: 100, height: 100 },
|
288
|
+
{ left: 100, top: 0, width: 300, height: 100 },
|
289
|
+
{ left: 400, top: 0, width: 200, height: 100 }
|
290
|
+
],
|
291
|
+
600: [
|
292
|
+
{ left: 0, top: 0, width: 100, height: 100 },
|
293
|
+
{ left: 100, top: 0, width: 300, height: 100 },
|
294
|
+
{ left: 400, top: 0, width: 200, height: 100 }
|
295
|
+
]
|
296
|
+
}
|
297
|
+
};
|
298
|
+
|
299
|
+
checkPositions(view, expect);
|
300
|
+
|
301
|
+
SC.RunLoop.begin();
|
302
|
+
view.set('align', SC.ALIGN_CENTER);
|
303
|
+
SC.RunLoop.end();
|
304
|
+
|
305
|
+
expect.wrap['400'][2].left = 100;
|
306
|
+
|
307
|
+
expect.noWrap['400'][0].left = -100;
|
308
|
+
expect.noWrap['400'][1].left = 0;
|
309
|
+
expect.noWrap['400'][2].left = 300;
|
310
|
+
|
311
|
+
checkPositions(view, expect);
|
312
|
+
});
|
313
|
+
|
314
|
+
test("Align right", function() {
|
315
|
+
var view = SC.View.create(SC.FlowedLayout, {
|
316
|
+
align: SC.ALIGN_LEFT,
|
317
|
+
|
318
|
+
childViews: 'a b c'.w(),
|
319
|
+
|
320
|
+
a: SC.View.create({
|
321
|
+
layout: { width: 100, height: 100 }
|
322
|
+
}),
|
323
|
+
|
324
|
+
b: SC.View.create({
|
325
|
+
layout: { width: 300, height: 100 }
|
326
|
+
}),
|
327
|
+
|
328
|
+
c: SC.View.create({
|
329
|
+
layout: { width: 200, height: 100 }
|
330
|
+
})
|
331
|
+
});
|
332
|
+
|
333
|
+
var expect = {
|
334
|
+
wrap: {
|
335
|
+
400: [
|
336
|
+
{ left: 0, top: 0, width: 100, height: 100 },
|
337
|
+
{ left: 100, top: 0, width: 300, height: 100 },
|
338
|
+
{ left: 0, top: 100, width: 200, height: 100 }
|
339
|
+
],
|
340
|
+
600: [
|
341
|
+
{ left: 0, top: 0, width: 100, height: 100 },
|
342
|
+
{ left: 100, top: 0, width: 300, height: 100 },
|
343
|
+
{ left: 400, top: 0, width: 200, height: 100 }
|
344
|
+
]
|
345
|
+
},
|
346
|
+
|
347
|
+
noWrap: {
|
348
|
+
400: [
|
349
|
+
{ left: 0, top: 0, width: 100, height: 100 },
|
350
|
+
{ left: 100, top: 0, width: 300, height: 100 },
|
351
|
+
{ left: 400, top: 0, width: 200, height: 100 }
|
352
|
+
],
|
353
|
+
600: [
|
354
|
+
{ left: 0, top: 0, width: 100, height: 100 },
|
355
|
+
{ left: 100, top: 0, width: 300, height: 100 },
|
356
|
+
{ left: 400, top: 0, width: 200, height: 100 }
|
357
|
+
]
|
358
|
+
}
|
359
|
+
};
|
360
|
+
|
361
|
+
checkPositions(view, expect);
|
362
|
+
|
363
|
+
SC.RunLoop.begin();
|
364
|
+
view.set('align', SC.ALIGN_RIGHT);
|
365
|
+
SC.RunLoop.end();
|
366
|
+
|
367
|
+
expect.wrap['400'][2].left = 200;
|
368
|
+
|
369
|
+
expect.noWrap['400'][0].left = -200;
|
370
|
+
expect.noWrap['400'][1].left = -100;
|
371
|
+
expect.noWrap['400'][2].left = 200;
|
372
|
+
|
373
|
+
checkPositions(view, expect);
|
374
|
+
});
|
375
|
+
|
376
|
+
test("Align justify", function() {
|
377
|
+
var view = SC.View.create(SC.FlowedLayout, {
|
378
|
+
align: SC.ALIGN_LEFT,
|
379
|
+
|
380
|
+
childViews: 'a b c'.w(),
|
381
|
+
|
382
|
+
a: SC.View.create({
|
383
|
+
layout: { width: 100, height: 100 }
|
384
|
+
}),
|
385
|
+
|
386
|
+
b: SC.View.create({
|
387
|
+
layout: { width: 200, height: 100 }
|
388
|
+
}),
|
389
|
+
|
390
|
+
c: SC.View.create({
|
391
|
+
layout: { width: 200, height: 100 }
|
392
|
+
})
|
393
|
+
});
|
394
|
+
|
395
|
+
var expect = {
|
396
|
+
wrap: {
|
397
|
+
400: [
|
398
|
+
{ left: 0, top: 0, width: 100, height: 100 },
|
399
|
+
{ left: 100, top: 0, width: 200, height: 100 },
|
400
|
+
{ left: 0, top: 100, width: 200, height: 100 }
|
401
|
+
],
|
402
|
+
600: [
|
403
|
+
{ left: 0, top: 0, width: 100, height: 100 },
|
404
|
+
{ left: 100, top: 0, width: 200, height: 100 },
|
405
|
+
{ left: 300, top: 0, width: 200, height: 100 }
|
406
|
+
]
|
407
|
+
},
|
408
|
+
|
409
|
+
noWrap: {
|
410
|
+
400: [
|
411
|
+
{ left: 0, top: 0, width: 100, height: 100 },
|
412
|
+
{ left: 100, top: 0, width: 200, height: 100 },
|
413
|
+
{ left: 300, top: 0, width: 200, height: 100 }
|
414
|
+
],
|
415
|
+
600: [
|
416
|
+
{ left: 0, top: 0, width: 100, height: 100 },
|
417
|
+
{ left: 100, top: 0, width: 200, height: 100 },
|
418
|
+
{ left: 300, top: 0, width: 200, height: 100 }
|
419
|
+
]
|
420
|
+
}
|
421
|
+
};
|
422
|
+
|
423
|
+
checkPositions(view, expect);
|
424
|
+
|
425
|
+
SC.RunLoop.begin();
|
426
|
+
view.set('align', SC.ALIGN_JUSTIFY);
|
427
|
+
SC.RunLoop.end();
|
428
|
+
|
429
|
+
expect.wrap['400'][1].left = 200;
|
430
|
+
|
431
|
+
expect.wrap['600'][1].left = 150;
|
432
|
+
expect.wrap['600'][2].left = 400;
|
433
|
+
|
434
|
+
expect.noWrap['600'][1].left = 150;
|
435
|
+
expect.noWrap['600'][2].left = 400;
|
436
|
+
|
437
|
+
checkPositions(view, expect);
|
438
|
+
});
|
439
|
+
|
440
|
+
module("FlowedLayout - Flags");
|
441
|
+
|
442
|
+
test("flowPadding", function() {
|
443
|
+
var view = SC.View.create(SC.FlowedLayout, {
|
444
|
+
align: SC.ALIGN_LEFT,
|
445
|
+
|
446
|
+
childViews: 'a b c'.w(),
|
447
|
+
|
448
|
+
a: SC.View.create({
|
449
|
+
layout: { width: 100, height: 100 }
|
450
|
+
}),
|
451
|
+
|
452
|
+
b: SC.View.create({
|
453
|
+
layout: { width: 200, height: 100 }
|
454
|
+
}),
|
455
|
+
|
456
|
+
c: SC.View.create({
|
457
|
+
layout: { width: 200, height: 100 }
|
458
|
+
})
|
459
|
+
});
|
460
|
+
|
461
|
+
var expect = {
|
462
|
+
wrap: {
|
463
|
+
400: [
|
464
|
+
{ left: 0, top: 0, width: 100, height: 100 },
|
465
|
+
{ left: 100, top: 0, width: 200, height: 100 },
|
466
|
+
{ left: 0, top: 100, width: 200, height: 100 }
|
467
|
+
],
|
468
|
+
600: [
|
469
|
+
{ left: 0, top: 0, width: 100, height: 100 },
|
470
|
+
{ left: 100, top: 0, width: 200, height: 100 },
|
471
|
+
{ left: 300, top: 0, width: 200, height: 100 }
|
472
|
+
]
|
473
|
+
},
|
474
|
+
|
475
|
+
noWrap: {
|
476
|
+
400: [
|
477
|
+
{ left: 0, top: 0, width: 100, height: 100 },
|
478
|
+
{ left: 100, top: 0, width: 200, height: 100 },
|
479
|
+
{ left: 300, top: 0, width: 200, height: 100 }
|
480
|
+
],
|
481
|
+
600: [
|
482
|
+
{ left: 0, top: 0, width: 100, height: 100 },
|
483
|
+
{ left: 100, top: 0, width: 200, height: 100 },
|
484
|
+
{ left: 300, top: 0, width: 200, height: 100 }
|
485
|
+
]
|
486
|
+
}
|
487
|
+
};
|
488
|
+
|
489
|
+
checkPositions(view, expect);
|
490
|
+
|
491
|
+
SC.RunLoop.begin();
|
492
|
+
view.set('flowPadding', { left: 5, top: 8, right: 210, bottom: 0 });
|
493
|
+
SC.RunLoop.end();
|
494
|
+
|
495
|
+
expect.wrap[400][0].left = 5;
|
496
|
+
expect.wrap[400][0].top = 8;
|
497
|
+
expect.wrap[400][1].left = 5;
|
498
|
+
expect.wrap[400][1].top = 108;
|
499
|
+
expect.wrap[400][2].left = 5;
|
500
|
+
expect.wrap[400][2].top = 208;
|
501
|
+
|
502
|
+
expect.wrap[600][0].left = 5;
|
503
|
+
expect.wrap[600][0].top = 8;
|
504
|
+
expect.wrap[600][1].left = 105;
|
505
|
+
expect.wrap[600][1].top = 8;
|
506
|
+
expect.wrap[600][2].left = 5;
|
507
|
+
expect.wrap[600][2].top = 108;
|
508
|
+
|
509
|
+
expect.noWrap[400][0].left = 5;
|
510
|
+
expect.noWrap[400][0].top = 8;
|
511
|
+
expect.noWrap[400][1].left = 105;
|
512
|
+
expect.noWrap[400][1].top = 8;
|
513
|
+
expect.noWrap[400][2].left = 305;
|
514
|
+
expect.noWrap[400][2].top = 8;
|
515
|
+
|
516
|
+
expect.noWrap[600] = expect.noWrap[400];
|
517
|
+
|
518
|
+
checkPositions(view, expect);
|
519
|
+
|
520
|
+
});
|
521
|
+
|
522
|
+
test("FlowedLayout - defaultFlowSpacing", function() {
|
523
|
+
var view = SC.View.create(SC.FlowedLayout, {
|
524
|
+
align: SC.ALIGN_LEFT,
|
525
|
+
|
526
|
+
childViews: 'a b c'.w(),
|
527
|
+
|
528
|
+
a: SC.View.create({
|
529
|
+
layout: { width: 100, height: 100 }
|
530
|
+
}),
|
531
|
+
|
532
|
+
b: SC.View.create({
|
533
|
+
layout: { width: 200, height: 100 }
|
534
|
+
}),
|
535
|
+
|
536
|
+
c: SC.View.create({
|
537
|
+
layout: { width: 200, height: 100 }
|
538
|
+
})
|
539
|
+
});
|
540
|
+
|
541
|
+
var expect = {
|
542
|
+
wrap: {
|
543
|
+
400: [
|
544
|
+
{ left: 0, top: 0, width: 100, height: 100 },
|
545
|
+
{ left: 100, top: 0, width: 200, height: 100 },
|
546
|
+
{ left: 0, top: 100, width: 200, height: 100 }
|
547
|
+
],
|
548
|
+
600: [
|
549
|
+
{ left: 0, top: 0, width: 100, height: 100 },
|
550
|
+
{ left: 100, top: 0, width: 200, height: 100 },
|
551
|
+
{ left: 300, top: 0, width: 200, height: 100 }
|
552
|
+
]
|
553
|
+
},
|
554
|
+
|
555
|
+
noWrap: {
|
556
|
+
400: [
|
557
|
+
{ left: 0, top: 0, width: 100, height: 100 },
|
558
|
+
{ left: 100, top: 0, width: 200, height: 100 },
|
559
|
+
{ left: 300, top: 0, width: 200, height: 100 }
|
560
|
+
],
|
561
|
+
600: [
|
562
|
+
{ left: 0, top: 0, width: 100, height: 100 },
|
563
|
+
{ left: 100, top: 0, width: 200, height: 100 },
|
564
|
+
{ left: 300, top: 0, width: 200, height: 100 }
|
565
|
+
]
|
566
|
+
}
|
567
|
+
};
|
568
|
+
|
569
|
+
checkPositions(view, expect);
|
570
|
+
|
571
|
+
SC.RunLoop.begin();
|
572
|
+
view.set('defaultFlowSpacing', 5);
|
573
|
+
SC.RunLoop.end();
|
574
|
+
|
575
|
+
expect.wrap[400][0].left = 5;
|
576
|
+
expect.wrap[400][0].top = 5;
|
577
|
+
expect.wrap[400][1].left = 115;
|
578
|
+
expect.wrap[400][1].top = 5;
|
579
|
+
expect.wrap[400][2].left = 5;
|
580
|
+
expect.wrap[400][2].top = 115;
|
581
|
+
|
582
|
+
expect.wrap[600][0].left = 5;
|
583
|
+
expect.wrap[600][0].top = 5;
|
584
|
+
expect.wrap[600][1].left = 115;
|
585
|
+
expect.wrap[600][1].top = 5;
|
586
|
+
expect.wrap[600][2].left = 325;
|
587
|
+
expect.wrap[600][2].top = 5;
|
588
|
+
|
589
|
+
expect.noWrap[600] = expect.noWrap[400] = expect.wrap[600];
|
590
|
+
|
591
|
+
checkPositions(view, expect);
|
592
|
+
});
|
593
|
+
|
594
|
+
module("FlowedLayout - Child View Flags");
|
595
|
+
|
596
|
+
test("startsNewRow", function() {
|
597
|
+
var view = SC.View.create(SC.FlowedLayout, {
|
598
|
+
align: SC.ALIGN_LEFT,
|
599
|
+
|
600
|
+
childViews: 'a b c'.w(),
|
601
|
+
|
602
|
+
a: SC.View.create({
|
603
|
+
layout: { width: 100, height: 100 }
|
604
|
+
}),
|
605
|
+
|
606
|
+
b: SC.View.create({
|
607
|
+
layout: { width: 200, height: 100 }
|
608
|
+
}),
|
609
|
+
|
610
|
+
c: SC.View.create({
|
611
|
+
layout: { width: 200, height: 100 }
|
612
|
+
})
|
613
|
+
});
|
614
|
+
|
615
|
+
var expect = {
|
616
|
+
wrap: {
|
617
|
+
400: [
|
618
|
+
{ left: 0, top: 0, width: 100, height: 100 },
|
619
|
+
{ left: 100, top: 0, width: 200, height: 100 },
|
620
|
+
{ left: 0, top: 100, width: 200, height: 100 }
|
621
|
+
],
|
622
|
+
600: [
|
623
|
+
{ left: 0, top: 0, width: 100, height: 100 },
|
624
|
+
{ left: 100, top: 0, width: 200, height: 100 },
|
625
|
+
{ left: 300, top: 0, width: 200, height: 100 }
|
626
|
+
]
|
627
|
+
},
|
628
|
+
|
629
|
+
noWrap: {
|
630
|
+
400: [
|
631
|
+
{ left: 0, top: 0, width: 100, height: 100 },
|
632
|
+
{ left: 100, top: 0, width: 200, height: 100 },
|
633
|
+
{ left: 300, top: 0, width: 200, height: 100 }
|
634
|
+
],
|
635
|
+
600: [
|
636
|
+
{ left: 0, top: 0, width: 100, height: 100 },
|
637
|
+
{ left: 100, top: 0, width: 200, height: 100 },
|
638
|
+
{ left: 300, top: 0, width: 200, height: 100 }
|
639
|
+
]
|
640
|
+
}
|
641
|
+
};
|
642
|
+
|
643
|
+
checkPositions(view, expect);
|
644
|
+
|
645
|
+
SC.RunLoop.begin();
|
646
|
+
view.childViews[1].set('startsNewRow', YES);
|
647
|
+
SC.RunLoop.end();
|
648
|
+
|
649
|
+
expect.wrap[400][1].top = 100;
|
650
|
+
expect.wrap[400][1].left = 0;
|
651
|
+
|
652
|
+
expect.wrap[400][2].left = 200;
|
653
|
+
expect.wrap[400][2].top = 100;
|
654
|
+
|
655
|
+
expect.wrap[600] = expect.wrap[400];
|
656
|
+
expect.noWrap = expect.wrap;
|
657
|
+
|
658
|
+
checkPositions(view, expect);
|
659
|
+
|
660
|
+
});
|
661
|
+
|
662
|
+
test("flowSpacing", function() {
|
663
|
+
var view = SC.View.create(SC.FlowedLayout, {
|
664
|
+
align: SC.ALIGN_LEFT,
|
665
|
+
|
666
|
+
childViews: 'a b c'.w(),
|
667
|
+
|
668
|
+
a: SC.View.create({
|
669
|
+
layout: { width: 100, height: 100 }
|
670
|
+
}),
|
671
|
+
|
672
|
+
b: SC.View.create({
|
673
|
+
layout: { width: 200, height: 100 }
|
674
|
+
}),
|
675
|
+
|
676
|
+
c: SC.View.create({
|
677
|
+
layout: { width: 200, height: 100 }
|
678
|
+
})
|
679
|
+
});
|
680
|
+
|
681
|
+
var expect = {
|
682
|
+
wrap: {
|
683
|
+
400: [
|
684
|
+
{ left: 0, top: 0, width: 100, height: 100 },
|
685
|
+
{ left: 100, top: 0, width: 200, height: 100 },
|
686
|
+
{ left: 0, top: 100, width: 200, height: 100 }
|
687
|
+
],
|
688
|
+
600: [
|
689
|
+
{ left: 0, top: 0, width: 100, height: 100 },
|
690
|
+
{ left: 100, top: 0, width: 200, height: 100 },
|
691
|
+
{ left: 300, top: 0, width: 200, height: 100 }
|
692
|
+
]
|
693
|
+
},
|
694
|
+
|
695
|
+
noWrap: {
|
696
|
+
400: [
|
697
|
+
{ left: 0, top: 0, width: 100, height: 100 },
|
698
|
+
{ left: 100, top: 0, width: 200, height: 100 },
|
699
|
+
{ left: 300, top: 0, width: 200, height: 100 }
|
700
|
+
],
|
701
|
+
600: [
|
702
|
+
{ left: 0, top: 0, width: 100, height: 100 },
|
703
|
+
{ left: 100, top: 0, width: 200, height: 100 },
|
704
|
+
{ left: 300, top: 0, width: 200, height: 100 }
|
705
|
+
]
|
706
|
+
}
|
707
|
+
};
|
708
|
+
|
709
|
+
checkPositions(view, expect);
|
710
|
+
|
711
|
+
SC.RunLoop.begin();
|
712
|
+
view.childViews[1].set('flowSpacing', { left: 20, top: 20, bottom: 20, right: 20 });
|
713
|
+
SC.RunLoop.end();
|
714
|
+
|
715
|
+
expect.wrap[400][1].left = 120;
|
716
|
+
expect.wrap[400][1].top = 20;
|
717
|
+
expect.wrap[400][2].top = 140;
|
718
|
+
|
719
|
+
expect.wrap[600][1].left = 120;
|
720
|
+
expect.wrap[600][1].top = 20;
|
721
|
+
expect.wrap[600][2].left = 340;
|
722
|
+
|
723
|
+
// because wrap is off, it should look like the results for wrapping 600 which,
|
724
|
+
// due to its width, doesn't wrap either.
|
725
|
+
expect.noWrap[400] = expect.noWrap[600] = expect.wrap[600];
|
726
|
+
|
727
|
+
checkPositions(view, expect);
|
728
|
+
|
729
|
+
});
|
730
|
+
|
731
|
+
test("fillHeight", function() {
|
732
|
+
var view = SC.View.create(SC.FlowedLayout, {
|
733
|
+
align: SC.ALIGN_LEFT,
|
734
|
+
|
735
|
+
childViews: 'a b c'.w(),
|
736
|
+
|
737
|
+
a: SC.View.create({
|
738
|
+
layout: { width: 100, height: 100 }
|
739
|
+
}),
|
740
|
+
|
741
|
+
b: SC.View.create({
|
742
|
+
layout: { width: 200, height: 50 }
|
743
|
+
}),
|
744
|
+
|
745
|
+
c: SC.View.create({
|
746
|
+
layout: { width: 200, height: 100 }
|
747
|
+
})
|
748
|
+
});
|
749
|
+
|
750
|
+
var expect = {
|
751
|
+
wrap: {
|
752
|
+
400: [
|
753
|
+
{ left: 0, top: 0, width: 100, height: 100 },
|
754
|
+
{ left: 100, top: 0, width: 200, height: 50 },
|
755
|
+
{ left: 0, top: 100, width: 200, height: 100 }
|
756
|
+
],
|
757
|
+
600: [
|
758
|
+
{ left: 0, top: 0, width: 100, height: 100 },
|
759
|
+
{ left: 100, top: 0, width: 200, height: 50 },
|
760
|
+
{ left: 300, top: 0, width: 200, height: 100 }
|
761
|
+
]
|
762
|
+
},
|
763
|
+
|
764
|
+
noWrap: {
|
765
|
+
400: [
|
766
|
+
{ left: 0, top: 0, width: 100, height: 100 },
|
767
|
+
{ left: 100, top: 0, width: 200, height: 50 },
|
768
|
+
{ left: 300, top: 0, width: 200, height: 100 }
|
769
|
+
],
|
770
|
+
600: [
|
771
|
+
{ left: 0, top: 0, width: 100, height: 100 },
|
772
|
+
{ left: 100, top: 0, width: 200, height: 50 },
|
773
|
+
{ left: 300, top: 0, width: 200, height: 100 }
|
774
|
+
]
|
775
|
+
}
|
776
|
+
};
|
777
|
+
|
778
|
+
checkPositions(view, expect);
|
779
|
+
|
780
|
+
SC.RunLoop.begin();
|
781
|
+
view.childViews[1].set('fillHeight', YES);
|
782
|
+
SC.RunLoop.end();
|
783
|
+
|
784
|
+
expect.wrap[400][1].height = 100;
|
785
|
+
expect.wrap[600][1].height = 100;
|
786
|
+
expect.noWrap[400][1].height = 100;
|
787
|
+
expect.noWrap[600][1].height = 100;
|
788
|
+
|
789
|
+
checkPositions(view, expect);
|
790
|
+
|
791
|
+
});
|
792
|
+
|
793
|
+
|
794
|
+
test("isSpacer", function() {
|
795
|
+
var view = SC.View.create(SC.FlowedLayout, {
|
796
|
+
align: SC.ALIGN_LEFT,
|
797
|
+
|
798
|
+
childViews: 'a b c'.w(),
|
799
|
+
|
800
|
+
a: SC.View.create({
|
801
|
+
layout: { width: 100, height: 100 }
|
802
|
+
}),
|
803
|
+
|
804
|
+
b: SC.View.create({
|
805
|
+
layout: { width: 200, height: 100 }
|
806
|
+
}),
|
807
|
+
|
808
|
+
c: SC.View.create({
|
809
|
+
layout: { width: 200, height: 100 }
|
810
|
+
})
|
811
|
+
});
|
812
|
+
|
813
|
+
var expect = {
|
814
|
+
wrap: {
|
815
|
+
400: [
|
816
|
+
{ left: 0, top: 0, width: 100, height: 100 },
|
817
|
+
{ left: 100, top: 0, width: 200, height: 100 },
|
818
|
+
{ left: 0, top: 100, width: 200, height: 100 }
|
819
|
+
],
|
820
|
+
600: [
|
821
|
+
{ left: 0, top: 0, width: 100, height: 100 },
|
822
|
+
{ left: 100, top: 0, width: 200, height: 100 },
|
823
|
+
{ left: 300, top: 0, width: 200, height: 100 }
|
824
|
+
]
|
825
|
+
},
|
826
|
+
|
827
|
+
noWrap: {
|
828
|
+
400: [
|
829
|
+
{ left: 0, top: 0, width: 100, height: 100 },
|
830
|
+
{ left: 100, top: 0, width: 200, height: 100 },
|
831
|
+
{ left: 300, top: 0, width: 200, height: 100 }
|
832
|
+
],
|
833
|
+
600: [
|
834
|
+
{ left: 0, top: 0, width: 100, height: 100 },
|
835
|
+
{ left: 100, top: 0, width: 200, height: 100 },
|
836
|
+
{ left: 300, top: 0, width: 200, height: 100 }
|
837
|
+
]
|
838
|
+
}
|
839
|
+
};
|
840
|
+
|
841
|
+
checkPositions(view, expect);
|
842
|
+
|
843
|
+
SC.RunLoop.begin();
|
844
|
+
view.childViews[1].set('isSpacer', YES);
|
845
|
+
SC.RunLoop.end();
|
846
|
+
|
847
|
+
expect.wrap[400][1].width = 100;
|
848
|
+
expect.wrap[400][2].top = 0;
|
849
|
+
expect.wrap[400][2].left = 200;
|
850
|
+
|
851
|
+
expect.wrap[600][1].width = 300;
|
852
|
+
expect.wrap[600][2].left = 400;
|
853
|
+
expect.noWrap[400] = expect.wrap[400];
|
854
|
+
expect.noWrap[600] = expect.wrap[600];
|
855
|
+
|
856
|
+
checkPositions(view, expect);
|
857
|
+
|
858
|
+
});
|
859
|
+
|
860
|
+
test("undefined and null can be passed for both defaultFlowSpacing and child's flowSpacing", function() {
|
861
|
+
var view = SC.View.create(SC.FlowedLayout, {
|
862
|
+
childViews: 'a b c'.w(),
|
863
|
+
|
864
|
+
a: SC.View.create({
|
865
|
+
layout: { width: 100, height: 100 }
|
866
|
+
}),
|
867
|
+
|
868
|
+
b: SC.View.create({
|
869
|
+
layout: { width: 300, height: 100 }
|
870
|
+
}),
|
871
|
+
|
872
|
+
c: SC.View.create({
|
873
|
+
layout: { width: 200, height: 100 }
|
874
|
+
})
|
875
|
+
});
|
876
|
+
|
877
|
+
var expect = {
|
878
|
+
wrap: {
|
879
|
+
400: [
|
880
|
+
{ left: 0, top: 0, width: 100, height: 100 },
|
881
|
+
{ left: 100, top: 0, width: 300, height: 100 },
|
882
|
+
{ left: 0, top: 100, width: 200, height: 100 }
|
883
|
+
],
|
884
|
+
600: [
|
885
|
+
{ left: 0, top: 0, width: 100, height: 100 },
|
886
|
+
{ left: 100, top: 0, width: 300, height: 100 },
|
887
|
+
{ left: 400, top: 0, width: 200, height: 100 }
|
888
|
+
]
|
889
|
+
},
|
890
|
+
|
891
|
+
noWrap: {
|
892
|
+
400: [
|
893
|
+
{ left: 0, top: 0, width: 100, height: 100 },
|
894
|
+
{ left: 100, top: 0, width: 300, height: 100 },
|
895
|
+
{ left: 400, top: 0, width: 200, height: 100 }
|
896
|
+
],
|
897
|
+
600: [
|
898
|
+
{ left: 0, top: 0, width: 100, height: 100 },
|
899
|
+
{ left: 100, top: 0, width: 300, height: 100 },
|
900
|
+
{ left: 400, top: 0, width: 200, height: 100 }
|
901
|
+
]
|
902
|
+
}
|
903
|
+
};
|
904
|
+
|
905
|
+
checkPositions(view, expect);
|
906
|
+
|
907
|
+
view.set('defaultFlowSpacing', undefined);
|
908
|
+
|
909
|
+
checkPositions(view, expect);
|
910
|
+
|
911
|
+
});
|
912
|
+
|