sproutcore 1.5.0.pre.4.1 → 1.5.0.pre.5
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +7 -0
- data/VERSION.yml +1 -1
- data/lib/buildtasks/manifest.rake +4 -3
- data/lib/frameworks/sproutcore/Buildfile +1 -2
- data/lib/frameworks/sproutcore/CHANGELOG.md +8 -3
- data/lib/frameworks/sproutcore/apps/greenhouse/english.lproj/css/app-selector.css +19 -23
- data/lib/frameworks/sproutcore/apps/greenhouse/english.lproj/css/button.css +139 -135
- data/lib/frameworks/sproutcore/apps/greenhouse/english.lproj/css/dock.css +5 -0
- data/lib/frameworks/sproutcore/apps/greenhouse/english.lproj/css/general.css +0 -1
- data/lib/frameworks/sproutcore/apps/greenhouse/english.lproj/css/menu.css +10 -13
- data/lib/frameworks/sproutcore/apps/greenhouse/english.lproj/css/modal.css +9 -8
- data/lib/frameworks/sproutcore/apps/greenhouse/english.lproj/css/picker.css +19 -12
- data/lib/frameworks/sproutcore/apps/greenhouse/models/design.js +2 -2
- data/lib/frameworks/sproutcore/apps/greenhouse/states/modals.js +1 -1
- data/lib/frameworks/sproutcore/apps/greenhouse/theme.js +2 -2
- data/lib/frameworks/sproutcore/apps/greenhouse/views/plist_item.js +3 -1
- data/lib/frameworks/sproutcore/frameworks/animation/core.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/bootstrap/system/browser.js +31 -20
- data/lib/frameworks/sproutcore/frameworks/bootstrap/tests/system/browser.js +15 -9
- data/lib/frameworks/sproutcore/frameworks/core_foundation/mixins/responder_context.js +5 -5
- data/lib/frameworks/sproutcore/frameworks/core_foundation/panes/pane.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/core_foundation/system/browser.js +23 -45
- data/lib/frameworks/sproutcore/frameworks/core_foundation/system/device.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/core_foundation/system/platform.js +60 -5
- data/lib/frameworks/sproutcore/frameworks/core_foundation/system/ready.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/core_foundation/system/render_context.js +2 -2
- data/lib/frameworks/sproutcore/frameworks/core_foundation/system/root_responder.js +4 -4
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/system/ready/done.js +32 -0
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/system/utils/offset.js +5 -2
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/pane/append_remove.js +8 -3
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/pane/layout.js +4 -4
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/template_view/collection.js +51 -5
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/template_view/core.js +18 -0
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/template_view/handlebars.js +261 -0
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/animation.js +55 -0
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/clippingFrame.js +2 -19
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/convertFrames.js +3 -1
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/insertBefore.js +17 -0
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/layoutStyle.js +96 -1
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/prepareContext.js +15 -0
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/updateLayerLocation.js +19 -0
- data/lib/frameworks/sproutcore/frameworks/core_foundation/views/template/collection.js +8 -1
- data/lib/frameworks/sproutcore/frameworks/core_foundation/views/view.js +179 -4
- data/lib/frameworks/sproutcore/frameworks/core_foundation/views/view/animation.js +8 -14
- data/lib/frameworks/sproutcore/frameworks/core_foundation/views/view/cursor.js +7 -0
- data/lib/frameworks/sproutcore/frameworks/core_foundation/views/view/enabled.js +4 -4
- data/lib/frameworks/sproutcore/frameworks/core_foundation/views/view/layout.js +51 -114
- data/lib/frameworks/sproutcore/frameworks/core_foundation/views/view/layout_style.js +84 -36
- data/lib/frameworks/sproutcore/frameworks/core_foundation/views/view/manipulation.js +4 -67
- data/lib/frameworks/sproutcore/frameworks/datastore/data_sources/data_source.js +244 -1
- data/lib/frameworks/sproutcore/frameworks/datastore/models/child_attribute.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/datastore/models/children_attribute.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/datastore/models/record_attribute.js +7 -1
- data/lib/frameworks/sproutcore/frameworks/datastore/system/child_array.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/datastore/system/store.js +2 -2
- data/lib/frameworks/sproutcore/frameworks/datastore/tests/models/record/normalize.js +23 -1
- data/lib/frameworks/sproutcore/frameworks/datastore/tests/system/nested_store/commitChanges.js +4 -2
- data/lib/frameworks/sproutcore/frameworks/datastore/tests/system/nested_store/commitChangesFromNestedStore.js +4 -0
- data/lib/frameworks/sproutcore/frameworks/datastore/tests/system/nested_store/discardChanges.js +4 -1
- data/lib/frameworks/sproutcore/frameworks/datastore/tests/system/query/record_type_is.js +4 -0
- data/lib/frameworks/sproutcore/frameworks/datastore/tests/system/query/registered_comparisons.js +4 -0
- data/lib/frameworks/sproutcore/frameworks/datastore/tests/system/query/registered_query_extensions.js +4 -0
- data/lib/frameworks/sproutcore/frameworks/datastore/tests/system/store/commitChangesFromNestedStore.js +4 -0
- data/lib/frameworks/sproutcore/frameworks/datastore/tests/system/store/createRecord.js +5 -1
- data/lib/frameworks/sproutcore/frameworks/datastore/tests/system/store/destroyRecord.js +5 -1
- data/lib/frameworks/sproutcore/frameworks/datastore/tests/system/store/loadRecord.js +64 -0
- data/lib/frameworks/sproutcore/frameworks/datastore/tests/system/store/recordDidChange.js +38 -35
- data/lib/frameworks/sproutcore/frameworks/datastore/tests/system/store/unloadRecords.js +4 -0
- data/lib/frameworks/sproutcore/frameworks/datetime/system/datetime.js +7 -4
- data/lib/frameworks/sproutcore/frameworks/datetime/tests/system/datetime.js +2 -2
- data/lib/frameworks/sproutcore/frameworks/debug/core.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/debug/invoke_once_last_debugging.js +5 -5
- data/lib/frameworks/sproutcore/frameworks/designer/coders/object.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/designer/designers/view_designer.js +11 -3
- data/lib/frameworks/sproutcore/frameworks/designer/ext/binding.js +33 -0
- data/lib/frameworks/sproutcore/frameworks/designer/ext/object.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/designer/ext/page.js +5 -33
- data/lib/frameworks/sproutcore/frameworks/designer/ext/view.js +0 -27
- data/lib/frameworks/sproutcore/frameworks/designer/tests/coders/page.js +54 -0
- data/lib/frameworks/sproutcore/frameworks/designer/tests/designers/view_designer.js +47 -0
- data/lib/frameworks/sproutcore/frameworks/designer/views/drawing.js +4 -4
- data/lib/frameworks/sproutcore/frameworks/desktop/mixins/border.js +19 -6
- data/lib/frameworks/sproutcore/frameworks/desktop/mixins/collection_view_delegate.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/desktop/mixins/navigation_builder.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/desktop/mixins/scrollable.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/desktop/panes/picker.js +133 -39
- data/lib/frameworks/sproutcore/frameworks/desktop/system/drag.js +3 -3
- data/lib/frameworks/sproutcore/frameworks/desktop/tests/mixins/border.js +6 -5
- data/lib/frameworks/sproutcore/frameworks/desktop/tests/panes/picker/ui.js +8 -2
- data/lib/frameworks/sproutcore/frameworks/desktop/tests/panes/select_button/ui.js +10 -2
- data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/button/ui.js +8 -2
- data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/checkbox/ui.js +10 -2
- data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/collection/ui_diagram.js +15 -9
- data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/progress/ui.js +8 -2
- data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/radio/ui.js +8 -2
- data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/segmented/ui.js +10 -2
- data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/select/ui.js +10 -2
- data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/select_field/methods.js +31 -0
- data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/select_field/ui.js +10 -3
- data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/separator.js +10 -3
- data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/split/ui.js +10 -3
- data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/stacked/ui_comments.js +15 -8
- data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/tab/ui.js +10 -3
- data/lib/frameworks/sproutcore/frameworks/desktop/views/button.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/desktop/views/file.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/desktop/views/list_item.js +1 -7
- data/lib/frameworks/sproutcore/frameworks/desktop/views/select_field.js +10 -0
- data/lib/frameworks/sproutcore/frameworks/desktop/views/toolbar.js +3 -3
- data/lib/frameworks/sproutcore/frameworks/foundation/mixins/collection_content.js +2 -2
- data/lib/frameworks/sproutcore/frameworks/foundation/mixins/inline_text_field.js +17 -5
- data/lib/frameworks/sproutcore/frameworks/foundation/mixins/inner_frame.js +60 -27
- data/lib/frameworks/sproutcore/frameworks/foundation/render_delegates/canvas_image.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/foundation/system/benchmark.js +4 -4
- data/lib/frameworks/sproutcore/frameworks/foundation/system/cookie.js +29 -18
- data/lib/frameworks/sproutcore/frameworks/foundation/system/module.js +18 -18
- data/lib/frameworks/sproutcore/frameworks/foundation/system/user_defaults.js +5 -5
- data/lib/frameworks/sproutcore/frameworks/foundation/system/utils/misc.js +62 -1
- data/lib/frameworks/sproutcore/frameworks/foundation/tests/integration/creating_views.js +8 -3
- data/lib/frameworks/sproutcore/frameworks/foundation/tests/mixins/button/ui.js +4 -3
- data/lib/frameworks/sproutcore/frameworks/foundation/tests/mixins/editable/ui.js +5 -3
- data/lib/frameworks/sproutcore/frameworks/foundation/tests/mixins/inline_text_field/ui.js +5 -3
- data/lib/frameworks/sproutcore/frameworks/foundation/tests/system/cookie.js +20 -4
- data/lib/frameworks/sproutcore/frameworks/foundation/tests/system/utils/pointInElement.js +235 -0
- data/lib/frameworks/sproutcore/frameworks/foundation/tests/views/container/ui.js +5 -0
- data/lib/frameworks/sproutcore/frameworks/foundation/tests/views/image/ui.js +0 -2
- data/lib/frameworks/sproutcore/frameworks/foundation/tests/views/label/ui.js +8 -3
- data/lib/frameworks/sproutcore/frameworks/foundation/views/container.js +2 -2
- data/lib/frameworks/sproutcore/frameworks/foundation/views/image.js +19 -11
- data/lib/frameworks/sproutcore/frameworks/foundation/views/label.js +6 -13
- data/lib/frameworks/sproutcore/frameworks/handlebars/extensions.js +23 -117
- data/lib/frameworks/sproutcore/frameworks/handlebars/extensions/bind.js +136 -0
- data/lib/frameworks/sproutcore/frameworks/handlebars/extensions/collection.js +75 -0
- data/lib/frameworks/sproutcore/frameworks/handlebars/extensions/localization.js +5 -0
- data/lib/frameworks/sproutcore/frameworks/handlebars/extensions/view.js +115 -0
- data/lib/frameworks/sproutcore/frameworks/handlebars/handlebars.js +143 -80
- data/lib/frameworks/sproutcore/frameworks/jquery/jquery-buffer.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/media/views/audio.js +4 -4
- data/lib/frameworks/sproutcore/frameworks/media/views/video.js +5 -5
- data/lib/frameworks/sproutcore/frameworks/runtime/debug/test_suites/array.js +14 -0
- data/lib/frameworks/sproutcore/frameworks/runtime/mixins/enumerable.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/runtime/mixins/observable.js +13 -13
- data/lib/frameworks/sproutcore/frameworks/runtime/system/binding.js +4 -4
- data/lib/frameworks/sproutcore/frameworks/runtime/system/run_loop.js +3 -3
- data/lib/frameworks/sproutcore/frameworks/runtime/tests/mixins/array.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/testing/system/plan.js +25 -17
- data/lib/frameworks/sproutcore/themes/ace/designs/psds/panel/pointers.psd +0 -0
- data/lib/frameworks/sproutcore/themes/ace/resources/button/ace/18px/button.css +18 -12
- data/lib/frameworks/sproutcore/themes/ace/resources/button/ace/24px/button.css +30 -16
- data/lib/frameworks/sproutcore/themes/ace/resources/button/ace/30px/button.css +27 -15
- data/lib/frameworks/sproutcore/themes/ace/resources/button/ace/44px/button.css +5 -0
- data/lib/frameworks/sproutcore/themes/ace/resources/button/ace/button.css +8 -0
- data/lib/frameworks/sproutcore/themes/ace/resources/button/dark/24px/button.css +25 -16
- data/lib/frameworks/sproutcore/themes/ace/resources/button/dark/30px/button.css +21 -15
- data/lib/frameworks/sproutcore/themes/ace/resources/imagebutton/ace/imagebutton.css +11 -0
- data/lib/frameworks/sproutcore/themes/ace/resources/picker/ace/panel.png +0 -0
- data/lib/frameworks/sproutcore/themes/ace/resources/picker/ace/picker.css +41 -0
- data/lib/frameworks/sproutcore/themes/ace/resources/picker/ace/pointers.png +0 -0
- data/lib/sproutcore.rb +2 -0
- data/lib/sproutcore/buildfile.rb +17 -17
- data/lib/sproutcore/buildfile/task.rb +4 -12
- data/lib/sproutcore/buildfile/task_manager.rb +13 -4
- data/lib/sproutcore/models/manifest.rb +3 -3
- data/lib/sproutcore/models/target.rb +1 -1
- data/spec/fixtures/real_world/Buildfile +1 -1
- data/vendor/chance/lib/chance/imagers/data_url.rb +38 -19
- data/vendor/chance/lib/chance/instance.rb +4 -7
- data/vendor/chance/lib/chance/slicing.rb +6 -10
- metadata +18 -5
- data/lib/frameworks/sproutcore/apps/greenhouse/english.lproj/css/tabbed.css +0 -68
- data/lib/frameworks/sproutcore/frameworks/designer/coders/localization.js +0 -19
- data/lib/sproutcore/buildfile/cloneable.rb +0 -34
@@ -97,7 +97,7 @@ SC.device = SC.Object.create({
|
|
97
97
|
*/
|
98
98
|
setup: function() {
|
99
99
|
var responder = SC.RootResponder.responder;
|
100
|
-
responder.listenFor('online offline'.w(),
|
100
|
+
responder.listenFor('online offline'.w(), window, this);
|
101
101
|
|
102
102
|
this.orientationHandlingShouldChange();
|
103
103
|
},
|
@@ -148,9 +148,29 @@ SC.platform = {
|
|
148
148
|
/** @private
|
149
149
|
When simulating touch events, this method is called when mousemove events
|
150
150
|
are received.
|
151
|
+
|
152
|
+
If the altKey is depresed and pinch center not yet established, we will capture the mouse position.
|
151
153
|
*/
|
152
154
|
_simtouch_mousemove: function(evt) {
|
153
|
-
if (!this._mousedown)
|
155
|
+
if (!this._mousedown) {
|
156
|
+
/*
|
157
|
+
we need to capture when was the first spot that the altKey was pressed and use it as
|
158
|
+
the center point of a pinch
|
159
|
+
*/
|
160
|
+
if(evt.altKey && this._pinchCenter == null) {
|
161
|
+
this._pinchCenter = {
|
162
|
+
pageX: evt.pageX,
|
163
|
+
pageY: evt.pageY,
|
164
|
+
screenX: evt.screenX,
|
165
|
+
screenY: evt.screenY,
|
166
|
+
clientX: evt.clientX,
|
167
|
+
clientY: evt.clientY
|
168
|
+
};
|
169
|
+
} else if(!evt.altKey && this._pinchCenter != null){
|
170
|
+
this._pinchCenter = null;
|
171
|
+
}
|
172
|
+
return NO;
|
173
|
+
}
|
154
174
|
|
155
175
|
var manufacturedEvt = this.manufactureTouchEvent(evt, 'touchmove');
|
156
176
|
return SC.RootResponder.responder.touchmove(manufacturedEvt);
|
@@ -186,17 +206,22 @@ SC.platform = {
|
|
186
206
|
Note that this method edits the passed event in place, and returns
|
187
207
|
that same instance instead of a new, modified version.
|
188
208
|
|
209
|
+
If altKey is depressed and we have previously captured a position for the center of
|
210
|
+
the pivot point for the virtual second touch, we will manufacture an additional touch.
|
211
|
+
The position of the virtual touch will be the reflection of the mouse position,
|
212
|
+
relative to the pinch center.
|
213
|
+
|
189
214
|
@param {Event} evt the mouse event to modify
|
190
215
|
@param {String} type the type of event (e.g., touchstart)
|
191
216
|
@returns {Event} the mouse event with an added changedTouches array
|
192
217
|
*/
|
193
218
|
manufactureTouchEvent: function(evt, type) {
|
194
|
-
var
|
219
|
+
var realTouch, virtualTouch, realTouchIdentifier = this._simtouch_counter;
|
195
220
|
|
196
|
-
|
221
|
+
realTouch = {
|
197
222
|
type: type,
|
198
223
|
target: evt.target,
|
199
|
-
identifier:
|
224
|
+
identifier: realTouchIdentifier,
|
200
225
|
pageX: evt.pageX,
|
201
226
|
pageY: evt.pageY,
|
202
227
|
screenX: evt.screenX,
|
@@ -204,8 +229,38 @@ SC.platform = {
|
|
204
229
|
clientX: evt.clientX,
|
205
230
|
clientY: evt.clientY
|
206
231
|
};
|
232
|
+
evt.touches = [ realTouch ];
|
233
|
+
|
234
|
+
/*
|
235
|
+
simulate pinch gesture
|
236
|
+
*/
|
237
|
+
if(evt.altKey && this._pinchCenter != null)
|
238
|
+
{
|
239
|
+
//calculate the mirror position of the virtual touch
|
240
|
+
var pageX = this._pinchCenter.pageX + this._pinchCenter.pageX - evt.pageX ,
|
241
|
+
pageY = this._pinchCenter.pageY + this._pinchCenter.pageY - evt.pageY,
|
242
|
+
screenX = this._pinchCenter.screenX + this._pinchCenter.screenX - evt.screenX,
|
243
|
+
screenY = this._pinchCenter.screenY + this._pinchCenter.screenY - evt.screenY,
|
244
|
+
clientX = this._pinchCenter.clientX + this._pinchCenter.clientX - evt.clientX,
|
245
|
+
clientY = this._pinchCenter.clientY + this._pinchCenter.clientY - evt.clientY,
|
246
|
+
virtualTouchIdentifier = this._simtouch_counter + 1;
|
247
|
+
|
248
|
+
virtualTouch = {
|
249
|
+
type: type,
|
250
|
+
target: evt.target,
|
251
|
+
identifier: virtualTouchIdentifier,
|
252
|
+
pageX: pageX,
|
253
|
+
pageY: pageY,
|
254
|
+
screenX: screenX,
|
255
|
+
screenY: screenY,
|
256
|
+
clientX: clientX,
|
257
|
+
clientY: clientY
|
258
|
+
};
|
259
|
+
|
260
|
+
evt.touches = [ realTouch , virtualTouch];
|
261
|
+
}
|
262
|
+
evt.changedTouches = evt.touches;
|
207
263
|
|
208
|
-
evt.changedTouches = evt.touches = [ touch ];
|
209
264
|
return evt;
|
210
265
|
},
|
211
266
|
|
@@ -607,7 +607,7 @@ SC.RenderContext = SC.Builder.create(/** SC.RenderContext.fn */ {
|
|
607
607
|
*/
|
608
608
|
addClass: function(nameOrClasses) {
|
609
609
|
if(nameOrClasses === undefined || nameOrClasses === null) {
|
610
|
-
|
610
|
+
SC.Logger.warn('You are adding an undefined or empty class'+ this.toString());
|
611
611
|
return this;
|
612
612
|
}
|
613
613
|
|
@@ -804,7 +804,7 @@ SC.RenderContext = SC.Builder.create(/** SC.RenderContext.fn */ {
|
|
804
804
|
this._styles = {};
|
805
805
|
} else {
|
806
806
|
if (this._cloneStyles) {
|
807
|
-
this._styles = SC.
|
807
|
+
this._styles = SC.clone(this._styles);
|
808
808
|
this._cloneStyles = NO ;
|
809
809
|
}
|
810
810
|
}
|
@@ -1953,7 +1953,7 @@ SC.RootResponder = SC.Object.extend({
|
|
1953
1953
|
var view = this.targetViewForEvent(evt) ;
|
1954
1954
|
this.sendEvent('animationDidStart', evt, view) ;
|
1955
1955
|
} catch (e) {
|
1956
|
-
|
1956
|
+
SC.Logger.warn('Exception during animationDidStart: %@'.fmt(e)) ;
|
1957
1957
|
throw e;
|
1958
1958
|
}
|
1959
1959
|
|
@@ -1965,7 +1965,7 @@ SC.RootResponder = SC.Object.extend({
|
|
1965
1965
|
var view = this.targetViewForEvent(evt) ;
|
1966
1966
|
this.sendEvent('animationDidIterate', evt, view) ;
|
1967
1967
|
} catch (e) {
|
1968
|
-
|
1968
|
+
SC.Logger.warn('Exception during animationDidIterate: %@'.fmt(e)) ;
|
1969
1969
|
throw e;
|
1970
1970
|
}
|
1971
1971
|
|
@@ -1977,7 +1977,7 @@ SC.RootResponder = SC.Object.extend({
|
|
1977
1977
|
var view = this.targetViewForEvent(evt) ;
|
1978
1978
|
this.sendEvent('animationDidEnd', evt, view) ;
|
1979
1979
|
} catch (e) {
|
1980
|
-
|
1980
|
+
SC.Logger.warn('Exception during animationDidEnd: %@'.fmt(e)) ;
|
1981
1981
|
throw e;
|
1982
1982
|
}
|
1983
1983
|
|
@@ -1989,7 +1989,7 @@ SC.RootResponder = SC.Object.extend({
|
|
1989
1989
|
var view = this.targetViewForEvent(evt) ;
|
1990
1990
|
this.sendEvent('transitionDidEnd', evt, view) ;
|
1991
1991
|
} catch (e) {
|
1992
|
-
|
1992
|
+
SC.Logger.warn('Exception during transitionDidEnd: %@'.fmt(e)) ;
|
1993
1993
|
throw e;
|
1994
1994
|
}
|
1995
1995
|
|
@@ -0,0 +1,32 @@
|
|
1
|
+
var realMainFunction, realApplicationMode, timesMainCalled;
|
2
|
+
module("SC.onReady.done", {
|
3
|
+
setup: function() {
|
4
|
+
timesMainCalled = 0;
|
5
|
+
|
6
|
+
realMainFunction = window.main;
|
7
|
+
window.main = function() {
|
8
|
+
timesMainCalled += 1;
|
9
|
+
};
|
10
|
+
|
11
|
+
realApplicationMode = SC.mode;
|
12
|
+
},
|
13
|
+
|
14
|
+
teardown: function() {
|
15
|
+
window.main = realMainFunction;
|
16
|
+
SC.mode = realApplicationMode;
|
17
|
+
}
|
18
|
+
});
|
19
|
+
|
20
|
+
test("When the application is done loading in test mode", function() {
|
21
|
+
SC.mode = SC.TEST_MODE;
|
22
|
+
SC.onReady.done();
|
23
|
+
|
24
|
+
equals(timesMainCalled, 0, "main should not have been called");
|
25
|
+
});
|
26
|
+
|
27
|
+
test("When the application is done loading in application mode", function() {
|
28
|
+
SC.mode = SC.APP_MODE;
|
29
|
+
SC.onReady.done();
|
30
|
+
|
31
|
+
equals(timesMainCalled, 1, "main should have been called");
|
32
|
+
});
|
@@ -6,12 +6,13 @@
|
|
6
6
|
|
7
7
|
var pane, view1, view2, view3, view4;
|
8
8
|
|
9
|
-
htmlbody('<style> body { height: 1500px; width: 1500px; } </style>');
|
10
9
|
|
11
10
|
|
12
11
|
module("SC.offset", {
|
13
12
|
|
14
13
|
setup: function() {
|
14
|
+
htmlbody('<style> body { height: 1500px; width: 1500px; } </style>');
|
15
|
+
|
15
16
|
var viewportEl;
|
16
17
|
|
17
18
|
SC.RunLoop.begin();
|
@@ -75,6 +76,8 @@ module("SC.offset", {
|
|
75
76
|
pane.remove();
|
76
77
|
pane = view1 = view2 = view3 = view4 = null;
|
77
78
|
// }
|
79
|
+
|
80
|
+
clearHtmlbody();
|
78
81
|
}
|
79
82
|
});
|
80
83
|
|
@@ -265,4 +268,4 @@ test("A regular view with window scroll offset top:100, left: 100", function() {
|
|
265
268
|
SC.RunLoop.begin();
|
266
269
|
SC.Timer.schedule({ target: this, action: function() { return testPosition4(element1, element2, element3, element4); }, interval: 200 });
|
267
270
|
SC.RunLoop.end();
|
268
|
-
});
|
271
|
+
});
|
@@ -6,12 +6,17 @@
|
|
6
6
|
|
7
7
|
/*global module test equals context ok same Q$ htmlbody */
|
8
8
|
|
9
|
-
htmlbody('<div id="appendtest"></div>');
|
10
|
-
|
11
9
|
// ..........................................................
|
12
10
|
// appendTo()
|
13
11
|
//
|
14
|
-
module("SC.Pane#appendTo"
|
12
|
+
module("SC.Pane#appendTo", {
|
13
|
+
setup: function(){
|
14
|
+
htmlbody('<div id="appendtest"></div>');
|
15
|
+
},
|
16
|
+
teardown: function(){
|
17
|
+
clearHtmlbody()
|
18
|
+
}
|
19
|
+
});
|
15
20
|
|
16
21
|
test("adding to document for first time - appendTo(elem)", function() {
|
17
22
|
var pane = SC.Pane.create();
|
@@ -22,10 +22,10 @@ module("SC.Pane#layout", {
|
|
22
22
|
});
|
23
23
|
|
24
24
|
test("make sure that a call to adjust actually adjusts the view's size", function() {
|
25
|
-
SC.
|
26
|
-
|
27
|
-
|
28
|
-
|
25
|
+
SC.RunLoop.begin();
|
26
|
+
pane.adjust({ width: 100, height: 50 });
|
27
|
+
SC.RunLoop.end();
|
28
|
+
|
29
29
|
equals(pane.$()[0].style.width, '100px', 'width should have been adjusted');
|
30
30
|
equals(pane.$()[0].style.height, '50px', 'height should have been adjusted');
|
31
31
|
});
|
data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/template_view/collection.js
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
module("SC.TemplateCollectionView");
|
2
2
|
|
3
|
+
TemplateTests = {};
|
4
|
+
|
3
5
|
test("creating a collection view works", function() {
|
4
6
|
var ExampleView = SC.TemplateView.extend({
|
5
7
|
tagName: 'li',
|
@@ -36,30 +38,74 @@ test("a block passed to a collection helper defaults to the content property of
|
|
36
38
|
});
|
37
39
|
|
38
40
|
var view = SC.TemplateView.create({
|
39
|
-
template: SC.Handlebars.compile('{{#collection "TemplateTests.CollectionTestView"}} <aside>{{
|
41
|
+
template: SC.Handlebars.compile('{{#collection "TemplateTests.CollectionTestView"}} <aside>{{content}}</aside> {{/collection}}')
|
40
42
|
});
|
41
43
|
|
42
44
|
view.createLayer();
|
45
|
+
|
43
46
|
equals(view.$('li:has(aside:contains("foo")) + li:has(aside:contains("bar")) + li:has(aside:contains("baz"))').length, 1, 'one aside element is created for each content item');
|
44
47
|
});
|
45
48
|
|
46
|
-
test("a block passed to a collection helper defaults to the
|
49
|
+
test("a block passed to a collection helper defaults to the view", function() {
|
47
50
|
TemplateTests.CollectionTestView = SC.TemplateCollectionView.create({
|
48
51
|
content: ['foo', 'bar', 'baz']
|
49
52
|
});
|
50
53
|
|
51
54
|
var view = SC.TemplateView.create({
|
52
|
-
template: SC.Handlebars.compile('{{#collection "TemplateTests.CollectionTestView"}} <aside>{{
|
55
|
+
template: SC.Handlebars.compile('{{#collection "TemplateTests.CollectionTestView"}} <aside>{{content}}</aside> {{/collection}}')
|
53
56
|
});
|
54
57
|
|
55
58
|
view.createLayer();
|
56
59
|
equals(view.$('li:has(aside:contains("foo")) + li:has(aside:contains("bar")) + li:has(aside:contains("baz"))').length, 1, 'precond - one aside element is created for each content item');
|
57
60
|
|
58
|
-
window.billy = true;
|
59
|
-
|
60
61
|
SC.run(function() {
|
61
62
|
TemplateTests.CollectionTestView.set('content', []);
|
62
63
|
});
|
63
64
|
equals(view.$('aside').length, 0, "all list item views should be removed from DOM");
|
64
65
|
});
|
65
66
|
|
67
|
+
test("should include an id attribute if id is set in the options hash", function() {
|
68
|
+
var view = SC.TemplateView.create({
|
69
|
+
template: SC.Handlebars.compile('{{#collection "TemplateTests.CollectionTestView" id="baz"}}foo{{/collection}}')
|
70
|
+
});
|
71
|
+
|
72
|
+
view.createLayer();
|
73
|
+
equals(view.$('ul#baz').length, 1, "adds an id attribute");
|
74
|
+
});
|
75
|
+
|
76
|
+
test("should give its item views the class specified by itemClass", function() {
|
77
|
+
TemplateTests.itemClassTestCollectionView = SC.TemplateCollectionView.create({
|
78
|
+
content: ['foo', 'bar', 'baz']
|
79
|
+
});
|
80
|
+
var view = SC.TemplateView.create({
|
81
|
+
template: SC.Handlebars.compile('{{#collection "TemplateTests.itemClassTestCollectionView" itemClass="baz"}}foo{{/collection}}')
|
82
|
+
});
|
83
|
+
|
84
|
+
view.createLayer();
|
85
|
+
equals(view.$('ul li.baz').length, 3, "adds class attribute");
|
86
|
+
});
|
87
|
+
|
88
|
+
test("should give its item views the classBinding specified by itemClassBinding", function() {
|
89
|
+
TemplateTests.itemClassBindingTestCollectionView = SC.TemplateCollectionView.create({
|
90
|
+
content: [SC.Object.create({ isBaz: false }), SC.Object.create({ isBaz: true }), SC.Object.create({ isBaz: true })]
|
91
|
+
});
|
92
|
+
var view = SC.TemplateView.create({
|
93
|
+
template: SC.Handlebars.compile('{{#collection "TemplateTests.itemClassBindingTestCollectionView" itemClassBinding="content.isBaz"}}foo{{/collection}}')
|
94
|
+
});
|
95
|
+
|
96
|
+
view.createLayer();
|
97
|
+
equals(view.$('ul li.is-baz').length, 2, "adds class on initial rendering");
|
98
|
+
|
99
|
+
SC.run(function() {
|
100
|
+
TemplateTests.itemClassBindingTestCollectionView.setPath('content.0.isBaz', true);
|
101
|
+
});
|
102
|
+
|
103
|
+
equals(view.$('ul li.is-baz').length, 3, "adds class when property changes");
|
104
|
+
|
105
|
+
SC.run(function() {
|
106
|
+
TemplateTests.itemClassBindingTestCollectionView.setPath('content.0.isBaz', false);
|
107
|
+
});
|
108
|
+
|
109
|
+
equals(view.$('ul li.is-baz').length, 2, "removes class when property changes");
|
110
|
+
});
|
111
|
+
|
@@ -65,3 +65,21 @@ test("template views return YES to mouseDown if there is a mouseUp method", func
|
|
65
65
|
|
66
66
|
ok(view.tryToPerform('mouseDown'), "view returns YES if we add a mouseUp method");
|
67
67
|
});
|
68
|
+
|
69
|
+
test("should add a 'hidden' class to a template view when isVisible is true", function() {
|
70
|
+
var view = SC.TemplateView.create();
|
71
|
+
|
72
|
+
ok(view.get('isVisible'), "precond - views default to being visible");
|
73
|
+
|
74
|
+
view.set('template', function() { return "foo"; });
|
75
|
+
|
76
|
+
view.createLayer();
|
77
|
+
ok(!view.$().hasClass('hidden'), "does not have hidden class applied");
|
78
|
+
|
79
|
+
SC.run(function() { view.set('isVisible', NO); });
|
80
|
+
ok(view.$().hasClass('hidden'), "adds hidden class when isVisible changes to NO");
|
81
|
+
|
82
|
+
SC.run(function() { view.set('isVisible', YES); });
|
83
|
+
ok(!view.$().hasClass('hidden'), "removes hidden class when isVisible changes to YES");
|
84
|
+
});
|
85
|
+
|
data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/template_view/handlebars.js
CHANGED
@@ -72,6 +72,22 @@ test("child views can be inserted using the {{view}} Handlebars helper", functio
|
|
72
72
|
|
73
73
|
});
|
74
74
|
|
75
|
+
test("should accept relative paths to views", function() {
|
76
|
+
var view = SC.TemplateView.create({
|
77
|
+
template: SC.Handlebars.compile('Hey look, at {{view ".myCool.view"}}'),
|
78
|
+
|
79
|
+
myCool: SC.Object.create({
|
80
|
+
view: SC.TemplateView.create({
|
81
|
+
template: SC.Handlebars.compile("my cool view")
|
82
|
+
})
|
83
|
+
})
|
84
|
+
});
|
85
|
+
|
86
|
+
view.createLayer();
|
87
|
+
|
88
|
+
equals(view.$().text(), "Hey look, at my cool view");
|
89
|
+
});
|
90
|
+
|
75
91
|
test("child views can be inserted inside a bind block", function() {
|
76
92
|
var templates = SC.Object.create({
|
77
93
|
nester: SC.Handlebars.compile("<h1 id='hello-world'>Hello {{world}}</h1>{{view \"TemplateTests.LabelView\"}}"),
|
@@ -131,6 +147,56 @@ test("SC.TemplateView updates when a property changes", function() {
|
|
131
147
|
equals(view.$('#first').text(), "bazam", "view updates when a bound property changes");
|
132
148
|
});
|
133
149
|
|
150
|
+
test("should not update when a property is removed from the view", function() {
|
151
|
+
var templates = SC.Object.create({
|
152
|
+
foo: SC.Handlebars.compile('<h1 id="first">{{#bind "content"}}{{#bind "foo"}}{{bind "baz"}}{{/bind}}{{/bind}}</h1>')
|
153
|
+
});
|
154
|
+
var removeCalled = 0;
|
155
|
+
|
156
|
+
var view = SC.TemplateView.create({
|
157
|
+
templateName: 'foo',
|
158
|
+
templates: templates,
|
159
|
+
|
160
|
+
content: SC.Object.create({
|
161
|
+
foo: SC.Object.create({
|
162
|
+
baz: "unicorns",
|
163
|
+
|
164
|
+
removeObserver: function(property, func) {
|
165
|
+
sc_super();
|
166
|
+
removeCalled++;
|
167
|
+
}
|
168
|
+
})
|
169
|
+
})
|
170
|
+
});
|
171
|
+
|
172
|
+
view.createLayer();
|
173
|
+
|
174
|
+
equals(view.$('#first').text(), "unicorns", "precond - renders the bound value");
|
175
|
+
|
176
|
+
var oldContent = view.get('content');
|
177
|
+
|
178
|
+
SC.run(function() {
|
179
|
+
view.set('content', SC.Object.create({
|
180
|
+
foo: SC.Object.create({
|
181
|
+
baz: "ninjas"
|
182
|
+
})
|
183
|
+
}));
|
184
|
+
});
|
185
|
+
|
186
|
+
equals(view.$('#first').text(), 'ninjas', "updates to new content value");
|
187
|
+
|
188
|
+
SC.run(function() {
|
189
|
+
oldContent.setPath('foo.baz', 'rockstars');
|
190
|
+
});
|
191
|
+
|
192
|
+
SC.run(function() {
|
193
|
+
oldContent.setPath('foo.baz', 'ewoks');
|
194
|
+
});
|
195
|
+
|
196
|
+
equals(removeCalled, 1, "does not try to remove observer more than once");
|
197
|
+
equals(view.$('#first').text(), "ninjas", "does not update removed object");
|
198
|
+
});
|
199
|
+
|
134
200
|
|
135
201
|
test("Handlebars templates update properties if a content object changes", function() {
|
136
202
|
var templates;
|
@@ -175,6 +241,90 @@ test("Handlebars templates update properties if a content object changes", funct
|
|
175
241
|
equals(view.$('#price').text(), "$5", "should update price field when price property is changed");
|
176
242
|
});
|
177
243
|
|
244
|
+
test("Template updates correctly if a path is passed to the bind helper", function() {
|
245
|
+
var templates;
|
246
|
+
|
247
|
+
templates = SC.Object.create({
|
248
|
+
menu: SC.Handlebars.compile('<h1>{{bind "coffee.price"}}</h1>')
|
249
|
+
});
|
250
|
+
|
251
|
+
var view = SC.TemplateView.create({
|
252
|
+
templateName: 'menu',
|
253
|
+
templates: templates,
|
254
|
+
|
255
|
+
coffee: SC.Object.create({
|
256
|
+
price: '$4'
|
257
|
+
})
|
258
|
+
});
|
259
|
+
|
260
|
+
view.createLayer();
|
261
|
+
|
262
|
+
equals(view.$('h1').text(), "$4", "precond - renders price");
|
263
|
+
|
264
|
+
view.setPath('coffee.price', "$5");
|
265
|
+
|
266
|
+
equals(view.$('h1').text(), "$5", "updates when property changes");
|
267
|
+
|
268
|
+
view.set('coffee', { price: "$6" });
|
269
|
+
equals(view.$('h1').text(), "$6", "updates when parent property changes");
|
270
|
+
});
|
271
|
+
|
272
|
+
test("Template updates correctly if a path is passed to the bind helper and the context object is an SC.ObjectController", function() {
|
273
|
+
var templates;
|
274
|
+
|
275
|
+
templates = SC.Object.create({
|
276
|
+
menu: SC.Handlebars.compile('<h1>{{bind "coffee.price"}}</h1>')
|
277
|
+
});
|
278
|
+
|
279
|
+
var controller = SC.ObjectController.create();
|
280
|
+
var realObject = SC.Object.create({
|
281
|
+
price: "$4"
|
282
|
+
});
|
283
|
+
|
284
|
+
controller.set('content', realObject);
|
285
|
+
|
286
|
+
var view = SC.TemplateView.create({
|
287
|
+
templateName: 'menu',
|
288
|
+
templates: templates,
|
289
|
+
|
290
|
+
coffee: controller
|
291
|
+
});
|
292
|
+
|
293
|
+
view.createLayer();
|
294
|
+
|
295
|
+
equals(view.$('h1').text(), "$4", "precond - renders price");
|
296
|
+
|
297
|
+
realObject.set('price', "$5");
|
298
|
+
|
299
|
+
equals(view.$('h1').text(), "$5", "updates when property is set on real object");
|
300
|
+
|
301
|
+
SC.run(function() {
|
302
|
+
controller.set('price', "$6" );
|
303
|
+
});
|
304
|
+
|
305
|
+
equals(view.$('h1').text(), "$6", "updates when property is set on object controller");
|
306
|
+
});
|
307
|
+
|
308
|
+
test("Should insert a localized string if the {{loc}} helper is used", function() {
|
309
|
+
SC.stringsFor('en', {
|
310
|
+
'Brazil': 'Brasilia'
|
311
|
+
});
|
312
|
+
|
313
|
+
templates = SC.Object.create({
|
314
|
+
'loc': SC.Handlebars.compile('<h1>Country: {{loc "Brazil"}}')
|
315
|
+
});
|
316
|
+
|
317
|
+
var view = SC.TemplateView.create({
|
318
|
+
templateName: 'loc',
|
319
|
+
templates: templates,
|
320
|
+
|
321
|
+
country: 'Brazil'
|
322
|
+
});
|
323
|
+
|
324
|
+
view.createLayer();
|
325
|
+
equals(view.$('h1').text(), 'Country: Brasilia', "returns localized value");
|
326
|
+
});
|
327
|
+
|
178
328
|
test("Template views return a no-op function if their template cannot be found", function() {
|
179
329
|
var view = SC.TemplateView.create({
|
180
330
|
templateName: 'cantBeFound'
|
@@ -293,3 +443,114 @@ test("Collection views that specify an example view class have their children be
|
|
293
443
|
|
294
444
|
ok(parentView.childViews[0].childViews[0].isCustom, "uses the example view class");
|
295
445
|
});
|
446
|
+
|
447
|
+
test("should update boundIf blocks if the conditional changes", function() {
|
448
|
+
var templates = SC.Object.create({
|
449
|
+
foo: SC.Handlebars.compile('<h1 id="first">{{#boundIf "content.myApp.isEnabled"}}{{content.wham}}{{/boundIf}}</h1>')
|
450
|
+
});
|
451
|
+
|
452
|
+
var view = SC.TemplateView.create({
|
453
|
+
templateName: 'foo',
|
454
|
+
templates: templates,
|
455
|
+
|
456
|
+
content: SC.Object.create({
|
457
|
+
wham: 'bam',
|
458
|
+
thankYou: "ma'am",
|
459
|
+
myApp: SC.Object.create({
|
460
|
+
isEnabled: YES
|
461
|
+
})
|
462
|
+
})
|
463
|
+
});
|
464
|
+
|
465
|
+
view.createLayer();
|
466
|
+
|
467
|
+
equals(view.$('#first').text(), "bam", "renders block when condition is true");
|
468
|
+
|
469
|
+
SC.run(function() { view.get('content').setPath('myApp.isEnabled', NO); });
|
470
|
+
|
471
|
+
equals(view.$('#first').text(), "", "re-renders without block when condition is false");
|
472
|
+
});
|
473
|
+
|
474
|
+
test("{{view}} id attribute should set id on layer", function() {
|
475
|
+
var templates = SC.Object.create({
|
476
|
+
foo: SC.Handlebars.compile('{{#view "TemplateTests.IdView" id="bar"}}baz{{/view}}')
|
477
|
+
});
|
478
|
+
|
479
|
+
TemplateTests.IdView = SC.TemplateView.create();
|
480
|
+
|
481
|
+
var view = SC.TemplateView.create({
|
482
|
+
templateName: 'foo',
|
483
|
+
templates: templates
|
484
|
+
});
|
485
|
+
|
486
|
+
view.createLayer();
|
487
|
+
|
488
|
+
equals(view.$('#bar').length, 1, "adds id attribute to layer");
|
489
|
+
equals(view.$('#bar').text(), 'baz', "emits content");
|
490
|
+
});
|
491
|
+
|
492
|
+
test("{{view}} class attribute should set class on layer", function() {
|
493
|
+
var templates = SC.Object.create({
|
494
|
+
foo: SC.Handlebars.compile('{{#view "TemplateTests.IdView" class="bar"}}baz{{/view}}')
|
495
|
+
});
|
496
|
+
|
497
|
+
TemplateTests.IdView = SC.TemplateView.create();
|
498
|
+
|
499
|
+
var view = SC.TemplateView.create({
|
500
|
+
templateName: 'foo',
|
501
|
+
templates: templates
|
502
|
+
});
|
503
|
+
|
504
|
+
view.createLayer();
|
505
|
+
|
506
|
+
equals(view.$('.bar').length, 1, "adds class attribute to layer");
|
507
|
+
equals(view.$('.bar').text(), 'baz', "emits content");
|
508
|
+
});
|
509
|
+
|
510
|
+
test("should be able to bind view class names to properties", function() {
|
511
|
+
var templates = SC.Object.create({
|
512
|
+
template: SC.Handlebars.compile('{{#view "TemplateTests.classBindingView" classBinding="isDone"}}foo{{/view}}')
|
513
|
+
});
|
514
|
+
|
515
|
+
TemplateTests.classBindingView = SC.TemplateView.create({
|
516
|
+
isDone: YES
|
517
|
+
});
|
518
|
+
|
519
|
+
var view = SC.TemplateView.create({
|
520
|
+
templateName: 'template',
|
521
|
+
templates: templates
|
522
|
+
});
|
523
|
+
|
524
|
+
view.createLayer();
|
525
|
+
|
526
|
+
equals(view.$('.is-done').length, 1, "dasherizes property and sets class name");
|
527
|
+
|
528
|
+
SC.run(function() {
|
529
|
+
TemplateTests.classBindingView.set('isDone', NO);
|
530
|
+
});
|
531
|
+
|
532
|
+
equals(view.$('.is-done').length, 0, "removes class name if bound property is set to false");
|
533
|
+
});
|
534
|
+
|
535
|
+
test("should be able to bind element attributes using {{bindAttr}}", function() {
|
536
|
+
var template = SC.Handlebars.compile('<img {{bindAttr src="content.url" alt="content.title"}}>');
|
537
|
+
|
538
|
+
var view = SC.TemplateView.create({
|
539
|
+
template: template,
|
540
|
+
content: SC.Object.create({
|
541
|
+
url: "http://www.sproutcore.com/assets/images/logo.png",
|
542
|
+
title: "The SproutCore Logo"
|
543
|
+
})
|
544
|
+
});
|
545
|
+
|
546
|
+
view.createLayer();
|
547
|
+
|
548
|
+
equals(view.$('img').attr('src'), "http://www.sproutcore.com/assets/images/logo.png", "sets src attribute");
|
549
|
+
equals(view.$('img').attr('alt'), "The SproutCore Logo", "sets alt attribute");
|
550
|
+
|
551
|
+
SC.run(function() {
|
552
|
+
view.setPath('content.title', "El logo de Esproutcore");
|
553
|
+
});
|
554
|
+
|
555
|
+
equals(view.$('img').attr('alt'), "El logo de Esproutcore", "updates alt attribute when content's title attribute changes");
|
556
|
+
});
|