sproutcore 1.5.0.pre.3 → 1.5.0.pre.4

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 (308) hide show
  1. data/.rspec +1 -0
  2. data/CHANGELOG +42 -0
  3. data/README.txt +25 -0
  4. data/VERSION.yml +1 -1
  5. data/bin/sc-build +1 -1
  6. data/bin/sc-build-number +1 -1
  7. data/bin/sc-docs +1 -1
  8. data/bin/sc-gen +1 -1
  9. data/bin/sc-init +1 -1
  10. data/bin/sc-manifest +1 -1
  11. data/bin/sc-server +1 -1
  12. data/bin/sproutcore +1 -1
  13. data/lib/buildtasks/build.rake +5 -0
  14. data/lib/buildtasks/manifest.rake +20 -1
  15. data/lib/frameworks/sproutcore/Buildfile +12 -9
  16. data/lib/frameworks/sproutcore/CHANGELOG.md +48 -0
  17. data/lib/frameworks/sproutcore/apps/greenhouse/README +2 -9
  18. data/lib/frameworks/sproutcore/apps/greenhouse/TODO +11 -27
  19. data/lib/frameworks/sproutcore/apps/greenhouse/controllers/library.js +3 -10
  20. data/lib/frameworks/sproutcore/apps/greenhouse/english.lproj/css/main-page.css +4 -31
  21. data/lib/frameworks/sproutcore/apps/greenhouse/english.lproj/dialogs.js +5 -4
  22. data/lib/frameworks/sproutcore/apps/greenhouse/models/dir.js +3 -3
  23. data/lib/frameworks/sproutcore/apps/greenhouse/models/file.js +2 -2
  24. data/lib/frameworks/sproutcore/apps/greenhouse/states/main.js +31 -14
  25. data/lib/frameworks/sproutcore/apps/greenhouse/states/modals.js +2 -1
  26. data/lib/frameworks/sproutcore/apps/greenhouse/states/ready.js +27 -1
  27. data/lib/frameworks/sproutcore/apps/greenhouse/tests/views/list_item.js +1 -0
  28. data/lib/frameworks/sproutcore/apps/greenhouse/tests/views/plist_item.js +20 -0
  29. data/lib/frameworks/sproutcore/apps/greenhouse/theme.js +25 -0
  30. data/lib/frameworks/sproutcore/apps/greenhouse/views/plist_item.js +161 -24
  31. data/lib/frameworks/sproutcore/apps/greenhouse/views/tear_off_picker.js +1 -1
  32. data/lib/frameworks/sproutcore/frameworks/bootstrap/system/browser.js +37 -25
  33. data/lib/frameworks/sproutcore/frameworks/bootstrap/tests/system/browser.js +135 -26
  34. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/controllers/array.js +0 -0
  35. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/controllers/controller.js +0 -0
  36. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/controllers/object.js +1 -1
  37. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/core.js +0 -0
  38. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/ext/object.js +0 -0
  39. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/ext/run_loop.js +1 -0
  40. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/mixins/delegate_support.js +0 -0
  41. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/mixins/responder_context.js +0 -0
  42. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/mixins/selection_support.js +0 -0
  43. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/mixins/string.js +0 -0
  44. data/lib/frameworks/sproutcore/frameworks/core_foundation/panes/keyboard.js +68 -0
  45. data/lib/frameworks/sproutcore/frameworks/core_foundation/panes/layout.js +108 -0
  46. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/panes/main.js +2 -2
  47. data/lib/frameworks/sproutcore/frameworks/core_foundation/panes/manipulation.js +27 -0
  48. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/panes/pane.js +215 -505
  49. data/lib/frameworks/sproutcore/frameworks/core_foundation/panes/template.js +24 -0
  50. data/lib/frameworks/sproutcore/frameworks/core_foundation/panes/visibility.js +11 -0
  51. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/protocols/observable_protocol.js +0 -0
  52. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/protocols/sparse_array_delegate.js +0 -0
  53. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/resources/core.css +0 -0
  54. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/resources/view.css +0 -0
  55. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/system/application.js +0 -0
  56. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/system/browser.js +1 -0
  57. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/system/builder.js +0 -0
  58. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/system/core_query.js +1 -1
  59. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/system/cursor.js +0 -0
  60. data/lib/frameworks/sproutcore/frameworks/core_foundation/system/device.js +210 -0
  61. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/system/event.js +5 -5
  62. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/system/json.js +0 -0
  63. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/system/locale.js +0 -0
  64. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/system/page.js +0 -0
  65. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/system/platform.js +31 -5
  66. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/system/ready.js +1 -1
  67. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/system/render_context.js +0 -0
  68. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/system/responder.js +0 -0
  69. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/system/root_responder.js +83 -110
  70. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/system/selection_set.js +7 -4
  71. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/system/sparse_array.js +0 -0
  72. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/system/theme.js +0 -0
  73. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/system/timer.js +0 -0
  74. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/system/utils/rect.js +0 -0
  75. data/lib/frameworks/sproutcore/frameworks/core_foundation/system/utils.js +151 -0
  76. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/tests/controllers/array/array_case.js +0 -0
  77. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/tests/controllers/array/enum_case.js +0 -0
  78. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/tests/controllers/array/null_case.js +0 -0
  79. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/tests/controllers/array/selection_support.js +26 -0
  80. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/tests/controllers/array/single_case.js +0 -0
  81. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/tests/controllers/object/empty_case.js +0 -0
  82. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/tests/controllers/object/multiple_case.js +0 -0
  83. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/tests/controllers/object/single_case.js +0 -0
  84. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/tests/controllers/object/single_enumerable_case.js +0 -0
  85. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/tests/mixins/responder_context.js +0 -0
  86. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/tests/mixins/string.js +0 -0
  87. data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/panes/template.js +14 -0
  88. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/tests/system/builder.js +0 -0
  89. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/tests/system/core_query/within.js +0 -0
  90. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/tests/system/json.js +0 -0
  91. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/tests/system/locale.js +0 -0
  92. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/tests/system/render_context/begin.js +0 -0
  93. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/tests/system/render_context/element.js +0 -0
  94. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/tests/system/render_context/end.js +0 -0
  95. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/tests/system/render_context/get.js +0 -0
  96. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/tests/system/render_context/helpers_attr.js +0 -0
  97. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/tests/system/render_context/helpers_basic.js +0 -0
  98. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/tests/system/render_context/helpers_className.js +0 -0
  99. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/tests/system/render_context/helpers_style.js +0 -0
  100. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/tests/system/render_context/init.js +0 -0
  101. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/tests/system/render_context/join.js +0 -0
  102. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/tests/system/render_context/push_text.js +0 -0
  103. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/tests/system/render_context/tag.js +0 -0
  104. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/tests/system/render_context/update.js +0 -0
  105. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/tests/system/root_responder/makeKeyPane.js +0 -0
  106. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/tests/system/root_responder/makeMainPane.js +0 -0
  107. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/tests/system/root_responder/makeMenuPane.js +0 -0
  108. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/tests/system/root_responder/root_responder.js +0 -0
  109. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/tests/system/root_responder/targetForAction.js +0 -0
  110. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/tests/system/selection_set/add.js +0 -0
  111. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/tests/system/selection_set/copy.js +0 -0
  112. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/tests/system/selection_set/indexSetForSource.js +0 -0
  113. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/tests/system/selection_set/isEqual.js +0 -0
  114. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/tests/system/selection_set/remove.js +0 -0
  115. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/tests/system/sparse_array.js +0 -0
  116. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/tests/system/theme.js +0 -0
  117. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/tests/system/timer/invalidate.js +0 -0
  118. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/tests/system/timer/invokeLater.js +0 -0
  119. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/tests/system/timer/isPaused.js +0 -0
  120. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/tests/system/timer/performAction.js +0 -0
  121. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/tests/system/timer/schedule.js +0 -0
  122. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/tests/system/utils/normalizeURL.js +0 -0
  123. data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/system/utils/offset.js +268 -0
  124. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/tests/system/utils/rect.js +0 -0
  125. data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/main_pane.js +43 -0
  126. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/tests/views/pane/append_remove.js +107 -18
  127. data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/pane/child_view.js +20 -0
  128. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/tests/views/pane/firstResponder.js +0 -0
  129. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/tests/views/pane/keyPane.js +0 -0
  130. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/tests/views/pane/layout.js +0 -0
  131. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/tests/views/pane/sendEvent.js +0 -0
  132. data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/template/checkbox_support.js +32 -0
  133. data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/template/text_field_support.js +73 -0
  134. data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/template_view/collection.js +65 -0
  135. data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/template_view/core.js +67 -0
  136. data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/template_view/handlebars.js +295 -0
  137. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/tests/views/view/animation.js +19 -18
  138. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/tests/views/view/build.js +0 -0
  139. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/tests/views/view/build_children.js +0 -0
  140. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/tests/views/view/clippingFrame.js +0 -0
  141. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/tests/views/view/convertFrames.js +0 -0
  142. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/tests/views/view/convertLayouts.js +0 -0
  143. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/tests/views/view/createChildViews.js +18 -15
  144. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/tests/views/view/createLayer.js +0 -0
  145. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/tests/views/view/destroyLayer.js +0 -0
  146. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/tests/views/view/didAppendToDocument.js +11 -8
  147. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/tests/views/view/findLayerInParentLayer.js +0 -0
  148. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/tests/views/view/init.js +0 -0
  149. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/tests/views/view/insertBefore.js +0 -0
  150. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/tests/views/view/isVisible.js +28 -0
  151. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/tests/views/view/isVisibleInWindow.js +0 -0
  152. data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/keyboard.js +22 -0
  153. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/tests/views/view/layer.js +0 -0
  154. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/tests/views/view/layoutChildViews.js +0 -0
  155. data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/layoutDidChange.js +180 -0
  156. data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/layoutStyle.js +640 -0
  157. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/tests/views/view/parentViewDidChange.js +0 -0
  158. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/tests/views/view/prepareContext.js +0 -0
  159. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/tests/views/view/removeChild.js +0 -0
  160. data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/render.js +125 -0
  161. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/tests/views/view/render_delegate_support.js +0 -0
  162. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/tests/views/view/replaceChild.js +0 -0
  163. data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/static_layout.js +21 -0
  164. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/tests/views/view/theme.js +0 -0
  165. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/tests/views/view/updateLayer.js +0 -0
  166. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/tests/views/view/updateLayerLocation.js +0 -0
  167. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/tests/views/view/view.js +0 -0
  168. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/tests/views/view/viewDidResize.js +0 -0
  169. data/lib/frameworks/sproutcore/frameworks/core_foundation/views/template/checkbox_support.js +20 -0
  170. data/lib/frameworks/sproutcore/frameworks/core_foundation/views/template/collection.js +99 -0
  171. data/lib/frameworks/sproutcore/frameworks/core_foundation/views/template/text_field_support.js +35 -0
  172. data/lib/frameworks/sproutcore/frameworks/core_foundation/views/template.js +77 -0
  173. data/lib/frameworks/sproutcore/frameworks/core_foundation/views/view/animation.js +187 -0
  174. data/lib/frameworks/sproutcore/frameworks/core_foundation/views/view/base.js +1 -0
  175. data/lib/frameworks/sproutcore/frameworks/core_foundation/views/view/cursor.js +41 -0
  176. data/lib/frameworks/sproutcore/frameworks/core_foundation/views/view/enabled.js +57 -0
  177. data/lib/frameworks/sproutcore/frameworks/core_foundation/views/view/keyboard.js +223 -0
  178. data/lib/frameworks/sproutcore/frameworks/core_foundation/views/view/layout.js +1150 -0
  179. data/lib/frameworks/sproutcore/frameworks/{amber/views → core_foundation/views/view}/layout_style.js +93 -1
  180. data/lib/frameworks/sproutcore/frameworks/core_foundation/views/view/manipulation.js +489 -0
  181. data/lib/frameworks/sproutcore/frameworks/core_foundation/views/view/theming.js +362 -0
  182. data/lib/frameworks/sproutcore/frameworks/core_foundation/views/view/touch.js +67 -0
  183. data/lib/frameworks/sproutcore/frameworks/core_foundation/views/view/visibility.js +113 -0
  184. data/lib/frameworks/sproutcore/frameworks/core_foundation/views/view.js +1280 -0
  185. data/lib/frameworks/sproutcore/frameworks/datastore/models/child_attribute.js +27 -53
  186. data/lib/frameworks/sproutcore/frameworks/datastore/models/children_attribute.js +13 -19
  187. data/lib/frameworks/sproutcore/frameworks/datastore/models/many_attribute.js +1 -0
  188. data/lib/frameworks/sproutcore/frameworks/datastore/models/record.js +183 -71
  189. data/lib/frameworks/sproutcore/frameworks/datastore/models/record_attribute.js +1 -2
  190. data/lib/frameworks/sproutcore/frameworks/datastore/system/child_array.js +26 -46
  191. data/lib/frameworks/sproutcore/frameworks/datastore/system/nested_store.js +25 -4
  192. data/lib/frameworks/sproutcore/frameworks/datastore/system/store.js +139 -21
  193. data/lib/frameworks/sproutcore/frameworks/datastore/tests/data_sources/fixtures.js +6 -1
  194. data/lib/frameworks/sproutcore/frameworks/datastore/tests/integration/cyclical_relationship.js +1 -1
  195. data/lib/frameworks/sproutcore/frameworks/datastore/tests/models/nested_records/{parentless.js → data_store.js} +62 -16
  196. data/lib/frameworks/sproutcore/frameworks/datastore/tests/models/nested_records/nested_record.js +51 -17
  197. data/lib/frameworks/sproutcore/frameworks/datastore/tests/models/nested_records/nested_record_array.js +36 -10
  198. data/lib/frameworks/sproutcore/frameworks/datastore/tests/models/nested_records/nested_record_array_complex.js +11 -11
  199. data/lib/frameworks/sproutcore/frameworks/datastore/tests/models/nested_records/nested_record_complex.js +8 -8
  200. data/lib/frameworks/sproutcore/frameworks/datastore/tests/models/record/normalize.js +2 -2
  201. data/lib/frameworks/sproutcore/frameworks/{foundation/english.lproj → datetime/resources}/strings.js +1 -0
  202. data/lib/frameworks/sproutcore/frameworks/{foundation → datetime}/system/datetime.js +5 -37
  203. data/lib/frameworks/sproutcore/frameworks/{foundation → datetime}/tests/system/datetime.js +1 -0
  204. data/lib/frameworks/sproutcore/frameworks/debug/core.js +1 -1
  205. data/lib/frameworks/sproutcore/frameworks/designer/controllers/designs.js +1 -2
  206. data/lib/frameworks/sproutcore/frameworks/designer/designers/object_designer.js +3 -3
  207. data/lib/frameworks/sproutcore/frameworks/designer/designers/view_designer.js +3 -3
  208. data/lib/frameworks/sproutcore/frameworks/designer/views/designer_drop_target.js +9 -3
  209. data/lib/frameworks/sproutcore/frameworks/desktop/english.lproj/segmented.css +71 -70
  210. data/lib/frameworks/sproutcore/frameworks/desktop/mixins/collection_row_delegate.js +10 -2
  211. data/lib/frameworks/sproutcore/frameworks/desktop/render_delegates/segment.js +4 -19
  212. data/lib/frameworks/sproutcore/frameworks/desktop/render_delegates/segmented.js +33 -14
  213. data/lib/frameworks/sproutcore/frameworks/desktop/system/drag.js +25 -0
  214. data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/date_field/ui.js +1 -1
  215. data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/segmented/methods.js +25 -103
  216. data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/segmented/ui.js +102 -92
  217. data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/tab/ui.js +22 -25
  218. data/lib/frameworks/sproutcore/frameworks/desktop/views/collection.js +38 -25
  219. data/lib/frameworks/sproutcore/frameworks/desktop/views/date_field.js +1 -1
  220. data/lib/frameworks/sproutcore/frameworks/desktop/views/scroll.js +1 -1
  221. data/lib/frameworks/sproutcore/frameworks/desktop/views/segment.js +42 -22
  222. data/lib/frameworks/sproutcore/frameworks/desktop/views/segmented.js +513 -230
  223. data/lib/frameworks/sproutcore/frameworks/desktop/views/select_field.js +0 -2
  224. data/lib/frameworks/sproutcore/frameworks/experimental/README.md +23 -0
  225. data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/device_motion/README.md +11 -0
  226. data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/device_motion/device.js +215 -0
  227. data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/device_motion/platform.js +67 -0
  228. data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/polymorphism/README.md +34 -0
  229. data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/polymorphism/models/polymorphic_single_attribute.js +183 -0
  230. data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/polymorphism/models/record.js +23 -0
  231. data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/polymorphism/tests/models/polymorphic/single.js +124 -0
  232. data/lib/frameworks/sproutcore/frameworks/foundation/mixins/auto_resize.js +0 -2
  233. data/lib/frameworks/sproutcore/frameworks/foundation/mixins/inner_frame.js +151 -0
  234. data/lib/frameworks/sproutcore/frameworks/foundation/render_delegates/canvas_image.js +27 -17
  235. data/lib/frameworks/sproutcore/frameworks/foundation/system/image_queue.js +6 -3
  236. data/lib/frameworks/sproutcore/frameworks/foundation/system/logger.js +163 -0
  237. data/lib/frameworks/sproutcore/frameworks/foundation/system/user_defaults.js +6 -3
  238. data/lib/frameworks/sproutcore/frameworks/foundation/tests/mixins/inline_text_field/beginEditing.js +1 -0
  239. data/lib/frameworks/sproutcore/frameworks/foundation/tests/system/logger.js +44 -0
  240. data/lib/frameworks/sproutcore/frameworks/foundation/tests/views/image/ui.js +200 -167
  241. data/lib/frameworks/sproutcore/frameworks/foundation/tests/views/text_field/ui.js +1 -1
  242. data/lib/frameworks/sproutcore/frameworks/foundation/views/image.js +52 -137
  243. data/lib/frameworks/sproutcore/frameworks/foundation/views/text_field.js +7 -11
  244. data/lib/frameworks/sproutcore/frameworks/handlebars/extensions.js +138 -0
  245. data/lib/frameworks/sproutcore/frameworks/handlebars/handlebars.js +1338 -0
  246. data/lib/frameworks/sproutcore/frameworks/runtime/core.js +32 -26
  247. data/lib/frameworks/sproutcore/frameworks/runtime/debug/test_suites/array/base.js +162 -3
  248. data/lib/frameworks/sproutcore/frameworks/runtime/mixins/array.js +10 -5
  249. data/lib/frameworks/sproutcore/frameworks/runtime/mixins/enumerable.js +123 -3
  250. data/lib/frameworks/sproutcore/frameworks/runtime/mixins/observable.js +12 -5
  251. data/lib/frameworks/sproutcore/frameworks/runtime/private/chain_observer.js +50 -13
  252. data/lib/frameworks/sproutcore/frameworks/runtime/system/logger.js +163 -333
  253. data/lib/frameworks/sproutcore/frameworks/runtime/system/object.js +58 -8
  254. data/lib/frameworks/sproutcore/frameworks/runtime/system/run_loop.js +2 -0
  255. data/lib/frameworks/sproutcore/frameworks/runtime/tests/core/itemType.js +9 -6
  256. data/lib/frameworks/sproutcore/frameworks/runtime/tests/core/makeArray.js +15 -1
  257. data/lib/frameworks/sproutcore/frameworks/runtime/tests/mixins/array.js +2 -0
  258. data/lib/frameworks/sproutcore/frameworks/runtime/tests/mixins/observable/chained.js +31 -0
  259. data/lib/frameworks/sproutcore/frameworks/runtime/tests/mixins/observable/observable.js +18 -0
  260. data/lib/frameworks/sproutcore/frameworks/runtime/tests/system/logger.js +31 -143
  261. data/lib/frameworks/sproutcore/frameworks/runtime/tests/system/object/concatenated_properties.js +71 -0
  262. data/lib/frameworks/sproutcore/frameworks/runtime/tests/system/object/enhance.js +177 -0
  263. data/lib/frameworks/sproutcore/frameworks/table/views/table.js +5 -4
  264. data/lib/frameworks/sproutcore/frameworks/table/views/table_header.js +5 -3
  265. data/lib/frameworks/sproutcore/themes/ace/resources/button/button.js +8 -2
  266. data/lib/frameworks/sproutcore/themes/ace/resources/menu/menu.css +2 -3
  267. data/lib/frameworks/sproutcore/themes/ace/resources/segmented/18px/segmented.css +1 -1
  268. data/lib/frameworks/sproutcore/themes/ace/resources/segmented/24px/segmented.css +1 -1
  269. data/lib/frameworks/sproutcore/themes/ace/resources/segmented/30px/segmented.css +1 -1
  270. data/lib/frameworks/sproutcore/themes/ace/resources/segmented/44px/segmented.css +1 -1
  271. data/lib/frameworks/sproutcore/themes/ace/resources/segmented/segmented.css +2 -2
  272. data/lib/frameworks/sproutcore/themes/standard_theme/english.lproj/segmented.css +62 -62
  273. data/lib/gen/html_app/Buildfile +36 -0
  274. data/lib/gen/html_app/README +1 -0
  275. data/lib/gen/html_app/USAGE +15 -0
  276. data/lib/gen/html_app/templates/apps/@target_name@/@target_name@.js +14 -0
  277. data/lib/gen/html_app/templates/apps/@target_name@/resources/images/.gitkeep +0 -0
  278. data/lib/gen/html_app/templates/apps/@target_name@/resources/stylesheets/@target_name@.css +0 -0
  279. data/lib/gen/html_app/templates/apps/@target_name@/resources/templates/@target_name@.handlebars +1 -0
  280. data/lib/gen/html_project/Buildfile +45 -0
  281. data/lib/gen/html_project/INIT +3 -0
  282. data/lib/gen/html_project/README +1 -0
  283. data/lib/gen/html_project/USAGE +2 -0
  284. data/lib/gen/html_project/templates/@filename@/Buildfile +8 -0
  285. data/lib/gen/html_project/templates/@filename@/README +7 -0
  286. data/lib/sproutcore/builders/handlebars.rb +30 -0
  287. data/lib/sproutcore/builders.rb +1 -1
  288. data/lib/sproutcore/helpers/static_helper.rb +3 -3
  289. data/lib/sproutcore/tools/init.rb +25 -9
  290. data/spec/buildtasks/manifest/prepare_build_tasks/handlebars_spec.rb +39 -0
  291. data/spec/fixtures/builder_tests/apps/handlebars_test/template.handlebars +5 -0
  292. data/spec/fixtures/real_world/frameworks/sproutcore/english.lproj/templates/demo.handlebars +4 -0
  293. data/spec/lib/builders/handlebars_spec.rb +29 -0
  294. data/vendor/chance/lib/chance/imagers/data_url.rb +20 -7
  295. data/vendor/chance/lib/chance/instance.rb +4 -1
  296. data/vendor/chance/lib/chance/parser.rb +31 -31
  297. data/vendor/chance/lib/chance/slicing.rb +38 -8
  298. metadata +195 -225
  299. data/lib/frameworks/sproutcore/frameworks/amber/system/device.js +0 -143
  300. data/lib/frameworks/sproutcore/frameworks/amber/system/utils.js +0 -174
  301. data/lib/frameworks/sproutcore/frameworks/amber/tests/views/main_pane.js +0 -31
  302. data/lib/frameworks/sproutcore/frameworks/amber/tests/views/pane/sendTouchEvent.js +0 -267
  303. data/lib/frameworks/sproutcore/frameworks/amber/tests/views/view/layoutDidChange.js +0 -149
  304. data/lib/frameworks/sproutcore/frameworks/amber/tests/views/view/layoutStyle.js +0 -602
  305. data/lib/frameworks/sproutcore/frameworks/amber/tests/views/view/render.js +0 -115
  306. data/lib/frameworks/sproutcore/frameworks/amber/views/base.js +0 -1
  307. data/lib/frameworks/sproutcore/frameworks/amber/views/view.js +0 -4003
  308. data/lib/frameworks/sproutcore/frameworks/datastore/models/child_record.js +0 -105
@@ -323,14 +323,12 @@ SC.SelectFieldView = SC.FieldView.extend(
323
323
  if (this.get('isEnabled') === false) this.$()[0].disabled = true;
324
324
  SC.Event.add(input, 'blur', this, this.fieldDidBlur);
325
325
  SC.Event.add(input, 'focus',this, this.fieldDidFocus);
326
- return sc_super();
327
326
  },
328
327
 
329
328
  willDestroyLayer: function() {
330
329
  var input = this.$input();
331
330
  SC.Event.remove(input, 'focus', this, this.fieldDidFocus);
332
331
  SC.Event.remove(input, 'blur', this, this.fieldDidBlur);
333
- return sc_super();
334
332
  }
335
333
 
336
334
  });
@@ -0,0 +1,23 @@
1
+ SproutCore Experimental Framework
2
+ =================================
3
+
4
+ The SproutCore Experimental framework contains code that is
5
+ not ready to be included in the core framework and is **actively** being
6
+ worked on. This code is being improved with the expectation that
7
+ eventually the code that lives in this parent framework will become
8
+ a part of the core framework. If you are interested in using a framework
9
+ that is experimental, can you do the following in your Buildfile:
10
+
11
+ config :your_app, :required => [:sproutcore, :'sproutcore/experimental/example']
12
+
13
+ which will include the experimental framework and whatever modifications
14
+ it makes to the core framework in your project.
15
+
16
+
17
+ ### Note
18
+
19
+ Experimental frameworks may not be kept up to date with the master core
20
+ code, and by nature will be unstable and less tested than the core code.
21
+ We will try our best to maintain experimental code and ensure
22
+ that code that will not make it into the core framework is pruned, but
23
+ there are no guarantees.
@@ -0,0 +1,11 @@
1
+ Device Motion Framework
2
+ =======================
3
+
4
+ This framework adds accelerometer and gyroscope support to SC.device in
5
+ browsers that support the window.ondeviceorientation and
6
+ window.ondevicemotion events.
7
+
8
+
9
+ ## Contributors
10
+
11
+ - Colin Campbell (<colin@sproutcore.com>)
@@ -0,0 +1,215 @@
1
+ // ==========================================================================
2
+ // Project: SproutCore - JavaScript Application Framework
3
+ // Copyright: ©2006-2011 Strobe Inc. and contributors.
4
+ // Portions ©2008-2010 Apple Inc. All rights reserved.
5
+ // License: Licensed under MIT license (see license.js)
6
+ // ==========================================================================
7
+
8
+ sc_require('platform');
9
+
10
+ /**
11
+ h1. Device Motion
12
+
13
+ When a device is moved, some platforms will inform us of its movement
14
+ (accelerometer) and angle (gyroscope).
15
+
16
+ */
17
+ SC.mixin(SC.device,
18
+ /** @scope SC.device */ {
19
+
20
+ // ..........................................................
21
+ // PROPERTIES
22
+ //
23
+
24
+ /*
25
+ TODO [CC] There shouldn't be a need for this property, we should overload
26
+ the addObserver/removeObserver functions and check for the
27
+ rotationX/Y/Z keys.
28
+ */
29
+ /**
30
+ Because the device motion events fire every 50ms, for performance reasons
31
+ you must opt into listening for those events.
32
+
33
+ @property {Boolean}
34
+ @default NO
35
+ */
36
+ listenForDeviceMotion: NO,
37
+
38
+ /**
39
+ Amount, in degrees, that the device is rotated around its x axis. x axis is
40
+ the plane of the screen and is positive towards the right hand side of
41
+ the screen, regardless of orientation.
42
+
43
+ SC.device#listenForDeviceMotion must be true for this property to update.
44
+
45
+ @property {Number}
46
+ @default 0
47
+ */
48
+ rotationX: 0,
49
+
50
+ /**
51
+ Amount, in degrees, that the device is rotated around its y axis (axis runs
52
+ from the top to the bottom of the device). y axis is the plane of the
53
+ screen and is positive towards the top of the screen, regardless of
54
+ orientation.
55
+
56
+ SC.device#listenForDeviceMotion must be true for this property to update.
57
+
58
+ @property {Number}
59
+ @default 0
60
+ */
61
+ rotationY: 0,
62
+
63
+ /**
64
+ Amount, in degrees, that the device is rotated around its z axis (normal
65
+ coming "out" of the screen). z axis is perpendicular to the screen and is
66
+ positive "out" of (or normal to) the screen. This property is only useful
67
+ if the device has a gyroscope; for devices which lack a gyroscope (use
68
+ an accelerometer or nothing), this property remains 0.
69
+
70
+ SC.device#listenForDeviceMotion must be true for this property to update.
71
+
72
+ @property {Number}
73
+ @default 0
74
+ */
75
+ rotationZ: 0,
76
+
77
+
78
+ // ..........................................................
79
+ // SETUP
80
+ //
81
+
82
+ setupMotion: function() {
83
+ SC.RootResponder.responder.listenFor('devicemotion deviceorientation'.w(), window, this);
84
+ },
85
+
86
+
87
+ // ..........................................................
88
+ // DEVICE MOTION HANDLING
89
+ //
90
+
91
+ _scd_listenForDeviceMotionDidChange: function() {
92
+ if (!SC.RootResponder.responder) return;
93
+
94
+ // we only care about the gyro now, we don't need acceleration
95
+ if (this.get('listenForDeviceMotion')) {
96
+ if (SC.platform.hasGyroscope) {
97
+ SC.Event.add(window, 'deviceorientation', this, this._scd_deviceorientationPoll);
98
+ } else if (SC.platform.hasAccelerometer) {
99
+ SC.Event.add(window, 'devicemotion', this, this._scd_devicemotionPoll);
100
+ } else {
101
+ SC.Logger.warn("Can't listen for device motion events on a platform that does not support them");
102
+ }
103
+ } else {
104
+ SC.Event.remove(window, 'deviceorientation', this, this._scd_deviceorientationPoll);
105
+ SC.Event.remove(window, 'devicemotion', this, this._scd_devicemotionPoll);
106
+ }
107
+ },
108
+
109
+ /**
110
+ Fired once every 50ms, informing us of the gyroscope measurements
111
+ */
112
+ deviceorientation: function(evt) {
113
+ evt = evt.originalEvent;
114
+
115
+ if (!SC.platform.hasGyroscope) SC.platform.hasGyroscope = YES;
116
+
117
+ SC.Event.remove(window, 'deviceorientation', this, this.deviceorientation);
118
+ SC.Event.remove(window, 'devicemotion', this, this.devicemotion);
119
+
120
+ this.addObserver('listenForDeviceMotion', this, this._scd_listenForDeviceMotionDidChange);
121
+ this.notifyPropertyChange('listenForDeviceMotion');
122
+ },
123
+
124
+ /** @private
125
+ Gets called after the first deviceorientation event, used to actually set
126
+ the rotation values
127
+ */
128
+ _scd_deviceorientationPoll: function(evt) {
129
+ var orientation = this.get('orientation');
130
+
131
+ evt = evt.originalEvent;
132
+
133
+ SC.run(function() {
134
+ this.beginPropertyChanges();
135
+ this.set('rotationX', orientation !== 'landscape' ? evt.beta : evt.gamma);
136
+ this.set('rotationY', orientation !== 'landscape' ? evt.gamma : -evt.beta);
137
+ this.set('rotationZ', evt.alpha);
138
+ this.endPropertyChanges();
139
+ }, this);
140
+ },
141
+
142
+ /** @private
143
+ Because we only want to deal with only the gyroscope, if it is firing its event,
144
+ we wait until two devicemotion events have been fired to decide to use the
145
+ accelerometer instead.
146
+ */
147
+ _devicemotionCalled: NO,
148
+
149
+ /**
150
+ Fired every 50ms, informing us of the accelerometer measurements
151
+ */
152
+ devicemotion: function(evt) {
153
+ if (!SC.platform.hasAccelerometer) SC.platform.hasAccelerometer = YES;
154
+
155
+ if (this._devicemotionCalled) {
156
+ // if this happens, and this event fires (ie. the deviceorientation event hasn't)
157
+ // then we assume the device does not have a gyroscope
158
+ SC.Event.remove(window, 'deviceorientation', this, this.deviceorientation);
159
+ SC.Event.remove(window, 'devicemotion', this, this.devicemotion);
160
+
161
+ this.set('rotationZ', 0); // ensure rotationZ does not get any other value
162
+ this.addObserver('listenForDeviceMotion', this, this._scd_listenForDeviceMotionDidChange);
163
+ this.notifyPropertyChange('listenForDeviceMotion');
164
+ } else {
165
+ this._devicemotionCalled = YES;
166
+ }
167
+ },
168
+
169
+ /*
170
+ TODO [CC] This needs to be expanded on a bit. If you hold the device in weird
171
+ positions, the rotation values from the accelerometer no longer match those
172
+ from the gyroscope. What about people who use their iPad in bed?!
173
+ */
174
+ /** @private
175
+ Gets called after the first devicemotion event, if the device has no gyropscope.
176
+ */
177
+ _scd_devicemotionPoll: function(evt) {
178
+ var min = SC.platform.accelerationMinimum,
179
+ max = SC.platform.accelerationMaximum,
180
+ spread = max - min,
181
+ orientation = this.get('orientation'),
182
+ aX, aY, rX, rY, swap;
183
+
184
+ evt = evt.originalEvent;
185
+
186
+ aX = evt.accelerationIncludingGravity.x;
187
+ aY = evt.accelerationIncludingGravity.y;
188
+
189
+ if (aX < min) aX = min;
190
+ else if (aX > max) aX = max;
191
+ if (aY < min) aY = min;
192
+ else if (aY > max) aY = max;
193
+
194
+ if (orientation === 'landscape') {
195
+ swap = aX;
196
+ aX = aY;
197
+ aY = swap;
198
+ }
199
+
200
+ rX = 90 - ((aY-min)/spread) * 180;
201
+ rY = -90 + ((aX-min)/spread) * 180;
202
+
203
+ SC.run(function() {
204
+ this.beginPropertyChanges();
205
+ this.set('rotationX', rX);
206
+ this.set('rotationY', rY);
207
+ this.endPropertyChanges();
208
+ }, this);
209
+ }
210
+
211
+ });
212
+
213
+ SC.ready(function() {
214
+ SC.device.setupMotion();
215
+ });
@@ -0,0 +1,67 @@
1
+ // ==========================================================================
2
+ // Project: SproutCore - JavaScript Application Framework
3
+ // Copyright: ©2006-2011 Strobe Inc. and contributors.
4
+ // Portions ©2008-2010 Apple Inc. All rights reserved.
5
+ // License: Licensed under MIT license (see license.js)
6
+ // ==========================================================================
7
+
8
+ SC.mixin(SC.platform,
9
+ /** @scope SC.platform */ {
10
+
11
+ /**
12
+ YES if the ondeviceorientation event on window is supported.
13
+
14
+ @property {Boolean}
15
+ @default NO
16
+ */
17
+ supportsGyroscope: ('ondeviceorientation' in window),
18
+
19
+ /**
20
+ YES if the ondeviceorientation event on window has actually been
21
+ fired. Some platforms have the event but will never fire it.
22
+
23
+ @property {Boolean}
24
+ @default NO
25
+ */
26
+ hasGyroscope: NO,
27
+
28
+ /**
29
+ YES if the ondevicemotion event on window is supported.
30
+
31
+ @property {Boolean}
32
+ @default NO
33
+ */
34
+ supportsAccelerometer: ('ondevicemotion' in window),
35
+
36
+ /**
37
+ YES if the ondevicemotion event on window has actually been
38
+ fired. Some platforms have the event but will never fire it.
39
+
40
+ @property {Boolean}
41
+ @default NO
42
+ */
43
+ hasAccelerometer: NO,
44
+
45
+ /*
46
+ TODO [CC] Find out the actual values on a multitude of devices.
47
+ We would want this to be a 'normal' use value...
48
+ */
49
+ /**
50
+ @property {Number}
51
+ @default -10
52
+ */
53
+ accelerationMinimum: function() {
54
+ // we may want finer grained control of this by platform later
55
+ return -10;
56
+ }(),
57
+
58
+ /**
59
+ @property {Number}
60
+ @default 10
61
+ */
62
+ accelerationMaximum: function() {
63
+ // we may want finer grained control of this by platform later
64
+ return 10;
65
+ }()
66
+
67
+ });
@@ -0,0 +1,34 @@
1
+ Polymorphism Framework
2
+ ======================
3
+
4
+ This framework adds polymorphism support to SC.Record relationships.
5
+ Right now, only one-to-one polymorphism is supported, but to-many
6
+ support is planned.
7
+
8
+
9
+ ## Using the Framework
10
+
11
+ In order to use the polymorphic to-one relationship, include this
12
+ framework in your Buildfile. Inside your Records, you can define
13
+ a relationship like this:
14
+
15
+ MyApp.Child = SC.Record.extend({
16
+ parent: SC.Record.toOneOf(['MyApp.Male', 'MyApp.Female'], {typeKey: 'parentType'}),
17
+ parentType: SC.Record.attr(String)
18
+ });
19
+
20
+ You need to pass in a hash like the following when creating the record:
21
+
22
+ {parent: 1, parentType: 'MyApp.Male'}
23
+
24
+
25
+ For other, more flexible, ways of using this polymorphic support,
26
+ see the unit tests or source code.
27
+
28
+ <!--
29
+ TODO Write more examples
30
+ -->
31
+
32
+ ## Contributors
33
+
34
+ - Colin Campbell (<colin@sproutcore.com>)
@@ -0,0 +1,183 @@
1
+ // ==========================================================================
2
+ // Project: SproutCore - JavaScript Application Framework
3
+ // Copyright: ©2006-2009 Sprout Systems, Inc. and contributors.
4
+ // Portions ©2008-2009 Apple Inc. All rights reserved.
5
+ // License: Licensed under MIT license (see license.js)
6
+ // ==========================================================================
7
+
8
+ /** @class
9
+
10
+ PolymorphicSingleAttribute is a subclass of SingleAttribute and handles polymorphic
11
+ to-one relationships.
12
+
13
+ @extends SC.SingleAttribute
14
+ @author Colin Campbell
15
+ @since SproutCore 1.0
16
+ */
17
+ SC.PolymorphicSingleAttribute = SC.SingleAttribute.extend(
18
+ /** @scope SC.PolymorphicSingleAttribute.prototype */ {
19
+
20
+ /**
21
+ Contains information on how to transform from and from the passed attribute values.
22
+ This property is required so the attribute knows which type to use for the relationship.
23
+ If it is not included, it will default to the first provided type.
24
+
25
+ @property {String}
26
+ @default null
27
+ */
28
+ typeKey: null,
29
+
30
+ /**
31
+ Provides the ability to map the type names provided by the attribute value into
32
+ something usable for record relationships. For example, you may need to store
33
+ record names on the server but only with the class name, not the fully qualified
34
+ path name (ie. 'Record' vs. 'MyApp.Record'). If the passed records are:
35
+
36
+ ['MyApp.Foo', 'MyApp.Bar']
37
+
38
+ then your typeMap may be
39
+
40
+ ['Foo', 'Bar']
41
+
42
+ 'Foo' and 'Bar' are what gets saved to the datahash when writing to the server,
43
+ and the types are used for the relationship within the application.
44
+
45
+ @property {Array of Strings}
46
+ @default null
47
+ */
48
+ typeMap: null,
49
+
50
+ /**
51
+ Returns the type, resolved to a class. If the type property is a regular
52
+ class, returns the type unchanged. Otherwise attempts to lookup the
53
+ type as a property path.
54
+
55
+ @property {Object}
56
+ */
57
+ typeClass: function() {
58
+ var ret = this.get('type'),
59
+ l, i, type;
60
+ if (SC.isArray(ret)) {
61
+ l = ret.get('length');
62
+ for (i=0; i<length; i++) {
63
+ type = ret.objectAt(i);
64
+ if (SC.typeOf(type) === SC.T_STRING) ret.replace(i, 1, SC.objectForPropertyPath(type));
65
+ }
66
+ } else {
67
+ SC.Logger.warn("%@ is a polymorphic relationship without an array of types".fmt(this));
68
+ if (SC.typeOf(ret) === SC.T_STRING) ret = SC.objectForPropertyPath(ret);
69
+ }
70
+ return ret ;
71
+ }.property('type').cacheable(),
72
+
73
+ /** @private
74
+ Override the transform function, as we need it to change depending on the record.
75
+
76
+ @param {Class} typeClass The class of the type
77
+ @param {SC.Record} record The record of this attribute
78
+ */
79
+ transform: function(klass) {
80
+ var transforms = SC.RecordAttribute.transforms,
81
+ ret ;
82
+
83
+ // walk up class hierarchy looking for a transform handler
84
+ while(klass && !(ret = transforms[SC.guidFor(klass)])) {
85
+ // check if super has create property to detect SC.Object's
86
+ if(klass.superclass.hasOwnProperty('create')) klass = klass.superclass;
87
+ // otherwise return the function transform handler
88
+ else klass = SC.T_FUNCTION;
89
+ }
90
+
91
+ return ret;
92
+ },
93
+
94
+ /**
95
+ Converts the passed value into the core attribute value. Uses the polymorphism
96
+ information provided to determine the correct type.
97
+
98
+ @param {SC.Record} record the record instance
99
+ @param {String} key the key used to access this attribute on the record
100
+ @param {Object} value the property value
101
+ @returns {Object} attribute value
102
+ */
103
+ toType: function(record, key, value) {
104
+ var types = this.get('type'),
105
+ typeKey = this.get('typeKey'),
106
+ typeMap = this.get('typeMap'),
107
+ type, transform, idx;
108
+
109
+ if (typeKey) {
110
+ type = record.get(typeKey);
111
+ } else if (SC.isArray(types)) {
112
+ // default to the first object if no type is provided
113
+ type = types.get('firstObject');
114
+ }
115
+
116
+ if (typeMap) {
117
+ idx = typeMap.indexOf(type);
118
+ if (idx > -1) {
119
+ type = types[idx];
120
+ } else {
121
+ SC.Logger.warn("Polymorphic map on property %@ for %@ did not exist on %@".fmt(key, type, record.constructor.toString()));
122
+ }
123
+ }
124
+
125
+ if (types.indexOf(type) > -1) {
126
+ if (SC.typeOf(type) === SC.T_STRING) type = SC.objectForPropertyPath(type);
127
+ transform = this.transform(type);
128
+ if (transform && transform.to) {
129
+ value = transform.to(value, this, type, record, key);
130
+ }
131
+ } else {
132
+ SC.Logger.warn("%@ is not a type on %@ of %@".fmt(type.toString(), key, record.constructor.toString()));
133
+ }
134
+
135
+ return value;
136
+ },
137
+
138
+ /**
139
+ Converts the passed value from the core attribute value. Uses the polymorphism
140
+ information provided to determine the correct type, and sets the typeKey attribute
141
+ on the record.
142
+
143
+ @param {SC.Record} record the record instance
144
+ @param {String} key the key used to access this attribute on the record
145
+ @param {Object} value the property value
146
+ @returns {Object} attribute value
147
+ */
148
+ fromType: function(record, key, value) {
149
+ var types = this.get('type'),
150
+ type = value.constructor,
151
+ typeString = type.toString(),
152
+ typeKey = this.get('typeKey'),
153
+ typeMap = this.get('typeMap'),
154
+ transform, idx;
155
+
156
+ if (!SC.empty(typeString)) {
157
+ if (typeMap) {
158
+ idx = types.indexOf(typeString);
159
+ if (idx > -1) {
160
+ typeString = typeMap[idx];
161
+ } else {
162
+ SC.Logger.warn("Polymorphic map on property %@ for %@ did not exist on %@".fmt(key, typeString, record.constructor.toString()));
163
+ }
164
+ }
165
+
166
+ if (typeKey) {
167
+ record.set(typeKey, typeString);
168
+ }
169
+ } else {
170
+ SC.Logger.warn("Could not determine type of %@ for polymorphic relation %@ on %@".fmt(value, key, record));
171
+ type = types.get('firstObject');
172
+ if (SC.typeOf(type) === SC.T_STRING) type = SC.objectForPropertyPath(type);
173
+ }
174
+
175
+ transform = this.transform(type);
176
+
177
+ if (transform && transform.from) {
178
+ value = transform.from(value, this, type, record, key);
179
+ }
180
+ return value;
181
+ }
182
+
183
+ });
@@ -0,0 +1,23 @@
1
+ // ==========================================================================
2
+ // Project: SproutCore - JavaScript Application Framework
3
+ // Copyright: ©2006-2011 Strobe Inc. and contributors.
4
+ // Portions ©2008-2010 Apple Inc. All rights reserved.
5
+ // License: Licensed under MIT license (see license.js)
6
+ // ==========================================================================
7
+
8
+ SC.mixin(SC.Record, {
9
+
10
+ /**
11
+ Returns a SC.PolymorphicSingleAttribute that converts the underlying ID to
12
+ a number of types, dependent on a attribute on the record (the name of this
13
+ attribute is provided by the typeKey property).
14
+
15
+ @param {Array} recordTypes the array of record types the object could be
16
+ @param {Hash} opts additional options
17
+ @returns {SC.PolymorphicSingleAttribute} created instance
18
+ */
19
+ toOneOf: function(recordTypes, opts) {
20
+ return SC.PolymorphicSingleAttribute.attr(recordTypes, opts);
21
+ }
22
+
23
+ });