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
@@ -1,256 +0,0 @@
1
- // ==========================================================================
2
- // Project: SproutCore - JavaScript Application Framework
3
- // Copyright: ©2006-2011 Strobe Inc. and contributors.
4
- // portions copyright @2011 Apple Inc.
5
- // License: Licensed under MIT license (see license.js)
6
- // ==========================================================================
7
-
8
- /*global module test ok equals same stop start */
9
-
10
- (function() {
11
- var appleURL="http://photos4.meetupstatic.com/photos/event/4/6/9/9/600_4518073.jpeg";
12
- var iv=SC.ImageView.design({value: appleURL, layout: {height:400, width:400}});
13
- var pane = SC.ControlTestPane.design({ height: 100 })
14
- .add("basic", SC.ScrollView, {
15
-
16
- })
17
-
18
- .add("basic2", SC.ScrollView, {
19
- contentView: iv
20
- })
21
-
22
- .add("basic3", SC.ScrollView, {
23
- contentView: iv,
24
- isHorizontalScrollerVisible: NO,
25
- autohidesHorizontalScroller: NO,
26
- autohidesVerticalScroller: NO
27
- })
28
-
29
- .add("nestedHoriz", SC.ScrollView, {
30
- layout: { width: 100, height: 440 },
31
-
32
- contentView: SC.ScrollView.design({
33
- layout: { width: 200, height: 420 },
34
- contentView: iv
35
- })
36
- })
37
-
38
- .add("nestedVert", SC.ScrollView, {
39
- layout: { width: 440, height: 100 },
40
-
41
- contentView: SC.ScrollView.design({
42
- layout: { width: 420, height: 200 },
43
- contentView: iv
44
- })
45
- })
46
-
47
- .add("nestedVertInHoriz", SC.ScrollView, {
48
- layout: { width: 100, height: 220 },
49
-
50
- contentView: SC.ScrollView.design({
51
- layout: { width: 420, height: 200 },
52
- contentView: iv
53
- })
54
- })
55
-
56
- .add("nestedHorizInVert", SC.ScrollView, {
57
- layout: { width: 220, height: 100 },
58
-
59
- contentView: SC.ScrollView.design({
60
- layout: { width: 200, height: 420 },
61
- contentView: iv
62
- })
63
- })
64
-
65
- .add("disabled", SC.ScrollView, {
66
- isEnabled: NO
67
- })
68
-
69
- .add("verticalScrollerBottom",SC.ScrollView, {
70
- contentView: iv,
71
- hasHorizontalScroller : NO,
72
- verticalScrollerBottom: 16,
73
- isVerticalScrollerVisible: YES,
74
- autohidesVerticalScroller: NO
75
-
76
- })
77
- .add("aria-controls_attribute", SC.ScrollView, {
78
- contentView: iv
79
- });
80
-
81
- // ..........................................................
82
- // TEST VIEWS
83
- //
84
- module('SC.ScrollView UI', pane.standardSetup());
85
-
86
- test("basic", function() {
87
- var view = pane.view('basic');
88
- ok(!view.$().hasClass('disabled'), 'should not have disabled class');
89
- ok(!view.$().hasClass('sel'), 'should not have sel class');
90
-
91
- equals(view.getPath('childViews.length'), 3, 'scroll view should have only three child views');
92
-
93
- var containerView = view.get('containerView') ;
94
- ok(containerView, 'scroll views should have a container view');
95
- ok(containerView.kindOf(SC.ContainerView), 'default containerView is a kind of SC.ContainerView');
96
- ok(containerView.get('contentView') === null, 'default containerView should have a null contentView itself');
97
- ok(view.get('contentView') === null, 'scroll view should have no contentView by default');
98
- equals(containerView.getPath('childViews.length'), 0, 'containerView should have no child views');
99
-
100
- var horizontalScrollerView = view.get('horizontalScrollerView');
101
- ok(view.get('hasHorizontalScroller'), 'default scroll view wants a horizontal scroller');
102
- ok(horizontalScrollerView, 'default scroll view has a horizontal scroller');
103
-
104
- var verticalScrollerView = view.get('verticalScrollerView');
105
- ok(view.get('hasVerticalScroller'), 'default scroll view wants a vertical scroller');
106
- ok(verticalScrollerView, 'default scroll view has a vertical scroller');
107
- });
108
-
109
- test("basic2", function() {
110
- var view = pane.view('basic2');
111
- ok(view.$().hasClass('sc-scroll-view'), 'should have sc-scroll-view class');
112
-
113
- var horizontalScrollerView = view.get('horizontalScrollerView');
114
- ok(view.get('hasHorizontalScroller'), 'default scroll view wants a horizontal scroller');
115
- ok(horizontalScrollerView, 'default scroll view has a horizontal scroller');
116
- ok(horizontalScrollerView.$().hasClass('sc-horizontal'), 'should have sc-horizontal class');
117
- var maxHScroll = view.maximumHorizontalScrollOffset();
118
- ok((maxHScroll > 0), 'Max horizontal scroll should be greater than zero');
119
-
120
- var verticalScrollerView = view.get('verticalScrollerView');
121
- ok(view.get('hasVerticalScroller'), 'default scroll view wants a vertical scroller');
122
- ok(verticalScrollerView, 'default scroll view has a vertical scroller');
123
- ok(verticalScrollerView.$().hasClass('sc-vertical'), 'should have sc-vertical class');
124
- var maxVScroll = view.maximumVerticalScrollOffset();
125
- ok((maxVScroll > 0), 'Max vertical scroll should be greater than zero');
126
-
127
- view.scrollTo(0,100);
128
- SC.RunLoop.begin().end();
129
- var elem = view.get('containerView').$()[0];
130
- equals(elem.scrollTop, 100, 'vertical scrolling should adjust scrollTop of container view');
131
-
132
- view.scrollTo(50,0);
133
- SC.RunLoop.begin().end();
134
- elem = view.get('containerView').$()[0];
135
- equals(elem.scrollLeft, 50, 'horizontal scrolling should adjust scrollLeft of container view');
136
- });
137
-
138
- test("basic3", function() {
139
- var view = pane.view('basic3');
140
- view.set('isHorizontalScrollerVisible',NO);
141
- ok(!view.get('canScrollHorizontal'),'cannot scroll in horizontal direction');
142
- ok(view.$().hasClass('sc-scroll-view'), 'should have sc-scroll-view class');
143
- var horizontalScrollerView = view.get('horizontalScrollerView');
144
- ok(view.get('hasHorizontalScroller'), 'default scroll view wants a horizontal scroller');
145
- ok(horizontalScrollerView, 'default scroll view has a horizontal scroller');
146
- ok(horizontalScrollerView.$().hasClass('sc-horizontal'), 'should have sc-horizontal class');
147
- var maxHScroll = view.maximumHorizontalScrollOffset();
148
- equals(maxHScroll , 0, 'Max horizontal scroll should be equal to zero');
149
-
150
- view.set('isVerticalScrollerVisible',NO);
151
- ok(!view.get('canScrollVertical'),'cannot scroll in vertical direction');
152
- var verticalScrollerView = view.get('verticalScrollerView');
153
- ok(view.get('hasVerticalScroller'), 'default scroll view wants a vertical scroller');
154
- ok(verticalScrollerView, 'default scroll view has a vertical scroller');
155
- ok(verticalScrollerView.$().hasClass('sc-vertical'), 'should have sc-vertical class');
156
- var maxVScroll = view.maximumVerticalScrollOffset();
157
- equals(maxVScroll ,0, 'Max vertical scroll should be equal to zero');
158
- });
159
-
160
- test("nestedHoriz", function() {
161
- var view = pane.view('nestedHoriz');
162
- ok(view.get('canScrollHorizontal'),'can scroll in horizontal direction');
163
- ok(!view.get('canScrollVertical'),'cannot scroll in vertical direction');
164
- ok(view.$().hasClass('sc-scroll-view'), 'should have sc-scroll-view class');
165
- equals(view.$('> .sc-scroll-container-view').css('overflow-x'), 'scroll', 'should have \'overflow-x\': \'scroll\' style');
166
- equals(view.$('> .sc-scroll-container-view').css('overflow-y'), 'hidden', 'should have \'overflow-y\': \'hidden\' style');
167
- var nestedView = view.get('contentView');
168
- ok(nestedView.get('canScrollHorizontal'),'can scroll in horizontal direction');
169
- ok(!nestedView.get('canScrollVertical'),'cannot scroll in vertical direction');
170
- ok(nestedView.$().hasClass('sc-scroll-view'), 'should have sc-scroll-view class');
171
- equals(nestedView.$('> .sc-scroll-container-view').css('overflow-x'), 'scroll', 'should have \'overflow-x\': \'scroll\' style');
172
- equals(nestedView.$('> .sc-scroll-container-view').css('overflow-y'), 'hidden', 'should have \'overflow-y\': \'hidden\' style');
173
- });
174
-
175
- test("nestedVert", function() {
176
- var view = pane.view('nestedVert');
177
- ok(!view.get('canScrollHorizontal'),'can scroll in horizontal direction');
178
- ok(view.get('canScrollVertical'),'cannot scroll in vertical direction');
179
- ok(view.$().hasClass('sc-scroll-view'), 'should have sc-scroll-view class');
180
- equals(view.$('> .sc-scroll-container-view').css('overflow-x'), 'hidden', 'should have \'overflow-x\': \'scroll\' style');
181
- equals(view.$('> .sc-scroll-container-view').css('overflow-y'), 'scroll', 'should have \'overflow-y\': \'hidden\' style');
182
- var nestedView = view.get('contentView');
183
- ok(!nestedView.get('canScrollHorizontal'),'can scroll in horizontal direction');
184
- ok(nestedView.get('canScrollVertical'),'cannot scroll in vertical direction');
185
- ok(nestedView.$().hasClass('sc-scroll-view'), 'should have sc-scroll-view class');
186
- equals(nestedView.$('> .sc-scroll-container-view').css('overflow-x'), 'hidden', 'should have \'overflow-x\': \'scroll\' style');
187
- equals(nestedView.$('> .sc-scroll-container-view').css('overflow-y'), 'scroll', 'should have \'overflow-y\': \'hidden\' style');
188
- });
189
-
190
- test("nestedVertInHoriz", function() {
191
- var view = pane.view('nestedVertInHoriz');
192
- ok(view.get('canScrollHorizontal'),'can scroll in horizontal direction');
193
- ok(!view.get('canScrollVertical'),'cannot scroll in vertical direction');
194
- ok(view.$().hasClass('sc-scroll-view'), 'should have sc-scroll-view class');
195
- equals(view.$('> .sc-scroll-container-view').css('overflow-x'), 'scroll', 'should have \'overflow-x\': \'scroll\' style');
196
- equals(view.$('> .sc-scroll-container-view').css('overflow-y'), 'hidden', 'should have \'overflow-y\': \'hidden\' style');
197
- var nestedView = view.get('contentView');
198
- ok(!nestedView.get('canScrollHorizontal'),'can scroll in horizontal direction');
199
- ok(nestedView.get('canScrollVertical'),'cannot scroll in vertical direction');
200
- ok(nestedView.$().hasClass('sc-scroll-view'), 'should have sc-scroll-view class');
201
- equals(nestedView.$('> .sc-scroll-container-view').css('overflow-x'), 'hidden', 'should have \'overflow-x\': \'scroll\' style');
202
- equals(nestedView.$('> .sc-scroll-container-view').css('overflow-y'), 'scroll', 'should have \'overflow-y\': \'hidden\' style');
203
- });
204
-
205
- test("nestedHorizInVert", function() {
206
- var view = pane.view('nestedHorizInVert');
207
- ok(!view.get('canScrollHorizontal'),'can scroll in horizontal direction');
208
- ok(view.get('canScrollVertical'),'cannot scroll in vertical direction');
209
- ok(view.$().hasClass('sc-scroll-view'), 'should have sc-scroll-view class');
210
- equals(view.$('> .sc-scroll-container-view').css('overflow-x'), 'hidden', 'should have \'overflow-x\': \'scroll\' style');
211
- equals(view.$('> .sc-scroll-container-view').css('overflow-y'), 'scroll', 'should have \'overflow-y\': \'hidden\' style');
212
- var nestedView = view.get('contentView');
213
- ok(nestedView.get('canScrollHorizontal'),'can scroll in horizontal direction');
214
- ok(!nestedView.get('canScrollVertical'),'cannot scroll in vertical direction');
215
- ok(nestedView.$().hasClass('sc-scroll-view'), 'should have sc-scroll-view class');
216
- equals(nestedView.$('> .sc-scroll-container-view').css('overflow-x'), 'scroll', 'should have \'overflow-x\': \'scroll\' style');
217
- equals(nestedView.$('> .sc-scroll-container-view').css('overflow-y'), 'hidden', 'should have \'overflow-y\': \'hidden\' style');
218
- });
219
-
220
- test("disabled", function() {
221
- var view = pane.view('disabled');
222
- ok(view.$().hasClass('disabled'), 'should have disabled class');
223
- ok(!view.$().hasClass('sel'), 'should not have sel class');
224
- });
225
-
226
- test("non-zero bottom in vertical scrollbar", function() {
227
- var view = pane.view('verticalScrollerBottom');
228
- equals(view.get('verticalScrollerBottom'),16, "should have verticalScrollerBottom as ");
229
- var scroller = view.get('verticalScrollerView') ;
230
- ok(scroller, 'should have vertical scroller view ');
231
- equals(scroller.get('layout').bottom,16, 'should have layout.bottom of scroller as ');
232
- equals(scroller.$()[0].style.bottom,'16px', 'should have style.bottom of scroller as ');
233
- });
234
-
235
- test('ScrollView should readjust scrollTop/scrollLeft if layer changes', function() {
236
- var view = pane.view('basic2'), cv = view.get('contentView'), container = view.get('containerView') ;
237
- view.scrollTo(10, 10);
238
- SC.RunLoop.begin().end();
239
- equals(container.get('layer').scrollLeft, 10, 'precond - scrollLeft is set to 10');
240
- equals(container.get('layer').scrollTop, 10, 'precond- scrollTop is set to 10');
241
- cv.replaceLayer();
242
- SC.RunLoop.begin().end();
243
- equals(container.get('layer').scrollLeft, 10, 'scrollLeft should be readjusted to 10');
244
- equals(container.get('layer').scrollTop, 10, 'scrollTop should be readjust to 10');
245
- });
246
-
247
- test('Scroller views of scroll view should have aria-controls set to its content', function() {
248
- var view = pane.view("aria-controls_attribute"),
249
- horizontalScrollerView = view.get('horizontalScrollerView'),
250
- verticalScrollerView = view.get('verticalScrollerView'),
251
- contentView = view.get('contentView').get('layerId');
252
-
253
- equals(horizontalScrollerView.$().attr('aria-controls'), contentView, "horizontalScroller has aria-controls set");
254
- equals(verticalScrollerView.$().attr('aria-controls'), contentView, "verticalScroller has aria-controls set");
255
- });
256
- })();
@@ -1,1164 +0,0 @@
1
- // ==========================================================================
2
- // Project: SproutCore - JavaScript Application Framework
3
- // Copyright: ©2006-2011 Strobe Inc. and contributors.
4
- // Portions ©2008-2011 Apple Inc. All rights reserved.
5
- // License: Licensed under MIT license (see license.js)
6
- // ==========================================================================
7
-
8
- sc_require('views/scroller');
9
-
10
- /** @class
11
- The core scroll view component.
12
-
13
- This class is an input-agnostic scroll view implementation.
14
-
15
- Important Events:
16
-
17
- - contentView frame size changes (to autoshow/hide scrollbar - adjust scrollbar size)
18
- - horizontalScrollOffset change
19
- - verticalScrollOffsetChanges
20
-
21
- @extends SC.View
22
- @since SproutCore 1.6
23
- */
24
- SC.CoreScrollView = SC.View.extend(
25
- /** @scope SC.ScrollView.prototype */{
26
-
27
- /**
28
- @type Array
29
- @default ['sc-scroll-view']
30
- @see SC.View#classNames
31
- */
32
- classNames: ['sc-scroll-view'],
33
-
34
- // ..........................................................
35
- // PROPERTIES
36
- //
37
-
38
- /**
39
- Walk like a duck
40
-
41
- @type Boolean
42
- @default YES
43
- @readOnly
44
- */
45
- isScrollable: YES,
46
-
47
- /**
48
- The content view you want the scroll view to manage.
49
- This will be assigned to the `contentView` of the `clipView` also.
50
-
51
- @type SC.View
52
- @default null
53
- */
54
- contentView: null,
55
-
56
- /**
57
- The horizontal alignment for non-filling content inside of the `ScrollView`.
58
- Possible values are:
59
-
60
- - `SC.ALIGN_LEFT`
61
- - `SC.ALIGN_RIGHT`
62
- - `SC.ALIGN_CENTER`
63
-
64
- @type String
65
- @default SC.ALIGN_LEFT
66
- */
67
- horizontalAlign: SC.ALIGN_LEFT,
68
-
69
- /**
70
- The vertical alignment for non-filling content inside of the `ScrollView`.
71
- Possible values are:
72
-
73
- - `SC.ALIGN_TOP`
74
- - `SC.ALIGN_BOTTOM`
75
- - `SC.ALIGN_MIDDLE`
76
-
77
- @type String
78
- @default SC.ALIGN_TOP
79
- */
80
- verticalAlign: SC.ALIGN_TOP,
81
-
82
- /**
83
- The current horizontal scroll offset. Changing this value will update both
84
- the `contentView` and the horizontal scroller, if there is one.
85
-
86
- @field
87
- @type Number
88
- @default 0
89
- */
90
- horizontalScrollOffset: function (key, value) {
91
- if (typeof value !== "undefined") {
92
- var minOffset = this.minimumHorizontalScrollOffset(),
93
- maxOffset = this.get('maximumHorizontalScrollOffset');
94
- this._scroll_horizontalScrollOffset = Math.max(minOffset, Math.min(maxOffset, value));
95
- }
96
-
97
- return this._scroll_horizontalScrollOffset || 0;
98
- }.property().cacheable(),
99
-
100
- /**
101
- The current vertical scroll offset. Changing this value will update both
102
- the `contentView` and the vertical scroller, if there is one.
103
-
104
- @field
105
- @type Number
106
- @default 0
107
- */
108
- verticalScrollOffset: function (key, value) {
109
- if (typeof value !== "undefined") {
110
- var minOffset = this.get('minimumVerticalScrollOffset'),
111
- maxOffset = this.get('maximumVerticalScrollOffset');
112
- this._scroll_verticalScrollOffset = Math.max(minOffset, Math.min(maxOffset, value));
113
- }
114
-
115
- return this._scroll_verticalScrollOffset || 0;
116
- }.property().cacheable(),
117
-
118
- /** @private
119
- Calculates the maximum offset given content and container sizes, and the
120
- alignment.
121
- */
122
- maximumScrollOffset: function (contentSize, containerSize, align) {
123
- // If the content is larger than the container, the maximum offset is
124
- // the location of the `contentView` when scrolled all the way down.
125
- var delta = contentSize - containerSize;
126
- if (contentSize >= containerSize) return delta;
127
-
128
- return (align === SC.ALIGN_LEFT || align === SC.ALIGN_TOP) ? 0 : // top-left aligned
129
- (align === SC.ALIGN_MIDDLE || align === SC.ALIGN_CENTER) ?
130
- Math.round(delta / 2) : // center aligned
131
- delta; // right aligned
132
- },
133
-
134
- /** @private
135
- Calculates the minimum offset given content and container sizes, and the
136
- alignment.
137
- */
138
- minimumScrollOffset: function (contentSize, containerSize, align) {
139
- var delta = contentSize - containerSize;
140
-
141
- return (contentSize > containerSize || align === SC.ALIGN_LEFT || align === SC.ALIGN_TOP) ?
142
- 0 : // top-left aligned or larger than the container.
143
- (align === SC.ALIGN_MIDDLE || align === SC.ALIGN_CENTER) ?
144
- Math.round(delta / 2) : // center aligned
145
- delta; // right aligned
146
- },
147
-
148
- /**
149
- The maximum horizontal scroll offset allowed given the current contentView
150
- size and the size of the scroll view. If horizontal scrolling is
151
- disabled, this will always return 0.
152
-
153
- @field
154
- @type Number
155
- @default 0
156
- */
157
- maximumHorizontalScrollOffset: function () {
158
- var view = this.get('contentView'),
159
- contentWidth = view ? view.get('frame').width : 0,
160
- calculatedWidth = view ? view.get('calculatedWidth') : 0,
161
- containerWidth = this.get('containerView').get('frame').width;
162
-
163
- // The following code checks if there is a calculatedWidth (collections)
164
- // to avoid looking at the incorrect value calculated by frame.
165
- if (calculatedWidth) {
166
- contentWidth = view.calculatedWidth;
167
- }
168
- contentWidth *= this._scale;
169
-
170
- // we still must go through minimumScrollOffset even if we can't scroll
171
- // because we need to adjust for alignment. So, just make sure it won't allow scrolling.
172
- if (!this.get('canScrollHorizontal')) contentWidth = Math.min(contentWidth, containerWidth);
173
- return this.maximumScrollOffset(contentWidth, containerWidth, this.get("horizontalAlign"));
174
- }.property(),
175
-
176
- /**
177
- The maximum vertical scroll offset allowed given the current contentView
178
- size and the size of the scroll view. If vertical scrolling is disabled,
179
- this will always return 0 (or whatever alignment dictates).
180
-
181
- @field
182
- @type Number
183
- @default 0
184
- */
185
- maximumVerticalScrollOffset: function () {
186
- var view = this.get('contentView'),
187
- contentHeight = (view && view.get('frame')) ? view.get('frame').height : 0,
188
- calculatedHeight = view ? view.get('calculatedHeight') : 0,
189
- containerHeight = this.get('containerView').get('frame').height;
190
-
191
- // The following code checks if there is a calculatedWidth (collections)
192
- // to avoid looking at the incorrect value calculated by frame.
193
- if (calculatedHeight) {
194
- contentHeight = calculatedHeight;
195
- }
196
- contentHeight *= this._scale;
197
-
198
- // we still must go through minimumScrollOffset even if we can't scroll
199
- // because we need to adjust for alignment. So, just make sure it won't allow scrolling.
200
- if (!this.get('canScrollVertical')) contentHeight = Math.min(contentHeight, containerHeight);
201
- return this.maximumScrollOffset(contentHeight, containerHeight, this.get("verticalAlign"));
202
- }.property(),
203
-
204
-
205
- /**
206
- The minimum horizontal scroll offset allowed given the current contentView
207
- size and the size of the scroll view. If horizontal scrolling is
208
- disabled, this will always return 0 (or whatever alignment dictates).
209
-
210
- @field
211
- @type Number
212
- @default 0
213
- */
214
- minimumHorizontalScrollOffset: function () {
215
- var view = this.get('contentView'),
216
- contentWidth = view ? view.get('frame').width : 0,
217
- calculatedWidth = view ? view.get('calculatedWidth') : 0,
218
- containerWidth = this.get('containerView').get('frame').width;
219
-
220
- // The following code checks if there is a calculatedWidth (collections)
221
- // to avoid looking at the incorrect value calculated by frame.
222
- if (calculatedWidth) {
223
- contentWidth = calculatedWidth;
224
- }
225
- contentWidth *= this._scale;
226
-
227
- // we still must go through minimumScrollOffset even if we can't scroll
228
- // because we need to adjust for alignment. So, just make sure it won't allow scrolling.
229
- if (!this.get('canScrollHorizontal')) contentWidth = Math.min(contentWidth, containerWidth);
230
- return this.minimumScrollOffset(contentWidth, containerWidth, this.get("horizontalAlign"));
231
- }.property(),
232
-
233
- /**
234
- The minimum vertical scroll offset allowed given the current contentView
235
- size and the size of the scroll view. If vertical scrolling is disabled,
236
- this will always return 0 (or whatever alignment dictates).
237
-
238
- @field
239
- @type Number
240
- @default 0
241
- */
242
- minimumVerticalScrollOffset: function () {
243
- var view = this.get('contentView'),
244
- contentHeight = (view && view.get('frame')) ? view.get('frame').height : 0,
245
- calculatedHeight = view ? view.get('calculatedHeight') : 0,
246
- containerHeight = this.get('containerView').get('frame').height;
247
-
248
- // The following code checks if there is a calculatedWidth (collections)
249
- // to avoid looking at the incorrect value calculated by frame.
250
- if (calculatedHeight) {
251
- contentHeight = view.calculatedHeight;
252
- }
253
- contentHeight *= this._scale;
254
-
255
- // we still must go through minimumScrollOffset even if we can't scroll
256
- // because we need to adjust for alignment. So, just make sure it won't allow scrolling.
257
- if (!this.get('canScrollVertical')) contentHeight = Math.min(contentHeight, containerHeight);
258
- return this.minimumScrollOffset(contentHeight, containerHeight, this.get("verticalAlign"));
259
- }.property(),
260
-
261
-
262
- /**
263
- Amount to scroll one vertical line.
264
-
265
- Used by the default implementation of scrollDownLine() and scrollUpLine().
266
-
267
- @type Number
268
- @default 20
269
- */
270
- verticalLineScroll: 20,
271
-
272
- /**
273
- Amount to scroll one horizontal line.
274
-
275
- Used by the default implementation of scrollLeftLine() and
276
- scrollRightLine().
277
-
278
- @type Number
279
- @default 20
280
- */
281
- horizontalLineScroll: 20,
282
-
283
- /**
284
- Amount to scroll one vertical page.
285
-
286
- Used by the default implementation of scrollUpPage() and scrollDownPage().
287
-
288
- @field
289
- @type Number
290
- @default value of frame.height
291
- @observes frame
292
- */
293
- verticalPageScroll: function () {
294
- return this.get('frame').height;
295
- }.property('frame'),
296
-
297
- /**
298
- Amount to scroll one horizontal page.
299
-
300
- Used by the default implementation of scrollLeftPage() and
301
- scrollRightPage().
302
-
303
- @field
304
- @type Number
305
- @default value of frame.width
306
- @observes frame
307
- */
308
- horizontalPageScroll: function () {
309
- return this.get('frame').width;
310
- }.property('frame'),
311
-
312
- /**
313
- Whether or not native scrollbars are wanted.
314
-
315
- @type Boolean
316
- @default NO
317
- */
318
- wantsNativeScrollbars: NO,
319
-
320
- // ..........................................................
321
- // SCROLLERS
322
- //
323
-
324
- /**
325
- YES if the view should maintain a horizontal scroller.
326
- This property must be set when the view is created.
327
-
328
- @type Boolean
329
- @default YES
330
- */
331
- hasHorizontalScroller: YES,
332
-
333
- /**
334
- The horizontal scroller view class.
335
-
336
- This will be replaced with a view instance when the
337
- ScrollView is created unless hasHorizontalScroller is NO.
338
-
339
- @type SC.View
340
- @default null
341
- */
342
- horizontalScrollerView: null,
343
-
344
- /**
345
- YES if the horizontal scroller should be visible. You can change this
346
- property value anytime to show or hide the horizontal scroller. If you
347
- do not want to use a horizontal scroller at all, you should instead set
348
- hasHorizontalScroller to NO to avoid creating a scroller view in the
349
- first place.
350
-
351
- @type Boolean
352
- @default YES
353
- */
354
- isHorizontalScrollerVisible: YES,
355
-
356
- /**
357
- Returns YES if the view both has a horizontal scroller, the scroller is
358
- visible.
359
-
360
- @field
361
- @type Boolean
362
- @default YES
363
- */
364
- canScrollHorizontal: function () {
365
- return !!(this.get('hasHorizontalScroller') &&
366
- this.get('horizontalScrollerView') &&
367
- this.get('isHorizontalScrollerVisible'));
368
- }.property('isHorizontalScrollerVisible', 'horizontalScrollerView').cacheable(),
369
-
370
- /**
371
- If YES, the horizontal scroller will autohide if the contentView is
372
- smaller than the visible area. You must set hasHorizontalScroller to YES
373
- for this property to have any effect.
374
-
375
- @type Boolean
376
- @default YES
377
- */
378
- autohidesHorizontalScroller: YES,
379
-
380
- /**
381
- YES if the view should maintain a vertical scroller. This property must
382
- be set when the view is created.
383
-
384
- @type Boolean
385
- @default YES
386
- */
387
- hasVerticalScroller: YES,
388
-
389
- /**
390
- The vertical scroller view class. This will be replaced with a view
391
- instance when the ScrollView is created unless hasVerticalScroller is NO.
392
-
393
- @type SC.View
394
- @default null
395
- */
396
- verticalScrollerView: null,
397
-
398
- /**
399
- YES if the vertical scroller should be visible. You can change this
400
- property value anytime to show or hide the vertical scroller. If you do
401
- not want to use a vertical scroller at all, you should instead set
402
- hasVerticalScroller to NO to avoid creating a scroller view in the first
403
- place.
404
-
405
- @type Boolean
406
- @default YES
407
- */
408
- isVerticalScrollerVisible: YES,
409
-
410
- /**
411
- Returns YES if the view both has a horizontal scroller, the scroller is
412
- visible.
413
-
414
- @field
415
- @type Boolean
416
- @default YES
417
- */
418
- canScrollVertical: function () {
419
- return !!(this.get('hasVerticalScroller') &&
420
- this.get('verticalScrollerView') &&
421
- this.get('isVerticalScrollerVisible'));
422
- }.property('isVerticalScrollerVisible', 'verticalScrollerView').cacheable(),
423
-
424
- /**
425
- If YES, the vertical scroller will autohide if the contentView is
426
- smaller than the visible area. You must set hasVerticalScroller to YES
427
- for this property to have any effect.
428
-
429
- @type Boolean
430
- @default YES
431
- */
432
- autohidesVerticalScroller: YES,
433
-
434
- /**
435
- Use this property to set the 'bottom' offset of your vertical scroller,
436
- to make room for a thumb view or other accessory view. Default is 0.
437
-
438
- @type Number
439
- @default 0
440
- */
441
- verticalScrollerBottom: 0,
442
-
443
- /**
444
- Use this to overlay the vertical scroller.
445
-
446
- This ensures that the container frame will not resize to accommodate the
447
- vertical scroller, hence overlaying the scroller on top of
448
- the container.
449
-
450
- @type Boolean
451
- @default NO
452
- */
453
- verticalOverlay: NO,
454
-
455
- /**
456
- Use this to overlay the horizontal scroller.
457
-
458
- This ensures that the container frame will not resize to accommodate the
459
- horizontal scroller, hence overlaying the scroller on top of
460
- the container
461
-
462
- @type Boolean
463
- @default NO
464
- */
465
- horizontalOverlay: NO,
466
-
467
- /**
468
- Use to control the positioning of the vertical scroller. If you do not
469
- set 'verticalOverlay' to YES, then the content view will be automatically
470
- sized to meet the left edge of the vertical scroller, wherever it may be.
471
- This allows you to easily, for example, have “one pixel higher and one
472
- pixel lower” scroll bars that blend into their parent views.
473
-
474
- If you do set 'verticalOverlay' to YES, then the scroller view will
475
- “float on top” of the content view.
476
-
477
- Example: { top: -1, bottom: -1, right: 0 }
478
-
479
- @type Hash
480
- @default null
481
- */
482
- verticalScrollerLayout: null,
483
-
484
- /**
485
- Use to control the positioning of the horizontal scroller. If you do not
486
- set 'horizontalOverlay' to YES, then the content view will be
487
- automatically sized to meet the top edge of the horizontal scroller,
488
- wherever it may be.
489
-
490
- If you do set 'horizontalOverlay' to YES, then the scroller view will
491
- “float on top” of the content view.
492
-
493
- Example: { left: 0, bottom: 0, right: 0 }
494
-
495
- @type Hash
496
- @default null
497
- */
498
- horizontalScrollerLayout: null,
499
-
500
- // ..........................................................
501
- // CUSTOM VIEWS
502
- //
503
-
504
- /**
505
- The container view that will contain your main content view. You can
506
- replace this property with your own custom subclass if you prefer.
507
-
508
- @type SC.ContainerView
509
- @default SC.ConainerView
510
- */
511
- containerView: SC.ContainerView.extend({}),
512
-
513
-
514
- // ..........................................................
515
- // METHODS
516
- //
517
-
518
- /**
519
- Scrolls the receiver to the specified x,y coordinate. This should be the
520
- offset into the contentView you want to appear at the top-left corner of
521
- the scroll view.
522
-
523
- This method will contain the actual scroll based on whether the view
524
- can scroll in the named direction and the maximum distance it can
525
- scroll.
526
-
527
- If you only want to scroll in one direction, pass null for the other
528
- direction. You can also optionally pass a Hash for the first parameter
529
- with x and y coordinates.
530
-
531
- @param {Number} x the x scroll location
532
- @param {Number} y the y scroll location
533
- @returns {SC.ScrollView} receiver
534
- */
535
- scrollTo: function (x, y) {
536
- // normalize params
537
- if (typeof y === "undefined" && SC.typeOf(x) === SC.T_HASH) {
538
- y = x.y; x = x.x;
539
- }
540
-
541
- if (!SC.none(x)) {
542
- this.set('horizontalScrollOffset', x);
543
- }
544
-
545
- if (!SC.none(y)) {
546
- this.set('verticalScrollOffset', y);
547
- }
548
-
549
- return this;
550
- },
551
-
552
- /**
553
- Scrolls the receiver in the horizontal and vertical directions by the
554
- amount specified, if allowed. The actual scroll amount will be
555
- constrained by the current scroll view settings.
556
-
557
- If you only want to scroll in one direction, pass null or 0 for the other
558
- direction. You can also optionally pass a Hash for the first parameter
559
- with x and y coordinates.
560
-
561
- @param {Number} x change in the x direction (or hash)
562
- @param {Number} y change in the y direction
563
- @returns {SC.ScrollView} receiver
564
- */
565
- scrollBy: function (x, y) {
566
- // normalize params
567
- if (typeof y === "undefined" && SC.typeOf(x) === SC.T_HASH) {
568
- y = x.y;
569
- x = x.x;
570
- }
571
-
572
- // if null, undefined, or 0, pass null; otherwise just add current offset
573
- x = (x) ? this.get('horizontalScrollOffset') + x : null;
574
- y = (y) ? this.get('verticalScrollOffset') + y : null;
575
- return this.scrollTo(x, y);
576
- },
577
-
578
- /**
579
- Scroll the view to make the view's frame visible. For this to make sense,
580
- the view should be a subview of the contentView. Otherwise the results
581
- will be undefined.
582
-
583
- @param {SC.View} view view to scroll or null to scroll receiver visible
584
- @returns {Boolean} YES if scroll position was changed
585
- */
586
- scrollToVisible: function (view) {
587
- // if no view is passed, do default
588
- if (typeof view === "undefined") return sc_super();
589
-
590
- var contentView = this.get('contentView');
591
- if (!contentView) return NO; // nothing to do if no contentView.
592
-
593
- // get the frame for the view - should work even for views with static
594
- // layout, assuming it has been added to the screen.
595
- var vf = view.get('frame');
596
- if (!vf) return NO; // nothing to do
597
-
598
- // convert view's frame to an offset from the contentView origin. This
599
- // will become the new scroll offset after some adjustment.
600
- vf = contentView.convertFrameFromView(vf, view.get('parentView'));
601
-
602
- return this.scrollToRect(vf);
603
- },
604
-
605
- /**
606
- Scroll to the supplied rectangle.
607
- @param {Rect} rect Rectangle to scroll to.
608
- @returns {Boolean} YES if scroll position was changed.
609
- */
610
- scrollToRect: function (rect) {
611
- // find current visible frame.
612
- var vo = SC.cloneRect(this.get('containerView').get('frame')),
613
- origX = this.get('horizontalScrollOffset'),
614
- origY = this.get('verticalScrollOffset');
615
-
616
- vo.x = origX;
617
- vo.y = origY;
618
-
619
- // if top edge is not visible, shift origin
620
- vo.y -= Math.max(0, SC.minY(vo) - SC.minY(rect));
621
- vo.x -= Math.max(0, SC.minX(vo) - SC.minX(rect));
622
-
623
- // if bottom edge is not visible, shift origin
624
- vo.y += Math.max(0, SC.maxY(rect) - SC.maxY(vo));
625
- vo.x += Math.max(0, SC.maxX(rect) - SC.maxX(vo));
626
-
627
- // scroll to that origin.
628
- if ((origX !== vo.x) || (origY !== vo.y)) {
629
- this.scrollTo(vo.x, vo.y);
630
- return YES;
631
- } else return NO;
632
- },
633
-
634
-
635
- /**
636
- Scrolls the receiver down one or more lines if allowed. If number of
637
- lines is not specified, scrolls one line.
638
-
639
- @param {Number} lines number of lines
640
- @returns {SC.ScrollView} receiver
641
- */
642
- scrollDownLine: function (lines) {
643
- if (typeof lines === "undefined") lines = 1;
644
- return this.scrollBy(null, this.get('verticalLineScroll') * lines);
645
- },
646
-
647
- /**
648
- Scrolls the receiver up one or more lines if allowed. If number of
649
- lines is not specified, scrolls one line.
650
-
651
- @param {Number} lines number of lines
652
- @returns {SC.ScrollView} receiver
653
- */
654
- scrollUpLine: function (lines) {
655
- if (typeof lines === "undefined") lines = 1;
656
- return this.scrollBy(null, -1 * this.get('verticalLineScroll') * lines);
657
- },
658
-
659
- /**
660
- Scrolls the receiver right one or more lines if allowed. If number of
661
- lines is not specified, scrolls one line.
662
-
663
- @param {Number} lines number of lines
664
- @returns {SC.ScrollView} receiver
665
- */
666
- scrollRightLine: function (lines) {
667
- if (typeof lines === "undefined") lines = 1;
668
- return this.scrollTo(this.get('horizontalLineScroll') * lines, null);
669
- },
670
-
671
- /**
672
- Scrolls the receiver left one or more lines if allowed. If number of
673
- lines is not specified, scrolls one line.
674
-
675
- @param {Number} lines number of lines
676
- @returns {SC.ScrollView} receiver
677
- */
678
- scrollLeftLine: function (lines) {
679
- if (typeof lines === "undefined") lines = 1;
680
- return this.scrollTo(-1 * this.get('horizontalLineScroll') * lines, null);
681
- },
682
-
683
- /**
684
- Scrolls the receiver down one or more page if allowed. If number of
685
- pages is not specified, scrolls one page. The page size is determined by
686
- the verticalPageScroll value. By default this is the size of the current
687
- scrollable area.
688
-
689
- @param {Number} pages number of lines
690
- @returns {SC.ScrollView} receiver
691
- */
692
- scrollDownPage: function (pages) {
693
- if (typeof pages === "undefined") pages = 1;
694
- return this.scrollBy(null, this.get('verticalPageScroll') * pages);
695
- },
696
-
697
- /**
698
- Scrolls the receiver up one or more page if allowed. If number of
699
- pages is not specified, scrolls one page. The page size is determined by
700
- the verticalPageScroll value. By default this is the size of the current
701
- scrollable area.
702
-
703
- @param {Number} pages number of lines
704
- @returns {SC.ScrollView} receiver
705
- */
706
- scrollUpPage: function (pages) {
707
- if (typeof pages === "undefined") pages = 1;
708
- return this.scrollBy(null, -1 * this.get('verticalPageScroll') * pages);
709
- },
710
-
711
- /**
712
- Scrolls the receiver right one or more page if allowed. If number of
713
- pages is not specified, scrolls one page. The page size is determined by
714
- the verticalPageScroll value. By default this is the size of the current
715
- scrollable area.
716
-
717
- @param {Number} pages number of lines
718
- @returns {SC.ScrollView} receiver
719
- */
720
- scrollRightPage: function (pages) {
721
- if (typeof pages === "undefined") pages = 1;
722
- return this.scrollBy(this.get('horizontalPageScroll') * pages, null);
723
- },
724
-
725
- /**
726
- Scrolls the receiver left one or more page if allowed. If number of
727
- pages is not specified, scrolls one page. The page size is determined by
728
- the verticalPageScroll value. By default this is the size of the current
729
- scrollable area.
730
-
731
- @param {Number} pages number of lines
732
- @returns {SC.ScrollView} receiver
733
- */
734
- scrollLeftPage: function (pages) {
735
- if (typeof pages === "undefined") pages = 1;
736
- return this.scrollBy(-1 * this.get('horizontalPageScroll') * pages, null);
737
- },
738
-
739
- /** @private
740
- Adjusts the layout for the various internal views. This method is called
741
- once when the scroll view is first configured and then anytime a scroller
742
- is shown or hidden. You can call this method yourself as well to retile.
743
-
744
- You may also want to override this method to handle layout for any
745
- additional controls you have added to the view.
746
- */
747
- tile: function () {
748
- if (this.get('wantsNativeScrollbars')) return; // Let the browser retile
749
-
750
- var hasHorizontal = this.get('canScrollHorizontal'),
751
- hasVertical = this.get('canScrollVertical'),
752
- hScroll = this.get('hasHorizontalScroller') ? this.get('horizontalScrollerView') : null,
753
- vScroll = this.get('hasVerticalScroller') ? this.get('verticalScrollerView') : null,
754
- clipView = this.get('containerView'),
755
- clipLayout = { left: 0, top: 0 }, layout;
756
-
757
- var ht = hasHorizontal ? hScroll.get('scrollbarThickness') : 0;
758
- var vt = hasVertical ? vScroll.get('scrollbarThickness') : 0;
759
-
760
- if (hasHorizontal) {
761
- layout = this.get('horizontalScrollerLayout');
762
- layout = {
763
- left: layout ? layout.left : 0,
764
- bottom: layout ? layout.bottom : 0,
765
- right: layout ? layout.right + vt-1 : vt-1,
766
- height: ht
767
- };
768
- hScroll.set('layout', layout);
769
- clipLayout.bottom = layout.bottom + (hScroll.get('isTranslucent') ? 0 : layout.height);
770
- }
771
-
772
- if ((hasHorizontal && this.get('horizontalOverlay')) || !hasHorizontal) {
773
- clipLayout.bottom = 0;
774
- }
775
-
776
- if (hScroll) hScroll.set('isVisible', hasHorizontal);
777
-
778
- if (hasVertical) {
779
- ht = ht + this.get('verticalScrollerBottom');
780
- layout = this.get('verticalScrollerLayout');
781
- layout = {
782
- top: layout ? layout.top : 0,
783
- bottom: layout ? layout.bottom + ht : ht,
784
- right: layout ? layout.right : 0,
785
- width: vt
786
- };
787
- vScroll.set('layout', layout);
788
- clipLayout.right = layout.right + (vScroll.get('isTranslucent') ? 0 : layout.width);
789
- }
790
-
791
- if ((hasVertical && this.get('verticalOverlay')) || !hasVertical) {
792
- clipLayout.right = 0;
793
- }
794
-
795
- if (vScroll) vScroll.set('isVisible', hasVertical);
796
-
797
- clipView.adjust(clipLayout);
798
- },
799
-
800
- /** @private
801
- Called whenever a scroller visibility changes.
802
- Calls the tile() method.
803
- */
804
- scrollerVisibilityDidChange: function () {
805
- this.tile();
806
- }.observes('isVerticalScrollerVisible', 'isHorizontalScrollerVisible'),
807
-
808
- // ..............................................
809
- // SCALING SUPPORT
810
- //
811
-
812
- /**
813
- Determines whether scaling is allowed.
814
-
815
- @type Boolean
816
- @default NO
817
- */
818
- canScale: NO,
819
-
820
- /** @private
821
- The current scale.
822
- */
823
- _scale: 1.0,
824
-
825
- /**
826
- @field
827
- @type Number
828
- @default 1.0
829
- */
830
- scale: function (key, value) {
831
- if (typeof value !== "undefined") {
832
- this._scale = Math.min(Math.max(this.get("minimumScale"), value), this.get("maximumScale"));
833
- }
834
- return this._scale;
835
- }.property().cacheable(),
836
-
837
- /**
838
- The minimum scale.
839
-
840
- @type Number
841
- @default 0.25
842
- */
843
- minimumScale: 0.25,
844
-
845
- /**
846
- The maximum scale.
847
-
848
- @type Number
849
- @default 2.0
850
- */
851
- maximumScale: 2.0,
852
-
853
- /**
854
- Whether to automatically determine the scale range based on the size of the content.
855
-
856
- @type Boolean
857
- @default NO
858
- */
859
- autoScaleRange: NO,
860
-
861
- /** @private */
862
- _scale_css: "",
863
-
864
- /** @private */
865
- updateScale: function (scale) {
866
- var contentView = this.get("contentView");
867
- if (!contentView) return;
868
-
869
- if (contentView.isScalable) {
870
- this.get("contentView").applyScale(scale);
871
- this._scale_css = "";
872
- } else {
873
- this._scale_css = "scale3d(" + scale + ", " + scale + ", 1)";
874
- }
875
- },
876
-
877
- // ..........................................................
878
- // INTERNAL SUPPORT
879
- //
880
-
881
- /** @private
882
- Instantiate scrollers & container views as needed. Replace their classes
883
- in the regular properties.
884
- */
885
- createChildViews: function () {
886
- var childViews = [], view;
887
-
888
- // create the containerView. We must always have a container view.
889
- // also, setup the contentView as the child of the containerView...
890
- if (SC.none(view = this.containerView)) view = SC.ContainerView;
891
-
892
- childViews.push(this.containerView = this.createChildView(view, {
893
- contentView: this.contentView,
894
- isScrollContainer: YES
895
- }));
896
-
897
- // and replace our own contentView...
898
- this.contentView = this.containerView.get('contentView');
899
-
900
- if (!this.get('wantsNativeScrollbars')) {
901
- // create a horizontal scroller view if needed...
902
- view = this.get("horizontalScrollerView");
903
- if (view) {
904
- if (this.get('hasHorizontalScroller')) {
905
- view = this.createChildView(view, {
906
- layoutDirection: SC.LAYOUT_HORIZONTAL,
907
- valueBinding: '*owner.horizontalScrollOffset'
908
- });
909
- this.set('horizontalScrollerView', view);
910
- childViews.push(view);
911
- } else this.horizontalScrollerView = null;
912
- }
913
-
914
- // create a vertical scroller view if needed...
915
- view = this.get("verticalScrollerView");
916
- if (view) {
917
- if (this.get('hasVerticalScroller')) {
918
- view = this.createChildView(view, {
919
- layoutDirection: SC.LAYOUT_VERTICAL,
920
- valueBinding: '*owner.verticalScrollOffset'
921
- });
922
- this.set('verticalScrollerView', view);
923
- childViews.push(view);
924
- } else this.verticalScrollerView = null;
925
- }
926
- }
927
-
928
- // set childViews array.
929
- this.childViews = childViews;
930
-
931
- this.contentViewDidChange(); // setup initial display...
932
- this.tile(); // set up initial tiling
933
- },
934
-
935
- /** @private */
936
- init: function () {
937
- sc_super();
938
-
939
- // start observing initial content view. The content view's frame has
940
- // already been setup in prepareDisplay so we don't need to call
941
- // viewFrameDidChange...
942
- this._scroll_contentView = this.get('contentView');
943
- var contentView = this._scroll_contentView;
944
-
945
- if (contentView) {
946
- contentView.addObserver('frame', this, this.contentViewFrameDidChange);
947
- contentView.addObserver('calculatedWidth', this, this.contentViewFrameDidChange);
948
- contentView.addObserver('calculatedHeight', this, this.contentViewFrameDidChange);
949
- }
950
-
951
- if (this.get('isVisibleInWindow')) this._scsv_registerAutoscroll();
952
- },
953
-
954
- /** @private
955
- Registers/deregisters view with SC.Drag for autoscrolling
956
- */
957
- _scsv_registerAutoscroll: function () {
958
- this.get('isVisibleInWindow') ? SC.Drag.addScrollableView(this) :
959
- SC.Drag.removeScrollableView(this);
960
- }.observes('isVisibleInWindow'),
961
-
962
- /** @private
963
- Whenever the contentView is changed, we need to observe the content view's
964
- frame to be notified whenever it's size changes.
965
- */
966
- contentViewDidChange: function () {
967
- var newView = this.get('contentView'),
968
- oldView = this._scroll_contentView,
969
- frameObserver = this.contentViewFrameDidChange,
970
- layerObserver = this.contentViewLayerDidChange;
971
-
972
- if (newView !== oldView) {
973
-
974
- // stop observing old content view
975
- if (oldView) {
976
- oldView.removeObserver('calculatedWidth', this, this.contentViewFrameDidChange);
977
- oldView.removeObserver('calculatedHeight', this, this.contentViewFrameDidChange);
978
- oldView.removeObserver('frame', this, frameObserver);
979
- oldView.removeObserver('layer', this, layerObserver);
980
- }
981
-
982
- // update cache
983
- this._scroll_contentView = newView;
984
- if (newView) {
985
- newView.addObserver('frame', this, frameObserver);
986
- newView.addObserver('calculatedWidth', this, this.contentViewFrameDidChange);
987
- newView.addObserver('calculatedHeight', this, this.contentViewFrameDidChange);
988
- newView.addObserver('layer', this, layerObserver);
989
- }
990
-
991
- // replace container
992
- this.containerView.set('contentView', newView);
993
-
994
- this.contentViewFrameDidChange();
995
- }
996
- }.observes('contentView'),
997
-
998
- /** @private */
999
- oldMaxHOffset: 0,
1000
-
1001
- /** @private */
1002
- oldMaxVOffset: 0,
1003
-
1004
- /** @private
1005
- Invoked whenever the contentView's frame changes. This will update the
1006
- scroller maximum and optionally update the scroller visibility if the
1007
- size of the contentView changes. We don't care about the origin since
1008
- that is tracked separately from the offset values.
1009
-
1010
- @param {Boolean} [force] Re-calculate everything even if the contentView’s frame didn’t change size
1011
- */
1012
- contentViewFrameDidChange: function (force) {
1013
- var view = this.get('contentView'),
1014
- f = (view) ? view.get('frame') : null,
1015
- scale = this._scale,
1016
- width = 0,
1017
- height = 0,
1018
- dim, dimWidth, dimHeight, calculatedWidth, calculatedHeight;
1019
-
1020
- // If no view has been set yet, or it doesn't have a frame,
1021
- // we can avoid doing any work.
1022
- if (!view || !f) { return; }
1023
-
1024
- width = view.get('calculatedWidth') || f.width || 0;
1025
- height = view.get('calculatedHeight') || f.height || 0;
1026
-
1027
- width *= scale;
1028
- height *= scale;
1029
-
1030
- // cache out scroll settings...
1031
- if (!force && (width === this._scroll_contentWidth) && (height === this._scroll_contentHeight)) return;
1032
- this._scroll_contentWidth = width;
1033
- this._scroll_contentHeight = height;
1034
-
1035
- dim = this.getPath('containerView.frame');
1036
- dimWidth = dim.width;
1037
- dimHeight = dim.height;
1038
-
1039
- if (this.get('hasHorizontalScroller') && (view = this.get('horizontalScrollerView'))) {
1040
- // decide if it should be visible or not
1041
- if (this.get('autohidesHorizontalScroller')) {
1042
- this.set('isHorizontalScrollerVisible', width > dimWidth);
1043
- }
1044
- if (!this.get('wantsNativeScrollbars')) {
1045
- view.setIfChanged('maximum', width-dimWidth);
1046
- view.setIfChanged('proportion', dimWidth/width);
1047
- }
1048
- }
1049
-
1050
- if (this.get('hasVerticalScroller') && (view = this.get('verticalScrollerView'))) {
1051
- // decide if it should be visible or not
1052
- if (this.get('autohidesVerticalScroller')) {
1053
- this.set('isVerticalScrollerVisible', height > dimHeight);
1054
- }
1055
- if (!this.get('wantsNativeScrollbars')) {
1056
- view.setIfChanged('maximum', height - dimHeight);
1057
- view.setIfChanged('proportion', dimHeight / height);
1058
- }
1059
- }
1060
-
1061
- // If there is no vertical scroller and auto hiding is on, make
1062
- // sure we are at the top if not already there
1063
- if (!this.get('isVerticalScrollerVisible') && (this.get('verticalScrollOffset') !== 0) &&
1064
- this.get('autohidesVerticalScroller')) {
1065
- this.set('verticalScrollOffset', 0);
1066
- }
1067
-
1068
- // Same thing for horizontal scrolling.
1069
- if (!this.get('isHorizontalScrollerVisible') && (this.get('horizontalScrollOffset') !== 0) &&
1070
- this.get('autohidesHorizontalScroller')) {
1071
- this.set('horizontalScrollOffset', 0);
1072
- }
1073
-
1074
- // This forces to recalculate the height of the frame when is at the bottom
1075
- // of the scroll and the content dimension are smaller that the previous one
1076
- var mxVOffSet = this.get('maximumVerticalScrollOffset'),
1077
- vOffSet = this.get('verticalScrollOffset'),
1078
- mxHOffSet = this.get('maximumHorizontalScrollOffset'),
1079
- hOffSet = this.get('horizontalScrollOffset'),
1080
- forceHeight = mxVOffSet < vOffSet,
1081
- forceWidth = mxHOffSet < hOffSet;
1082
-
1083
- if (forceHeight || forceWidth) {
1084
- this.forceDimensionsRecalculation(forceWidth, forceHeight, vOffSet, hOffSet);
1085
- }
1086
- },
1087
-
1088
- /** @private
1089
- If our frame changes, then we need to re-calculate the visibility of our
1090
- scrollers, etc.
1091
- */
1092
- frameDidChange: function () {
1093
- this.contentViewFrameDidChange(YES);
1094
- }.observes('frame'),
1095
-
1096
- /** @private
1097
- If the layer of the content view changes, we need to readjust the
1098
- scrollTop and scrollLeft properties on the new DOM element.
1099
- */
1100
- contentViewLayerDidChange: function () {
1101
- // Invalidate these cached values, as they're no longer valid
1102
- if (this._verticalScrollOffset !== 0) this._verticalScrollOffset = -1;
1103
- if (this._horizontalScrollOffset !== 0) this._horizontalScrollOffset = -1;
1104
- this.invokeLast(this.adjustElementScroll);
1105
- },
1106
-
1107
- willScroll: function () {
1108
- var content = this.get('contentView');
1109
- content && content.willScroll && content.willScroll(this);
1110
- },
1111
-
1112
- didScroll: function () {
1113
- var content = this.get('contentView');
1114
- content && content.didScroll && content.didScroll(this);
1115
- },
1116
-
1117
- /** @private
1118
- Whenever the horizontal scroll offset changes, update the scrollers and
1119
- edit the location of the contentView.
1120
- */
1121
- _scsv_offsetDidChange: function () {
1122
- this.invokeLast(this.adjustElementScroll);
1123
- }.observes('horizontalScrollOffset', 'verticalScrollOffset'),
1124
-
1125
- /** @private
1126
- Called at the end of the run loop to actually adjust the scrollTop
1127
- and scrollLeft properties of the container view.
1128
- */
1129
- adjustElementScroll: function () {
1130
- var content = this.get('contentView');
1131
-
1132
- // We notify the content view that its frame property has changed
1133
- // before we actually update the scrollTop/scrollLeft properties.
1134
- // This gives views that use incremental rendering a chance to render
1135
- // newly-appearing elements before they come into view.
1136
- if (content && content._viewFrameDidChange) {
1137
- content._viewFrameDidChange();
1138
- }
1139
- },
1140
-
1141
- /** @private */
1142
- forceDimensionsRecalculation: function (forceWidth, forceHeight, vOffSet, hOffSet) {
1143
- var oldScrollHOffset = hOffSet;
1144
- var oldScrollVOffset = vOffSet;
1145
- this.scrollTo(0, 0);
1146
- if (forceWidth && forceHeight) {
1147
- this.scrollTo(this.get('maximumHorizontalScrollOffset'),
1148
- this.get('maximumVerticalScrollOffset'));
1149
- }
1150
- if (forceWidth && !forceHeight) {
1151
- this.scrollTo(this.get('maximumHorizontalScrollOffset'), oldScrollVOffset);
1152
- }
1153
- if (!forceWidth && forceHeight) {
1154
- this.scrollTo(oldScrollHOffset, this.get('maximumVerticalScrollOffset'));
1155
- }
1156
- },
1157
-
1158
- /** @private */
1159
- _scroll_verticalScrollOffset: 0,
1160
-
1161
- /** @private */
1162
- _scroll_horizontalScrollOffset: 0
1163
-
1164
- });