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.
Files changed (143) hide show
  1. data/CHANGELOG +21 -0
  2. data/Gemfile +5 -0
  3. data/Rakefile +26 -13
  4. data/VERSION.yml +2 -2
  5. data/lib/Buildfile +43 -4
  6. data/lib/buildtasks/build.rake +10 -0
  7. data/lib/buildtasks/helpers/file_rule.rb +22 -0
  8. data/lib/buildtasks/helpers/file_rule_list.rb +137 -0
  9. data/lib/buildtasks/manifest.rake +133 -122
  10. data/lib/frameworks/sproutcore/CHANGELOG.md +69 -2
  11. data/lib/frameworks/sproutcore/apps/tests/english.lproj/strings.js +1 -0
  12. data/lib/frameworks/sproutcore/frameworks/bootstrap/system/browser.js +28 -22
  13. data/lib/frameworks/sproutcore/frameworks/core_foundation/controllers/array.js +9 -5
  14. data/lib/frameworks/sproutcore/frameworks/core_foundation/controllers/controller.js +1 -1
  15. data/lib/frameworks/sproutcore/frameworks/core_foundation/controls/button.js +18 -13
  16. data/lib/frameworks/sproutcore/frameworks/core_foundation/ext/handlebars/bind.js +5 -3
  17. data/lib/frameworks/sproutcore/frameworks/core_foundation/ext/handlebars/collection.js +2 -0
  18. data/lib/frameworks/sproutcore/frameworks/core_foundation/mixins/action_support.js +80 -0
  19. data/lib/frameworks/sproutcore/frameworks/core_foundation/mixins/template_helpers/text_field_support.js +84 -116
  20. data/lib/frameworks/sproutcore/frameworks/core_foundation/panes/pane.js +8 -5
  21. data/lib/frameworks/sproutcore/frameworks/core_foundation/system/event.js +157 -157
  22. data/lib/frameworks/sproutcore/frameworks/core_foundation/system/platform.js +5 -3
  23. data/lib/frameworks/sproutcore/frameworks/core_foundation/system/root_responder.js +6 -6
  24. data/lib/frameworks/sproutcore/frameworks/core_foundation/system/sparse_array.js +10 -7
  25. data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/mixins/action_support.js +106 -0
  26. data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/template/collection.js +18 -0
  27. data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/template/handlebars.js +71 -1
  28. data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/attribute_bindings_test.js +38 -0
  29. data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/class_name_bindings_test.js +47 -0
  30. data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/layoutChildViews.js +18 -18
  31. data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/layoutStyle.js +42 -10
  32. data/lib/frameworks/sproutcore/frameworks/core_foundation/views/view.js +158 -1
  33. data/lib/frameworks/sproutcore/frameworks/core_foundation/views/view/keyboard.js +26 -1
  34. data/lib/frameworks/sproutcore/frameworks/core_foundation/views/view/layout_style.js +14 -8
  35. data/lib/frameworks/sproutcore/frameworks/datastore/models/record.js +15 -2
  36. data/lib/frameworks/sproutcore/frameworks/datastore/models/record_attribute.js +108 -108
  37. data/lib/frameworks/sproutcore/frameworks/datastore/system/query.js +1 -1
  38. data/lib/frameworks/sproutcore/frameworks/datastore/system/record_array.js +2 -4
  39. data/lib/frameworks/sproutcore/frameworks/datastore/tests/models/record/error_methods.js +2 -2
  40. data/lib/frameworks/sproutcore/frameworks/datastore/tests/models/single_attribute.js +26 -0
  41. data/lib/frameworks/sproutcore/frameworks/datastore/tests/system/query/builders.js +7 -0
  42. data/lib/frameworks/sproutcore/frameworks/datastore/tests/system/record_array/error_methods.js +1 -1
  43. data/lib/frameworks/sproutcore/frameworks/datetime/frameworks/core/system/datetime.js +4 -1
  44. data/lib/frameworks/sproutcore/frameworks/datetime/frameworks/core/tests/system/datetime.js +6 -0
  45. data/lib/frameworks/sproutcore/frameworks/desktop/panes/menu.js +26 -5
  46. data/lib/frameworks/sproutcore/frameworks/desktop/panes/picker.js +97 -96
  47. data/lib/frameworks/sproutcore/frameworks/desktop/system/drag.js +4 -3
  48. data/lib/frameworks/sproutcore/frameworks/desktop/tests/panes/menu/ui.js +17 -4
  49. data/lib/frameworks/sproutcore/frameworks/desktop/views/collection.js +7 -7
  50. data/lib/frameworks/sproutcore/frameworks/desktop/views/menu_item.js +7 -5
  51. data/lib/frameworks/sproutcore/frameworks/desktop/views/scroll.js +12 -3
  52. data/lib/frameworks/sproutcore/frameworks/desktop/views/web.js +23 -14
  53. data/lib/frameworks/sproutcore/frameworks/experimental/Buildfile +5 -1
  54. data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/menu/render_delegates/menu_scroller.js +28 -0
  55. data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/menu/tests/menu/scroll.js +235 -0
  56. data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/menu/views/menu/scroll.js +363 -0
  57. data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/menu/views/menu/scroller.js +250 -0
  58. data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/scroll_view/render_delegates/desktop_scroller.js +92 -0
  59. data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/scroll_view/render_delegates/native_scroll.js +25 -0
  60. data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/scroll_view/render_delegates/scroll.js +33 -0
  61. data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/scroll_view/render_delegates/touch_scroller.js +76 -0
  62. data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/scroll_view/tests/scroll/integration.js +50 -0
  63. data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/scroll_view/tests/scroll/methods.js +143 -0
  64. data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/scroll_view/tests/scroll/ui.js +258 -0
  65. data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/scroll_view/views/core_scroll.js +1164 -0
  66. data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/scroll_view/views/core_scroller.js +332 -0
  67. data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/scroll_view/views/desktop/scroll.js +236 -0
  68. data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/scroll_view/views/desktop/scroller.js +347 -0
  69. data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/scroll_view/views/scroll.js +15 -0
  70. data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/scroll_view/views/scroller.js +10 -0
  71. data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/scroll_view/views/touch/scroll.js +804 -0
  72. data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/scroll_view/views/touch/scroller.js +133 -0
  73. data/lib/frameworks/sproutcore/frameworks/foundation/resources/text_field.css +3 -3
  74. data/lib/frameworks/sproutcore/frameworks/foundation/validators/number.js +3 -1
  75. data/lib/frameworks/sproutcore/frameworks/foundation/views/text_field.js +3 -3
  76. data/lib/frameworks/sproutcore/frameworks/media/views/audio.js +2 -1
  77. data/lib/frameworks/sproutcore/frameworks/media/views/controls.js +2 -1
  78. data/lib/frameworks/sproutcore/frameworks/media/views/media_slider.js +2 -4
  79. data/lib/frameworks/sproutcore/frameworks/media/views/mini_controls.js +2 -4
  80. data/lib/frameworks/sproutcore/frameworks/media/views/simple_controls.js +2 -4
  81. data/lib/frameworks/sproutcore/frameworks/media/views/video.js +2 -2
  82. data/lib/frameworks/sproutcore/frameworks/routing/system/routes.js +29 -3
  83. data/lib/frameworks/sproutcore/frameworks/runtime/core.js +2 -2
  84. data/lib/frameworks/sproutcore/frameworks/runtime/debug/test_suites/array/replace.js +1 -1
  85. data/lib/frameworks/sproutcore/frameworks/runtime/private/property_chain.js +2 -1
  86. data/lib/frameworks/sproutcore/frameworks/runtime/system/binding.js +3 -3
  87. data/lib/frameworks/sproutcore/frameworks/runtime/system/index_set.js +2 -2
  88. data/lib/frameworks/sproutcore/frameworks/runtime/system/object.js +1 -1
  89. data/lib/frameworks/sproutcore/themes/ace/resources/collection/normal/list_item.css +2 -2
  90. data/lib/frameworks/sproutcore/themes/legacy_theme/english.lproj/segmented.css +1 -1
  91. data/lib/gen/app/templates/apps/@target_name@/Buildfile +3 -5
  92. data/lib/gen/app/templates/apps/@target_name@/resources/_theme.css +18 -0
  93. data/lib/gen/project/templates/@filename@/Buildfile +2 -2
  94. data/lib/sproutcore.rb +30 -5
  95. data/lib/sproutcore/builders.rb +1 -0
  96. data/lib/sproutcore/builders/chance_file.rb +9 -16
  97. data/lib/sproutcore/builders/html.rb +2 -1
  98. data/lib/sproutcore/builders/minify.rb +4 -35
  99. data/lib/sproutcore/builders/module.rb +38 -1
  100. data/lib/sproutcore/builders/split.rb +63 -0
  101. data/lib/sproutcore/builders/strings.rb +7 -1
  102. data/lib/sproutcore/helpers.rb +1 -1
  103. data/lib/sproutcore/helpers/css_split.rb +190 -0
  104. data/lib/sproutcore/helpers/entry_sorter.rb +2 -0
  105. data/lib/sproutcore/helpers/minifier.rb +40 -16
  106. data/lib/sproutcore/helpers/static_helper.rb +35 -17
  107. data/lib/sproutcore/models/manifest.rb +26 -0
  108. data/lib/sproutcore/models/target.rb +12 -1
  109. data/lib/sproutcore/rack.rb +1 -0
  110. data/lib/sproutcore/rack/proxy.rb +244 -225
  111. data/lib/sproutcore/rack/restrict_ip.rb +67 -0
  112. data/lib/sproutcore/rack/service.rb +8 -2
  113. data/lib/sproutcore/tools.rb +102 -46
  114. data/lib/sproutcore/tools/build.rb +91 -43
  115. data/lib/sproutcore/tools/gen.rb +2 -3
  116. data/lib/sproutcore/tools/manifest.rb +22 -16
  117. data/lib/sproutcore/tools/server.rb +21 -0
  118. data/spec/buildtasks/helpers/accept_list +22 -0
  119. data/spec/buildtasks/helpers/accept_list.rb +128 -0
  120. data/spec/buildtasks/helpers/list.json +11 -0
  121. data/spec/buildtasks/manifest/prepare_build_tasks/chance_2x_spec.rb +1 -39
  122. data/spec/buildtasks/manifest/prepare_build_tasks/chance_spec.rb +0 -38
  123. data/spec/buildtasks/manifest/prepare_build_tasks/combine_spec.rb +4 -4
  124. data/spec/buildtasks/manifest/prepare_build_tasks/module_spec.rb +2 -2
  125. data/spec/buildtasks/manifest/prepare_build_tasks/packed_2x_indirect_spec.rb +7 -16
  126. data/spec/buildtasks/manifest/prepare_build_tasks/packed_2x_spec.rb +7 -17
  127. data/spec/buildtasks/manifest/prepare_build_tasks/packed_spec.rb +11 -6
  128. data/spec/fixtures/builder_tests/Buildfile +2 -1
  129. data/spec/fixtures/builder_tests/apps/module_test/modules/required_module/core.js +0 -0
  130. data/spec/lib/builders/module_spec.rb +1 -1
  131. data/spec/spec_helper.rb +1 -0
  132. data/sproutcore.gemspec +4 -9
  133. data/vendor/chance/lib/chance.rb +25 -6
  134. data/vendor/chance/lib/chance/factory.rb +45 -0
  135. data/vendor/chance/lib/chance/instance.rb +173 -28
  136. data/vendor/chance/lib/chance/instance/data_url.rb +0 -29
  137. data/vendor/chance/lib/chance/instance/slicing.rb +57 -4
  138. data/vendor/chance/lib/chance/instance/spriting.rb +112 -21
  139. data/vendor/chance/lib/chance/parser.rb +80 -52
  140. data/vendor/sproutcore/SCCompiler.jar +0 -0
  141. data/vendor/sproutcore/lib/args4j-2.0.12.jar +0 -0
  142. data/vendor/sproutcore/lib/yuicompressor-2.4.2.jar +0 -0
  143. metadata +84 -25
@@ -0,0 +1,92 @@
1
+ // ==========================================================================
2
+ // Project: SproutCore - JavaScript Application Framework
3
+ // Copyright: ©2006-2011 Strobe Inc. and contributors.
4
+ // Portions ©2008-2011 Apple Inc. All rights reserved.
5
+ // License: Licensed under MIT license (see license.js)
6
+ // ==========================================================================
7
+
8
+
9
+ SC.BaseTheme.desktopScrollerRenderDelegate = SC.RenderDelegate.create({
10
+ className: 'desktop-scroller',
11
+
12
+ render: function (dataSource, context) {
13
+ var layoutDirection = dataSource.get('layoutDirection'),
14
+ isVertical = layoutDirection === SC.LAYOUT_VERTICAL,
15
+ isHorizontal = layoutDirection === SC.LAYOUT_HORIZONTAL;
16
+
17
+ context.setClass({
18
+ 'sc-vertical': isVertical,
19
+ 'sc-horizontal': isHorizontal,
20
+ disabled: !dataSource.get('isEnabled'),
21
+ 'controls-hidden': dataSource.get('controlsHidden')
22
+ });
23
+
24
+ context.push(
25
+ '<div class="track"></div>',
26
+ '<div class="cap"></div>',
27
+ dataSource.get('hasButtons') ?
28
+ '<div class="button-bottom"></div><div class="button-top"></div>' :
29
+ '<div class="endcap"></div>',
30
+ ('<div class="thumb" style="%@:' + dataSource.get('thumbLength') + 'px;' +
31
+ 'top:' + dataSource.get('thumbPosition') + 'px;">').
32
+ fmt(isVertical ? 'height' : 'width'),
33
+ '<div class="thumb-center"></div>',
34
+ '<div class="thumb-top"></div>',
35
+ '<div class="thumb-bottom"></div>',
36
+ '</div>');
37
+
38
+
39
+ context.attr('aria-orientation',
40
+ (layoutDirection === SC.LAYOUT_VERTICAL) ? 'vertical' : 'horizontal');
41
+ context.attr('aria-valuemax', dataSource.get('maximum'));
42
+ context.attr('aria-valuemin', dataSource.get('minimum'));
43
+ context.attr('aria-valuenow', dataSource.get('value'));
44
+ context.attr('aria-controls', dataSource.get('controlsId'));
45
+ },
46
+
47
+ update: function (dataSource, context) {
48
+ var layoutDirection = dataSource.get('layoutDirection'),
49
+ isVertical = layoutDirection === SC.LAYOUT_VERTICAL,
50
+ isHorizontal = layoutDirection === SC.LAYOUT_HORIZONTAL,
51
+ controlsAreHidden = dataSource.get('controlsHidden'),
52
+ thumb, K = 'desktopScrollerRenderDelegate';
53
+
54
+ context.setClass({
55
+ 'sc-vertical': isVertical,
56
+ 'sc-horizontal': isHorizontal,
57
+ disabled: !dataSource.get('isEnabled'),
58
+ 'controls-hidden': controlsAreHidden
59
+ });
60
+
61
+ if (dataSource.didChangeFor(K, 'maximum')) {
62
+ context.attr('aria-valuemax', dataSource.get('maximum'));
63
+ }
64
+
65
+ if (dataSource.didChangeFor(K, 'minimum')) {
66
+ context.attr('aria-valuemin', dataSource.get('minimum'));
67
+ }
68
+
69
+ if (dataSource.didChangeFor(K, 'value')) {
70
+ context.attr('aria-valuenow', dataSource.get('value'));
71
+ }
72
+
73
+ if (dataSource.didChangeFor(K, 'controlsId')) {
74
+ context.attr('aria-controls', dataSource.get('controlsId'));
75
+ }
76
+
77
+ // Don't bother if the controls are hidden.
78
+ if (!controlsAreHidden) {
79
+ thumb = context.find('.thumb');
80
+
81
+ if (dataSource.didChangeFor(K, 'thumbPosition')) {
82
+ thumb.css(layoutDirection === SC.LAYOUT_VERTICAL ?
83
+ 'top' : 'left', dataSource.get('thumbPosition'));
84
+ }
85
+
86
+ if (dataSource.didChangeFor(K, 'thumbLength')) {
87
+ thumb.css(layoutDirection === SC.LAYOUT_VERTICAL ?
88
+ 'height' : 'width', dataSource.get('thumbLength'));
89
+ }
90
+ }
91
+ }
92
+ });
@@ -0,0 +1,25 @@
1
+ // ==========================================================================
2
+ // Project: SproutCore - JavaScript Application Framework
3
+ // Copyright: ©2006-2010 Sprout Systems, Inc. and contributors.
4
+ // License: Licensed under MIT license (see license.js)
5
+ // ==========================================================================
6
+
7
+ SC.BaseTheme.nativeScrollRenderDelegate = SC.RenderDelegate.create({
8
+ className: 'native-scroll',
9
+
10
+ render: function (dataSource, context) {},
11
+
12
+ update: function (dataSource, context) {
13
+ var K = 'scrollRenderDelegate',
14
+ scroll = context.find('> .sc-scroll-container-view');
15
+
16
+ if (dataSource.didChangeFor(K, 'canScrollHorizontal')) {
17
+ scroll.css('overflow-x', dataSource.get('canScrollHorizontal') ? 'scroll' : 'hidden');
18
+ }
19
+
20
+ if (dataSource.didChangeFor(K, 'canScrollVertical')) {
21
+ scroll.css('overflow-y', dataSource.get('canScrollVertical') ? 'scroll' : 'hidden');
22
+ }
23
+ }
24
+
25
+ });
@@ -0,0 +1,33 @@
1
+ // ==========================================================================
2
+ // Project: SproutCore - JavaScript Application Framework
3
+ // Copyright: ©2006-2010 Sprout Systems, Inc. and contributors.
4
+ // License: Licensed under MIT license (see license.js)
5
+ // ==========================================================================
6
+
7
+ SC.BaseTheme.scrollRenderDelegate = SC.RenderDelegate.create({
8
+ className: 'scroll',
9
+
10
+ render: function (dataSource, context) {
11
+ context.push('<div class="corner"></div>');
12
+ },
13
+
14
+ update: function (dataSource, context) {
15
+ var K = 'scrollRenderDelegate',
16
+ thicknessDidChange = dataSource.didChangeFor(K, 'nativeScrollbarThickness'),
17
+ scroll = context.find('> .sc-scroll-container-view'),
18
+ canScroll, thickness = dataSource.get('nativeScrollbarThickness');
19
+
20
+ if (thicknessDidChange || dataSource.didChangeFor(K, 'canScrollHorizontal')) {
21
+ canScroll = dataSource.get('canScrollHorizontal');
22
+ scroll.css('margin-bottom', canScroll ? -1 * thickness : 0);
23
+ scroll.css('overflow-x', canScroll ? 'scroll' : 'hidden');
24
+ }
25
+
26
+ if (thicknessDidChange || dataSource.didChangeFor(K, 'canScrollVertical')) {
27
+ canScroll = dataSource.get('canScrollVertical');
28
+ scroll.css('margin-right', canScroll ? -1 * thickness : 0);
29
+ scroll.css('overflow-y', canScroll ? 'scroll' : 'hidden');
30
+ }
31
+ }
32
+
33
+ });
@@ -0,0 +1,76 @@
1
+ // ==========================================================================
2
+ // Project: SproutCore - JavaScript Application Framework
3
+ // Copyright: ©2006-2011 Strobe Inc. and contributors.
4
+ // Portions ©2008-2011 Apple Inc. All rights reserved.
5
+ // License: Licensed under MIT license (see license.js)
6
+ // ==========================================================================
7
+
8
+ SC.BaseTheme.touchScrollerRenderDelegate = SC.RenderDelegate.create({
9
+ className: 'touch-scroller',
10
+
11
+ render: function (dataSource, context) {
12
+ var layoutDirection = dataSource.get('layoutDirection'),
13
+ isVertical = layoutDirection === SC.LAYOUT_VERTICAL,
14
+ isHorizontal = layoutDirection === SC.LAYOUT_HORIZONTAL;
15
+
16
+ context.setClass({
17
+ 'sc-vertical': isVertical,
18
+ 'sc-horizontal': isHorizontal,
19
+ disabled: !dataSource.get('isEnabled'),
20
+ 'controls-hidden': dataSource.get('controlsHidden')
21
+ });
22
+
23
+ context.push(
24
+ '<div class="track"></div>',
25
+ '<div class="cap"></div>',
26
+ dataSource.get('hasButtons') ?
27
+ '<div class="button-bottom"></div><div class="button-top"></div>' :
28
+ '<div class="endcap"></div>',
29
+ '<div class="thumb">',
30
+ '<div class="thumb-top"></div>',
31
+ '<div class="thumb-clip">',
32
+ ('<div class="thumb-inner" style="-webkit-transform: ' +
33
+ 'translate%@(' + (dataSource.get('thumbLength') - 1044) + 'px);').
34
+ fmt(isVertical ? 'Y' : 'X') + '">',
35
+ '<div class="thumb-center"></div>',
36
+ '<div class="thumb-bottom"></div>',
37
+ '</div>',
38
+ '</div>',
39
+ '</div>');
40
+ },
41
+
42
+ update: function (dataSource, context) {
43
+ var layoutDirection = dataSource.get('layoutDirection'),
44
+ isVertical = layoutDirection === SC.LAYOUT_VERTICAL,
45
+ isHorizontal = layoutDirection === SC.LAYOUT_HORIZONTAL,
46
+ controlsAreHidden = dataSource.get('controlsHidden'),
47
+ K = 'touchScrollerRenderDelegate';
48
+
49
+ context.setClass({
50
+ 'sc-vertical': isVertical,
51
+ 'sc-horizontal': isHorizontal,
52
+ disabled: !dataSource.get('isEnabled'),
53
+ 'controls-hidden': controlsAreHidden
54
+ });
55
+
56
+ if (!controlsAreHidden) {
57
+ var length = dataSource.get('thumbLength'),
58
+ position = dataSource.get('thumbPosition'),
59
+ T = 'translate3d(%@px,%@px,%@px)';
60
+
61
+ if (dataSource.didChangeFor(K, 'thumbPosition')) {
62
+ context.find('.thumb').css('-webkit-transform', isVertical ?
63
+ T.fmt(0, position, 0) :
64
+ T.fmt(position, 0, 0));
65
+ }
66
+
67
+ if (dataSource.didChangeFor(K, 'thumbLength')) {
68
+ context.find('.thumb-inner').css('-webkit-transform', isVertical ?
69
+ T.fmt(0, length, 0) :
70
+ T.fmt(length, 0, 0));
71
+
72
+ }
73
+ }
74
+ }
75
+
76
+ });
@@ -0,0 +1,50 @@
1
+ module("SC.ScrollView integration");
2
+
3
+ test("should work with SC.TemplateView", function() {
4
+ var pane = SC.MainPane.create({
5
+ childViews: ['scrollView'],
6
+
7
+ scrollView: SC.ScrollView.design({
8
+ layout: { width: 400, height: 600 },
9
+
10
+ contentView: SC.TemplateView.create({
11
+ template: SC.Handlebars.compile("foo bar baz")
12
+ })
13
+ })
14
+ });
15
+
16
+ pane.append();
17
+ var exceptionThrown = false;
18
+ try {
19
+ SC.RunLoop.begin().end();
20
+ } catch (e) {
21
+ exceptionThrown = true;
22
+ }
23
+ ok(!exceptionThrown, "Does not throw an exception at the end of the run loop.");
24
+ pane.remove();
25
+ });
26
+
27
+ test("should work with views that have static layout applied", function() {
28
+ var pane;
29
+ try {
30
+ pane = SC.MainPane.create({
31
+ childViews: ['scrollView'],
32
+
33
+ scrollView: SC.ScrollView.design({
34
+ layout: { width: 400, height: 600 },
35
+
36
+ contentView: SC.View.design({
37
+ useStaticLayout: YES
38
+ })
39
+ })
40
+ });
41
+
42
+ pane.append();
43
+ SC.RunLoop.begin().end();
44
+
45
+ ok(true, "displays scroll view without throwing an exception");
46
+ } finally {
47
+ if (pane) { pane.remove(); }
48
+ }
49
+ });
50
+
@@ -0,0 +1,143 @@
1
+ // ==========================================================================
2
+ // Project: SproutCore - JavaScript Application Framework
3
+ // Copyright: ©2006-2011 Strobe Inc. and contributors.
4
+ // portions copyright @2011 Apple Inc.
5
+ // License: Licensed under MIT license (see license.js)
6
+ // ==========================================================================
7
+
8
+ /*global module test htmlbody ok equals same stop start */
9
+
10
+ var pane, view , view2;
11
+ var appleURL='http://photos4.meetupstatic.com/photos/event/4/6/9/9/600_4518073.jpeg';
12
+ module("SC.ScrollView",{
13
+ setup: function() {
14
+ SC.RunLoop.begin();
15
+ pane = SC.MainPane.create({
16
+ childViews: [
17
+ SC.ScrollView.extend({
18
+ contentView: SC.ImageView.design({value: appleURL, layout: {height:4000, width:4000}})
19
+ }),
20
+ SC.ScrollView.extend({
21
+ contentView: SC.ImageView.design({value: appleURL, layout: {height:2000, width:2000}})
22
+ })
23
+
24
+ ],
25
+
26
+ expectedVertLine: function(line) {
27
+ var ret = view.get('verticalLineScroll')*line;
28
+ var alt = view.get('maximumVerticalScrollOffset');
29
+ ret = (ret > alt)? alt : ret;
30
+ return ret;
31
+ },
32
+ expectedHorzLine: function(line) {
33
+ var ret = view.get('horizontalLineScroll')*line;
34
+ var alt = view.get('maximumHorizontalScrollOffset');
35
+ ret = (ret > alt)? alt : ret;
36
+ return ret;
37
+ },
38
+ expectedVertPage: function(page) {
39
+ var ret = view.get('verticalPageScroll')*page;
40
+ var alt = view.get('maximumVerticalScrollOffset');
41
+ ret = (ret > alt)? alt : ret;
42
+ return ret;
43
+ },
44
+ expectedHorzPage: function(page) {
45
+ var ret = view.get('horizontalPageScroll')*page;
46
+ var alt = view.get('maximumHorizontalScrollOffset');
47
+ ret = (ret > alt)? alt : ret;
48
+ return ret;
49
+ }
50
+ });
51
+
52
+
53
+ pane.append(); // make sure there is a layer...
54
+ SC.RunLoop.end();
55
+ view = pane.childViews[0];
56
+ view.get('containerView').get('frame').height = 100;
57
+ view.get('containerView').get('frame').width = 100;
58
+
59
+ view2 = pane.childViews[1];
60
+ view2.get('containerView').get('frame').height = 100;
61
+ view2.get('containerView').get('frame').width = 100;
62
+
63
+ },
64
+
65
+ teardown: function() {
66
+ pane.remove();
67
+ pane = view = null ;
68
+ }
69
+ });
70
+
71
+
72
+
73
+ test("Scrolling to a certain co-ordinate of the container view", function() {
74
+ equals(view.get('horizontalScrollOffset'), 0, "Initial horizontal offset must be zero");
75
+ equals(view.get('verticalScrollOffset'), 0, "Initial vertical offset must be zero");
76
+ SC.RunLoop.begin();
77
+ view.scrollTo(100, 100);
78
+ SC.RunLoop.end();
79
+
80
+ equals(view.get('horizontalScrollOffset'), 100, "After scrolling to 100, horizontal offset must be");
81
+ equals(view.get('verticalScrollOffset'), 100, "After scrolling to 100, vertical offset must be");
82
+ view.scrollTo(5000, 5000);
83
+ equals(view.get('horizontalScrollOffset'), view.get('maximumHorizontalScrollOffset'), "After scrolling to 400, horizontal offset must be maximum");
84
+ equals(view.get('verticalScrollOffset'), view.get('maximumVerticalScrollOffset'), "After scrolling to 400, vertical offset must be maximum");
85
+ });
86
+
87
+ test("Scrolling relative to the current possition of the container view", function() {
88
+ equals(view.get('horizontalScrollOffset'), 0, "Initial horizontal offset must be zero");
89
+ equals(view.get('verticalScrollOffset'), 0, "Initial vertical offset must be zero");
90
+ view.scrollBy(100, 100);
91
+ equals(view.get('horizontalScrollOffset'), 100, "After scrolling by 100, horizontal offset must be");
92
+ equals(view.get('verticalScrollOffset'), 100, "After scrolling by 100, vertical offset must be");
93
+ view.scrollBy(100, 100);
94
+ equals(view.get('horizontalScrollOffset'), 200, "After scrolling by 100, horizontal offset must be");
95
+ equals(view.get('verticalScrollOffset'), 200, "After scrolling by 100, vertical offset must be");
96
+ view.scrollBy(5000, 5000);
97
+ equals(view.get('horizontalScrollOffset'), view.get('maximumHorizontalScrollOffset'), "After scrolling by 400, horizontal offset must be maximum");
98
+ equals(view.get('verticalScrollOffset'), view.get('maximumVerticalScrollOffset'), "After scrolling by 400, vertical offset must be maximum");
99
+ });
100
+
101
+ test("Scrolling through line by line", function() {
102
+ var line = 3;
103
+ equals(view.get('horizontalScrollOffset'), 0, "Initial horizontal offset must be zero");
104
+ equals(view.get('verticalScrollOffset'), 0, "Initial vertical offset must be zero");
105
+ view.scrollDownLine(line);
106
+ equals(view.get('horizontalScrollOffset'), 0, "After scrolling down by lines, horizontal offset is unchanged");
107
+ equals(view.get('verticalScrollOffset'), pane.expectedVertLine(line), "After scrolling down by lines, vertical offset must be");
108
+ view.scrollUpLine(line);
109
+ });
110
+
111
+ test("maximumHorizontalScrollOffset() returns the maximum horizontal scroll dimention", function() {
112
+ var old_horizontalScrollOffset=2;
113
+ var old_verticalScrollOffset=2;
114
+
115
+ view2.set('horizontalScrollOffset',old_horizontalScrollOffset);
116
+ view2.set('verticalScrollOffset',old_verticalScrollOffset);
117
+ view2.scrollBy(5000, 0);
118
+ view2.get('horizontalScrollOffset');
119
+
120
+ equals(view2.get('horizontalScrollOffset'),1900, 'maximum y coordinate should be 1900');
121
+
122
+ view2.set('horizontalScrollOffset',old_horizontalScrollOffset);
123
+ view2.set('verticalScrollOffset',old_verticalScrollOffset);
124
+ view2.scrollBy(-5000,0);
125
+ equals(view2.get('horizontalScrollOffset'),0, 'minimum y coordinate should be 0');
126
+
127
+ });
128
+
129
+ test("maximumVerticalScrollOffset() returns the maximum vertical scroll dimention", function() {
130
+ var old_horizontalScrollOffset=2;
131
+ var old_verticalScrollOffset=2;
132
+
133
+ view2.set('horizontalScrollOffset',old_horizontalScrollOffset);
134
+ view2.set('verticalScrollOffset',old_verticalScrollOffset);
135
+ view2.scrollBy(0, 5000);
136
+ view2.get('maximumVerticalScrollOffset');
137
+ equals(view2.get('verticalScrollOffset'),1900, 'maximum coordinate should be 1900');
138
+ view2.set('horizontalScrollOffset',old_horizontalScrollOffset);
139
+ view2.set('verticalScrollOffset',old_verticalScrollOffset);
140
+ view2.scrollBy(0,-5000);
141
+ equals(view2.get('verticalScrollOffset'),0, 'The minimum y coordinate should be 0');
142
+
143
+ });
@@ -0,0 +1,258 @@
1
+ // ==========================================================================
2
+ // Project: SproutCore - JavaScript Application Framework
3
+ // Copyright: ©2006-2011 Strobe Inc. and contributors.
4
+ // portions copyright @2011 Apple Inc.
5
+ // License: Licensed under MIT license (see license.js)
6
+ // ==========================================================================
7
+
8
+ /*global module test ok equals same stop start */
9
+
10
+ (function() {
11
+ var appleURL="http://photos4.meetupstatic.com/photos/event/4/6/9/9/600_4518073.jpeg";
12
+ var iv=SC.ImageView.design({value: appleURL, layout: {height:400, width:400}});
13
+ var pane = SC.ControlTestPane.design({ height: 100 })
14
+ .add("basic", SC.ScrollView, {
15
+
16
+ })
17
+
18
+ .add("basic2", SC.ScrollView, {
19
+ contentView: iv
20
+ })
21
+
22
+ .add("basic3", SC.ScrollView, {
23
+ contentView: iv,
24
+ isHorizontalScrollerVisible: NO,
25
+ autohidesHorizontalScroller: NO,
26
+ autohidesVerticalScroller: NO
27
+ })
28
+
29
+ .add("nestedHoriz", SC.ScrollView, {
30
+ layout: { width: 100, height: 440 },
31
+
32
+ contentView: SC.ScrollView.design({
33
+ layout: { width: 200, height: 420 },
34
+ contentView: iv
35
+ })
36
+ })
37
+
38
+ .add("nestedVert", SC.ScrollView, {
39
+ layout: { width: 440, height: 100 },
40
+
41
+ contentView: SC.ScrollView.design({
42
+ layout: { width: 420, height: 200 },
43
+ contentView: iv
44
+ })
45
+ })
46
+
47
+ .add("nestedVertInHoriz", SC.ScrollView, {
48
+ layout: { width: 100, height: 220 },
49
+
50
+ contentView: SC.ScrollView.design({
51
+ layout: { width: 420, height: 200 },
52
+ contentView: iv
53
+ })
54
+ })
55
+
56
+ .add("nestedHorizInVert", SC.ScrollView, {
57
+ layout: { width: 220, height: 100 },
58
+
59
+ contentView: SC.ScrollView.design({
60
+ layout: { width: 200, height: 420 },
61
+ contentView: iv
62
+ })
63
+ })
64
+
65
+ .add("disabled", SC.ScrollView, {
66
+ isEnabled: NO
67
+ })
68
+
69
+ .add("verticalScrollerBottom",SC.ScrollView, {
70
+ contentView: iv,
71
+ hasHorizontalScroller : NO,
72
+ verticalScrollerBottom: 16,
73
+ isVerticalScrollerVisible: YES,
74
+ autohidesVerticalScroller: NO
75
+
76
+ })
77
+ .add("aria-controls_attribute", SC.ScrollView, {
78
+ contentView: iv
79
+ });
80
+
81
+ pane.show(); // add a test to show the test pane
82
+
83
+ // ..........................................................
84
+ // TEST VIEWS
85
+ //
86
+ module('SC.ScrollView UI', pane.standardSetup());
87
+
88
+ test("basic", function() {
89
+ var view = pane.view('basic');
90
+ ok(!view.$().hasClass('disabled'), 'should not have disabled class');
91
+ ok(!view.$().hasClass('sel'), 'should not have sel class');
92
+
93
+ equals(view.getPath('childViews.length'), 3, 'scroll view should have only three child views');
94
+
95
+ var containerView = view.get('containerView') ;
96
+ ok(containerView, 'scroll views should have a container view');
97
+ ok(containerView.kindOf(SC.ContainerView), 'default containerView is a kind of SC.ContainerView');
98
+ ok(containerView.get('contentView') === null, 'default containerView should have a null contentView itself');
99
+ ok(view.get('contentView') === null, 'scroll view should have no contentView by default');
100
+ equals(containerView.getPath('childViews.length'), 0, 'containerView should have no child views');
101
+
102
+ var horizontalScrollerView = view.get('horizontalScrollerView');
103
+ ok(view.get('hasHorizontalScroller'), 'default scroll view wants a horizontal scroller');
104
+ ok(horizontalScrollerView, 'default scroll view has a horizontal scroller');
105
+
106
+ var verticalScrollerView = view.get('verticalScrollerView');
107
+ ok(view.get('hasVerticalScroller'), 'default scroll view wants a vertical scroller');
108
+ ok(verticalScrollerView, 'default scroll view has a vertical scroller');
109
+ });
110
+
111
+ test("basic2", function() {
112
+ var view = pane.view('basic2');
113
+ ok(view.$().hasClass('sc-scroll-view'), 'should have sc-scroll-view class');
114
+
115
+ var horizontalScrollerView = view.get('horizontalScrollerView');
116
+ ok(view.get('hasHorizontalScroller'), 'default scroll view wants a horizontal scroller');
117
+ ok(horizontalScrollerView, 'default scroll view has a horizontal scroller');
118
+ ok(horizontalScrollerView.$().hasClass('sc-horizontal'), 'should have sc-horizontal class');
119
+ var maxHScroll = view.maximumHorizontalScrollOffset();
120
+ ok((maxHScroll > 0), 'Max horizontal scroll should be greater than zero');
121
+
122
+ var verticalScrollerView = view.get('verticalScrollerView');
123
+ ok(view.get('hasVerticalScroller'), 'default scroll view wants a vertical scroller');
124
+ ok(verticalScrollerView, 'default scroll view has a vertical scroller');
125
+ ok(verticalScrollerView.$().hasClass('sc-vertical'), 'should have sc-vertical class');
126
+ var maxVScroll = view.maximumVerticalScrollOffset();
127
+ ok((maxVScroll > 0), 'Max vertical scroll should be greater than zero');
128
+
129
+ view.scrollTo(0,100);
130
+ SC.RunLoop.begin().end();
131
+ var elem = view.get('containerView').$()[0];
132
+ equals(elem.scrollTop, 100, 'vertical scrolling should adjust scrollTop of container view');
133
+
134
+ view.scrollTo(50,0);
135
+ SC.RunLoop.begin().end();
136
+ elem = view.get('containerView').$()[0];
137
+ equals(elem.scrollLeft, 50, 'horizontal scrolling should adjust scrollLeft of container view');
138
+ });
139
+
140
+ test("basic3", function() {
141
+ var view = pane.view('basic3');
142
+ view.set('isHorizontalScrollerVisible',NO);
143
+ ok(!view.get('canScrollHorizontal'),'cannot scroll in horizontal direction');
144
+ ok(view.$().hasClass('sc-scroll-view'), 'should have sc-scroll-view class');
145
+ var horizontalScrollerView = view.get('horizontalScrollerView');
146
+ ok(view.get('hasHorizontalScroller'), 'default scroll view wants a horizontal scroller');
147
+ ok(horizontalScrollerView, 'default scroll view has a horizontal scroller');
148
+ ok(horizontalScrollerView.$().hasClass('sc-horizontal'), 'should have sc-horizontal class');
149
+ var maxHScroll = view.maximumHorizontalScrollOffset();
150
+ equals(maxHScroll , 0, 'Max horizontal scroll should be equal to zero');
151
+
152
+ view.set('isVerticalScrollerVisible',NO);
153
+ ok(!view.get('canScrollVertical'),'cannot scroll in vertical direction');
154
+ var verticalScrollerView = view.get('verticalScrollerView');
155
+ ok(view.get('hasVerticalScroller'), 'default scroll view wants a vertical scroller');
156
+ ok(verticalScrollerView, 'default scroll view has a vertical scroller');
157
+ ok(verticalScrollerView.$().hasClass('sc-vertical'), 'should have sc-vertical class');
158
+ var maxVScroll = view.maximumVerticalScrollOffset();
159
+ equals(maxVScroll ,0, 'Max vertical scroll should be equal to zero');
160
+ });
161
+
162
+ test("nestedHoriz", function() {
163
+ var view = pane.view('nestedHoriz');
164
+ ok(view.get('canScrollHorizontal'),'can scroll in horizontal direction');
165
+ ok(!view.get('canScrollVertical'),'cannot scroll in vertical direction');
166
+ ok(view.$().hasClass('sc-scroll-view'), 'should have sc-scroll-view class');
167
+ equals(view.$('> .sc-scroll-container-view').css('overflow-x'), 'scroll', 'should have \'overflow-x\': \'scroll\' style');
168
+ equals(view.$('> .sc-scroll-container-view').css('overflow-y'), 'hidden', 'should have \'overflow-y\': \'hidden\' style');
169
+ var nestedView = view.get('contentView');
170
+ ok(nestedView.get('canScrollHorizontal'),'can scroll in horizontal direction');
171
+ ok(!nestedView.get('canScrollVertical'),'cannot scroll in vertical direction');
172
+ ok(nestedView.$().hasClass('sc-scroll-view'), 'should have sc-scroll-view class');
173
+ equals(nestedView.$('> .sc-scroll-container-view').css('overflow-x'), 'scroll', 'should have \'overflow-x\': \'scroll\' style');
174
+ equals(nestedView.$('> .sc-scroll-container-view').css('overflow-y'), 'hidden', 'should have \'overflow-y\': \'hidden\' style');
175
+ });
176
+
177
+ test("nestedVert", function() {
178
+ var view = pane.view('nestedVert');
179
+ ok(!view.get('canScrollHorizontal'),'can scroll in horizontal direction');
180
+ ok(view.get('canScrollVertical'),'cannot scroll in vertical direction');
181
+ ok(view.$().hasClass('sc-scroll-view'), 'should have sc-scroll-view class');
182
+ equals(view.$('> .sc-scroll-container-view').css('overflow-x'), 'hidden', 'should have \'overflow-x\': \'scroll\' style');
183
+ equals(view.$('> .sc-scroll-container-view').css('overflow-y'), 'scroll', 'should have \'overflow-y\': \'hidden\' style');
184
+ var nestedView = view.get('contentView');
185
+ ok(!nestedView.get('canScrollHorizontal'),'can scroll in horizontal direction');
186
+ ok(nestedView.get('canScrollVertical'),'cannot scroll in vertical direction');
187
+ ok(nestedView.$().hasClass('sc-scroll-view'), 'should have sc-scroll-view class');
188
+ equals(nestedView.$('> .sc-scroll-container-view').css('overflow-x'), 'hidden', 'should have \'overflow-x\': \'scroll\' style');
189
+ equals(nestedView.$('> .sc-scroll-container-view').css('overflow-y'), 'scroll', 'should have \'overflow-y\': \'hidden\' style');
190
+ });
191
+
192
+ test("nestedVertInHoriz", function() {
193
+ var view = pane.view('nestedVertInHoriz');
194
+ ok(view.get('canScrollHorizontal'),'can scroll in horizontal direction');
195
+ ok(!view.get('canScrollVertical'),'cannot scroll in vertical direction');
196
+ ok(view.$().hasClass('sc-scroll-view'), 'should have sc-scroll-view class');
197
+ equals(view.$('> .sc-scroll-container-view').css('overflow-x'), 'scroll', 'should have \'overflow-x\': \'scroll\' style');
198
+ equals(view.$('> .sc-scroll-container-view').css('overflow-y'), 'hidden', 'should have \'overflow-y\': \'hidden\' style');
199
+ var nestedView = view.get('contentView');
200
+ ok(!nestedView.get('canScrollHorizontal'),'can scroll in horizontal direction');
201
+ ok(nestedView.get('canScrollVertical'),'cannot scroll in vertical direction');
202
+ ok(nestedView.$().hasClass('sc-scroll-view'), 'should have sc-scroll-view class');
203
+ equals(nestedView.$('> .sc-scroll-container-view').css('overflow-x'), 'hidden', 'should have \'overflow-x\': \'scroll\' style');
204
+ equals(nestedView.$('> .sc-scroll-container-view').css('overflow-y'), 'scroll', 'should have \'overflow-y\': \'hidden\' style');
205
+ });
206
+
207
+ test("nestedHorizInVert", function() {
208
+ var view = pane.view('nestedHorizInVert');
209
+ ok(!view.get('canScrollHorizontal'),'can scroll in horizontal direction');
210
+ ok(view.get('canScrollVertical'),'cannot scroll in vertical direction');
211
+ ok(view.$().hasClass('sc-scroll-view'), 'should have sc-scroll-view class');
212
+ equals(view.$('> .sc-scroll-container-view').css('overflow-x'), 'hidden', 'should have \'overflow-x\': \'scroll\' style');
213
+ equals(view.$('> .sc-scroll-container-view').css('overflow-y'), 'scroll', 'should have \'overflow-y\': \'hidden\' style');
214
+ var nestedView = view.get('contentView');
215
+ ok(nestedView.get('canScrollHorizontal'),'can scroll in horizontal direction');
216
+ ok(!nestedView.get('canScrollVertical'),'cannot scroll in vertical direction');
217
+ ok(nestedView.$().hasClass('sc-scroll-view'), 'should have sc-scroll-view class');
218
+ equals(nestedView.$('> .sc-scroll-container-view').css('overflow-x'), 'scroll', 'should have \'overflow-x\': \'scroll\' style');
219
+ equals(nestedView.$('> .sc-scroll-container-view').css('overflow-y'), 'hidden', 'should have \'overflow-y\': \'hidden\' style');
220
+ });
221
+
222
+ test("disabled", function() {
223
+ var view = pane.view('disabled');
224
+ ok(view.$().hasClass('disabled'), 'should have disabled class');
225
+ ok(!view.$().hasClass('sel'), 'should not have sel class');
226
+ });
227
+
228
+ test("non-zero bottom in vertical scrollbar", function() {
229
+ var view = pane.view('verticalScrollerBottom');
230
+ equals(view.get('verticalScrollerBottom'),16, "should have verticalScrollerBottom as ");
231
+ var scroller = view.get('verticalScrollerView') ;
232
+ ok(scroller, 'should have vertical scroller view ');
233
+ equals(scroller.get('layout').bottom,16, 'should have layout.bottom of scroller as ');
234
+ equals(scroller.$()[0].style.bottom,'16px', 'should have style.bottom of scroller as ');
235
+ });
236
+
237
+ test('ScrollView should readjust scrollTop/scrollLeft if layer changes', function() {
238
+ var view = pane.view('basic2'), cv = view.get('contentView'), container = view.get('containerView') ;
239
+ view.scrollTo(10, 10);
240
+ SC.RunLoop.begin().end();
241
+ equals(container.get('layer').scrollLeft, 10, 'precond - scrollLeft is set to 10');
242
+ equals(container.get('layer').scrollTop, 10, 'precond- scrollTop is set to 10');
243
+ cv.replaceLayer();
244
+ SC.RunLoop.begin().end();
245
+ equals(container.get('layer').scrollLeft, 10, 'scrollLeft should be readjusted to 10');
246
+ equals(container.get('layer').scrollTop, 10, 'scrollTop should be readjust to 10');
247
+ });
248
+
249
+ test('Scroller views of scroll view should have aria-controls set to its content', function() {
250
+ var view = pane.view("aria-controls_attribute"),
251
+ horizontalScrollerView = view.get('horizontalScrollerView'),
252
+ verticalScrollerView = view.get('verticalScrollerView'),
253
+ contentView = view.get('contentView').get('layerId');
254
+
255
+ equals(horizontalScrollerView.$().attr('aria-controls'), contentView, "horizontalScroller has aria-controls set");
256
+ equals(verticalScrollerView.$().attr('aria-controls'), contentView, "verticalScroller has aria-controls set");
257
+ });
258
+ })();