sproutcore 1.6.0.1-java → 1.7.1.beta-java
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +21 -0
- data/Gemfile +5 -0
- data/Rakefile +26 -13
- data/VERSION.yml +2 -2
- data/lib/Buildfile +43 -4
- data/lib/buildtasks/build.rake +10 -0
- data/lib/buildtasks/helpers/file_rule.rb +22 -0
- data/lib/buildtasks/helpers/file_rule_list.rb +137 -0
- data/lib/buildtasks/manifest.rake +133 -122
- data/lib/frameworks/sproutcore/CHANGELOG.md +69 -2
- data/lib/frameworks/sproutcore/apps/tests/english.lproj/strings.js +1 -0
- data/lib/frameworks/sproutcore/frameworks/bootstrap/system/browser.js +28 -22
- data/lib/frameworks/sproutcore/frameworks/core_foundation/controllers/array.js +9 -5
- data/lib/frameworks/sproutcore/frameworks/core_foundation/controllers/controller.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/core_foundation/controls/button.js +18 -13
- data/lib/frameworks/sproutcore/frameworks/core_foundation/ext/handlebars/bind.js +5 -3
- data/lib/frameworks/sproutcore/frameworks/core_foundation/ext/handlebars/collection.js +2 -0
- data/lib/frameworks/sproutcore/frameworks/core_foundation/mixins/action_support.js +80 -0
- data/lib/frameworks/sproutcore/frameworks/core_foundation/mixins/template_helpers/text_field_support.js +84 -116
- data/lib/frameworks/sproutcore/frameworks/core_foundation/panes/pane.js +8 -5
- data/lib/frameworks/sproutcore/frameworks/core_foundation/system/event.js +157 -157
- data/lib/frameworks/sproutcore/frameworks/core_foundation/system/platform.js +5 -3
- data/lib/frameworks/sproutcore/frameworks/core_foundation/system/root_responder.js +6 -6
- data/lib/frameworks/sproutcore/frameworks/core_foundation/system/sparse_array.js +10 -7
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/mixins/action_support.js +106 -0
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/template/collection.js +18 -0
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/template/handlebars.js +71 -1
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/attribute_bindings_test.js +38 -0
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/class_name_bindings_test.js +47 -0
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/layoutChildViews.js +18 -18
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/layoutStyle.js +42 -10
- data/lib/frameworks/sproutcore/frameworks/core_foundation/views/view.js +158 -1
- data/lib/frameworks/sproutcore/frameworks/core_foundation/views/view/keyboard.js +26 -1
- data/lib/frameworks/sproutcore/frameworks/core_foundation/views/view/layout_style.js +14 -8
- data/lib/frameworks/sproutcore/frameworks/datastore/models/record.js +15 -2
- data/lib/frameworks/sproutcore/frameworks/datastore/models/record_attribute.js +108 -108
- data/lib/frameworks/sproutcore/frameworks/datastore/system/query.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/datastore/system/record_array.js +2 -4
- data/lib/frameworks/sproutcore/frameworks/datastore/tests/models/record/error_methods.js +2 -2
- data/lib/frameworks/sproutcore/frameworks/datastore/tests/models/single_attribute.js +26 -0
- data/lib/frameworks/sproutcore/frameworks/datastore/tests/system/query/builders.js +7 -0
- data/lib/frameworks/sproutcore/frameworks/datastore/tests/system/record_array/error_methods.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/datetime/frameworks/core/system/datetime.js +4 -1
- data/lib/frameworks/sproutcore/frameworks/datetime/frameworks/core/tests/system/datetime.js +6 -0
- data/lib/frameworks/sproutcore/frameworks/desktop/panes/menu.js +26 -5
- data/lib/frameworks/sproutcore/frameworks/desktop/panes/picker.js +97 -96
- data/lib/frameworks/sproutcore/frameworks/desktop/system/drag.js +4 -3
- data/lib/frameworks/sproutcore/frameworks/desktop/tests/panes/menu/ui.js +17 -4
- data/lib/frameworks/sproutcore/frameworks/desktop/views/collection.js +7 -7
- data/lib/frameworks/sproutcore/frameworks/desktop/views/menu_item.js +7 -5
- data/lib/frameworks/sproutcore/frameworks/desktop/views/scroll.js +12 -3
- data/lib/frameworks/sproutcore/frameworks/desktop/views/web.js +23 -14
- data/lib/frameworks/sproutcore/frameworks/experimental/Buildfile +5 -1
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/menu/render_delegates/menu_scroller.js +28 -0
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/menu/tests/menu/scroll.js +235 -0
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/menu/views/menu/scroll.js +363 -0
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/menu/views/menu/scroller.js +250 -0
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/scroll_view/render_delegates/desktop_scroller.js +92 -0
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/scroll_view/render_delegates/native_scroll.js +25 -0
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/scroll_view/render_delegates/scroll.js +33 -0
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/scroll_view/render_delegates/touch_scroller.js +76 -0
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/scroll_view/tests/scroll/integration.js +50 -0
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/scroll_view/tests/scroll/methods.js +143 -0
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/scroll_view/tests/scroll/ui.js +258 -0
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/scroll_view/views/core_scroll.js +1164 -0
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/scroll_view/views/core_scroller.js +332 -0
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/scroll_view/views/desktop/scroll.js +236 -0
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/scroll_view/views/desktop/scroller.js +347 -0
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/scroll_view/views/scroll.js +15 -0
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/scroll_view/views/scroller.js +10 -0
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/scroll_view/views/touch/scroll.js +804 -0
- data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/scroll_view/views/touch/scroller.js +133 -0
- data/lib/frameworks/sproutcore/frameworks/foundation/resources/text_field.css +3 -3
- data/lib/frameworks/sproutcore/frameworks/foundation/validators/number.js +3 -1
- data/lib/frameworks/sproutcore/frameworks/foundation/views/text_field.js +3 -3
- data/lib/frameworks/sproutcore/frameworks/media/views/audio.js +2 -1
- data/lib/frameworks/sproutcore/frameworks/media/views/controls.js +2 -1
- data/lib/frameworks/sproutcore/frameworks/media/views/media_slider.js +2 -4
- data/lib/frameworks/sproutcore/frameworks/media/views/mini_controls.js +2 -4
- data/lib/frameworks/sproutcore/frameworks/media/views/simple_controls.js +2 -4
- data/lib/frameworks/sproutcore/frameworks/media/views/video.js +2 -2
- data/lib/frameworks/sproutcore/frameworks/routing/system/routes.js +29 -3
- data/lib/frameworks/sproutcore/frameworks/runtime/core.js +2 -2
- data/lib/frameworks/sproutcore/frameworks/runtime/debug/test_suites/array/replace.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/runtime/private/property_chain.js +2 -1
- data/lib/frameworks/sproutcore/frameworks/runtime/system/binding.js +3 -3
- data/lib/frameworks/sproutcore/frameworks/runtime/system/index_set.js +2 -2
- data/lib/frameworks/sproutcore/frameworks/runtime/system/object.js +1 -1
- data/lib/frameworks/sproutcore/themes/ace/resources/collection/normal/list_item.css +2 -2
- data/lib/frameworks/sproutcore/themes/legacy_theme/english.lproj/segmented.css +1 -1
- data/lib/gen/app/templates/apps/@target_name@/Buildfile +3 -5
- data/lib/gen/app/templates/apps/@target_name@/resources/_theme.css +18 -0
- data/lib/gen/project/templates/@filename@/Buildfile +2 -2
- data/lib/sproutcore.rb +30 -5
- data/lib/sproutcore/builders.rb +1 -0
- data/lib/sproutcore/builders/chance_file.rb +9 -16
- data/lib/sproutcore/builders/html.rb +2 -1
- data/lib/sproutcore/builders/minify.rb +4 -35
- data/lib/sproutcore/builders/module.rb +38 -1
- data/lib/sproutcore/builders/split.rb +63 -0
- data/lib/sproutcore/builders/strings.rb +7 -1
- data/lib/sproutcore/helpers.rb +1 -1
- data/lib/sproutcore/helpers/css_split.rb +190 -0
- data/lib/sproutcore/helpers/entry_sorter.rb +2 -0
- data/lib/sproutcore/helpers/minifier.rb +40 -16
- data/lib/sproutcore/helpers/static_helper.rb +35 -17
- data/lib/sproutcore/models/manifest.rb +26 -0
- data/lib/sproutcore/models/target.rb +12 -1
- data/lib/sproutcore/rack.rb +1 -0
- data/lib/sproutcore/rack/proxy.rb +244 -225
- data/lib/sproutcore/rack/restrict_ip.rb +67 -0
- data/lib/sproutcore/rack/service.rb +8 -2
- data/lib/sproutcore/tools.rb +102 -46
- data/lib/sproutcore/tools/build.rb +91 -43
- data/lib/sproutcore/tools/gen.rb +2 -3
- data/lib/sproutcore/tools/manifest.rb +22 -16
- data/lib/sproutcore/tools/server.rb +21 -0
- data/spec/buildtasks/helpers/accept_list +22 -0
- data/spec/buildtasks/helpers/accept_list.rb +128 -0
- data/spec/buildtasks/helpers/list.json +11 -0
- data/spec/buildtasks/manifest/prepare_build_tasks/chance_2x_spec.rb +1 -39
- data/spec/buildtasks/manifest/prepare_build_tasks/chance_spec.rb +0 -38
- data/spec/buildtasks/manifest/prepare_build_tasks/combine_spec.rb +4 -4
- data/spec/buildtasks/manifest/prepare_build_tasks/module_spec.rb +2 -2
- data/spec/buildtasks/manifest/prepare_build_tasks/packed_2x_indirect_spec.rb +7 -16
- data/spec/buildtasks/manifest/prepare_build_tasks/packed_2x_spec.rb +7 -17
- data/spec/buildtasks/manifest/prepare_build_tasks/packed_spec.rb +11 -6
- data/spec/fixtures/builder_tests/Buildfile +2 -1
- data/spec/fixtures/builder_tests/apps/module_test/modules/required_module/core.js +0 -0
- data/spec/lib/builders/module_spec.rb +1 -1
- data/spec/spec_helper.rb +1 -0
- data/sproutcore.gemspec +4 -9
- data/vendor/chance/lib/chance.rb +25 -6
- data/vendor/chance/lib/chance/factory.rb +45 -0
- data/vendor/chance/lib/chance/instance.rb +173 -28
- data/vendor/chance/lib/chance/instance/data_url.rb +0 -29
- data/vendor/chance/lib/chance/instance/slicing.rb +57 -4
- data/vendor/chance/lib/chance/instance/spriting.rb +112 -21
- data/vendor/chance/lib/chance/parser.rb +80 -52
- data/vendor/sproutcore/SCCompiler.jar +0 -0
- data/vendor/sproutcore/lib/args4j-2.0.12.jar +0 -0
- data/vendor/sproutcore/lib/yuicompressor-2.4.2.jar +0 -0
- metadata +84 -25
@@ -20,14 +20,16 @@ SC.platform = SC.Object.create({
|
|
20
20
|
@property
|
21
21
|
*/
|
22
22
|
scrollbarSize: function() {
|
23
|
-
var tester = document.createElement("DIV")
|
23
|
+
var tester = document.createElement("DIV"),
|
24
|
+
child;
|
24
25
|
tester.innerHTML = "<div style='height:1px;'></div>";
|
25
26
|
tester.style.cssText="position:absolute;width:100px;height:100px;overflow-y:visible;";
|
26
27
|
|
28
|
+
child = tester.childNodes[0];
|
27
29
|
document.body.appendChild(tester);
|
28
|
-
var noScroller =
|
30
|
+
var noScroller = child.innerWidth || child.clientWidth;
|
29
31
|
tester.style.overflowY = 'scroll';
|
30
|
-
var withScroller =
|
32
|
+
var withScroller = child.innerWidth || child.clientWidth;
|
31
33
|
document.body.removeChild(tester);
|
32
34
|
|
33
35
|
return noScroller-withScroller;
|
@@ -79,7 +79,7 @@ SC.RootResponder = SC.Object.extend(
|
|
79
79
|
Usually you will not need to edit the main pane directly. Instead, you
|
80
80
|
should use a MainPane subclass, which will automatically make itself main
|
81
81
|
when you append it to the document.
|
82
|
-
|
82
|
+
|
83
83
|
@type SC.MainPane
|
84
84
|
*/
|
85
85
|
mainPane: null,
|
@@ -344,7 +344,7 @@ SC.RootResponder = SC.Object.extend(
|
|
344
344
|
(removing sc-blur). Also notify panes.
|
345
345
|
*/
|
346
346
|
focus: function() {
|
347
|
-
|
347
|
+
|
348
348
|
if (!this.get('hasFocus')) {
|
349
349
|
SC.$('body').addClass('sc-focus').removeClass('sc-blur');
|
350
350
|
|
@@ -355,7 +355,7 @@ SC.RootResponder = SC.Object.extend(
|
|
355
355
|
nextValidKeyView = mainPane ? mainPane.get('nextValidKeyView') : null;
|
356
356
|
if (nextValidKeyView) mainPane.makeFirstResponder(nextValidKeyView);
|
357
357
|
}
|
358
|
-
|
358
|
+
|
359
359
|
SC.run(function() {
|
360
360
|
this.set('hasFocus', YES);
|
361
361
|
}, this);
|
@@ -904,7 +904,7 @@ SC.RootResponder = SC.Object.extend(
|
|
904
904
|
|
905
905
|
assignTouch: function(touch, view) {
|
906
906
|
// sanity-check
|
907
|
-
if (touch.hasEnded) throw "
|
907
|
+
if (touch.hasEnded) throw "Attempt to assign a touch that is already finished.";
|
908
908
|
|
909
909
|
// unassign from old view if necessary
|
910
910
|
if (touch.view === view) return;
|
@@ -1697,9 +1697,9 @@ SC.RootResponder = SC.Object.extend(
|
|
1697
1697
|
/**
|
1698
1698
|
IE's default behavior to blur textfields and other controls can only be
|
1699
1699
|
blocked by returning NO to this event. However we don't want to block
|
1700
|
-
its default behavior otherwise textfields won't
|
1700
|
+
its default behavior otherwise textfields won't lose focus by clicking on
|
1701
1701
|
an empty area as it's expected. If you want to block IE from bluring another
|
1702
|
-
control set blockIEDeactivate to true on the
|
1702
|
+
control set blockIEDeactivate to true on the specific view in which you
|
1703
1703
|
want to avoid this. Think of an autocomplete menu, you want to click on
|
1704
1704
|
the menu but don't loose focus.
|
1705
1705
|
*/
|
@@ -314,15 +314,18 @@ SC.SparseArray = SC.Object.extend(SC.Observable, SC.Enumerable, SC.Array,
|
|
314
314
|
@returns {Number} the discovered index or -1 if not found
|
315
315
|
*/
|
316
316
|
indexOf: function(obj) {
|
317
|
-
var del = this.delegate ;
|
317
|
+
var c, ret, del = this.delegate ;
|
318
318
|
if (del && del.sparseArrayDidRequestIndexOf) {
|
319
|
-
|
320
|
-
}
|
321
|
-
|
322
|
-
|
323
|
-
|
319
|
+
ret = del.sparseArrayDidRequestIndexOf(this, obj);
|
320
|
+
}
|
321
|
+
|
322
|
+
if (SC.none(ret)) {
|
323
|
+
c = this._sa_content ;
|
324
|
+
if (!c) c = this._sa_content = [] ;
|
325
|
+
ret = c.indexOf(obj) ;
|
324
326
|
}
|
325
|
-
|
327
|
+
return ret;
|
328
|
+
},
|
326
329
|
|
327
330
|
// ..........................................................
|
328
331
|
// EDITING
|
@@ -0,0 +1,106 @@
|
|
1
|
+
// ==========================================================================
|
2
|
+
// Project: SproutCore - JavaScript Application Framework
|
3
|
+
// Copyright: ©2006-2011 Strobe Inc. and contributors.
|
4
|
+
// ©2008-2011 Apple Inc. All rights reserved.
|
5
|
+
// License: Licensed under MIT license (see license.js)
|
6
|
+
// ==========================================================================
|
7
|
+
/*global module test equals context ok same */
|
8
|
+
|
9
|
+
(function() {
|
10
|
+
var target, pane, sendActionSpy, view;
|
11
|
+
|
12
|
+
module("SC.ActionSupport", {
|
13
|
+
setup: function() {
|
14
|
+
target = SC.Object.create({
|
15
|
+
mainAction: function() {},
|
16
|
+
someAction: function() {}
|
17
|
+
});
|
18
|
+
|
19
|
+
var rootResponder = {sendAction: function(){} };
|
20
|
+
sendActionSpy = CoreTest.spyOn(rootResponder, 'sendAction');
|
21
|
+
|
22
|
+
pane = SC.Object.create({
|
23
|
+
rootResponder: rootResponder
|
24
|
+
});
|
25
|
+
|
26
|
+
view = SC.View.create(SC.ActionSupport, {
|
27
|
+
action: null,
|
28
|
+
zomgAction: null,
|
29
|
+
pane: pane,
|
30
|
+
|
31
|
+
someEvent: function() {
|
32
|
+
return this.fireAction(this.get('zomgAction'));
|
33
|
+
}
|
34
|
+
});
|
35
|
+
},
|
36
|
+
|
37
|
+
teardown: function() {
|
38
|
+
target = pane = sendActionSpy = view = null;
|
39
|
+
}
|
40
|
+
});
|
41
|
+
|
42
|
+
|
43
|
+
// ..........................................................
|
44
|
+
// No Parameters
|
45
|
+
//
|
46
|
+
|
47
|
+
test("no paramaters - only action set", function() {
|
48
|
+
var expectedAction = 'someAction';
|
49
|
+
|
50
|
+
view.set('action', expectedAction);
|
51
|
+
view.fireAction();
|
52
|
+
|
53
|
+
ok(sendActionSpy.wasCalledWith(expectedAction, null, view, pane, null, view), 'triggers the action');
|
54
|
+
});
|
55
|
+
|
56
|
+
test("no paramaters - action and target set", function() {
|
57
|
+
var expectedAction = 'someAction';
|
58
|
+
|
59
|
+
view.set('target', target);
|
60
|
+
view.set('action', expectedAction);
|
61
|
+
view.fireAction();
|
62
|
+
|
63
|
+
ok(sendActionSpy.wasCalledWith(expectedAction, target, view, pane, null, view), 'triggers the action');
|
64
|
+
});
|
65
|
+
|
66
|
+
|
67
|
+
// ..........................................................
|
68
|
+
// Actions Parameter
|
69
|
+
//
|
70
|
+
|
71
|
+
test("action parameter - only action set", function() {
|
72
|
+
var expectedAction = 'someAction';
|
73
|
+
|
74
|
+
view.set('zomgAction', expectedAction);
|
75
|
+
view.someEvent();
|
76
|
+
|
77
|
+
ok(sendActionSpy.wasCalledWith(expectedAction, null, view, pane, null, view), 'triggers the action');
|
78
|
+
});
|
79
|
+
|
80
|
+
test("action parameter - action and target set", function() {
|
81
|
+
var expectedAction = 'someAction';
|
82
|
+
|
83
|
+
view.set('target', target);
|
84
|
+
view.set('zomgAction', expectedAction);
|
85
|
+
view.someEvent();
|
86
|
+
|
87
|
+
ok(sendActionSpy.wasCalledWith(expectedAction, target, view, pane, null, view), 'triggers the action');
|
88
|
+
});
|
89
|
+
|
90
|
+
|
91
|
+
// ..........................................................
|
92
|
+
// Action Context
|
93
|
+
//
|
94
|
+
|
95
|
+
test("context", function() {
|
96
|
+
var expectedAction = 'someAction';
|
97
|
+
var context = {zomg: "context"};
|
98
|
+
|
99
|
+
view.set('action', expectedAction);
|
100
|
+
view.set('actionContext', context)
|
101
|
+
view.fireAction();
|
102
|
+
|
103
|
+
ok(sendActionSpy.wasCalledWith(expectedAction, null, view, pane, context, view), 'triggers the action');
|
104
|
+
});
|
105
|
+
|
106
|
+
})();
|
data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/template/collection.js
CHANGED
@@ -382,3 +382,21 @@ test("#collection helper should allow relative paths for the collection view cla
|
|
382
382
|
equals(view.$('li').length, 3, '#collection should find relative collection view path');
|
383
383
|
});
|
384
384
|
|
385
|
+
test("#collection helper should raise an error when passing a first argument that isn't an SC.TemplateCollectionView", function() {
|
386
|
+
var view = SC.TemplateView.create({
|
387
|
+
content: {
|
388
|
+
names: ["Dom", "Arthur"]
|
389
|
+
},
|
390
|
+
template: SC.Handlebars.compile('{{#collection content.names}}{{/collection}}')
|
391
|
+
});
|
392
|
+
var errored = false;
|
393
|
+
|
394
|
+
try {
|
395
|
+
view.createLayer();
|
396
|
+
} catch(e) {
|
397
|
+
errored = true;
|
398
|
+
}
|
399
|
+
|
400
|
+
ok(errored, "throws an error when creating the view");
|
401
|
+
});
|
402
|
+
|
data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/template/handlebars.js
CHANGED
@@ -3,8 +3,54 @@
|
|
3
3
|
// Copyright: ©2006-2011 Strobe Inc. and contributors.
|
4
4
|
// License: Licensed under MIT license (see license.js)
|
5
5
|
// ==========================================================================
|
6
|
-
|
7
6
|
/*globals TemplateTests module */
|
7
|
+
|
8
|
+
// Included to test bindAttr problem where setting an attr when it
|
9
|
+
// has the same value is overkill and sometimes causes the browser
|
10
|
+
// to misbehave, like in SC.TextField where listening to change
|
11
|
+
// events caused the cursor to go to the end of the input
|
12
|
+
(function() {
|
13
|
+
|
14
|
+
jQuery.fn.caretPosition = function() {
|
15
|
+
var ctrl = this[0];
|
16
|
+
|
17
|
+
var CaretPos = 0;
|
18
|
+
// IE Support
|
19
|
+
if (document.selection) {
|
20
|
+
|
21
|
+
ctrl.focus();
|
22
|
+
var Sel = document.selection.createRange ();
|
23
|
+
|
24
|
+
Sel.moveStart ('character', -ctrl.value.length);
|
25
|
+
|
26
|
+
CaretPos = Sel.text.length;
|
27
|
+
}
|
28
|
+
// Firefox support
|
29
|
+
else if (ctrl.selectionStart || ctrl.selectionStart == '0') {
|
30
|
+
CaretPos = ctrl.selectionStart;
|
31
|
+
}
|
32
|
+
|
33
|
+
return (CaretPos);
|
34
|
+
};
|
35
|
+
|
36
|
+
|
37
|
+
jQuery.fn.setCaretPosition = function(pos) {
|
38
|
+
var ctrl = this[0];
|
39
|
+
|
40
|
+
if(ctrl.setSelectionRange) {
|
41
|
+
ctrl.focus();
|
42
|
+
ctrl.setSelectionRange(pos,pos);
|
43
|
+
} else if (ctrl.createTextRange) {
|
44
|
+
var range = ctrl.createTextRange();
|
45
|
+
range.collapse(true);
|
46
|
+
range.moveEnd('character', pos);
|
47
|
+
range.moveStart('character', pos);
|
48
|
+
range.select();
|
49
|
+
}
|
50
|
+
}
|
51
|
+
|
52
|
+
})();
|
53
|
+
|
8
54
|
/**
|
9
55
|
This module specifically tests integration with Handlebars and SproutCore-specific
|
10
56
|
Handlebars extensions.
|
@@ -855,6 +901,30 @@ test("should be able to bind element attributes using {{bindAttr}}", function()
|
|
855
901
|
equals(view.$('img').attr('alt'), "Nanananana SproutCore!", "updates alt attribute when title property is computed");
|
856
902
|
});
|
857
903
|
|
904
|
+
test("should not reset cursor position when text field receives keyUp event", function() {
|
905
|
+
var pane = SC.Pane.create({
|
906
|
+
childViews: ['view'],
|
907
|
+
view: SC.TextField.create({
|
908
|
+
value: "Broseidon, King of the Brocean"
|
909
|
+
})
|
910
|
+
});
|
911
|
+
|
912
|
+
pane.append();
|
913
|
+
|
914
|
+
var view = pane.get('childViews')[0];
|
915
|
+
|
916
|
+
view.$('input').val('Brosiedoon, King of the Brocean');
|
917
|
+
view.$('input').setCaretPosition(5);
|
918
|
+
|
919
|
+
SC.run(function() {
|
920
|
+
view.keyUp({});
|
921
|
+
});
|
922
|
+
|
923
|
+
equals(view.$('input').caretPosition(), 5, "The keyUp event should not result in the cursor being reset due to the bindAttr observers");
|
924
|
+
|
925
|
+
pane.remove().destroy();
|
926
|
+
});
|
927
|
+
|
858
928
|
test("should be able to bind element attributes using {{bindAttr}} inside a block", function() {
|
859
929
|
var template = SC.Handlebars.compile('{{#with content}}<img {{bindAttr src="url" alt="title"}}>{{/with}}');
|
860
930
|
|
@@ -0,0 +1,38 @@
|
|
1
|
+
// ==========================================================================
|
2
|
+
// Project: SproutCore - JavaScript Application Framework
|
3
|
+
// Copyright: ©2006-2011 Apple Inc. and contributors.
|
4
|
+
// License: Licensed under MIT license (see license.js)
|
5
|
+
// ==========================================================================
|
6
|
+
/*global module test equals context ok same */
|
7
|
+
|
8
|
+
module("SC.CoreView - Attribute Bindings");
|
9
|
+
|
10
|
+
test("should render and update attribute bindings", function() {
|
11
|
+
var view = SC.View.create({
|
12
|
+
classNameBindings: ['priority', 'isUrgent', 'isClassified:classified', 'canIgnore'],
|
13
|
+
attributeBindings: ['type', 'exploded', 'destroyed', 'exists', 'explosions'],
|
14
|
+
|
15
|
+
type: 'reset',
|
16
|
+
exploded: true,
|
17
|
+
destroyed: true,
|
18
|
+
exists: false,
|
19
|
+
explosions: 15
|
20
|
+
});
|
21
|
+
|
22
|
+
view.createLayer();
|
23
|
+
equals(view.$().attr('type'), 'reset', "adds type attribute");
|
24
|
+
ok(view.$().attr('exploded'), "adds exploded attribute when true");
|
25
|
+
ok(view.$().attr('destroyed'), "adds destroyed attribute when true");
|
26
|
+
ok(!view.$().attr('exists'), "does not add exists attribute when false");
|
27
|
+
equals(view.$().attr('explosions'), "15", "adds integer attributes");
|
28
|
+
|
29
|
+
view.set('type', 'submit');
|
30
|
+
view.set('exploded', false);
|
31
|
+
view.set('destroyed', false);
|
32
|
+
view.set('exists', true);
|
33
|
+
|
34
|
+
equals(view.$().attr('type'), 'submit', "updates type attribute");
|
35
|
+
ok(!view.$().attr('exploded'), "removes exploded attribute when false");
|
36
|
+
ok(!view.$().attr('destroyed'), "removes destroyed attribute when false");
|
37
|
+
ok(view.$().attr('exists'), "adds exists attribute when true");
|
38
|
+
});
|
@@ -0,0 +1,47 @@
|
|
1
|
+
// ==========================================================================
|
2
|
+
// Project: SproutCore - JavaScript Application Framework
|
3
|
+
// Copyright: ©2006-2011 Apple Inc. and contributors.
|
4
|
+
// License: Licensed under MIT license (see license.js)
|
5
|
+
// ==========================================================================
|
6
|
+
/*global module test equals context ok same */
|
7
|
+
|
8
|
+
module("SC.CoreView - Class Name Bindings");
|
9
|
+
|
10
|
+
test("should apply bound class names to the element", function() {
|
11
|
+
var view = SC.View.create({
|
12
|
+
classNameBindings: ['priority', 'isUrgent', 'isClassified:classified', 'canIgnore'],
|
13
|
+
|
14
|
+
priority: 'high',
|
15
|
+
isUrgent: true,
|
16
|
+
isClassified: true,
|
17
|
+
canIgnore: false
|
18
|
+
});
|
19
|
+
|
20
|
+
view.createLayer();
|
21
|
+
ok(view.$().hasClass('high'), "adds string values as class name");
|
22
|
+
ok(view.$().hasClass('is-urgent'), "adds true Boolean values by dasherizing");
|
23
|
+
ok(view.$().hasClass('classified'), "supports customizing class name for Boolean values");
|
24
|
+
ok(!view.$().hasClass('can-ignore'), "does not add false Boolean values as class");
|
25
|
+
});
|
26
|
+
|
27
|
+
test("should add, remove, or change class names if changed after element is created", function() {
|
28
|
+
var view = SC.View.create({
|
29
|
+
classNameBindings: ['priority', 'isUrgent', 'canIgnore'],
|
30
|
+
|
31
|
+
priority: 'high',
|
32
|
+
isUrgent: true,
|
33
|
+
canIgnore: false
|
34
|
+
});
|
35
|
+
|
36
|
+
view.createLayer();
|
37
|
+
|
38
|
+
view.set('priority', 'orange');
|
39
|
+
view.set('isUrgent', false);
|
40
|
+
view.set('canIgnore', true);
|
41
|
+
|
42
|
+
ok(view.$().hasClass('orange'), "updates string values");
|
43
|
+
ok(!view.$().hasClass('high'), "removes old string value");
|
44
|
+
|
45
|
+
ok(!view.$().hasClass('is-urgent', "removes dasherized class when changed from true to false"));
|
46
|
+
ok(view.$().hasClass('can-ignore'), "adds dasherized class when changed from false to true");
|
47
|
+
});
|
data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/layoutChildViews.js
CHANGED
@@ -7,8 +7,8 @@
|
|
7
7
|
/*global module test equals context ok same */
|
8
8
|
|
9
9
|
// .......................................................
|
10
|
-
// layoutChildViews()
|
11
|
-
//
|
10
|
+
// layoutChildViews()
|
11
|
+
//
|
12
12
|
module("SC.View#layoutChildViews");
|
13
13
|
|
14
14
|
test("calls renderLayout() on child views on views that need layout if they have a layer", function() {
|
@@ -17,25 +17,25 @@ test("calls renderLayout() on child views on views that need layout if they have
|
|
17
17
|
var ChildView = SC.View.extend({
|
18
18
|
updateLayout: function(context) { callCount++; }
|
19
19
|
});
|
20
|
-
|
20
|
+
|
21
21
|
var view = SC.View.create({
|
22
22
|
childViews: [ChildView, ChildView, ChildView]
|
23
23
|
});
|
24
|
-
|
24
|
+
|
25
25
|
var cv1 = view.childViews[0];
|
26
26
|
var cv2 = view.childViews[1];
|
27
|
-
|
27
|
+
|
28
28
|
// add to set...
|
29
29
|
view.layoutDidChangeFor(cv1);
|
30
30
|
view.layoutDidChangeFor(cv2);
|
31
|
-
|
31
|
+
|
32
32
|
view.layoutChildViews();
|
33
33
|
equals(callCount, 2, 'updateLayout should be called on two dirty child views');
|
34
34
|
});
|
35
35
|
|
36
36
|
// .......................................................
|
37
|
-
// updateLayout()
|
38
|
-
//
|
37
|
+
// updateLayout()
|
38
|
+
//
|
39
39
|
module("SC.View#updateLayout");
|
40
40
|
|
41
41
|
test("if view has layout, calls renderLayout with context to update element", function() {
|
@@ -52,10 +52,10 @@ test("if view has layout, calls renderLayout with context to update element", fu
|
|
52
52
|
callCount++;
|
53
53
|
}
|
54
54
|
});
|
55
|
-
|
55
|
+
|
56
56
|
view.createLayer(); // we need a layer
|
57
57
|
ok(view.get('layer'), 'precond - should have a layer');
|
58
|
-
|
58
|
+
|
59
59
|
isTesting= YES ;
|
60
60
|
view.updateLayout();
|
61
61
|
equals(callCount, 1, 'should call renderLayout()');
|
@@ -74,9 +74,9 @@ test("if view has NO layout, should not call renderLayout", function() {
|
|
74
74
|
callCount++;
|
75
75
|
}
|
76
76
|
});
|
77
|
-
|
77
|
+
|
78
78
|
ok(!view.get('layer'), 'precond - should NOT have a layer');
|
79
|
-
|
79
|
+
|
80
80
|
isTesting= YES ;
|
81
81
|
view.updateLayout();
|
82
82
|
equals(callCount, 0, 'should NOT call renderLayout()');
|
@@ -88,7 +88,7 @@ test("returns receiver", function() {
|
|
88
88
|
});
|
89
89
|
|
90
90
|
// .......................................................
|
91
|
-
// renderLayout()
|
91
|
+
// renderLayout()
|
92
92
|
//
|
93
93
|
module('SC.View#renderLayout');
|
94
94
|
|
@@ -96,7 +96,7 @@ test("adds layoutStyle property to passed context", function() {
|
|
96
96
|
|
97
97
|
var view = SC.View.create({
|
98
98
|
// mock style for testing...
|
99
|
-
layoutStyle: { width: 50, height: 50 }
|
99
|
+
layoutStyle: { width: 50, height: 50 }
|
100
100
|
});
|
101
101
|
var context = view.renderContext();
|
102
102
|
|
@@ -111,7 +111,7 @@ test("adds layoutStyle property to passed context", function() {
|
|
111
111
|
});
|
112
112
|
|
113
113
|
// .......................................................
|
114
|
-
// layoutChildViewsIfNeeded()
|
114
|
+
// layoutChildViewsIfNeeded()
|
115
115
|
//
|
116
116
|
var view, callCount ;
|
117
117
|
module('SC.View#layoutChildViewsIfNeeded', {
|
@@ -123,7 +123,7 @@ module('SC.View#layoutChildViewsIfNeeded', {
|
|
123
123
|
},
|
124
124
|
teardown: function() { view = null; }
|
125
125
|
});
|
126
|
-
|
126
|
+
|
127
127
|
test("calls layoutChildViews() if childViewsNeedLayout and isVisibleInWindow & sets childViewsNeedLayout to NO", function() {
|
128
128
|
|
129
129
|
view.childViewsNeedLayout = YES ;
|
@@ -149,7 +149,7 @@ test("does not call layoutChildViews() if isVisibleInWindow is NO unless passed
|
|
149
149
|
view.layoutChildViewsIfNeeded();
|
150
150
|
equals(callCount, 0, 'should NOT call layoutChildViews()');
|
151
151
|
equals(view.get('childViewsNeedLayout'), YES, 'should leave childViewsNeedLayout set to YES');
|
152
|
-
|
152
|
+
|
153
153
|
view.layoutChildViewsIfNeeded(YES);
|
154
154
|
equals(callCount, 1, 'should call layoutChildViews()');
|
155
155
|
equals(view.get('childViewsNeedLayout'), NO, 'should set childViewsNeedLayout to NO');
|
@@ -158,5 +158,5 @@ test("does not call layoutChildViews() if isVisibleInWindow is NO unless passed
|
|
158
158
|
test("returns receiver", function() {
|
159
159
|
equals(view.layoutChildViewsIfNeeded(), view, 'should return receiver');
|
160
160
|
});
|
161
|
-
|
161
|
+
|
162
162
|
|