sproutcore 1.6.0.beta.3-java → 1.6.0-java

Sign up to get free protection for your applications and to get access to all the features.
Files changed (633) hide show
  1. data/CHANGELOG +70 -0
  2. data/{History.txt → History.rdoc} +0 -0
  3. data/{README.txt → README.rdoc} +3 -2
  4. data/Rakefile +213 -10
  5. data/{Todo.txt → Todo.rdoc} +0 -0
  6. data/VERSION.yml +1 -1
  7. data/bin/sc-docs +6 -1
  8. data/lib/Buildfile +5 -1
  9. data/lib/buildtasks/manifest.rake +14 -1
  10. data/lib/buildtasks/target.rake +20 -23
  11. data/lib/frameworks/sproutcore/Buildfile +8 -3
  12. data/lib/frameworks/sproutcore/CHANGELOG.md +364 -1
  13. data/lib/frameworks/sproutcore/README.md +1 -1
  14. data/lib/frameworks/sproutcore/apps/test_controls/controllers/select.js +12 -0
  15. data/lib/frameworks/sproutcore/apps/test_controls/resources/select_page.js +19 -5
  16. data/lib/frameworks/sproutcore/apps/welcome/english.lproj/main_page.css +9 -0
  17. data/lib/frameworks/sproutcore/frameworks/ajax/system/request.js +243 -199
  18. data/lib/frameworks/sproutcore/frameworks/ajax/system/response.js +250 -172
  19. data/lib/frameworks/sproutcore/frameworks/ajax/tests/system/request.js +29 -0
  20. data/lib/frameworks/sproutcore/frameworks/core_foundation/controllers/array.js +5 -0
  21. data/lib/frameworks/sproutcore/frameworks/core_foundation/controllers/controller.js +21 -1
  22. data/lib/frameworks/sproutcore/frameworks/core_foundation/controls/button.js +6 -2
  23. data/lib/frameworks/sproutcore/frameworks/core_foundation/core.js +2 -42
  24. data/lib/frameworks/sproutcore/frameworks/core_foundation/ext/handlebars/bind.js +38 -15
  25. data/lib/frameworks/sproutcore/frameworks/core_foundation/ext/handlebars/collection.js +6 -4
  26. data/lib/frameworks/sproutcore/frameworks/core_foundation/mixins/responder_context.js +1 -1
  27. data/lib/frameworks/sproutcore/frameworks/core_foundation/mixins/template_helpers/checkbox_support.js +11 -6
  28. data/lib/frameworks/sproutcore/frameworks/core_foundation/mixins/template_helpers/text_field_support.js +55 -20
  29. data/lib/frameworks/sproutcore/frameworks/core_foundation/panes/keyboard.js +2 -0
  30. data/lib/frameworks/sproutcore/frameworks/core_foundation/panes/pane.js +26 -20
  31. data/lib/frameworks/sproutcore/frameworks/core_foundation/panes/template.js +37 -21
  32. data/lib/frameworks/sproutcore/frameworks/core_foundation/system/application.js +2 -7
  33. data/lib/frameworks/sproutcore/frameworks/core_foundation/system/event.js +7 -7
  34. data/lib/frameworks/sproutcore/frameworks/core_foundation/system/locale.js +157 -5
  35. data/lib/frameworks/sproutcore/frameworks/core_foundation/system/platform.js +2 -2
  36. data/lib/frameworks/sproutcore/frameworks/core_foundation/system/render_context.js +7 -6
  37. data/lib/frameworks/sproutcore/frameworks/core_foundation/system/responder.js +1 -1
  38. data/lib/frameworks/sproutcore/frameworks/core_foundation/system/root_responder.js +29 -15
  39. data/lib/frameworks/sproutcore/frameworks/core_foundation/system/sparse_array.js +8 -8
  40. data/lib/frameworks/sproutcore/frameworks/core_foundation/system/string.js +162 -1
  41. data/lib/frameworks/sproutcore/frameworks/core_foundation/system/theme.js +3 -56
  42. data/lib/frameworks/sproutcore/frameworks/core_foundation/system/utils.js +24 -8
  43. data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/controllers/array/array_case.js +42 -0
  44. data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/controllers/object/content_destroyed.js +59 -0
  45. data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/controls/button.js +39 -57
  46. data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/mixins/string.js +41 -1
  47. data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/mixins/template_helpers/text_field_support.js +19 -2
  48. data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/panes/template.js +16 -1
  49. data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/system/render_context/helpers_style.js +5 -3
  50. data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/system/sparse_array.js +32 -0
  51. data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/template/collection.js +135 -0
  52. data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/template/handlebars.js +29 -18
  53. data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/clippingFrame.js +11 -0
  54. data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/didAppendToDocument.js +18 -2
  55. data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/insertBefore.js +10 -6
  56. data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/keyboard.js +414 -1
  57. data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/view.js +1 -1
  58. data/lib/frameworks/sproutcore/frameworks/core_foundation/{system → views}/bindable_span.js +2 -1
  59. data/lib/frameworks/sproutcore/frameworks/core_foundation/views/template_collection.js +112 -40
  60. data/lib/frameworks/sproutcore/frameworks/core_foundation/views/view.js +13 -7
  61. data/lib/frameworks/sproutcore/frameworks/core_foundation/views/view/enabled.js +2 -1
  62. data/lib/frameworks/sproutcore/frameworks/core_foundation/views/view/keyboard.js +245 -67
  63. data/lib/frameworks/sproutcore/frameworks/core_foundation/views/view/manipulation.js +17 -9
  64. data/lib/frameworks/sproutcore/frameworks/core_foundation/views/view/theming.js +8 -18
  65. data/lib/frameworks/sproutcore/frameworks/core_tools/core.js +8 -2
  66. data/lib/frameworks/sproutcore/frameworks/core_tools/data_source.js +1 -1
  67. data/lib/frameworks/sproutcore/frameworks/core_tools/models/target.js +1 -1
  68. data/lib/frameworks/sproutcore/frameworks/datastore/data_sources/data_source.js +15 -8
  69. data/lib/frameworks/sproutcore/frameworks/datastore/data_sources/fixtures.js +12 -2
  70. data/lib/frameworks/sproutcore/frameworks/datastore/mixins/relationship_support.js +296 -0
  71. data/lib/frameworks/sproutcore/frameworks/datastore/models/child_record.js +3 -3
  72. data/lib/frameworks/sproutcore/frameworks/datastore/models/record.js +330 -326
  73. data/lib/frameworks/sproutcore/frameworks/datastore/models/record_attribute.js +23 -1
  74. data/lib/frameworks/sproutcore/frameworks/datastore/system/child_array.js +26 -5
  75. data/lib/frameworks/sproutcore/frameworks/datastore/system/nested_store.js +1 -1
  76. data/lib/frameworks/sproutcore/frameworks/datastore/system/record_array.js +69 -58
  77. data/lib/frameworks/sproutcore/frameworks/datastore/system/store.js +614 -614
  78. data/lib/frameworks/sproutcore/frameworks/datastore/tests/data_sources/data_source.js +203 -0
  79. data/lib/frameworks/sproutcore/frameworks/datastore/tests/models/nested_records/nested_record.js +3 -1
  80. data/lib/frameworks/sproutcore/frameworks/datastore/tests/models/nested_records/nested_record_array.js +44 -0
  81. data/lib/frameworks/sproutcore/frameworks/datastore/tests/models/nested_records/nested_record_array_complex.js +2 -0
  82. data/lib/frameworks/sproutcore/frameworks/datastore/tests/models/nested_records/nested_record_complex.js +2 -0
  83. data/lib/frameworks/sproutcore/frameworks/datastore/tests/models/record/core_methods.js +20 -13
  84. data/lib/frameworks/sproutcore/frameworks/datastore/tests/models/record_attribute.js +76 -47
  85. data/lib/frameworks/sproutcore/frameworks/datastore/tests/system/nested_store/commitChangesFromNestedStore.js +30 -30
  86. data/lib/frameworks/sproutcore/frameworks/datastore/tests/system/record_array/core_methods.js +74 -53
  87. data/lib/frameworks/sproutcore/frameworks/datastore/tests/system/record_array/flush.js +0 -1
  88. data/lib/frameworks/sproutcore/frameworks/datastore/tests/system/store/commitChangesFromNestedStore.js +24 -24
  89. data/lib/frameworks/sproutcore/frameworks/datastore/tests/system/store/connectDataSource.js +31 -0
  90. data/lib/frameworks/sproutcore/frameworks/datastore/tests/system/store/pushRelationships.js +1177 -0
  91. data/lib/frameworks/sproutcore/frameworks/datetime/frameworks/core/system/datetime.js +212 -182
  92. data/lib/frameworks/sproutcore/frameworks/datetime/frameworks/localized/system/datetime.js +6 -67
  93. data/lib/frameworks/sproutcore/frameworks/desktop/mixins/border.js +1 -1
  94. data/lib/frameworks/sproutcore/frameworks/desktop/mixins/collection_row_delegate.js +1 -1
  95. data/lib/frameworks/sproutcore/frameworks/desktop/mixins/scrollable.js +1 -1
  96. data/lib/frameworks/sproutcore/frameworks/desktop/panes/alert.js +13 -15
  97. data/lib/frameworks/sproutcore/frameworks/desktop/panes/menu.js +41 -12
  98. data/lib/frameworks/sproutcore/frameworks/desktop/panes/panel.js +9 -0
  99. data/lib/frameworks/sproutcore/frameworks/desktop/panes/picker.js +6 -3
  100. data/lib/frameworks/sproutcore/frameworks/desktop/protocols/drag_data_source.js +3 -3
  101. data/lib/frameworks/sproutcore/frameworks/desktop/protocols/drop_target.js +3 -3
  102. data/lib/frameworks/sproutcore/frameworks/desktop/render_delegates/button.js +1 -1
  103. data/lib/frameworks/sproutcore/frameworks/desktop/render_delegates/checkbox.js +1 -1
  104. data/lib/frameworks/sproutcore/frameworks/desktop/render_delegates/collection.js +1 -1
  105. data/lib/frameworks/sproutcore/frameworks/desktop/render_delegates/disclosure.js +1 -1
  106. data/lib/frameworks/sproutcore/frameworks/desktop/render_delegates/image_button.js +1 -1
  107. data/lib/frameworks/sproutcore/frameworks/desktop/render_delegates/master_detail.js +3 -2
  108. data/lib/frameworks/sproutcore/frameworks/desktop/render_delegates/menu.js +12 -2
  109. data/lib/frameworks/sproutcore/frameworks/desktop/render_delegates/panel.js +1 -1
  110. data/lib/frameworks/sproutcore/frameworks/desktop/render_delegates/picker.js +1 -1
  111. data/lib/frameworks/sproutcore/frameworks/desktop/render_delegates/progress.js +1 -1
  112. data/lib/frameworks/sproutcore/frameworks/desktop/render_delegates/radio.js +1 -1
  113. data/lib/frameworks/sproutcore/frameworks/desktop/render_delegates/radio_group.js +2 -2
  114. data/lib/frameworks/sproutcore/frameworks/desktop/render_delegates/segment.js +1 -1
  115. data/lib/frameworks/sproutcore/frameworks/desktop/render_delegates/segmented.js +1 -1
  116. data/lib/frameworks/sproutcore/frameworks/desktop/render_delegates/slider.js +1 -1
  117. data/lib/frameworks/sproutcore/frameworks/desktop/render_delegates/toolbar.js +1 -1
  118. data/lib/frameworks/sproutcore/frameworks/desktop/render_delegates/well.js +1 -1
  119. data/lib/frameworks/sproutcore/frameworks/desktop/render_delegates/workspace.js +1 -1
  120. data/lib/frameworks/sproutcore/frameworks/desktop/resources/alert.css +49 -0
  121. data/lib/frameworks/sproutcore/frameworks/desktop/{english.lproj → resources}/debug/a_sample_image.jpg +0 -0
  122. data/lib/frameworks/sproutcore/frameworks/desktop/{english.lproj → resources}/debug/apple-logo1.jpeg +0 -0
  123. data/lib/frameworks/sproutcore/frameworks/desktop/{english.lproj → resources}/debug/iframe.html +0 -0
  124. data/lib/frameworks/sproutcore/frameworks/desktop/resources/disclosure.css +20 -0
  125. data/lib/frameworks/sproutcore/frameworks/desktop/{english.lproj → resources}/drag.css +1 -1
  126. data/lib/frameworks/sproutcore/frameworks/desktop/resources/icons.css +214 -0
  127. data/lib/frameworks/sproutcore/frameworks/desktop/{english.lproj → resources}/images/cap.png +0 -0
  128. data/lib/frameworks/sproutcore/frameworks/desktop/{english.lproj → resources}/images/downbutton.png +0 -0
  129. data/lib/frameworks/sproutcore/frameworks/desktop/resources/images/icons/sc-icon-alert-16.png +0 -0
  130. data/lib/frameworks/sproutcore/frameworks/desktop/resources/images/icons/sc-icon-alert-24.png +0 -0
  131. data/lib/frameworks/sproutcore/frameworks/desktop/resources/images/icons/sc-icon-alert-48.png +0 -0
  132. data/lib/frameworks/sproutcore/frameworks/desktop/resources/images/icons/sc-icon-bookmark-16.png +0 -0
  133. data/lib/frameworks/sproutcore/frameworks/desktop/resources/images/icons/sc-icon-bookmark-24.png +0 -0
  134. data/lib/frameworks/sproutcore/frameworks/desktop/resources/images/icons/sc-icon-cancel-24.png +0 -0
  135. data/lib/frameworks/sproutcore/frameworks/desktop/resources/images/icons/sc-icon-document-16.png +0 -0
  136. data/lib/frameworks/sproutcore/frameworks/desktop/resources/images/icons/sc-icon-document-24.png +0 -0
  137. data/lib/frameworks/sproutcore/frameworks/desktop/resources/images/icons/sc-icon-down-24.png +0 -0
  138. data/lib/frameworks/sproutcore/frameworks/desktop/resources/images/icons/sc-icon-error-48.png +0 -0
  139. data/lib/frameworks/sproutcore/frameworks/desktop/resources/images/icons/sc-icon-favorite-16.png +0 -0
  140. data/lib/frameworks/sproutcore/frameworks/desktop/resources/images/icons/sc-icon-favorite-24.png +0 -0
  141. data/lib/frameworks/sproutcore/frameworks/desktop/resources/images/icons/sc-icon-folder-16.png +0 -0
  142. data/lib/frameworks/sproutcore/frameworks/desktop/resources/images/icons/sc-icon-folder-24.png +0 -0
  143. data/lib/frameworks/sproutcore/frameworks/desktop/resources/images/icons/sc-icon-group-16.png +0 -0
  144. data/lib/frameworks/sproutcore/frameworks/desktop/resources/images/icons/sc-icon-group-24.png +0 -0
  145. data/lib/frameworks/sproutcore/frameworks/desktop/resources/images/icons/sc-icon-help-16.png +0 -0
  146. data/lib/frameworks/sproutcore/frameworks/desktop/resources/images/icons/sc-icon-help-24.png +0 -0
  147. data/lib/frameworks/sproutcore/frameworks/desktop/resources/images/icons/sc-icon-info-16.png +0 -0
  148. data/lib/frameworks/sproutcore/frameworks/desktop/resources/images/icons/sc-icon-info-24.png +0 -0
  149. data/lib/frameworks/sproutcore/frameworks/desktop/resources/images/icons/sc-icon-info-48.png +0 -0
  150. data/lib/frameworks/sproutcore/frameworks/desktop/resources/images/icons/sc-icon-left-24.png +0 -0
  151. data/lib/frameworks/sproutcore/frameworks/desktop/resources/images/icons/sc-icon-options-16.png +0 -0
  152. data/lib/frameworks/sproutcore/frameworks/desktop/resources/images/icons/sc-icon-options-24.png +0 -0
  153. data/lib/frameworks/sproutcore/frameworks/desktop/resources/images/icons/sc-icon-redo-24.png +0 -0
  154. data/lib/frameworks/sproutcore/frameworks/desktop/resources/images/icons/sc-icon-right-24.png +0 -0
  155. data/lib/frameworks/sproutcore/frameworks/desktop/resources/images/icons/sc-icon-tools-24.png +0 -0
  156. data/lib/frameworks/sproutcore/frameworks/desktop/resources/images/icons/sc-icon-trash-16.png +0 -0
  157. data/lib/frameworks/sproutcore/frameworks/desktop/resources/images/icons/sc-icon-trash-24.png +0 -0
  158. data/lib/frameworks/sproutcore/frameworks/desktop/resources/images/icons/sc-icon-undo-24.png +0 -0
  159. data/lib/frameworks/sproutcore/frameworks/desktop/resources/images/icons/sc-icon-up-24.png +0 -0
  160. data/lib/frameworks/sproutcore/frameworks/desktop/resources/images/icons/sc-icon-user-16.png +0 -0
  161. data/lib/frameworks/sproutcore/frameworks/desktop/resources/images/icons/sc-icon-user-24.png +0 -0
  162. data/lib/frameworks/sproutcore/frameworks/desktop/{english.lproj → resources}/images/thumb-bottom.png +0 -0
  163. data/lib/frameworks/sproutcore/frameworks/desktop/{english.lproj → resources}/images/thumb-center.png +0 -0
  164. data/lib/frameworks/sproutcore/frameworks/desktop/{english.lproj → resources}/images/thumb-top.png +0 -0
  165. data/lib/frameworks/sproutcore/frameworks/desktop/{english.lproj → resources}/images/track.png +0 -0
  166. data/lib/frameworks/sproutcore/frameworks/desktop/{english.lproj → resources}/images/upbutton.png +0 -0
  167. data/lib/frameworks/sproutcore/frameworks/desktop/resources/list_item.css +145 -0
  168. data/lib/frameworks/sproutcore/frameworks/desktop/resources/menu.css +10 -0
  169. data/lib/frameworks/sproutcore/frameworks/desktop/resources/menu_item_view.css +88 -0
  170. data/lib/frameworks/sproutcore/frameworks/desktop/{english.lproj → resources}/modal.css +3 -4
  171. data/lib/frameworks/sproutcore/frameworks/desktop/resources/panel.css +91 -0
  172. data/lib/frameworks/sproutcore/frameworks/desktop/resources/picker.css +37 -0
  173. data/lib/frameworks/sproutcore/frameworks/desktop/resources/progress.css +29 -0
  174. data/lib/frameworks/sproutcore/frameworks/desktop/resources/radio.css +11 -0
  175. data/lib/frameworks/sproutcore/frameworks/desktop/resources/segmented.css +122 -0
  176. data/lib/frameworks/sproutcore/frameworks/desktop/resources/separator.css +20 -0
  177. data/lib/frameworks/sproutcore/frameworks/desktop/resources/slider.css +34 -0
  178. data/lib/frameworks/sproutcore/frameworks/desktop/{english.lproj → resources}/split.css +0 -0
  179. data/lib/frameworks/sproutcore/frameworks/desktop/{english.lproj → resources}/split_divider.css +0 -0
  180. data/lib/frameworks/sproutcore/frameworks/desktop/{english.lproj → resources}/tab.css +0 -0
  181. data/lib/frameworks/sproutcore/frameworks/desktop/{english.lproj → resources}/toolbar.css +0 -0
  182. data/lib/frameworks/sproutcore/frameworks/desktop/{english.lproj → resources}/touch-scroller.css +13 -13
  183. data/lib/frameworks/sproutcore/frameworks/desktop/resources/well.css +65 -0
  184. data/lib/frameworks/sproutcore/frameworks/desktop/tests/panes/alert/ui.js +58 -23
  185. data/lib/frameworks/sproutcore/frameworks/desktop/tests/panes/panel/methods.js +20 -1
  186. data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/checkbox/methods.js +121 -103
  187. data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/date_field/methods.js +34 -7
  188. data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/static_content.js +3 -2
  189. data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/tab/methods.js +1 -3
  190. data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/tab/ui.js +20 -1
  191. data/lib/frameworks/sproutcore/frameworks/desktop/views/button.js +14 -15
  192. data/lib/frameworks/sproutcore/frameworks/desktop/views/checkbox.js +43 -16
  193. data/lib/frameworks/sproutcore/frameworks/desktop/views/collection.js +717 -700
  194. data/lib/frameworks/sproutcore/frameworks/desktop/views/list_item.js +2 -2
  195. data/lib/frameworks/sproutcore/frameworks/desktop/views/master_detail.js +11 -1
  196. data/lib/frameworks/sproutcore/frameworks/desktop/views/menu_item.js +16 -6
  197. data/lib/frameworks/sproutcore/frameworks/desktop/views/popup_button.js +4 -7
  198. data/lib/frameworks/sproutcore/frameworks/desktop/views/progress.js +0 -1
  199. data/lib/frameworks/sproutcore/frameworks/desktop/views/radio.js +49 -7
  200. data/lib/frameworks/sproutcore/frameworks/desktop/views/segmented.js +9 -2
  201. data/lib/frameworks/sproutcore/frameworks/desktop/{panes → views}/select_button.js +52 -0
  202. data/lib/frameworks/sproutcore/frameworks/desktop/views/select_field.js +7 -3
  203. data/lib/frameworks/sproutcore/frameworks/desktop/views/slider.js +4 -26
  204. data/lib/frameworks/sproutcore/frameworks/desktop/views/tab.js +46 -49
  205. data/lib/frameworks/sproutcore/frameworks/desktop/views/web.js +20 -19
  206. data/lib/frameworks/sproutcore/frameworks/experimental/Buildfile +2 -0
  207. data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/designer/designers/view_designer.js +249 -249
  208. data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/forms/mixins/edit_mode.js +13 -5
  209. data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/forms/mixins/emptiness.js +53 -37
  210. data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/forms/render_delegates/form.js +2 -1
  211. data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/forms/render_delegates/form_row.js +3 -11
  212. data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/forms/tests/mixins/edit_mode.js +53 -0
  213. data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/forms/tests/mixins/emptiness.js +114 -0
  214. data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/forms/tests/views/form.js +174 -6
  215. data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/forms/tests/views/form_row.js +86 -6
  216. data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/forms/views/form.js +98 -126
  217. data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/forms/views/form_row.js +96 -97
  218. data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/polymorphism/README.md +2 -1
  219. data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/polymorphism/models/record.js +20 -36
  220. data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/select_view/ext/menu.js +121 -0
  221. data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/select_view/ext/menu_item.js +90 -0
  222. data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/select_view/mixins/select_view_menu.js +139 -0
  223. data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/select_view/render_delegates/select_button.js +14 -0
  224. data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/select_view/tests/ext/menu_resizing.js +25 -0
  225. data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/select_view/tests/mixins/select_view_menu/bindings.js +43 -0
  226. data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/select_view/tests/mixins/select_view_menu/check_selected.js +32 -0
  227. data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/select_view/tests/views/popup_button/menu_setup.js +40 -0
  228. data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/select_view/tests/views/popup_button/show_menu.js +45 -0
  229. data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/select_view/tests/views/select/menu_width.js +49 -0
  230. data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/select_view/tests/views/select/selected_item.js +191 -0
  231. data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/select_view/views/popup_button.js +264 -0
  232. data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/select_view/views/select.js +450 -0
  233. data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/split_view/mixins/split_child.js +14 -6
  234. data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/split_view/mixins/split_thumb.js +1 -1
  235. data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/split_view/render_delegates/split.js +1 -1
  236. data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/split_view/render_delegates/split_divider.js +1 -1
  237. data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/split_view/views/split.js +9 -0
  238. data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/split_view/views/thumb.js +3 -2
  239. data/lib/frameworks/sproutcore/frameworks/foundation/core.js +2 -2
  240. data/lib/frameworks/sproutcore/frameworks/foundation/mixins/auto_resize.js +16 -19
  241. data/lib/frameworks/sproutcore/frameworks/foundation/mixins/button.js +4 -7
  242. data/lib/frameworks/sproutcore/frameworks/foundation/mixins/content_value_support.js +1 -1
  243. data/lib/frameworks/sproutcore/frameworks/foundation/mixins/flowed_layout.js +85 -16
  244. data/lib/frameworks/sproutcore/frameworks/foundation/mixins/inline_editable.js +1 -1
  245. data/lib/frameworks/sproutcore/frameworks/foundation/mixins/inline_editor.js +1 -1
  246. data/lib/frameworks/sproutcore/frameworks/foundation/mixins/inline_editor_delegate.js +1 -1
  247. data/lib/frameworks/sproutcore/frameworks/foundation/mixins/inner_frame.js +1 -1
  248. data/lib/frameworks/sproutcore/frameworks/foundation/render_delegates/canvas_image.js +4 -2
  249. data/lib/frameworks/sproutcore/frameworks/foundation/render_delegates/helpers/sizing.js +2 -0
  250. data/lib/frameworks/sproutcore/frameworks/foundation/render_delegates/image.js +1 -1
  251. data/lib/frameworks/sproutcore/frameworks/foundation/render_delegates/label.js +1 -1
  252. data/lib/frameworks/sproutcore/frameworks/foundation/render_delegates/render_delegate.js +13 -13
  253. data/lib/frameworks/sproutcore/frameworks/foundation/{english.lproj → resources}/benchmark.css +0 -0
  254. data/lib/frameworks/sproutcore/frameworks/foundation/{english.lproj → resources}/blank.gif +0 -0
  255. data/lib/frameworks/sproutcore/frameworks/foundation/{english.lproj → resources}/bootstrap.rhtml +0 -0
  256. data/lib/frameworks/sproutcore/frameworks/foundation/resources/button_view.css +36 -0
  257. data/lib/frameworks/sproutcore/frameworks/foundation/{english.lproj → resources}/checkbox_view.css +0 -0
  258. data/lib/frameworks/sproutcore/frameworks/foundation/{english.lproj → resources}/debug/control-test-pane.css +0 -0
  259. data/lib/frameworks/sproutcore/frameworks/foundation/resources/images/favicon.ico +0 -0
  260. data/lib/frameworks/sproutcore/frameworks/foundation/{english.lproj → resources}/images/sproutcore-logo.png +0 -0
  261. data/lib/frameworks/sproutcore/frameworks/foundation/{english.lproj → resources}/images/sproutcore-startup-landscape.jpg +0 -0
  262. data/lib/frameworks/sproutcore/frameworks/foundation/{english.lproj → resources}/images/sproutcore-startup-landscape.png +0 -0
  263. data/lib/frameworks/sproutcore/frameworks/foundation/{english.lproj → resources}/images/sproutcore-startup-portrait.jpg +0 -0
  264. data/lib/frameworks/sproutcore/frameworks/foundation/{english.lproj → resources}/images/sproutcore-startup-portrait.png +0 -0
  265. data/lib/frameworks/sproutcore/frameworks/foundation/{english.lproj → resources}/images/sproutcore-startup.png +0 -0
  266. data/lib/frameworks/sproutcore/frameworks/foundation/{english.lproj → resources}/images/sproutcore.png +0 -0
  267. data/lib/frameworks/sproutcore/frameworks/foundation/{english.lproj → resources}/inline_editor.css +0 -0
  268. data/lib/frameworks/sproutcore/frameworks/foundation/resources/label.css +47 -0
  269. data/lib/frameworks/sproutcore/frameworks/foundation/{english.lproj → resources}/radio_view.css +0 -0
  270. data/lib/frameworks/sproutcore/frameworks/foundation/{english.lproj → resources}/static_layout.css +1 -1
  271. data/lib/frameworks/sproutcore/frameworks/foundation/resources/text_field.css +125 -0
  272. data/lib/frameworks/sproutcore/frameworks/foundation/system/chance.js +5 -1
  273. data/lib/frameworks/sproutcore/frameworks/foundation/system/exception_handler.js +4 -2
  274. data/lib/frameworks/sproutcore/frameworks/foundation/system/math.js +2 -1
  275. data/lib/frameworks/sproutcore/frameworks/foundation/system/module.js +13 -0
  276. data/lib/frameworks/sproutcore/frameworks/foundation/system/string.js +0 -43
  277. data/lib/frameworks/sproutcore/frameworks/foundation/system/utils/string_measurement.js +11 -11
  278. data/lib/frameworks/sproutcore/frameworks/foundation/tests/mixins/flowed_layout/tests.js +912 -0
  279. data/lib/frameworks/sproutcore/frameworks/foundation/tests/views/container/ui.js +23 -0
  280. data/lib/frameworks/sproutcore/frameworks/foundation/tests/views/text_field/methods.js +36 -7
  281. data/lib/frameworks/sproutcore/frameworks/foundation/tests/views/text_field/ui.js +58 -4
  282. data/lib/frameworks/sproutcore/frameworks/foundation/validators/date.js +4 -4
  283. data/lib/frameworks/sproutcore/frameworks/foundation/validators/validator.js +1 -3
  284. data/lib/frameworks/sproutcore/frameworks/foundation/views/container.js +17 -6
  285. data/lib/frameworks/sproutcore/frameworks/foundation/views/field.js +0 -15
  286. data/lib/frameworks/sproutcore/frameworks/foundation/views/label.js +3 -3
  287. data/lib/frameworks/sproutcore/frameworks/foundation/views/text_field.js +30 -19
  288. data/lib/frameworks/sproutcore/frameworks/handlebars/handlebars.js +1 -1
  289. data/lib/frameworks/sproutcore/frameworks/jquery/jquery-buffered.js +2 -76
  290. data/lib/frameworks/sproutcore/frameworks/jquery/jquery.js +3348 -1591
  291. data/lib/frameworks/sproutcore/frameworks/routing/system/routes.js +6 -3
  292. data/lib/frameworks/sproutcore/frameworks/routing/tests/system/routes.js +11 -0
  293. data/lib/frameworks/sproutcore/frameworks/runtime/core.js +38 -12
  294. data/lib/frameworks/sproutcore/frameworks/runtime/debug/test_suites/array/flatten.js +24 -0
  295. data/lib/frameworks/sproutcore/frameworks/runtime/ext/array.js +2 -1
  296. data/lib/frameworks/sproutcore/frameworks/runtime/ext/function.js +5 -5
  297. data/lib/frameworks/sproutcore/frameworks/runtime/mixins/array.js +21 -2
  298. data/lib/frameworks/sproutcore/frameworks/runtime/mixins/copyable.js +3 -2
  299. data/lib/frameworks/sproutcore/frameworks/runtime/mixins/freezable.js +1 -1
  300. data/lib/frameworks/sproutcore/frameworks/runtime/mixins/observable.js +1 -1
  301. data/lib/frameworks/sproutcore/frameworks/runtime/private/property_chain.js +2 -2
  302. data/lib/frameworks/sproutcore/frameworks/runtime/system/binding.js +14 -14
  303. data/lib/frameworks/sproutcore/frameworks/runtime/system/error.js +4 -1
  304. data/lib/frameworks/sproutcore/frameworks/runtime/system/index_set.js +0 -3
  305. data/lib/frameworks/sproutcore/frameworks/runtime/system/logger.js +4 -4
  306. data/lib/frameworks/sproutcore/frameworks/runtime/system/object.js +4 -4
  307. data/lib/frameworks/sproutcore/frameworks/runtime/system/range_observer.js +1 -1
  308. data/lib/frameworks/sproutcore/frameworks/runtime/system/run_loop.js +3 -3
  309. data/lib/frameworks/sproutcore/frameworks/runtime/system/set.js +15 -16
  310. data/lib/frameworks/sproutcore/frameworks/runtime/tests/core/itemType.js +6 -2
  311. data/lib/frameworks/sproutcore/frameworks/runtime/tests/core/objectForPropertyPath.js +10 -5
  312. data/lib/frameworks/sproutcore/frameworks/runtime/tests/core/requiredObjectForPropertyPath.js +29 -0
  313. data/lib/frameworks/sproutcore/frameworks/runtime/tests/private/observer_queue.js +98 -0
  314. data/lib/frameworks/sproutcore/frameworks/runtime/tests/system/object/enhance.js +30 -0
  315. data/lib/frameworks/sproutcore/frameworks/runtime/tests/system/range_observer/create.js +17 -0
  316. data/lib/frameworks/sproutcore/frameworks/statechart/debug/monitor.js +4 -73
  317. data/lib/frameworks/sproutcore/frameworks/statechart/debug/sequence_matcher.js +189 -0
  318. data/lib/frameworks/sproutcore/frameworks/statechart/ext/function.js +122 -0
  319. data/lib/frameworks/sproutcore/frameworks/statechart/system/async.js +88 -0
  320. data/lib/frameworks/sproutcore/frameworks/statechart/system/empty_state.js +34 -0
  321. data/lib/frameworks/sproutcore/frameworks/statechart/system/history_state.js +97 -0
  322. data/lib/frameworks/sproutcore/frameworks/statechart/system/state.js +16 -191
  323. data/lib/frameworks/sproutcore/frameworks/statechart/system/statechart.js +17 -79
  324. data/lib/frameworks/sproutcore/frameworks/statechart/tests/debug/sequence_matcher.js +464 -0
  325. data/lib/frameworks/sproutcore/frameworks/statechart/tests/event_handling/basic/with_concurrent_states.js +31 -11
  326. data/lib/frameworks/sproutcore/frameworks/statechart/tests/state_transitioning/async/with_concurrent_states.js +6 -4
  327. data/lib/frameworks/sproutcore/frameworks/statechart/tests/state_transitioning/standard/with_concurrent_states/advanced.js +40 -6
  328. data/lib/frameworks/sproutcore/frameworks/statechart/tests/state_transitioning/standard/with_concurrent_states/basic.js +22 -2
  329. data/lib/frameworks/sproutcore/frameworks/statechart/tests/state_transitioning/standard/with_concurrent_states/intermediate.js +44 -3
  330. data/lib/frameworks/sproutcore/frameworks/testing/core.js +61 -9
  331. data/lib/frameworks/sproutcore/frameworks/testing/{english.lproj → resources}/additions.css +0 -0
  332. data/lib/frameworks/sproutcore/frameworks/testing/{english.lproj → resources}/runner.css +10 -2
  333. data/lib/frameworks/sproutcore/frameworks/testing/{english.lproj → resources}/testsuite.css +0 -0
  334. data/lib/frameworks/sproutcore/frameworks/testing/system/runner.js +66 -27
  335. data/lib/frameworks/sproutcore/frameworks/testing/tests/spy_on.js +41 -0
  336. data/lib/frameworks/sproutcore/frameworks/testing/tests/stub_method.js +9 -0
  337. data/lib/frameworks/sproutcore/frameworks/yuireset/resources/base.css +80 -0
  338. data/lib/frameworks/sproutcore/frameworks/yuireset/resources/core.css +20 -0
  339. data/lib/frameworks/sproutcore/frameworks/yuireset/resources/fonts.css +39 -0
  340. data/lib/frameworks/sproutcore/frameworks/yuireset/resources/reset.css +126 -0
  341. data/lib/frameworks/sproutcore/frameworks/yuireset/resources/view.css +57 -0
  342. data/lib/frameworks/sproutcore/lib/index.rhtml +8 -4
  343. data/lib/frameworks/sproutcore/themes/ace/designs/psds/checkbox/ace/14px/checkbox_checked.psd +0 -0
  344. data/lib/frameworks/sproutcore/themes/ace/designs/psds/checkbox/ace/14px/checkbox_checked_active.psd +0 -0
  345. data/lib/frameworks/sproutcore/themes/ace/designs/psds/checkbox/ace/14px/checkbox_mixed.psd +0 -0
  346. data/lib/frameworks/sproutcore/themes/ace/designs/psds/checkbox/ace/14px/checkbox_mixed_active.psd +0 -0
  347. data/lib/frameworks/sproutcore/themes/ace/designs/psds/checkbox/ace/14px/checkbox_unchecked.psd +0 -0
  348. data/lib/frameworks/sproutcore/themes/ace/designs/psds/checkbox/ace/14px/checkbox_unchecked_active.psd +0 -0
  349. data/lib/frameworks/sproutcore/themes/ace/designs/psds/checkbox/ace/16px/checkbox_checked.psd +0 -0
  350. data/lib/frameworks/sproutcore/themes/ace/designs/psds/checkbox/ace/16px/checkbox_checked_active.psd +0 -0
  351. data/lib/frameworks/sproutcore/themes/ace/designs/psds/checkbox/ace/16px/checkbox_mixed.psd +0 -0
  352. data/lib/frameworks/sproutcore/themes/ace/designs/psds/checkbox/ace/16px/checkbox_mixed_active.psd +0 -0
  353. data/lib/frameworks/sproutcore/themes/ace/designs/psds/checkbox/ace/16px/checkbox_unchecked.psd +0 -0
  354. data/lib/frameworks/sproutcore/themes/ace/designs/psds/checkbox/ace/16px/checkbox_unchecked_active.psd +0 -0
  355. data/lib/frameworks/sproutcore/themes/ace/designs/psds/menu/menu_item.psd +0 -0
  356. data/lib/frameworks/sproutcore/themes/ace/resources/checkbox/ace/14px/checkbox_checked.png +0 -0
  357. data/lib/frameworks/sproutcore/themes/ace/resources/checkbox/ace/14px/checkbox_checked_active.png +0 -0
  358. data/lib/frameworks/sproutcore/themes/ace/resources/checkbox/ace/14px/checkbox_mixed.png +0 -0
  359. data/lib/frameworks/sproutcore/themes/ace/resources/checkbox/ace/14px/checkbox_mixed_active.png +0 -0
  360. data/lib/frameworks/sproutcore/themes/ace/resources/checkbox/ace/14px/checkbox_unchecked.png +0 -0
  361. data/lib/frameworks/sproutcore/themes/ace/resources/checkbox/ace/14px/checkbox_unchecked_active.png +0 -0
  362. data/lib/frameworks/sproutcore/themes/ace/resources/checkbox/ace/16px/checkbox_checked.png +0 -0
  363. data/lib/frameworks/sproutcore/themes/ace/resources/checkbox/ace/16px/checkbox_checked_active.png +0 -0
  364. data/lib/frameworks/sproutcore/themes/ace/resources/checkbox/ace/16px/checkbox_mixed.png +0 -0
  365. data/lib/frameworks/sproutcore/themes/ace/resources/checkbox/ace/16px/checkbox_mixed_active.png +0 -0
  366. data/lib/frameworks/sproutcore/themes/ace/resources/checkbox/ace/16px/checkbox_unchecked.png +0 -0
  367. data/lib/frameworks/sproutcore/themes/ace/resources/checkbox/ace/16px/checkbox_unchecked_active.png +0 -0
  368. data/lib/frameworks/sproutcore/themes/ace/resources/collection/normal/list.css +13 -4
  369. data/lib/frameworks/sproutcore/themes/ace/resources/collection/normal/list_item.css +16 -14
  370. data/lib/frameworks/sproutcore/themes/ace/resources/form/form.css +9 -0
  371. data/lib/frameworks/sproutcore/themes/ace/resources/menu/menu.css +3 -1
  372. data/lib/frameworks/sproutcore/themes/ace/resources/menu/menu_item.png +0 -0
  373. data/lib/frameworks/sproutcore/themes/ace/resources/picker/popover/picker.js +1 -1
  374. data/lib/frameworks/sproutcore/themes/ace/resources/picker/popover/workspace.js +1 -1
  375. data/lib/frameworks/sproutcore/themes/ace/resources/split/split.css +1 -1
  376. data/lib/frameworks/sproutcore/themes/legacy_theme/render_delegates/button.js +1 -1
  377. data/lib/frameworks/sproutcore/themes/legacy_theme/render_delegates/panel.js +1 -1
  378. data/lib/frameworks/sproutcore/themes/legacy_theme/render_delegates/progress.js +2 -0
  379. data/lib/frameworks/sproutcore/themes/legacy_theme/render_delegates/slider.js +1 -1
  380. data/lib/frameworks/sproutcore/themes/legacy_theme/render_delegates/well.js +1 -1
  381. data/lib/gen/app/templates/apps/@target_name@/Buildfile +1 -4
  382. data/lib/gen/app/templates/apps/@target_name@/core.js +1 -4
  383. data/lib/gen/app/templates/apps/@target_name@/main.js +1 -4
  384. data/lib/gen/app/templates/apps/@target_name@/resources/main_page.js +1 -4
  385. data/lib/gen/app/templates/apps/@target_name@/theme.js +1 -4
  386. data/lib/gen/controller/templates/controllers/{@filename@.js → @filename@_controller.js} +1 -4
  387. data/lib/gen/controller/templates/tests/controllers/{@filename@.js → @filename@_test.js} +1 -4
  388. data/lib/gen/data-source/templates/data_sources/{@filename@.js → @filename@_data_source.js} +1 -4
  389. data/lib/gen/design/templates/resources/@filename@.js +1 -4
  390. data/lib/gen/framework/templates/frameworks/@target_name@/core.js +1 -4
  391. data/lib/gen/framework/templates/frameworks/@target_name@/english.lproj/strings.js +1 -4
  392. data/lib/gen/html_app/templates/apps/@target_name@/@target_name@.js +1 -4
  393. data/lib/gen/html_app/templates/apps/@target_name@/resources/stylesheets/@target_name@.css +2 -0
  394. data/lib/gen/html_project/templates/@filename@/Buildfile +1 -4
  395. data/lib/gen/html_project/templates/@filename@/README +1 -4
  396. data/lib/gen/language/Buildfile +1 -1
  397. data/lib/gen/language/templates/@filename@/strings.js +1 -4
  398. data/lib/gen/model/templates/fixtures/{@filename@.js → @filename@_fixtures.js} +2 -5
  399. data/lib/gen/model/templates/models/{@filename@.js → @filename@_model.js} +1 -4
  400. data/lib/gen/model/templates/tests/models/{@filename@.js → @filename@_test.js} +1 -4
  401. data/lib/gen/page/templates/pages/@target_name@/Buildfile +1 -4
  402. data/lib/gen/page/templates/pages/@target_name@/core.js +1 -4
  403. data/lib/gen/page/templates/pages/@target_name@/en.lproj/strings.js +1 -4
  404. data/lib/gen/page/templates/pages/@target_name@/resources/body.css +3 -1
  405. data/lib/gen/project/templates/@filename@/Buildfile +1 -4
  406. data/lib/gen/project/templates/@filename@/README +1 -5
  407. data/lib/gen/responder/templates/states/{@filename@.js → @filename@_state.js} +1 -4
  408. data/lib/gen/test/templates/tests/{@filename@.js → @filename@_test.js} +1 -4
  409. data/lib/gen/theme/templates/themes/@target_name@/resources/theme_styles.css +1 -5
  410. data/lib/gen/theme/templates/themes/@target_name@/theme.js +1 -4
  411. data/lib/gen/view/templates/tests/views/{@filename@.js → @filename@_test.js} +1 -4
  412. data/lib/gen/view/templates/views/{@filename@.js → @filename@_view.js} +1 -4
  413. data/lib/sproutcore.rb +5 -15
  414. data/lib/sproutcore/builders/base.rb +5 -1
  415. data/lib/sproutcore/builders/handlebars.rb +12 -1
  416. data/lib/sproutcore/builders/module.rb +2 -2
  417. data/lib/sproutcore/buildfile/string_ext.rb +0 -4
  418. data/lib/sproutcore/helpers/cssmin.rb +44 -59
  419. data/lib/sproutcore/helpers/static_helper.rb +4 -2
  420. data/lib/sproutcore/helpers/text_helper.rb +11 -13
  421. data/lib/sproutcore/models/generator.rb +22 -0
  422. data/lib/sproutcore/models/manifest.rb +4 -4
  423. data/lib/sproutcore/models/manifest_entry.rb +1 -0
  424. data/lib/sproutcore/models/target.rb +3 -107
  425. data/lib/sproutcore/rack.rb +0 -1
  426. data/lib/sproutcore/rack/builder.rb +3 -0
  427. data/lib/sproutcore/rack/dev.rb +0 -1
  428. data/lib/sproutcore/rack/proxy.rb +240 -93
  429. data/lib/sproutcore/rack/service.rb +1 -1
  430. data/lib/sproutcore/render_engines/haml.rb +2 -5
  431. data/lib/sproutcore/tools.rb +11 -11
  432. data/lib/sproutcore/tools/build.rb +2 -0
  433. data/lib/sproutcore/tools/docs.rb +2 -37
  434. data/lib/sproutcore/tools/init.rb +10 -22
  435. data/lib/sproutcore/tools/manifest.rb +21 -22
  436. data/spec/buildtasks/manifest/prepare_build_tasks/combine_spec.rb +21 -1
  437. data/spec/buildtasks/target_spec.rb +9 -0
  438. data/spec/fixtures/builder_tests/apps/handlebars_test/Buildfile +1 -0
  439. data/spec/fixtures/builder_tests/apps/handlebars_test/{template.handlebars → templates/template.handlebars} +2 -0
  440. data/{lib/doc_templates/sproutcore/allclasses.tmpl → spec/fixtures/ordered_entries/apps/template_style/a.js} +0 -0
  441. data/spec/fixtures/{real_world/frameworks/sproutcore/apps/docs/PLACEHOLDER → ordered_entries/apps/template_style/template_style.js} +0 -0
  442. data/spec/fixtures/real_world/frameworks/sproutcore/Buildfile +1 -1
  443. data/spec/lib/builders/handlebars_spec.rb +10 -4
  444. data/spec/lib/buildfile_commands/build_task_spec.rb +1 -1
  445. data/spec/lib/tools/manifest_spec.rb +11 -0
  446. data/sproutcore.gemspec +8 -7
  447. data/vendor/chance/lib/chance/instance.rb +8 -9
  448. metadata +167 -266
  449. data/lib/doc_templates/jsdoc/allclasses.tmpl +0 -17
  450. data/lib/doc_templates/jsdoc/allfiles.tmpl +0 -56
  451. data/lib/doc_templates/jsdoc/class.tmpl +0 -487
  452. data/lib/doc_templates/jsdoc/index.tmpl +0 -38
  453. data/lib/doc_templates/jsdoc/publish.js +0 -170
  454. data/lib/doc_templates/jsdoc/static/default.css +0 -162
  455. data/lib/doc_templates/jsdoc/static/header.html +0 -2
  456. data/lib/doc_templates/jsdoc/static/index.html +0 -19
  457. data/lib/doc_templates/jsdoc/symbol.tmpl +0 -35
  458. data/lib/doc_templates/sproutcore/allfiles.tmpl +0 -56
  459. data/lib/doc_templates/sproutcore/class.tmpl +0 -674
  460. data/lib/doc_templates/sproutcore/classes-json.tmpl +0 -55
  461. data/lib/doc_templates/sproutcore/index.tmpl +0 -62
  462. data/lib/doc_templates/sproutcore/publish.js +0 -346
  463. data/lib/doc_templates/sproutcore/static/default.css +0 -258
  464. data/lib/doc_templates/sproutcore/static/header.html +0 -2
  465. data/lib/doc_templates/sproutcore/static/index.html +0 -19
  466. data/lib/doc_templates/sproutcore/symbol.tmpl +0 -35
  467. data/lib/frameworks/sproutcore/frameworks/core_foundation/resources/core.css +0 -378
  468. data/lib/frameworks/sproutcore/frameworks/core_foundation/resources/view.css +0 -57
  469. data/lib/frameworks/sproutcore/frameworks/desktop/english.lproj/alert.css +0 -56
  470. data/lib/frameworks/sproutcore/frameworks/desktop/english.lproj/disclosure.css +0 -73
  471. data/lib/frameworks/sproutcore/frameworks/desktop/english.lproj/icons.css +0 -916
  472. data/lib/frameworks/sproutcore/frameworks/desktop/english.lproj/images/icons/shared.png +0 -0
  473. data/lib/frameworks/sproutcore/frameworks/desktop/english.lproj/list_item.css +0 -185
  474. data/lib/frameworks/sproutcore/frameworks/desktop/english.lproj/menu.css +0 -12
  475. data/lib/frameworks/sproutcore/frameworks/desktop/english.lproj/menu_item_view.css +0 -101
  476. data/lib/frameworks/sproutcore/frameworks/desktop/english.lproj/panel.css +0 -91
  477. data/lib/frameworks/sproutcore/frameworks/desktop/english.lproj/picker.css +0 -35
  478. data/lib/frameworks/sproutcore/frameworks/desktop/english.lproj/progress.css +0 -33
  479. data/lib/frameworks/sproutcore/frameworks/desktop/english.lproj/radio.css +0 -10
  480. data/lib/frameworks/sproutcore/frameworks/desktop/english.lproj/segmented.css +0 -132
  481. data/lib/frameworks/sproutcore/frameworks/desktop/english.lproj/separator.css +0 -19
  482. data/lib/frameworks/sproutcore/frameworks/desktop/english.lproj/slider.css +0 -69
  483. data/lib/frameworks/sproutcore/frameworks/desktop/english.lproj/strings.js +0 -14
  484. data/lib/frameworks/sproutcore/frameworks/desktop/english.lproj/well.css +0 -71
  485. data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/forms/english.lproj/default_styles.css +0 -5
  486. data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/forms/english.lproj/strings.js +0 -15
  487. data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/forms/tests/views/form_checkbox_field.js +0 -17
  488. data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/forms/tests/views/form_field.js +0 -17
  489. data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/forms/tests/views/form_label.js +0 -17
  490. data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/forms/tests/views/form_radio_field.js +0 -17
  491. data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/forms/tests/views/form_text_field.js +0 -17
  492. data/lib/frameworks/sproutcore/frameworks/foundation/english.lproj/button_view.css +0 -40
  493. data/lib/frameworks/sproutcore/frameworks/foundation/english.lproj/images/favicon.ico +0 -0
  494. data/lib/frameworks/sproutcore/frameworks/foundation/english.lproj/label.css +0 -47
  495. data/lib/frameworks/sproutcore/frameworks/foundation/english.lproj/text_field.css +0 -146
  496. data/lib/frameworks/sproutcore/frameworks/runtime/tests/private/observer_queue/isObservingSuspended.js +0 -55
  497. data/lib/frameworks/sproutcore/themes/empty_theme/tests/mini_icons.rhtml +0 -69
  498. data/lib/sproutcore/rack/docs.rb +0 -24
  499. data/vendor/jsdoc/README.txt +0 -151
  500. data/vendor/jsdoc/app/frame.js +0 -33
  501. data/vendor/jsdoc/app/frame/Chain.js +0 -102
  502. data/vendor/jsdoc/app/frame/Dumper.js +0 -144
  503. data/vendor/jsdoc/app/frame/Hash.js +0 -47
  504. data/vendor/jsdoc/app/frame/Link.js +0 -142
  505. data/vendor/jsdoc/app/frame/Namespace.js +0 -10
  506. data/vendor/jsdoc/app/frame/Opt.js +0 -134
  507. data/vendor/jsdoc/app/frame/Reflection.js +0 -26
  508. data/vendor/jsdoc/app/frame/String.js +0 -93
  509. data/vendor/jsdoc/app/frame/Testrun.js +0 -129
  510. data/vendor/jsdoc/app/handlers/FOODOC.js +0 -26
  511. data/vendor/jsdoc/app/handlers/XMLDOC.js +0 -26
  512. data/vendor/jsdoc/app/handlers/XMLDOC/DomReader.js +0 -159
  513. data/vendor/jsdoc/app/handlers/XMLDOC/XMLDoc.js +0 -16
  514. data/vendor/jsdoc/app/handlers/XMLDOC/XMLParse.js +0 -292
  515. data/vendor/jsdoc/app/lib/JSDOC.js +0 -98
  516. data/vendor/jsdoc/app/lib/JSDOC/DocComment.js +0 -200
  517. data/vendor/jsdoc/app/lib/JSDOC/DocTag.js +0 -294
  518. data/vendor/jsdoc/app/lib/JSDOC/JsDoc.js +0 -162
  519. data/vendor/jsdoc/app/lib/JSDOC/JsPlate.js +0 -100
  520. data/vendor/jsdoc/app/lib/JSDOC/Lang.js +0 -144
  521. data/vendor/jsdoc/app/lib/JSDOC/Parser.js +0 -109
  522. data/vendor/jsdoc/app/lib/JSDOC/PluginManager.js +0 -33
  523. data/vendor/jsdoc/app/lib/JSDOC/Symbol.js +0 -681
  524. data/vendor/jsdoc/app/lib/JSDOC/SymbolSet.js +0 -226
  525. data/vendor/jsdoc/app/lib/JSDOC/TextStream.js +0 -41
  526. data/vendor/jsdoc/app/lib/JSDOC/Token.js +0 -18
  527. data/vendor/jsdoc/app/lib/JSDOC/TokenReader.js +0 -332
  528. data/vendor/jsdoc/app/lib/JSDOC/TokenStream.js +0 -133
  529. data/vendor/jsdoc/app/lib/JSDOC/Util.js +0 -32
  530. data/vendor/jsdoc/app/lib/JSDOC/Walker.js +0 -453
  531. data/vendor/jsdoc/app/main.js +0 -74
  532. data/vendor/jsdoc/app/plugins/commentSrcJson.js +0 -19
  533. data/vendor/jsdoc/app/plugins/frameworkPrototype.js +0 -16
  534. data/vendor/jsdoc/app/plugins/functionCall.js +0 -10
  535. data/vendor/jsdoc/app/plugins/publishSrcHilite.js +0 -62
  536. data/vendor/jsdoc/app/plugins/sproutcoreTags.js +0 -26
  537. data/vendor/jsdoc/app/plugins/symbolLink.js +0 -9
  538. data/vendor/jsdoc/app/plugins/tagParamConfig.js +0 -31
  539. data/vendor/jsdoc/app/plugins/tagSynonyms.js +0 -43
  540. data/vendor/jsdoc/app/run.js +0 -346
  541. data/vendor/jsdoc/app/t/TestDoc.js +0 -144
  542. data/vendor/jsdoc/app/t/runner.js +0 -13
  543. data/vendor/jsdoc/app/test.js +0 -304
  544. data/vendor/jsdoc/app/test/addon.js +0 -24
  545. data/vendor/jsdoc/app/test/anon_inner.js +0 -14
  546. data/vendor/jsdoc/app/test/augments.js +0 -31
  547. data/vendor/jsdoc/app/test/augments2.js +0 -26
  548. data/vendor/jsdoc/app/test/borrows.js +0 -41
  549. data/vendor/jsdoc/app/test/borrows2.js +0 -23
  550. data/vendor/jsdoc/app/test/config.js +0 -22
  551. data/vendor/jsdoc/app/test/constructs.js +0 -18
  552. data/vendor/jsdoc/app/test/encoding.js +0 -10
  553. data/vendor/jsdoc/app/test/encoding_other.js +0 -12
  554. data/vendor/jsdoc/app/test/functions_anon.js +0 -39
  555. data/vendor/jsdoc/app/test/functions_nested.js +0 -33
  556. data/vendor/jsdoc/app/test/global.js +0 -13
  557. data/vendor/jsdoc/app/test/globals.js +0 -25
  558. data/vendor/jsdoc/app/test/ignore.js +0 -10
  559. data/vendor/jsdoc/app/test/inner.js +0 -16
  560. data/vendor/jsdoc/app/test/jsdoc_test.js +0 -477
  561. data/vendor/jsdoc/app/test/lend.js +0 -33
  562. data/vendor/jsdoc/app/test/memberof.js +0 -20
  563. data/vendor/jsdoc/app/test/memberof_constructor.js +0 -15
  564. data/vendor/jsdoc/app/test/name.js +0 -19
  565. data/vendor/jsdoc/app/test/namespace_nested.js +0 -23
  566. data/vendor/jsdoc/app/test/nocode.js +0 -13
  567. data/vendor/jsdoc/app/test/oblit_anon.js +0 -20
  568. data/vendor/jsdoc/app/test/overview.js +0 -20
  569. data/vendor/jsdoc/app/test/param_inline.js +0 -37
  570. data/vendor/jsdoc/app/test/params_optional.js +0 -8
  571. data/vendor/jsdoc/app/test/prototype.js +0 -17
  572. data/vendor/jsdoc/app/test/prototype_nested.js +0 -9
  573. data/vendor/jsdoc/app/test/prototype_oblit.js +0 -13
  574. data/vendor/jsdoc/app/test/prototype_oblit_constructor.js +0 -24
  575. data/vendor/jsdoc/app/test/public.js +0 -10
  576. data/vendor/jsdoc/app/test/shared.js +0 -42
  577. data/vendor/jsdoc/app/test/shared2.js +0 -2
  578. data/vendor/jsdoc/app/test/shortcuts.js +0 -22
  579. data/vendor/jsdoc/app/test/static_this.js +0 -13
  580. data/vendor/jsdoc/app/test/synonyms.js +0 -23
  581. data/vendor/jsdoc/app/test/tosource.js +0 -23
  582. data/vendor/jsdoc/app/test/variable_redefine.js +0 -14
  583. data/vendor/jsdoc/changes.txt +0 -47
  584. data/vendor/jsdoc/conf/sample.conf +0 -31
  585. data/vendor/jsdoc/java/build.xml +0 -36
  586. data/vendor/jsdoc/java/build_1.4.xml +0 -36
  587. data/vendor/jsdoc/java/classes/js.jar +0 -0
  588. data/vendor/jsdoc/java/src/JsDebugRun.java +0 -21
  589. data/vendor/jsdoc/java/src/JsRun.java +0 -21
  590. data/vendor/jsdoc/jsdebug.jar +0 -0
  591. data/vendor/jsdoc/jsrun.jar +0 -0
  592. data/vendor/jsdoc/t/TestDoc.js +0 -144
  593. data/vendor/jsdoc/t/runner.js +0 -13
  594. data/vendor/jsdoc/test.js +0 -304
  595. data/vendor/jsdoc/test/addon.js +0 -24
  596. data/vendor/jsdoc/test/anon_inner.js +0 -14
  597. data/vendor/jsdoc/test/augments.js +0 -31
  598. data/vendor/jsdoc/test/augments2.js +0 -26
  599. data/vendor/jsdoc/test/borrows.js +0 -41
  600. data/vendor/jsdoc/test/borrows2.js +0 -23
  601. data/vendor/jsdoc/test/config.js +0 -22
  602. data/vendor/jsdoc/test/constructs.js +0 -18
  603. data/vendor/jsdoc/test/encoding.js +0 -10
  604. data/vendor/jsdoc/test/encoding_other.js +0 -12
  605. data/vendor/jsdoc/test/functions_anon.js +0 -39
  606. data/vendor/jsdoc/test/functions_nested.js +0 -33
  607. data/vendor/jsdoc/test/global.js +0 -13
  608. data/vendor/jsdoc/test/globals.js +0 -25
  609. data/vendor/jsdoc/test/ignore.js +0 -10
  610. data/vendor/jsdoc/test/inner.js +0 -16
  611. data/vendor/jsdoc/test/jsdoc_test.js +0 -477
  612. data/vendor/jsdoc/test/lend.js +0 -33
  613. data/vendor/jsdoc/test/memberof.js +0 -20
  614. data/vendor/jsdoc/test/memberof_constructor.js +0 -15
  615. data/vendor/jsdoc/test/name.js +0 -19
  616. data/vendor/jsdoc/test/namespace_nested.js +0 -23
  617. data/vendor/jsdoc/test/nocode.js +0 -13
  618. data/vendor/jsdoc/test/oblit_anon.js +0 -20
  619. data/vendor/jsdoc/test/overview.js +0 -20
  620. data/vendor/jsdoc/test/param_inline.js +0 -37
  621. data/vendor/jsdoc/test/params_optional.js +0 -8
  622. data/vendor/jsdoc/test/prototype.js +0 -17
  623. data/vendor/jsdoc/test/prototype_nested.js +0 -9
  624. data/vendor/jsdoc/test/prototype_oblit.js +0 -13
  625. data/vendor/jsdoc/test/prototype_oblit_constructor.js +0 -24
  626. data/vendor/jsdoc/test/public.js +0 -10
  627. data/vendor/jsdoc/test/shared.js +0 -42
  628. data/vendor/jsdoc/test/shared2.js +0 -2
  629. data/vendor/jsdoc/test/shortcuts.js +0 -22
  630. data/vendor/jsdoc/test/static_this.js +0 -13
  631. data/vendor/jsdoc/test/synonyms.js +0 -23
  632. data/vendor/jsdoc/test/tosource.js +0 -23
  633. data/vendor/jsdoc/test/variable_redefine.js +0 -14
@@ -133,6 +133,27 @@ SC.RecordAttribute = SC.Object.extend(
133
133
  @default NO
134
134
  */
135
135
  aggregate: NO,
136
+
137
+
138
+ /**
139
+ Can only be used for toOne or toMany relationship attributes. If YES,
140
+ this flag will lazily create the related record that was pushed in
141
+ from the data source (via pushRetrieve) if the related record does
142
+ not exist yet.
143
+
144
+ Useful when you have a record used as a join table. Assumptions then
145
+ can be made that the record exists at all times (even if it doesn't).
146
+ For instance, if you have a contact that is a member of groups,
147
+ a group will be created automatically when a contact pushes a new
148
+ group.
149
+
150
+ Note that you will have to take care of destroying the created record
151
+ once all relationships are removed from it.
152
+
153
+ @property {Boolean}
154
+ @default NO
155
+ */
156
+ lazilyInstantiate: NO,
136
157
 
137
158
  // ..........................................................
138
159
  // HELPER PROPERTIES
@@ -149,7 +170,7 @@ SC.RecordAttribute = SC.Object.extend(
149
170
  */
150
171
  typeClass: function() {
151
172
  var ret = this.get('type');
152
- if (SC.typeOf(ret) === SC.T_STRING) ret = SC.objectForPropertyPath(ret);
173
+ if (SC.typeOf(ret) === SC.T_STRING) ret = SC.requiredObjectForPropertyPath(ret);
153
174
  return ret ;
154
175
  }.property('type').cacheable(),
155
176
 
@@ -572,6 +593,7 @@ if (SC.DateTime && !SC.RecordAttribute.transforms[SC.guidFor(SC.DateTime)]) {
572
593
  */
573
594
  to: function(str, attr) {
574
595
  if (SC.none(str) || SC.instanceOf(str, SC.DateTime)) return str;
596
+ if (SC.none(str) || SC.instanceOf(str, Date)) return SC.DateTime.create(str.getTime());
575
597
  var format = attr.get('format');
576
598
  return SC.DateTime.parse(str, format ? format : SC.DateTime.recordFormat);
577
599
  },
@@ -104,7 +104,6 @@ SC.ChildArray = SC.Object.extend(SC.Enumerable, SC.Array,
104
104
  ret = hash[pname] = [];
105
105
  }
106
106
 
107
- if (ret !== this._prevChildren) this.recordPropertyDidChange();
108
107
  return ret ;
109
108
  }.property(),
110
109
 
@@ -169,9 +168,15 @@ SC.ChildArray = SC.Object.extend(SC.Enumerable, SC.Array,
169
168
 
170
169
  pname = this.get('propertyName'),
171
170
  cr, recordType;
171
+
172
172
  newRecs = this._processRecordsToHashes(recs);
173
173
  children.replace(idx, amt, newRecs);
174
174
  // notify that the record did change...
175
+ if (newRecs !== this._prevChildren){
176
+ this._performRecordPropertyChange(null, false);
177
+ this.arrayContentWillChange(idx, amt, len);
178
+ this._childrenContentDidChange(idx, amt, len);
179
+ }
175
180
  record.recordDidChange(pname);
176
181
 
177
182
  return this;
@@ -218,10 +223,25 @@ SC.ChildArray = SC.Object.extend(SC.Enumerable, SC.Array,
218
223
  @returns {SC.ChildArray} itself.
219
224
  */
220
225
  recordPropertyDidChange: function(keys) {
226
+ this._performRecordPropertyChange(keys, true);
227
+ return this;
228
+ },
229
+
230
+ /** @private
231
+ Invoked when the object is changed from the parent or an outside source
232
+
233
+ will cause the entire array to reset
234
+
235
+ @param {SC.Array} keys optional
236
+ @param {Boolean} doReset optional
237
+ @returns {SC.ChildArray} itself.
238
+ */
239
+ _performRecordPropertyChange: function(keys, doReset){
221
240
  if (keys && !keys.contains(this.get('propertyName'))) return this;
222
241
 
223
242
  var children = this.get('readOnlyChildren'), oldLen = 0, newLen = 0;
224
243
  var prev = this._prevChildren, f = this._childrenContentDidChange;
244
+ doReset = SC.none(doReset) ? true : doReset;
225
245
 
226
246
  if (children === prev) return this; // nothing to do
227
247
 
@@ -244,11 +264,12 @@ SC.ChildArray = SC.Object.extend(SC.Enumerable, SC.Array,
244
264
 
245
265
  newLen = children.get('length');
246
266
  }
247
-
248
-
249
- this.arrayContentWillChange(0, oldLen, newLen);
250
267
  this._prevChildren = children;
251
- this._childrenContentDidChange(0, oldLen, newLen);
268
+
269
+ if (doReset){
270
+ this.arrayContentWillChange(0, oldLen, newLen);
271
+ this._childrenContentDidChange(0, oldLen, newLen);
272
+ }
252
273
 
253
274
  return this;
254
275
  },
@@ -318,7 +318,7 @@ SC.NestedStore = SC.Store.extend(
318
318
  if (!editables) editables = this.editables = [];
319
319
  editables[storeKey] = 1 ; // mark as editable
320
320
 
321
- } else this.dataHashes[storeKey] = this.dataHashes[storeKey];
321
+ } else this.dataHashes[storeKey] = pstore.dataHashes[storeKey];
322
322
 
323
323
  // also copy the status + revision
324
324
  this.statuses[storeKey] = this.statuses[storeKey];
@@ -14,33 +14,33 @@ sc_require('models/record');
14
14
  object. When you access the items of a `RecordArray`, it will automatically
15
15
  convert the `storeKeys` into actual `SC.Record` objects that the rest of
16
16
  your application can work with.
17
-
17
+
18
18
  Normally you do not create `RecordArray`s yourself. Instead, a
19
19
  `RecordArray` is returned when you call `SC.Store.findAll()`, already
20
20
  properly configured. You can usually just work with the `RecordArray`
21
21
  instance just like any other array.
22
-
22
+
23
23
  The information below about `RecordArray` internals is only intended for
24
24
  those who need to override this class for some reason to do something
25
25
  special.
26
-
26
+
27
27
  Internal Notes
28
28
  ---
29
-
29
+
30
30
  Normally the `RecordArray` behavior is very simple. Any array-like
31
31
  operations will be translated into similar calls onto the underlying array
32
- of `storeKeys`. The underlying array can be a real array or it may be a
32
+ of `storeKeys`. The underlying array can be a real array or it may be a
33
33
  `SparseArray`, which is how you implement incremental loading.
34
-
35
- If the `RecordArray` is created with an `SC.Query` object as well (and it
36
- almost always will have a `Query` object), then the `RecordArray` will also
37
- consult the query for various delegate operations such as determining if
34
+
35
+ If the `RecordArray` is created with an `SC.Query` object as well (and it
36
+ almost always will have a `Query` object), then the `RecordArray` will also
37
+ consult the query for various delegate operations such as determining if
38
38
  the record array should update automatically whenever records in the store
39
39
  changes. It will also ask the `Query` to refresh the `storeKeys` whenever
40
40
  records change in the store.
41
-
42
- If the `SC.Query` object has complex matching rules, it might be
43
- computationally heavy to match a large dataset to a query. To avoid the
41
+
42
+ If the `SC.Query` object has complex matching rules, it might be
43
+ computationally heavy to match a large dataset to a query. To avoid the
44
44
  browser from ever showing a slow script timer in this scenario, the query
45
45
  matching is by default paced at 100ms. If query matching takes longer than
46
46
  100ms, it will chunk the work with setTimeout to avoid too much computation
@@ -57,12 +57,12 @@ SC.RecordArray = SC.Object.extend(SC.Enumerable, SC.Array,
57
57
  /** @scope SC.RecordArray.prototype */ {
58
58
 
59
59
  /**
60
- The store that owns this record array. All record arrays must have a
61
- store to function properly.
62
-
60
+ The store that owns this record array. All record arrays must have a
61
+ store to function properly.
62
+
63
63
  NOTE: You **MUST** set this property on the `RecordArray` when creating
64
64
  it or else it will fail.
65
-
65
+
66
66
  @type SC.Store
67
67
  */
68
68
  store: null,
@@ -74,14 +74,14 @@ SC.RecordArray = SC.Object.extend(SC.Enumerable, SC.Array,
74
74
 
75
75
  NOTE: You **MUST** set this property on the `RecordArray` when creating
76
76
  it or else it will fail.
77
-
77
+
78
78
  @type SC.Query
79
79
  */
80
80
  query: null,
81
81
 
82
82
  /**
83
83
  The array of `storeKeys` as retrieved from the owner store.
84
-
84
+
85
85
  @type SC.Array
86
86
  */
87
87
  storeKeys: null,
@@ -95,14 +95,15 @@ SC.RecordArray = SC.Object.extend(SC.Enumerable, SC.Array,
95
95
  status: SC.Record.EMPTY,
96
96
 
97
97
  /**
98
- The current editabile state based on the query.
98
+ The current editable state based on the query. If this record array is not
99
+ backed by an SC.Query, it is assumed to be editable.
99
100
 
100
101
  @property
101
102
  @type Boolean
102
103
  */
103
104
  isEditable: function() {
104
105
  var query = this.get('query');
105
- return query ? query.get('isEditable') : NO;
106
+ return query ? query.get('isEditable') : YES;
106
107
  }.property('query').cacheable(),
107
108
 
108
109
  // ..........................................................
@@ -119,6 +120,14 @@ SC.RecordArray = SC.Object.extend(SC.Enumerable, SC.Array,
119
120
  return storeKeys ? storeKeys.get('length') : 0;
120
121
  }.property('storeKeys').cacheable(),
121
122
 
123
+ /** @private
124
+ A cache of materialized records. The first time an instance of SC.Record is
125
+ created for a store key at a given index, it will be saved to this array.
126
+
127
+ Whenever the `storeKeys` property is reset, this cache is also reset.
128
+
129
+ @type Array
130
+ */
122
131
  _scra_records: null,
123
132
 
124
133
  /** @private
@@ -181,13 +190,19 @@ SC.RecordArray = SC.Object.extend(SC.Enumerable, SC.Array,
181
190
  },
182
191
 
183
192
  /** @private
184
- Pass through to the underlying array. The passed in objects must be
185
- records, which can be converted to `storeKeys`.
186
-
193
+ Replaces a range of records starting at a given index with the replacement
194
+ records provided. The objects to be inserted must be instances of SC.Record
195
+ and must have a store key assigned to them.
196
+
197
+ Note that most SC.RecordArrays are *not* editable via `replace()`, since they
198
+ are generated by a rule-based SC.Query. You can check the `isEditable` property
199
+ before attempting to modify a record array.
200
+
187
201
  @param {Number} idx start index
188
- @param {Number} amt end index
189
- @param {SC.RecordArray} recs to replace with records
190
- @return {SC.RecordArray} 'this' after replace
202
+ @param {Number} amt count of records to remove
203
+ @param {SC.RecordArray} recs the records that should replace the removed records
204
+
205
+ @returns {SC.RecordArray} receiver, after mutation has occurred
191
206
  */
192
207
  replace: function(idx, amt, recs) {
193
208
 
@@ -197,13 +212,9 @@ SC.RecordArray = SC.Object.extend(SC.Enumerable, SC.Array,
197
212
  len = recs ? (recs.get ? recs.get('length') : recs.length) : 0,
198
213
  i, keys;
199
214
 
200
- if (!storeKeys) throw "storeKeys required";
215
+ if (!storeKeys) throw "Unable to edit an SC.RecordArray that does not have its storeKeys property set.";
201
216
 
202
- var query = this.get('query');
203
- if (query && !query.get('isEditable')) throw SC.RecordArray.NOT_EDITABLE;
204
-
205
- // you can't modify an array whose store keys are autogenerated from a
206
- // query.
217
+ if (!this.get('isEditable')) throw SC.RecordArray.NOT_EDITABLE;
207
218
 
208
219
  // map to store keys
209
220
  keys = [] ;
@@ -266,10 +277,10 @@ SC.RecordArray = SC.Object.extend(SC.Enumerable, SC.Array,
266
277
  return storeKeys ? storeKeys.lastIndexOf(storeKey, startAt) : -1;
267
278
  },
268
279
 
269
- /**
270
- Adds the specified record to the record array if it is not already part
280
+ /**
281
+ Adds the specified record to the record array if it is not already part
271
282
  of the array. Provided for compatibilty with `SC.Set`.
272
-
283
+
273
284
  @param {SC.Record} record
274
285
  @returns {SC.RecordArray} receiver
275
286
  */
@@ -282,7 +293,7 @@ SC.RecordArray = SC.Object.extend(SC.Enumerable, SC.Array,
282
293
  /**
283
294
  Removes the specified record from the array if it is not already a part
284
295
  of the array. Provided for compatibility with `SC.Set`.
285
-
296
+
286
297
  @param {SC.Record} record
287
298
  @returns {SC.RecordArray} receiver
288
299
  */
@@ -305,11 +316,11 @@ SC.RecordArray = SC.Object.extend(SC.Enumerable, SC.Array,
305
316
 
306
317
  @returns {SC.RecordArray}
307
318
  */
308
- find: function(query, target) {
319
+ find: function(original, query, target) {
309
320
  if (query && query.isQuery) {
310
321
  return this.get('store').find(query.queryWithScope(this));
311
- } else return sc_super();
312
- },
322
+ } else return original.apply(this, SC.$A(arguments).slice(1));
323
+ }.enhance(),
313
324
 
314
325
  /**
315
326
  Call whenever you want to refresh the results of this query. This will
@@ -324,11 +335,11 @@ SC.RecordArray = SC.Object.extend(SC.Enumerable, SC.Array,
324
335
 
325
336
  /**
326
337
  Will recompute the results based on the `SC.Query` attached to the record
327
- array. Useful if your query is based on computed properties that might
338
+ array. Useful if your query is based on computed properties that might
328
339
  have changed. Use `refresh()` instead of you want to trigger a fetch on
329
340
  your data source since this will purely look at records already loaded
330
341
  into the store.
331
-
342
+
332
343
  @returns {SC.RecordArray} receiver
333
344
  */
334
345
  reload: function() {
@@ -352,14 +363,14 @@ SC.RecordArray = SC.Object.extend(SC.Enumerable, SC.Array,
352
363
 
353
364
  // ..........................................................
354
365
  // STORE CALLBACKS
355
- //
356
-
366
+ //
367
+
357
368
  // **NOTE**: `storeWillFetchQuery()`, `storeDidFetchQuery()`,
358
369
  // `storeDidCancelQuery()`, and `storeDidErrorQuery()` are tested implicitly
359
370
  // through the related methods in `SC.Store`. We're doing it this way
360
371
  // because eventually this particular implementation is likely to change;
361
372
  // moving some or all of this code directly into the store. -CAJ
362
-
373
+
363
374
  /** @private
364
375
  Called whenever the store initiates a refresh of the query. Sets the
365
376
  status of the record array to the appropriate status.
@@ -416,10 +427,13 @@ SC.RecordArray = SC.Object.extend(SC.Enumerable, SC.Array,
416
427
  },
417
428
 
418
429
  /** @private
419
- Called by the store whenever it changes the state of certain store keys.
420
- If the receiver cares about these changes, it will mark itself as dirty.
421
- The next time you try to access the record array it will update any
422
- pending changes.
430
+ Called by the store whenever it changes the state of certain store keys. If
431
+ the receiver cares about these changes, it will mark itself as dirty and add
432
+ the changed store keys to the _scq_changedStoreKeys index set.
433
+
434
+ The next time you try to access the record array, it will call `flush()` and
435
+ add the changed keys to the underlying `storeKeys` array if the new records
436
+ match the conditions of the record array's query.
423
437
 
424
438
  @param {SC.Array} storeKeys the effected store keys
425
439
  @param {SC.Set} recordTypes the record types for the storeKeys.
@@ -437,11 +451,8 @@ SC.RecordArray = SC.Object.extend(SC.Enumerable, SC.Array,
437
451
  changed.addEach(storeKeys);
438
452
 
439
453
  this.set('needsFlush', YES);
440
-
441
454
  if (this.get('storeKeys')) {
442
455
  this.flush();
443
- } else {
444
- this.arrayContentDidChange();
445
456
  }
446
457
 
447
458
  return this;
@@ -453,8 +464,8 @@ SC.RecordArray = SC.Object.extend(SC.Enumerable, SC.Array,
453
464
  you access the RecordArray to make sure it is up to date, but you can
454
465
  call it yourself as well if you need to force the record array to fully
455
466
  update immediately.
456
-
457
- Currently this method only has an effect if the query location is
467
+
468
+ Currently this method only has an effect if the query location is
458
469
  `SC.Query.LOCAL`. You can call this method on any `RecordArray` however,
459
470
  without an error.
460
471
 
@@ -604,7 +615,7 @@ SC.RecordArray = SC.Object.extend(SC.Enumerable, SC.Array,
604
615
  },
605
616
 
606
617
  /**
607
- Set to `YES` when the query is dirty and needs to update its storeKeys
618
+ Set to `YES` when the query is dirty and needs to update its storeKeys
608
619
  before returning any results. `RecordArray`s always start dirty and become
609
620
  clean the first time you try to access their contents.
610
621
 
@@ -619,7 +630,7 @@ SC.RecordArray = SC.Object.extend(SC.Enumerable, SC.Array,
619
630
  /**
620
631
  Returns `YES` whenever the status is `SC.Record.ERROR`. This will allow
621
632
  you to put the UI into an error state.
622
-
633
+
623
634
  @property
624
635
  @type Boolean
625
636
  */
@@ -630,7 +641,7 @@ SC.RecordArray = SC.Object.extend(SC.Enumerable, SC.Array,
630
641
  /**
631
642
  Returns the receiver if the record array is in an error state. Returns
632
643
  `null` otherwise.
633
-
644
+
634
645
  @property
635
646
  @type SC.Record
636
647
  */
@@ -642,7 +653,7 @@ SC.RecordArray = SC.Object.extend(SC.Enumerable, SC.Array,
642
653
  Returns the current error object only if the record array is in an error
643
654
  state. If no explicit error object has been set, returns
644
655
  `SC.Record.GENERIC_ERROR.`
645
-
656
+
646
657
  @property
647
658
  @type SC.Error
648
659
  */
@@ -655,7 +666,7 @@ SC.RecordArray = SC.Object.extend(SC.Enumerable, SC.Array,
655
666
 
656
667
  // ..........................................................
657
668
  // INTERNAL SUPPORT
658
- //
669
+ //
659
670
 
660
671
  propertyWillChange: function(key) {
661
672
  if (key === 'storeKeys') {
@@ -11,14 +11,14 @@ sc_require('models/record');
11
11
  @class
12
12
 
13
13
 
14
- The Store is where you can find all of your dataHashes. Stores can be
15
- chained for editing purposes and committed back one chain level at a time
14
+ The Store is where you can find all of your dataHashes. Stores can be
15
+ chained for editing purposes and committed back one chain level at a time
16
16
  all the way back to a persistent data source.
17
-
17
+
18
18
  Every application you create should generally have its own store objects.
19
19
  Once you create the store, you will rarely need to work with the store
20
- directly except to retrieve records and collections.
21
-
20
+ directly except to retrieve records and collections.
21
+
22
22
  Internally, the store will keep track of changes to your json data hashes
23
23
  and manage syncing those changes with your data source. A data source may
24
24
  be a server, local storage, or any other persistent code.
@@ -27,19 +27,19 @@ sc_require('models/record');
27
27
  @since SproutCore 1.0
28
28
  */
29
29
  SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
30
-
30
+
31
31
  /**
32
32
  An (optional) name of the store, which can be useful during debugging,
33
33
  especially if you have multiple nested stores.
34
-
34
+
35
35
  @type String
36
36
  */
37
37
  name: null,
38
38
 
39
39
  /**
40
- An array of all the chained stores that current rely on the receiver
40
+ An array of all the chained stores that current rely on the receiver
41
41
  store.
42
-
42
+
43
43
  @type Array
44
44
  */
45
45
  nestedStores: null,
@@ -48,39 +48,39 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
48
48
  The data source is the persistent storage that will provide data to the
49
49
  store and save changes. You normally will set your data source when you
50
50
  first create your store in your application.
51
-
51
+
52
52
  @type SC.DataSource
53
53
  */
54
54
  dataSource: null,
55
-
55
+
56
56
  /**
57
57
  This type of store is not nested.
58
-
58
+
59
59
  @default NO
60
60
  @type Boolean
61
61
  */
62
62
  isNested: NO,
63
-
63
+
64
64
  /**
65
65
  This type of store is not nested.
66
-
66
+
67
67
  @default NO
68
68
  @type Boolean
69
69
  */
70
70
  commitRecordsAutomatically: NO,
71
-
71
+
72
72
  // ..........................................................
73
73
  // DATA SOURCE SUPPORT
74
- //
75
-
74
+ //
75
+
76
76
  /**
77
77
  Convenience method. Sets the current data source to the passed property.
78
78
  This will also set the store property on the dataSource to the receiver.
79
-
79
+
80
80
  If you are using this from the `core.js` method of your app, you may need to
81
81
  just pass a string naming your data source class. If this is the case,
82
82
  then your data source will be instantiated the first time it is requested.
83
-
83
+
84
84
  @param {SC.DataSource|String} dataSource the data source
85
85
  @returns {SC.Store} receiver
86
86
  */
@@ -88,48 +88,48 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
88
88
  this.set('dataSource', dataSource);
89
89
  return this ;
90
90
  },
91
-
91
+
92
92
  // lazily convert data source to real object
93
93
  _getDataSource: function() {
94
94
  var ret = this.get('dataSource');
95
95
  if (typeof ret === SC.T_STRING) {
96
- ret = SC.objectForPropertyPath(ret);
97
- if (ret && ret.isClass) ret = ret.create();
98
- if (ret) this.set('dataSource', ret);
96
+ ret = SC.requiredObjectForPropertyPath(ret);
97
+ if (ret.isClass) ret = ret.create();
98
+ this.set('dataSource', ret);
99
99
  }
100
100
  return ret;
101
101
  },
102
-
102
+
103
103
  /**
104
- Convenience method. Creates a `CascadeDataSource` with the passed
105
- data source arguments and sets the `CascadeDataSource` as the data source
104
+ Convenience method. Creates a `CascadeDataSource` with the passed
105
+ data source arguments and sets the `CascadeDataSource` as the data source
106
106
  for the receiver.
107
-
107
+
108
108
  @param {SC.DataSource...} dataSource one or more data source arguments
109
- @returns {SC.Store} reciever
109
+ @returns {SC.Store} receiver
110
110
  */
111
111
  cascade: function(dataSource) {
112
112
  var dataSources = SC.A(arguments) ;
113
113
  dataSource = SC.CascadeDataSource.create({
114
- dataSources: dataSources
114
+ dataSources: dataSources
115
115
  });
116
116
  return this.from(dataSource);
117
117
  },
118
-
118
+
119
119
  // ..........................................................
120
120
  // STORE CHAINING
121
- //
122
-
123
- /**
121
+ //
122
+
123
+ /**
124
124
  Returns a new nested store instance that can be used to buffer changes
125
- until you are ready to commit them. When you are ready to commit your
125
+ until you are ready to commit them. When you are ready to commit your
126
126
  changes, call `commitChanges()` or `destroyChanges()` and then `destroy()`
127
127
  when you are finished with the chained store altogether.
128
-
128
+
129
129
  store = MyApp.store.chain();
130
130
  .. edit edit edit
131
131
  store.commitChanges().destroy();
132
-
132
+
133
133
  @param {Hash} attrs optional attributes to set on new store
134
134
  @param {Class} newStoreClass optional the class of the newly-created nested store (defaults to SC.NestedStore)
135
135
  @returns {SC.NestedStore} new nested store chained to receiver
@@ -137,7 +137,7 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
137
137
  chain: function(attrs, newStoreClass) {
138
138
  if (!attrs) attrs = {};
139
139
  attrs.parentStore = this;
140
-
140
+
141
141
  if (newStoreClass) {
142
142
  // Ensure the passed-in class is a type of nested store.
143
143
  if (SC.typeOf(newStoreClass) !== 'class') throw new Error("%@ is not a valid class".fmt(newStoreClass));
@@ -146,24 +146,24 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
146
146
  else {
147
147
  newStoreClass = SC.NestedStore;
148
148
  }
149
-
149
+
150
150
  // Replicate parent records references
151
151
  attrs.childRecords = this.childRecords ? SC.clone(this.childRecords) : {};
152
152
  attrs.parentRecords = this.parentRecords ? SC.clone(this.parentRecords) : {};
153
-
153
+
154
154
  var ret = newStoreClass.create(attrs),
155
155
  nested = this.nestedStores;
156
-
156
+
157
157
  if (!nested) nested = this.nestedStores = [];
158
158
  nested.push(ret);
159
159
  return ret ;
160
160
  },
161
-
161
+
162
162
  /** @private
163
-
163
+
164
164
  Called by a nested store just before it is destroyed so that the parent
165
165
  can remove the store from its list of nested stores.
166
-
166
+
167
167
  @returns {SC.Store} receiver
168
168
  */
169
169
  willDestroyNestedStore: function(nestedStore) {
@@ -176,7 +176,7 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
176
176
  /**
177
177
  Used to determine if a nested store belongs directly or indirectly to the
178
178
  receiver.
179
-
179
+
180
180
  @param {SC.Store} store store instance
181
181
  @returns {Boolean} YES if belongs
182
182
  */
@@ -186,110 +186,110 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
186
186
  },
187
187
 
188
188
  // ..........................................................
189
- // SHARED DATA STRUCTURES
190
- //
191
-
189
+ // SHARED DATA STRUCTURES
190
+ //
191
+
192
192
  /** @private
193
- JSON data hashes indexed by store key.
194
-
193
+ JSON data hashes indexed by store key.
194
+
195
195
  *IMPORTANT: Property is not observable*
196
196
 
197
197
  Shared by a store and its child stores until you make edits to it.
198
-
198
+
199
199
  @type Hash
200
200
  */
201
201
  dataHashes: null,
202
202
 
203
203
  /** @private
204
204
  The current status of a data hash indexed by store key.
205
-
205
+
206
206
  *IMPORTANT: Property is not observable*
207
207
 
208
208
  Shared by a store and its child stores until you make edits to it.
209
-
209
+
210
210
  @type Hash
211
211
  */
212
212
  statuses: null,
213
-
213
+
214
214
  /** @private
215
- This array contains the revisions for the attributes indexed by the
216
- storeKey.
217
-
215
+ This array contains the revisions for the attributes indexed by the
216
+ storeKey.
217
+
218
218
  *IMPORTANT: Property is not observable*
219
-
220
- Revisions are used to keep track of when an attribute hash has been
221
- changed. A store shares the revisions data with its parent until it
219
+
220
+ Revisions are used to keep track of when an attribute hash has been
221
+ changed. A store shares the revisions data with its parent until it
222
222
  starts to make changes to it.
223
-
223
+
224
224
  @type Hash
225
225
  */
226
226
  revisions: null,
227
227
 
228
228
  /**
229
- Array indicates whether a data hash is possibly in use by an external
229
+ Array indicates whether a data hash is possibly in use by an external
230
230
  record for editing. If a data hash is editable then it may be modified
231
- at any time and therefore chained stores may need to clone the
231
+ at any time and therefore chained stores may need to clone the
232
232
  attributes before keeping a copy of them.
233
-
234
- Note that this is kept as an array because it will be stored as a dense
233
+
234
+ Note that this is kept as an array because it will be stored as a dense
235
235
  array on some browsers, making it faster.
236
-
236
+
237
237
  @type Array
238
238
  */
239
239
  editables: null,
240
-
240
+
241
241
  /**
242
242
  A set of storeKeys that need to be committed back to the data source. If
243
243
  you call `commitRecords()` without passing any other parameters, the keys
244
244
  in this set will be committed instead.
245
-
245
+
246
246
  @type SC.Set
247
247
  */
248
248
  changelog: null,
249
-
249
+
250
250
  /**
251
251
  An array of `SC.Error` objects associated with individual records in the
252
252
  store (indexed by store keys).
253
-
253
+
254
254
  Errors passed form the data source in the call to dataSourceDidError() are
255
255
  stored here.
256
-
256
+
257
257
  @type Array
258
258
  */
259
259
  recordErrors: null,
260
-
260
+
261
261
  /**
262
262
  A hash of `SC.Error` objects associated with queries (indexed by the GUID
263
263
  of the query).
264
-
264
+
265
265
  Errors passed from the data source in the call to
266
266
  `dataSourceDidErrorQuery()` are stored here.
267
-
267
+
268
268
  @type Hash
269
269
  */
270
270
  queryErrors: null,
271
-
271
+
272
272
  /**
273
273
  A hash of child Records and there immediate parents
274
274
  */
275
275
  childRecords: null,
276
-
276
+
277
277
  /**
278
278
  A hash of parent records with registered children
279
279
  */
280
280
  parentRecords: null,
281
-
281
+
282
282
  // ..........................................................
283
283
  // CORE ATTRIBUTE API
284
- //
284
+ //
285
285
  // The methods in this layer work on data hashes in the store. They do not
286
- // perform any changes that can impact records. Usually you will not need
286
+ // perform any changes that can impact records. Usually you will not need
287
287
  // to use these methods.
288
-
288
+
289
289
  /**
290
290
  Returns the current edit status of a storekey. May be one of
291
291
  `EDITABLE` or `LOCKED`. Used mostly for unit testing.
292
-
292
+
293
293
  @param {Number} storeKey the store key
294
294
  @returns {Number} edit status
295
295
  */
@@ -297,27 +297,27 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
297
297
  var editables = this.editables, locks = this.locks;
298
298
  return (editables && editables[storeKey]) ? SC.Store.EDITABLE : SC.Store.LOCKED ;
299
299
  },
300
-
301
- /**
300
+
301
+ /**
302
302
  Returns the data hash for the given `storeKey`. This will also 'lock'
303
- the hash so that further edits to the parent store will no
303
+ the hash so that further edits to the parent store will no
304
304
  longer be reflected in this store until you reset.
305
-
305
+
306
306
  @param {Number} storeKey key to retrieve
307
307
  @returns {Hash} data hash or null
308
308
  */
309
309
  readDataHash: function(storeKey) {
310
310
  return this.dataHashes[storeKey];
311
311
  },
312
-
313
- /**
312
+
313
+ /**
314
314
  Returns the data hash for the `storeKey`, cloned so that you can edit
315
315
  the contents of the attributes if you like. This will do the extra work
316
- to make sure that you only clone the attributes one time.
317
-
318
- If you use this method to modify data hash, be sure to call
316
+ to make sure that you only clone the attributes one time.
317
+
318
+ If you use this method to modify data hash, be sure to call
319
319
  `dataHashDidChange()` when you make edits to record the change.
320
-
320
+
321
321
  @param {Number} storeKey the store key to retrieve
322
322
  @returns {Hash} the attributes hash
323
323
  */
@@ -335,48 +335,48 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
335
335
  }
336
336
  return ret;
337
337
  },
338
-
338
+
339
339
  /**
340
- Reads a property from the hash - cloning it if needed so you can modify
340
+ Reads a property from the hash - cloning it if needed so you can modify
341
341
  it independently of any parent store. This method is really only well
342
- tested for use with toMany relationships. Although it is public you
342
+ tested for use with toMany relationships. Although it is public you
343
343
  generally should not call it directly.
344
-
345
- @param {Number} storeKey storeKey of data hash
344
+
345
+ @param {Number} storeKey storeKey of data hash
346
346
  @param {String} propertyName property to read
347
347
  @returns {Object} editable property value
348
348
  */
349
349
  readEditableProperty: function(storeKey, propertyName) {
350
- var hash = this.readEditableDataHash(storeKey),
350
+ var hash = this.readEditableDataHash(storeKey),
351
351
  editables = this.editables[storeKey], // get editable info...
352
352
  ret = hash[propertyName];
353
-
353
+
354
354
  // editables must be made into a hash so that we can keep track of which
355
355
  // properties have already been made editable
356
356
  if (editables === 1) editables = this.editables[storeKey] = {};
357
-
357
+
358
358
  // clone if needed
359
359
  if (!editables[propertyName]) {
360
360
  ret = hash[propertyName];
361
361
  if (ret && ret.isCopyable) ret = hash[propertyName] = ret.copy(YES);
362
362
  editables[propertyName] = YES ;
363
363
  }
364
-
364
+
365
365
  return ret ;
366
366
  },
367
-
367
+
368
368
  /**
369
369
  Replaces the data hash for the `storeKey`. This will lock the data hash
370
370
  and mark them as cloned. This will also call `dataHashDidChange()` for
371
371
  you.
372
-
373
- Note that the hash you set here must be a different object from the
372
+
373
+ Note that the hash you set here must be a different object from the
374
374
  original data hash. Once you make a change here, you must also call
375
375
  `dataHashDidChange()` to register the changes.
376
376
 
377
377
  If the data hash does not yet exist in the store, this method will add it.
378
378
  Pass the optional status to edit the status as well.
379
-
379
+
380
380
  @param {Number} storeKey the store key to write
381
381
  @param {Hash} hash the new hash
382
382
  @param {String} status the new hash status
@@ -387,53 +387,53 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
387
387
  // update dataHashes and optionally status.
388
388
  if (hash) this.dataHashes[storeKey] = hash;
389
389
  if (status) this.statuses[storeKey] = status ;
390
-
390
+
391
391
  // also note that this hash is now editable
392
392
  var editables = this.editables;
393
393
  if (!editables) editables = this.editables = [];
394
394
  editables[storeKey] = 1 ; // use number for dense array support
395
-
395
+
396
396
  var that = this;
397
397
  this._propagateToChildren(storeKey, function(storeKey){
398
398
  that.writeDataHash(storeKey, null, status);
399
399
  });
400
-
400
+
401
401
  return this ;
402
402
  },
403
403
 
404
404
  /**
405
405
  Removes the data hash from the store. This does not imply a deletion of
406
- the record. You could be simply unloading the record. Either way,
407
- removing the dataHash will be synced back to the parent store but not to
406
+ the record. You could be simply unloading the record. Either way,
407
+ removing the dataHash will be synced back to the parent store but not to
408
408
  the server.
409
-
409
+
410
410
  Note that you can optionally pass a new status to go along with this. If
411
411
  you do not pass a status, it will change the status to `SC.RECORD_EMPTY`
412
412
  (assuming you just unloaded the record). If you are deleting the record
413
413
  you may set it to `SC.Record.DESTROYED_CLEAN`.
414
-
414
+
415
415
  Be sure to also call `dataHashDidChange()` to register this change.
416
-
416
+
417
417
  @param {Number} storeKey
418
418
  @param {String} status optional new status
419
- @returns {SC.Store} reciever
419
+ @returns {SC.Store} receiver
420
420
  */
421
421
  removeDataHash: function(storeKey, status) {
422
422
  // don't use delete -- that will allow parent dataHash to come through
423
- this.dataHashes[storeKey] = null;
423
+ this.dataHashes[storeKey] = null;
424
424
  this.statuses[storeKey] = status || SC.Record.EMPTY;
425
-
425
+
426
426
  // hash is gone and therefore no longer editable
427
427
  var editables = this.editables;
428
428
  if (editables) editables[storeKey] = 0 ;
429
-
430
- return this ;
429
+
430
+ return this ;
431
431
  },
432
-
432
+
433
433
  /**
434
- Reads the current status for a storeKey. This will also lock the data
434
+ Reads the current status for a storeKey. This will also lock the data
435
435
  hash. If no status is found, returns `SC.RECORD_EMPTY`.
436
-
436
+
437
437
  @param {Number} storeKey the store key
438
438
  @returns {Number} status
439
439
  */
@@ -443,41 +443,41 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
443
443
  this.readDataHash(storeKey);
444
444
  return this.statuses[storeKey] || SC.Record.EMPTY;
445
445
  },
446
-
446
+
447
447
  /**
448
- Reads the current status for the storeKey without actually locking the
448
+ Reads the current status for the storeKey without actually locking the
449
449
  record. Usually you won't need to use this method. It is mostly used
450
450
  internally.
451
-
451
+
452
452
  @param {Number} storeKey the store key
453
453
  @returns {Number} status
454
454
  */
455
455
  peekStatus: function(storeKey) {
456
- return this.statuses[storeKey] || SC.Record.EMPTY;
456
+ return this.statuses[storeKey] || SC.Record.EMPTY;
457
457
  },
458
-
458
+
459
459
  /**
460
- Writes the current status for a storeKey. If the new status is
461
- `SC.Record.ERROR`, you may also pass an optional error object. Otherwise
460
+ Writes the current status for a storeKey. If the new status is
461
+ `SC.Record.ERROR`, you may also pass an optional error object. Otherwise
462
462
  this param is ignored.
463
-
463
+
464
464
  @param {Number} storeKey the store key
465
465
  @param {String} newStatus the new status
466
466
  @param {SC.Error} error optional error object
467
467
  @returns {SC.Store} receiver
468
468
  */
469
469
  writeStatus: function(storeKey, newStatus) {
470
- // use writeDataHash for now to handle optimistic lock. maximize code
470
+ // use writeDataHash for now to handle optimistic lock. maximize code
471
471
  // reuse.
472
472
  return this.writeDataHash(storeKey, null, newStatus);
473
473
  },
474
-
474
+
475
475
  /**
476
476
  Call this method whenever you modify some editable data hash to register
477
477
  with the Store that the attribute values have actually changed. This will
478
- do the book-keeping necessary to track the change across stores including
478
+ do the book-keeping necessary to track the change across stores including
479
479
  managing locks.
480
-
480
+
481
481
  @param {Number|Array} storeKeys one or more store keys that changed
482
482
  @param {Number} rev optional new revision number. normally leave null
483
483
  @param {Boolean} statusOnly (optional) YES if only status changed
@@ -485,13 +485,13 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
485
485
  @returns {SC.Store} receiver
486
486
  */
487
487
  dataHashDidChange: function(storeKeys, rev, statusOnly, key) {
488
-
488
+
489
489
  // update the revision for storeKey. Use generateStoreKey() because that
490
- // gaurantees a universally (to this store hierarchy anyway) unique
490
+ // gaurantees a universally (to this store hierarchy anyway) unique
491
491
  // key value.
492
492
  if (!rev) rev = SC.Store.generateStoreKey();
493
493
  var isArray, len, idx, storeKey;
494
-
494
+
495
495
  isArray = SC.typeOf(storeKeys) === SC.T_ARRAY;
496
496
  if (isArray) {
497
497
  len = storeKeys.length;
@@ -499,39 +499,39 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
499
499
  len = 1;
500
500
  storeKey = storeKeys;
501
501
  }
502
-
502
+
503
503
  var that = this;
504
504
  for(idx=0;idx<len;idx++) {
505
505
  if (isArray) storeKey = storeKeys[idx];
506
506
  this.revisions[storeKey] = rev;
507
507
  this._notifyRecordPropertyChange(storeKey, statusOnly, key);
508
-
508
+
509
509
  this._propagateToChildren(storeKey, function(storeKey){
510
510
  that.dataHashDidChange(storeKey, null, statusOnly, key);
511
511
  });
512
512
  }
513
-
513
+
514
514
  return this ;
515
515
  },
516
516
 
517
- /** @private
517
+ /** @private
518
518
  Will push all changes to a the recordPropertyChanges property
519
519
  and execute `flush()` once at the end of the runloop.
520
520
  */
521
521
  _notifyRecordPropertyChange: function(storeKey, statusOnly, key) {
522
-
523
- var records = this.records,
522
+
523
+ var records = this.records,
524
524
  nestedStores = this.get('nestedStores'),
525
525
  K = SC.Store,
526
526
  rec, editState, len, idx, store, status, keys;
527
-
527
+
528
528
  // pass along to nested stores
529
529
  len = nestedStores ? nestedStores.length : 0 ;
530
530
  for(idx=0;idx<len;idx++) {
531
531
  store = nestedStores[idx];
532
532
  status = store.peekStatus(storeKey); // important: peek avoids read-lock
533
533
  editState = store.storeKeyEditState(storeKey);
534
-
534
+
535
535
  // when store needs to propagate out changes in the parent store
536
536
  // to nested stores
537
537
  if (editState === K.INHERITED) {
@@ -543,29 +543,29 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
543
543
  store.reset();
544
544
  }
545
545
  }
546
-
546
+
547
547
  // store info in changes hash and schedule notification if needed.
548
548
  var changes = this.recordPropertyChanges;
549
549
  if (!changes) {
550
- changes = this.recordPropertyChanges =
550
+ changes = this.recordPropertyChanges =
551
551
  { storeKeys: SC.CoreSet.create(),
552
552
  records: SC.CoreSet.create(),
553
553
  hasDataChanges: SC.CoreSet.create(),
554
554
  propertyForStoreKeys: {} };
555
555
  }
556
-
556
+
557
557
  changes.storeKeys.add(storeKey);
558
558
 
559
559
  if (records && (rec=records[storeKey])) {
560
560
  changes.records.push(storeKey);
561
-
561
+
562
562
  // If there are changes other than just the status we need to record
563
563
  // that information so we do the right thing during the next flush.
564
564
  // Note that if we're called multiple times before flush and one call
565
565
  // has `statusOnly=true` and another has `statusOnly=false`, the flush
566
566
  // will (correctly) operate in `statusOnly=false` mode.
567
567
  if (!statusOnly) changes.hasDataChanges.push(storeKey);
568
-
568
+
569
569
  // If this is a key specific change, make sure that only those
570
570
  // properties/keys are notified. However, if a previous invocation of
571
571
  // `_notifyRecordPropertyChange` specified that all keys have changed, we
@@ -574,7 +574,7 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
574
574
  if (!(keys = changes.propertyForStoreKeys[storeKey])) {
575
575
  keys = changes.propertyForStoreKeys[storeKey] = SC.CoreSet.create();
576
576
  }
577
-
577
+
578
578
  // If it's '*' instead of a set, then that means there was a previous
579
579
  // invocation that said all keys have changed.
580
580
  if (keys !== '*') {
@@ -586,22 +586,22 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
586
586
  changes.propertyForStoreKeys[storeKey] = '*';
587
587
  }
588
588
  }
589
-
589
+
590
590
  this.invokeOnce(this.flush);
591
591
  return this;
592
592
  },
593
593
 
594
594
  /**
595
- Delivers any pending changes to materialized records. Normally this
595
+ Delivers any pending changes to materialized records. Normally this
596
596
  happens once, automatically, at the end of the RunLoop. If you have
597
- updated some records and need to update records immediately, however,
597
+ updated some records and need to update records immediately, however,
598
598
  you may call this manually.
599
599
 
600
600
  @returns {SC.Store} receiver
601
601
  */
602
602
  flush: function() {
603
603
  if (!this.recordPropertyChanges) return this;
604
-
604
+
605
605
  var changes = this.recordPropertyChanges,
606
606
  storeKeys = changes.storeKeys,
607
607
  hasDataChanges = changes.hasDataChanges,
@@ -609,26 +609,26 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
609
609
  propertyForStoreKeys = changes.propertyForStoreKeys,
610
610
  recordTypes = SC.CoreSet.create(),
611
611
  rec, recordType, statusOnly, idx, len, storeKey, keys;
612
-
612
+
613
613
  storeKeys.forEach(function(storeKey) {
614
614
  if (records.contains(storeKey)) {
615
615
  statusOnly = hasDataChanges.contains(storeKey) ? NO : YES;
616
616
  rec = this.records[storeKey];
617
617
  keys = propertyForStoreKeys ? propertyForStoreKeys[storeKey] : null;
618
-
618
+
619
619
  // Are we invalidating all keys? If so, don't pass any to
620
620
  // storeDidChangeProperties.
621
621
  if (keys === '*') keys = null;
622
-
622
+
623
623
  // remove it so we don't trigger this twice
624
624
  records.remove(storeKey);
625
-
625
+
626
626
  if (rec) rec.storeDidChangeProperties(statusOnly, keys);
627
627
  }
628
-
628
+
629
629
  recordType = SC.Store.recordTypeFor(storeKey);
630
630
  recordTypes.add(recordType);
631
-
631
+
632
632
  }, this);
633
633
 
634
634
  if (storeKeys.get('length') > 0) this._notifyRecordArrays(storeKeys, recordTypes);
@@ -638,19 +638,19 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
638
638
  records.clear();
639
639
  // Provide full reference to overwrite
640
640
  this.recordPropertyChanges.propertyForStoreKeys = {};
641
-
641
+
642
642
  return this;
643
643
  },
644
-
644
+
645
645
  /**
646
646
  Resets the store content. This will clear all internal data for all
647
647
  records, resetting them to an EMPTY state. You generally do not want
648
648
  to call this method yourself, though you may override it.
649
-
649
+
650
650
  @returns {SC.Store} receiver
651
651
  */
652
652
  reset: function() {
653
-
653
+
654
654
  // create a new empty data store
655
655
  this.dataHashes = {} ;
656
656
  this.revisions = {} ;
@@ -662,6 +662,9 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
662
662
  this.recordErrors = null;
663
663
  this.queryErrors = null;
664
664
 
665
+ var dataSource = this.get('dataSource');
666
+ if (dataSource && dataSource.reset) { dataSource.reset(); }
667
+
665
668
  var records = this.records, storeKey;
666
669
  if (records) {
667
670
  for(storeKey in records) {
@@ -669,21 +672,21 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
669
672
  this._notifyRecordPropertyChange(parseInt(storeKey, 10), NO);
670
673
  }
671
674
  }
672
-
675
+
673
676
  this.set('hasChanges', NO);
674
677
  },
675
-
678
+
676
679
  /** @private
677
680
  Called by a nested store on a parent store to commit any changes from the
678
- store. This will copy any changed dataHashes as well as any persistant
681
+ store. This will copy any changed dataHashes as well as any persistant
679
682
  change logs.
680
-
683
+
681
684
  If the parentStore detects a conflict with the optimistic locking, it will
682
- raise an exception before it makes any changes. If you pass the
685
+ raise an exception before it makes any changes. If you pass the
683
686
  force flag then this detection phase will be skipped and the changes will
684
687
  be applied even if another resource has modified the store in the mean
685
688
  time.
686
-
689
+
687
690
  @param {SC.Store} nestedStore the child store
688
691
  @param {SC.Set} changes the set of changed store keys
689
692
  @param {Boolean} force
@@ -692,20 +695,20 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
692
695
  commitChangesFromNestedStore: function(nestedStore, changes, force) {
693
696
  // first, check for optimistic locking problems
694
697
  if (!force) this._verifyLockRevisions(changes, nestedStore.locks);
695
-
696
- // OK, no locking issues. So let's just copy them changes.
698
+
699
+ // OK, no locking issues. So let's just copy them changes.
697
700
  // get local reference to values.
698
- var len = changes.length, i, storeKey, myDataHashes, myStatuses,
699
- myEditables, myRevisions, myParentRecords, myChildRecords,
701
+ var len = changes.length, i, storeKey, myDataHashes, myStatuses,
702
+ myEditables, myRevisions, myParentRecords, myChildRecords,
700
703
  chDataHashes, chStatuses, chRevisions, chParentRecords, chChildRecords;
701
-
704
+
702
705
  myRevisions = this.revisions ;
703
706
  myDataHashes = this.dataHashes;
704
707
  myStatuses = this.statuses;
705
708
  myEditables = this.editables ;
706
709
  myParentRecords = this.parentRecords ? this.parentRecords : this.parentRecords ={} ;
707
710
  myChildRecords = this.childRecords ? this.childRecords : this.childRecords = {} ;
708
-
711
+
709
712
  // setup some arrays if needed
710
713
  if (!myEditables) myEditables = this.editables = [] ;
711
714
  chDataHashes = nestedStore.dataHashes;
@@ -713,7 +716,7 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
713
716
  chStatuses = nestedStore.statuses;
714
717
  chParentRecords = nestedStore.parentRecords || {};
715
718
  chChildRecords = nestedStore.childRecords || {};
716
-
719
+
717
720
  for(i=0;i<len;i++) {
718
721
  storeKey = changes[i];
719
722
 
@@ -723,32 +726,32 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
723
726
  myRevisions[storeKey] = chRevisions[storeKey];
724
727
  myParentRecords[storeKey] = chParentRecords[storeKey];
725
728
  myChildRecords[storeKey] = chChildRecords[storeKey];
726
-
729
+
727
730
  myEditables[storeKey] = 0 ; // always make dataHash no longer editable
728
-
731
+
729
732
  this._notifyRecordPropertyChange(storeKey, NO);
730
733
  }
731
-
734
+
732
735
  // add any records to the changelog for commit handling
733
736
  var myChangelog = this.changelog, chChangelog = nestedStore.changelog;
734
737
  if (chChangelog) {
735
738
  if (!myChangelog) myChangelog = this.changelog = SC.CoreSet.create();
736
739
  myChangelog.addEach(chChangelog);
737
- }
740
+ }
738
741
  this.changelog = myChangelog;
739
-
742
+
740
743
  // immediately flush changes to notify records - nested stores will flush
741
744
  // later on.
742
745
  if (!this.get('parentStore')) this.flush();
743
-
746
+
744
747
  return this ;
745
748
  },
746
749
 
747
750
  /** @private
748
- Verifies that the passed lock revisions match the current revisions
749
- in the receiver store. If the lock revisions do not match, then the
751
+ Verifies that the passed lock revisions match the current revisions
752
+ in the receiver store. If the lock revisions do not match, then the
750
753
  store is in a conflict and an exception will be raised.
751
-
754
+
752
755
  @param {Array} changes set of changes we are trying to apply
753
756
  @param {SC.Set} locks the locks to verify
754
757
  @returns {SC.Store} receiver
@@ -763,85 +766,85 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
763
766
 
764
767
  // if the save revision for the item does not match the current rev
765
768
  // the someone has changed the data hash in this store and we have
766
- // a conflict.
769
+ // a conflict.
767
770
  if (lock < rev) throw SC.Store.CHAIN_CONFLICT_ERROR;
768
- }
771
+ }
769
772
  }
770
773
  return this ;
771
774
  },
772
-
775
+
773
776
  // ..........................................................
774
777
  // HIGH-LEVEL RECORD API
775
- //
776
-
778
+ //
779
+
777
780
  /**
778
781
  Finds a single record instance with the specified `recordType` and id or
779
782
  an array of records matching some query conditions.
780
-
783
+
781
784
  Finding a Single Record
782
785
  ---
783
-
786
+
784
787
  If you pass a single `recordType` and id, this method will return an
785
788
  actual record instance. If the record has not been loaded into the store
786
789
  yet, this method will ask the data source to retrieve it. If no data
787
790
  source indicates that it can retrieve the record, then this method will
788
791
  return `null`.
789
-
792
+
790
793
  Note that if the record needs to be retrieved from the server, then the
791
- record instance returned from this method will not have any data yet.
794
+ record instance returned from this method will not have any data yet.
792
795
  Instead it will have a status of `SC.Record.READY_LOADING`. You can
793
796
  monitor the status property to be notified when the record data is
794
797
  available for you to use it.
795
-
798
+
796
799
  Find a Collection of Records
797
800
  ---
798
-
799
- If you pass only a record type or a query object, you can instead find
801
+
802
+ If you pass only a record type or a query object, you can instead find
800
803
  all records matching a specified set of conditions. When you call
801
804
  `find()` in this way, it will create a query if needed and pass it to the
802
805
  data source to fetch the results.
803
-
806
+
804
807
  If this is the first time you have fetched the query, then the store will
805
- automatically ask the data source to fetch any records related to it as
808
+ automatically ask the data source to fetch any records related to it as
806
809
  well. Otherwise you can refresh the query results at anytime by calling
807
810
  `refresh()` on the returned `RecordArray`.
808
811
 
809
- You can detect whether a RecordArray is fetching from the server by
812
+ You can detect whether a RecordArray is fetching from the server by
810
813
  checking its status.
811
-
814
+
812
815
  Examples
813
816
  ---
814
-
817
+
815
818
  Finding a single record:
816
-
819
+
817
820
  MyApp.store.find(MyApp.Contact, "23"); // returns MyApp.Contact
818
-
821
+
819
822
  Finding all records of a particular type:
820
-
823
+
821
824
  MyApp.store.find(MyApp.Contact); // returns SC.RecordArray of contacts
822
-
823
-
825
+
826
+
824
827
  Finding all contacts with first name John:
825
-
828
+
826
829
  var query = SC.Query.local(MyApp.Contact, "firstName = %@", "John");
827
830
  MyApp.store.find(query); // returns SC.RecordArray of contacts
828
-
831
+
829
832
  Finding all contacts using a remote query:
830
-
833
+
831
834
  var query = SC.Query.remote(MyApp.Contact);
832
835
  MyApp.store.find(query); // returns SC.RecordArray filled by server
833
-
836
+
834
837
  @param {SC.Record|String} recordType the expected record type
835
838
  @param {String} id the id to load
836
839
  @returns {SC.Record} record instance or null
837
840
  */
838
841
  find: function(recordType, id) {
839
-
842
+
840
843
  // if recordType is passed as string, find object
841
844
  if (SC.typeOf(recordType)===SC.T_STRING) {
842
845
  recordType = SC.objectForPropertyPath(recordType);
843
846
  }
844
-
847
+
845
848
  // handle passing a query...
846
849
  if ((arguments.length === 1) && !(recordType && recordType.get && recordType.get('isRecord'))) {
847
850
  if (!recordType) throw new Error("SC.Store#find() must pass recordType or query");
@@ -849,7 +852,7 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
849
852
  recordType = SC.Query.local(recordType);
850
853
  }
851
854
  return this._findQuery(recordType, YES, YES);
852
-
855
+
853
856
  // handle finding a single record
854
857
  } else {
855
858
  return this._findRecord(recordType, id);
@@ -858,36 +861,35 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
858
861
 
859
862
  /** @private
860
863
  DEPRECATED used find() instead.
861
-
864
+
862
865
  This method will accept a record type or query and return a record array
863
- matching the results. This method was commonly used prior to SproutCore
866
+ matching the results. This method was commonly used prior to SproutCore
864
867
  1.0. It has been deprecated in favor of a single `find()` method instead.
865
-
868
+
866
869
  For compatibility, this method will continue to work in SproutCore 1.0 but
867
- it will raise a warning. It will be removed in a future version of
870
+ it will raise a warning. It will be removed in a future version of
868
871
  SproutCore.
869
872
  */
870
873
  findAll: function(recordType, conditions, params) {
871
874
  SC.Logger.warn("SC.Store#findAll() will be removed in a future version of SproutCore. Use SC.Store#find() instead");
872
-
873
875
 
874
876
  if (!recordType || !recordType.isQuery) {
875
877
  recordType = SC.Query.local(recordType, conditions, params);
876
878
  }
877
-
879
+
878
880
  return this._findQuery(recordType, YES, YES);
879
881
  },
880
-
881
-
882
+
883
+
882
884
  _findQuery: function(query, createIfNeeded, refreshIfNew) {
883
885
 
884
886
  // lookup the local RecordArray for this query.
885
- var cache = this._scst_recordArraysByQuery,
887
+ var cache = this._scst_recordArraysByQuery,
886
888
  key = SC.guidFor(query),
887
889
  ret, ra ;
888
890
  if (!cache) cache = this._scst_recordArraysByQuery = {};
889
891
  ret = cache[key];
890
-
892
+
891
893
  // if a RecordArray was not found, then create one and also add it to the
892
894
  // list of record arrays to update.
893
895
  if (!ret && createIfNeeded) {
@@ -899,51 +901,51 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
899
901
 
900
902
  if (refreshIfNew) this.refreshQuery(query);
901
903
  }
902
-
904
+
903
905
  this.flush();
904
906
  return ret ;
905
907
  },
906
-
908
+
907
909
  _findRecord: function(recordType, id) {
908
910
 
909
- var storeKey ;
910
-
911
- // if a record instance is passed, simply use the storeKey. This allows
911
+ var storeKey ;
912
+
913
+ // if a record instance is passed, simply use the storeKey. This allows
912
914
  // you to pass a record from a chained store to get the same record in the
913
915
  // current store.
914
916
  if (recordType && recordType.get && recordType.get('isRecord')) {
915
917
  storeKey = recordType.get('storeKey');
916
-
917
- // otherwise, lookup the storeKey for the passed id. look in subclasses
918
+
919
+ // otherwise, lookup the storeKey for the passed id. look in subclasses
918
920
  // as well.
919
921
  } else storeKey = id ? recordType.storeKeyFor(id) : null;
920
-
922
+
921
923
  if (storeKey && (this.readStatus(storeKey) === SC.Record.EMPTY)) {
922
924
  storeKey = this.retrieveRecord(recordType, id);
923
925
  }
924
-
926
+
925
927
  // now we have the storeKey, materialize the record and return it.
926
928
  return storeKey ? this.materializeRecord(storeKey) : null ;
927
929
  },
928
930
 
929
931
  // ..........................................................
930
932
  // RECORD ARRAY OPERATIONS
931
- //
933
+ //
932
934
 
933
935
  /**
934
- Called by the record array just before it is destroyed. This will
936
+ Called by the record array just before it is destroyed. This will
935
937
  de-register it from receiving future notifications.
936
938
 
937
939
  You should never call this method yourself. Instead call `destroy()` on
938
940
  the `RecordArray` directly.
939
-
941
+
940
942
  @param {SC.RecordArray} recordArray the record array
941
943
  @returns {SC.Store} receiver
942
944
  */
943
945
  recordArrayWillDestroy: function(recordArray) {
944
946
  var cache = this._scst_recordArraysByQuery,
945
947
  set = this.get('recordArrays');
946
-
948
+
947
949
  if (cache) delete cache[SC.guidFor(recordArray.get('query'))];
948
950
  if (set) set.remove(recordArray);
949
951
  return this ;
@@ -956,7 +958,7 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
956
958
 
957
959
  You should never call this method yourself. Instead call `refresh()` on
958
960
  the `RecordArray` directly.
959
-
961
+
960
962
  @param {SC.Query} query the record array query to refresh
961
963
  @returns {SC.Store} receiver
962
964
  */
@@ -964,21 +966,21 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
964
966
  if (!query) throw new Error("refreshQuery() requires a query");
965
967
 
966
968
  var cache = this._scst_recordArraysByQuery,
967
- recArray = cache ? cache[SC.guidFor(query)] : null,
969
+ recArray = cache ? cache[SC.guidFor(query)] : null,
968
970
  source = this._getDataSource();
969
-
971
+
970
972
  if (source && source.fetch) {
971
973
  if (recArray) recArray.storeWillFetchQuery(query);
972
974
  source.fetch.call(source, this, query);
973
975
  }
974
-
975
- return this ;
976
+
977
+ return this ;
976
978
  },
977
-
978
- /** @private
979
+
980
+ /** @private
979
981
  Will ask all record arrays that have been returned from `findAll`
980
982
  with an `SC.Query` to check their arrays with the new `storeKey`s
981
-
983
+
982
984
  @param {SC.IndexSet} storeKeys set of storeKeys that changed
983
985
  @param {SC.Set} recordTypes
984
986
  @returns {SC.Store} receiver
@@ -990,29 +992,29 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
990
992
  recordArrays.forEach(function(recArray) {
991
993
  if (recArray) recArray.storeDidChangeStoreKeys(storeKeys, recordTypes);
992
994
  }, this);
993
-
995
+
994
996
  return this ;
995
997
  },
996
-
997
-
998
+
999
+
998
1000
  // ..........................................................
999
1001
  // LOW-LEVEL HELPERS
1000
- //
1001
-
1002
+ //
1003
+
1002
1004
  /**
1003
1005
  Array of all records currently in the store with the specified
1004
1006
  type. This method only reflects the actual records loaded into memory and
1005
1007
  therefore is not usually needed at runtime. However you will often use
1006
1008
  this method for testing.
1007
-
1009
+
1008
1010
  @param {SC.Record} recordType the record type
1009
1011
  @returns {SC.Array} array instance - usually SC.RecordArray
1010
1012
  */
1011
1013
  recordsFor: function(recordType) {
1012
- var storeKeys = [],
1014
+ var storeKeys = [],
1013
1015
  storeKeysById = recordType.storeKeysById(),
1014
1016
  id, storeKey, ret;
1015
-
1017
+
1016
1018
  // collect all non-empty store keys
1017
1019
  for(id in storeKeysById) {
1018
1020
  storeKey = storeKeysById[id]; // get the storeKey
@@ -1020,23 +1022,23 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
1020
1022
  storeKeys.push(storeKey);
1021
1023
  }
1022
1024
  }
1023
-
1025
+
1024
1026
  if (storeKeys.length>0) {
1025
1027
  ret = SC.RecordArray.create({ store: this, storeKeys: storeKeys });
1026
1028
  } else ret = storeKeys; // empty array
1027
1029
  return ret ;
1028
1030
  },
1029
-
1031
+
1030
1032
  _TMP_REC_ATTRS: {},
1031
-
1032
- /**
1033
+
1034
+ /**
1033
1035
  Given a `storeKey`, return a materialized record. You will not usually
1034
1036
  call this method yourself. Instead it will used by other methods when
1035
1037
  you find records by id or perform other searches.
1036
1038
 
1037
1039
  If a `recordType` has been mapped to the storeKey, then a record instance
1038
1040
  will be returned even if the data hash has not been requested yet.
1039
-
1041
+
1040
1042
  Each Store instance returns unique record instances for each storeKey.
1041
1043
 
1042
1044
  @param {Number} storeKey The storeKey for the dataHash.
@@ -1044,33 +1046,33 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
1044
1046
  */
1045
1047
  materializeRecord: function(storeKey) {
1046
1048
  var records = this.records, ret, recordType, attrs;
1047
-
1049
+
1048
1050
  // look up in cached records
1049
1051
  if (!records) records = this.records = {}; // load cached records
1050
1052
  ret = records[storeKey];
1051
1053
  if (ret) return ret;
1052
-
1054
+
1053
1055
  // not found -- OK, create one then.
1054
1056
  recordType = SC.Store.recordTypeFor(storeKey);
1055
1057
  if (!recordType) return null; // not recordType registered, nothing to do
1056
-
1058
+
1057
1059
  attrs = this._TMP_REC_ATTRS ;
1058
1060
  attrs.storeKey = storeKey ;
1059
1061
  attrs.store = this ;
1060
1062
  ret = records[storeKey] = recordType.create(attrs);
1061
-
1063
+
1062
1064
  return ret ;
1063
1065
  },
1064
1066
 
1065
1067
  // ..........................................................
1066
1068
  // CORE RECORDS API
1067
- //
1068
- // The methods in this section can be used to manipulate records without
1069
+ //
1070
+ // The methods in this section can be used to manipulate records without
1069
1071
  // actually creating record instances.
1070
-
1072
+
1071
1073
  /**
1072
1074
  Creates a new record instance with the passed `recordType` and `dataHash`.
1073
- You can also optionally specify an id or else it will be pulled from the
1075
+ You can also optionally specify an id or else it will be pulled from the
1074
1076
  data hash.
1075
1077
 
1076
1078
  Note that the record will not yet be saved back to the server. To save
@@ -1085,8 +1087,8 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
1085
1087
  createRecord: function(recordType, dataHash, id) {
1086
1088
  var primaryKey, storeKey, status, K = SC.Record, changelog, defaultVal,
1087
1089
  ret;
1088
-
1089
- // First, try to get an id. If no id is passed, look it up in the
1090
+
1091
+ // First, try to get an id. If no id is passed, look it up in the
1090
1092
  // dataHash.
1091
1093
  if (!id && (primaryKey = recordType.prototype.primaryKey)) {
1092
1094
  id = dataHash[primaryKey];
@@ -1097,57 +1099,57 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
1097
1099
  id = dataHash[primaryKey] = defaultVal();
1098
1100
  }
1099
1101
  }
1100
-
1102
+
1101
1103
  // Next get the storeKey - base on id if available
1102
1104
  storeKey = id ? recordType.storeKeyFor(id) : SC.Store.generateStoreKey();
1103
-
1105
+
1104
1106
  // now, check the state and do the right thing.
1105
1107
  status = this.readStatus(storeKey);
1106
-
1108
+
1107
1109
  // check state
1108
1110
  // any busy or ready state or destroyed dirty state is not allowed
1109
- if ((status & K.BUSY) ||
1110
- (status & K.READY) ||
1111
- (status === K.DESTROYED_DIRTY)) {
1111
+ if ((status & K.BUSY) ||
1112
+ (status & K.READY) ||
1113
+ (status === K.DESTROYED_DIRTY)) {
1112
1114
  throw id ? K.RECORD_EXISTS_ERROR : K.BAD_STATE_ERROR;
1113
-
1115
+
1114
1116
  // allow error or destroyed state only with id
1115
1117
  } else if (!id && (status===SC.DESTROYED_CLEAN || status===SC.ERROR)) {
1116
1118
  throw K.BAD_STATE_ERROR;
1117
1119
  }
1118
-
1120
+
1119
1121
  // add dataHash and setup initial status -- also save recordType
1120
1122
  this.writeDataHash(storeKey, (dataHash ? dataHash : {}), K.READY_NEW);
1121
-
1123
+
1122
1124
  SC.Store.replaceRecordTypeFor(storeKey, recordType);
1123
1125
  this.dataHashDidChange(storeKey);
1124
-
1126
+
1125
1127
  // Record is now in a committable state -- add storeKey to changelog
1126
1128
  changelog = this.changelog;
1127
1129
  if (!changelog) changelog = SC.Set.create();
1128
1130
  changelog.add(storeKey);
1129
1131
  this.changelog = changelog;
1130
-
1132
+
1131
1133
  // if commit records is enabled
1132
1134
  if(this.get('commitRecordsAutomatically')){
1133
1135
  this.invokeLast(this.commitRecords);
1134
1136
  }
1135
-
1137
+
1136
1138
  // Finally return materialized record, after we propagate the status to
1137
1139
  // any aggregrate records.
1138
1140
  ret = this.materializeRecord(storeKey);
1139
1141
  if (ret) ret.propagateToAggregates();
1140
1142
  return ret;
1141
- },
1142
-
1143
+ },
1144
+
1143
1145
  /**
1144
- Creates an array of new records. You must pass an array of `dataHash`es
1146
+ Creates an array of new records. You must pass an array of `dataHash`es
1145
1147
  plus a `recordType` and, optionally, an array of ids. This will create an
1146
1148
  array of record instances with the same record type.
1147
-
1149
+
1148
1150
  If you need to instead create a bunch of records with different data types
1149
1151
  you can instead pass an array of `recordType`s, one for each data hash.
1150
-
1152
+
1151
1153
  @param {SC.Record|Array} recordTypes class or array of classes
1152
1154
  @param {Array} dataHashes array of data hashes
1153
1155
  @param {Array} ids (optional) ids to assign to records
@@ -1164,14 +1166,14 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
1164
1166
  }
1165
1167
  return ret ;
1166
1168
  },
1167
-
1168
-
1169
+
1170
+
1169
1171
  /**
1170
- Unloads a record, removing the data hash from the store. If you try to
1171
- unload a record that is already destroyed then this method will have no effect.
1172
- If you unload a record that does not exist or an error then an exception
1172
+ Unloads a record, removing the data hash from the store. If you try to
1173
+ unload a record that is already destroyed then this method will have no effect.
1174
+ If you unload a record that does not exist or an error then an exception
1173
1175
  will be raised.
1174
-
1176
+
1175
1177
  @param {SC.Record} recordType the recordType
1176
1178
  @param {String} id the record id
1177
1179
  @param {Number} storeKey (optional) if passed, ignores recordType and id
@@ -1184,35 +1186,35 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
1184
1186
  // handle status - ignore if destroying or destroyed
1185
1187
  if ((status === K.BUSY_DESTROYING) || (status & K.DESTROYED)) {
1186
1188
  return this; // nothing to do
1187
-
1189
+
1188
1190
  // error out if empty
1189
1191
  } else if (status & K.BUSY) {
1190
1192
  throw K.BUSY_ERROR ;
1191
-
1193
+
1192
1194
  // otherwise, destroy in dirty state
1193
1195
  } else status = newStatus ;
1194
-
1196
+
1195
1197
  // remove the data hash, set new status
1196
1198
  this.removeDataHash(storeKey, status);
1197
1199
  this.dataHashDidChange(storeKey);
1198
-
1200
+
1199
1201
  // Handle all the child Records
1200
1202
  var that = this;
1201
1203
  this._propagateToChildren(storeKey, function(storeKey){
1202
1204
  that.unloadRecord(null, null, storeKey, newStatus);
1203
1205
  });
1204
-
1206
+
1205
1207
  return this ;
1206
1208
  },
1207
-
1209
+
1208
1210
  /**
1209
1211
  Unloads a group of records. If you have a set of record ids, unloading
1210
- them this way can be faster than retrieving each record and unloading
1212
+ them this way can be faster than retrieving each record and unloading
1211
1213
  it individually.
1212
1214
 
1213
1215
  You can pass either a single `recordType` or an array of `recordType`s. If
1214
1216
  you pass a single `recordType`, then the record type will be used for each
1215
- record. If you pass an array, then each id must have a matching record
1217
+ record. If you pass an array, then each id must have a matching record
1216
1218
  type in the array.
1217
1219
 
1218
1220
  You can optionally pass an array of `storeKey`s instead of the `recordType`
@@ -1259,10 +1261,10 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
1259
1261
 
1260
1262
  /**
1261
1263
  Destroys a record, removing the data hash from the store and adding the
1262
- record to the destroyed changelog. If you try to destroy a record that is
1263
- already destroyed then this method will have no effect. If you destroy a
1264
+ record to the destroyed changelog. If you try to destroy a record that is
1265
+ already destroyed then this method will have no effect. If you destroy a
1264
1266
  record that does not exist or an error then an exception will be raised.
1265
-
1267
+
1266
1268
  @param {SC.Record} recordType the recordType
1267
1269
  @param {String} id the record id
1268
1270
  @param {Number} storeKey (optional) if passed, ignores recordType and id
@@ -1275,22 +1277,22 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
1275
1277
  // handle status - ignore if destroying or destroyed
1276
1278
  if ((status === K.BUSY_DESTROYING) || (status & K.DESTROYED)) {
1277
1279
  return this; // nothing to do
1278
-
1280
+
1279
1281
  // error out if empty
1280
1282
  } else if (status === K.EMPTY) {
1281
1283
  throw K.NOT_FOUND_ERROR ;
1282
-
1284
+
1283
1285
  // error out if busy
1284
1286
  } else if (status & K.BUSY) {
1285
1287
  throw K.BUSY_ERROR ;
1286
-
1288
+
1287
1289
  // if new status, destroy but leave in clean state
1288
1290
  } else if (status === K.READY_NEW) {
1289
1291
  status = K.DESTROYED_CLEAN ;
1290
-
1292
+
1291
1293
  // otherwise, destroy in dirty state
1292
1294
  } else status = K.DESTROYED_DIRTY ;
1293
-
1295
+
1294
1296
  // remove the data hash, set new status
1295
1297
  this.writeStatus(storeKey, status);
1296
1298
  this.dataHashDidChange(storeKey);
@@ -1306,30 +1308,30 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
1306
1308
  if(this.get('commitRecordsAutomatically')){
1307
1309
  this.invokeLast(this.commitRecords);
1308
1310
  }
1309
-
1311
+
1310
1312
  var that = this;
1311
1313
  this._propagateToChildren(storeKey, function(storeKey){
1312
1314
  that.destroyRecord(null, null, storeKey);
1313
1315
  });
1314
-
1316
+
1315
1317
  return this ;
1316
1318
  },
1317
-
1319
+
1318
1320
  /**
1319
1321
  Destroys a group of records. If you have a set of record ids, destroying
1320
- them this way can be faster than retrieving each record and destroying
1322
+ them this way can be faster than retrieving each record and destroying
1321
1323
  it individually.
1322
-
1324
+
1323
1325
  You can pass either a single `recordType` or an array of `recordType`s. If
1324
1326
  you pass a single `recordType`, then the record type will be used for each
1325
- record. If you pass an array, then each id must have a matching record
1327
+ record. If you pass an array, then each id must have a matching record
1326
1328
  type in the array.
1327
1329
 
1328
1330
  You can optionally pass an array of `storeKey`s instead of the `recordType`
1329
1331
  and ids. In this case the first two parameters will be ignored. This
1330
1332
  is usually only used by low-level internal methods. You will not usually
1331
1333
  destroy records this way.
1332
-
1334
+
1333
1335
  @param {SC.Record|Array} recordTypes class or array of classes
1334
1336
  @param {Array} ids ids to destroy
1335
1337
  @param {Array} storeKeys (optional) store keys to destroy
@@ -1355,7 +1357,7 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
1355
1357
  }
1356
1358
  return this ;
1357
1359
  },
1358
-
1360
+
1359
1361
  /**
1360
1362
  register a Child Record to the parent
1361
1363
  */
@@ -1380,7 +1382,7 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
1380
1382
  this.childRecords = crs;
1381
1383
  this.parentRecords = prs;
1382
1384
  },
1383
-
1385
+
1384
1386
  /**
1385
1387
  materialize the parent when passing in a store key for the child
1386
1388
  */
@@ -1390,10 +1392,10 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
1390
1392
  crs = this.childRecords;
1391
1393
  pk = crs ? this.childRecords[childStoreKey] : null ;
1392
1394
  if (SC.none(pk)) return null;
1393
-
1395
+
1394
1396
  return this.materializeRecord(pk);
1395
1397
  },
1396
-
1398
+
1397
1399
  /**
1398
1400
  function for retrieving a parent record key
1399
1401
 
@@ -1404,7 +1406,7 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
1404
1406
  var crs = this.childRecords || {};
1405
1407
  return crs[storeKey];
1406
1408
  },
1407
-
1409
+
1408
1410
  /**
1409
1411
  function that propagates a function call to all children
1410
1412
  */
@@ -1417,12 +1419,12 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
1417
1419
  if (children.hasOwnProperty(key)) func(key);
1418
1420
  }
1419
1421
  },
1420
-
1422
+
1421
1423
  /**
1422
1424
  Notes that the data for the given record id has changed. The record will
1423
1425
  be committed to the server the next time you commit the root store. Only
1424
1426
  call this method on a record in a READY state of some type.
1425
-
1427
+
1426
1428
  @param {SC.Record} recordType the recordType
1427
1429
  @param {String} id the record id
1428
1430
  @param {Number} storeKey (optional) if passed, ignores recordType and id
@@ -1433,55 +1435,55 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
1433
1435
  recordDidChange: function(recordType, id, storeKey, key, statusOnly) {
1434
1436
  if (storeKey === undefined) storeKey = recordType.storeKeyFor(id);
1435
1437
  var status = this.readStatus(storeKey), changelog, K = SC.Record;
1436
-
1438
+
1437
1439
  // BUSY_LOADING, BUSY_CREATING, BUSY_COMMITTING, BUSY_REFRESH_CLEAN
1438
1440
  // BUSY_REFRESH_DIRTY, BUSY_DESTROYING
1439
1441
  if (status & K.BUSY) {
1440
1442
  throw K.BUSY_ERROR ;
1441
-
1443
+
1442
1444
  // if record is not in ready state, then it is not found.
1443
1445
  // ERROR, EMPTY, DESTROYED_CLEAN, DESTROYED_DIRTY
1444
1446
  } else if (!(status & K.READY)) {
1445
1447
  throw K.NOT_FOUND_ERROR ;
1446
-
1448
+
1447
1449
  // otherwise, make new status READY_DIRTY unless new.
1448
1450
  // K.READY_CLEAN, K.READY_DIRTY, ignore K.READY_NEW
1449
1451
  } else {
1450
1452
  if (status != K.READY_NEW) this.writeStatus(storeKey, K.READY_DIRTY);
1451
1453
  }
1452
-
1454
+
1453
1455
  // record data hash change
1454
1456
  this.dataHashDidChange(storeKey, null, statusOnly, key);
1455
-
1457
+
1456
1458
  // record in changelog
1457
1459
  changelog = this.changelog ;
1458
1460
  if (!changelog) changelog = this.changelog = SC.Set.create() ;
1459
1461
  changelog.add(storeKey);
1460
1462
  this.changelog = changelog;
1461
-
1463
+
1462
1464
  // if commit records is enabled
1463
1465
  if(this.get('commitRecordsAutomatically')){
1464
1466
  this.invokeLast(this.commitRecords);
1465
1467
  }
1466
-
1468
+
1467
1469
  return this ;
1468
1470
  },
1469
1471
 
1470
1472
  /**
1471
1473
  Mark a group of records as dirty. The records will be committed to the
1472
- server the next time you commit changes on the root store. If you have a
1473
- set of record ids, marking them dirty this way can be faster than
1474
+ server the next time you commit changes on the root store. If you have a
1475
+ set of record ids, marking them dirty this way can be faster than
1474
1476
  retrieving each record and destroying it individually.
1475
-
1477
+
1476
1478
  You can pass either a single `recordType` or an array of `recordType`s. If
1477
1479
  you pass a single `recordType`, then the record type will be used for each
1478
- record. If you pass an array, then each id must have a matching record
1480
+ record. If you pass an array, then each id must have a matching record
1479
1481
  type in the array.
1480
1482
 
1481
1483
  You can optionally pass an array of `storeKey`s instead of the `recordType`
1482
1484
  and ids. In this case the first two parameters will be ignored. This
1483
- is usually only used by low-level internal methods.
1484
-
1485
+ is usually only used by low-level internal methods.
1486
+
1485
1487
  @param {SC.Record|Array} recordTypes class or array of classes
1486
1488
  @param {Array} ids ids to destroy
1487
1489
  @param {Array} storeKeys (optional) store keys to destroy
@@ -1506,20 +1508,20 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
1506
1508
  this.recordDidChange(undefined, undefined, storeKey);
1507
1509
  }
1508
1510
  }
1509
- return this ;
1511
+ return this ;
1510
1512
  },
1511
1513
 
1512
1514
  /**
1513
- Retrieves a set of records from the server. If the records has
1514
- already been loaded in the store, then this method will simply return.
1515
- Otherwise if your store has a `dataSource`, this will call the
1516
- `dataSource` to retrieve the record. Generally you will not need to
1515
+ Retrieves a set of records from the server. If the records has
1516
+ already been loaded in the store, then this method will simply return.
1517
+ Otherwise if your store has a `dataSource`, this will call the
1518
+ `dataSource` to retrieve the record. Generally you will not need to
1517
1519
  call this method yourself. Instead you can just use `find()`.
1518
-
1519
- This will not actually create a record instance but it will initiate a
1520
- load of the record from the server. You can subsequently get a record
1520
+
1521
+ This will not actually create a record instance but it will initiate a
1522
+ load of the record from the server. You can subsequently get a record
1521
1523
  instance itself using `materializeRecord()`.
1522
-
1524
+
1523
1525
  @param {SC.Record|Array} recordTypes class or array of classes
1524
1526
  @param {Array} ids ids to retrieve
1525
1527
  @param {Array} storeKeys (optional) store keys to retrieve
@@ -1528,7 +1530,7 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
1528
1530
  @returns {Array} storeKeys to be retrieved
1529
1531
  */
1530
1532
  retrieveRecords: function(recordTypes, ids, storeKeys, isRefresh, callbacks) {
1531
-
1533
+
1532
1534
  var source = this._getDataSource(),
1533
1535
  isArray = SC.typeOf(recordTypes) === SC.T_ARRAY,
1534
1536
  hasCallbackArray = SC.typeOf(callbacks) === SC.T_ARRAY,
@@ -1537,12 +1539,12 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
1537
1539
  rev = SC.Store.generateStoreKey(),
1538
1540
  K = SC.Record,
1539
1541
  recordType, idx, storeKey, status, ok, callback;
1540
-
1542
+
1541
1543
  if (!isArray) recordType = recordTypes;
1542
-
1544
+
1543
1545
  // if no storeKeys were passed, map recordTypes + ids
1544
1546
  for(idx=0;idx<len;idx++) {
1545
-
1547
+
1546
1548
  // collect store key
1547
1549
  if (storeKeys) {
1548
1550
  storeKey = storeKeys[idx];
@@ -1552,10 +1554,10 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
1552
1554
  }
1553
1555
  //collect the callback
1554
1556
  callback = hasCallbackArray ? callbacks[idx] : callbacks;
1555
-
1557
+
1556
1558
  // collect status and process
1557
1559
  status = this.readStatus(storeKey);
1558
-
1560
+
1559
1561
  // K.EMPTY, K.ERROR, K.DESTROYED_CLEAN - initial retrieval
1560
1562
  if ((status == K.EMPTY) || (status == K.ERROR) || (status == K.DESTROYED_CLEAN)) {
1561
1563
  this.writeStatus(storeKey, K.BUSY_LOADING);
@@ -1577,19 +1579,19 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
1577
1579
  // K.DESTROY_DIRTY, bad state...
1578
1580
  } else if (status == K.DESTROYED_DIRTY) {
1579
1581
  throw K.BAD_STATE_ERROR ;
1580
-
1582
+
1581
1583
  // ignore K.BUSY_LOADING, K.BUSY_REFRESH_CLEAN, K.BUSY_REFRESH_DIRTY
1582
1584
  }
1583
1585
  }
1584
1586
  }
1585
-
1587
+
1586
1588
  // now retrieve storekeys from dataSource. if there is no dataSource,
1587
1589
  // then act as if we couldn't retrieve.
1588
1590
  ok = NO;
1589
1591
  if (source) ok = source.retrieveRecords.call(source, this, ret, ids);
1590
1592
 
1591
1593
  // if the data source could not retrieve or if there is no source, then
1592
- // simulate the data source calling dataSourceDidError on those we are
1594
+ // simulate the data source calling dataSourceDidError on those we are
1593
1595
  // loading for the first time or dataSourceDidComplete on refreshes.
1594
1596
  if (!ok) {
1595
1597
  len = ret.length;
@@ -1600,7 +1602,7 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
1600
1602
  if (status === K.BUSY_LOADING) {
1601
1603
  this.writeStatus(storeKey, K.ERROR);
1602
1604
  this.dataHashDidChange(storeKey, rev, YES);
1603
-
1605
+
1604
1606
  } else if (status & K.BUSY_REFRESH) {
1605
1607
  this.writeStatus(storeKey, K.READY | (status & 0x03));
1606
1608
  this.dataHashDidChange(storeKey, rev, YES);
@@ -1610,11 +1612,11 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
1610
1612
  }
1611
1613
  return ret ;
1612
1614
  },
1613
-
1615
+
1614
1616
  _TMP_RETRIEVE_ARRAY: [],
1615
-
1617
+
1616
1618
  _callback_queue: {},
1617
-
1619
+
1618
1620
  /**
1619
1621
  @private
1620
1622
  stores the callbacks for the storeKeys that are inflight
@@ -1651,14 +1653,14 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
1651
1653
  delete queue[key];
1652
1654
  });
1653
1655
  }
1654
-
1656
+
1655
1657
  }
1656
1658
  }
1657
1659
  },
1658
-
1660
+
1659
1661
  /*
1660
1662
  @private
1661
-
1663
+
1662
1664
  */
1663
1665
  _cancelCallback: function(storeKey){
1664
1666
  var queue = this._callback_queue;
@@ -1666,17 +1668,17 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
1666
1668
  delete queue[storeKey];
1667
1669
  }
1668
1670
  },
1669
-
1670
-
1671
+
1672
+
1671
1673
  /**
1672
1674
  Retrieves a record from the server. If the record has already been loaded
1673
- in the store, then this method will simply return. Otherwise if your
1674
- store has a `dataSource`, this will call the `dataSource` to retrieve the
1675
- record. Generally you will not need to call this method yourself.
1675
+ in the store, then this method will simply return. Otherwise if your
1676
+ store has a `dataSource`, this will call the `dataSource` to retrieve the
1677
+ record. Generally you will not need to call this method yourself.
1676
1678
  Instead you can just use `find()`.
1677
-
1678
- This will not actually create a record instance but it will initiate a
1679
- load of the record from the server. You can subsequently get a record
1679
+
1680
+ This will not actually create a record instance but it will initiate a
1681
+ load of the record from the server. You can subsequently get a record
1680
1682
  instance itself using `materializeRecord()`.
1681
1683
 
1682
1684
  @param {SC.Record} recordType class
@@ -1684,12 +1686,12 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
1684
1686
  @param {Number} storeKey (optional) store key
1685
1687
  @param {Boolean} isRefresh
1686
1688
  @param {Function} callback (optional)
1687
- @returns {Number} storeKey that was retrieved
1689
+ @returns {Number} storeKey that was retrieved
1688
1690
  */
1689
1691
  retrieveRecord: function(recordType, id, storeKey, isRefresh, callback) {
1690
1692
  var array = this._TMP_RETRIEVE_ARRAY,
1691
1693
  ret;
1692
-
1694
+
1693
1695
  if (storeKey) {
1694
1696
  array[0] = storeKey;
1695
1697
  storeKey = array;
@@ -1698,7 +1700,7 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
1698
1700
  array[0] = id;
1699
1701
  id = array;
1700
1702
  }
1701
-
1703
+
1702
1704
  ret = this.retrieveRecords(recordType, id, storeKey, isRefresh, callback);
1703
1705
  array.length = 0 ;
1704
1706
  return ret[0];
@@ -1708,7 +1710,7 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
1708
1710
  Refreshes a record from the server. If the record has already been loaded
1709
1711
  in the store, then this method will request a refresh from the
1710
1712
  `dataSource`. Otherwise it will attempt to retrieve the record.
1711
-
1713
+
1712
1714
  @param {String} id to id of the record to load
1713
1715
  @param {SC.Record} recordType the expected record type
1714
1716
  @param {Number} storeKey (optional) optional store key
@@ -1723,7 +1725,7 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
1723
1725
  Refreshes a set of records from the server. If the records has already been loaded
1724
1726
  in the store, then this method will request a refresh from the
1725
1727
  `dataSource`. Otherwise it will attempt to retrieve them.
1726
-
1728
+
1727
1729
  @param {SC.Record|Array} recordTypes class or array of classes
1728
1730
  @param {Array} ids ids to destroy
1729
1731
  @param {Array} storeKeys (optional) store keys to destroy
@@ -1734,29 +1736,29 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
1734
1736
  var ret = this.retrieveRecords(recordTypes, ids, storeKeys, YES, callback);
1735
1737
  return ret && ret.length>0;
1736
1738
  },
1737
-
1739
+
1738
1740
  /**
1739
1741
  Commits the passed store keys or ids. If no `storeKey`s are given,
1740
- it will commit any records in the changelog.
1741
-
1742
- Based on the current state of the record, this will ask the data
1742
+ it will commit any records in the changelog.
1743
+
1744
+ Based on the current state of the record, this will ask the data
1743
1745
  source to perform the appropriate actions
1744
1746
  on the store keys.
1745
-
1747
+
1746
1748
  @param {Array} recordTypes the expected record types (SC.Record)
1747
1749
  @param {Array} ids to commit
1748
1750
  @param {SC.Set} storeKeys to commit
1749
1751
  @param {Hash} params optional additional parameters to pass along to the
1750
1752
  data source
1751
1753
  @param {Function|Array} callback function or array of callbacks
1752
-
1754
+
1753
1755
  @returns {Boolean} if the action was succesful.
1754
1756
  */
1755
1757
  commitRecords: function(recordTypes, ids, storeKeys, params, callbacks) {
1756
1758
  var source = this._getDataSource(),
1757
1759
  isArray = SC.typeOf(recordTypes) === SC.T_ARRAY,
1758
- hasCallbackArray = SC.typeOf(callbacks) === SC.T_ARRAY,
1759
- retCreate= [], retUpdate= [], retDestroy = [],
1760
+ hasCallbackArray = SC.typeOf(callbacks) === SC.T_ARRAY,
1761
+ retCreate= [], retUpdate= [], retDestroy = [],
1760
1762
  rev = SC.Store.generateStoreKey(),
1761
1763
  K = SC.Record,
1762
1764
  recordType, idx, storeKey, status, key, ret, len, callback;
@@ -1769,9 +1771,9 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
1769
1771
  }
1770
1772
 
1771
1773
  len = storeKeys ? storeKeys.get('length') : (ids ? ids.get('length') : 0);
1772
-
1774
+
1773
1775
  for(idx=0;idx<len;idx++) {
1774
-
1776
+
1775
1777
  // collect store key
1776
1778
  if (storeKeys) {
1777
1779
  storeKey = storeKeys[idx];
@@ -1780,16 +1782,16 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
1780
1782
  else recordType = recordTypes;
1781
1783
  storeKey = recordType.storeKeyFor(ids[idx]);
1782
1784
  }
1783
-
1785
+
1784
1786
  //collect the callback
1785
1787
  callback = hasCallbackArray ? callbacks[idx] : callbacks;
1786
-
1788
+
1787
1789
  // collect status and process
1788
1790
  status = this.readStatus(storeKey);
1789
-
1791
+
1790
1792
  if ((status == K.EMPTY) || (status == K.ERROR)) {
1791
1793
  throw K.NOT_FOUND_ERROR ;
1792
- }
1794
+ }
1793
1795
  else {
1794
1796
  if(status==K.READY_NEW) {
1795
1797
  this.writeStatus(storeKey, K.BUSY_CREATING);
@@ -1809,16 +1811,16 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
1809
1811
  } else if (status==K.DESTROYED_CLEAN) {
1810
1812
  this.dataHashDidChange(storeKey, rev, YES);
1811
1813
  }
1812
- // ignore K.READY_CLEAN, K.BUSY_LOADING, K.BUSY_CREATING, K.BUSY_COMMITTING,
1814
+ // ignore K.READY_CLEAN, K.BUSY_LOADING, K.BUSY_CREATING, K.BUSY_COMMITTING,
1813
1815
  // K.BUSY_REFRESH_CLEAN, K_BUSY_REFRESH_DIRTY, KBUSY_DESTROYING
1814
1816
  }
1815
1817
  }
1816
-
1818
+
1817
1819
  // now commit storekeys to dataSource
1818
1820
  if (source && (len>0 || params)) {
1819
1821
  ret = source.commitRecords.call(source, this, retCreate, retUpdate, retDestroy, params);
1820
1822
  }
1821
-
1823
+
1822
1824
  //remove all commited changes from changelog
1823
1825
  if (ret && !recordTypes && !ids) {
1824
1826
  if (storeKeys === this.changelog) {
@@ -1832,13 +1834,13 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
1832
1834
  },
1833
1835
 
1834
1836
  /**
1835
- Commits the passed store key or id. Based on the current state of the
1837
+ Commits the passed store key or id. Based on the current state of the
1836
1838
  record, this will ask the data source to perform the appropriate action
1837
1839
  on the store key.
1838
-
1839
- You have to pass either the id or the storeKey otherwise it will return
1840
+
1841
+ You have to pass either the id or the storeKey otherwise it will return
1840
1842
  NO.
1841
-
1843
+
1842
1844
  @param {SC.Record} recordType the expected record type
1843
1845
  @param {String} id the id of the record to commit
1844
1846
  @param {Number} storeKey the storeKey of the record to commit
@@ -1859,17 +1861,17 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
1859
1861
  array[0] = id;
1860
1862
  id = array;
1861
1863
  }
1862
-
1864
+
1863
1865
  ret = this.commitRecords(recordType, id, storeKey, params, callback);
1864
1866
  array.length = 0 ;
1865
1867
  return ret;
1866
1868
  },
1867
-
1869
+
1868
1870
  /**
1869
- Cancels an inflight request for the passed records. Depending on the
1870
- server implementation, this could cancel an entire request, causing
1871
+ Cancels an inflight request for the passed records. Depending on the
1872
+ server implementation, this could cancel an entire request, causing
1871
1873
  other records to also transition their current state.
1872
-
1874
+
1873
1875
  @param {SC.Record|Array} recordTypes class or array of classes
1874
1876
  @param {Array} ids ids to destroy
1875
1877
  @param {Array} storeKeys (optional) store keys to destroy
@@ -1881,22 +1883,22 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
1881
1883
  K = SC.Record,
1882
1884
  ret = [],
1883
1885
  status, len, idx, id, recordType, storeKey;
1884
-
1886
+
1885
1887
  len = (storeKeys === undefined) ? ids.length : storeKeys.length;
1886
1888
  for(idx=0;idx<len;idx++) {
1887
1889
  if (isArray) recordType = recordTypes[idx] || SC.Record;
1888
1890
  else recordType = recordTypes || SC.Record;
1889
-
1891
+
1890
1892
  id = ids ? ids[idx] : undefined ;
1891
-
1893
+
1892
1894
  if(storeKeys===undefined){
1893
1895
  storeKey = recordType.storeKeyFor(id);
1894
1896
  }else{
1895
- storeKey = storeKeys ? storeKeys[idx] : undefined ;
1897
+ storeKey = storeKeys ? storeKeys[idx] : undefined ;
1896
1898
  }
1897
1899
  if(storeKey) {
1898
1900
  status = this.readStatus(storeKey);
1899
-
1901
+
1900
1902
  if ((status == K.EMPTY) || (status == K.ERROR)) {
1901
1903
  throw K.NOT_FOUND_ERROR ;
1902
1904
  }
@@ -1904,17 +1906,17 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
1904
1906
  this._cancelCallback(storeKey);
1905
1907
  }
1906
1908
  }
1907
-
1909
+
1908
1910
  if (source) source.cancel.call(source, this, ret);
1909
-
1911
+
1910
1912
  return this ;
1911
1913
  },
1912
1914
 
1913
1915
  /**
1914
- Cancels an inflight request for the passed record. Depending on the
1915
- server implementation, this could cancel an entire request, causing
1916
+ Cancels an inflight request for the passed record. Depending on the
1917
+ server implementation, this could cancel an entire request, causing
1916
1918
  other records to also transition their current state.
1917
-
1919
+
1918
1920
  @param {SC.Record|Array} recordTypes class or array of classes
1919
1921
  @param {Array} ids ids to destroy
1920
1922
  @param {Array} storeKeys (optional) store keys to destroy
@@ -1923,7 +1925,7 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
1923
1925
  cancelRecord: function(recordType, id, storeKey) {
1924
1926
  var array = this._TMP_RETRIEVE_ARRAY,
1925
1927
  ret ;
1926
-
1928
+
1927
1929
  if (storeKey !== undefined) {
1928
1930
  array[0] = storeKey;
1929
1931
  storeKey = array;
@@ -1932,32 +1934,32 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
1932
1934
  array[0] = id;
1933
1935
  id = array;
1934
1936
  }
1935
-
1937
+
1936
1938
  ret = this.cancelRecords(recordType, id, storeKey);
1937
1939
  array.length = 0 ;
1938
1940
  return this;
1939
1941
  },
1940
1942
 
1941
- /**
1942
- Convenience method can be called by the store or other parts of your
1943
+ /**
1944
+ Convenience method can be called by the store or other parts of your
1943
1945
  application to load a record into the store. This method will take a
1944
- recordType and a data hashes and either add or update the
1945
- record in the store.
1946
-
1946
+ recordType and a data hashes and either add or update the
1947
+ record in the store.
1948
+
1947
1949
  The loaded records will be in an `SC.Record.READY_CLEAN` state, indicating
1948
- they were loaded from the data source and do not need to be committed
1950
+ they were loaded from the data source and do not need to be committed
1949
1951
  back before changing.
1950
-
1951
- This method will check the state of the storeKey and call either
1952
- `pushRetrieve()` or `dataSourceDidComplete()`. The standard state constraints
1952
+
1953
+ This method will check the state of the storeKey and call either
1954
+ `pushRetrieve()` or `dataSourceDidComplete()`. The standard state constraints
1953
1955
  for these methods apply here.
1954
-
1956
+
1955
1957
  The return value will be the `storeKey` used for the push. This is often
1956
1958
  convenient to pass into `loadQuery()`, if you are fetching a remote query.
1957
-
1958
- If you are upgrading from a pre SproutCore 1.0 application, this method
1959
+
1960
+ If you are upgrading from a pre SproutCore 1.0 application, this method
1959
1961
  is the closest to the old `updateRecord()`.
1960
-
1962
+
1961
1963
  @param {SC.Record} recordType the record type
1962
1964
  @param {Array} dataHash to update
1963
1965
  @param {Array} id optional. if not passed lookup on the hash
@@ -1966,44 +1968,44 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
1966
1968
  loadRecord: function(recordType, dataHash, id) {
1967
1969
  var K = SC.Record,
1968
1970
  ret, primaryKey, storeKey;
1969
-
1971
+
1970
1972
  // save lookup info
1971
1973
  recordType = recordType || SC.Record;
1972
1974
  primaryKey = recordType.prototype.primaryKey;
1973
-
1974
-
1975
+
1976
+
1975
1977
  // push each record
1976
1978
  id = id || dataHash[primaryKey];
1977
1979
  ret = storeKey = recordType.storeKeyFor(id); // needed to cache
1978
-
1980
+
1979
1981
  if (this.readStatus(storeKey) & K.BUSY) {
1980
1982
  this.dataSourceDidComplete(storeKey, dataHash, id);
1981
1983
  } else this.pushRetrieve(recordType, id, dataHash, storeKey);
1982
-
1984
+
1983
1985
  // return storeKey
1984
1986
  return ret ;
1985
1987
  },
1986
-
1987
- /**
1988
- Convenience method can be called by the store or other parts of your
1988
+
1989
+ /**
1990
+ Convenience method can be called by the store or other parts of your
1989
1991
  application to load records into the store. This method will take a
1990
- recordType and an array of data hashes and either add or update the
1991
- record in the store.
1992
-
1992
+ recordType and an array of data hashes and either add or update the
1993
+ record in the store.
1994
+
1993
1995
  The loaded records will be in an `SC.Record.READY_CLEAN` state, indicating
1994
- they were loaded from the data source and do not need to be committed
1996
+ they were loaded from the data source and do not need to be committed
1995
1997
  back before changing.
1996
-
1997
- This method will check the state of each storeKey and call either
1998
- `pushRetrieve()` or `dataSourceDidComplete()`. The standard state
1998
+
1999
+ This method will check the state of each storeKey and call either
2000
+ `pushRetrieve()` or `dataSourceDidComplete()`. The standard state
1999
2001
  constraints for these methods apply here.
2000
-
2002
+
2001
2003
  The return value will be the storeKeys used for each push. This is often
2002
2004
  convenient to pass into `loadQuery()`, if you are fetching a remote query.
2003
-
2004
- If you are upgrading from a pre SproutCore 1.0 application, this method
2005
+
2006
+ If you are upgrading from a pre SproutCore 1.0 application, this method
2005
2007
  is the closest to the old `updateRecords()`.
2006
-
2008
+
2007
2009
  @param {SC.Record} recordTypes the record type or array of record types
2008
2010
  @param {Array} dataHashes array of data hashes to update
2009
2011
  @param {Array} ids optional array of ids. if not passed lookup on hashes
@@ -2015,13 +2017,13 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
2015
2017
  ret = [],
2016
2018
  K = SC.Record,
2017
2019
  recordType, id, primaryKey, idx, dataHash, storeKey;
2018
-
2020
+
2019
2021
  // save lookup info
2020
2022
  if (!isArray) {
2021
2023
  recordType = recordTypes || SC.Record;
2022
2024
  primaryKey = recordType.prototype.primaryKey ;
2023
2025
  }
2024
-
2026
+
2025
2027
  // push each record
2026
2028
  for(idx=0;idx<len;idx++) {
2027
2029
  dataHash = dataHashes.objectAt(idx);
@@ -2031,9 +2033,9 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
2031
2033
  }
2032
2034
  id = (ids) ? ids.objectAt(idx) : dataHash[primaryKey];
2033
2035
  ret[idx] = this.loadRecord(recordType, dataHash, id);
2034
-
2036
+
2035
2037
  }
2036
-
2038
+
2037
2039
  // return storeKeys
2038
2040
  return ret ;
2039
2041
  },
@@ -2042,7 +2044,7 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
2042
2044
  Returns the `SC.Error` object associated with a specific record.
2043
2045
 
2044
2046
  @param {Number} storeKey The store key of the record.
2045
-
2047
+
2046
2048
  @returns {SC.Error} SC.Error or undefined if no error associated with the record.
2047
2049
  */
2048
2050
  readError: function(storeKey) {
@@ -2054,91 +2056,91 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
2054
2056
  Returns the `SC.Error` object associated with a specific query.
2055
2057
 
2056
2058
  @param {SC.Query} query The SC.Query with which the error is associated.
2057
-
2059
+
2058
2060
  @returns {SC.Error} SC.Error or undefined if no error associated with the query.
2059
2061
  */
2060
2062
  readQueryError: function(query) {
2061
2063
  var errors = this.queryErrors ;
2062
2064
  return errors ? errors[SC.guidFor(query)] : undefined ;
2063
2065
  },
2064
-
2066
+
2065
2067
  // ..........................................................
2066
2068
  // DATA SOURCE CALLBACKS
2067
- //
2069
+ //
2068
2070
  // Mathods called by the data source on the store
2069
2071
 
2070
2072
  /**
2071
- Called by a `dataSource` when it cancels an inflight operation on a
2073
+ Called by a `dataSource` when it cancels an inflight operation on a
2072
2074
  record. This will transition the record back to it non-inflight state.
2073
-
2075
+
2074
2076
  @param {Number} storeKey record store key to cancel
2075
- @returns {SC.Store} reciever
2077
+ @returns {SC.Store} receiver
2076
2078
  */
2077
2079
  dataSourceDidCancel: function(storeKey) {
2078
- var status = this.readStatus(storeKey),
2080
+ var status = this.readStatus(storeKey),
2079
2081
  K = SC.Record;
2080
-
2082
+
2081
2083
  // EMPTY, ERROR, READY_CLEAN, READY_NEW, READY_DIRTY, DESTROYED_CLEAN,
2082
2084
  // DESTROYED_DIRTY
2083
2085
  if (!(status & K.BUSY)) {
2084
2086
  throw K.BAD_STATE_ERROR; // should never be called in this state
2085
2087
  }
2086
-
2088
+
2087
2089
  // otherwise, determine proper state transition
2088
2090
  switch(status) {
2089
2091
  case K.BUSY_LOADING:
2090
2092
  status = K.EMPTY;
2091
2093
  break ;
2092
-
2094
+
2093
2095
  case K.BUSY_CREATING:
2094
2096
  status = K.READY_NEW;
2095
2097
  break;
2096
-
2098
+
2097
2099
  case K.BUSY_COMMITTING:
2098
2100
  status = K.READY_DIRTY ;
2099
2101
  break;
2100
-
2102
+
2101
2103
  case K.BUSY_REFRESH_CLEAN:
2102
2104
  status = K.READY_CLEAN;
2103
2105
  break;
2104
-
2106
+
2105
2107
  case K.BUSY_REFRESH_DIRTY:
2106
2108
  status = K.READY_DIRTY ;
2107
2109
  break ;
2108
-
2110
+
2109
2111
  case K.BUSY_DESTROYING:
2110
2112
  status = K.DESTROYED_DIRTY ;
2111
2113
  break;
2112
-
2114
+
2113
2115
  default:
2114
2116
  throw K.BAD_STATE_ERROR ;
2115
- }
2117
+ }
2116
2118
  this.writeStatus(storeKey, status) ;
2117
2119
  this.dataHashDidChange(storeKey, null, YES);
2118
2120
  this._cancelCallback(storeKey);
2119
-
2121
+
2120
2122
  return this ;
2121
2123
  },
2122
-
2124
+
2123
2125
  /**
2124
2126
  Called by a data source when it creates or commits a record. Passing an
2125
- optional id will remap the `storeKey` to the new record id. This is
2127
+ optional id will remap the `storeKey` to the new record id. This is
2126
2128
  required when you commit a record that does not have an id yet.
2127
-
2129
+
2128
2130
  @param {Number} storeKey record store key to change to READY_CLEAN state
2129
2131
  @param {Hash} dataHash optional data hash to replace current hash
2130
2132
  @param {Object} newId optional new id to replace the old one
2131
- @returns {SC.Store} reciever
2133
+ @returns {SC.Store} receiver
2132
2134
  */
2133
2135
  dataSourceDidComplete: function(storeKey, dataHash, newId) {
2134
2136
  var status = this.readStatus(storeKey), K = SC.Record, statusOnly;
2135
-
2137
+
2136
2138
  // EMPTY, ERROR, READY_CLEAN, READY_NEW, READY_DIRTY, DESTROYED_CLEAN,
2137
2139
  // DESTROYED_DIRTY
2138
2140
  if (!(status & K.BUSY)) {
2139
2141
  throw K.BAD_STATE_ERROR; // should never be called in this state
2140
2142
  }
2141
-
2143
+
2142
2144
  // otherwise, determine proper state transition
2143
2145
  if(status===K.BUSY_DESTROYING) {
2144
2146
  throw K.BAD_STATE_ERROR ;
@@ -2147,7 +2149,7 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
2147
2149
  this.writeStatus(storeKey, status) ;
2148
2150
  if (dataHash) this.writeDataHash(storeKey, dataHash, status) ;
2149
2151
  if (newId) SC.Store.replaceIdFor(storeKey, newId);
2150
-
2152
+
2151
2153
  statusOnly = dataHash || newId ? NO : YES;
2152
2154
  this.dataHashDidChange(storeKey, null, statusOnly);
2153
2155
 
@@ -2158,16 +2160,16 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
2158
2160
  }
2159
2161
  //update callbacks
2160
2162
  this._retreiveCallbackForStoreKey(storeKey);
2161
-
2163
+
2162
2164
  return this ;
2163
2165
  },
2164
-
2166
+
2165
2167
  /**
2166
2168
  Called by a data source when it has destroyed a record. This will
2167
2169
  transition the record to the proper state.
2168
-
2170
+
2169
2171
  @param {Number} storeKey record store key to cancel
2170
- @returns {SC.Store} reciever
2172
+ @returns {SC.Store} receiver
2171
2173
  */
2172
2174
  dataSourceDidDestroy: function(storeKey) {
2173
2175
  var status = this.readStatus(storeKey), K = SC.Record;
@@ -2180,7 +2182,7 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
2180
2182
  // otherwise, determine proper state transition
2181
2183
  else{
2182
2184
  status = K.DESTROYED_CLEAN ;
2183
- }
2185
+ }
2184
2186
  this.removeDataHash(storeKey, status) ;
2185
2187
  this.dataHashDidChange(storeKey);
2186
2188
 
@@ -2197,10 +2199,10 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
2197
2199
 
2198
2200
  /**
2199
2201
  Converts the passed record into an error object.
2200
-
2202
+
2201
2203
  @param {Number} storeKey record store key to error
2202
2204
  @param {SC.Error} error [optional] an SC.Error instance to associate with storeKey
2203
- @returns {SC.Store} reciever
2205
+ @returns {SC.Store} receiver
2204
2206
  */
2205
2207
  dataSourceDidError: function(storeKey, error) {
2206
2208
  var status = this.readStatus(storeKey), errors = this.recordErrors, K = SC.Record;
@@ -2233,44 +2235,44 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
2233
2235
 
2234
2236
  // ..........................................................
2235
2237
  // PUSH CHANGES FROM DATA SOURCE
2236
- //
2237
-
2238
+ //
2239
+
2238
2240
  /**
2239
- Call by the data source whenever you want to push new data out of band
2241
+ Call by the data source whenever you want to push new data out of band
2240
2242
  into the store.
2241
-
2243
+
2242
2244
  @param {Class} recordType the SC.Record subclass
2243
2245
  @param {Object} id the record id or null
2244
2246
  @param {Hash} dataHash data hash to load
2245
- @param {Number} storeKey optional store key.
2247
+ @param {Number} storeKey optional store key.
2246
2248
  @returns {Number|Boolean} storeKey if push was allowed, NO if not
2247
2249
  */
2248
2250
  pushRetrieve: function(recordType, id, dataHash, storeKey) {
2249
2251
  var K = SC.Record, status;
2250
-
2252
+
2251
2253
  if(storeKey===undefined) storeKey = recordType.storeKeyFor(id);
2252
2254
  status = this.readStatus(storeKey);
2253
2255
  if(status==K.EMPTY || status==K.ERROR || status==K.READY_CLEAN || status==K.DESTROYED_CLEAN) {
2254
-
2256
+
2255
2257
  status = K.READY_CLEAN;
2256
2258
  if(dataHash===undefined) this.writeStatus(storeKey, status) ;
2257
2259
  else this.writeDataHash(storeKey, dataHash, status) ;
2258
2260
 
2259
2261
  this.dataHashDidChange(storeKey);
2260
-
2262
+
2261
2263
  return storeKey;
2262
2264
  }
2263
2265
  //conflicted (ready)
2264
2266
  return NO;
2265
2267
  },
2266
-
2268
+
2267
2269
  /**
2268
- Call by the data source whenever you want to push a deletion into the
2270
+ Call by the data source whenever you want to push a deletion into the
2269
2271
  store.
2270
-
2272
+
2271
2273
  @param {Class} recordType the SC.Record subclass
2272
2274
  @param {Object} id the record id or null
2273
- @param {Number} storeKey optional store key.
2275
+ @param {Number} storeKey optional store key.
2274
2276
  @returns {Number|Boolean} storeKey if push was allowed, NO if not
2275
2277
  */
2276
2278
  pushDestroy: function(recordType, id, storeKey) {
@@ -2291,9 +2293,9 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
2291
2293
  },
2292
2294
 
2293
2295
  /**
2294
- Call by the data source whenever you want to push an error into the
2296
+ Call by the data source whenever you want to push an error into the
2295
2297
  store.
2296
-
2298
+
2297
2299
  @param {Class} recordType the SC.Record subclass
2298
2300
  @param {Object} id the record id or null
2299
2301
  @param {SC.Error} error [optional] an SC.Error instance to associate with id or storeKey
@@ -2308,13 +2310,13 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
2308
2310
 
2309
2311
  if(status==K.EMPTY || status==K.ERROR || status==K.READY_CLEAN || status==K.DESTROYED_CLEAN){
2310
2312
  status = K.ERROR;
2311
-
2313
+
2312
2314
  // Add the error to the array of record errors (for lookup later on if necessary).
2313
2315
  if (error && error.isError) {
2314
2316
  if (!errors) errors = this.recordErrors = [];
2315
2317
  errors[storeKey] = error;
2316
2318
  }
2317
-
2319
+
2318
2320
  this.writeStatus(storeKey, status) ;
2319
2321
  this.dataHashDidChange(storeKey, null, YES);
2320
2322
  return storeKey;
@@ -2322,29 +2324,29 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
2322
2324
  //conflicted (error)
2323
2325
  return NO;
2324
2326
  },
2325
-
2327
+
2326
2328
  // ..........................................................
2327
2329
  // FETCH CALLBACKS
2328
- //
2329
-
2330
+ //
2331
+
2330
2332
  // **NOTE**: although these method works on RecordArray instances right now.
2331
2333
  // They could be optimized to actually share query results between nested
2332
- // stores. This is why these methods are implemented here instead of
2334
+ // stores. This is why these methods are implemented here instead of
2333
2335
  // directly on `Query` or `RecordArray` objects.
2334
-
2336
+
2335
2337
  /**
2336
2338
  Sets the passed array of storeKeys as the new data for the query. You
2337
2339
  can call this at any time for a remote query to update its content. If
2338
2340
  you want to use incremental loading, then pass a `SparseArray` object.
2339
-
2341
+
2340
2342
  If the query you pass is not a REMOTE query, then this method will raise
2341
- an exception. This will also implicitly transition the query state to
2343
+ an exception. This will also implicitly transition the query state to
2342
2344
  `SC.Record.READY`.
2343
-
2345
+
2344
2346
  If you called `loadRecords()` before to load the actual content, you can
2345
2347
  call this method with the return value of that method to actually set the
2346
2348
  storeKeys on the result.
2347
-
2349
+
2348
2350
  @param {SC.Query} query the query you are loading. must be remote.
2349
2351
  @param {SC.Array} storeKeys array of store keys
2350
2352
  @returns {SC.Store} receiver
@@ -2357,75 +2359,75 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
2357
2359
  var recArray = this._findQuery(query, YES, NO);
2358
2360
  if (recArray) recArray.set('storeKeys', storeKeys);
2359
2361
  this.dataSourceDidFetchQuery(query);
2360
-
2362
+
2361
2363
  return this ;
2362
2364
  },
2363
-
2365
+
2364
2366
  /**
2365
- Called by your data source whenever you finish fetching the results of a
2367
+ Called by your data source whenever you finish fetching the results of a
2366
2368
  query. This will put the query into a READY state if it was loading.
2367
-
2368
- Note that if the query is a REMOTE query, then you must separately load
2369
- the results into the query using `loadQueryResults()`. If the query is
2370
- LOCAL, then the query will update automatically with any new records you
2369
+
2370
+ Note that if the query is a REMOTE query, then you must separately load
2371
+ the results into the query using `loadQueryResults()`. If the query is
2372
+ LOCAL, then the query will update automatically with any new records you
2371
2373
  added to the store.
2372
-
2374
+
2373
2375
  @param {SC.Query} query the query you fetched
2374
2376
  @returns {SC.Store} receiver
2375
2377
  */
2376
2378
  dataSourceDidFetchQuery: function(query) {
2377
2379
  return this._scstore_dataSourceDidFetchQuery(query, YES);
2378
2380
  },
2379
-
2381
+
2380
2382
  _scstore_dataSourceDidFetchQuery: function(query, createIfNeeded) {
2381
2383
  var recArray = this._findQuery(query, createIfNeeded, NO),
2382
2384
  nestedStores = this.get('nestedStores'),
2383
2385
  loc = nestedStores ? nestedStores.get('length') : 0;
2384
-
2386
+
2385
2387
  // fix query if needed
2386
2388
  if (recArray) recArray.storeDidFetchQuery(query);
2387
-
2389
+
2388
2390
  // notify nested stores
2389
2391
  while(--loc >= 0) {
2390
2392
  nestedStores[loc]._scstore_dataSourceDidFetchQuery(query, NO);
2391
2393
  }
2392
-
2394
+
2393
2395
  return this ;
2394
2396
  },
2395
-
2397
+
2396
2398
  /**
2397
2399
  Called by your data source if it cancels fetching the results of a query.
2398
2400
  This will put any RecordArray's back into its original state (READY or
2399
2401
  EMPTY).
2400
-
2402
+
2401
2403
  @param {SC.Query} query the query you cancelled
2402
2404
  @returns {SC.Store} receiver
2403
2405
  */
2404
2406
  dataSourceDidCancelQuery: function(query) {
2405
2407
  return this._scstore_dataSourceDidCancelQuery(query, YES);
2406
2408
  },
2407
-
2409
+
2408
2410
  _scstore_dataSourceDidCancelQuery: function(query, createIfNeeded) {
2409
2411
  var recArray = this._findQuery(query, createIfNeeded, NO),
2410
2412
  nestedStores = this.get('nestedStores'),
2411
2413
  loc = nestedStores ? nestedStores.get('length') : 0;
2412
-
2414
+
2413
2415
  // fix query if needed
2414
2416
  if (recArray) recArray.storeDidCancelQuery(query);
2415
-
2417
+
2416
2418
  // notify nested stores
2417
2419
  while(--loc >= 0) {
2418
2420
  nestedStores[loc]._scstore_dataSourceDidCancelQuery(query, NO);
2419
2421
  }
2420
-
2422
+
2421
2423
  return this ;
2422
2424
  },
2423
-
2425
+
2424
2426
  /**
2425
2427
  Called by your data source if it encountered an error loading the query.
2426
2428
  This will put the query into an error state until you try to refresh it
2427
2429
  again.
2428
-
2430
+
2429
2431
  @param {SC.Query} query the query with the error
2430
2432
  @param {SC.Error} error [optional] an SC.Error instance to associate with query
2431
2433
  @returns {SC.Store} receiver
@@ -2457,18 +2459,18 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
2457
2459
 
2458
2460
  return this ;
2459
2461
  },
2460
-
2462
+
2461
2463
  // ..........................................................
2462
2464
  // INTERNAL SUPPORT
2463
- //
2464
-
2465
+ //
2466
+
2465
2467
  /** @private */
2466
2468
  init: function() {
2467
2469
  sc_super();
2468
2470
  this.reset();
2469
2471
  },
2470
-
2471
-
2472
+
2473
+
2472
2474
  toString: function() {
2473
2475
  // Include the name if the client has specified one.
2474
2476
  var name = this.get('name');
@@ -2484,32 +2486,32 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
2484
2486
 
2485
2487
  // ..........................................................
2486
2488
  // PRIMARY KEY CONVENIENCE METHODS
2487
- //
2489
+ //
2488
2490
 
2489
- /**
2491
+ /**
2490
2492
  Given a `storeKey`, return the `primaryKey`.
2491
-
2493
+
2492
2494
  @param {Number} storeKey the store key
2493
2495
  @returns {String} primaryKey value
2494
2496
  */
2495
2497
  idFor: function(storeKey) {
2496
2498
  return SC.Store.idFor(storeKey);
2497
2499
  },
2498
-
2500
+
2499
2501
  /**
2500
2502
  Given a storeKey, return the recordType.
2501
-
2503
+
2502
2504
  @param {Number} storeKey the store key
2503
2505
  @returns {SC.Record} record instance
2504
2506
  */
2505
2507
  recordTypeFor: function(storeKey) {
2506
2508
  return SC.Store.recordTypeFor(storeKey) ;
2507
2509
  },
2508
-
2510
+
2509
2511
  /**
2510
2512
  Given a `recordType` and `primaryKey`, find the `storeKey`. If the
2511
2513
  `primaryKey` has not been assigned a `storeKey` yet, it will be added.
2512
-
2514
+
2513
2515
  @param {SC.Record} recordType the record type
2514
2516
  @param {String} primaryKey the primary key
2515
2517
  @returns {Number} storeKey
@@ -2517,12 +2519,12 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
2517
2519
  storeKeyFor: function(recordType, primaryKey) {
2518
2520
  return recordType.storeKeyFor(primaryKey);
2519
2521
  },
2520
-
2522
+
2521
2523
  /**
2522
2524
  Given a `primaryKey` value for the record, returns the associated
2523
2525
  `storeKey`. As opposed to `storeKeyFor()` however, this method
2524
2526
  will **NOT** generate a new `storeKey` but returned `undefined`.
2525
-
2527
+
2526
2528
  @param {SC.Record} recordType the record type
2527
2529
  @param {String} primaryKey the primary key
2528
2530
  @returns {Number} a storeKey.
@@ -2530,56 +2532,56 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
2530
2532
  storeKeyExists: function(recordType, primaryKey) {
2531
2533
  return recordType.storeKeyExists(primaryKey);
2532
2534
  },
2533
-
2535
+
2534
2536
  /**
2535
2537
  Finds all `storeKey`s of a certain record type in this store
2536
2538
  and returns an array.
2537
-
2539
+
2538
2540
  @param {SC.Record} recordType
2539
2541
  @returns {Array} set of storeKeys
2540
2542
  */
2541
2543
  storeKeysFor: function(recordType) {
2542
- var ret = [],
2544
+ var ret = [],
2543
2545
  isEnum = recordType && recordType.isEnumerable,
2544
2546
  recType, storeKey, isMatch ;
2545
-
2547
+
2546
2548
  if (!this.statuses) return ret;
2547
2549
  for(storeKey in SC.Store.recordTypesByStoreKey) {
2548
2550
  recType = SC.Store.recordTypesByStoreKey[storeKey];
2549
-
2551
+
2550
2552
  // if same record type and this store has it
2551
2553
  if (isEnum) isMatch = recordType.contains(recType);
2552
2554
  else isMatch = recType === recordType;
2553
-
2555
+
2554
2556
  if(isMatch && this.statuses[storeKey]) ret.push(parseInt(storeKey, 10));
2555
2557
  }
2556
-
2558
+
2557
2559
  return ret;
2558
2560
  },
2559
-
2561
+
2560
2562
  /**
2561
2563
  Finds all `storeKey`s in this store
2562
2564
  and returns an array.
2563
-
2565
+
2564
2566
  @returns {Array} set of storeKeys
2565
2567
  */
2566
2568
  storeKeys: function() {
2567
2569
  var ret = [], storeKey;
2568
2570
  if(!this.statuses) return ret;
2569
-
2571
+
2570
2572
  for(storeKey in this.statuses) {
2571
2573
  // if status is not empty
2572
2574
  if(this.statuses[storeKey] != SC.Record.EMPTY) {
2573
2575
  ret.push(parseInt(storeKey, 10));
2574
2576
  }
2575
2577
  }
2576
-
2578
+
2577
2579
  return ret;
2578
2580
  },
2579
-
2581
+
2580
2582
  /**
2581
2583
  Returns string representation of a `storeKey`, with status.
2582
-
2584
+
2583
2585
  @param {Number} storeKey
2584
2586
  @returns {String}
2585
2587
  */
@@ -2587,54 +2589,54 @@ SC.Store = SC.Object.extend( /** @scope SC.Store.prototype */ {
2587
2589
  var rec = this.materializeRecord(storeKey);
2588
2590
  return rec.statusString();
2589
2591
  }
2590
-
2592
+
2591
2593
  }) ;
2592
2594
 
2593
2595
  SC.Store.mixin(/** @scope SC.Store.prototype */{
2594
-
2596
+
2595
2597
  /**
2596
2598
  Standard error raised if you try to commit changes from a nested store
2597
2599
  and there is a conflict.
2598
-
2600
+
2599
2601
  @type Error
2600
2602
  */
2601
2603
  CHAIN_CONFLICT_ERROR: new Error("Nested Store Conflict"),
2602
-
2604
+
2603
2605
  /**
2604
- Standard error if you try to perform an operation on a nested store
2606
+ Standard error if you try to perform an operation on a nested store
2605
2607
  without a parent.
2606
-
2608
+
2607
2609
  @type Error
2608
2610
  */
2609
2611
  NO_PARENT_STORE_ERROR: new Error("Parent Store Required"),
2610
-
2612
+
2611
2613
  /**
2612
2614
  Standard error if you try to perform an operation on a nested store that
2613
2615
  is only supported in root stores.
2614
-
2616
+
2615
2617
  @type Error
2616
2618
  */
2617
2619
  NESTED_STORE_UNSUPPORTED_ERROR: new Error("Unsupported In Nested Store"),
2618
-
2620
+
2619
2621
  /**
2620
2622
  Standard error if you try to retrieve a record in a nested store that is
2621
2623
  dirty. (This is allowed on the main store, but not in nested stores.)
2622
-
2624
+
2623
2625
  @type Error
2624
2626
  */
2625
2627
  NESTED_STORE_RETRIEVE_DIRTY_ERROR: new Error("Cannot Retrieve Dirty Record in Nested Store"),
2626
2628
 
2627
2629
  /**
2628
2630
  Data hash state indicates the data hash is currently editable
2629
-
2631
+
2630
2632
  @type String
2631
2633
  */
2632
2634
  EDITABLE: 'editable',
2633
-
2635
+
2634
2636
  /**
2635
- Data hash state indicates the hash no longer tracks changes from a
2637
+ Data hash state indicates the hash no longer tracks changes from a
2636
2638
  parent store, but it is not editable.
2637
-
2639
+
2638
2640
  @type String
2639
2641
  */
2640
2642
  LOCKED: 'locked',
@@ -2642,88 +2644,88 @@ SC.Store.mixin(/** @scope SC.Store.prototype */{
2642
2644
  /**
2643
2645
  Data hash state indicates the hash is tracking changes from the parent
2644
2646
  store and is not editable.
2645
-
2647
+
2646
2648
  @type String
2647
2649
  */
2648
2650
  INHERITED: 'inherited',
2649
-
2651
+
2650
2652
  /** @private
2651
2653
  This array maps all storeKeys to primary keys. You will not normally
2652
- access this method directly. Instead use the `idFor()` and
2654
+ access this method directly. Instead use the `idFor()` and
2653
2655
  `storeKeyFor()` methods on `SC.Record`.
2654
2656
  */
2655
2657
  idsByStoreKey: [],
2656
-
2658
+
2657
2659
  /** @private
2658
2660
  Maps all `storeKey`s to a `recordType`. Once a `storeKey` is associated
2659
2661
  with a `primaryKey` and `recordType` that remains constant throughout the
2660
2662
  lifetime of the application.
2661
2663
  */
2662
2664
  recordTypesByStoreKey: {},
2663
-
2665
+
2664
2666
  /** @private
2665
2667
  Maps some `storeKeys` to query instance. Once a `storeKey` is associated
2666
- with a query instance, that remains constant through the lifetime of the
2667
- application. If a `Query` is destroyed, it will remove itself from this
2668
+ with a query instance, that remains constant through the lifetime of the
2669
+ application. If a `Query` is destroyed, it will remove itself from this
2668
2670
  list.
2669
-
2671
+
2670
2672
  Don't access this directly. Use queryFor().
2671
2673
  */
2672
2674
  queriesByStoreKey: [],
2673
-
2675
+
2674
2676
  /** @private
2675
2677
  The next store key to allocate. A storeKey must always be greater than 0
2676
2678
  */
2677
2679
  nextStoreKey: 1,
2678
-
2680
+
2679
2681
  /**
2680
2682
  Generates a new store key for use.
2681
-
2683
+
2682
2684
  @type Number
2683
2685
  */
2684
2686
  generateStoreKey: function() { return this.nextStoreKey++; },
2685
-
2686
- /**
2687
+
2688
+ /**
2687
2689
  Given a `storeKey` returns the `primaryKey` associated with the key.
2688
2690
  If no `primaryKey` is associated with the `storeKey`, returns `null`.
2689
-
2691
+
2690
2692
  @param {Number} storeKey the store key
2691
2693
  @returns {String} the primary key or null
2692
2694
  */
2693
2695
  idFor: function(storeKey) {
2694
2696
  return this.idsByStoreKey[storeKey] ;
2695
2697
  },
2696
-
2698
+
2697
2699
  /**
2698
2700
  Given a `storeKey`, returns the query object associated with the key. If
2699
2701
  no query is associated with the `storeKey`, returns `null`.
2700
-
2702
+
2701
2703
  @param {Number} storeKey the store key
2702
2704
  @returns {SC.Query} query query object
2703
2705
  */
2704
2706
  queryFor: function(storeKey) {
2705
- return this.queriesByStoreKey[storeKey];
2707
+ return this.queriesByStoreKey[storeKey];
2706
2708
  },
2707
-
2709
+
2708
2710
  /**
2709
2711
  Given a `storeKey` returns the `SC.Record` class associated with the key.
2710
2712
  If no record type is associated with the store key, returns `null`.
2711
-
2713
+
2712
2714
  The SC.Record class will only be found if you have already called
2713
2715
  storeKeyFor() on the record.
2714
-
2716
+
2715
2717
  @param {Number} storeKey the store key
2716
2718
  @returns {SC.Record} the record type
2717
2719
  */
2718
2720
  recordTypeFor: function(storeKey) {
2719
2721
  return this.recordTypesByStoreKey[storeKey];
2720
2722
  },
2721
-
2723
+
2722
2724
  /**
2723
- Swaps the `primaryKey` mapped to the given storeKey with the new
2725
+ Swaps the `primaryKey` mapped to the given storeKey with the new
2724
2726
  `primaryKey`. If the `storeKey` is not currently associated with a record
2725
2727
  this will raise an exception.
2726
-
2728
+
2727
2729
  @param {Number} storeKey the existing store key
2728
2730
  @param {String} newPrimaryKey the new primary key
2729
2731
  @returns {SC.Store} receiver
@@ -2731,7 +2733,7 @@ SC.Store.mixin(/** @scope SC.Store.prototype */{
2731
2733
  replaceIdFor: function(storeKey, newId) {
2732
2734
  var oldId = this.idsByStoreKey[storeKey],
2733
2735
  recordType, storeKeys;
2734
-
2736
+
2735
2737
  if (oldId !== newId) { // skip if id isn't changing
2736
2738
 
2737
2739
  recordType = this.recordTypeFor(storeKey);
@@ -2740,32 +2742,32 @@ SC.Store.mixin(/** @scope SC.Store.prototype */{
2740
2742
  }
2741
2743
 
2742
2744
  // map one direction...
2743
- this.idsByStoreKey[storeKey] = newId;
2745
+ this.idsByStoreKey[storeKey] = newId;
2744
2746
 
2745
2747
  // then the other...
2746
2748
  storeKeys = recordType.storeKeysById() ;
2747
2749
  delete storeKeys[oldId];
2748
- storeKeys[newId] = storeKey;
2750
+ storeKeys[newId] = storeKey;
2749
2751
  }
2750
-
2752
+
2751
2753
  return this ;
2752
2754
  },
2753
-
2755
+
2754
2756
  /**
2755
2757
  Swaps the `recordType` recorded for a given `storeKey`. Normally you
2756
2758
  should not call this method directly as it can damage the store behavior.
2757
- This method is used by other store methods to set the `recordType` for a
2759
+ This method is used by other store methods to set the `recordType` for a
2758
2760
  `storeKey`.
2759
-
2761
+
2760
2762
  @param {Integer} storeKey the store key
2761
2763
  @param {SC.Record} recordType a record class
2762
- @returns {SC.Store} reciever
2764
+ @returns {SC.Store} receiver
2763
2765
  */
2764
2766
  replaceRecordTypeFor: function(storeKey, recordType) {
2765
2767
  this.recordTypesByStoreKey[storeKey] = recordType;
2766
2768
  return this ;
2767
2769
  }
2768
-
2770
+
2769
2771
  });
2770
2772
 
2771
2773
 
@@ -2774,7 +2776,7 @@ SC.Store.prototype.nextStoreIndex = 1;
2774
2776
 
2775
2777
  // ..........................................................
2776
2778
  // COMPATIBILITY
2777
- //
2779
+ //
2778
2780
 
2779
2781
  /** @private
2780
2782
  global store is used only for deprecated compatibility methods. Don't use
@@ -2789,14 +2791,14 @@ SC.Store._getDefaultStore = function() {
2789
2791
  /** @private
2790
2792
 
2791
2793
  DEPRECATED
2792
-
2793
- Included for compatibility, loads data hashes with the named `recordType`.
2794
- If no `recordType` is passed, expects to find a `recordType` property in the
2794
+
2795
+ Included for compatibility, loads data hashes with the named `recordType`.
2796
+ If no `recordType` is passed, expects to find a `recordType` property in the
2795
2797
  data hashes. `dataSource` and `isLoaded` params are ignored.
2796
-
2797
- Calls `SC.Store#loadRecords()` on the default store. Do not use this method in
2798
- new code.
2799
-
2798
+
2799
+ Calls `SC.Store#loadRecords()` on the default store. Do not use this method in
2800
+ new code.
2801
+
2800
2802
  @param {Array} dataHashes data hashes to import
2801
2803
  @param {Object} dataSource ignored
2802
2804
  @param {SC.Record} recordType default record type
@@ -2804,37 +2806,35 @@ SC.Store._getDefaultStore = function() {
2804
2806
  @returns {Array} SC.Record instances for loaded data hashes
2805
2807
  */
2806
2808
  SC.Store.updateRecords = function(dataHashes, dataSource, recordType, isLoaded) {
2807
-
2808
2809
  SC.Logger.warn("SC.Store.updateRecords() is deprecated. Use loadRecords() instead");
2809
-
2810
2810
  var store = this._getDefaultStore(),
2811
2811
  len = dataHashes.length,
2812
2812
  idx, ret;
2813
-
2813
+
2814
2814
  // if no recordType was passed, build an array of recordTypes from hashes
2815
2815
  if (!recordType) {
2816
2816
  recordType = [];
2817
2817
  for(idx=0;idx<len;idx++) recordType[idx] = dataHashes[idx].recordType;
2818
2818
  }
2819
-
2819
+
2820
2820
  // call new API. Returns storeKeys
2821
2821
  ret = store.loadRecords(recordType, dataHashes);
2822
-
2822
+
2823
2823
  // map to SC.Record instances
2824
2824
  len = ret.length;
2825
2825
  for(idx=0;idx<len;idx++) ret[idx] = store.materializeRecord(ret[idx]);
2826
-
2826
+
2827
2827
  return ret ;
2828
2828
  };
2829
2829
 
2830
2830
  /** @private
2831
2831
 
2832
- DEPRECATED
2832
+ DEPRECATED
2833
2833
 
2834
2834
  Finds a record with the passed guid on the default store. This is included
2835
2835
  only for compatibility. You should use the newer `find()` method defined on
2836
2836
  `SC.Store` instead.
2837
-
2837
+
2838
2838
  @param {String} guid the guid
2839
2839
  @param {SC.Record} recordType expected record type
2840
2840
  @returns {SC.Record} found record
@@ -2845,12 +2845,12 @@ SC.Store.find = function(guid, recordType) {
2845
2845
 
2846
2846
  /** @private
2847
2847
 
2848
- DEPRECATED
2848
+ DEPRECATED
2849
2849
 
2850
- Passes through to `findAll` on default store. This is included only for
2850
+ Passes through to `findAll` on default store. This is included only for
2851
2851
  compatibility. You should use the newer `findAll()` defined on `SC.Store`
2852
2852
  instead.
2853
-
2853
+
2854
2854
  @param {Hash} filter search parameters
2855
2855
  @param {SC.Record} recordType type of record to find
2856
2856
  @returns {SC.RecordArray} result set