sproutcore 1.11.0.rc2 → 1.11.0.rc3
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/CHANGELOG +10 -0
- data/VERSION.yml +1 -1
- data/lib/frameworks/sproutcore/CHANGELOG.md +114 -1
- data/lib/frameworks/sproutcore/apps/showcase/views/views_item_view.js +1 -7
- data/lib/frameworks/sproutcore/apps/showcase/views/views_list_view.js +9 -9
- data/lib/frameworks/sproutcore/frameworks/ajax/system/request.js +167 -5
- data/lib/frameworks/sproutcore/frameworks/ajax/system/response.js +24 -8
- data/lib/frameworks/sproutcore/frameworks/core_foundation/child_view_layouts/stack_layout.js +737 -0
- data/lib/frameworks/sproutcore/frameworks/core_foundation/panes/layout.js +0 -6
- data/lib/frameworks/sproutcore/frameworks/core_foundation/panes/pane.js +11 -7
- data/lib/frameworks/sproutcore/frameworks/core_foundation/panes/pane_statechart.js +7 -11
- data/lib/frameworks/sproutcore/frameworks/core_foundation/protocols/child_view_layout_protocol.js +8 -3
- data/lib/frameworks/sproutcore/frameworks/core_foundation/protocols/observable_protocol.js +9 -6
- data/lib/frameworks/sproutcore/frameworks/{desktop/protocols/responder.js → core_foundation/protocols/responder_protocol.js} +83 -17
- data/lib/frameworks/sproutcore/frameworks/core_foundation/protocols/{sparse_array_delegate.js → sparse_array_delegate_protocol.js} +11 -7
- data/lib/frameworks/sproutcore/frameworks/core_foundation/protocols/view_transition_protocol.js +11 -6
- data/lib/frameworks/sproutcore/frameworks/core_foundation/system/color.js +2 -2
- data/lib/frameworks/sproutcore/frameworks/core_foundation/system/page.js +0 -22
- data/lib/frameworks/sproutcore/frameworks/core_foundation/system/root_responder.js +61 -56
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/main_pane.js +2 -2
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/pane/append_remove.js +3 -3
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/animation.js +63 -39
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/border_frame_test.js +28 -28
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/createLayer.js +10 -4
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/layout.js +102 -1
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/layoutDidChange.js +4 -4
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/layoutStyle.js +103 -103
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/replaceAllChildren_test.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/view.js +77 -1
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/view_states_test.js +18 -17
- data/lib/frameworks/sproutcore/frameworks/core_foundation/views/view.js +42 -49
- data/lib/frameworks/sproutcore/frameworks/core_foundation/views/view/animation.js +5 -6
- data/lib/frameworks/sproutcore/frameworks/core_foundation/views/view/enabled.js +16 -5
- data/lib/frameworks/sproutcore/frameworks/core_foundation/views/view/layout.js +241 -102
- data/lib/frameworks/sproutcore/frameworks/core_foundation/views/view/layout_style.js +1 -4
- data/lib/frameworks/sproutcore/frameworks/core_foundation/views/view/manipulation.js +0 -11
- data/lib/frameworks/sproutcore/frameworks/core_foundation/views/view/statechart.js +993 -610
- data/lib/frameworks/sproutcore/frameworks/core_foundation/views/view/theming.js +3 -2
- data/lib/frameworks/sproutcore/frameworks/datastore/data_sources/data_source.js +6 -11
- data/lib/frameworks/sproutcore/frameworks/datastore/system/nested_store.js +94 -27
- data/lib/frameworks/sproutcore/frameworks/datastore/system/query.js +133 -53
- data/lib/frameworks/sproutcore/frameworks/datastore/system/store.js +30 -35
- data/lib/frameworks/sproutcore/frameworks/datastore/tests/models/record/writeAttribute.js +3 -2
- data/lib/frameworks/sproutcore/frameworks/datastore/tests/system/nested_store/writeDataHash.js +73 -29
- data/lib/frameworks/sproutcore/frameworks/datastore/tests/system/store/conflictedStoreKeys_test.js +156 -0
- data/lib/frameworks/sproutcore/frameworks/datastore/tests/system/store/dataSourceCallbacks.js +61 -37
- data/lib/frameworks/sproutcore/frameworks/datastore/tests/system/store/find.js +2 -2
- data/lib/frameworks/sproutcore/frameworks/datetime/frameworks/core/system/datetime.js +68 -39
- data/lib/frameworks/sproutcore/frameworks/designer/tests/coders/page.js +1 -2
- data/lib/frameworks/sproutcore/frameworks/desktop/panes/panel.js +8 -6
- data/lib/frameworks/sproutcore/frameworks/desktop/panes/picker.js +80 -14
- data/lib/frameworks/sproutcore/frameworks/desktop/panes/sheet.js +2 -2
- data/lib/frameworks/sproutcore/frameworks/desktop/protocols/{drag_data_source.js → drag_data_source_protocol.js} +16 -10
- data/lib/frameworks/sproutcore/frameworks/desktop/protocols/{drag_source.js → drag_source_protocol.js} +28 -26
- data/lib/frameworks/sproutcore/frameworks/desktop/protocols/{drop_target.js → drop_target_protocol.js} +73 -75
- data/lib/frameworks/sproutcore/frameworks/desktop/system/drag.js +4 -4
- data/lib/frameworks/sproutcore/frameworks/desktop/tests/panes/panel/ui.js +39 -23
- data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/collection/mouse.js +120 -97
- data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/list/rowSizeForContentIndex.js +26 -25
- data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/scroll/ui.js +3 -3
- data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/segmented/ui.js +5 -0
- data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/split/{dividers.js → dividers_test.js} +38 -38
- data/lib/frameworks/sproutcore/frameworks/desktop/views/collection.js +29 -14
- data/lib/frameworks/sproutcore/frameworks/desktop/views/menu_scroll.js +2 -1
- data/lib/frameworks/sproutcore/frameworks/desktop/views/scroll_view.js +13 -18
- data/lib/frameworks/sproutcore/frameworks/desktop/views/segmented.js +41 -35
- data/lib/frameworks/sproutcore/frameworks/desktop/views/slider.js +14 -14
- data/lib/frameworks/sproutcore/frameworks/desktop/views/split.js +41 -26
- data/lib/frameworks/sproutcore/frameworks/desktop/views/static_content.js +2 -12
- data/lib/frameworks/sproutcore/frameworks/foundation/gestures/tap.js +2 -2
- data/lib/frameworks/sproutcore/frameworks/foundation/mixins/auto_resize.js +14 -10
- data/lib/frameworks/sproutcore/frameworks/foundation/mixins/gesturable.js +104 -63
- data/lib/frameworks/sproutcore/frameworks/foundation/protocols/swap_transition_protocol.js +9 -4
- data/lib/frameworks/sproutcore/frameworks/foundation/tests/mixins/auto_mixin_tests.js +1 -2
- data/lib/frameworks/sproutcore/frameworks/foundation/tests/mixins/auto_resize_test.js +33 -33
- data/lib/frameworks/sproutcore/frameworks/foundation/tests/transitions/view_transitions_test.js +5 -5
- data/lib/frameworks/sproutcore/frameworks/foundation/tests/views/container/methods.js +0 -4
- data/lib/frameworks/sproutcore/frameworks/foundation/tests/views/container/transition_test.js +0 -4
- data/lib/frameworks/sproutcore/frameworks/foundation/tests/views/container/ui.js +0 -2
- data/lib/frameworks/sproutcore/frameworks/foundation/views/text_field.js +12 -8
- data/lib/frameworks/sproutcore/frameworks/media/resources/silence.mp3 +0 -0
- data/lib/frameworks/sproutcore/frameworks/media/tests/audio.js +69 -0
- data/lib/frameworks/sproutcore/frameworks/media/views/audio.js +1 -0
- data/lib/frameworks/sproutcore/frameworks/runtime/core.js +2 -2
- data/lib/frameworks/sproutcore/frameworks/runtime/mixins/observable.js +11 -4
- data/lib/frameworks/sproutcore/frameworks/runtime/protocols/mixin_protocol.js +150 -0
- data/lib/frameworks/sproutcore/frameworks/runtime/system/binding.js +447 -137
- data/lib/frameworks/sproutcore/frameworks/runtime/system/object.js +9 -15
- data/lib/frameworks/sproutcore/frameworks/runtime/system/set.js +19 -17
- data/lib/frameworks/sproutcore/frameworks/runtime/tests/system/binding.js +188 -16
- data/lib/frameworks/sproutcore/frameworks/statechart/system/state.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/template_view/panes/template.js +0 -3
- data/lib/frameworks/sproutcore/frameworks/template_view/tests/panes/template.js +0 -17
- data/lib/frameworks/sproutcore/frameworks/template_view/tests/views/template/collection.js +43 -26
- data/lib/frameworks/sproutcore/frameworks/template_view/views/bindable_span.js +9 -2
- data/lib/frameworks/sproutcore/themes/ace/resources/collection/normal/list.css +0 -1
- data/lib/frameworks/sproutcore/themes/ace/resources/scroll/scroll.css +3 -0
- data/sproutcore.gemspec +3 -3
- metadata +19 -17
- data/lib/frameworks/sproutcore/frameworks/core_foundation/child_view_layouts/horizontal_stack_layout.js +0 -465
- data/lib/frameworks/sproutcore/frameworks/core_foundation/child_view_layouts/vertical_stack_layout.js +0 -472
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/build.js +0 -87
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/build_children.js +0 -89
@@ -199,13 +199,13 @@ SC.AutoResize = {
|
|
199
199
|
@private
|
200
200
|
Begins observing the auto resize field.
|
201
201
|
*/
|
202
|
+
// @if (debug)
|
202
203
|
initMixin: function() {
|
203
|
-
// @if (debug)
|
204
204
|
if (!this.get('supportsAutoResize')) {
|
205
205
|
throw new Error("View `%@` does not support automatic resize. See documentation for SC.AutoResize".fmt(this));
|
206
206
|
}
|
207
|
-
// @endif
|
208
207
|
},
|
208
|
+
// @endif
|
209
209
|
|
210
210
|
/**
|
211
211
|
If this property is provided, all views that share the same value for this property will be resized as a batch for increased performance.
|
@@ -228,8 +228,10 @@ SC.AutoResize = {
|
|
228
228
|
SC.AutoResizeManager.scheduleMeasurementForView(this, batchResizeId);
|
229
229
|
}.observes('isVisibleInWindow', 'shouldMeasureSize', 'autoResizeText', 'batchResizeId'),
|
230
230
|
|
231
|
+
/** @private */
|
231
232
|
_lastMeasuredText: null,
|
232
233
|
|
234
|
+
/** @private */
|
233
235
|
_cachedMetrics: function(key, value) {
|
234
236
|
if(!this.get('shouldCacheSizes')) return;
|
235
237
|
|
@@ -250,11 +252,12 @@ SC.AutoResize = {
|
|
250
252
|
@param batch For internal use during batch resizing.
|
251
253
|
*/
|
252
254
|
measureSize: function(batch) {
|
253
|
-
var metrics, layer = this.get('autoResizeLayer'),
|
255
|
+
var metrics, layer = this.get('autoResizeLayer'),
|
256
|
+
autoResizeText = this.get('autoResizeText'),
|
254
257
|
ignoreEscape = !this.get('escapeHTML'),
|
255
258
|
batchResizeId = this.get('batchResizeId'),
|
256
|
-
cachedMetrics = this.get('_cachedMetrics')
|
257
|
-
maxFontSize = this.get('maxFontSize');
|
259
|
+
cachedMetrics = this.get('_cachedMetrics');
|
260
|
+
// maxFontSize = this.get('maxFontSize');
|
258
261
|
|
259
262
|
if (!layer) return;
|
260
263
|
|
@@ -353,7 +356,8 @@ SC.AutoResize = {
|
|
353
356
|
// the frame will be truncated
|
354
357
|
width = frame.width - 1, height = frame.height - 1,
|
355
358
|
measured = this.get('measuredSize'),
|
356
|
-
mWidth = measured.width, mHeight = measured.height
|
359
|
+
mWidth = measured.width, mHeight = measured.height,
|
360
|
+
actual;
|
357
361
|
|
358
362
|
// figure out and apply padding to the width/height
|
359
363
|
if(SC.typeOf(padding) === SC.T_NUMBER) {
|
@@ -382,7 +386,6 @@ SC.AutoResize = {
|
|
382
386
|
var xProportion = width / mWidth, yProportion = height / mHeight,
|
383
387
|
|
384
388
|
guestimate = Math.floor(maxFontSize * Math.min(xProportion, yProportion)),
|
385
|
-
actual,
|
386
389
|
|
387
390
|
classNames = this.get('classNames'),
|
388
391
|
ignoreEscape = !this.get('escapeHTML'),
|
@@ -472,7 +475,7 @@ SC.AutoResize = {
|
|
472
475
|
|
473
476
|
TODO: consider making the measurement state a formal SC.View state
|
474
477
|
*/
|
475
|
-
_transitionIn: function (original) {
|
478
|
+
_transitionIn: function (original, inPlace) {
|
476
479
|
// In order to allow views to measure and adjust themselves on append, we
|
477
480
|
// can't transition until after the measurement is done.
|
478
481
|
var preTransitionOpacity = this.get('layout').opacity || 1;
|
@@ -480,7 +483,7 @@ SC.AutoResize = {
|
|
480
483
|
this.adjust('opacity', 0);
|
481
484
|
this.invokeNext(function () {
|
482
485
|
this.adjust('opacity', preTransitionOpacity);
|
483
|
-
original();
|
486
|
+
original(inPlace);
|
484
487
|
});
|
485
488
|
}.enhance()
|
486
489
|
|
@@ -515,7 +518,7 @@ SC.AutoResizeManager = {
|
|
515
518
|
scheduleMeasurementForView: function(view) {
|
516
519
|
this.measurementQueue.add(view);
|
517
520
|
|
518
|
-
SC.RunLoop.currentRunLoop.
|
521
|
+
SC.RunLoop.currentRunLoop.invokeOnce(this.doBatchResize);
|
519
522
|
},
|
520
523
|
|
521
524
|
/**
|
@@ -587,4 +590,5 @@ SC.AutoResizeManager = {
|
|
587
590
|
}
|
588
591
|
}
|
589
592
|
}
|
593
|
+
|
590
594
|
};
|
@@ -7,132 +7,173 @@
|
|
7
7
|
|
8
8
|
/**
|
9
9
|
@namespace
|
10
|
-
|
10
|
+
|
11
11
|
You can mix in SC.Gesturable to your views to add some support for recognizing
|
12
12
|
gestures.
|
13
|
-
|
13
|
+
|
14
14
|
SproutCore views have built-in touch events. However, sometimes you may want
|
15
15
|
to recognize gestures like tap, pinch, swipe, etc. This becomes tedious if you
|
16
16
|
need to do this often, and more so if you need to check for multiple possible
|
17
17
|
gestures on the same view.
|
18
|
-
|
18
|
+
|
19
19
|
SC.Gesturable allows you to define a collection of gestures (SC.Gesture objects)
|
20
20
|
that your view should recognize. When a gesture is recognized, methods will be
|
21
21
|
called on the view:
|
22
|
-
|
23
|
-
- [gestureName](gesture, args...): called when the gesture has occurred. This is
|
22
|
+
|
23
|
+
- [gestureName](gesture, args...): called when the gesture has occurred. This is
|
24
24
|
useful for event-style gestures, where you aren't interested in when it starts or
|
25
25
|
ends, but just that it has occurred. SC.SwipeGesture triggers this after the
|
26
26
|
swipe has moved a minimum amount—40px by default.
|
27
|
-
- [gestureName]Start(gesture, args...): called when the gesture is first recognized.
|
28
|
-
For instance, a swipe gesture may be recognized after the finger has moved a
|
27
|
+
- [gestureName]Start(gesture, args...): called when the gesture is first recognized.
|
28
|
+
For instance, a swipe gesture may be recognized after the finger has moved a
|
29
29
|
minimum distance in a horizontal.
|
30
|
-
- [gestureName]Changed(gesture, args...): called when some property of the gesture
|
31
|
-
has changed. For instance, this may be called continuously as the user swipes as
|
30
|
+
- [gestureName]Changed(gesture, args...): called when some property of the gesture
|
31
|
+
has changed. For instance, this may be called continuously as the user swipes as
|
32
32
|
the swipe's distance changes.
|
33
|
-
- [gestureName]Cancelled(gesture, args...): called when a gesture, for one reason
|
34
|
-
or another, is no longer recognized. For instance, a horizontal swipe gesture
|
33
|
+
- [gestureName]Cancelled(gesture, args...): called when a gesture, for one reason
|
34
|
+
or another, is no longer recognized. For instance, a horizontal swipe gesture
|
35
35
|
could cancel if the user moves too far in a vertical direction.
|
36
36
|
- [gestureName]End(gesture, args...): called when a gesture ends. A swipe would end
|
37
37
|
when the user lifts their finger.
|
38
|
-
|
38
|
+
|
39
39
|
Each of these methods is passed the gesture instance, in addition to any arguments
|
40
40
|
the gesture sends for your convenience. The default swipe gesture sends an SC.Touch
|
41
41
|
instance, the swipe direction, and the distance the swipe has moved in that direction.
|
42
|
-
|
42
|
+
|
43
43
|
Using SC.Gesturable
|
44
44
|
-------------------
|
45
|
-
|
45
|
+
|
46
46
|
To make your view recognize gestures, mix in Gesturable and add items to the 'gestures'
|
47
47
|
property:
|
48
|
-
|
48
|
+
|
49
49
|
SC.View.extend(SC.Gesturable, {
|
50
50
|
gestures: [SC.PinchGesture, 'mySwipeGesture'],
|
51
|
-
|
51
|
+
|
52
52
|
// specifying as a string allows you to configure it:
|
53
53
|
mySwipeGesture: SC.SwipeGesture.extend({
|
54
54
|
direction: SC.SWIPE_VERTICAL,
|
55
55
|
startDistance: 3,
|
56
56
|
swipeDistance: 20
|
57
57
|
}),
|
58
|
-
|
58
|
+
|
59
59
|
// handle the swipe action
|
60
60
|
swipe: function(touch, direction) {
|
61
61
|
console.error("Swiped! In direction: " + direction);
|
62
62
|
},
|
63
|
-
|
63
|
+
|
64
64
|
swipeStart: function(touch, direction, delta) {
|
65
65
|
console.error("Swipe started in direction: " + direction + "; dist: " + delta);
|
66
66
|
},
|
67
|
-
|
67
|
+
|
68
68
|
swipeChanged: function(touch, direction, delta) {
|
69
69
|
console.error("Swipe continued in direction: " + direction + "; dist: " + delta);
|
70
70
|
},
|
71
|
-
|
71
|
+
|
72
72
|
swipeEnd: function(touch, direction, delta) {
|
73
73
|
console.error("Completed swipe in direction: " + direction + "; dist: " + delta);
|
74
74
|
}
|
75
|
-
|
75
|
+
|
76
76
|
})
|
77
|
-
|
77
|
+
|
78
|
+
@extends SC.ObjectMixinProtocol
|
78
79
|
*/
|
79
80
|
SC.Gesturable = {
|
80
81
|
|
81
|
-
concatenatedProperties: ["gestures"],
|
82
|
-
gestures: [],
|
83
|
-
|
84
82
|
/**
|
85
|
-
@
|
86
|
-
|
83
|
+
@type Array
|
84
|
+
@default ['gestures']
|
85
|
+
@see SC.Object#concatenatedProperties
|
86
|
+
*/
|
87
|
+
concatenatedProperties: ['gestures'],
|
88
|
+
|
89
|
+
/**
|
90
|
+
The gestures that the view will support. This property must be set on the consumer of
|
91
|
+
`SC.Gesturable` before it is initialized.
|
92
|
+
|
93
|
+
These gestures should be objects that extend the `SC.Gesture` class. You can use SproutCore's
|
94
|
+
pre-built gestures or create your own. If you create your own, you can use a property name
|
95
|
+
in the list of gestures to refer to the actual gesture class, similar to how the childViews
|
96
|
+
array works. For example,
|
97
|
+
|
98
|
+
gestures: [SC.PinchGesture, 'mySwipeGesture'],
|
99
|
+
|
100
|
+
// Specifying the Gesture by property name allows you to configure it.
|
101
|
+
mySwipeGesture: SC.SwipeGesture.extend({
|
102
|
+
direction: SC.SWIPE_VERTICAL,
|
103
|
+
startDistance: 3,
|
104
|
+
swipeDistance: 20
|
105
|
+
}),
|
106
|
+
|
107
|
+
Note that `gestures` is a *concatenated property*, which means that it will not be overwritten
|
108
|
+
by subclasses. So for example, if the base class lists gestures as `[SC.PinchGesture]` and its
|
109
|
+
subclass lists gestures as `[SC.TapGesture]`, the actual gestures supported by the subclass will
|
110
|
+
be `[SC.PinchGesture, SC.TapGesture]`.
|
111
|
+
|
112
|
+
@type Array
|
113
|
+
@default null
|
114
|
+
*/
|
115
|
+
gestures: null,
|
116
|
+
|
117
|
+
/**
|
118
|
+
When SC.Gesturable initializes, any gestures named on the view are instantiated.
|
119
|
+
|
120
|
+
@see SC.ObjectMixinProtocol#initMixin
|
87
121
|
*/
|
88
122
|
initMixin: function() {
|
123
|
+
//@if(debug)
|
124
|
+
if (SC.none(this.gestures)) {
|
125
|
+
SC.error("Developer Error: When mixing in SC.Gesturable, you must define a list of gestures to use.");
|
126
|
+
}
|
127
|
+
//@endif
|
89
128
|
this.createGestures();
|
90
129
|
},
|
91
|
-
|
92
|
-
/**
|
93
|
-
@private
|
94
|
-
Instantiates the gestures.
|
95
|
-
*/
|
130
|
+
|
131
|
+
/** @private Instantiates the gestures. */
|
96
132
|
createGestures: function() {
|
97
|
-
var gestures = this.get("gestures"),
|
133
|
+
var gestures = this.get("gestures"),
|
134
|
+
len = gestures.length,
|
135
|
+
instantiatedGestures = [],
|
136
|
+
idx;
|
98
137
|
|
99
138
|
// loop through all gestures
|
100
139
|
for (idx = 0; idx < len; idx++) {
|
140
|
+
var gesture;
|
141
|
+
|
101
142
|
// get the proper gesture
|
102
143
|
if (SC.typeOf(gestures[idx]) === SC.T_STRING) {
|
103
|
-
|
144
|
+
gesture = this.get(gestures[idx]);
|
104
145
|
} else {
|
105
|
-
|
146
|
+
gesture = gestures[idx];
|
106
147
|
}
|
107
|
-
|
148
|
+
|
108
149
|
// if it was not found, well, that's an error.
|
109
|
-
if (!
|
110
|
-
throw new Error("Could not find gesture named '" + gestures[idx] + "' on view.");
|
150
|
+
if (!gesture) {
|
151
|
+
throw new Error("Developer Error: Could not find gesture named '" + gestures[idx] + "' on view.");
|
111
152
|
}
|
112
|
-
|
153
|
+
|
113
154
|
// if it is a class, instantiate (it really ought to be a class...)
|
114
|
-
if (
|
115
|
-
|
155
|
+
if (gesture.isClass) {
|
156
|
+
gesture = gesture.create({
|
116
157
|
view: this
|
117
158
|
});
|
118
159
|
}
|
119
|
-
|
160
|
+
|
120
161
|
// and set the gesture instance and add it to the array.
|
121
|
-
if (SC.typeOf(gestures[idx]) === SC.T_STRING) this[gestures[idx]] =
|
122
|
-
|
162
|
+
if (SC.typeOf(gestures[idx]) === SC.T_STRING) this[gestures[idx]] = gesture;
|
163
|
+
instantiatedGestures.push(gesture);
|
123
164
|
}
|
124
|
-
|
125
|
-
this.set("gestures",
|
165
|
+
|
166
|
+
this.set("gestures", instantiatedGestures);
|
126
167
|
},
|
127
|
-
|
168
|
+
|
128
169
|
/**
|
129
170
|
Handles touch start by handing it to the gesture recognizing code.
|
130
|
-
|
171
|
+
|
131
172
|
If you override touchStart, you will need to call gestureTouchStart to
|
132
173
|
give the gesture system control of the touch. You will continue to get
|
133
174
|
events until if and when a gesture decides to take "possession" of a touch—
|
134
175
|
at this point, you will get a [gestureName]Start event.
|
135
|
-
|
176
|
+
|
136
177
|
You do not have to call gestureTouchStart immediately; you can call it
|
137
178
|
at any time. This allows you to avoid passing control until _after_ you
|
138
179
|
have determined your own touchStart, touchesDragged, and touchEnd methods
|
@@ -141,50 +182,50 @@ SC.Gesturable = {
|
|
141
182
|
touchStart: function(touch) {
|
142
183
|
this.gestureTouchStart(touch);
|
143
184
|
},
|
144
|
-
|
185
|
+
|
145
186
|
/**
|
146
187
|
Tells the gesture recognizing code about touches moving.
|
147
|
-
|
188
|
+
|
148
189
|
If you override touchesDragged, you will need to call gestureTouchesDragged
|
149
|
-
(at least for any touches you called gestureTouchStart for in touchStart) to
|
190
|
+
(at least for any touches you called gestureTouchStart for in touchStart) to
|
150
191
|
allow the gesture system to update.
|
151
192
|
*/
|
152
193
|
touchesDragged: function(evt, touches) {
|
153
194
|
this.gestureTouchesDragged(evt, touches);
|
154
195
|
},
|
155
|
-
|
196
|
+
|
156
197
|
/**
|
157
198
|
Tells the gesture recognizing code about a touch ending.
|
158
|
-
|
199
|
+
|
159
200
|
If you override touchEnd, you will need to call gestureTouchEnd
|
160
201
|
for any touches you called touchStart for.
|
161
202
|
*/
|
162
203
|
touchEnd: function(touch) {
|
163
204
|
this.gestureTouchEnd(touch);
|
164
205
|
},
|
165
|
-
|
206
|
+
|
166
207
|
/**
|
167
208
|
Tells the gesture recognizing system about a new touch.
|
168
|
-
|
209
|
+
|
169
210
|
This informs all gestures that a new touch, "unassigned" to any gesture,
|
170
211
|
has been located. Later, each gesture has an opportunity to claim the touch.
|
171
|
-
|
212
|
+
|
172
213
|
Once they have claimed the touch, further events will go _directly_ to them—
|
173
214
|
this view will cease receiving the touchesDragged and will not receive a touchEnd.
|
174
215
|
*/
|
175
216
|
gestureTouchStart: function(touch) {
|
176
217
|
touch.isInteresting = 0;
|
177
|
-
|
218
|
+
|
178
219
|
var gestures = this.get("gestures"), idx, len = gestures.length, g;
|
179
220
|
for (idx = 0; idx < len; idx++) {
|
180
221
|
g = gestures[idx];
|
181
222
|
g.unassignedTouchDidStart(touch);
|
182
223
|
}
|
183
224
|
},
|
184
|
-
|
225
|
+
|
185
226
|
/**
|
186
227
|
Tells the gesture recognition system that some touches have moved.
|
187
|
-
|
228
|
+
|
188
229
|
This informs all gestures that these touches have changed. All such touches
|
189
230
|
are "unassigned" because all "assigned" touches already get sent directly
|
190
231
|
to the gesture.
|
@@ -196,10 +237,10 @@ SC.Gesturable = {
|
|
196
237
|
g.unassignedTouchesDidChange(evt, touches);
|
197
238
|
}
|
198
239
|
},
|
199
|
-
|
240
|
+
|
200
241
|
/**
|
201
242
|
Tells the gesture recognition system that a touch have ended.
|
202
|
-
|
243
|
+
|
203
244
|
This informs all of the gestures that the touch ended. The touch is
|
204
245
|
an unassigned touch as, if it were assigned to a gesture, it would have
|
205
246
|
been sent directly to the gesture, bypassing this view.
|
@@ -211,4 +252,4 @@ SC.Gesturable = {
|
|
211
252
|
g.unassignedTouchDidEnd(touch);
|
212
253
|
}
|
213
254
|
}
|
214
|
-
};
|
255
|
+
};
|
@@ -6,11 +6,16 @@
|
|
6
6
|
|
7
7
|
|
8
8
|
/** @namespace
|
9
|
-
|
9
|
+
The `SC.SwapTransitionProtocol` protocol defines the properties and methods that you may
|
10
|
+
implement in your custom swap transition plugins. All methods are optional, but a plugin is
|
11
|
+
expected to use at least one of the methods.
|
10
12
|
|
11
|
-
SC.ContainerView uses transition plugins to setup, execute and cleanup the
|
12
|
-
|
13
|
-
|
13
|
+
SC.ContainerView uses transition plugins to setup, execute and cleanup the swapping between views
|
14
|
+
and expects the given transition plugin object to implement the methods in this protocol.
|
15
|
+
|
16
|
+
*Note: Do not mix `SC.SwapTransitionProtocol` into your classes. As a protocol, it exists only
|
17
|
+
for reference sake. You only need define any of the properties or methods listed below in order to
|
18
|
+
use this protocol.*
|
14
19
|
*/
|
15
20
|
SC.SwapTransitionProtocol = {
|
16
21
|
|
@@ -1,6 +1,5 @@
|
|
1
1
|
// ==========================================================================
|
2
|
-
// Project:
|
3
|
-
// Copyright: ©2013 7x7 Software, Inc.
|
2
|
+
// Project: SproutCore
|
4
3
|
// License: Licensed under MIT license
|
5
4
|
// ==========================================================================
|
6
5
|
/*globals module, test, ok, equals */
|
@@ -13,9 +13,11 @@ var view;
|
|
13
13
|
module("SC.AutoResize", {
|
14
14
|
|
15
15
|
setup: function () {
|
16
|
-
|
17
|
-
|
18
|
-
|
16
|
+
SC.run(function () {
|
17
|
+
view = SC.LabelView.create(SC.AutoResize, {
|
18
|
+
layout: { left: 0, height: 40 },
|
19
|
+
value: "The bottom line, Williams said, is that the internet is “a giant machine designed to give people what they want.” It’s not a utopia. It’s not magical. It’s simply an engine of convenience. Those who can tune that engine well — who solve basic human problems with greater speed and simplicity than those who came before — will profit immensely. Those who lose sight of basic human needs — who want to give people the next great idea — will have problems. “We often think of the internet enables you to do new things,” Williams said. “But people just want to do the same things they’ve always done.”"
|
20
|
+
});
|
19
21
|
});
|
20
22
|
},
|
21
23
|
|
@@ -40,10 +42,10 @@ test("Resize height only.", function () {
|
|
40
42
|
|
41
43
|
// Set the view up for height only resizing.
|
42
44
|
// i.e. It should grow to fit the text wrapped within the width of the view.
|
43
|
-
view.set('shouldResizeWidth', false);
|
44
|
-
view.set('shouldResizeHeight', true);
|
45
|
-
|
46
45
|
SC.run(function () {
|
46
|
+
view.set('shouldResizeWidth', false);
|
47
|
+
view.set('shouldResizeHeight', true);
|
48
|
+
|
47
49
|
pane.appendChild(view);
|
48
50
|
pane.append();
|
49
51
|
});
|
@@ -101,7 +103,7 @@ test("Resize with transition plugin - conflict", function () {
|
|
101
103
|
|
102
104
|
// Width transition plugin.
|
103
105
|
run: function (view, options, finalLayout, finalFrame) {
|
104
|
-
view.animate('width', finalFrame.width, { duration:
|
106
|
+
view.animate('width', finalFrame.width, { duration: 1 }, function (data) {
|
105
107
|
this.didTransitionIn();
|
106
108
|
});
|
107
109
|
}
|
@@ -119,7 +121,7 @@ test("Resize with transition plugin - conflict", function () {
|
|
119
121
|
ok(jqEl.width() > 10, 'width is > 10: %@'.fmt(jqEl.width()));
|
120
122
|
ok(jqEl.width() < 3000, 'width is < 3000: %@'.fmt(jqEl.width()));
|
121
123
|
ok(view.get('layout').width > 3000, 'layout.width is > 3000: %@'.fmt(view.get('layout').width));
|
122
|
-
},
|
124
|
+
}, 250);
|
123
125
|
|
124
126
|
setTimeout(function () {
|
125
127
|
var jqEl = view.$();
|
@@ -132,13 +134,10 @@ test("Resize with transition plugin - conflict", function () {
|
|
132
134
|
});
|
133
135
|
|
134
136
|
start();
|
135
|
-
},
|
137
|
+
}, 1250);
|
136
138
|
});
|
137
139
|
|
138
|
-
|
139
140
|
test("Resize with child view layout", function () {
|
140
|
-
stop(700);
|
141
|
-
|
142
141
|
var pane, view2;
|
143
142
|
|
144
143
|
SC.run(function () {
|
@@ -147,8 +146,8 @@ test("Resize with child view layout", function () {
|
|
147
146
|
layout: { top: 200, left: 0, width: 200, height: 200 },
|
148
147
|
childViewLayout: SC.View.HORIZONTAL_STACK,
|
149
148
|
|
150
|
-
a: SC.
|
151
|
-
|
149
|
+
a: SC.LabelView.extend(SC.AutoResize, {
|
150
|
+
value: "XYZ"
|
152
151
|
}),
|
153
152
|
|
154
153
|
b: SC.View.extend({
|
@@ -167,23 +166,24 @@ test("Resize with child view layout", function () {
|
|
167
166
|
pane.appendChild(view2);
|
168
167
|
});
|
169
168
|
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
ok(view2.get('layout').left > 2000, 'left: %@ is > 2000'.fmt(view2.get('layout').left));
|
169
|
+
var childViews = pane.get('childViews'),
|
170
|
+
viewA = childViews.objectAt(0),
|
171
|
+
viewB = childViews.objectAt(1);
|
174
172
|
|
175
|
-
|
176
|
-
|
173
|
+
ok(view.get('layout').width > 2000, 'width is > 2000');
|
174
|
+
equals(viewB.get('layout').left, viewA.get('frame').width, 'second view left is');
|
175
|
+
equals(view.get('layout').left, viewA.get('frame').width + 50, 'third view left is');
|
176
|
+
ok(view2.get('layout').left > 2000, 'left: %@ is > 2000'.fmt(view2.get('layout').left));
|
177
177
|
|
178
|
-
|
179
|
-
|
178
|
+
pane.destroy();
|
179
|
+
pane.remove();
|
180
180
|
});
|
181
181
|
|
182
182
|
/**
|
183
|
-
For a TextFieldView where we set it to only resize its height every time its value changes
|
183
|
+
For a TextFieldView where we set it to only resize its height every time its value changes
|
184
184
|
we get the textareas width and set its max-width to this if no autoResizeLayer has been set.
|
185
185
|
|
186
|
-
This test checks that every-time the value changes the max-width we set doesn't change the
|
186
|
+
This test checks that every-time the value changes the max-width we set doesn't change the
|
187
187
|
textarea width (i.e. takes padding into account when measuring).
|
188
188
|
*/
|
189
189
|
test("Resize height only for textarea where textarea has padding.", function () {
|
@@ -218,10 +218,10 @@ test("Resize height only for textarea where textarea has padding.", function ()
|
|
218
218
|
SC.run(function () {
|
219
219
|
view.$('textarea').css({
|
220
220
|
'padding': '10px',
|
221
|
-
'-webkit-box-sizing': 'border-box',
|
221
|
+
'-webkit-box-sizing': 'border-box',
|
222
222
|
'-moz-box-sizing': 'border-box',
|
223
|
-
'box-sizing': 'border-box'
|
224
|
-
})
|
223
|
+
'box-sizing': 'border-box'
|
224
|
+
});
|
225
225
|
});
|
226
226
|
|
227
227
|
// now the css is applied measure the textareas width
|
@@ -236,7 +236,7 @@ test("Resize height only for textarea where textarea has padding.", function ()
|
|
236
236
|
setTimeout(function () {
|
237
237
|
// check the frame and textarea have the expected dimensions
|
238
238
|
ok(view.get('frame').width == 200, 'frame width is 200');
|
239
|
-
equals(origWidth, view.$('textarea').outerWidth(), 'textarea width has not changed since update of value')
|
239
|
+
equals(origWidth, view.$('textarea').outerWidth(), 'textarea width has not changed since update of value');
|
240
240
|
|
241
241
|
pane.destroy();
|
242
242
|
pane.remove();
|
@@ -280,10 +280,10 @@ test("Resize text only for input where input has padding.", function () {
|
|
280
280
|
SC.run(function () {
|
281
281
|
view.$('input').css({
|
282
282
|
'padding': '10px',
|
283
|
-
'-webkit-box-sizing': 'border-box',
|
283
|
+
'-webkit-box-sizing': 'border-box',
|
284
284
|
'-moz-box-sizing': 'border-box',
|
285
|
-
'box-sizing': 'border-box'
|
286
|
-
})
|
285
|
+
'box-sizing': 'border-box'
|
286
|
+
});
|
287
287
|
});
|
288
288
|
|
289
289
|
// now the css is applied measure the input fields width
|
@@ -298,11 +298,11 @@ test("Resize text only for input where input has padding.", function () {
|
|
298
298
|
setTimeout(function () {
|
299
299
|
// check the frame and input field have the expected dimensions
|
300
300
|
ok(view.get('frame').width == 200, 'frame width is 200');
|
301
|
-
equals(origWidth, view.$('input').outerWidth(), 'input field width has not changed since update of value')
|
301
|
+
equals(origWidth, view.$('input').outerWidth(), 'input field width has not changed since update of value');
|
302
302
|
|
303
303
|
pane.destroy();
|
304
304
|
pane.remove();
|
305
305
|
|
306
306
|
start();
|
307
307
|
}, 500);
|
308
|
-
})
|
308
|
+
});
|