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
@@ -7,53 +7,43 @@
|
|
7
7
|
|
8
8
|
sc_require('views/table');
|
9
9
|
|
10
|
-
|
11
|
-
The views that make up the column header cells in a typical `SC.TableView`.
|
12
|
-
|
13
|
-
In addition, this view is in charge of rendering the _entire_ table column
|
14
|
-
(both header and body) when the table is in the "drag-reorder" state. This
|
15
|
-
is the state that occurs when the user clicks and holds on a table header,
|
16
|
-
then drags that header horizontally.
|
17
|
-
|
18
|
-
@extends SC.View
|
19
|
-
@since SproutCore 1.1
|
20
|
-
*/
|
10
|
+
|
21
11
|
SC.TableHeaderView = SC.View.extend({
|
22
|
-
|
12
|
+
|
23
13
|
classNames: ['sc-table-header'],
|
24
|
-
|
14
|
+
|
25
15
|
displayProperties: ['sortState', 'isInDragMode'],
|
26
|
-
|
16
|
+
|
27
17
|
acceptsFirstResponder: YES,
|
28
|
-
|
18
|
+
|
29
19
|
isInDragMode: NO,
|
30
|
-
|
20
|
+
|
31
21
|
hasHorizontalScroller: NO,
|
32
22
|
hasVerticalScroller: NO,
|
33
|
-
|
23
|
+
|
34
24
|
childViews: ['dragModeView'],
|
35
|
-
|
36
|
-
|
25
|
+
|
26
|
+
|
37
27
|
/**
|
38
28
|
The view that is visible when the column is in drag mode.
|
39
29
|
*/
|
40
30
|
dragModeView: SC.ListView.extend({
|
41
31
|
isVisible: NO,
|
42
|
-
|
32
|
+
|
43
33
|
layout: { left: 0, right: 0, bottom: 0 },
|
44
|
-
|
34
|
+
|
45
35
|
init: function() {
|
46
36
|
sc_super();
|
47
37
|
|
48
38
|
var tableHeaderView = this.get('parentView');
|
49
|
-
|
39
|
+
|
50
40
|
if (tableHeaderView) {
|
51
41
|
tableHeaderView.addObserver('isInDragMode', this,
|
52
42
|
'_scthv_dragModeDidChange');
|
53
43
|
}
|
54
|
-
|
44
|
+
|
55
45
|
},
|
56
|
-
|
46
|
+
|
57
47
|
_scthv_dragModeDidChange: function() {
|
58
48
|
// var isInDragMode = this.get('tableHeaderView').get('isInDragMode');
|
59
49
|
// this.set('isVisible', isInDragMode);
|
@@ -64,7 +54,7 @@ SC.TableHeaderView = SC.View.extend({
|
|
64
54
|
The SC.TableColumn object this header cell is bound to.
|
65
55
|
*/
|
66
56
|
column: null,
|
67
|
-
|
57
|
+
|
68
58
|
render: function(context, firstTime) {
|
69
59
|
var column = this.get('column'), icon = column.get('icon'), html;
|
70
60
|
var span = context.begin('span');
|
@@ -76,7 +66,7 @@ SC.TableHeaderView = SC.View.extend({
|
|
76
66
|
}
|
77
67
|
span.end();
|
78
68
|
},
|
79
|
-
|
69
|
+
|
80
70
|
// ========================================================
|
81
71
|
// = For the column we look after, set up some observers. =
|
82
72
|
// ========================================================
|
@@ -89,76 +79,76 @@ SC.TableHeaderView = SC.View.extend({
|
|
89
79
|
column.addObserver('minWidth', this, '_scthv_layoutDidChange');
|
90
80
|
column.addObserver('sortState', this, '_scthv_sortStateDidChange');
|
91
81
|
column.addObserver('tableContent', this, '_scthv_tableContentDidChange');
|
92
|
-
|
82
|
+
|
93
83
|
// var tableContent = column.get('tableContent');
|
94
84
|
// var columnContent = this._scthv_columnContentFromTableContent(tableContent);
|
95
85
|
// this.set('content', columnContent);
|
96
86
|
},
|
97
|
-
|
87
|
+
|
98
88
|
/**
|
99
89
|
The sortState of the header view's column.
|
100
90
|
*/
|
101
91
|
sortState: function() {
|
102
92
|
return this.get('column').get('sortState');
|
103
93
|
}.property(),
|
104
|
-
|
94
|
+
|
105
95
|
mouseDown: function(evt) {
|
106
|
-
var tableView = this.get('tableView');
|
96
|
+
var tableView = this.get('tableView');
|
107
97
|
return tableView ? tableView.mouseDownInTableHeaderView(evt, this) :
|
108
98
|
sc_super();
|
109
99
|
},
|
110
|
-
|
100
|
+
|
111
101
|
mouseUp: function(evt) {
|
112
102
|
var tableView = this.get('tableView');
|
113
103
|
return tableView ? tableView.mouseUpInTableHeaderView(evt, this) :
|
114
104
|
sc_super();
|
115
105
|
},
|
116
|
-
|
106
|
+
|
117
107
|
mouseDragged: function(evt) {
|
118
108
|
var tableView = this.get('tableView');
|
119
109
|
return tableView ? tableView.mouseDraggedInTableHeaderView(evt, this) :
|
120
110
|
sc_super();
|
121
111
|
},
|
122
|
-
|
112
|
+
|
123
113
|
_scthv_dragViewForHeader: function() {
|
124
114
|
var dragLayer = this.get('layer').cloneNode(true);
|
125
115
|
var view = SC.View.create({ layer: dragLayer, parentView: this });
|
126
|
-
|
116
|
+
|
127
117
|
// cleanup weird stuff that might make the drag look out of place
|
128
118
|
SC.$(dragLayer).css('backgroundColor', 'transparent')
|
129
119
|
.css('border', 'none')
|
130
|
-
.css('top', 0).css('left', 0);
|
131
|
-
|
120
|
+
.css('top', 0).css('left', 0);
|
121
|
+
|
132
122
|
return view;
|
133
123
|
},
|
134
|
-
|
124
|
+
|
135
125
|
_scthv_enterDragMode: function() {
|
136
126
|
this.set('isInDragMode', YES);
|
137
127
|
},
|
138
|
-
|
128
|
+
|
139
129
|
_scthv_exitDragMode: function() {
|
140
130
|
this.set('isInDragMode', NO);
|
141
131
|
},
|
142
|
-
|
143
|
-
// _scthv_hideViewInDragMode: function() {
|
132
|
+
|
133
|
+
// _scthv_hideViewInDragMode: function() {
|
144
134
|
// var shouldBeVisible = !this.get('isInDragMode'), layer = this.get('layer');
|
145
135
|
// console.log('should be visible: %@'.fmt(!this.get('isInDragMode')));
|
146
136
|
// SC.RunLoop.begin();
|
147
137
|
// SC.$(layer).css('display', shouldBeVisible ? 'block' : 'none');
|
148
138
|
// SC.RunLoop.end();
|
149
139
|
// }.observes('isInDragMode'),
|
150
|
-
|
140
|
+
|
151
141
|
// _scthv_setupDragMode: function() {
|
152
142
|
// var isInDragMode = this.get('isInDragMode');
|
153
143
|
// if (isInDragMode) {
|
154
|
-
// });
|
144
|
+
// });
|
155
145
|
// } else {
|
156
146
|
// //
|
157
147
|
// }
|
158
|
-
//
|
159
|
-
//
|
148
|
+
//
|
149
|
+
//
|
160
150
|
// }.observes('isInDragMode'),
|
161
|
-
|
151
|
+
|
162
152
|
_scthv_dragModeViewDidChange: function() {
|
163
153
|
var dragModeView = this.get('dragModeView');
|
164
154
|
if (dragModeView && dragModeView.set) {
|
@@ -166,45 +156,45 @@ SC.TableHeaderView = SC.View.extend({
|
|
166
156
|
dragModeView.set('tableView', this.get('tableView'));
|
167
157
|
}
|
168
158
|
}.observes('dragModeView'),
|
169
|
-
|
159
|
+
|
170
160
|
_scthv_layoutDidChange: function(sender, key, value, rev) {
|
171
161
|
var pv = this.get('parentView');
|
172
162
|
pv.invokeOnce(pv.layoutChildViews);
|
173
|
-
|
163
|
+
|
174
164
|
// Tell the container view how tall the header is so that it can adjust
|
175
165
|
// itself accordingly.
|
176
|
-
var layout = this.get('layout');
|
166
|
+
var layout = this.get('layout');
|
177
167
|
//this.get('dragModeView').adjust('top', layout.height);
|
178
168
|
},
|
179
|
-
|
169
|
+
|
180
170
|
// When our column's tableContent property changes, we need to go back and get our column content
|
181
171
|
_scthv_tableContentDidChange: function() {
|
182
|
-
var tableContent = this.get('column').get('tableContent');
|
172
|
+
var tableContent = this.get('column').get('tableContent');
|
183
173
|
var columnContent = this.get('parentView')._scthv_columnContentFromTableContent(tableContent, this.get('columnIndex'));
|
184
174
|
this.set('content', columnContent);
|
185
175
|
},
|
186
|
-
|
176
|
+
|
187
177
|
_scthv_sortStateDidChange: function() {
|
188
178
|
SC.RunLoop.begin();
|
189
179
|
var sortState = this.get('column').get('sortState');
|
190
180
|
var classNames = this.get('classNames');
|
191
|
-
|
181
|
+
|
192
182
|
classNames.removeObject('sc-table-header-sort-asc');
|
193
183
|
classNames.removeObject('sc-table-header-sort-desc');
|
194
184
|
classNames.removeObject('sc-table-header-sort-active');
|
195
|
-
|
185
|
+
|
196
186
|
if (sortState !== null) {
|
197
187
|
classNames.push('sc-table-header-sort-active');
|
198
188
|
}
|
199
|
-
|
189
|
+
|
200
190
|
if (sortState === SC.SORT_ASCENDING) {
|
201
191
|
classNames.push('sc-table-header-sort-asc');
|
202
192
|
}
|
203
|
-
|
193
|
+
|
204
194
|
if (sortState === SC.SORT_DESCENDING) {
|
205
195
|
classNames.push('sc-table-header-sort-desc');
|
206
196
|
}
|
207
|
-
|
197
|
+
|
208
198
|
// TODO: Figure out why it's not enough to simply call
|
209
199
|
// `displayDidChange` here.
|
210
200
|
this.displayDidChange();
|
@@ -5,13 +5,7 @@
|
|
5
5
|
// License: Licensed under MIT license (see license.js)
|
6
6
|
// ==========================================================================
|
7
7
|
|
8
|
-
/** @class
|
9
8
|
|
10
|
-
The default example view for a table row. Belongs to a SC.TableView.
|
11
|
-
|
12
|
-
@extends SC.View
|
13
|
-
@since SproutCore 1.1
|
14
|
-
*/
|
15
9
|
|
16
10
|
SC.TableRowView = SC.View.extend({
|
17
11
|
/** @scope SC.TableRowView.prototype */
|
@@ -165,7 +165,9 @@ test("should give its item views the classBinding specified by itemClassBinding"
|
|
165
165
|
template: SC.Handlebars.compile('{{#collection "TemplateTests.itemClassBindingTestCollectionView" itemClassBinding="content.isBaz"}}foo{{/collection}}')
|
166
166
|
});
|
167
167
|
|
168
|
-
|
168
|
+
SC.run(function () {
|
169
|
+
view.createLayer();
|
170
|
+
});
|
169
171
|
equals(view.$('ul li.is-baz').length, 2, "adds class on initial rendering");
|
170
172
|
|
171
173
|
SC.run(function() {
|
@@ -188,7 +190,9 @@ test("should pass item* property when created with a block", function() {
|
|
188
190
|
var view = SC.TemplateView.create({
|
189
191
|
template: SC.Handlebars.compile('{{#collection TemplateTests.CollectionTestView itemFoo="bar"}}baz{{/collection}}')
|
190
192
|
});
|
191
|
-
|
193
|
+
SC.run(function () {
|
194
|
+
view.createLayer();
|
195
|
+
});
|
192
196
|
|
193
197
|
var childViews = view.getPath('childViews.firstObject.childViews');
|
194
198
|
childViews.forEach(function(childView, index) {
|
@@ -203,7 +207,9 @@ test("should pass item* property when created without a block", function() {
|
|
203
207
|
var view = SC.TemplateView.create({
|
204
208
|
template: SC.Handlebars.compile('{{collection TemplateTests.CollectionTestView itemFoo="bar"}}')
|
205
209
|
});
|
206
|
-
|
210
|
+
SC.run(function () {
|
211
|
+
view.createLayer();
|
212
|
+
});
|
207
213
|
|
208
214
|
var childViews = view.getPath('childViews.firstObject.childViews');
|
209
215
|
childViews.forEach(function(childView, index) {
|
@@ -222,7 +228,9 @@ test("should work inside a bound {{#if}}", function() {
|
|
222
228
|
shouldDisplay: true
|
223
229
|
});
|
224
230
|
|
225
|
-
|
231
|
+
SC.run(function () {
|
232
|
+
view.createLayer();
|
233
|
+
});
|
226
234
|
equals(view.$('ul li').length, 3, "renders collection when conditional is true");
|
227
235
|
|
228
236
|
SC.run(function() { view.set('shouldDisplay', NO); });
|
@@ -162,8 +162,8 @@ SC._BindableSpan = SC.TemplateView.extend(
|
|
162
162
|
len = childViews.get('length');
|
163
163
|
for (idx = len-1; idx >= 0; idx--){
|
164
164
|
childView = childViews[idx];
|
165
|
-
childView.$().remove();
|
166
|
-
childView.removeFromParent();
|
165
|
+
// childView.$().remove();
|
166
|
+
// childView.removeFromParent();
|
167
167
|
childView.destroy();
|
168
168
|
}
|
169
169
|
|
@@ -175,6 +175,7 @@ SC._BindableSpan = SC.TemplateView.extend(
|
|
175
175
|
this.$().replaceWith(elem);
|
176
176
|
this.set('layer', elem);
|
177
177
|
this._rendered();
|
178
|
+
this._callOnChildViews('_parentDidRender');
|
178
179
|
}
|
179
180
|
});
|
180
181
|
|
@@ -46,7 +46,7 @@ SC.TemplateCollectionView = SC.TemplateView.extend(
|
|
46
46
|
*/
|
47
47
|
init: function() {
|
48
48
|
var templateCollectionView = sc_super();
|
49
|
-
|
49
|
+
this._sctcv_contentDidChange();
|
50
50
|
return templateCollectionView;
|
51
51
|
},
|
52
52
|
|
@@ -173,6 +173,7 @@ SC.TemplateCollectionView = SC.TemplateView.extend(
|
|
173
173
|
needed.
|
174
174
|
*/
|
175
175
|
_sctcv_contentDidChange: function() {
|
176
|
+
|
176
177
|
var oldContent = this._content, oldLen = 0;
|
177
178
|
var content = this.get('content'), newLen = 0;
|
178
179
|
|
@@ -249,7 +250,7 @@ SC.TemplateCollectionView = SC.TemplateView.extend(
|
|
249
250
|
// each item.
|
250
251
|
itemOptions = this.get('itemViewOptions') || {};
|
251
252
|
|
252
|
-
|
253
|
+
insertAtElement = elem.find('li')[start-1] || null;
|
253
254
|
len = addedObjects.get('length');
|
254
255
|
|
255
256
|
// TODO: This logic is duplicated from the view helper. Refactor
|
@@ -284,8 +285,13 @@ SC.TemplateCollectionView = SC.TemplateView.extend(
|
|
284
285
|
childView.set('context', childView.get(contextProperty));
|
285
286
|
}
|
286
287
|
|
287
|
-
|
288
|
-
|
288
|
+
itemElem = childView.createLayer().$();
|
289
|
+
if (!insertAtElement) {
|
290
|
+
elem.append(itemElem);
|
291
|
+
} else {
|
292
|
+
itemElem.insertAfter(insertAtElement);
|
293
|
+
}
|
294
|
+
insertAtElement = itemElem;
|
289
295
|
|
290
296
|
addedViews.push(childView);
|
291
297
|
}
|
@@ -300,10 +306,7 @@ SC.TemplateCollectionView = SC.TemplateView.extend(
|
|
300
306
|
content: this
|
301
307
|
}));
|
302
308
|
this.set('emptyView', childView);
|
303
|
-
|
304
|
-
// Have to create child views manually.
|
305
|
-
childView.createLayer()._doAttach(elem[0]);
|
306
|
-
|
309
|
+
childView.createLayer().$().appendTo(elem);
|
307
310
|
this.childViews = [childView];
|
308
311
|
}
|
309
312
|
|
@@ -171,7 +171,6 @@ var urls=[
|
|
171
171
|
{url:'sproutcore/foundation/en/current/tests/mixins/validatable/ui.html'},
|
172
172
|
{url:'sproutcore/foundation/en/current/tests/mixins/content_value_support/content.html'},
|
173
173
|
{url:'sproutcore/foundation/en/current/tests/mixins/inline_text_field/api.html'},
|
174
|
-
{url:'sproutcore/foundation/en/current/tests/mixins/inline_text_field/beginEditing.html'},
|
175
174
|
{url:'sproutcore/foundation/en/current/tests/mixins/content_display.html'},
|
176
175
|
{url:'sproutcore/foundation/en/current/tests/controllers/tree/selection_support.html'},
|
177
176
|
{url:'sproutcore/foundation/en/current/tests/controllers/tree/outline_case.html'},
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sproutcore
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.10.0.rc.
|
4
|
+
version: 1.10.0.rc.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Strobe, Inc., Apple Inc. and contributors
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-09-
|
11
|
+
date: 2013-09-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rack
|
@@ -1275,6 +1275,7 @@ files:
|
|
1275
1275
|
- lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/isVisibleInWindow.js
|
1276
1276
|
- lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/keyboard.js
|
1277
1277
|
- lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/layer.js
|
1278
|
+
- lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/layout.js
|
1278
1279
|
- lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/layoutChildViews.js
|
1279
1280
|
- lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/layoutDidChange.js
|
1280
1281
|
- lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/layoutStyle.js
|
@@ -1858,7 +1859,6 @@ files:
|
|
1858
1859
|
- lib/frameworks/sproutcore/frameworks/foundation/tests/mixins/inline_editor/commitEditing.js
|
1859
1860
|
- lib/frameworks/sproutcore/frameworks/foundation/tests/mixins/inline_editor/discardEditing.js
|
1860
1861
|
- lib/frameworks/sproutcore/frameworks/foundation/tests/mixins/inline_text_field/api.js
|
1861
|
-
- lib/frameworks/sproutcore/frameworks/foundation/tests/mixins/inline_text_field/beginEditing.js
|
1862
1862
|
- lib/frameworks/sproutcore/frameworks/foundation/tests/mixins/staticLayout.js
|
1863
1863
|
- lib/frameworks/sproutcore/frameworks/foundation/tests/mixins/validatable/ui.js
|
1864
1864
|
- lib/frameworks/sproutcore/frameworks/foundation/tests/private/tree_item_observer/flat_case.js
|
data/lib/frameworks/sproutcore/frameworks/foundation/tests/mixins/inline_text_field/beginEditing.js
DELETED
@@ -1,235 +0,0 @@
|
|
1
|
-
// ==========================================================================
|
2
|
-
// Project: SproutCore - JavaScript Application Framework
|
3
|
-
// Copyright: ©2006-2011 Strobe Inc. and contributors.
|
4
|
-
// portions copyright @2011 Apple Inc.
|
5
|
-
// License: Licensed under MIT license (see license.js)
|
6
|
-
// ==========================================================================
|
7
|
-
/*global module test htmlbody ok equals same stop start Q$ */
|
8
|
-
|
9
|
-
var pane, optionsForLabel1, optionsForLabel2, delegate, optionsForLabelFromView;
|
10
|
-
|
11
|
-
pane = SC.ControlTestPane.design().add("label1", SC.LabelView, {
|
12
|
-
value: 'Some Text',
|
13
|
-
notifiedWillBegin: NO,
|
14
|
-
notifiedDidBegin: NO,
|
15
|
-
|
16
|
-
inlineEditorShouldBeginEditing: function(inlineEditor) {
|
17
|
-
return YES;
|
18
|
-
},
|
19
|
-
|
20
|
-
inlineEditorWillBeginEditing: function(inlineEditor) {
|
21
|
-
this.set('notifiedWillBegin', YES);
|
22
|
-
|
23
|
-
// The inline editor is the last view appended to the parent
|
24
|
-
var parentView = this.get('parentView'),
|
25
|
-
length = parentView.childViews.length,
|
26
|
-
editor = parentView.childViews[length - 1];
|
27
|
-
|
28
|
-
ok(!editor.get('isFirstResponder'), "should not be first responder yet");
|
29
|
-
|
30
|
-
sc_super();
|
31
|
-
},
|
32
|
-
|
33
|
-
inlineEditorDidBeginEditing: function(inlineEditor) {
|
34
|
-
this.set('notifiedDidBegin', YES);
|
35
|
-
|
36
|
-
// The inline editor is the last view appended to the parent
|
37
|
-
var parentView = this.get('parentView'),
|
38
|
-
length = parentView.childViews.length,
|
39
|
-
editor = parentView.childViews[length - 1];
|
40
|
-
|
41
|
-
ok(editor.get('isFirstResponder'), "should be first responder now");
|
42
|
-
|
43
|
-
sc_super();
|
44
|
-
}
|
45
|
-
}).add("label2", SC.LabelView, {
|
46
|
-
value: 'Can\'t Touch This',
|
47
|
-
|
48
|
-
inlineEditorShouldBeginEditing: function(inlineEditor) {
|
49
|
-
return NO;
|
50
|
-
}
|
51
|
-
});
|
52
|
-
|
53
|
-
pane.resetView = function(view) {
|
54
|
-
view.set('notifiedWillBegin', NO);
|
55
|
-
view.set('notifiedDidBegin', NO);
|
56
|
-
};
|
57
|
-
|
58
|
-
|
59
|
-
optionsForLabelFromView = function(view) {
|
60
|
-
var el = view.$(),
|
61
|
-
f = SC.offset(el[0]),
|
62
|
-
frameTemp = view.convertFrameFromView(view.get('frame'), null);
|
63
|
-
|
64
|
-
f.width = frameTemp.width;
|
65
|
-
f.height = frameTemp.height;
|
66
|
-
|
67
|
-
var optionsForLabel = {
|
68
|
-
frame: f,
|
69
|
-
delegate: view,
|
70
|
-
exampleElement: view.$(),
|
71
|
-
value: view.get('value'),
|
72
|
-
multiline: view.get('isInlineEditorMultiline'),
|
73
|
-
validator: view.get('validator'),
|
74
|
-
exampleInlineTextFieldView: view.get('exampleInlineTextFieldView')
|
75
|
-
};
|
76
|
-
|
77
|
-
return optionsForLabel;
|
78
|
-
};
|
79
|
-
|
80
|
-
|
81
|
-
/**
|
82
|
-
|
83
|
-
*/
|
84
|
-
module("Test the beginEditing() function of SC.InlineTextFieldView", {
|
85
|
-
setup: function() {
|
86
|
-
|
87
|
-
pane.standardSetup().setup();
|
88
|
-
|
89
|
-
var view1 = pane.view('label1'),
|
90
|
-
view2 = pane.view("label2");
|
91
|
-
|
92
|
-
// Reset view1 delegate functions
|
93
|
-
pane.resetView(view1);
|
94
|
-
|
95
|
-
optionsForLabel1 = optionsForLabelFromView(view1);
|
96
|
-
optionsForLabel2 = optionsForLabelFromView(view2);
|
97
|
-
},
|
98
|
-
|
99
|
-
teardown: function() {
|
100
|
-
optionsForLabel1 = optionsForLabel2 = null;
|
101
|
-
SC.InlineTextFieldView.discardEditing();
|
102
|
-
pane.standardSetup().teardown();
|
103
|
-
|
104
|
-
}
|
105
|
-
});
|
106
|
-
|
107
|
-
test("fails when required options are missing",
|
108
|
-
function() {
|
109
|
-
try {
|
110
|
-
optionsForLabel1["frame"] = null;
|
111
|
-
ok(SC.InlineTextFieldView.beginEditing(optionsForLabel1) === NO, "should fail if frame missing");
|
112
|
-
} catch(e1) {
|
113
|
-
ok(YES, "should fail if frame missing: %@".fmt(e1));
|
114
|
-
}
|
115
|
-
|
116
|
-
try {
|
117
|
-
optionsForLabel1["delegate"] = null;
|
118
|
-
ok(SC.InlineTextFieldView.beginEditing(optionsForLabel1) === NO, "should fail if delegate missing");
|
119
|
-
} catch(e2) {
|
120
|
-
ok(YES, "should fail if delegate missing: %@".fmt(e2));
|
121
|
-
}
|
122
|
-
|
123
|
-
try {
|
124
|
-
optionsForLabel1["exampleElement"] = null;
|
125
|
-
ok(SC.InlineTextFieldView.beginEditing(optionsForLabel1) === NO, "should fail if exampleElement missing");
|
126
|
-
} catch(e3) {
|
127
|
-
ok(YES, "should fail if exampleElement missing: %@".fmt(e3));
|
128
|
-
}
|
129
|
-
});
|
130
|
-
|
131
|
-
test("value of inline editor same as label",
|
132
|
-
function() {
|
133
|
-
|
134
|
-
SC.RunLoop.begin();
|
135
|
-
SC.InlineTextFieldView.beginEditing(optionsForLabel1);
|
136
|
-
SC.RunLoop.end();
|
137
|
-
|
138
|
-
// The inline editor is the last view appended to the parent
|
139
|
-
var view = pane.view('label1'),
|
140
|
-
parentView = view.get('parentView'),
|
141
|
-
length = parentView.childViews.length,
|
142
|
-
editor = parentView.childViews[length - 1];
|
143
|
-
|
144
|
-
equals(editor.get('value'), view.get('value'), "editor should have the same initial value as its label");
|
145
|
-
});
|
146
|
-
|
147
|
-
test("use input element when options.multiline is set to NO",
|
148
|
-
function() {
|
149
|
-
SC.RunLoop.begin();
|
150
|
-
SC.InlineTextFieldView.beginEditing(optionsForLabel1);
|
151
|
-
SC.RunLoop.end();
|
152
|
-
|
153
|
-
// The inline editor is the last view appended to the parent
|
154
|
-
var view = pane.view('label1'),
|
155
|
-
parentView = view.get('parentView'),
|
156
|
-
length = parentView.childViews.length,
|
157
|
-
editor = parentView.childViews[length - 1];
|
158
|
-
|
159
|
-
ok(editor.$("input").length > 0, "should be using an input element");
|
160
|
-
});
|
161
|
-
|
162
|
-
test("use textarea element when options.multiline is set to YES",
|
163
|
-
function() {
|
164
|
-
optionsForLabel1["multiline"] = YES;
|
165
|
-
|
166
|
-
SC.RunLoop.begin();
|
167
|
-
SC.InlineTextFieldView.beginEditing(optionsForLabel1);
|
168
|
-
SC.RunLoop.end();
|
169
|
-
|
170
|
-
// The inline editor is the last view appended to the parent
|
171
|
-
var view = pane.view('label1'),
|
172
|
-
parentView = view.get('parentView'),
|
173
|
-
length = parentView.childViews.length,
|
174
|
-
editor = parentView.childViews[length - 1];
|
175
|
-
|
176
|
-
ok(editor.$("textarea").length > 0, "should be using a textarea element");
|
177
|
-
});
|
178
|
-
/* TODO: move these to inlineEditorDelegate tests
|
179
|
-
test("inline editor aborts if delegate returns NO to inlineEditorShouldBeginEditing()",
|
180
|
-
function() {
|
181
|
-
SC.InlineTextFieldView.beginEditing(optionsForLabel2);
|
182
|
-
|
183
|
-
// The inline editor is the last view appended to the pane
|
184
|
-
var length = pane._pane.childViews.length,
|
185
|
-
editor = pane._pane.childViews[length - 1];
|
186
|
-
|
187
|
-
ok(!editor.get('isEditing'), "editor should have isEditing set to NO");
|
188
|
-
});
|
189
|
-
|
190
|
-
test("inline editor notifies delegate with inlineEditorWillBeginEditing() before becoming responder",
|
191
|
-
function() {
|
192
|
-
var view1 = pane.view('label1');
|
193
|
-
|
194
|
-
SC.RunLoop.begin();
|
195
|
-
ok(!view1.get('notifiedWillBegin'), "the delegate should not have been notified of begin editing at this point");
|
196
|
-
SC.InlineTextFieldView.beginEditing(optionsForLabel1);
|
197
|
-
ok(view1.get('notifiedWillBegin'), "the delegate should have been notified of begin editing at this point");
|
198
|
-
SC.RunLoop.end();
|
199
|
-
});
|
200
|
-
*/
|
201
|
-
test("inline editor notifies delegate with inlineEditorDidBeginEditing() after becoming responder",
|
202
|
-
function() {
|
203
|
-
var view1 = pane.view('label1');
|
204
|
-
|
205
|
-
// Start a run loop because the notification isn't invoked until the beginning of the next run loop
|
206
|
-
SC.RunLoop.begin();
|
207
|
-
|
208
|
-
ok(!view1.get('notifiedDidBegin'), "the delegate should not have been notified of begin editing at this point");
|
209
|
-
SC.InlineTextFieldView.beginEditing(optionsForLabel1);
|
210
|
-
SC.RunLoop.end();
|
211
|
-
|
212
|
-
ok(view1.get('notifiedDidBegin'), "the delegate should have been notified of begin editing at this point");
|
213
|
-
});
|
214
|
-
|
215
|
-
test("inline editor does not display the defaultValue if the label's value is the number 0",
|
216
|
-
function() {
|
217
|
-
var view1 = pane.view('label1');
|
218
|
-
view1.set('value', 0);
|
219
|
-
optionsForLabel1 = optionsForLabelFromView(view1);
|
220
|
-
|
221
|
-
SC.RunLoop.begin();
|
222
|
-
SC.InlineTextFieldView.beginEditing(optionsForLabel1);
|
223
|
-
SC.RunLoop.end();
|
224
|
-
|
225
|
-
// The inline editor is the last view appended to the parent
|
226
|
-
var view = pane.view('label1'),
|
227
|
-
parentView = view.get('parentView'),
|
228
|
-
length = parentView.childViews.length,
|
229
|
-
editor = parentView.childViews[length - 1];
|
230
|
-
|
231
|
-
same(editor.get('value'), 0, "editor should have number 0 as value");
|
232
|
-
editor.blurEditor();
|
233
|
-
|
234
|
-
same(view1.get('value'), 0, "view should still have number 0 as value");
|
235
|
-
});
|