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
@@ -27,66 +27,57 @@ sc_require('models/record_attribute');
27
27
  SC.ChildAttribute = SC.RecordAttribute.extend(
28
28
  /** @scope SC.ChildAttribute.prototype */ {
29
29
 
30
- isChildRecordTransform: YES,
30
+ isNestedRecordTransform: YES,
31
31
 
32
32
  // ..........................................................
33
33
  // LOW-LEVEL METHODS
34
34
  //
35
35
 
36
- /** @private - adapted for to many relationship */
37
- toType: function(parentRecord, key, hash) {
38
- var ret = null,
39
- cacheKey = SC.keyFor('__kid__', SC.guidFor(this)),
36
+ /** @private - adapted for to one relationship */
37
+ toType: function(record, key, value) {
38
+ var ret = null, rel,
40
39
  recordType = this.get('typeClass');
41
-
42
- if (parentRecord[cacheKey]) return parentRecord[cacheKey];
43
-
44
- if (!parentRecord) {
40
+
41
+ if (!record) {
45
42
  throw 'SC.Child: Error during transform: Unable to retrieve parent record.';
46
43
  }
47
-
48
- // If no hash, return null.
49
- if (hash){
50
- // Get the record type.
51
- var childNS = parentRecord.get('childRecordNamespace');
52
- if (hash.type && !SC.none(childNS)) {
53
- recordType = childNS[hash.type];
54
- }
55
-
56
- if (!recordType || SC.typeOf(recordType) !== SC.T_CLASS) {
57
- throw 'SC.Child: Error during transform: Invalid record type.';
58
- }
59
- // Create an instance of the record by registering it with the parent and return.
60
- ret = parentRecord[cacheKey] = parentRecord.registerChildRecord(recordType, hash);
61
- }
44
+ if (!SC.none(value)) ret = record.registerNestedRecord(value, key);
45
+
62
46
  return ret;
63
47
  },
64
48
 
65
49
  // Default fromType is just returning itself
66
50
  fromType: function(record, key, value){
67
- return value;
51
+ var sk, store, ret;
52
+ if (record){
53
+ ret = record.registerNestedRecord(value, key, key);
54
+ if (ret) {
55
+ sk = ret.get('storeKey');
56
+ store = ret.get('store');
57
+ record.writeAttribute(key, store.readDataHash(sk));
58
+ }
59
+ else if (value) {
60
+ record.writeAttribute(key, value);
61
+ }
62
+ }
63
+
64
+ return ret;
68
65
  },
69
66
 
70
67
  /**
71
68
  The core handler. Called from the property.
72
-
73
69
  @param {SC.Record} record the record instance
74
70
  @param {String} key the key used to access this attribute on the record
75
71
  @param {Object} value the property value if called as a setter
76
72
  @returns {Object} property value
77
73
  */
78
74
  call: function(record, key, value) {
79
- var attrKey = this.get('key') || key,
80
- cacheKey = SC.keyFor('__kid__', SC.guidFor(this)),
81
- nvalue;
75
+ var attrKey = this.get('key') || key, cRef,
76
+ cacheKey = SC.keyFor('__kid__', SC.guidFor(this));
82
77
  if (value !== undefined) {
83
- // careful: don't overwrite value here. we want the return value to
84
- // cache.
85
- this.orphan(record);
86
- nvalue = this.fromType(record, key, value) ; // convert to attribute.
87
- record[cacheKey] = null;
88
- record.writeAttribute(attrKey, nvalue);
89
- value = this.toType(record, key, value); // need to convert to the child record for caching
78
+ // this.orphan(record, cacheKey, value);
79
+ value = this.fromType(record, key, value) ; // convert to attribute.
80
+ // record[cacheKey] = value;
90
81
  } else {
91
82
  value = record.readAttribute(attrKey);
92
83
  if (SC.none(value) && (value = this.get('defaultValue'))) {
@@ -99,23 +90,6 @@ SC.ChildAttribute = SC.RecordAttribute.extend(
99
90
  }
100
91
 
101
92
  return value ;
102
- },
103
-
104
- orphan: function(parentRecord){
105
- var cacheKey = SC.keyFor('__kid__', SC.guidFor(this)),
106
- store, storeKey, attrs, key, param, cRef;
107
- cRef = parentRecord ? parentRecord[cacheKey] : null;
108
- if (cRef) {
109
- attrs = cRef.get('readOnlyAttributes');
110
- for(key in attrs) {
111
- param = cRef[key];
112
- // Orphan all the child record and child records in a tree to clean up the store
113
- if(param && param.isChildRecordTransform) param.orphan(parentRecord);
114
- }
115
- store = cRef.get('store');
116
- if(store) storeKey = cRef.storeKey;
117
- if(storeKey) store.unloadRecord(undefined, undefined, storeKey);
118
- }
119
93
  }
120
94
  });
121
95
 
@@ -7,6 +7,7 @@
7
7
  sc_require('models/record');
8
8
  sc_require('models/record_attribute');
9
9
  sc_require('models/child_attribute');
10
+ sc_require('system/child_array');
10
11
 
11
12
  /** @class
12
13
 
@@ -48,7 +49,7 @@ SC.ChildrenAttribute = SC.ChildAttribute.extend(
48
49
  defaultRecordType: recordType
49
50
  });
50
51
 
51
- record[arrayKey] = this._cachedRef = ret ; // save on record
52
+ record[arrayKey] = ret ; // save on record
52
53
  rel = record.get('relationships');
53
54
  if (!rel) record.set('relationships', rel = []);
54
55
  rel.push(ret); // make sure we get notified of changes...
@@ -56,25 +57,18 @@ SC.ChildrenAttribute = SC.ChildAttribute.extend(
56
57
 
57
58
  return ret;
58
59
  },
59
-
60
- orphan: function(parentRecord){
61
- var cArray = this._cachedRef,
62
- store, storeKey, attrs, key,
63
- len, param, cr;
64
-
65
- if (cArray) {
66
- cArray.forEach( function(cr){
67
- attrs = cr.get('readOnlyAttributes');
68
- for(key in attrs) {
69
- param = cr[key];
70
- // Orphan all the child record and child records in a tree to clean up the store
71
- if(param && param.isChildRecordTransform) param.orphan(parentRecord);
72
- }
73
- store = cr.get('store');
74
- if(store) storeKey = cr.storeKey;
75
- if(storeKey) store.unloadRecord(undefined, undefined, storeKey);
76
- }, this);
60
+
61
+ // Default fromType is just returning itself
62
+ fromType: function(record, key, value){
63
+ var sk, store,
64
+ arrayKey = SC.keyFor('__kidsArray__', SC.guidFor(this)),
65
+ ret = record[arrayKey];
66
+ if (record) {
67
+ record.writeAttribute(key, value);
68
+ if (ret) ret = ret.recordPropertyDidChange();
77
69
  }
70
+
71
+ return ret;
78
72
  }
79
73
  });
80
74
 
@@ -7,6 +7,7 @@
7
7
 
8
8
  sc_require('models/record');
9
9
  sc_require('models/record_attribute');
10
+ sc_require('system/many_array');
10
11
 
11
12
  /** @class
12
13
 
@@ -46,6 +46,11 @@ SC.Record = SC.Object.extend(
46
46
  */
47
47
  isRecord: YES,
48
48
 
49
+ /**
50
+ If you have nested records
51
+ */
52
+ isParentRecord: NO,
53
+
49
54
  // ...............................
50
55
  // PROPERTIES
51
56
  //
@@ -202,15 +207,27 @@ SC.Record = SC.Object.extend(
202
207
  }.property(),
203
208
 
204
209
  /**
205
- * The child record cache.
210
+ * The namespace which to retrieve the childRecord Types from
206
211
  */
207
- childRecords: null,
212
+ nestedRecordNamespace: null,
208
213
 
209
214
  /**
210
- * The namespace which to retrieve the childRecord Types from
211
- */
212
- childRecordNamespace: null,
213
-
215
+ Function that returns whether this is a nested Record
216
+ */
217
+ isNestedRecord: function(){
218
+ var store = this.get('store'), ret,
219
+ sk = this.get('storeKey'),
220
+ prKey = store.parentStoreKeyExists(sk);
221
+
222
+ ret = prKey ? YES : NO;
223
+ return ret;
224
+ }.property().cacheable(),
225
+
226
+ parentRecord: function(){
227
+ var sk = this.storeKey, store = this.get('store');
228
+ return store.materializeParentRecord(sk);
229
+ }.property(),
230
+
214
231
  // ...............................
215
232
  // CRUD OPERATIONS
216
233
  //
@@ -221,10 +238,26 @@ SC.Record = SC.Object.extend(
221
238
  record data from the server. If the record is new and exists only in
222
239
  memory then this call will have no effect.
223
240
 
241
+ @param {boolean} recordOnly, optional param if you want to only THIS record
242
+ even if it is a child record.
243
+
224
244
  @returns {SC.Record} receiver
225
245
  */
226
- refresh: function() {
227
- this.get('store').refreshRecord(null, null, this.get('storeKey'));
246
+ refresh: function(recordOnly) {
247
+ var store = this.get('store'), rec, ro,
248
+ sk = this.get('storeKey'),
249
+ prKey = store.parentStoreKeyExists();
250
+
251
+ // If we only want to commit this record or it doesn't have a parent record
252
+ // we will commit this record
253
+ ro = recordOnly || (SC.none(recordOnly) && SC.none(prKey));
254
+ if (ro){
255
+ store.refreshRecord(null, null, sk);
256
+ } else if (prKey){
257
+ rec = store.materializeRecord(prKey);
258
+ rec.refresh(recordOnly);
259
+ }
260
+
228
261
  return this ;
229
262
  },
230
263
 
@@ -234,16 +267,31 @@ SC.Record = SC.Object.extend(
234
267
  property on the record to YES. If this is a new record, this will avoid
235
268
  creating the record in the first place.
236
269
 
270
+ @param {boolean} recordOnly, optional param if you want to only THIS record
271
+ even if it is a child record.
272
+
237
273
  @returns {SC.Record} receiver
238
274
  */
239
- destroy: function() {
240
- this.get('store').destroyRecord(null, null, this.get('storeKey'));
241
- this.notifyPropertyChange('status');
242
-
243
- // If there are any aggregate records, we might need to propagate our new
244
- // status to them.
245
- this.propagateToAggregates();
246
-
275
+ destroy: function(recordOnly) {
276
+ var store = this.get('store'), rec, ro,
277
+ sk = this.get('storeKey'),
278
+ prKey = store.parentStoreKeyExists();
279
+
280
+ // If we only want to commit this record or it doesn't have a parent record
281
+ // we will commit this record
282
+ ro = recordOnly || (SC.none(recordOnly) && SC.none(prKey));
283
+ if (ro){
284
+ store.destroyRecord(null, null, sk);
285
+ this.notifyPropertyChange('status');
286
+ // If there are any aggregate records, we might need to propagate our new
287
+ // status to them.
288
+ this.propagateToAggregates();
289
+
290
+ } else if (prKey){
291
+ rec = store.materializeRecord(prKey);
292
+ rec.destroy(recordOnly);
293
+ }
294
+
247
295
  return this ;
248
296
  },
249
297
 
@@ -262,6 +310,11 @@ SC.Record = SC.Object.extend(
262
310
  @returns {SC.Record} receiver
263
311
  */
264
312
  recordDidChange: function(key) {
313
+
314
+ // If we have a parent, they changed too!
315
+ var p = this.get('parentRecord');
316
+ if (p) p.recordDidChange();
317
+
265
318
  this.get('store').recordDidChange(null, null, this.get('storeKey'), key);
266
319
  this.notifyPropertyChange('status');
267
320
 
@@ -452,7 +505,7 @@ SC.Record = SC.Object.extend(
452
505
  // also notify manyArrays
453
506
  var manyArrays = this.relationships,
454
507
  loc = manyArrays ? manyArrays.length : 0 ;
455
- while(--loc>=0) manyArrays[loc].recordPropertyDidChange(keys);
508
+ while(--loc>=0) manyArrays[loc].recordPropertyDidChange(keys);
456
509
  }
457
510
  },
458
511
 
@@ -496,7 +549,7 @@ SC.Record = SC.Object.extend(
496
549
  if (typeClass) {
497
550
  keyForDataHash = valueForKey.get('key') || key; // handle alt keys
498
551
  isRecord = SC.typeOf(typeClass.call(valueForKey))===SC.T_CLASS;
499
- isChild = valueForKey.isChildRecordTransform;
552
+ isChild = valueForKey.isNestedRecordTransform;
500
553
  if (!isRecord && !isChild) {
501
554
  attrValue = this.get(key);
502
555
  if(attrValue!==undefined || (attrValue===null && includeNull)) {
@@ -591,11 +644,25 @@ SC.Record = SC.Object.extend(
591
644
 
592
645
  @param {Hash} params optional additonal params that will passed down
593
646
  to the data source
647
+ @param {boolean} recordOnly, optional param if you want to only commit a single
648
+ record if it has a parent.
594
649
  @returns {SC.Record} receiver
595
650
  */
596
- commitRecord: function(params) {
597
- var store = this.get('store');
598
- store.commitRecord(undefined, undefined, this.get('storeKey'), params);
651
+ commitRecord: function(params, recordOnly) {
652
+ var store = this.get('store'), rec, ro,
653
+ sk = this.get('storeKey'),
654
+ prKey = store.parentStoreKeyExists();
655
+
656
+ // If we only want to commit this record or it doesn't have a parent record
657
+ // we will commit this record
658
+ ro = recordOnly || (SC.none(recordOnly) && SC.none(prKey));
659
+ if (ro){
660
+ store.commitRecord(undefined, undefined, this.get('storeKey'), params);
661
+ } else if (prKey){
662
+ rec = store.materializeRecord(prKey);
663
+ rec.commitRecord(params, recordOnly);
664
+ }
665
+
599
666
  return this ;
600
667
  },
601
668
 
@@ -698,64 +765,119 @@ SC.Record = SC.Object.extend(
698
765
  instance. If not, create the child record instance and add it to the child
699
766
  record cache.
700
767
 
701
- @param {SC.ChildRecord} recordType The type of the child record to
702
- register.
703
- @param {Hash} hash The hash of attributes to apply to the child record.
768
+ @param {Hash} value The hash of attributes to apply to the child record.
769
+ @param {Integer} key The store key that we are asking for
704
770
  */
705
- registerChildRecord: function(recordType, hash) {
706
- var pm = recordType.primaryKey || 'childRecordKey';
707
- var childKey = hash[pm];
708
- var childRecord = null;
709
- var crManager = this.get('childRecords');
710
- if (childKey && crManager) {
711
- childRecord = crManager[childKey];
771
+ registerNestedRecord: function(value, key, path) {
772
+ var store, psk, csk, childRecord, recordType;
773
+
774
+ // if no path is entered it must be the key
775
+ if (SC.none(path)) path = key;
776
+ // if a record instance is passed, simply use the storeKey. This allows
777
+ // you to pass a record from a chained store to get the same record in the
778
+ // current store.
779
+ if (value && value.get && value.get('isRecord')) {
780
+ childRecord = value;
781
+ }
782
+ else {
783
+ recordType = this._materializeNestedRecordType(value, key);
784
+ childRecord = this.createNestedRecord(recordType, value);
785
+ }
786
+ if (childRecord){
787
+ this.isParentRecord = YES;
788
+ store = this.get('store');
789
+ psk = this.get('storeKey');
790
+ csk = childRecord.get('storeKey');
791
+ store.registerChildToParent(psk, csk, path);
792
+ }
793
+
794
+ return childRecord;
795
+ },
796
+
797
+ /**
798
+ private method that retrieves the recordType from the hash that is provided.
799
+
800
+ Important for use in polymorphism but you must have the following items in the
801
+ parent record:
802
+
803
+ nestedRecordNamespace <= this is the object that has the SC.Records defined
804
+
805
+ @param {Hash} value The hash of attributes to apply to the child record.
806
+ @param {String} key the name of the key on the attribute
807
+ */
808
+ _materializeNestedRecordType: function(value, key){
809
+ var childNS, recordType, ret;
810
+
811
+ // Get the record type, first checking the "type" property on the hash.
812
+ if (SC.typeOf(value) === SC.T_HASH) {
813
+ // Get the record type.
814
+ childNS = this.get('nestedRecordNamespace');
815
+ if (value.type && !SC.none(childNS)) {
816
+ recordType = childNS[value.type];
817
+ }
712
818
  }
713
819
 
714
- if (SC.none(childRecord)) childRecord = this.createChildRecord(recordType, hash);
820
+ // Maybe it's not a hash or there was no type property.
821
+ if (!recordType && key && this[key]) {
822
+ recordType = this[key].get('typeClass');
823
+ }
715
824
 
716
- return childRecord;
825
+ // When all else fails throw and exception.
826
+ if (!recordType || !SC.kindOf(recordType, SC.Record)) {
827
+ throw 'SC.Child: Error during transform: Invalid record type.';
828
+ }
829
+
830
+ return recordType;
717
831
  },
718
832
 
719
833
  /**
720
- Creates a new child record instance.
834
+ Creates a new nested record instance.
721
835
 
722
- @param {SC.ChildRecord} recordType The type of the child record to create.
836
+ @param {SC.Record} recordType The type of the nested record to create.
723
837
  @param {Hash} hash The hash of attributes to apply to the child record.
724
838
  (may be null)
725
839
  */
726
- createChildRecord: function(childRecordType, hash) {
727
- var cr = null;
840
+ createNestedRecord: function(recordType, hash) {
841
+ var store, id, sk, pk, cr = null, existingId = null;
728
842
  SC.run(function() {
729
- // Generate the key used by the parent's child record manager.
730
- var key = SC.Record._generateChildKey();
731
843
  hash = hash || {}; // init if needed
732
- var pm = childRecordType.primaryKey || 'childRecordKey';
733
- var childKey = hash[pm];
734
- hash[pm] = key;
735
-
736
- var store = this.get('store');
844
+
845
+ existingId = hash[recordType.prototype.primaryKey];
846
+
847
+ store = this.get('store');
737
848
  if (SC.none(store)) throw 'Error: during the creation of a child record: NO STORE ON PARENT!';
738
-
739
- cr = store.createRecord(childRecordType, hash);
740
- cr._parentRecord = this;
741
-
742
- // ID processing if necessary
743
- if(this.generateIdForChild) this.generateIdForChild(cr);
744
-
745
- // Add the child record to the hash.
746
- var crManager = this.get('childRecords');
747
- if (SC.none(crManager)) {
748
- //console.log('Creating Child Record Manager for (%@)'.fmt(SC.guidFor(this)));
749
- crManager = SC.Object.create();
750
- this.set('childRecords', crManager);
849
+
850
+ if (!id && (pk = recordType.prototype.primaryKey)) {
851
+ id = hash[pk];
852
+ // In case there isnt a primary key supplied then we create on
853
+ // on the fly
854
+ sk = id ? store.storeKeyExists(recordType, id) : null;
855
+ if (sk){
856
+ store.writeDataHash(sk, hash);
857
+ cr = store.materializeRecord(sk);
858
+ } else {
859
+ cr = store.createRecord(recordType, hash) ;
860
+ if (SC.none(id)){
861
+ sk = cr.get('storeKey');
862
+ id = 'cr'+sk;
863
+ SC.Store.replaceIdFor(sk, id);
864
+ hash = store.readEditableDataHash(sk);
865
+ hash[pk] = id;
866
+ }
867
+ }
868
+
751
869
  }
870
+
871
+ // ID processing if necessary
872
+ if (SC.none(existingId) && this.generateIdForChild) this.generateIdForChild(cr);
752
873
 
753
- crManager[key] = cr;
754
874
  }, this);
755
875
 
756
876
  return cr;
757
877
  },
758
878
 
879
+ _nestedRecordKey: 0,
880
+
759
881
  /**
760
882
  * Override this function if you want to have a special way of creating
761
883
  * ids for your child records
@@ -976,7 +1098,7 @@ SC.Record.mixin( /** @scope SC.Record */ {
976
1098
 
977
1099
  @property {SC.Error}
978
1100
  */
979
- BAD_STATE_ERROR: SC.$error("Internal Inconsistency"),
1101
+ BAD_STATE_ERROR: SC.$error("Internal barf Inconsistency"),
980
1102
 
981
1103
  /**
982
1104
  Error for when you try to create a new record that already exists.
@@ -1083,7 +1205,7 @@ SC.Record.mixin( /** @scope SC.Record */ {
1083
1205
  */
1084
1206
  toMany: function(recordType, opts) {
1085
1207
  opts = opts || {};
1086
- var isNested = opts.nested;
1208
+ var isNested = opts.nested || opts.isNested;
1087
1209
  var attr;
1088
1210
  if(isNested){
1089
1211
  attr = SC.ChildrenAttribute.attr(recordType, opts);
@@ -1109,7 +1231,7 @@ SC.Record.mixin( /** @scope SC.Record */ {
1109
1231
  */
1110
1232
  toOne: function(recordType, opts) {
1111
1233
  opts = opts || {};
1112
- var isNested = opts.nested;
1234
+ var isNested = opts.nested || opts.isNested;
1113
1235
  var attr;
1114
1236
  if(isNested){
1115
1237
  attr = SC.ChildAttribute.attr(recordType, opts);
@@ -1190,15 +1312,5 @@ SC.Record.mixin( /** @scope SC.Record */ {
1190
1312
  var ret = SC.Object.extend.apply(this, arguments);
1191
1313
  SC.Query._scq_didDefineRecordType(ret);
1192
1314
  return ret ;
1193
- },
1194
-
1195
- // ..........................................................
1196
- // PRIVATE METHODS
1197
- //
1198
-
1199
- _generateChildKey: function() {
1200
- var newIdx = SC.Record._nextChildKey + 1;
1201
- SC.Record._nextChildKey = newIdx;
1202
- return newIdx;
1203
1315
  }
1204
1316
  }) ;
@@ -6,7 +6,6 @@
6
6
  // ==========================================================================
7
7
 
8
8
  sc_require('models/record');
9
- sc_require('models/child_record');
10
9
 
11
10
  /** @class
12
11
 
@@ -463,7 +462,7 @@ SC.RecordAttribute.registerTransform(Date, {
463
462
  if (d[12]) { date.setMilliseconds(Number("0." + d[12]) * 1000); }
464
463
  if (d[14]) {
465
464
  offset = (Number(d[16]) * 60) + Number(d[17]);
466
- offset *= ((d[15] == '-') ? 1 : -1);
465
+ offset *= ((d[15] === '-') ? 1 : -1);
467
466
  }
468
467
 
469
468
  offset -= date.getTimezoneOffset();