sproutcore 1.10.3.1 → 1.11.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (380) hide show
  1. checksums.yaml +8 -8
  2. data/CHANGELOG +4 -8
  3. data/VERSION.yml +2 -2
  4. data/lib/frameworks/sproutcore/Buildfile +5 -4
  5. data/lib/frameworks/sproutcore/CHANGELOG.md +274 -40
  6. data/lib/frameworks/sproutcore/CONTRIBUTORS.md +133 -0
  7. data/lib/frameworks/sproutcore/README.md +31 -144
  8. data/lib/frameworks/sproutcore/apps/showcase/controllers/source_tree_controller.js +9 -4
  9. data/lib/frameworks/sproutcore/apps/showcase/resources/stylesheet.css +5 -0
  10. data/lib/frameworks/sproutcore/apps/showcase/system/views_item_content.js +1 -1
  11. data/lib/frameworks/sproutcore/apps/showcase/views/split_views.js +15 -2
  12. data/lib/frameworks/sproutcore/apps/showcase/views/stacked_views.js +1 -1
  13. data/lib/frameworks/sproutcore/apps/tests/english.lproj/main_page.js +11 -1
  14. data/lib/frameworks/sproutcore/frameworks/ajax/mixins/websocket_delegate.js +90 -0
  15. data/lib/frameworks/sproutcore/frameworks/ajax/system/request.js +81 -5
  16. data/lib/frameworks/sproutcore/frameworks/ajax/system/response.js +23 -4
  17. data/lib/frameworks/sproutcore/frameworks/ajax/system/websocket.js +475 -0
  18. data/lib/frameworks/sproutcore/frameworks/ajax/tests/system/request.js +149 -26
  19. data/lib/frameworks/sproutcore/frameworks/ajax/tests/system/websocket.js +197 -0
  20. data/lib/frameworks/sproutcore/frameworks/ajax/tests/system/xhr_response_test.js +65 -0
  21. data/lib/frameworks/sproutcore/frameworks/bootstrap/system/loader.js +4 -0
  22. data/lib/frameworks/sproutcore/frameworks/core_foundation/child_view_layouts/horizontal_stack_layout.js +232 -52
  23. data/lib/frameworks/sproutcore/frameworks/core_foundation/child_view_layouts/vertical_stack_layout.js +235 -49
  24. data/lib/frameworks/sproutcore/frameworks/core_foundation/controllers/array.js +23 -13
  25. data/lib/frameworks/sproutcore/frameworks/core_foundation/controllers/object.js +3 -1
  26. data/lib/frameworks/sproutcore/frameworks/core_foundation/core.js +81 -1
  27. data/lib/frameworks/sproutcore/frameworks/core_foundation/english.lproj/ordinal.js +17 -0
  28. data/lib/frameworks/sproutcore/frameworks/core_foundation/ext/string.js +7 -0
  29. data/lib/frameworks/sproutcore/frameworks/{desktop/tests/views/disclosure/methods.js → core_foundation/french.lproj/ordinal.js} +7 -4
  30. data/lib/frameworks/sproutcore/frameworks/core_foundation/panes/layout.js +2 -6
  31. data/lib/frameworks/sproutcore/frameworks/core_foundation/panes/main.js +1 -1
  32. data/lib/frameworks/sproutcore/frameworks/core_foundation/panes/pane.js +104 -69
  33. data/lib/frameworks/sproutcore/frameworks/core_foundation/panes/pane_statechart.js +6 -1
  34. data/lib/frameworks/sproutcore/frameworks/core_foundation/protocols/child_view_layout_protocol.js +59 -0
  35. data/lib/frameworks/sproutcore/frameworks/core_foundation/protocols/view_transition_protocol.js +18 -1
  36. data/lib/frameworks/sproutcore/frameworks/core_foundation/system/application.js +192 -0
  37. data/lib/frameworks/sproutcore/frameworks/core_foundation/system/bezier_curves.js +52 -0
  38. data/lib/frameworks/sproutcore/frameworks/core_foundation/system/color.js +384 -64
  39. data/lib/frameworks/sproutcore/frameworks/core_foundation/system/core_query.js +6 -14
  40. data/lib/frameworks/sproutcore/frameworks/core_foundation/system/device.js +21 -35
  41. data/lib/frameworks/sproutcore/frameworks/core_foundation/system/event.js +72 -36
  42. data/lib/frameworks/sproutcore/frameworks/core_foundation/system/locale.js +90 -34
  43. data/lib/frameworks/sproutcore/frameworks/core_foundation/system/platform.js +55 -7
  44. data/lib/frameworks/sproutcore/frameworks/core_foundation/system/render_context.js +20 -15
  45. data/lib/frameworks/sproutcore/frameworks/core_foundation/system/req_anim_frame.js +9 -10
  46. data/lib/frameworks/sproutcore/frameworks/core_foundation/system/root_responder.js +763 -542
  47. data/lib/frameworks/sproutcore/frameworks/core_foundation/system/selection_set.js +4 -3
  48. data/lib/frameworks/sproutcore/frameworks/core_foundation/system/sparse_array.js +1 -7
  49. data/lib/frameworks/sproutcore/frameworks/core_foundation/system/string.js +14 -0
  50. data/lib/frameworks/sproutcore/frameworks/core_foundation/system/touch.js +538 -0
  51. data/lib/frameworks/sproutcore/frameworks/core_foundation/system/utils/rect.js +56 -1
  52. data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/controllers/array/array_case.js +99 -4
  53. data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/controllers/object/single_case.js +25 -19
  54. data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/core_tests.js +75 -0
  55. data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/ext/number_test.js +81 -0
  56. data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/mixins/action_support.js +4 -4
  57. data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/mixins/responder_context.js +4 -4
  58. data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/mixins/string.js +19 -1
  59. data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/system/color.js +36 -20
  60. data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/system/root_responder/design_modes_test.js +83 -0
  61. data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/system/root_responder/makeMainPane.js +7 -3
  62. data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/system/root_responder/mouse_events.js +338 -0
  63. data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/system/root_responder/root_responder.js +14 -89
  64. data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/system/root_responder/touch.js +106 -0
  65. data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/system/sparse_array.js +2 -2
  66. data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/system/touch.js +136 -0
  67. data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/system/utils/rect.js +42 -1
  68. data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/pane/append_remove.js +11 -0
  69. data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/pane/child_view.js +5 -5
  70. data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/pane/design_mode_test.js +457 -0
  71. data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/pane/sendEvent.js +36 -10
  72. data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/background_color.js +44 -0
  73. data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/border_frame_test.js +51 -24
  74. data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/childViewLayout_test.js +176 -1
  75. data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/clippingFrame.js +46 -16
  76. data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/convertFrames.js +69 -15
  77. data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/didAppendToDocument.js +2 -2
  78. data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/layout.js +7 -1
  79. data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/layoutDidChange.js +30 -10
  80. data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/layoutStyle.js +376 -71
  81. data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/static_layout.js +0 -10
  82. data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/viewDidResize.js +117 -34
  83. data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/view_states_test.js +52 -2
  84. data/lib/frameworks/sproutcore/frameworks/core_foundation/views/view.js +656 -42
  85. data/lib/frameworks/sproutcore/frameworks/core_foundation/views/view/animation.js +159 -38
  86. data/lib/frameworks/sproutcore/frameworks/core_foundation/views/view/cursor.js +0 -7
  87. data/lib/frameworks/sproutcore/frameworks/core_foundation/views/view/design_mode.js +206 -0
  88. data/lib/frameworks/sproutcore/frameworks/core_foundation/views/view/enabled.js +0 -28
  89. data/lib/frameworks/sproutcore/frameworks/core_foundation/views/view/keyboard.js +21 -6
  90. data/lib/frameworks/sproutcore/frameworks/core_foundation/views/view/layout.js +372 -450
  91. data/lib/frameworks/sproutcore/frameworks/core_foundation/views/view/layout_style.js +28 -13
  92. data/lib/frameworks/sproutcore/frameworks/core_foundation/views/view/manipulation.js +22 -51
  93. data/lib/frameworks/sproutcore/frameworks/core_foundation/views/view/statechart.js +59 -30
  94. data/lib/frameworks/sproutcore/frameworks/core_foundation/views/view/theming.js +0 -29
  95. data/lib/frameworks/sproutcore/frameworks/datastore/mixins/relationship_support.js +22 -10
  96. data/lib/frameworks/sproutcore/frameworks/datastore/models/children_attribute.js +42 -36
  97. data/lib/frameworks/sproutcore/frameworks/datastore/models/many_attribute.js +54 -3
  98. data/lib/frameworks/sproutcore/frameworks/datastore/models/record.js +178 -59
  99. data/lib/frameworks/sproutcore/frameworks/datastore/models/record_attribute.js +2 -2
  100. data/lib/frameworks/sproutcore/frameworks/datastore/system/child_array.js +206 -132
  101. data/lib/frameworks/sproutcore/frameworks/datastore/system/many_array.js +214 -118
  102. data/lib/frameworks/sproutcore/frameworks/datastore/system/nested_store.js +96 -13
  103. data/lib/frameworks/sproutcore/frameworks/datastore/system/query.js +14 -4
  104. data/lib/frameworks/sproutcore/frameworks/datastore/system/record_array.js +82 -42
  105. data/lib/frameworks/sproutcore/frameworks/datastore/system/store.js +272 -177
  106. data/lib/frameworks/sproutcore/frameworks/datastore/tests/integration/store_interaction_test.js +54 -0
  107. data/lib/frameworks/sproutcore/frameworks/datastore/tests/models/datetime_recordattribute.js +24 -16
  108. data/lib/frameworks/sproutcore/frameworks/datastore/tests/models/many_attribute.js +6 -3
  109. data/lib/frameworks/sproutcore/frameworks/datastore/tests/models/nested_records/data_store.js +267 -35
  110. data/lib/frameworks/sproutcore/frameworks/datastore/tests/models/nested_records/nested_record.js +57 -46
  111. data/lib/frameworks/sproutcore/frameworks/datastore/tests/models/nested_records/nested_record_array.js +150 -53
  112. data/lib/frameworks/sproutcore/frameworks/datastore/tests/models/nested_records/nested_record_array_complex.js +57 -17
  113. data/lib/frameworks/sproutcore/frameworks/datastore/tests/models/nested_records/nested_record_complex.js +13 -9
  114. data/lib/frameworks/sproutcore/frameworks/{experimental/frameworks/polymorphism → datastore}/tests/models/polymorphism/many.js +2 -2
  115. data/lib/frameworks/sproutcore/frameworks/{experimental/frameworks/polymorphism → datastore}/tests/models/polymorphism/simple.js +0 -0
  116. data/lib/frameworks/sproutcore/frameworks/{experimental/frameworks/polymorphism → datastore}/tests/models/polymorphism/single.js +12 -2
  117. data/lib/frameworks/sproutcore/frameworks/datastore/tests/models/record/writeAttribute.js +20 -15
  118. data/lib/frameworks/sproutcore/frameworks/datastore/tests/models/record_attribute.js +9 -2
  119. data/lib/frameworks/sproutcore/frameworks/datastore/tests/system/many_array/core_methods.js +80 -14
  120. data/lib/frameworks/sproutcore/frameworks/datastore/tests/system/nested_store/autonomous_dataSourceCallbacks.js +280 -0
  121. data/lib/frameworks/sproutcore/frameworks/datastore/tests/system/nested_store/autonomous_pushChanges.js +232 -0
  122. data/lib/frameworks/sproutcore/frameworks/datastore/tests/system/nested_store/chain.js +31 -5
  123. data/lib/frameworks/sproutcore/frameworks/datastore/tests/system/query/parse.js +16 -2
  124. data/lib/frameworks/sproutcore/frameworks/datastore/tests/system/store/core_methods.js +60 -40
  125. data/lib/frameworks/sproutcore/frameworks/datastore/tests/system/store/materializeRecord.js +78 -0
  126. data/lib/frameworks/sproutcore/frameworks/datetime/frameworks/core/system/datetime.js +13 -1
  127. data/lib/frameworks/sproutcore/frameworks/datetime/frameworks/core/tests/system/datetime.js +20 -0
  128. data/lib/frameworks/sproutcore/frameworks/datetime/frameworks/localized/{resources → english.lproj}/strings.js +0 -0
  129. data/lib/frameworks/sproutcore/frameworks/datetime/frameworks/localized/french.lproj/strings.js +45 -0
  130. data/lib/frameworks/sproutcore/frameworks/designer/designers/object_designer.js +7 -3
  131. data/lib/frameworks/sproutcore/frameworks/desktop/mixins/collection_row_delegate.js +125 -44
  132. data/lib/frameworks/sproutcore/frameworks/desktop/panes/alert.js +139 -48
  133. data/lib/frameworks/sproutcore/frameworks/desktop/panes/draggable.js +202 -0
  134. data/lib/frameworks/sproutcore/frameworks/desktop/panes/menu.js +59 -56
  135. data/lib/frameworks/sproutcore/frameworks/desktop/panes/palette.js +13 -49
  136. data/lib/frameworks/sproutcore/frameworks/desktop/panes/picker.js +466 -305
  137. data/lib/frameworks/sproutcore/frameworks/desktop/protocols/drag_source.js +49 -12
  138. data/lib/frameworks/sproutcore/frameworks/desktop/render_delegates/slider.js +79 -21
  139. data/lib/frameworks/sproutcore/frameworks/desktop/render_delegates/split.js +12 -2
  140. data/lib/frameworks/sproutcore/frameworks/desktop/resources/menu_item_view.css +8 -0
  141. data/lib/frameworks/sproutcore/frameworks/desktop/resources/overlay-scroller.css +187 -0
  142. data/lib/frameworks/sproutcore/frameworks/desktop/system/drag.js +94 -30
  143. data/lib/frameworks/sproutcore/frameworks/desktop/tests/panes/alert/ui.js +163 -3
  144. data/lib/frameworks/sproutcore/frameworks/desktop/tests/panes/menu/methods.js +97 -78
  145. data/lib/frameworks/sproutcore/frameworks/desktop/tests/panes/menu/ui.js +61 -1
  146. data/lib/frameworks/sproutcore/frameworks/desktop/tests/panes/panel/methods.js +7 -3
  147. data/lib/frameworks/sproutcore/frameworks/desktop/tests/panes/panel/ui.js +47 -22
  148. data/lib/frameworks/sproutcore/frameworks/desktop/tests/panes/picker/methods.js +66 -9
  149. data/lib/frameworks/sproutcore/frameworks/desktop/tests/panes/picker/ui.js +21 -11
  150. data/lib/frameworks/sproutcore/frameworks/desktop/tests/panes/sheet/ui.js +12 -18
  151. data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/button/methods.js +17 -14
  152. data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/button/ui.js +2 -1
  153. data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/checkbox/methods.js +9 -6
  154. data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/collection/collection_fast_path.js +54 -21
  155. data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/collection/content.js +52 -20
  156. data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/collection/itemViewForContentIndex.js +94 -4
  157. data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/collection/keyboard.js +177 -0
  158. data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/collection/layerIdFor.js +13 -1
  159. data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/collection/length.js +9 -9
  160. data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/collection/mouse.js +18 -0
  161. data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/date_field/methods.js +104 -0
  162. data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/disclosure/ui.js +48 -49
  163. data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/grid/drag_and_drop.js +22 -18
  164. data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/grid/methods.js +17 -5
  165. data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/link_view_test.js +136 -0
  166. data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/list/contentIndexesInRect.js +77 -0
  167. data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/list/drag_and_drop.js +53 -16
  168. data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/list/layoutForContentIndex.js +41 -0
  169. data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/list/rowDelegate.js +25 -25
  170. data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/list/rowOffsetForContentIndex.js +102 -27
  171. data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/list/{rowHeightForContentIndex.js → rowSizeForContentIndex.js} +7 -6
  172. data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/list/ui_outline.js +2 -0
  173. data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/list/ui_row_heights.js +70 -75
  174. data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/list/ui_simple.js +29 -30
  175. data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/list_item.js +57 -0
  176. data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/menu_scroll_view/menu_scroll_view_test.js +206 -0
  177. data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/progress/ui.js +15 -0
  178. data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/radio/methods.js +15 -7
  179. data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/scroll/integration.js +16 -11
  180. data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/scroll/methods.js +164 -12
  181. data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/scroll/scale.js +387 -0
  182. data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/scroll/touch.js +549 -0
  183. data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/scroll/ui.js +214 -45
  184. data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/scroller.js +5 -5
  185. data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/segmented/methods.js +73 -22
  186. data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/segmented/ui.js +88 -3
  187. data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/select/methods.js +8 -0
  188. data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/slider/methods.js +16 -1
  189. data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/slider/ui.js +54 -0
  190. data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/split/dividers.js +21 -2
  191. data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/static_content.js +31 -25
  192. data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/tab/methods.js +109 -29
  193. data/lib/frameworks/sproutcore/frameworks/desktop/views/button.js +10 -1
  194. data/lib/frameworks/sproutcore/frameworks/desktop/views/checkbox.js +3 -0
  195. data/lib/frameworks/sproutcore/frameworks/desktop/views/collection.js +779 -603
  196. data/lib/frameworks/sproutcore/frameworks/desktop/views/date_field.js +106 -7
  197. data/lib/frameworks/sproutcore/frameworks/desktop/views/link_view.js +406 -0
  198. data/lib/frameworks/sproutcore/frameworks/desktop/views/list.js +437 -245
  199. data/lib/frameworks/sproutcore/frameworks/desktop/views/list_item.js +13 -0
  200. data/lib/frameworks/sproutcore/frameworks/desktop/views/menu_item.js +124 -62
  201. data/lib/frameworks/sproutcore/frameworks/desktop/views/menu_scroll.js +176 -597
  202. data/lib/frameworks/sproutcore/frameworks/desktop/views/menu_scroller_view.js +206 -0
  203. data/lib/frameworks/sproutcore/frameworks/desktop/views/popup_button.js +3 -0
  204. data/lib/frameworks/sproutcore/frameworks/desktop/views/progress.js +5 -4
  205. data/lib/frameworks/sproutcore/frameworks/desktop/views/radio.js +3 -0
  206. data/lib/frameworks/sproutcore/frameworks/desktop/views/scene.js +56 -158
  207. data/lib/frameworks/sproutcore/frameworks/desktop/views/scroll_view.js +2560 -0
  208. data/lib/frameworks/sproutcore/frameworks/desktop/views/scroller.js +458 -242
  209. data/lib/frameworks/sproutcore/frameworks/desktop/views/segmented.js +117 -54
  210. data/lib/frameworks/sproutcore/frameworks/desktop/views/select.js +18 -12
  211. data/lib/frameworks/sproutcore/frameworks/desktop/views/slider.js +162 -34
  212. data/lib/frameworks/sproutcore/frameworks/desktop/views/split.js +30 -15
  213. data/lib/frameworks/sproutcore/frameworks/desktop/views/split_divider.js +33 -7
  214. data/lib/frameworks/sproutcore/frameworks/desktop/views/static_content.js +22 -2
  215. data/lib/frameworks/sproutcore/frameworks/desktop/views/tab.js +47 -22
  216. data/lib/frameworks/sproutcore/frameworks/experimental/Buildfile +0 -6
  217. data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/forms/views/form.js +2 -1
  218. data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/forms/views/form_row.js +21 -21
  219. data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/select_view/ext/menu.js +14 -3
  220. data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/select_view/mixins/select_view_menu.js +24 -10
  221. data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/select_view/tests/ext/menu_resizing.js +1 -1
  222. data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/select_view/tests/mixins/select_view_menu/bindings.js +7 -4
  223. data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/select_view/tests/mixins/select_view_menu/check_selected.js +7 -9
  224. data/lib/frameworks/sproutcore/frameworks/{desktop/tests/panes/select_button/methods.js → experimental/frameworks/select_view/tests/views/select/method.js} +54 -76
  225. data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/select_view/tests/views/select/selected_item.js +35 -0
  226. data/lib/frameworks/sproutcore/frameworks/{desktop/tests/panes/select_button → experimental/frameworks/select_view/tests/views/select}/ui.js +107 -36
  227. data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/select_view/views/select.js +225 -66
  228. data/lib/frameworks/sproutcore/frameworks/foundation/controllers/tree.js +39 -38
  229. data/lib/frameworks/sproutcore/frameworks/foundation/core.js +5 -18
  230. data/lib/frameworks/sproutcore/frameworks/foundation/debug/control_test_pane.js +12 -0
  231. data/lib/frameworks/sproutcore/frameworks/foundation/english.lproj/inflections.js +84 -0
  232. data/lib/frameworks/sproutcore/frameworks/foundation/french.lproj/inflections.js +41 -0
  233. data/lib/frameworks/sproutcore/frameworks/foundation/mixins/auto_mixin.js +1 -0
  234. data/lib/frameworks/sproutcore/frameworks/foundation/mixins/auto_resize.js +7 -0
  235. data/lib/frameworks/sproutcore/frameworks/foundation/mixins/content_display.js +3 -4
  236. data/lib/frameworks/sproutcore/frameworks/foundation/mixins/flowed_layout.js +6 -2
  237. data/lib/frameworks/sproutcore/frameworks/foundation/private/tree_item_observer.js +408 -239
  238. data/lib/frameworks/sproutcore/frameworks/foundation/render_delegates/canvas_image.js +1 -1
  239. data/lib/frameworks/sproutcore/frameworks/foundation/resources/text_field.css +2 -1
  240. data/lib/frameworks/sproutcore/frameworks/foundation/spanish.lproj/inflections.js +38 -0
  241. data/lib/frameworks/sproutcore/frameworks/foundation/system/benchmark.js +104 -76
  242. data/lib/frameworks/sproutcore/frameworks/foundation/system/string.js +20 -94
  243. data/lib/frameworks/sproutcore/frameworks/foundation/system/text_selection.js +33 -22
  244. data/lib/frameworks/sproutcore/frameworks/foundation/system/undo_manager.js +475 -0
  245. data/lib/frameworks/sproutcore/frameworks/foundation/tests/mixins/auto_resize_test.js +163 -1
  246. data/lib/frameworks/sproutcore/frameworks/foundation/tests/mixins/flowed_layout/tests.js +41 -0
  247. data/lib/frameworks/sproutcore/frameworks/foundation/tests/mixins/staticLayout.js +2 -5
  248. data/lib/frameworks/sproutcore/frameworks/foundation/tests/private/tree_item_observer/methods.js +268 -0
  249. data/lib/frameworks/sproutcore/frameworks/foundation/tests/system/undo_manager.js +231 -0
  250. data/lib/frameworks/sproutcore/frameworks/foundation/tests/views/container/ui.js +16 -0
  251. data/lib/frameworks/sproutcore/frameworks/foundation/tests/views/image/ui.js +27 -0
  252. data/lib/frameworks/sproutcore/frameworks/foundation/tests/views/text_field/methods.js +24 -0
  253. data/lib/frameworks/sproutcore/frameworks/foundation/tests/views/text_field/ui.js +135 -6
  254. data/lib/frameworks/sproutcore/frameworks/foundation/transitions/fade_transition.js +6 -0
  255. data/lib/frameworks/sproutcore/frameworks/foundation/transitions/pop_transition.js +7 -0
  256. data/lib/frameworks/sproutcore/frameworks/foundation/transitions/scale_transition.js +6 -0
  257. data/lib/frameworks/sproutcore/frameworks/foundation/transitions/slide_transition.js +4 -0
  258. data/lib/frameworks/sproutcore/frameworks/foundation/transitions/swap_dissolve_transition.js +3 -1
  259. data/lib/frameworks/sproutcore/frameworks/foundation/validators/credit_card.js +21 -21
  260. data/lib/frameworks/sproutcore/frameworks/foundation/views/container.js +65 -15
  261. data/lib/frameworks/sproutcore/frameworks/foundation/views/image.js +4 -1
  262. data/lib/frameworks/sproutcore/frameworks/foundation/views/label.js +1 -1
  263. data/lib/frameworks/sproutcore/frameworks/foundation/views/text_field.js +193 -213
  264. data/lib/frameworks/sproutcore/frameworks/jquery/{jquery-1.8.3-patched.js → jquery-1.11.1.js} +7507 -6684
  265. data/lib/frameworks/sproutcore/frameworks/routing/system/routes.js +28 -11
  266. data/lib/frameworks/sproutcore/frameworks/routing/tests/system/routes.js +26 -0
  267. data/lib/frameworks/sproutcore/frameworks/runtime/core.js +54 -25
  268. data/lib/frameworks/sproutcore/frameworks/runtime/ext/array.js +0 -6
  269. data/lib/frameworks/sproutcore/frameworks/runtime/ext/number.js +36 -0
  270. data/lib/frameworks/sproutcore/frameworks/runtime/ext/window.js +25 -0
  271. data/lib/frameworks/sproutcore/frameworks/runtime/mixins/array.js +3 -3
  272. data/lib/frameworks/sproutcore/frameworks/runtime/mixins/enumerable.js +1 -1
  273. data/lib/frameworks/sproutcore/frameworks/runtime/mixins/observable.js +156 -66
  274. data/lib/frameworks/sproutcore/frameworks/runtime/private/observer_set.js +2 -2
  275. data/lib/frameworks/sproutcore/frameworks/runtime/system/binding.js +150 -65
  276. data/lib/frameworks/sproutcore/frameworks/runtime/system/index_set.js +57 -11
  277. data/lib/frameworks/sproutcore/frameworks/runtime/system/object.js +68 -49
  278. data/lib/frameworks/sproutcore/frameworks/runtime/system/run_loop.js +14 -6
  279. data/lib/frameworks/sproutcore/frameworks/runtime/system/string.js +23 -23
  280. data/lib/frameworks/sproutcore/frameworks/runtime/tests/ext/number_test.js +44 -0
  281. data/lib/frameworks/sproutcore/frameworks/runtime/tests/mixins/array.js +0 -10
  282. data/lib/frameworks/sproutcore/frameworks/runtime/tests/mixins/enumerable/enumerable.js +340 -285
  283. data/lib/frameworks/sproutcore/frameworks/runtime/tests/system/binding.js +104 -3
  284. data/lib/frameworks/sproutcore/frameworks/runtime/tests/system/observer_set.js +14 -1
  285. data/lib/frameworks/sproutcore/frameworks/runtime/tests/system/string.js +15 -2
  286. data/lib/frameworks/sproutcore/frameworks/statechart/system/state.js +21 -18
  287. data/lib/frameworks/sproutcore/frameworks/statechart/system/statechart.js +52 -19
  288. data/lib/frameworks/sproutcore/frameworks/statechart/tests/event_handling/responder/pane.js +27 -24
  289. data/lib/frameworks/sproutcore/frameworks/template_view/controls/button.js +30 -0
  290. data/lib/frameworks/sproutcore/frameworks/template_view/ext/handlebars/bind.js +1 -1
  291. data/lib/frameworks/sproutcore/frameworks/template_view/ext/handlebars/collection.js +2 -0
  292. data/lib/frameworks/sproutcore/frameworks/template_view/ext/handlebars/view.js +1 -0
  293. data/lib/frameworks/sproutcore/frameworks/template_view/tests/mixins/template_helpers/checkbox_support.js +2 -2
  294. data/lib/frameworks/sproutcore/frameworks/template_view/tests/views/template/handlebars.js +4 -2
  295. data/lib/frameworks/sproutcore/frameworks/template_view/views/bindable_span.js +1 -1
  296. data/lib/frameworks/sproutcore/frameworks/template_view/views/template_collection.js +16 -14
  297. data/lib/frameworks/sproutcore/frameworks/testing/core.js +5 -3
  298. data/lib/frameworks/sproutcore/frameworks/testing/system/plan.js +13 -0
  299. data/lib/frameworks/sproutcore/lib/index.rhtml +2 -2
  300. data/lib/frameworks/sproutcore/phantomjs/test_runner.js +28 -7
  301. data/lib/frameworks/sproutcore/scripts/run_sc_server_master.sh +1 -1
  302. data/lib/frameworks/sproutcore/themes/ace/resources/_variables.css +2 -0
  303. data/lib/frameworks/sproutcore/themes/ace/resources/disclosure/ace/disclosure.css +1 -0
  304. data/lib/frameworks/sproutcore/themes/ace/resources/picker/popover/popover.css +3 -4
  305. data/lib/frameworks/sproutcore/themes/ace/resources/scroller/horizontal/horizontal.css +15 -15
  306. data/lib/frameworks/sproutcore/themes/ace/resources/scroller/horizontal/horizontal_overlay.css +74 -0
  307. data/lib/frameworks/sproutcore/themes/ace/resources/scroller/vertical/vertical.css +11 -13
  308. data/lib/frameworks/sproutcore/themes/ace/resources/scroller/vertical/vertical_overlay.css +74 -0
  309. data/lib/frameworks/sproutcore/themes/ace/resources/slider/ace/jumbo/knob-active.png +0 -0
  310. data/lib/frameworks/sproutcore/themes/ace/resources/slider/ace/jumbo/knob-active@2x.png +0 -0
  311. data/lib/frameworks/sproutcore/themes/ace/resources/slider/ace/jumbo/knob.png +0 -0
  312. data/lib/frameworks/sproutcore/themes/ace/resources/slider/ace/jumbo/knob@2x.png +0 -0
  313. data/lib/frameworks/sproutcore/themes/ace/resources/slider/ace/{22px → jumbo}/slider.css +9 -4
  314. data/lib/frameworks/sproutcore/themes/ace/resources/slider/ace/jumbo/track.png +0 -0
  315. data/lib/frameworks/sproutcore/themes/ace/resources/slider/ace/jumbo/track@2x.png +0 -0
  316. data/lib/frameworks/sproutcore/themes/ace/resources/slider/ace/regular/knob-active.png +0 -0
  317. data/lib/frameworks/sproutcore/themes/ace/resources/slider/ace/regular/knob-active@2x.png +0 -0
  318. data/lib/frameworks/sproutcore/themes/ace/resources/slider/ace/regular/knob.png +0 -0
  319. data/lib/frameworks/sproutcore/themes/ace/resources/slider/ace/regular/knob@2x.png +0 -0
  320. data/lib/frameworks/sproutcore/themes/ace/resources/slider/ace/regular/slider.css +32 -0
  321. data/lib/frameworks/sproutcore/themes/ace/resources/slider/ace/regular/track.png +0 -0
  322. data/lib/frameworks/sproutcore/themes/ace/resources/slider/ace/regular/track@2x.png +0 -0
  323. data/lib/frameworks/sproutcore/themes/ace/resources/slider/ace/slider.css +13 -0
  324. data/lib/frameworks/sproutcore/themes/ace/resources/slider/ace/small/knob-active.png +0 -0
  325. data/lib/frameworks/sproutcore/themes/ace/resources/slider/ace/small/knob-active@2x.png +0 -0
  326. data/lib/frameworks/sproutcore/themes/ace/resources/slider/ace/small/knob.png +0 -0
  327. data/lib/frameworks/sproutcore/themes/ace/resources/slider/ace/small/knob@2x.png +0 -0
  328. data/lib/frameworks/sproutcore/themes/ace/resources/slider/ace/small/slider.css +32 -0
  329. data/lib/frameworks/sproutcore/themes/ace/resources/slider/ace/small/track.png +0 -0
  330. data/lib/frameworks/sproutcore/themes/ace/resources/slider/ace/small/track@2x.png +0 -0
  331. data/lib/frameworks/sproutcore/themes/ace/resources/split/split.css +2 -3
  332. data/lib/sproutcore/builders/chance_file.rb +3 -3
  333. data/lib/sproutcore/helpers/minifier.rb +1 -0
  334. data/vendor/chance/lib/chance/instance.rb +34 -34
  335. data/vendor/chance/lib/chance/instance/spriting.rb +21 -16
  336. metadata +81 -58
  337. data/lib/frameworks/sproutcore/frameworks/core_foundation/panes/visibility.js +0 -17
  338. data/lib/frameworks/sproutcore/frameworks/desktop/mixins/collection_fast_path.js +0 -710
  339. data/lib/frameworks/sproutcore/frameworks/desktop/mixins/scrollable.js +0 -267
  340. data/lib/frameworks/sproutcore/frameworks/desktop/resources/touch-scroller.css +0 -196
  341. data/lib/frameworks/sproutcore/frameworks/desktop/system/undo_manager.js +0 -224
  342. data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/select_field/methods.js +0 -163
  343. data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/select_field/ui.js +0 -177
  344. data/lib/frameworks/sproutcore/frameworks/desktop/views/scroll.js +0 -2053
  345. data/lib/frameworks/sproutcore/frameworks/desktop/views/select_button.js +0 -1024
  346. data/lib/frameworks/sproutcore/frameworks/desktop/views/select_field.js +0 -404
  347. data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/menu/render_delegates/menu_scroller.js +0 -28
  348. data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/menu/tests/menu/scroll.js +0 -235
  349. data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/menu/views/menu/scroll.js +0 -363
  350. data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/menu/views/menu/scroller.js +0 -250
  351. data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/polymorphism/README.md +0 -47
  352. data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/polymorphism/models/record.js +0 -134
  353. data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/scroll_view/render_delegates/desktop_scroller.js +0 -92
  354. data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/scroll_view/render_delegates/native_scroll.js +0 -25
  355. data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/scroll_view/render_delegates/scroll.js +0 -33
  356. data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/scroll_view/render_delegates/touch_scroller.js +0 -76
  357. data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/scroll_view/tests/scroll/integration.js +0 -25
  358. data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/scroll_view/tests/scroll/methods.js +0 -143
  359. data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/scroll_view/tests/scroll/ui.js +0 -256
  360. data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/scroll_view/views/core_scroll.js +0 -1164
  361. data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/scroll_view/views/core_scroller.js +0 -332
  362. data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/scroll_view/views/desktop/scroll.js +0 -236
  363. data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/scroll_view/views/desktop/scroller.js +0 -347
  364. data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/scroll_view/views/scroll.js +0 -15
  365. data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/scroll_view/views/scroller.js +0 -10
  366. data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/scroll_view/views/touch/scroll.js +0 -804
  367. data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/scroll_view/views/touch/scroller.js +0 -133
  368. data/lib/frameworks/sproutcore/frameworks/foundation/tasks/preload_bundle.js +0 -41
  369. data/lib/frameworks/sproutcore/themes/ace/resources/scroller/horizontal/horizontal_touch.css +0 -91
  370. data/lib/frameworks/sproutcore/themes/ace/resources/scroller/vertical/vertical_touch.css +0 -92
  371. data/lib/frameworks/sproutcore/themes/ace/resources/slider/ace/14px/knob.png +0 -0
  372. data/lib/frameworks/sproutcore/themes/ace/resources/slider/ace/14px/knob_active.png +0 -0
  373. data/lib/frameworks/sproutcore/themes/ace/resources/slider/ace/14px/slider.css +0 -27
  374. data/lib/frameworks/sproutcore/themes/ace/resources/slider/ace/16px/knob.png +0 -0
  375. data/lib/frameworks/sproutcore/themes/ace/resources/slider/ace/16px/knob_active.png +0 -0
  376. data/lib/frameworks/sproutcore/themes/ace/resources/slider/ace/16px/slider.css +0 -27
  377. data/lib/frameworks/sproutcore/themes/ace/resources/slider/ace/22px/knob.png +0 -0
  378. data/lib/frameworks/sproutcore/themes/ace/resources/slider/ace/22px/knob_active.png +0 -0
  379. data/lib/frameworks/sproutcore/themes/ace/resources/slider/ace/22px/track.png +0 -0
  380. data/lib/frameworks/sproutcore/themes/ace/resources/slider/ace/track.png +0 -0
@@ -6,51 +6,53 @@
6
6
  // ==========================================================================
7
7
 
8
8
  sc_require('views/collection');
9
+ sc_require('views/list_item');
9
10
  sc_require('mixins/collection_row_delegate');
10
11
 
11
12
  /** @class
12
13
 
13
- A list view renders vertical lists of items. It is a specialized form of
14
- collection view that is simpler than the table view, but more refined than
14
+ A list view renders vertical or horizontal lists of items. It is a specialized
15
+ form of collection view that is simpler than a table view, but more refined than
15
16
  a generic collection.
16
17
 
17
- You can use a list view just like a collection view, except that often you
18
- also should provide a default rowHeight. Setting this value will allow
19
- the ListView to optimize its rendering.
18
+ You can use a list view just like any collection view, except that often you
19
+ provide the rowSize, which will be either the height of each row when laying
20
+ out rows vertically (the default) or the widht of each row when laying out
21
+ the rows horizontally.
20
22
 
21
23
  ## Variable Row Heights
22
24
 
23
- Normally you set the row height through the rowHeight property. You can
24
- also support custom row heights by implementing the
25
- contentCustomRowHeightIndexes property to return an index set.
25
+ Normally you set the row height or width through the rowSize property, but
26
+ you can also support custom row sizes by assigning the `customRowSizeIndexes`
27
+ property to an index set of all custom sized rows.
26
28
 
27
29
  ## Using ListView with Very Large Data Sets
28
30
 
29
31
  ListView implements incremental rendering, which means it will only render
30
- HTML for the items that are current visible on the screen. You can use it
31
- to efficiently render lists with 100K+ items very efficiently.
32
+ HTML for the items that are currently visible on the screen. This means you
33
+ can use it to efficiently render lists with 100K+ items or more very efficiently.
32
34
 
33
- If you need to work with very large lists of items, however, be aware that
34
- calculate variable rows heights can become very expensive since the list
35
+ If you need to work with very large lists of items however, be aware that
36
+ calculating variable row sizes can become very expensive since the list
35
37
  view will essentially have to iterate over every item in the collection to
36
- collect its row height.
38
+ determine each the total height or width.
37
39
 
38
- To work with very large lists, you should consider making your row heights
39
- uniform. This will allow the list view to efficiently render content
40
- without worrying about the overall performance.
40
+ Therefore, to work with very large lists, you should consider using a design
41
+ that allows your row sizes to remain uniform. This will allow the list view
42
+ to much more efficiently render content.
41
43
 
42
- Alternatively, you may want to consider overriding the
43
- offsetForRowAtContentIndex() and heightForRowAtContentIndex() methods to
44
- perform some faster calculations that do not require inspecting every
45
- item in the collection.
44
+ Alternatively, to support differently sized and incrementally rendered item
45
+ views, you may want to consider overriding the `offsetForRowAtContentIndex()`
46
+ and `rowSizeForContentIndex()` methods to perform some specialized faster
47
+ calculations that do not require inspecting every item in the collection.
46
48
 
47
- Note that row heights and offsets are cached so once they are calculated
49
+ Note: row sizes and offsets are cached so once they are calculated
48
50
  the list view will be able to display very quickly.
49
51
 
50
- ## Dropping on an Item
52
+ ## Dragging and Dropping
51
53
 
52
- When the list view is configured to accept drags and drops onto its items, it
53
- will set the isDropTarget property on the target item accordingly. This
54
+ When the list view is configured to accept drops onto its items, it
55
+ will set the `isDropTarget` property on the target item accordingly. This
54
56
  allows you to modify the appearance of the drop target list item accordingly
55
57
  (@see SC.ListItemView#isDropTarget).
56
58
 
@@ -63,6 +65,30 @@ sc_require('mixins/collection_row_delegate');
63
65
  SC.ListView = SC.CollectionView.extend(SC.CollectionRowDelegate,
64
66
  /** @scope SC.ListView.prototype */ {
65
67
 
68
+ /** @private */
69
+ _sc_customRowSizeIndexes: null,
70
+
71
+ /** @private */
72
+ _sc_insertionPointView: null,
73
+
74
+ /** @private */
75
+ _sc_lastDropOnView: null,
76
+
77
+ /** @private */
78
+ _sc_layout: null,
79
+
80
+ /** @private */
81
+ _sc_sizeCache: null,
82
+
83
+ /** @private */
84
+ _sc_offsetCache: null,
85
+
86
+ /** @private */
87
+ _sc_rowDelegate: null,
88
+
89
+ /** @private */
90
+ _sc_rowSize: null,
91
+
66
92
  /**
67
93
  @type Array
68
94
  @default ['sc-list-view']
@@ -72,35 +98,73 @@ SC.ListView = SC.CollectionView.extend(SC.CollectionRowDelegate,
72
98
 
73
99
  /**
74
100
  @type Boolean
75
- @default YES
101
+ @default true
76
102
  */
77
- acceptsFirstResponder: YES,
103
+ acceptsFirstResponder: true,
78
104
 
79
105
  /** @private SC.CollectionView.prototype */
80
106
  exampleView: SC.ListItemView,
81
107
 
82
108
  /**
83
- If set to YES, the default theme will show alternating rows
109
+ Determines the layout direction of the rows of items, either vertically or
110
+ horizontally. Possible values:
111
+
112
+ - SC.LAYOUT_HORIZONTAL
113
+ - SC.LAYOUT_VERTICAL
114
+
115
+ @type String
116
+ @default SC.LAYOUT_VERTICAL
117
+ */
118
+ layoutDirection: SC.LAYOUT_VERTICAL,
119
+
120
+ /**
121
+ If set to true, the default theme will show alternating rows
84
122
  for the views this ListView created through exampleView property.
85
123
 
86
124
  @type Boolean
87
- @default NO
125
+ @default false
88
126
  */
89
- showAlternatingRows: NO,
90
-
127
+ showAlternatingRows: false,
91
128
 
92
129
  // ..........................................................
93
130
  // METHODS
94
131
  //
95
132
 
96
133
  /** @private */
97
- render: function(context, firstTime) {
134
+ init: function () {
135
+ sc_super();
136
+
137
+ this._sc_rowDelegateDidChange();
138
+ },
139
+
140
+ /** @private SC.CollectionView.prototype.destroy. */
141
+ destroy: function () {
142
+ sc_super();
143
+
144
+ // All manipulations made to objects we use must be reversed!
145
+ var del = this._sc_rowDelegate;
146
+ if (del) {
147
+ del.removeObserver('_sc_totalRowSize', this, this._sc_rowSizeDidChange);
148
+ del.removeObserver('customRowSizeIndexes', this, this._sc_customRowSizeIndexesDidChange);
149
+
150
+ this._sc_rowDelegate = null;
151
+ }
152
+
153
+ var customRowSizeIndexes = this._sc_customRowSizeIndexes;
154
+ if (customRowSizeIndexes) {
155
+ customRowSizeIndexes.removeObserver('[]', this, this._sc_customRowSizeIndexesContentDidChange);
156
+
157
+ this._sc_customRowSizeIndexes = null;
158
+ }
159
+ },
160
+
161
+ /** @private */
162
+ render: function (context, firstTime) {
98
163
  context.setClass('alternating', this.get('showAlternatingRows'));
99
164
 
100
165
  return sc_super();
101
166
  },
102
167
 
103
-
104
168
  // ..........................................................
105
169
  // COLLECTION ROW DELEGATE SUPPORT
106
170
  //
@@ -111,103 +175,107 @@ SC.ListView = SC.CollectionView.extend(SC.CollectionRowDelegate,
111
175
  @observes 'delegate'
112
176
  @observes 'content'
113
177
  */
114
- rowDelegate: function() {
178
+ rowDelegate: function () {
115
179
  var del = this.delegate,
116
- content = this.get('content');
180
+ content = this.get('content');
117
181
 
118
182
  return this.delegateFor('isCollectionRowDelegate', del, content);
119
183
  }.property('delegate', 'content').cacheable(),
120
184
 
121
- /** @private
122
- Whenever the rowDelegate changes, begin observing important properties
123
- */
124
- _sclv_rowDelegateDidChange: function() {
125
- var last = this._sclv_rowDelegate,
126
- del = this.get('rowDelegate'),
127
- func = this._sclv_rowHeightDidChange,
128
- func2 = this._sclv_customRowHeightIndexesDidChange;
185
+ /** @private - Whenever the rowDelegate changes, begin observing important properties */
186
+ _sc_rowDelegateDidChange: function () {
187
+ var last = this._sc_rowDelegate,
188
+ del = this.get('rowDelegate'),
189
+ func = this._sc_rowSizeDidChange,
190
+ func2 = this._sc_customRowSizeIndexesDidChange;
129
191
 
130
192
  if (last === del) return this; // nothing to do
131
- this._sclv_rowDelegate = del;
193
+ this._sc_rowDelegate = del;
132
194
 
133
195
  // last may be null on a new object
134
196
  if (last) {
135
- last.removeObserver('rowHeight', this, func);
136
- last.removeObserver('customRowHeightIndexes', this, func2);
197
+ last.removeObserver('_sc_totalRowSize', this, func);
198
+ last.removeObserver('customRowSizeIndexes', this, func2);
137
199
  }
138
200
 
201
+ //@if(debug)
139
202
  if (!del) {
140
- throw new Error("Internal Inconsistancy: ListView must always have CollectionRowDelegate");
203
+ throw new Error("%@ - Developer Error: SC.ListView must always have a rowDelegate.".fmt(this));
141
204
  }
205
+ //@endif
142
206
 
143
- del.addObserver('rowHeight', this, func);
144
- del.addObserver('customRowHeightIndexes', this, func2);
145
- this._sclv_rowHeightDidChange()._sclv_customRowHeightIndexesDidChange();
146
- return this ;
207
+ // Add the new observers.
208
+ del.addObserver('_sc_totalRowSize', this, func);
209
+ del.addObserver('customRowSizeIndexes', this, func2);
210
+
211
+ // Trigger once to initialize.
212
+ this._sc_rowSizeDidChange()._sc_customRowSizeIndexesDidChange();
213
+
214
+ return this;
147
215
  }.observes('rowDelegate'),
148
216
 
149
- /** @private
150
- called whenever the rowHeight changes. If the property actually changed
151
- then invalidate all row heights.
152
- */
153
- _sclv_rowHeightDidChange: function() {
217
+ /** @private - Called whenever the _sc_totalRowSize changes. If the property actually changed then invalidate all row sizes. */
218
+ _sc_rowSizeDidChange: function () {
154
219
  var del = this.get('rowDelegate'),
155
- height = del.get('rowHeight'),
156
- indexes;
220
+ totalRowSize = del.get('_sc_totalRowSize'),
221
+ indexes;
157
222
 
158
- if (height === this._sclv_rowHeight) return this; // nothing to do
159
- this._sclv_rowHeight = height;
223
+ if (totalRowSize === this._sc_rowSize) return this; // nothing to do
224
+ this._sc_rowSize = totalRowSize;
160
225
 
161
226
  indexes = SC.IndexSet.create(0, this.get('length'));
162
- this.rowHeightDidChangeForIndexes(indexes);
163
- return this ;
227
+ this.rowSizeDidChangeForIndexes(indexes);
228
+
229
+ return this;
164
230
  },
165
231
 
166
- /** @private
167
- called whenever the customRowHeightIndexes changes. If the property
168
- actually changed then invalidate affected row heights.
169
- */
170
- _sclv_customRowHeightIndexesDidChange: function() {
171
- var del = this.get('rowDelegate'),
172
- indexes = del.get('customRowHeightIndexes'),
173
- last = this._sclv_customRowHeightIndexes,
174
- func = this._sclv_customRowHeightIndexesContentDidChange;
232
+ /** @private - Called whenever the customRowSizeIndexes changes. If the property actually changed then invalidate affected row sizes. */
233
+ _sc_customRowSizeIndexesDidChange: function () {
234
+ var del = this.get('rowDelegate'),
235
+ indexes = del.get('customRowSizeIndexes'),
236
+ last = this._sc_customRowSizeIndexes,
237
+ func = this._sc_customRowSizeIndexesContentDidChange;
175
238
 
176
239
  // nothing to do
177
- if ((indexes===last) || (last && last.isEqual(indexes))) return this;
240
+ if ((indexes === last) || (last && last.isEqual(indexes))) return this;
178
241
 
179
242
  // if we were observing the last index set, then remove observer
180
- if (last && this._sclv_isObservingCustomRowHeightIndexes) {
243
+ if (last && this._sc_isObservingCustomRowSizeIndexes) {
181
244
  last.removeObserver('[]', this, func);
182
245
  }
183
246
 
184
247
  // only observe new index set if it exists and it is not frozen.
185
- if (this._sclv_isObservingCustomRowHeightIndexes = indexes && !indexes.get('isFrozen')) {
248
+ this._sc_isObservingCustomRowSizeIndexes = indexes;
249
+ if (indexes && !indexes.get('isFrozen')) {
186
250
  indexes.addObserver('[]', this, func);
187
251
  }
188
252
 
189
- this._sclv_customRowHeightIndexesContentDidChange();
190
- return this ;
253
+ // Trigger once to initialize.
254
+ this._sc_customRowSizeIndexesContentDidChange();
255
+
256
+ return this;
191
257
  },
192
258
 
193
- /** @private
194
- Called whenever the customRowHeightIndexes set is modified.
195
- */
196
- _sclv_customRowHeightIndexesContentDidChange: function() {
259
+ /** @private - Called whenever the customRowSizeIndexes set is modified. */
260
+ _sc_customRowSizeIndexesContentDidChange: function () {
197
261
  var del = this.get('rowDelegate'),
198
- indexes = del.get('customRowHeightIndexes'),
199
- last = this._sclv_customRowHeightIndexes,
200
- changed;
262
+ indexes = del.get('customRowSizeIndexes'),
263
+ last = this._sc_customRowSizeIndexes,
264
+ changed;
201
265
 
202
266
  // compute the set to invalidate. the union of cur and last set
203
267
  if (indexes && last) {
204
268
  changed = indexes.copy().add(last);
205
- } else changed = indexes || last ;
206
- this._sclv_customRowHeightIndexes = indexes ? indexes.frozenCopy() : null;
269
+ } else {
270
+ changed = indexes || last;
271
+ }
272
+
273
+ this._sc_customRowSizeIndexes = indexes ? indexes.frozenCopy() : null;
207
274
 
208
275
  // invalidate
209
- this.rowHeightDidChangeForIndexes(changed);
210
- return this ;
276
+ this.rowSizeDidChangeForIndexes(changed);
277
+
278
+ return this;
211
279
  },
212
280
 
213
281
 
@@ -216,115 +284,154 @@ SC.ListView = SC.CollectionView.extend(SC.CollectionRowDelegate,
216
284
  //
217
285
 
218
286
  /**
219
- Returns the top offset for the specified content index. This will take
220
- into account any custom row heights and group views.
287
+ Returns the top or left offset for the specified content index. This will take
288
+ into account any custom row sizes and group views.
221
289
 
222
290
  @param {Number} idx the content index
223
291
  @returns {Number} the row offset
224
292
  */
225
- rowOffsetForContentIndex: function(idx) {
226
- if (idx === 0) return 0 ; // fastpath
293
+ rowOffsetForContentIndex: function (idx) {
294
+ if (idx === 0) return 0; // Fast path!
227
295
 
228
- var del = this.get('rowDelegate'),
229
- rowHeight = del.get('rowHeight'),
230
- rowSpacing, ret, custom, cache, delta, max, content ;
296
+ var del = this.get('rowDelegate'),
297
+ totalRowSize = del.get('_sc_totalRowSize'),
298
+ rowSpacing = del.get('rowSpacing'),
299
+ ret, custom, cache, delta, max;
231
300
 
232
- ret = idx * rowHeight;
301
+ ret = idx * totalRowSize;
233
302
 
234
- rowSpacing = this.get('rowSpacing');
235
- if(rowSpacing){
303
+ if (rowSpacing) {
236
304
  ret += idx * rowSpacing;
237
305
  }
238
306
 
239
- if (del.customRowHeightIndexes && (custom=del.get('customRowHeightIndexes'))) {
307
+ if (del.customRowSizeIndexes && (custom = del.get('customRowSizeIndexes'))) {
240
308
 
241
309
  // prefill the cache with custom rows.
242
- cache = this._sclv_offsetCache;
310
+ cache = this._sc_offsetCache;
243
311
  if (!cache) {
244
312
  cache = [];
245
- delta = max = 0 ;
246
- custom.forEach(function(idx) {
247
- delta += this.rowHeightForContentIndex(idx)-rowHeight;
248
- cache[idx+1] = delta;
249
- max = idx ;
313
+ delta = max = 0;
314
+ custom.forEach(function (idx) {
315
+ delta += this.rowSizeForContentIndex(idx) - totalRowSize;
316
+ cache[idx + 1] = delta;
317
+ max = idx;
250
318
  }, this);
251
- this._sclv_max = max+1;
319
+ this._sc_max = max + 1;
320
+
252
321
  // moved down so that the cache is not marked as initialized until it actually is
253
- this._sclv_offsetCache = cache;
322
+ this._sc_offsetCache = cache;
254
323
  }
255
324
 
256
325
  // now just get the delta for the last custom row before the current
257
326
  // idx.
258
327
  delta = cache[idx];
259
328
  if (delta === undefined) {
260
- delta = cache[idx] = cache[idx-1];
329
+ delta = cache[idx] = cache[idx - 1];
261
330
  if (delta === undefined) {
262
- max = this._sclv_max;
263
- if (idx < max) max = custom.indexBefore(idx)+1;
331
+ max = this._sc_max;
332
+ if (idx < max) max = custom.indexBefore(idx) + 1;
264
333
  delta = cache[idx] = cache[max] || 0;
265
334
  }
266
335
  }
267
336
 
268
- ret += delta ;
337
+ ret += delta;
269
338
  }
270
339
 
271
- return ret ;
340
+ return ret;
272
341
  },
273
342
 
343
+ /** @deprecated Version 1.11. Please use the `rowSizeForContentIndex()` function instead.
344
+ Not implemented by default.
345
+
346
+ @field
347
+ @param {Number} idx content index
348
+ @returns {Number} the row height
349
+ */
350
+ rowHeightForContentIndex: null,
351
+
274
352
  /**
275
- Returns the row height for the specified content index. This will take
276
- into account custom row heights and group rows.
353
+ Returns the row size for the specified content index. This will take
354
+ into account custom row sizes and group rows.
277
355
 
278
356
  @param {Number} idx content index
279
357
  @returns {Number} the row height
280
358
  */
281
- rowHeightForContentIndex: function(idx) {
359
+ rowSizeForContentIndex: function (idx) {
282
360
  var del = this.get('rowDelegate'),
283
361
  ret, cache, content, indexes;
284
362
 
285
- if (del.customRowHeightIndexes && (indexes=del.get('customRowHeightIndexes'))) {
286
- cache = this._sclv_heightCache ;
363
+ if (this.rowHeightForContentIndex) {
364
+ //@if(debug)
365
+ SC.warn('Developer Warning: The rowHeightForContentIndex() method of SC.ListView has been renamed rowSizeForContentIndex().');
366
+ //@endif
367
+ return this.rowHeightForContentIndex(idx);
368
+ }
369
+
370
+ if (del.customRowSizeIndexes && (indexes = del.get('customRowSizeIndexes'))) {
371
+ cache = this._sc_sizeCache;
287
372
  if (!cache) {
288
373
  cache = [];
289
374
  content = this.get('content');
290
- indexes.forEach(function(idx) {
291
- cache[idx] = del.contentIndexRowHeight(this, content, idx);
375
+ indexes.forEach(function (idx) {
376
+ cache[idx] = del.contentIndexRowSize(this, content, idx);
292
377
  }, this);
293
- // moved down so that the cache is not marked as initialized until it actually is
294
- this._sclv_heightCache = cache;
378
+
379
+ // moved down so that the cache is not marked as initialized until it actually is.
380
+ this._sc_sizeCache = cache;
295
381
  }
296
382
 
297
383
  ret = cache[idx];
298
- if (ret === undefined) ret = del.get('rowHeight');
299
- } else ret = del.get('rowHeight');
384
+ if (ret === undefined) ret = del.get('_sc_totalRowSize');
385
+ } else {
386
+ ret = del.get('_sc_totalRowSize');
387
+ }
300
388
 
301
- return ret ;
389
+ return ret;
302
390
  },
303
391
 
304
- /**
392
+ /** @deprecated Version 1.11. Please use the `rowSizeDidChangeForIndexes()` function instead.
305
393
  Call this method whenever a row height has changed in one or more indexes.
306
394
  This will invalidate the row height cache and reload the content indexes.
307
395
  Pass either an index set or a single index number.
308
396
 
309
- This method is called automatically whenever you change the rowHeight
310
- or customRowHeightIndexes properties on the collectionRowDelegate.
397
+ This method is called automatically whenever you change the rowSize, rowPadding
398
+ or customRowSizeIndexes properties on the collectionRowDelegate.
399
+
400
+ @param {SC.IndexSet|Number} indexes
401
+ @returns {SC.ListView} receiver
402
+ */
403
+ rowHeightDidChangeForIndexes: function (indexes) {
404
+ //@if(debug)
405
+ SC.warn('Developer Warning: The rowHeightDidChangeForIndexes() function of SC.ListView has been renamed to rowSizeDidChangeForIndexes().');
406
+ //@endif
407
+ return this.rowSizeDidChangeForIndexes(indexes);
408
+ },
409
+
410
+ /**
411
+ Call this method whenever a row size has changed in one or more indexes.
412
+ This will invalidate the row size cache and reload the content indexes.
413
+ Pass either an index set or a single index number.
414
+
415
+ This method is called automatically whenever you change the rowSize, rowPadding
416
+ or customRowSizeIndexes properties on the collectionRowDelegate.
311
417
 
312
418
  @param {SC.IndexSet|Number} indexes
313
419
  @returns {SC.ListView} receiver
314
420
  */
315
- rowHeightDidChangeForIndexes: function(indexes) {
421
+ rowSizeDidChangeForIndexes: function (indexes) {
316
422
  var len = this.get('length');
317
423
 
318
424
  // clear any cached offsets
319
- this._sclv_heightCache = this._sclv_offsetCache = null;
425
+ this._sc_sizeCache = this._sc_offsetCache = null;
320
426
 
321
427
  // find the smallest index changed; invalidate everything past it
322
428
  if (indexes && indexes.isIndexSet) indexes = indexes.get('min');
323
- this.reload(SC.IndexSet.create(indexes, len-indexes));
429
+ this.reload(SC.IndexSet.create(indexes, len - indexes));
324
430
 
325
431
  // If the row height changes, our entire layout needs to change.
326
432
  this.invokeOnce('adjustLayout');
327
- return this ;
433
+
434
+ return this;
328
435
  },
329
436
 
330
437
  // ..........................................................
@@ -335,13 +442,25 @@ SC.ListView = SC.CollectionView.extend(SC.CollectionRowDelegate,
335
442
  The layout for a ListView is computed from the total number of rows
336
443
  along with any custom row heights.
337
444
  */
338
- computeLayout: function() {
445
+ computeLayout: function () {
339
446
  // default layout
340
- var ret = this._sclv_layout;
341
- if (!ret) ret = this._sclv_layout = {};
342
- ret.minHeight = this.rowOffsetForContentIndex(this.get('length'));
343
- this.set('calculatedHeight', ret.minHeight);
344
- return ret ;
447
+ var ret = this._sc_layout,
448
+ layoutDirection = this.get('layoutDirection'),
449
+ del = this.get('rowDelegate'),
450
+ rowSpacing = del.get('rowSpacing');
451
+
452
+ // Initialize lazily.
453
+ if (!ret) ret = this._sc_layout = {};
454
+
455
+ // Support both vertical and horizontal lists.
456
+ if (layoutDirection === SC.LAYOUT_HORIZONTAL) {
457
+ // Don't include the row spacing after the last item in the width.
458
+ ret.width = Math.max(this.rowOffsetForContentIndex(this.get('length')) - rowSpacing, 0);
459
+ } else {
460
+ // Don't include the row spacing after the last item in the height.
461
+ ret.height = Math.max(this.rowOffsetForContentIndex(this.get('length')) - rowSpacing, 0);
462
+ }
463
+ return ret;
345
464
  },
346
465
 
347
466
  /**
@@ -351,15 +470,30 @@ SC.ListView = SC.CollectionView.extend(SC.CollectionRowDelegate,
351
470
  @param {Number} contentIndex
352
471
  @returns {Hash} layout hash for the index provided
353
472
  */
354
- layoutForContentIndex: function(contentIndex) {
355
- var del = this.get('rowDelegate');
356
-
357
- return {
358
- top: this.rowOffsetForContentIndex(contentIndex),
359
- height: this.rowHeightForContentIndex(contentIndex) - del.get('rowPadding') * 2,
360
- left: 0,
361
- right: 0
362
- };
473
+ layoutForContentIndex: function (contentIndex) {
474
+ var del = this.get('rowDelegate'),
475
+ layoutDirection = this.get('layoutDirection'),
476
+ offset, size;
477
+
478
+ offset = this.rowOffsetForContentIndex(contentIndex);
479
+ size = this.rowSizeForContentIndex(contentIndex) - del.get('rowPadding') * 2;
480
+
481
+ // Support both vertical and horizontal lists.
482
+ if (layoutDirection === SC.LAYOUT_HORIZONTAL) {
483
+ return {
484
+ left: offset,
485
+ width: size,
486
+ top: 0,
487
+ bottom: 0
488
+ };
489
+ } else {
490
+ return {
491
+ top: offset,
492
+ height: size,
493
+ left: 0,
494
+ right: 0
495
+ };
496
+ }
363
497
  },
364
498
 
365
499
  /**
@@ -375,61 +509,75 @@ SC.ListView = SC.CollectionView.extend(SC.CollectionRowDelegate,
375
509
  @param {Rect} rect the visible rect or a point
376
510
  @returns {SC.IndexSet} now showing indexes
377
511
  */
378
- contentIndexesInRect: function(rect) {
379
- var rowHeight = this.get('rowDelegate').get('rowHeight'),
380
- top = SC.minY(rect),
381
- bottom = SC.maxY(rect),
382
- height = rect.height || 0,
383
- len = this.get('length'),
384
- offset, start, end;
512
+ contentIndexesInRect: function (rect) {
513
+ var del = this.get('rowDelegate'),
514
+ totalRowSize = del.get('_sc_totalRowSize'),
515
+ rowSpacing = del.get('rowSpacing'),
516
+ totalRowSizeWithSpacing = totalRowSize + rowSpacing,
517
+ layoutDirection = this.get('layoutDirection'),
518
+ len = this.get('length'),
519
+ offset, start, end,
520
+ firstEdge, lastEdge,
521
+ size;
522
+
523
+ // Support both vertical and horizontal lists.
524
+ if (layoutDirection === SC.LAYOUT_HORIZONTAL) {
525
+ firstEdge = SC.minX(rect);
526
+ lastEdge = SC.maxX(rect);
527
+ size = rect.width || 0;
528
+ } else {
529
+ firstEdge = SC.minY(rect);
530
+ lastEdge = SC.maxY(rect);
531
+ size = rect.height || 0;
532
+ }
385
533
 
386
534
  // estimate the starting row and then get actual offsets until we are
387
535
  // right.
388
- start = (top - (top % rowHeight)) / rowHeight;
536
+ start = (firstEdge - (firstEdge % totalRowSizeWithSpacing)) / totalRowSizeWithSpacing;
389
537
  offset = this.rowOffsetForContentIndex(start);
390
538
 
391
- // go backwards until top of row is before top edge
392
- while(start>0 && offset>top) {
539
+ // go backwards until offset of row is before first edge
540
+ while (start > 0 && offset > firstEdge) {
393
541
  start--;
394
- offset -= this.rowHeightForContentIndex(start);
542
+ offset -= (this.rowSizeForContentIndex(start) + rowSpacing);
395
543
  }
396
544
 
397
- // go forwards until bottom of row is after top edge
398
- offset += this.rowHeightForContentIndex(start);
399
- while(start<len && offset<=top) {
545
+ // go forwards until offset plus size of row is after first edge
546
+ offset += this.rowSizeForContentIndex(start);
547
+ while (start < len && offset <= firstEdge) {
400
548
  start++;
401
- offset += this.rowHeightForContentIndex(start);
549
+ offset += this.rowSizeForContentIndex(start) + rowSpacing;
402
550
  }
403
- if (start<0) start = 0;
404
- if (start>=len) start=len;
551
+ if (start < 0) start = 0;
552
+ if (start >= len) start = len;
405
553
 
406
554
 
407
555
  // estimate the final row and then get the actual offsets until we are
408
556
  // right. - look at the offset of the _following_ row
409
- end = start + ((height - (height % rowHeight)) / rowHeight) ;
557
+ end = start + ((size - (size % totalRowSizeWithSpacing)) / totalRowSizeWithSpacing);
410
558
  if (end > len) end = len;
411
559
  offset = this.rowOffsetForContentIndex(end);
412
560
 
413
- // walk backwards until top of row is before or at bottom edge
414
- while(end>=start && offset>=bottom) {
561
+ // walk backwards until offset of row is before or at last edge
562
+ while (end >= start && offset >= lastEdge) {
415
563
  end--;
416
- offset -= this.rowHeightForContentIndex(end);
564
+ offset -= (this.rowSizeForContentIndex(end) + rowSpacing);
417
565
  }
418
566
 
419
- // go forwards until bottom of row is after bottom edge
420
- offset += this.rowHeightForContentIndex(end);
421
- while(end<len && offset<bottom) {
567
+ // go forwards until offset plus size of row is after last edge
568
+ offset += this.rowSizeForContentIndex(end) + rowSpacing;
569
+ while (end < len && offset < lastEdge) {
422
570
  end++;
423
- offset += this.rowHeightForContentIndex(end);
571
+ offset += this.rowSizeForContentIndex(end) + rowSpacing;
424
572
  }
425
573
 
426
574
  end++; // end should be after start
427
575
 
428
- if (end<start) end = start;
429
- if (end>len) end = len ;
576
+ if (end < start) end = start;
577
+ if (end > len) end = len;
430
578
 
431
579
  // convert to IndexSet and return
432
- return SC.IndexSet.create(start, end-start);
580
+ return SC.IndexSet.create(start, end - start);
433
581
  },
434
582
 
435
583
 
@@ -450,10 +598,30 @@ SC.ListView = SC.CollectionView.extend(SC.CollectionRowDelegate,
450
598
  insertionPointView: SC.View.extend({
451
599
  classNames: 'sc-list-insertion-point',
452
600
 
453
- layout: { height: 2 },
601
+ layout: function (key, value) {
602
+ var layoutDirection = this.get('layoutDirection');
603
+
604
+ key = layoutDirection === SC.LAYOUT_HORIZONTAL ? 'width' : 'height';
605
+
606
+ // Getter – create layout hash.
607
+ if (value === undefined) {
608
+ value = {};
609
+ }
610
+
611
+ // Either way, add the narrow dimension to the layout if needed.
612
+ if (SC.none(value[key])) value[key] = 2;
613
+
614
+ return value;
615
+ }.property('layoutDirection').cacheable(),
616
+
617
+ /**
618
+ The direction of layout of the SC.ListView.
619
+ This property will be set by the list view when this view is created.
620
+ */
621
+ layoutDirection: SC.LAYOUT_VERTICAL,
454
622
 
455
623
  /** @private */
456
- render: function(context, firstTime) {
624
+ render: function (context, firstTime) {
457
625
  if (firstTime) context.push('<div class="anchor"></div>');
458
626
  }
459
627
  }),
@@ -463,26 +631,11 @@ SC.ListView = SC.CollectionView.extend(SC.CollectionRowDelegate,
463
631
  @see SC.CollectionView#showInsertionPoint
464
632
  */
465
633
  showInsertionPoint: function (itemView, dropOperation) {
466
- var index = itemView.get('contentIndex'),
467
- len = this.get('length'),
468
- level = itemView.get('outlineLevel'),
469
- indent = itemView.get('outlineIndent') || 0;
470
-
471
- // show item indented if we are inserting at the end and the last item
472
- // is a group item. This is a special case that should really be
473
- // converted into a more general protocol.
474
- if ((index >= len) && index>0) {
475
- var group = this.itemViewForContentIndex(len - 1);
476
- if (group.get('isGroupView')) {
477
- level = 1;
478
- indent = group.get('outlineIndent');
479
- }
480
- }
481
-
482
- if (SC.none(level)) level = -1;
483
-
634
+ // FAST PATH: If we're dropping on the item view itself... (Note: support for this
635
+ // should be built into CollectionView's calling method and not the unrelated method
636
+ // for showing an insertion point.)
484
637
  if (dropOperation & SC.DROP_ON) {
485
- if (itemView !== this._lastDropOnView) {
638
+ if (itemView && itemView !== this._sc_lastDropOnView) {
486
639
  this.hideInsertionPoint();
487
640
 
488
641
  // If the drag is supposed to drop onto an item, notify the item that it
@@ -491,46 +644,95 @@ SC.ListView = SC.CollectionView.extend(SC.CollectionRowDelegate,
491
644
 
492
645
  // Track the item so that we can clear isDropTarget when the drag changes;
493
646
  // versus having to clear it from all items.
494
- this._lastDropOnView = itemView;
495
- }
496
- } else {
497
- if (this._lastDropOnView) {
498
- // If there was an item that was the target of the drop previously, be
499
- // sure to clear it.
500
- this._lastDropOnView.set('isDropTarget', NO);
501
- this._lastDropOnView = null;
647
+ this._sc_lastDropOnView = itemView;
502
648
  }
649
+ return;
650
+ }
651
+
652
+ // Otherwise, we're actually inserting.
503
653
 
504
- var insertionPoint = this._insertionPointView,
505
- layout = itemView.get('layout'),
506
- top, left;
654
+ // TODO: CollectionView's notes on showInsertionPoint specify that if no itemView
655
+ // is passed, this should try to get the last itemView. (Note that ListView's
656
+ // itemViewForContentIndex creates a new view on demand, so make sure that we
657
+ // have content items before getting the last view.) This is a change in established
658
+ // behavior however, so proceed carefully.
659
+
660
+ // If there was an item that was the target of the drop previously, be
661
+ // sure to clear it.
662
+ if (this._sc_lastDropOnView) {
663
+ this._sc_lastDropOnView.set('isDropTarget', NO);
664
+ this._sc_lastDropOnView = null;
665
+ }
507
666
 
508
- if (!insertionPoint) {
509
- insertionPoint = this._insertionPointView = this.get('insertionPointView').create();
667
+ var len = this.get('length'),
668
+ index, level, indent;
669
+
670
+ // Get values from itemView, if present.
671
+ if (itemView) {
672
+ index = itemView.get('contentIndex');
673
+ level = itemView.get('outlineLevel');
674
+ indent = itemView.get('outlineIndent');
675
+ }
676
+
677
+ // Set defaults.
678
+ index = index || 0;
679
+ if (SC.none(level)) level = -1;
680
+ indent = indent || 0;
681
+
682
+ // Show item indented if we are inserting at the end and the last item
683
+ // is a group item. This is a special case that should really be
684
+ // converted into a more general protocol.
685
+ if ((index >= len) && index > 0) {
686
+ var previousItem = this.itemViewForContentIndex(len - 1);
687
+ if (previousItem.get('isGroupView')) {
688
+ level = 1;
689
+ indent = previousItem.get('outlineIndent');
510
690
  }
691
+ }
511
692
 
512
- // Adjust the position of the insertion point.
513
- top = layout.top;
514
- if (dropOperation & SC.DROP_AFTER) top += layout.height;
515
- left = ((level + 1) * indent) + 12;
693
+ // Get insertion point.
694
+ var insertionPoint = this._sc_insertionPointView,
695
+ layoutDirection = this.get('layoutDirection');
696
+
697
+ if (!insertionPoint) {
698
+ insertionPoint = this._sc_insertionPointView = this.get('insertionPointView').create({
699
+ layoutDirection: layoutDirection
700
+ });
701
+ }
516
702
 
517
- insertionPoint.adjust({ top: top, left: left });
518
- this.appendChild(insertionPoint);
703
+ // Calculate where it should go.
704
+ var itemViewLayout = itemView ? itemView.get('layout') : { top: 0, left: 0 },
705
+ top, left;
706
+
707
+ // Support both vertical and horizontal lists.
708
+ if (layoutDirection === SC.LAYOUT_HORIZONTAL) {
709
+ left = itemViewLayout.left;
710
+ if (dropOperation & SC.DROP_AFTER) { left += itemViewLayout.width; }
711
+ top = ((level + 1) * indent) + 12;
712
+ } else {
713
+ top = itemViewLayout.top;
714
+ if (dropOperation & SC.DROP_AFTER) { top += itemViewLayout.height; }
715
+ left = ((level + 1) * indent) + 12;
519
716
  }
717
+
718
+ // Put it there.
719
+ insertionPoint.adjust({ top: top, left: left });
720
+
721
+ this.appendChild(insertionPoint);
520
722
  },
521
723
 
522
724
  /** @see SC.CollectionView#hideInsertionPoint */
523
- hideInsertionPoint: function() {
725
+ hideInsertionPoint: function () {
524
726
  // If there was an item that was the target of the drop previously, be
525
727
  // sure to clear it.
526
- if (this._lastDropOnView) {
527
- this._lastDropOnView.set('isDropTarget', NO);
528
- this._lastDropOnView = null;
728
+ if (this._sc_lastDropOnView) {
729
+ this._sc_lastDropOnView.set('isDropTarget', NO);
730
+ this._sc_lastDropOnView = null;
529
731
  }
530
732
 
531
- var view = this._insertionPointView;
733
+ var view = this._sc_insertionPointView;
532
734
  if (view) view.removeFromParent().destroy();
533
- this._insertionPointView = null;
735
+ this._sc_insertionPointView = null;
534
736
  },
535
737
 
536
738
  /**
@@ -548,12 +750,12 @@ SC.ListView = SC.CollectionView.extend(SC.CollectionRowDelegate,
548
750
 
549
751
  @see SC.CollectionView.insertionIndexForLocation
550
752
  */
551
- insertionIndexForLocation: function(loc, dropOperation) {
552
- var locRect = {x:loc.x, y:loc.y, width:1, height:1},
553
- indexes = this.contentIndexesInRect(locRect),
554
- index = indexes.get('min'),
555
- len = this.get('length'),
556
- min, max, diff, clevel, cindent, plevel, pindent, itemView, pgroup;
753
+ insertionIndexForLocation: function (loc, dropOperation) {
754
+ var locRect = { x: loc.x, y: loc.y, width: 1, height: 1 },
755
+ indexes = this.contentIndexesInRect(locRect),
756
+ index = indexes.get('min'),
757
+ len = this.get('length'),
758
+ min, max, diff, clevel, cindent, plevel, pindent, itemView;
557
759
 
558
760
  // if there are no indexes in the rect, then we need to either insert
559
761
  // before the top item or after the last item. Figure that out by
@@ -565,11 +767,11 @@ SC.ListView = SC.CollectionView.extend(SC.CollectionRowDelegate,
565
767
 
566
768
  // figure the range of the row the location must be within.
567
769
  min = this.rowOffsetForContentIndex(index);
568
- max = min + this.rowHeightForContentIndex(index);
770
+ max = min + this.rowSizeForContentIndex(index);
569
771
 
570
772
  // now we know which index we are in. if dropOperation is DROP_ON, figure
571
773
  // if we can drop on or not.
572
- if (dropOperation == SC.DROP_ON) {
774
+ if (dropOperation === SC.DROP_ON) {
573
775
  // editable size - reduce height by a bit to handle dropping
574
776
  if (this.get('isEditable')) diff = Math.min(Math.floor((max - min) * 0.2), 5);
575
777
  else diff = 0;
@@ -582,13 +784,13 @@ SC.ListView = SC.CollectionView.extend(SC.CollectionRowDelegate,
582
784
 
583
785
  // finally, let's decide if we want to actually insert before/after. Only
584
786
  // matters if we are using outlining.
585
- if (index>0) {
787
+ if (index > 0) {
586
788
 
587
- itemView = this.itemViewForContentIndex(index-1);
789
+ itemView = this.itemViewForContentIndex(index - 1);
588
790
  pindent = (itemView ? itemView.get('outlineIndent') : 0) || 0;
589
791
  plevel = itemView ? itemView.get('outlineLevel') : 0;
590
792
 
591
- if (index<len) {
793
+ if (index < len) {
592
794
  itemView = this.itemViewForContentIndex(index);
593
795
  clevel = itemView ? itemView.get('outlineLevel') : 0;
594
796
  cindent = (itemView ? itemView.get('outlineIndent') : 0) || 0;
@@ -598,7 +800,7 @@ SC.ListView = SC.CollectionView.extend(SC.CollectionRowDelegate,
598
800
  cindent = pindent * clevel;
599
801
  }
600
802
 
601
- pindent *= plevel;
803
+ pindent *= plevel;
602
804
 
603
805
  // if indent levels are different, then try to figure out which level
604
806
  // it should be on.
@@ -619,37 +821,27 @@ SC.ListView = SC.CollectionView.extend(SC.CollectionRowDelegate,
619
821
  // and dropping at length, last item must not be a group
620
822
  //
621
823
  if (dropOperation === SC.DROP_BEFORE) {
622
- itemView = (index<len) ? this.itemViewForContentIndex(index) : null;
824
+ itemView = (index < len) ? this.itemViewForContentIndex(index) : null;
623
825
  if (!itemView || itemView.get('isGroupView')) {
624
- if (index>0) {
625
- itemView = this.itemViewForContentIndex(index-1);
826
+ if (index > 0) {
827
+ itemView = this.itemViewForContentIndex(index - 1);
626
828
 
627
829
  // don't allow a drop if the previous item is a group view and we're
628
830
  // insert before the end. For the end, allow the drop if the
629
831
  // previous item is a group view but OPEN.
630
832
  if (!itemView.get('isGroupView') || (itemView.get('disclosureState') === SC.BRANCH_OPEN)) {
631
- index = index-1;
833
+ index = index - 1;
632
834
  dropOperation = SC.DROP_AFTER;
633
835
  } else index = -1;
634
836
 
635
837
  } else index = -1;
636
838
  }
637
839
 
638
- if (index<0) dropOperation = SC.DRAG_NONE ;
840
+ if (index < 0) dropOperation = SC.DRAG_NONE;
639
841
  }
640
842
 
641
843
  // return whatever we came up with
642
844
  return [index, dropOperation];
643
- },
644
-
645
- // ..........................................................
646
- // INTERNAL SUPPORT
647
- //
648
-
649
- /** @private */
650
- init: function() {
651
- sc_super();
652
- this._sclv_rowDelegateDidChange();
653
845
  }
654
846
 
655
847
  });