sproutcore 0.9.1 → 0.9.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (208) hide show
  1. data/History.txt +233 -0
  2. data/Manifest.txt +67 -34
  3. data/bin/sc-build +12 -1
  4. data/bin/sc-gen +1 -1
  5. data/bin/sproutcore +14 -0
  6. data/clients/sc_docs/controllers/docs.js +38 -8
  7. data/clients/sc_docs/english.lproj/body.css +80 -127
  8. data/clients/sc_docs/english.lproj/body.rhtml +43 -23
  9. data/clients/sc_docs/english.lproj/no_docs.rhtml +2 -1
  10. data/clients/sc_docs/english.lproj/tabs.rhtml +16 -0
  11. data/clients/sc_docs/main.js +14 -9
  12. data/clients/sc_docs/models/doc.js +1 -1
  13. data/clients/sc_docs/tests/controllers/docs.rhtml +1 -2
  14. data/clients/sc_docs/tests/models/doc.rhtml +1 -2
  15. data/clients/sc_docs/tests/views/doc_frame.rhtml +1 -2
  16. data/clients/sc_docs/tests/views/doc_label_view.rhtml +1 -2
  17. data/clients/sc_docs/views/doc_frame.js +1 -1
  18. data/clients/sc_test_runner/controllers/runner.js +31 -8
  19. data/clients/sc_test_runner/english.lproj/body.css +62 -122
  20. data/clients/sc_test_runner/english.lproj/body.rhtml +62 -26
  21. data/clients/sc_test_runner/main.js +1 -6
  22. data/clients/sc_test_runner/models/test.js +14 -1
  23. data/clients/sc_test_runner/views/runner_frame.js +4 -2
  24. data/clients/view_builder/builders/builder.js +339 -0
  25. data/clients/view_builder/builders/button.js +81 -0
  26. data/clients/view_builder/controllers/document.js +21 -0
  27. data/clients/view_builder/core.js +19 -0
  28. data/clients/view_builder/english.lproj/body.css +77 -0
  29. data/clients/view_builder/english.lproj/body.rhtml +41 -0
  30. data/clients/{sc_docs → view_builder}/english.lproj/controls.css +0 -0
  31. data/clients/view_builder/english.lproj/strings.js +14 -0
  32. data/clients/view_builder/main.js +38 -0
  33. data/clients/view_builder/tests/controllers/document.rhtml +20 -0
  34. data/clients/view_builder/tests/views/builder.rhtml +20 -0
  35. data/clients/view_builder/views/builder.js +23 -0
  36. data/frameworks/prototype/prototype.js +1 -1
  37. data/frameworks/sproutcore/Core.js +32 -7
  38. data/frameworks/sproutcore/README +1 -1
  39. data/frameworks/sproutcore/animation/animation.js +411 -0
  40. data/frameworks/sproutcore/controllers/array.js +17 -9
  41. data/frameworks/sproutcore/controllers/collection.js +9 -110
  42. data/frameworks/sproutcore/controllers/controller.js +1 -1
  43. data/frameworks/sproutcore/controllers/object.js +2 -1
  44. data/frameworks/sproutcore/drag/drag.js +267 -56
  45. data/frameworks/sproutcore/drag/drag_data_source.js +24 -16
  46. data/frameworks/sproutcore/drag/drag_source.js +53 -42
  47. data/frameworks/sproutcore/drag/drop_target.js +2 -2
  48. data/frameworks/sproutcore/english.lproj/buttons.css +337 -236
  49. data/frameworks/sproutcore/english.lproj/core.css +115 -0
  50. data/frameworks/sproutcore/english.lproj/icons.css +227 -0
  51. data/{clients/sc_docs → frameworks/sproutcore}/english.lproj/images/indicator.gif +0 -0
  52. data/frameworks/sproutcore/english.lproj/images/sc-theme-sprite.png +0 -0
  53. data/frameworks/sproutcore/english.lproj/images/sc-theme-ysprite.png +0 -0
  54. data/frameworks/sproutcore/english.lproj/images/shared-icons.png +0 -0
  55. data/frameworks/sproutcore/english.lproj/menu.css +1 -1
  56. data/frameworks/sproutcore/english.lproj/strings.js +1 -1
  57. data/frameworks/sproutcore/english.lproj/theme.css +405 -31
  58. data/frameworks/sproutcore/foundation/application.js +15 -11
  59. data/frameworks/sproutcore/foundation/benchmark.js +1 -1
  60. data/frameworks/sproutcore/foundation/binding.js +2 -2
  61. data/frameworks/sproutcore/foundation/date.js +1 -1
  62. data/frameworks/sproutcore/foundation/error.js +1 -1
  63. data/frameworks/sproutcore/foundation/input_manager.js +32 -21
  64. data/frameworks/sproutcore/foundation/mock.js +1 -1
  65. data/frameworks/sproutcore/foundation/node_descriptor.js +9 -6
  66. data/frameworks/sproutcore/foundation/object.js +249 -177
  67. data/frameworks/sproutcore/foundation/page.js +5 -2
  68. data/frameworks/sproutcore/foundation/path_module.js +11 -10
  69. data/frameworks/sproutcore/foundation/responder.js +5 -2
  70. data/frameworks/sproutcore/foundation/routes.js +17 -13
  71. data/frameworks/sproutcore/foundation/run_loop.js +249 -11
  72. data/frameworks/sproutcore/foundation/server.js +1 -1
  73. data/frameworks/sproutcore/foundation/set.js +3 -3
  74. data/frameworks/sproutcore/foundation/string.js +5 -3
  75. data/frameworks/sproutcore/foundation/timer.js +371 -0
  76. data/frameworks/sproutcore/foundation/undo_manager.js +1 -1
  77. data/frameworks/sproutcore/foundation/unittest.js +3 -3
  78. data/frameworks/sproutcore/foundation/utils.js +161 -2
  79. data/frameworks/sproutcore/globals/panels.js +1 -1
  80. data/frameworks/sproutcore/globals/popups.js +4 -3
  81. data/frameworks/sproutcore/globals/window.js +44 -4
  82. data/frameworks/sproutcore/lib/button_views.rb +328 -0
  83. data/frameworks/sproutcore/lib/collection_view.rb +80 -0
  84. data/frameworks/sproutcore/lib/core_views.rb +281 -0
  85. data/frameworks/sproutcore/lib/form_views.rb +253 -0
  86. data/frameworks/sproutcore/lib/index.rhtml +2 -0
  87. data/frameworks/sproutcore/lib/menu_views.rb +88 -0
  88. data/frameworks/sproutcore/{foundation → mixins}/array.js +60 -29
  89. data/frameworks/sproutcore/mixins/control.js +265 -0
  90. data/frameworks/sproutcore/mixins/delegate_support.js +66 -0
  91. data/frameworks/sproutcore/{foundation → mixins}/observable.js +176 -6
  92. data/frameworks/sproutcore/mixins/scrollable.js +245 -0
  93. data/frameworks/sproutcore/mixins/selection_support.js +148 -0
  94. data/frameworks/sproutcore/mixins/validatable.js +152 -0
  95. data/frameworks/sproutcore/models/collection.js +5 -5
  96. data/frameworks/sproutcore/models/record.js +1 -1
  97. data/frameworks/sproutcore/models/store.js +1 -1
  98. data/frameworks/sproutcore/panes/dialog.js +1 -1
  99. data/frameworks/sproutcore/panes/manager.js +1 -1
  100. data/frameworks/sproutcore/panes/menu.js +1 -1
  101. data/frameworks/sproutcore/panes/overlay.js +2 -2
  102. data/frameworks/sproutcore/panes/panel.js +1 -1
  103. data/frameworks/sproutcore/panes/picker.js +1 -1
  104. data/frameworks/sproutcore/tests/controllers/array.rhtml +44 -4
  105. data/frameworks/sproutcore/tests/foundation/timer/invalidate.rhtml +33 -0
  106. data/frameworks/sproutcore/tests/foundation/timer/invokeLater.rhtml +145 -0
  107. data/frameworks/sproutcore/tests/foundation/timer/isPaused.rhtml +70 -0
  108. data/frameworks/sproutcore/tests/foundation/timer/schedule.rhtml +145 -0
  109. data/frameworks/sproutcore/tests/views/{scroll.rhtml → checkbox.rhtml} +3 -3
  110. data/frameworks/sproutcore/tests/views/{collection.rhtml → collection/base.rhtml} +33 -32
  111. data/frameworks/sproutcore/tests/views/collection/incremental_rendering.rhtml +260 -0
  112. data/frameworks/sproutcore/tests/views/image_cell.rhtml +19 -0
  113. data/frameworks/sproutcore/tests/views/label_item.rhtml +2 -4
  114. data/frameworks/sproutcore/tests/views/list.rhtml +2 -3
  115. data/frameworks/sproutcore/tests/views/list_item.rhtml +20 -0
  116. data/frameworks/sproutcore/tests/views/slider.rhtml +20 -0
  117. data/frameworks/sproutcore/tests/views/text_cell.rhtml +19 -0
  118. data/frameworks/sproutcore/tests/views/view/clippingFrame.rhtml +395 -0
  119. data/frameworks/sproutcore/tests/views/view/frame.rhtml +353 -0
  120. data/frameworks/sproutcore/tests/views/view/innerFrame.rhtml +347 -0
  121. data/frameworks/sproutcore/tests/views/view/isVisibleInWindow.rhtml +148 -0
  122. data/frameworks/sproutcore/tests/views/view/scrollFrame.rhtml +468 -0
  123. data/frameworks/sproutcore/validators/credit_card.js +33 -13
  124. data/frameworks/sproutcore/validators/date.js +26 -6
  125. data/frameworks/sproutcore/validators/email.js +21 -3
  126. data/frameworks/sproutcore/validators/not_empty.js +11 -1
  127. data/frameworks/sproutcore/validators/number.js +18 -4
  128. data/frameworks/sproutcore/validators/password.js +12 -1
  129. data/frameworks/sproutcore/validators/validator.js +204 -194
  130. data/frameworks/sproutcore/views/{button.js → button/button.js} +96 -94
  131. data/frameworks/sproutcore/views/button/checkbox.js +29 -0
  132. data/frameworks/sproutcore/views/button/disclosure.js +42 -0
  133. data/frameworks/sproutcore/views/button/radio.js +29 -0
  134. data/frameworks/sproutcore/views/{collection.js → collection/collection.js} +1373 -1024
  135. data/frameworks/sproutcore/views/collection/grid.js +124 -46
  136. data/frameworks/sproutcore/views/collection/image_cell.js +17 -46
  137. data/frameworks/sproutcore/views/collection/list.js +45 -35
  138. data/frameworks/sproutcore/views/collection/source_list.js +386 -0
  139. data/frameworks/sproutcore/views/collection/table.js +118 -0
  140. data/frameworks/sproutcore/views/container.js +7 -2
  141. data/frameworks/sproutcore/views/error_explanation.js +23 -10
  142. data/frameworks/sproutcore/views/{checkbox_field.js → field/checkbox_field.js} +16 -6
  143. data/frameworks/sproutcore/views/field/field.js +219 -0
  144. data/frameworks/sproutcore/views/{radio_field.js → field/radio_field.js} +27 -12
  145. data/frameworks/sproutcore/views/{select_field.js → field/select_field.js} +116 -90
  146. data/frameworks/sproutcore/views/{text_field.js → field/text_field.js} +57 -8
  147. data/frameworks/sproutcore/views/{textarea_field.js → field/textarea_field.js} +13 -3
  148. data/frameworks/sproutcore/views/filter_button.js +2 -2
  149. data/frameworks/sproutcore/views/form.js +3 -3
  150. data/frameworks/sproutcore/views/image.js +128 -21
  151. data/frameworks/sproutcore/views/inline_text_editor.js +1 -1
  152. data/frameworks/sproutcore/views/label.js +149 -92
  153. data/frameworks/sproutcore/views/list_item.js +225 -0
  154. data/frameworks/sproutcore/views/menu_item.js +10 -4
  155. data/frameworks/sproutcore/views/pagination.js +11 -4
  156. data/frameworks/sproutcore/views/popup_button.js +25 -21
  157. data/frameworks/sproutcore/views/popup_menu.js +10 -4
  158. data/frameworks/sproutcore/views/progress.js +29 -16
  159. data/frameworks/sproutcore/views/radio_group.js +1 -1
  160. data/frameworks/sproutcore/views/scroll.js +60 -20
  161. data/frameworks/sproutcore/views/segmented.js +1 -1
  162. data/frameworks/sproutcore/views/slider.js +132 -0
  163. data/frameworks/sproutcore/views/source_list_group.js +130 -0
  164. data/frameworks/sproutcore/views/spinner.js +1 -1
  165. data/frameworks/sproutcore/views/split.js +292 -0
  166. data/frameworks/sproutcore/views/split_divider.js +109 -0
  167. data/frameworks/sproutcore/views/tab.js +1 -1
  168. data/frameworks/sproutcore/views/toolbar.js +1 -1
  169. data/frameworks/sproutcore/views/view.js +1272 -591
  170. data/generators/client/templates/english.lproj/body.css +1 -1
  171. data/generators/controller/controller_generator.rb +1 -1
  172. data/generators/controller/templates/test.rhtml +2 -1
  173. data/generators/model/templates/test.rhtml +1 -1
  174. data/generators/test/templates/test.rhtml +1 -1
  175. data/generators/view/templates/test.rhtml +1 -1
  176. data/jsdoc/templates/sproutcore/class.tmpl +241 -338
  177. data/jsdoc/templates/sproutcore/default.css +105 -155
  178. data/jsdoc/templates/sproutcore/index.tmpl +43 -8
  179. data/jsdoc/templates/sproutcore/publish.js +9 -4
  180. data/lib/sproutcore/build_tools/html_builder.rb +29 -13
  181. data/lib/sproutcore/build_tools/resource_builder.rb +1 -1
  182. data/lib/sproutcore/bundle.rb +86 -25
  183. data/lib/sproutcore/jsdoc.rb +2 -0
  184. data/lib/sproutcore/version.rb +1 -1
  185. data/lib/sproutcore/view_helpers.rb +36 -3
  186. data/tasks/deployment.rake +1 -1
  187. metadata +69 -36
  188. data/clients/sc_docs/english.lproj/icons/small/next.png +0 -0
  189. data/clients/sc_docs/english.lproj/icons/small/reset.png +0 -0
  190. data/clients/sc_docs/english.lproj/images/gradients.png +0 -0
  191. data/clients/sc_docs/english.lproj/images/toolbar.png +0 -0
  192. data/clients/sc_docs/english.lproj/warning.rhtml +0 -6
  193. data/clients/sc_test_runner/english.lproj/warning.rhtml +0 -6
  194. data/frameworks/sproutcore/english.lproj/buttons.png +0 -0
  195. data/frameworks/sproutcore/english.lproj/collections.css +0 -82
  196. data/frameworks/sproutcore/english.lproj/images/buttons-sprite.png +0 -0
  197. data/frameworks/sproutcore/views/collection/collection_item.js +0 -36
  198. data/frameworks/sproutcore/views/collection/text_cell.js +0 -128
  199. data/frameworks/sproutcore/views/field.js +0 -214
  200. data/frameworks/sproutcore/views/workspace.js +0 -170
  201. data/generators/client/templates/english.lproj/controls.css +0 -0
  202. data/generators/framework/templates/english.lproj/body.css +0 -0
  203. data/generators/framework/templates/english.lproj/body.rhtml +0 -3
  204. data/generators/framework/templates/english.lproj/controls.css +0 -0
  205. data/lib/sproutcore/view_helpers/button_views.rb +0 -302
  206. data/lib/sproutcore/view_helpers/core_views.rb +0 -292
  207. data/lib/sproutcore/view_helpers/form_views.rb +0 -258
  208. data/lib/sproutcore/view_helpers/menu_views.rb +0 -94
@@ -0,0 +1,21 @@
1
+ // ==========================================================================
2
+ // ViewBuilder.DocumentController
3
+ // ==========================================================================
4
+
5
+ require('core');
6
+
7
+ /** @class
8
+
9
+ (Document Your View Here)
10
+
11
+ @extends SC.Object
12
+ @author AuthorName
13
+ @version 0.1
14
+ @static
15
+ */
16
+ ViewBuilder.documentController = SC.Object.create(
17
+ /** @scope ViewBuilder.documentController */ {
18
+
19
+ rootView: null
20
+
21
+ }) ;
@@ -0,0 +1,19 @@
1
+ // ==========================================================================
2
+ // ViewBuilder
3
+ // ==========================================================================
4
+
5
+ ViewBuilder = SC.Object.create({
6
+
7
+ // This will create the server for your application. Add any namespaces
8
+ // your model objects are defined in to the prefix array.
9
+ server: SC.Server.create({ prefix: ['ViewBuilder'] }),
10
+
11
+ // When you are in development mode, this array will be populated with
12
+ // any fixtures you create for testing and loaded automatically in your
13
+ // main method. When in production, this will be an empty array.
14
+ FIXTURES: [],
15
+
16
+ // Any keys in this array will be instantiated automatically from main.
17
+ controllers: [],
18
+
19
+ }) ;
@@ -0,0 +1,77 @@
1
+ /* @override
2
+ http://localhost:4020/static/photos/en/_cache/body-1208305764.css
3
+ http://localhost:4020/static/photos/en/_cache/body-1208344721.css
4
+ http://localhost:4020/static/view_builder/en/_cache/body-1208631407.css
5
+ http://localhost:4020/static/view_builder/en/_cache/body-1208631886.css
6
+ http://localhost:4020/static/view_builder/en/_cache/body-1208632215.css
7
+ http://localhost:4020/static/view_builder/en/_cache/body-1208632366.css
8
+ */
9
+
10
+ /* @group Core */
11
+
12
+ body {
13
+ position: absolute ;
14
+ left: 0;
15
+ right: 0;
16
+ top: 0;
17
+ bottom: 0;
18
+ padding: 0;
19
+ margin: 0;
20
+ overflow: hidden ;
21
+ }
22
+
23
+ .workspace .sidebar {
24
+ position: absolute;
25
+ left: 0;
26
+ top: 0;
27
+ width: 200px;
28
+ bottom: 0;
29
+ }
30
+
31
+ .sc-theme .workspace.horizontal .sc-split-divider-view {
32
+ position: absolute;
33
+ left: 200px;
34
+ top: 0;
35
+ bottom: 0;
36
+ }
37
+
38
+ .workspace .document_view {
39
+ position: absolute;
40
+ left: 205px;
41
+ right: 0;
42
+ top: 0;
43
+ bottom: 0;
44
+ border: none ;
45
+ background-color: #aaa ;
46
+ }
47
+
48
+ .left.app-label {
49
+ font-weight: bold ;
50
+ padding-bottom: 9px;
51
+ text-shadow: white 0px 1px 0px;
52
+ }
53
+
54
+ .app-label img {
55
+ width: 27px;
56
+ height: 27px;
57
+ vertical-align: middle;
58
+ position: relative ;
59
+ top: -3px;
60
+ margin-right: 2px;
61
+ }
62
+
63
+ /* @end */
64
+
65
+ /* @group Sidebar */
66
+
67
+ .sidebar .source_list {
68
+ position: absolute ;
69
+ top: 0;
70
+ left: 0;
71
+ right: 0;
72
+ bottom: 0;
73
+ border: none ;
74
+ }
75
+
76
+ /* @end */
77
+
@@ -0,0 +1,41 @@
1
+ <% content_for('body') do %>
2
+
3
+ <% view :header, :class => 'sc-header sc-square-theme' do %>
4
+ <div class="left app-label">
5
+ <img src="<%= static_url('images/sproutcore-logo.png') %>" />ViewBuilder
6
+ </div>
7
+ <div class="center">
8
+ </div>
9
+ <div class="right">
10
+ </div>
11
+ <% end %>
12
+
13
+
14
+ <% split_view :workspace, :class => 'sc-app-workspace header footer', :direction => :horizontal do %>
15
+ <% view :sidebar, :outlet => true do %>
16
+ <% scroll_view :source_list, :outlet => true do %>
17
+ <%= source_list_view :outlet => true,
18
+ :content_value_key => :name,
19
+ :group_visible_key => true,
20
+ :content_icon_key => :icon %>
21
+ <% end %>
22
+ <% end %>
23
+
24
+ <%= split_divider_view :outlet => true, :width => 5 %>
25
+
26
+ <% scroll_view :document_view, :outlet => true do %>
27
+ <%= view :builder_view, :outlet => true, :view => 'SC.BuilderView', :bind => { :content => 'ViewBuilder.documentController.rootView' } %>
28
+ <% end %>
29
+
30
+ <% end %>
31
+
32
+ <% view :footer, :class => 'sc-footer sc-square-theme' do %>
33
+ <div class="left">
34
+ </div>
35
+ <div class="center"></div>
36
+ <div class="right">
37
+ </div>
38
+ <% end %>
39
+
40
+
41
+ <% end %>
@@ -0,0 +1,14 @@
1
+ // ==========================================================================
2
+ // ViewBuilder English Strings
3
+ // ==========================================================================
4
+
5
+ // Place strings you want to localize here. In your app, use the key and
6
+ // localize it using "key string".loc(). HINT: For your key names, use the
7
+ // english string with an underscore in front. This way you can still see
8
+ // how your UI will look and you'll notice right away when something needs a
9
+ // localized string added to this file!
10
+ //
11
+ Object.extend(String.English,{
12
+ // "_String Key": "Localized String"
13
+ }) ;
14
+
@@ -0,0 +1,38 @@
1
+ // ==========================================================================
2
+ // ViewBuilder
3
+ // ==========================================================================
4
+
5
+ // This is the function that will start your app running. The default
6
+ // implementation will load any fixtures you have created then instantiate
7
+ // your controllers and awake the elements on your page.
8
+ //
9
+ // As you develop your application you will probably want to override this.
10
+ // See comments for some pointers on what to do next.
11
+ //
12
+ function main() {
13
+
14
+ // Step 1: Load Your Model Data
15
+ // The default code here will load the fixtures you have defined.
16
+ // Comment out the preload line and add something to refresh from the server
17
+ // when you are ready to pull data from your server.
18
+ ViewBuilder.server.preload(ViewBuilder.FIXTURES) ;
19
+
20
+ // TODO: refresh() any collections you have created to get their records.
21
+ // ex: ViewBuilder.contacts.refresh() ;
22
+
23
+ // Step 2: Instantiate Your Views
24
+ // The default code just activates all the views you have on the page. If
25
+ // your app gets any level of complexity, you should just get the views you
26
+ // need to show the app in the first place, to speed things up.
27
+ SC.page.awake() ;
28
+
29
+ // Step 3. Set the content property on your primary controller.
30
+ // This will make your app come alive!
31
+
32
+ // TODO: Set the content property on your primary controller
33
+ // ex: ViewBuilder.contactsController.set('content',ViewBuilder.contacts);
34
+ var v = SC.ButtonView.Builder.newBuilder() ;
35
+ ViewBuilder.documentController.set('rootView', v) ;
36
+ } ;
37
+
38
+
@@ -0,0 +1,20 @@
1
+ <% # ========================================================================
2
+ # ViewBuilder.DocumentController Unit Test
3
+ # ========================================================================
4
+ %>
5
+ <% content_for('final') do %>
6
+
7
+ <script>
8
+
9
+ Test.context("ViewBuilder.DocumentController",{
10
+
11
+ "TODO: Add your own tests here": function() {
12
+ true.shouldEqual(true) ;
13
+ }
14
+
15
+ }) ;
16
+
17
+ if (window.main && (appMain = main)) main = null ;
18
+ </script>
19
+
20
+ <% end %>
@@ -0,0 +1,20 @@
1
+ <% # ========================================================================
2
+ # ViewBuilder.BuilderView Unit Test
3
+ # ========================================================================
4
+ %>
5
+ <% content_for('final') do %>
6
+
7
+ <script>
8
+
9
+ Test.context("ViewBuilder.BuilderView",{
10
+
11
+ "TODO: Add your own tests here": function() {
12
+ true.shouldEqual(true) ;
13
+ }
14
+
15
+ }) ;
16
+
17
+ if (window.main && (appMain = main)) main = null ;
18
+ </script>
19
+
20
+ <% end %>
@@ -0,0 +1,23 @@
1
+ // ==========================================================================
2
+ // ViewBuilder.BuilderView
3
+ // ==========================================================================
4
+
5
+ require('core');
6
+
7
+ /** @class
8
+
9
+ A BuilderView displays the visible and editable portion of a view. You
10
+ can plug any generic builder record into a view and it will display the
11
+ content. If the builder is a container, it will also allow you to add
12
+ child views to the container.
13
+
14
+ @extends SC.View
15
+ @author AuthorName
16
+ @version 0.1
17
+ */
18
+ SC.BuilderView = SC.View.extend(
19
+ /** @scope ViewBuilder.BuilderView.prototype */ {
20
+
21
+ // TODO: Add your own code here.
22
+
23
+ }) ;
@@ -1,6 +1,6 @@
1
1
  /* @license
2
2
  * Prototype JavaScript framework, version 1.6.0
3
- * (c) 2005-2007 Sam Stephenson
3
+ * (c) 2005-2008 Sam Stephenson
4
4
  *
5
5
  * Prototype is freely distributable under the terms of an MIT-style license.
6
6
  * For details, see the Prototype web site: http://www.prototypejs.org/
@@ -1,7 +1,7 @@
1
1
  //@license
2
2
  // ==========================================================================
3
3
  // SproutCore -- JavaScript Application Framework
4
- // copyright 2006-2007, Sprout Systems, Inc. and contributors.
4
+ // copyright 2006-2008, Sprout Systems, Inc. and contributors.
5
5
  //
6
6
  // Permission is hereby granted, free of charge, to any person obtaining a
7
7
  // copy of this software and associated documentation files (the "Software"),
@@ -101,7 +101,7 @@ Object.extend(SC,{
101
101
  var r = function() {
102
102
  document.body.removeChild(document.getElementById(frameId));
103
103
  } ;
104
- var t = setTimeout(r,2000);
104
+ var t = r.invokeLater(null, 2000);
105
105
  }
106
106
  },
107
107
 
@@ -204,12 +204,25 @@ Object.extend(SC,{
204
204
  },
205
205
 
206
206
  _nextGUID: 0,
207
- getGUID: function( obj )
208
- {
207
+
208
+ /**
209
+ Returns a unique GUID for the object. If the object does not yet have
210
+ a guid, one will be assigned to it. You can call this on any object,
211
+ SC.Object-based or not, but be aware that it will add a _guid property.
212
+ */
213
+ guidFor: function(obj) {
209
214
  if (obj == null) return 0 ;
210
215
  return obj._guid ? obj._guid : (obj._guid = SC._nextGUID++);
211
216
  },
217
+
212
218
 
219
+ /**
220
+ Convenience method to inspect an object by converting it to a hash.
221
+ */
222
+ inspect: function(obj) {
223
+ return $H(obj).inspect() ;
224
+ },
225
+
213
226
  /** Browser and Platform info. */
214
227
  Platform: {
215
228
 
@@ -299,6 +312,9 @@ Object.extend(SC,{
299
312
 
300
313
  });
301
314
 
315
+ /** @deprecated Use guidFor() instead. */
316
+ SC.getGUID = SC.guidFor ;
317
+
302
318
  // Save the Platform.Browser name.
303
319
  SC.Platform.Browser = function() {
304
320
  if (SC.Platform.IE >0) {
@@ -322,7 +338,9 @@ T_BOOL = 'boolean' ;
322
338
  T_ARRAY = 'array' ;
323
339
  T_STRING = 'string' ;
324
340
 
325
- $type = function(item) { return SC.typeOf(item); };
341
+ $type = SC.typeOf ;
342
+
343
+ $I = SC.inspect ;
326
344
 
327
345
  Object.extend(Object,{
328
346
 
@@ -366,8 +384,15 @@ Object.extend(Event,{
366
384
  return String.fromCharCode(Event.getCharCode(e)) ;
367
385
  },
368
386
 
369
- pointerLocation: function(e) {
370
- return { x: Event.pointerX(e), y: Event.pointerY(e) };
387
+ pointerLocation: function(event) {
388
+ var ret = {
389
+ x: event.pageX || (event.clientX +
390
+ (document.documentElement.scrollLeft || document.body.scrollLeft)),
391
+ y: event.pageY || (event.clientY +
392
+ (document.documentElement.scrollTop || document.body.scrollTop))
393
+
394
+ };
395
+ return ret ;
371
396
  },
372
397
 
373
398
  ALT_KEY: '_ALT',
@@ -1,3 +1,3 @@
1
- SproutCore is a framework for building JavaScript applications. It contains a number of components you can use to enable traditional desktop-like functions using only javascript. SproutCore relies on Prototype and works with Scriptaculous.
1
+ SproutCore is a framework for building JavaScript applications. It contains a number of components you can use to enable traditional desktop-like functions using only javascript. SproutCore relies on Prototype and works with Scriptaculous, jQuery or any other toolkit you like to use.
2
2
 
3
3
 
@@ -0,0 +1,411 @@
1
+ // ========================================================================
2
+ // SproutCore
3
+ // copyright 2006-2008 Sprout Systems, Inc.
4
+ // ========================================================================
5
+
6
+ require('Core') ;
7
+ require('foundation/timer') ;
8
+
9
+ /**
10
+ @class
11
+
12
+ An animator is a special timer that will transition its value property from
13
+ 0 to 1 according to a transform function you define. You can also specify
14
+ one or more "subjects" that will be invoked whenever the animation value
15
+ changes, which can apply the animation to any target you like.
16
+
17
+ This class and its related classes are based on Bernie's Better Animator
18
+ class.
19
+
20
+ Use Cases:
21
+
22
+ 1. I just want to transition from x=0 -> x=20.
23
+ v.transitionTo('styleLeft', 20) ;
24
+ -> creates an animation for styleLeft. If you add a new animation for
25
+ the same effect, it will cancel the old one automatically.
26
+
27
+ 2. I want to have an 'animation behavior' attached to some property.
28
+ whenever I change it, it should automatically transition the property
29
+ instead of just updating it. i.e. a "Tracker".
30
+
31
+ -> I may want the tracker to update several things at once. But that
32
+ could be done through changing one property which will in turn
33
+ update everything else. Better idea.
34
+
35
+ Tracker simply stores some animation properties and calls transitionTo
36
+ whenever your target value changes.
37
+
38
+ 3. I want to have some property animating on its own. For example a
39
+ throbbing button
40
+
41
+ a = v.addAnimation('opacity', {
42
+ repeatCount: ,
43
+ autoreverses: YES,
44
+ end: 1.0,
45
+ start: 0.0,
46
+ property: 'opacity'
47
+ }) ;
48
+
49
+ a.set('isPaused', YES) ;
50
+ v.removeAnimation('opacity');
51
+
52
+ --
53
+ We will need an animation builder. It would be nice if I could have a
54
+ complete timeline for an animation setup and you just tell it to run. Set
55
+ the timecode to anytime that you want, tell it to start or stop.
56
+
57
+ @extends SC.Timer
58
+ @author Charles Jolley
59
+ @since SproutCore 1.0
60
+ */
61
+ SC.Animation = SC.Timer.extend(
62
+ /** @scope SC.Animation.prototype */ {
63
+
64
+ /**
65
+ The target frame rate. This is used to determine the interval of the
66
+ timer.
67
+
68
+ @type {Number}
69
+ @field
70
+ */
71
+ frameRate: 60,
72
+
73
+ /**
74
+ The interval between frames. Calculated automatically from the frameRate.
75
+ This property is read only.
76
+
77
+ @type {Number}
78
+ @field
79
+ */
80
+ interval: function() {
81
+ return 1000 / this.get('frameRate') ;
82
+ }.property('frameRate'),
83
+
84
+ /**
85
+ The total amount of time in msec you want to take for the animation to
86
+ go from 0-1.
87
+ */
88
+ duration: 0,
89
+
90
+ /**
91
+ The speed at which the timecode for the animation will progress. 1.0
92
+ means it will progress in real time, 2.0 means twice as fast, etc.
93
+ */
94
+ speed: 1.0,
95
+
96
+ /**
97
+ The total number of times you want the animation to repeat.
98
+
99
+ This can be any number, including partial numbers. If you set this
100
+ value you must not set repeatDuration as well. This will be ignored
101
+ if the value is 0, which is the default.
102
+
103
+ If you set this property to -1, then the animation will repeat
104
+ indefinitely.
105
+
106
+ Setting this property will update the targetTimecode.
107
+
108
+ @type {Number}
109
+ @field
110
+ */
111
+ repeatCount: 0,
112
+
113
+ /**
114
+ The total amount of time the animation should run, repeating itself, in
115
+ msec.
116
+
117
+ If you set this value you must not set repeatCount as well. This will
118
+ be ignored if the value is 0, which is the default.
119
+
120
+ Setting this property will update the targetTimecode.
121
+
122
+ @type {Number}
123
+ @field
124
+ */
125
+ repeatDuration: 0,
126
+
127
+ /**
128
+ If YES, then the animation will automatically reverse itself on each
129
+ repeat.
130
+
131
+ @type {Boolean}
132
+ @field
133
+ */
134
+ autoreverses: NO,
135
+
136
+ /**
137
+ A transition function. This is used to convert the progress into a
138
+ state value. You can supply your own transition function to provide
139
+ varied behaviors such as ease in, ease out, etc.
140
+
141
+ The function must have a signature like:
142
+
143
+ transition: function(value, animator)
144
+
145
+ It must accept a value from 0-1 indicating the current animation progress
146
+ and return a value from 0-1 indication the current transition progress.
147
+
148
+ @type {Function}
149
+ @field
150
+ */
151
+ transition: null,
152
+
153
+ /**
154
+ This is the current timecode for the animation, in msec. You can set
155
+ this to any value that you want and the animation to compute the current
156
+ transition value from it.
157
+
158
+ To move instantly to any part of your animation, you can simply set this
159
+ timecode or use jumpTo().
160
+
161
+ @type {Number}
162
+ @field
163
+ */
164
+ currentTimecode: 0,
165
+
166
+ /**
167
+ This is the target timecode. Whenever the target timecode and the
168
+ current timecode do not match, the animation will animate until it
169
+ reaches the target timecode.
170
+
171
+ To transition the animation to a new state, set the timecode to any
172
+ value that you want.
173
+
174
+ @type {Number}
175
+ */
176
+ targetTimecode: 0,
177
+
178
+ /**
179
+ The current animation progress.
180
+
181
+ This value will loop from 0-1 based on the current timecode and the
182
+ setting of autoreverses. You generally do not want to use this value.
183
+ Instead use the value property to compute the current transition.
184
+
185
+ @type {Number}
186
+ @field
187
+ */
188
+ progress: function() {
189
+
190
+ // current progress is calculated from the currentTimecode by dividing
191
+ // it by the animation duration and autoreverses.
192
+ var currentTimecode = this.get('currentTimecode') ;
193
+ var duration = this.get('duration') ;
194
+ var reverses = this.get('autoreverses') ;
195
+
196
+ // find the progress through the current cycle.
197
+ var cycle = Math.floor(currentTimecode / duration) ;
198
+ var progress = (currentTimecode - (duration * cycle)) / duration;
199
+
200
+ // if we autoreverse and the cycle is odd numbered, invert.
201
+ if (reverses && (cycle % 2) > 0) progress = 1 - progress ;
202
+ return progress ;
203
+ }.property('currentTimecode', 'duration', 'autoreverses'),
204
+
205
+ /**
206
+ The current animation value. Transform functions can observe this
207
+ property and update the target object accordingly.
208
+
209
+ @type {Number}
210
+ @field
211
+ */
212
+ value: function() {
213
+ var value = this.get('progress');
214
+ if (this.transition) value = this.transition(value, this) ;
215
+ return value ;
216
+ }.property('progress'),
217
+
218
+ /**
219
+ The target object of the animation. This is often used by transform
220
+ functions as the target of their change. It is not strictly required.
221
+
222
+ @type {Object}
223
+ @field
224
+ */
225
+ target: null,
226
+
227
+
228
+ /**
229
+ This method must be called once when the animation is created to schedule
230
+ it with the run loop. Once animation has been started, you should can
231
+ pause it to remove it from the runloop temporarily.
232
+
233
+ @returns {void}
234
+ */
235
+ play: function() {
236
+ this.beginPropertyChanges() ;
237
+ if (!this.get('isScheduled')) {
238
+ this.schedule() ;
239
+ this._lastActionTime = SC.runLoop.get('startTime') ;
240
+ }
241
+
242
+ if (this.get('isPaused')) this.set('isPaused', NO) ;
243
+ this.endPropertyChanges() ;
244
+ },
245
+
246
+ /**
247
+ Once an animation has been started, you can pause it anytime with this
248
+ method. Call start() to restart it or set isPaused to NO.
249
+
250
+ @returns {void}
251
+ */
252
+ pause: function() {
253
+ this.set('isPaused', YES) ;
254
+ },
255
+
256
+ /**
257
+ Immediately changes the currentTimecode to reflect the requested amount
258
+ of progress through a single cycle of the animation.
259
+
260
+ @param progress {Number} a progress value from 0 to 1.
261
+ @returns {void}
262
+ */
263
+ jumpTo: function(progress) {
264
+ // get the current progress.
265
+ var cur = this.get('progress') ;
266
+ var diff = progress - cur ;
267
+ var duration = this.get('duration') ;
268
+ diff *= duration ;
269
+
270
+ var timecode = this.get('currentTimecode') ;
271
+ if (diff !== 0) this.set('currentTimecode', timecode + diff) ;
272
+ },
273
+
274
+ /**
275
+ Changes the targetTimecode to reflect the request amount of progress
276
+ through the current cycle of the animation. If the animation is in
277
+ reverse, this could move the timecode in the opposite direction.
278
+
279
+ @param progress {Number} a progress value from 0 to 1.
280
+ @returns {void}
281
+ */
282
+ seekTo: function(progress) {
283
+ // get the current progress.
284
+ var cur = this.get('progress') ;
285
+ var diff = progress - cur ;
286
+ var duration = this.get('duration') ;
287
+ diff *= duration ;
288
+
289
+ var timecode = this.get('currentTimecode') ;
290
+ if (diff !== 0) this.set('targetTimecode', timecode + diff) ;
291
+ },
292
+
293
+ /**
294
+ Changes the currentTimecode and targetTimecode to reflect the requested
295
+ amount of progress through the current cycle of the animation. If the
296
+ animation is in reverse, this could move the timecode in the opposite
297
+ direction.
298
+
299
+ @param fromProgress {Number} a progress value from 0 to 1
300
+ @param toProgress {Number} a progress value from 0 to 1
301
+ @returns {void}
302
+ */
303
+ seekFromTo: function(fromProgress, toProgress) {
304
+ // get the current progress.
305
+ var timecode = this.get('currentTimecode') ;
306
+ var cur = this.get('progress') ;
307
+ var duration = this.get('duration') ;
308
+
309
+ this.beginPropertyChanges() ;
310
+
311
+ var diff = fromProgress - cur ;
312
+ diff *= duration ;
313
+ if (diff !== 0) this.set('currentTimecode', timecode + diff) ;
314
+
315
+ diff = toProgress - cur ;
316
+ diff *= duration ;
317
+ if (diff !== 0) this.set('targetTimecode', timecode + diff) ;
318
+
319
+ this.endPropertyChanges() ;
320
+ },
321
+
322
+ /**
323
+ Changes the targetTimecode to invert the direction of the animation.
324
+ If the progress value is currently headed towards 1.0, it will be instead
325
+ headed to 0.
326
+
327
+ @returns {Number} the new progress
328
+ */
329
+ toggle: function() {
330
+ throw "toggle not yet implemented" ;
331
+ },
332
+
333
+ /**
334
+ The core action executed by the timer.
335
+ */
336
+ performAction: function() {
337
+
338
+ // if timecodes match, then we suspend the animation and return, there
339
+ // is nothing more to do.
340
+ var cur = this.get('currentTimecode') ;
341
+ var target = this.get('targetTimecode') ;
342
+ if (cur == target) {
343
+ this.set('isPaused', YES) ;
344
+ return ;
345
+ }
346
+
347
+ // determine the amount of time that has elapsed since the last time
348
+ // we were called.
349
+ var curTime = SC.runLoop.get('startTime') ;
350
+ var lapsed = (curTime - this._lastActionTime) * this.get('speed') ;
351
+ this._lastActionTime = curTime ;
352
+
353
+ // update the current timecode. Moving in the direction of the target
354
+ // timecode. If timecodes match, there is nothing to do.
355
+ if (target > cur) {
356
+ cur += lapsed ;
357
+ if (cur > target) cur = target ;
358
+ } else {
359
+ cur -= lapsed ;
360
+ if (cur < target) cur = target ;
361
+ }
362
+
363
+ // now set the new timecode, this should trigger other observers to
364
+ // update.
365
+ this.set('currentTimecode', cur) ;
366
+ },
367
+
368
+ // ......................................
369
+ // INTERNAL METHODS
370
+ //
371
+
372
+ /** @private
373
+ Observes changes to repeatCount; updates the targetTimecode.
374
+ */
375
+ _repeatCountObserver: function() {
376
+ var repeatCount = this.get('repeatCount') ;
377
+ var target ;
378
+ if (repeatCount < 0) {
379
+ target = Date.now() * 2 ;
380
+ } else if (repeatCount > 0) {
381
+ target = this.get('duration') * repeatCount ;
382
+ } else return ; // nothing to do.
383
+ this.set('targetTimecode', target) ;
384
+ }.observes('repeatCount'),
385
+
386
+ /** @private
387
+ Observes changes to the repeatDuration; updates the targetTimecode.
388
+ */
389
+ _repeatDurationObserver: function() {
390
+ var dur = this.get('repeatDuration') ;
391
+ if (dur < 0) {
392
+ dur = Date.now() * 2 ;
393
+ } else if (dur == 0) return; // nothing to do
394
+ this.set('targetTimecode', dur) ;
395
+ }.observes('repeatDuration'),
396
+
397
+ init: function() {
398
+ arguments.callee.base.call(this) ;
399
+
400
+ this.targetTimecode = this.get('duration') ;
401
+ this._repeatDurationObserver() ;
402
+ this._repeatCountObserver() ;
403
+ },
404
+
405
+ repeats: YES, // for timer
406
+
407
+ _logValueObserver: function() {
408
+ console.log('value did change to: %@'.fmt(this.get('value')));
409
+ }.observes('value')
410
+
411
+ });