sproutcore 1.10.0.rc.2 → 1.10.0.rc.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +8 -8
- data/VERSION.yml +1 -1
- data/lib/frameworks/sproutcore/CHANGELOG.md +14 -0
- data/lib/frameworks/sproutcore/frameworks/core_foundation/controllers/array.js +9 -1
- data/lib/frameworks/sproutcore/frameworks/core_foundation/panes/pane_statechart.js +7 -0
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/controllers/array/array_case.js +14 -0
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/layout.js +103 -0
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/layoutChildViews.js +4 -4
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/layoutDidChange.js +4 -1
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/viewDidResize.js +5 -5
- data/lib/frameworks/sproutcore/frameworks/core_foundation/views/view/layout.js +17 -6
- data/lib/frameworks/sproutcore/frameworks/core_foundation/views/view/statechart.js +62 -8
- data/lib/frameworks/sproutcore/frameworks/core_foundation/views/view.js +14 -2
- data/lib/frameworks/sproutcore/frameworks/datastore/system/store.js +26 -5
- data/lib/frameworks/sproutcore/frameworks/datastore/tests/integration/many_array.js +9 -1
- data/lib/frameworks/sproutcore/frameworks/datastore/tests/models/nested_records/data_store.js +6 -2
- data/lib/frameworks/sproutcore/frameworks/desktop/mixins/split_child.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/desktop/panes/picker.js +0 -2
- data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/list/render.js +56 -54
- data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/scroll/methods.js +221 -171
- data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/split/methods.js +261 -315
- data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/split/split_child.js +137 -122
- data/lib/frameworks/sproutcore/frameworks/desktop/views/collection.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/desktop/views/scroll.js +10 -7
- data/lib/frameworks/sproutcore/frameworks/desktop/views/split.js +5 -4
- data/lib/frameworks/sproutcore/frameworks/foundation/mixins/content_display.js +14 -14
- data/lib/frameworks/sproutcore/frameworks/foundation/mixins/content_value_support.js +123 -98
- data/lib/frameworks/sproutcore/frameworks/foundation/tests/mixins/content_display.js +18 -6
- data/lib/frameworks/sproutcore/frameworks/foundation/tests/mixins/inline_text_field/api.js +9 -11
- data/lib/frameworks/sproutcore/frameworks/foundation/tests/views/container/transition_test.js +2 -2
- data/lib/frameworks/sproutcore/frameworks/foundation/views/container.js +15 -16
- data/lib/frameworks/sproutcore/frameworks/foundation/views/inline_text_field.js +11 -0
- data/lib/frameworks/sproutcore/frameworks/runtime/mixins/enumerable.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/runtime/system/binding.js +3 -3
- data/lib/frameworks/sproutcore/frameworks/runtime/tests/system/binding.js +170 -153
- data/lib/frameworks/sproutcore/frameworks/table/views/table.js +105 -101
- data/lib/frameworks/sproutcore/frameworks/table/views/table_head.js +0 -7
- data/lib/frameworks/sproutcore/frameworks/table/views/table_header.js +46 -56
- data/lib/frameworks/sproutcore/frameworks/table/views/table_row.js +0 -6
- data/lib/frameworks/sproutcore/frameworks/template_view/tests/views/template/collection.js +12 -4
- data/lib/frameworks/sproutcore/frameworks/template_view/views/bindable_span.js +3 -2
- data/lib/frameworks/sproutcore/frameworks/template_view/views/template_collection.js +11 -8
- data/lib/frameworks/sproutcore/tests/phantomjs_runner.phantomjs +0 -1
- metadata +3 -3
- data/lib/frameworks/sproutcore/frameworks/foundation/tests/mixins/inline_text_field/beginEditing.js +0 -235
@@ -4,149 +4,164 @@
|
|
4
4
|
// portions copyright ©2011 Apple Inc.
|
5
5
|
// License: Licensed under MIT license (see license.js)
|
6
6
|
// ==========================================================================
|
7
|
+
/*global equals, module, test */
|
7
8
|
|
8
9
|
/*
|
9
10
|
Tests SplitView Child logic. This covers properties which are interpreted
|
10
11
|
by the SplitChild mixin itself—not the properties used by the SplitView.
|
11
|
-
|
12
|
+
|
12
13
|
As such, we look at:
|
13
|
-
|
14
|
+
|
14
15
|
- layout
|
15
16
|
- positionOffset
|
16
17
|
- sizeOffset
|
17
18
|
- splitChildLayoutDidChange
|
18
19
|
- splitView calculation
|
19
20
|
- splitViewLayoutDirection property
|
20
|
-
|
21
|
+
|
21
22
|
All tests are run twice: once in horizontal, once in vertical.
|
22
23
|
*/
|
23
24
|
|
24
25
|
|
25
|
-
var splitView;
|
26
|
+
var pane, splitView;
|
26
27
|
|
27
28
|
function setupSuite(layoutDirection) {
|
28
|
-
module("SplitView - SplitChild (" + (layoutDirection === SC.LAYOUT_HORIZONTAL ? "HORIZONTAL" : "VERTICAL") + ")", {
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
width: layoutDirection === SC.LAYOUT_HORIZONTAL ? 500 : 300,
|
48
|
-
height: layoutDirection === SC.LAYOUT_HORIZONTAL ? 300 : 500
|
49
|
-
},
|
50
|
-
|
51
|
-
layoutDirection: layoutDirection,
|
52
|
-
|
53
|
-
splitDividerView: null // in most of these tests, we are not checking the behavior of split dividers
|
54
|
-
});
|
55
|
-
SC.RunLoop.end();
|
56
|
-
}
|
57
|
-
});
|
58
|
-
|
59
|
-
function verifyChildren(view) {
|
60
|
-
var pos = 0;
|
61
|
-
for (var i = 1; i < arguments.length; i++) {
|
62
|
-
var child = view.childViews[i - 1];
|
63
|
-
equals(child.get('position'), pos, "Correct position for view " + i);
|
64
|
-
equals(child.get('size'), arguments[i], "Correct size for view " + i);
|
65
|
-
|
66
|
-
var cpos = pos + child.get('positionOffset');
|
67
|
-
var csize = arguments[i] + child.get('sizeOffset');
|
68
|
-
var layout = child.get('layout');
|
69
|
-
|
70
|
-
// check layout, and consider offset
|
71
|
-
if (splitView.get('layoutDirection') === SC.LAYOUT_HORIZONTAL) {
|
72
|
-
equals(layout.left, cpos, "Correct left for view " + i);
|
73
|
-
equals(layout.width, csize, "Correct width for view " + i);
|
74
|
-
|
75
|
-
equals(layout.top, 0, "Top is 0 in LAYOUT_HORIZONTAL");
|
76
|
-
equals(layout.bottom, 0, "Bottom is 0 in LAYOUT_HORIZONTAL");
|
77
|
-
} else {
|
78
|
-
equals(layout.top, cpos, "Correct top for view " + i);
|
79
|
-
equals(layout.height, csize, "Correct height for view " + i);
|
29
|
+
module("SplitView - SplitChild (" + (layoutDirection === SC.LAYOUT_HORIZONTAL ? "HORIZONTAL" : "VERTICAL") + ")", {
|
30
|
+
|
31
|
+
setup: function () {
|
32
|
+
SC.run(function () {
|
33
|
+
splitView = SC.SplitView.create({
|
34
|
+
childViews: [ 'left', 'middle', 'right' ],
|
35
|
+
|
36
|
+
left: SC.View.extend(SC.SplitChild, { name: 'left', size: 100 }),
|
37
|
+
|
38
|
+
middle: SC.View.extend(SC.SplitChild, { name: 'middle', size: 300, positionOffset: -10, sizeOffset: 20 }),
|
39
|
+
|
40
|
+
right: SC.SplitView.extend(SC.SplitChild, {
|
41
|
+
name: 'right',
|
42
|
+
size: 100,
|
43
|
+
splitDividerView: null,
|
44
|
+
childViews: ['top', 'bottom'],
|
45
|
+
top: SC.View.extend(SC.SplitChild, { name: 'top', size: 100 }),
|
46
|
+
bottom: SC.View.extend(SC.SplitChild, { name: 'bottom', size: 400 })
|
47
|
+
}),
|
80
48
|
|
81
|
-
|
82
|
-
|
49
|
+
layout: {
|
50
|
+
left: 0,
|
51
|
+
top: 0,
|
52
|
+
width: layoutDirection === SC.LAYOUT_HORIZONTAL ? 500 : 300,
|
53
|
+
height: layoutDirection === SC.LAYOUT_HORIZONTAL ? 300 : 500
|
54
|
+
},
|
55
|
+
|
56
|
+
layoutDirection: layoutDirection,
|
57
|
+
|
58
|
+
splitDividerView: null // in most of these tests, we are not checking the behavior of split dividers
|
59
|
+
|
60
|
+
});
|
61
|
+
|
62
|
+
pane = SC.Pane.create({
|
63
|
+
childViews: [splitView]
|
64
|
+
});
|
65
|
+
pane.append();
|
66
|
+
});
|
67
|
+
},
|
68
|
+
|
69
|
+
teardown: function () {
|
70
|
+
pane.destroy();
|
71
|
+
pane = splitView = null;
|
83
72
|
}
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
73
|
+
});
|
74
|
+
|
75
|
+
function verifyChildren(view) {
|
76
|
+
var pos = 0;
|
77
|
+
|
78
|
+
for (var i = 1; i < arguments.length; i++) {
|
79
|
+
var child = view.childViews[i - 1];
|
80
|
+
|
81
|
+
equals(child.get('position'), pos, "Correct position for view " + i);
|
82
|
+
equals(child.get('size'), arguments[i], "Correct size for view " + i);
|
83
|
+
|
84
|
+
var cpos = pos + child.get('positionOffset');
|
85
|
+
var csize = arguments[i] + child.get('sizeOffset');
|
86
|
+
var layout = child.get('layout');
|
87
|
+
|
88
|
+
// check layout, and consider offset
|
89
|
+
if (splitView.get('layoutDirection') === SC.LAYOUT_HORIZONTAL) {
|
90
|
+
equals(layout.left, cpos, "Correct left for view " + i);
|
91
|
+
equals(layout.width, csize, "Correct width for view " + i);
|
88
92
|
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
equals(cv[1].get('layout').top, 90, "Middle child has proper (offsetted) position in layout");
|
102
|
-
equals(cv[1].get('layout').height, 320, "Middle child has proper (offsetted) size in layout");
|
93
|
+
equals(layout.top, 0, "Top is 0 in LAYOUT_HORIZONTAL");
|
94
|
+
equals(layout.bottom, 0, "Bottom is 0 in LAYOUT_HORIZONTAL");
|
95
|
+
} else {
|
96
|
+
equals(layout.top, cpos, "Correct top for view " + i);
|
97
|
+
equals(layout.height, csize, "Correct height for view " + i);
|
98
|
+
|
99
|
+
equals(layout.left, 0, "Left is 0 in LAYOUT_VERTICAL");
|
100
|
+
equals(layout.right, 0, "Right is 0 in LAYOUT_VERTICAL");
|
101
|
+
}
|
102
|
+
|
103
|
+
pos += arguments[i];
|
104
|
+
}
|
103
105
|
}
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
106
|
+
|
107
|
+
test("Layout gets applied correctly for child views.", function () {
|
108
|
+
verifyChildren(splitView, 100, 300, 100);
|
109
|
+
|
110
|
+
// double-check the position/sizeOffset
|
111
|
+
var cv = splitView.get('childViews');
|
112
|
+
equals(cv[1].get('positionOffset'), -10, "Middle child has proper position offset");
|
113
|
+
equals(cv[1].get('sizeOffset'), 20, "Middle child has proper size offset");
|
114
|
+
|
115
|
+
if (layoutDirection === SC.LAYOUT_HORIZONTAL) {
|
116
|
+
equals(cv[1].get('layout').left, 90, "Middle child has proper (offsetted) position in layout");
|
117
|
+
equals(cv[1].get('layout').width, 320, "Middle child has proper (offsetted) size in layout");
|
118
|
+
} else {
|
119
|
+
equals(cv[1].get('layout').top, 90, "Middle child has proper (offsetted) position in layout");
|
120
|
+
equals(cv[1].get('layout').height, 320, "Middle child has proper (offsetted) size in layout");
|
121
|
+
}
|
122
|
+
|
123
|
+
});
|
124
|
+
|
125
|
+
test("Check that layout adjusts after adjusting child view position", function () {
|
126
|
+
SC.RunLoop.begin();
|
127
|
+
splitView.adjustPositionForChild(splitView.childViews[1], 200);
|
128
|
+
SC.RunLoop.end();
|
129
|
+
|
130
|
+
verifyChildren(splitView, 200, 200, 100);
|
131
|
+
});
|
132
|
+
|
133
|
+
test("Check that changing orientation changes layouts.", function () {
|
134
|
+
equals(splitView.get('layoutDirection'), layoutDirection);
|
135
|
+
|
136
|
+
var childLayoutDirection = splitView.childViews[0].get('splitViewLayoutDirection');
|
137
|
+
equals(childLayoutDirection, layoutDirection, "Child has correct layout direction before orientation change.");
|
138
|
+
|
139
|
+
var newLayoutDirection = layoutDirection === SC.LAYOUT_HORIZONTAL ? SC.LAYOUT_VERTICAL : SC.LAYOUT_HORIZONTAL;
|
140
|
+
|
141
|
+
SC.run(function () {
|
142
|
+
splitView.set('layoutDirection', newLayoutDirection);
|
143
|
+
});
|
144
|
+
|
145
|
+
equals(splitView.get('layoutDirection'), newLayoutDirection);
|
146
|
+
|
147
|
+
childLayoutDirection = splitView.childViews[0].get('splitViewLayoutDirection');
|
148
|
+
equals(childLayoutDirection, newLayoutDirection, "Child has correct layout direction after orientation change.");
|
149
|
+
|
150
|
+
// height is different, so layout should have changed to 100, 100, 100
|
151
|
+
verifyChildren(splitView, 100, 100, 100);
|
152
|
+
});
|
153
|
+
|
154
|
+
test("Check that the `splitView` computed is correct on SC.SplitChilds", function () {
|
155
|
+
equals(splitView, splitView.childViews[0].get('splitView'));
|
156
|
+
equals(splitView, splitView.childViews[1].get('splitView'));
|
157
|
+
equals(splitView, splitView.childViews[2].get('splitView'),
|
158
|
+
'the splitView should the closest parent splitView');
|
159
|
+
|
160
|
+
var nestedSplitView = splitView.childViews[2];
|
161
|
+
|
162
|
+
equals(nestedSplitView, nestedSplitView.childViews[0].get('splitView'));
|
163
|
+
equals(nestedSplitView, nestedSplitView.childViews[1].get('splitView'));
|
164
|
+
});
|
150
165
|
|
151
166
|
}
|
152
167
|
|
@@ -825,7 +825,7 @@ SC.CollectionView = SC.View.extend(SC.CollectionViewDelegate, SC.CollectionConte
|
|
825
825
|
contentLengthDidChange: function () {
|
826
826
|
var content = this.get('content');
|
827
827
|
this.set('length', content ? content.get('length') : 0);
|
828
|
-
this.invokeOnce(
|
828
|
+
this.invokeOnce(this.adjustLayout);
|
829
829
|
},
|
830
830
|
|
831
831
|
/** @private
|
@@ -1509,9 +1509,9 @@ SC.ScrollView = SC.View.extend({
|
|
1509
1509
|
y: touch.scrollVelocity.y * 10
|
1510
1510
|
};
|
1511
1511
|
|
1512
|
-
|
1513
|
-
|
1514
|
-
|
1512
|
+
window.requestAnimationFrame(function () {
|
1513
|
+
self.decelerateAnimation();
|
1514
|
+
});
|
1515
1515
|
},
|
1516
1516
|
|
1517
1517
|
/** @private
|
@@ -1714,9 +1714,9 @@ SC.ScrollView = SC.View.extend({
|
|
1714
1714
|
// (so we may calculate elapsed time) and the timeout we are creating, so we may cancel it in future.
|
1715
1715
|
var self = this;
|
1716
1716
|
touch.lastEventTime = Date.now();
|
1717
|
-
|
1718
|
-
|
1719
|
-
|
1717
|
+
window.requestAnimationFrame(function () {
|
1718
|
+
SC.run(self.decelerateAnimation(), self);
|
1719
|
+
});
|
1720
1720
|
},
|
1721
1721
|
|
1722
1722
|
// ..........................................................
|
@@ -1791,6 +1791,9 @@ SC.ScrollView = SC.View.extend({
|
|
1791
1791
|
}
|
1792
1792
|
|
1793
1793
|
if (this.get('isVisibleInWindow')) this._scsv_registerAutoscroll();
|
1794
|
+
|
1795
|
+
// Initialize cache values.
|
1796
|
+
this._scroll_contentWidth = this._scroll_contentHeight = null;
|
1794
1797
|
},
|
1795
1798
|
|
1796
1799
|
/** @private
|
@@ -1862,7 +1865,7 @@ SC.ScrollView = SC.View.extend({
|
|
1862
1865
|
size of the contentView changes. We don't care about the origin since
|
1863
1866
|
that is tracked separately from the offset values.
|
1864
1867
|
*/
|
1865
|
-
contentViewFrameDidChange: function(force) {
|
1868
|
+
contentViewFrameDidChange: function (force) {
|
1866
1869
|
var view = this.get('contentView'),
|
1867
1870
|
f = (view) ? view.get('frame') : null,
|
1868
1871
|
scale = this._scale,
|
@@ -43,7 +43,7 @@ SC.RESIZE_AUTOMATIC = 'sc-automatic-resize';
|
|
43
43
|
You can set up a split view like any other view in SproutCore:
|
44
44
|
|
45
45
|
SplitView.design({
|
46
|
-
childViews: 'leftPanel rightPanel'
|
46
|
+
childViews: ['leftPanel', 'rightPanel'],
|
47
47
|
|
48
48
|
leftPanel: SC.View.design(SC.SplitChild, {
|
49
49
|
minimumSize: 200
|
@@ -178,10 +178,11 @@ SC.SplitView = SC.View.extend({
|
|
178
178
|
}
|
179
179
|
}.property('frame', 'layoutDirection').cacheable(),
|
180
180
|
|
181
|
-
viewDidResize: function(
|
181
|
+
viewDidResize: function () {
|
182
182
|
this.scheduleTiling();
|
183
|
-
|
184
|
-
|
183
|
+
|
184
|
+
sc_super();
|
185
|
+
},
|
185
186
|
|
186
187
|
layoutDirectionDidChange: function() {
|
187
188
|
this.scheduleTiling();
|
@@ -10,33 +10,33 @@
|
|
10
10
|
|
11
11
|
The SC.ContentDisplay mixin makes it easy to automatically update your view
|
12
12
|
display whenever relevant properties on a content object change. To use
|
13
|
-
this mixin, include it in your view and then add the names of the
|
14
|
-
properties on the content object you want to trigger a displayDidChange()
|
15
|
-
method on your view. Your updateDisplay() method will then be called at the
|
13
|
+
this mixin, include it in your view and then add the names of the
|
14
|
+
properties on the content object you want to trigger a displayDidChange()
|
15
|
+
method on your view. Your updateDisplay() method will then be called at the
|
16
16
|
end of the run loop.
|
17
|
-
|
17
|
+
|
18
18
|
## Example
|
19
|
-
|
20
|
-
MyApp.MyViewClass = SC.View.extend(SC.ContentDisplay, {
|
19
|
+
|
20
|
+
MyApp.MyViewClass = SC.View.extend(SC.ContentDisplay, {
|
21
21
|
contentDisplayProperties: 'title isEnabled hasChildren'.w(),
|
22
22
|
...
|
23
23
|
});
|
24
|
-
|
24
|
+
|
25
25
|
@since SproutCore 1.0
|
26
26
|
*/
|
27
27
|
SC.ContentDisplay = {
|
28
|
-
|
28
|
+
|
29
29
|
/** @private */
|
30
30
|
concatenatedProperties: 'contentDisplayProperties',
|
31
31
|
|
32
32
|
/** @private */
|
33
33
|
displayProperties: ['content'],
|
34
|
-
|
35
|
-
/**
|
34
|
+
|
35
|
+
/**
|
36
36
|
Add an array with the names of any property on the content object that
|
37
37
|
should trigger an update of the display for your view. Changes to the
|
38
38
|
content object will only invoke your display method once per runloop.
|
39
|
-
|
39
|
+
|
40
40
|
@type Array
|
41
41
|
@default []
|
42
42
|
*/
|
@@ -97,8 +97,8 @@ SC.ContentDisplay = {
|
|
97
97
|
if (content) this._display_beginObservingContent(content);
|
98
98
|
|
99
99
|
this.displayDidChange();
|
100
|
-
}.observes('content'
|
101
|
-
|
100
|
+
}.observes('content'),
|
101
|
+
|
102
102
|
/** @private Invoked when properties on the content object change. */
|
103
103
|
_display_contentPropertyDidChange: function(target, key, value, propertyRevision) {
|
104
104
|
if (key === '*') {
|
@@ -109,5 +109,5 @@ SC.ContentDisplay = {
|
|
109
109
|
if (ary && ary.indexOf(key)>=0) this.displayDidChange();
|
110
110
|
}
|
111
111
|
}
|
112
|
-
|
112
|
+
|
113
113
|
} ;
|