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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (308) hide show
  1. data/.rspec +1 -0
  2. data/CHANGELOG +42 -0
  3. data/README.txt +25 -0
  4. data/VERSION.yml +1 -1
  5. data/bin/sc-build +1 -1
  6. data/bin/sc-build-number +1 -1
  7. data/bin/sc-docs +1 -1
  8. data/bin/sc-gen +1 -1
  9. data/bin/sc-init +1 -1
  10. data/bin/sc-manifest +1 -1
  11. data/bin/sc-server +1 -1
  12. data/bin/sproutcore +1 -1
  13. data/lib/buildtasks/build.rake +5 -0
  14. data/lib/buildtasks/manifest.rake +20 -1
  15. data/lib/frameworks/sproutcore/Buildfile +12 -9
  16. data/lib/frameworks/sproutcore/CHANGELOG.md +48 -0
  17. data/lib/frameworks/sproutcore/apps/greenhouse/README +2 -9
  18. data/lib/frameworks/sproutcore/apps/greenhouse/TODO +11 -27
  19. data/lib/frameworks/sproutcore/apps/greenhouse/controllers/library.js +3 -10
  20. data/lib/frameworks/sproutcore/apps/greenhouse/english.lproj/css/main-page.css +4 -31
  21. data/lib/frameworks/sproutcore/apps/greenhouse/english.lproj/dialogs.js +5 -4
  22. data/lib/frameworks/sproutcore/apps/greenhouse/models/dir.js +3 -3
  23. data/lib/frameworks/sproutcore/apps/greenhouse/models/file.js +2 -2
  24. data/lib/frameworks/sproutcore/apps/greenhouse/states/main.js +31 -14
  25. data/lib/frameworks/sproutcore/apps/greenhouse/states/modals.js +2 -1
  26. data/lib/frameworks/sproutcore/apps/greenhouse/states/ready.js +27 -1
  27. data/lib/frameworks/sproutcore/apps/greenhouse/tests/views/list_item.js +1 -0
  28. data/lib/frameworks/sproutcore/apps/greenhouse/tests/views/plist_item.js +20 -0
  29. data/lib/frameworks/sproutcore/apps/greenhouse/theme.js +25 -0
  30. data/lib/frameworks/sproutcore/apps/greenhouse/views/plist_item.js +161 -24
  31. data/lib/frameworks/sproutcore/apps/greenhouse/views/tear_off_picker.js +1 -1
  32. data/lib/frameworks/sproutcore/frameworks/bootstrap/system/browser.js +37 -25
  33. data/lib/frameworks/sproutcore/frameworks/bootstrap/tests/system/browser.js +135 -26
  34. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/controllers/array.js +0 -0
  35. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/controllers/controller.js +0 -0
  36. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/controllers/object.js +1 -1
  37. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/core.js +0 -0
  38. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/ext/object.js +0 -0
  39. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/ext/run_loop.js +1 -0
  40. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/mixins/delegate_support.js +0 -0
  41. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/mixins/responder_context.js +0 -0
  42. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/mixins/selection_support.js +0 -0
  43. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/mixins/string.js +0 -0
  44. data/lib/frameworks/sproutcore/frameworks/core_foundation/panes/keyboard.js +68 -0
  45. data/lib/frameworks/sproutcore/frameworks/core_foundation/panes/layout.js +108 -0
  46. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/panes/main.js +2 -2
  47. data/lib/frameworks/sproutcore/frameworks/core_foundation/panes/manipulation.js +27 -0
  48. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/panes/pane.js +215 -505
  49. data/lib/frameworks/sproutcore/frameworks/core_foundation/panes/template.js +24 -0
  50. data/lib/frameworks/sproutcore/frameworks/core_foundation/panes/visibility.js +11 -0
  51. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/protocols/observable_protocol.js +0 -0
  52. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/protocols/sparse_array_delegate.js +0 -0
  53. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/resources/core.css +0 -0
  54. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/resources/view.css +0 -0
  55. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/system/application.js +0 -0
  56. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/system/browser.js +1 -0
  57. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/system/builder.js +0 -0
  58. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/system/core_query.js +1 -1
  59. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/system/cursor.js +0 -0
  60. data/lib/frameworks/sproutcore/frameworks/core_foundation/system/device.js +210 -0
  61. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/system/event.js +5 -5
  62. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/system/json.js +0 -0
  63. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/system/locale.js +0 -0
  64. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/system/page.js +0 -0
  65. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/system/platform.js +31 -5
  66. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/system/ready.js +1 -1
  67. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/system/render_context.js +0 -0
  68. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/system/responder.js +0 -0
  69. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/system/root_responder.js +83 -110
  70. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/system/selection_set.js +7 -4
  71. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/system/sparse_array.js +0 -0
  72. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/system/theme.js +0 -0
  73. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/system/timer.js +0 -0
  74. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/system/utils/rect.js +0 -0
  75. data/lib/frameworks/sproutcore/frameworks/core_foundation/system/utils.js +151 -0
  76. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/tests/controllers/array/array_case.js +0 -0
  77. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/tests/controllers/array/enum_case.js +0 -0
  78. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/tests/controllers/array/null_case.js +0 -0
  79. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/tests/controllers/array/selection_support.js +26 -0
  80. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/tests/controllers/array/single_case.js +0 -0
  81. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/tests/controllers/object/empty_case.js +0 -0
  82. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/tests/controllers/object/multiple_case.js +0 -0
  83. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/tests/controllers/object/single_case.js +0 -0
  84. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/tests/controllers/object/single_enumerable_case.js +0 -0
  85. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/tests/mixins/responder_context.js +0 -0
  86. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/tests/mixins/string.js +0 -0
  87. data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/panes/template.js +14 -0
  88. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/tests/system/builder.js +0 -0
  89. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/tests/system/core_query/within.js +0 -0
  90. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/tests/system/json.js +0 -0
  91. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/tests/system/locale.js +0 -0
  92. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/tests/system/render_context/begin.js +0 -0
  93. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/tests/system/render_context/element.js +0 -0
  94. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/tests/system/render_context/end.js +0 -0
  95. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/tests/system/render_context/get.js +0 -0
  96. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/tests/system/render_context/helpers_attr.js +0 -0
  97. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/tests/system/render_context/helpers_basic.js +0 -0
  98. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/tests/system/render_context/helpers_className.js +0 -0
  99. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/tests/system/render_context/helpers_style.js +0 -0
  100. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/tests/system/render_context/init.js +0 -0
  101. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/tests/system/render_context/join.js +0 -0
  102. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/tests/system/render_context/push_text.js +0 -0
  103. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/tests/system/render_context/tag.js +0 -0
  104. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/tests/system/render_context/update.js +0 -0
  105. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/tests/system/root_responder/makeKeyPane.js +0 -0
  106. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/tests/system/root_responder/makeMainPane.js +0 -0
  107. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/tests/system/root_responder/makeMenuPane.js +0 -0
  108. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/tests/system/root_responder/root_responder.js +0 -0
  109. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/tests/system/root_responder/targetForAction.js +0 -0
  110. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/tests/system/selection_set/add.js +0 -0
  111. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/tests/system/selection_set/copy.js +0 -0
  112. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/tests/system/selection_set/indexSetForSource.js +0 -0
  113. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/tests/system/selection_set/isEqual.js +0 -0
  114. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/tests/system/selection_set/remove.js +0 -0
  115. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/tests/system/sparse_array.js +0 -0
  116. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/tests/system/theme.js +0 -0
  117. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/tests/system/timer/invalidate.js +0 -0
  118. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/tests/system/timer/invokeLater.js +0 -0
  119. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/tests/system/timer/isPaused.js +0 -0
  120. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/tests/system/timer/performAction.js +0 -0
  121. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/tests/system/timer/schedule.js +0 -0
  122. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/tests/system/utils/normalizeURL.js +0 -0
  123. data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/system/utils/offset.js +268 -0
  124. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/tests/system/utils/rect.js +0 -0
  125. data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/main_pane.js +43 -0
  126. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/tests/views/pane/append_remove.js +107 -18
  127. data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/pane/child_view.js +20 -0
  128. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/tests/views/pane/firstResponder.js +0 -0
  129. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/tests/views/pane/keyPane.js +0 -0
  130. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/tests/views/pane/layout.js +0 -0
  131. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/tests/views/pane/sendEvent.js +0 -0
  132. data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/template/checkbox_support.js +32 -0
  133. data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/template/text_field_support.js +73 -0
  134. data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/template_view/collection.js +65 -0
  135. data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/template_view/core.js +67 -0
  136. data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/template_view/handlebars.js +295 -0
  137. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/tests/views/view/animation.js +19 -18
  138. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/tests/views/view/build.js +0 -0
  139. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/tests/views/view/build_children.js +0 -0
  140. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/tests/views/view/clippingFrame.js +0 -0
  141. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/tests/views/view/convertFrames.js +0 -0
  142. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/tests/views/view/convertLayouts.js +0 -0
  143. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/tests/views/view/createChildViews.js +18 -15
  144. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/tests/views/view/createLayer.js +0 -0
  145. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/tests/views/view/destroyLayer.js +0 -0
  146. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/tests/views/view/didAppendToDocument.js +11 -8
  147. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/tests/views/view/findLayerInParentLayer.js +0 -0
  148. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/tests/views/view/init.js +0 -0
  149. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/tests/views/view/insertBefore.js +0 -0
  150. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/tests/views/view/isVisible.js +28 -0
  151. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/tests/views/view/isVisibleInWindow.js +0 -0
  152. data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/keyboard.js +22 -0
  153. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/tests/views/view/layer.js +0 -0
  154. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/tests/views/view/layoutChildViews.js +0 -0
  155. data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/layoutDidChange.js +180 -0
  156. data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/layoutStyle.js +640 -0
  157. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/tests/views/view/parentViewDidChange.js +0 -0
  158. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/tests/views/view/prepareContext.js +0 -0
  159. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/tests/views/view/removeChild.js +0 -0
  160. data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/render.js +125 -0
  161. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/tests/views/view/render_delegate_support.js +0 -0
  162. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/tests/views/view/replaceChild.js +0 -0
  163. data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/static_layout.js +21 -0
  164. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/tests/views/view/theme.js +0 -0
  165. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/tests/views/view/updateLayer.js +0 -0
  166. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/tests/views/view/updateLayerLocation.js +0 -0
  167. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/tests/views/view/view.js +0 -0
  168. data/lib/frameworks/sproutcore/frameworks/{amber → core_foundation}/tests/views/view/viewDidResize.js +0 -0
  169. data/lib/frameworks/sproutcore/frameworks/core_foundation/views/template/checkbox_support.js +20 -0
  170. data/lib/frameworks/sproutcore/frameworks/core_foundation/views/template/collection.js +99 -0
  171. data/lib/frameworks/sproutcore/frameworks/core_foundation/views/template/text_field_support.js +35 -0
  172. data/lib/frameworks/sproutcore/frameworks/core_foundation/views/template.js +77 -0
  173. data/lib/frameworks/sproutcore/frameworks/core_foundation/views/view/animation.js +187 -0
  174. data/lib/frameworks/sproutcore/frameworks/core_foundation/views/view/base.js +1 -0
  175. data/lib/frameworks/sproutcore/frameworks/core_foundation/views/view/cursor.js +41 -0
  176. data/lib/frameworks/sproutcore/frameworks/core_foundation/views/view/enabled.js +57 -0
  177. data/lib/frameworks/sproutcore/frameworks/core_foundation/views/view/keyboard.js +223 -0
  178. data/lib/frameworks/sproutcore/frameworks/core_foundation/views/view/layout.js +1150 -0
  179. data/lib/frameworks/sproutcore/frameworks/{amber/views → core_foundation/views/view}/layout_style.js +93 -1
  180. data/lib/frameworks/sproutcore/frameworks/core_foundation/views/view/manipulation.js +489 -0
  181. data/lib/frameworks/sproutcore/frameworks/core_foundation/views/view/theming.js +362 -0
  182. data/lib/frameworks/sproutcore/frameworks/core_foundation/views/view/touch.js +67 -0
  183. data/lib/frameworks/sproutcore/frameworks/core_foundation/views/view/visibility.js +113 -0
  184. data/lib/frameworks/sproutcore/frameworks/core_foundation/views/view.js +1280 -0
  185. data/lib/frameworks/sproutcore/frameworks/datastore/models/child_attribute.js +27 -53
  186. data/lib/frameworks/sproutcore/frameworks/datastore/models/children_attribute.js +13 -19
  187. data/lib/frameworks/sproutcore/frameworks/datastore/models/many_attribute.js +1 -0
  188. data/lib/frameworks/sproutcore/frameworks/datastore/models/record.js +183 -71
  189. data/lib/frameworks/sproutcore/frameworks/datastore/models/record_attribute.js +1 -2
  190. data/lib/frameworks/sproutcore/frameworks/datastore/system/child_array.js +26 -46
  191. data/lib/frameworks/sproutcore/frameworks/datastore/system/nested_store.js +25 -4
  192. data/lib/frameworks/sproutcore/frameworks/datastore/system/store.js +139 -21
  193. data/lib/frameworks/sproutcore/frameworks/datastore/tests/data_sources/fixtures.js +6 -1
  194. data/lib/frameworks/sproutcore/frameworks/datastore/tests/integration/cyclical_relationship.js +1 -1
  195. data/lib/frameworks/sproutcore/frameworks/datastore/tests/models/nested_records/{parentless.js → data_store.js} +62 -16
  196. data/lib/frameworks/sproutcore/frameworks/datastore/tests/models/nested_records/nested_record.js +51 -17
  197. data/lib/frameworks/sproutcore/frameworks/datastore/tests/models/nested_records/nested_record_array.js +36 -10
  198. data/lib/frameworks/sproutcore/frameworks/datastore/tests/models/nested_records/nested_record_array_complex.js +11 -11
  199. data/lib/frameworks/sproutcore/frameworks/datastore/tests/models/nested_records/nested_record_complex.js +8 -8
  200. data/lib/frameworks/sproutcore/frameworks/datastore/tests/models/record/normalize.js +2 -2
  201. data/lib/frameworks/sproutcore/frameworks/{foundation/english.lproj → datetime/resources}/strings.js +1 -0
  202. data/lib/frameworks/sproutcore/frameworks/{foundation → datetime}/system/datetime.js +5 -37
  203. data/lib/frameworks/sproutcore/frameworks/{foundation → datetime}/tests/system/datetime.js +1 -0
  204. data/lib/frameworks/sproutcore/frameworks/debug/core.js +1 -1
  205. data/lib/frameworks/sproutcore/frameworks/designer/controllers/designs.js +1 -2
  206. data/lib/frameworks/sproutcore/frameworks/designer/designers/object_designer.js +3 -3
  207. data/lib/frameworks/sproutcore/frameworks/designer/designers/view_designer.js +3 -3
  208. data/lib/frameworks/sproutcore/frameworks/designer/views/designer_drop_target.js +9 -3
  209. data/lib/frameworks/sproutcore/frameworks/desktop/english.lproj/segmented.css +71 -70
  210. data/lib/frameworks/sproutcore/frameworks/desktop/mixins/collection_row_delegate.js +10 -2
  211. data/lib/frameworks/sproutcore/frameworks/desktop/render_delegates/segment.js +4 -19
  212. data/lib/frameworks/sproutcore/frameworks/desktop/render_delegates/segmented.js +33 -14
  213. data/lib/frameworks/sproutcore/frameworks/desktop/system/drag.js +25 -0
  214. data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/date_field/ui.js +1 -1
  215. data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/segmented/methods.js +25 -103
  216. data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/segmented/ui.js +102 -92
  217. data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/tab/ui.js +22 -25
  218. data/lib/frameworks/sproutcore/frameworks/desktop/views/collection.js +38 -25
  219. data/lib/frameworks/sproutcore/frameworks/desktop/views/date_field.js +1 -1
  220. data/lib/frameworks/sproutcore/frameworks/desktop/views/scroll.js +1 -1
  221. data/lib/frameworks/sproutcore/frameworks/desktop/views/segment.js +42 -22
  222. data/lib/frameworks/sproutcore/frameworks/desktop/views/segmented.js +513 -230
  223. data/lib/frameworks/sproutcore/frameworks/desktop/views/select_field.js +0 -2
  224. data/lib/frameworks/sproutcore/frameworks/experimental/README.md +23 -0
  225. data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/device_motion/README.md +11 -0
  226. data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/device_motion/device.js +215 -0
  227. data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/device_motion/platform.js +67 -0
  228. data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/polymorphism/README.md +34 -0
  229. data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/polymorphism/models/polymorphic_single_attribute.js +183 -0
  230. data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/polymorphism/models/record.js +23 -0
  231. data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/polymorphism/tests/models/polymorphic/single.js +124 -0
  232. data/lib/frameworks/sproutcore/frameworks/foundation/mixins/auto_resize.js +0 -2
  233. data/lib/frameworks/sproutcore/frameworks/foundation/mixins/inner_frame.js +151 -0
  234. data/lib/frameworks/sproutcore/frameworks/foundation/render_delegates/canvas_image.js +27 -17
  235. data/lib/frameworks/sproutcore/frameworks/foundation/system/image_queue.js +6 -3
  236. data/lib/frameworks/sproutcore/frameworks/foundation/system/logger.js +163 -0
  237. data/lib/frameworks/sproutcore/frameworks/foundation/system/user_defaults.js +6 -3
  238. data/lib/frameworks/sproutcore/frameworks/foundation/tests/mixins/inline_text_field/beginEditing.js +1 -0
  239. data/lib/frameworks/sproutcore/frameworks/foundation/tests/system/logger.js +44 -0
  240. data/lib/frameworks/sproutcore/frameworks/foundation/tests/views/image/ui.js +200 -167
  241. data/lib/frameworks/sproutcore/frameworks/foundation/tests/views/text_field/ui.js +1 -1
  242. data/lib/frameworks/sproutcore/frameworks/foundation/views/image.js +52 -137
  243. data/lib/frameworks/sproutcore/frameworks/foundation/views/text_field.js +7 -11
  244. data/lib/frameworks/sproutcore/frameworks/handlebars/extensions.js +138 -0
  245. data/lib/frameworks/sproutcore/frameworks/handlebars/handlebars.js +1338 -0
  246. data/lib/frameworks/sproutcore/frameworks/runtime/core.js +32 -26
  247. data/lib/frameworks/sproutcore/frameworks/runtime/debug/test_suites/array/base.js +162 -3
  248. data/lib/frameworks/sproutcore/frameworks/runtime/mixins/array.js +10 -5
  249. data/lib/frameworks/sproutcore/frameworks/runtime/mixins/enumerable.js +123 -3
  250. data/lib/frameworks/sproutcore/frameworks/runtime/mixins/observable.js +12 -5
  251. data/lib/frameworks/sproutcore/frameworks/runtime/private/chain_observer.js +50 -13
  252. data/lib/frameworks/sproutcore/frameworks/runtime/system/logger.js +163 -333
  253. data/lib/frameworks/sproutcore/frameworks/runtime/system/object.js +58 -8
  254. data/lib/frameworks/sproutcore/frameworks/runtime/system/run_loop.js +2 -0
  255. data/lib/frameworks/sproutcore/frameworks/runtime/tests/core/itemType.js +9 -6
  256. data/lib/frameworks/sproutcore/frameworks/runtime/tests/core/makeArray.js +15 -1
  257. data/lib/frameworks/sproutcore/frameworks/runtime/tests/mixins/array.js +2 -0
  258. data/lib/frameworks/sproutcore/frameworks/runtime/tests/mixins/observable/chained.js +31 -0
  259. data/lib/frameworks/sproutcore/frameworks/runtime/tests/mixins/observable/observable.js +18 -0
  260. data/lib/frameworks/sproutcore/frameworks/runtime/tests/system/logger.js +31 -143
  261. data/lib/frameworks/sproutcore/frameworks/runtime/tests/system/object/concatenated_properties.js +71 -0
  262. data/lib/frameworks/sproutcore/frameworks/runtime/tests/system/object/enhance.js +177 -0
  263. data/lib/frameworks/sproutcore/frameworks/table/views/table.js +5 -4
  264. data/lib/frameworks/sproutcore/frameworks/table/views/table_header.js +5 -3
  265. data/lib/frameworks/sproutcore/themes/ace/resources/button/button.js +8 -2
  266. data/lib/frameworks/sproutcore/themes/ace/resources/menu/menu.css +2 -3
  267. data/lib/frameworks/sproutcore/themes/ace/resources/segmented/18px/segmented.css +1 -1
  268. data/lib/frameworks/sproutcore/themes/ace/resources/segmented/24px/segmented.css +1 -1
  269. data/lib/frameworks/sproutcore/themes/ace/resources/segmented/30px/segmented.css +1 -1
  270. data/lib/frameworks/sproutcore/themes/ace/resources/segmented/44px/segmented.css +1 -1
  271. data/lib/frameworks/sproutcore/themes/ace/resources/segmented/segmented.css +2 -2
  272. data/lib/frameworks/sproutcore/themes/standard_theme/english.lproj/segmented.css +62 -62
  273. data/lib/gen/html_app/Buildfile +36 -0
  274. data/lib/gen/html_app/README +1 -0
  275. data/lib/gen/html_app/USAGE +15 -0
  276. data/lib/gen/html_app/templates/apps/@target_name@/@target_name@.js +14 -0
  277. data/lib/gen/html_app/templates/apps/@target_name@/resources/images/.gitkeep +0 -0
  278. data/lib/gen/html_app/templates/apps/@target_name@/resources/stylesheets/@target_name@.css +0 -0
  279. data/lib/gen/html_app/templates/apps/@target_name@/resources/templates/@target_name@.handlebars +1 -0
  280. data/lib/gen/html_project/Buildfile +45 -0
  281. data/lib/gen/html_project/INIT +3 -0
  282. data/lib/gen/html_project/README +1 -0
  283. data/lib/gen/html_project/USAGE +2 -0
  284. data/lib/gen/html_project/templates/@filename@/Buildfile +8 -0
  285. data/lib/gen/html_project/templates/@filename@/README +7 -0
  286. data/lib/sproutcore/builders/handlebars.rb +30 -0
  287. data/lib/sproutcore/builders.rb +1 -1
  288. data/lib/sproutcore/helpers/static_helper.rb +3 -3
  289. data/lib/sproutcore/tools/init.rb +25 -9
  290. data/spec/buildtasks/manifest/prepare_build_tasks/handlebars_spec.rb +39 -0
  291. data/spec/fixtures/builder_tests/apps/handlebars_test/template.handlebars +5 -0
  292. data/spec/fixtures/real_world/frameworks/sproutcore/english.lproj/templates/demo.handlebars +4 -0
  293. data/spec/lib/builders/handlebars_spec.rb +29 -0
  294. data/vendor/chance/lib/chance/imagers/data_url.rb +20 -7
  295. data/vendor/chance/lib/chance/instance.rb +4 -1
  296. data/vendor/chance/lib/chance/parser.rb +31 -31
  297. data/vendor/chance/lib/chance/slicing.rb +38 -8
  298. metadata +195 -225
  299. data/lib/frameworks/sproutcore/frameworks/amber/system/device.js +0 -143
  300. data/lib/frameworks/sproutcore/frameworks/amber/system/utils.js +0 -174
  301. data/lib/frameworks/sproutcore/frameworks/amber/tests/views/main_pane.js +0 -31
  302. data/lib/frameworks/sproutcore/frameworks/amber/tests/views/pane/sendTouchEvent.js +0 -267
  303. data/lib/frameworks/sproutcore/frameworks/amber/tests/views/view/layoutDidChange.js +0 -149
  304. data/lib/frameworks/sproutcore/frameworks/amber/tests/views/view/layoutStyle.js +0 -602
  305. data/lib/frameworks/sproutcore/frameworks/amber/tests/views/view/render.js +0 -115
  306. data/lib/frameworks/sproutcore/frameworks/amber/views/base.js +0 -1
  307. data/lib/frameworks/sproutcore/frameworks/amber/views/view.js +0 -4003
  308. data/lib/frameworks/sproutcore/frameworks/datastore/models/child_record.js +0 -105
@@ -0,0 +1,1150 @@
1
+ sc_require("views/view");
2
+ sc_require('views/view/layout_style') ;
3
+
4
+ /** Select a horizontal layout for various views.*/
5
+ SC.LAYOUT_HORIZONTAL = 'sc-layout-horizontal';
6
+
7
+ /** Select a vertical layout for various views.*/
8
+ SC.LAYOUT_VERTICAL = 'sc-layout-vertical';
9
+
10
+ /** @private */
11
+ SC._VIEW_DEFAULT_DIMS = 'marginTop marginLeft'.w();
12
+
13
+ /**
14
+ Layout properties to take up the full width of a parent view.
15
+ */
16
+ SC.FULL_WIDTH = { left: 0, right: 0 };
17
+
18
+ /**
19
+ Layout properties to take up the full height of a parent view.
20
+ */
21
+ SC.FULL_HEIGHT = { top: 0, bottom: 0 };
22
+
23
+ /**
24
+ Layout properties to center. Note that you must also specify a width and
25
+ height for this to work.
26
+ */
27
+ SC.ANCHOR_CENTER = { centerX: 0, centerY: 0 };
28
+
29
+ /**
30
+ Layout property for width, height
31
+ */
32
+
33
+ SC.LAYOUT_AUTO = 'auto';
34
+
35
+ SC.View.reopen(
36
+ /** @scope SC.View.prototype */ {
37
+
38
+ concatenatedProperties: ["layoutProperties"],
39
+
40
+ /**
41
+ Optional background color. Will be applied to the view's element if
42
+ set. This property is intended for one-off views that need a background
43
+ element. If you plan to create many view instances it is probably better
44
+ to use CSS.
45
+
46
+ @property {String}
47
+ */
48
+ backgroundColor: null,
49
+
50
+ displayProperties: ['backgroundColor'],
51
+
52
+ /**
53
+ Activates use of brower's static layout. To activate, set this
54
+ property to YES.
55
+
56
+ @property {Boolean}
57
+ */
58
+ useStaticLayout: NO,
59
+
60
+ // ...........................................
61
+ // LAYOUT
62
+ //
63
+
64
+ init: function(original) {
65
+ original();
66
+
67
+ // TODO: This makes it impossible to override
68
+ this.layoutStyleCalculator = SC.View.LayoutStyleCalculator.create({ view: this });
69
+
70
+ this._previousLayout = this.get('layout');
71
+ }.enhance(),
72
+
73
+ /**
74
+ The 'frame' property depends on the 'layout' property as well as the
75
+ parent view's frame. In order to properly invalidate any cached values,
76
+ we need to invalidate the cache whenever 'layout' changes. However,
77
+ observing 'layout' does not guarantee that; the observer might not be run
78
+ immediately.
79
+
80
+ In order to avoid any window of opportunity where the cached frame could
81
+ be invalid, we need to force layoutDidChange() to always immediately run
82
+ whenever 'layout' is set.
83
+ */
84
+ propertyDidChange: function(key, value, _keepCache) {
85
+ // If the key is 'layout', we need to call layoutDidChange() immediately
86
+ // so that if the frame has changed any cached values (for both this view
87
+ // and any child views) can be appropriately invalidated.
88
+
89
+ // To allow layout to be a computed property, we check if any property has
90
+ // changed and if layout is dependent on the property.
91
+ // If it is we call layoutDidChange.
92
+ var layoutChange = false;
93
+ if(typeof this.layout === "function" && this._kvo_dependents) {
94
+ var dependents = this._kvo_dependents[key];
95
+ if(dependents && dependents.indexOf('layout')!=-1) { layoutChange = true; }
96
+ }
97
+ if(key==='layout' || layoutChange) { this.layoutDidChange(); }
98
+ // Resume notification as usual.
99
+ sc_super();
100
+ },
101
+
102
+
103
+ /**
104
+ This convenience method will take the current layout, apply any changes
105
+ you pass and set it again. It is more convenient than having to do this
106
+ yourself sometimes.
107
+
108
+ You can pass just a key/value pair or a hash with several pairs. You can
109
+ also pass a null value to delete a property.
110
+
111
+ This method will avoid actually setting the layout if the value you pass
112
+ does not edit the layout.
113
+
114
+ @param {String|Hash} key
115
+ @param {Object} value
116
+ @returns {SC.View} receiver
117
+ */
118
+ adjust: function(key, value) {
119
+ var layout = SC.clone(this.get('layout')), didChange = NO, cur ;
120
+
121
+ if (key === undefined) { return this ; } // nothing to do.
122
+
123
+ // handle string case
124
+ if (SC.typeOf(key) === SC.T_STRING) {
125
+ hash = {};
126
+ hash[key] = value;
127
+ } else {
128
+ hash = key;
129
+ }
130
+
131
+ for(key in hash) {
132
+ if (!hash.hasOwnProperty(key)) { continue; }
133
+
134
+ value = hash[key] ;
135
+ cur = layout[key] ;
136
+
137
+ if (value === undefined || cur == value) { continue; }
138
+
139
+ if (value === null) {
140
+ delete layout[key] ;
141
+ } else {
142
+ layout[key] = value ;
143
+ }
144
+
145
+ didChange = YES;
146
+ }
147
+
148
+ // now set adjusted layout
149
+ if (didChange) {
150
+ this.set('layout', layout) ;
151
+ }
152
+
153
+ return this ;
154
+ },
155
+
156
+ /**
157
+ The layout describes how you want your view to be positions on the
158
+ screen. You can define the following properties:
159
+
160
+ - left: the left edge
161
+ - top: the top edge
162
+ - right: the right edge
163
+ - bottom: the bottom edge
164
+ - height: the height
165
+ - width: the width
166
+ - centerX: an offset from center X
167
+ - centerY: an offset from center Y
168
+ - minWidth: a minimum width
169
+ - minHeight: a minimum height
170
+ - maxWidth: a maximum width
171
+ - maxHeight: a maximum height
172
+
173
+ Note that you can only use certain combinations to set layout. For
174
+ example, you may set left/right or left/width, but not left/width/right,
175
+ since that combination doesn't make sense.
176
+
177
+ Likewise, you may set a minWidth/minHeight, or maxWidth/maxHeight, but
178
+ if you also set the width/height explicitly, then those constraints won't
179
+ matter as much.
180
+
181
+ Layout is designed to maximize reliance on the browser's rendering
182
+ engine to keep your app up to date.
183
+
184
+ @test in layoutStyle
185
+ */
186
+ layout: { top: 0, left: 0, bottom: 0, right: 0 },
187
+
188
+ /**
189
+ Converts a frame from the receiver's offset to the target offset. Both
190
+ the receiver and the target must belong to the same pane. If you pass
191
+ null, the conversion will be to the pane level.
192
+
193
+ Note that the context of a view's frame is the view's parent frame. In
194
+ other words, if you want to convert the frame of your view to the global
195
+ frame, then you should do:
196
+
197
+ {{{
198
+ var pv = this.get('parentView'), frame = this.get('frame');
199
+ var newFrame = pv ? pv.convertFrameToView(frame, null) : frame;
200
+ }}}
201
+
202
+ @param {Rect} frame the source frame
203
+ @param {SC.View} targetView the target view to convert to
204
+ @returns {Rect} converted frame
205
+ @test in converFrames
206
+ */
207
+ convertFrameToView: function(frame, targetView) {
208
+ var myX=0, myY=0, targetX=0, targetY=0, view = this, f ;
209
+
210
+ // walk up this side
211
+ while (view) {
212
+ f = view.get('frame'); myX += f.x; myY += f.y ;
213
+ view = view.get('layoutView') ;
214
+ }
215
+
216
+ // walk up other size
217
+ if (targetView) {
218
+ view = targetView ;
219
+ while (view) {
220
+ f = view.get('frame'); targetX += f.x; targetY += f.y ;
221
+ view = view.get('layoutView') ;
222
+ }
223
+ }
224
+
225
+ // now we can figure how to translate the origin.
226
+ myX = frame.x + myX - targetX ;
227
+ myY = frame.y + myY - targetY ;
228
+ return { x: myX, y: myY, width: frame.width, height: frame.height } ;
229
+ },
230
+
231
+ /**
232
+ Converts a frame offset in the coordinates of another view system to the
233
+ receiver's view.
234
+
235
+ Note that the convext of a view's frame is relative to the view's
236
+ parentFrame. For example, if you want to convert the frame of view that
237
+ belongs to another view to the receiver's frame you would do:
238
+
239
+ {{{
240
+ var frame = view.get('frame');
241
+ var newFrame = this.convertFrameFromView(frame, view.get('parentView'));
242
+ }}}
243
+
244
+ @param {Rect} frame the source frame
245
+ @param {SC.View} targetView the target view to convert to
246
+ @returns {Rect} converted frame
247
+ @test in converFrames
248
+ */
249
+ convertFrameFromView: function(frame, targetView) {
250
+ var myX=0, myY=0, targetX=0, targetY=0, view = this, f ;
251
+
252
+ // walk up this side
253
+ //Note: Intentional assignment of variable f
254
+ while (view && (f = view.get('frame'))) {
255
+ myX += f.x; myY += f.y ;
256
+ view = view.get('parentView') ;
257
+ }
258
+
259
+ // walk up other size
260
+ if (targetView) {
261
+ view = targetView ;
262
+ while(view) {
263
+ f = view.get('frame'); targetX += f.x; targetY += f.y ;
264
+ view = view.get('parentView') ;
265
+ }
266
+ }
267
+
268
+ // now we can figure how to translate the origin.
269
+ myX = frame.x - myX + targetX ;
270
+ myY = frame.y - myY + targetY ;
271
+ return { x: myX, y: myY, width: frame.width, height: frame.height } ;
272
+ },
273
+
274
+ /**
275
+ Attempt to scroll the view to visible. This will walk up the parent
276
+ view hierarchy looking looking for a scrollable view. It will then
277
+ call scrollToVisible() on it.
278
+
279
+ Returns YES if an actual scroll took place, no otherwise.
280
+
281
+ @returns {Boolean}
282
+ */
283
+ scrollToVisible: function() {
284
+ var pv = this.get('parentView');
285
+ while(pv && !pv.get('isScrollable')) { pv = pv.get('parentView'); }
286
+
287
+ // found view, first make it scroll itself visible then scroll this.
288
+ if (pv) {
289
+ pv.scrollToVisible();
290
+ return pv.scrollToVisible(this);
291
+ } else {
292
+ return NO ;
293
+ }
294
+ },
295
+
296
+ /**
297
+ Frame describes the current bounding rect for your view. This is always
298
+ measured from the top-left corner of the parent view.
299
+
300
+ @property {Rect}
301
+ @test in layoutStyle
302
+ */
303
+ frame: function() {
304
+ return this.computeFrameWithParentFrame(null) ;
305
+ }.property('useStaticLayout').cacheable(), // We depend on the layout, but layoutDidChange will call viewDidResize to check the frame for us
306
+
307
+ /**
308
+ Computes what the frame of this view would be if the parent were resized
309
+ to the passed dimensions. You can use this method to project the size of
310
+ a frame based on the resize behavior of the parent.
311
+
312
+ This method is used especially by the scroll view to automatically
313
+ calculate when scrollviews should be visible.
314
+
315
+ Passing null for the parent dimensions will use the actual current
316
+ parent dimensions. This is the same method used to calculate the current
317
+ frame when it changes.
318
+
319
+ @param {Rect} pdim the projected parent dimensions
320
+ @returns {Rect} the computed frame
321
+ */
322
+ computeFrameWithParentFrame: function(pdim) {
323
+ var layout = this.get('layout'),
324
+ f = {} , error, layer, AUTO = SC.LAYOUT_AUTO,
325
+ stLayout = this.get('useStaticLayout'),
326
+ pv = this.get('parentView'),
327
+ dH, dW, //shortHand for parentDimensions
328
+ borderTop, borderLeft,
329
+ lR = layout.right,
330
+ lL = layout.left,
331
+ lT = layout.top,
332
+ lB = layout.bottom,
333
+ lW = layout.width,
334
+ lH = layout.height,
335
+ lcX = layout.centerX,
336
+ lcY = layout.centerY;
337
+
338
+ if (lW === AUTO && stLayout !== undefined && !stLayout) {
339
+ error = SC.Error.desc(("%@.layout() cannot use width:auto if "+
340
+ "staticLayout is disabled").fmt(this), "%@".fmt(this), -1);
341
+ console.error(error.toString()) ;
342
+ throw error ;
343
+ }
344
+
345
+ if (lH === AUTO && stLayout !== undefined && !stLayout) {
346
+ error = SC.Error.desc(("%@.layout() cannot use height:auto if "+
347
+ "staticLayout is disabled").fmt(this),"%@".fmt(this), -1);
348
+ console.error(error.toString()) ;
349
+ throw error ;
350
+ }
351
+
352
+ if (stLayout) {
353
+ // need layer to be able to compute rect
354
+ if (layer = this.get('layer')) {
355
+ f = SC.viewportOffset(layer); // x,y
356
+ if (pv) { f = pv.convertFrameFromView(f, null); }
357
+
358
+ /*
359
+ TODO Can probably have some better width/height values - CC
360
+ FIXME This will probably not work right with borders - PW
361
+ */
362
+ f.width = layer.offsetWidth;
363
+ f.height = layer.offsetHeight;
364
+ return f;
365
+ }
366
+ return null; // can't compute
367
+ }
368
+
369
+
370
+ if (!pdim) { pdim = this.computeParentDimensions(layout) ; }
371
+ dH = pdim.height;
372
+ dW = pdim.width;
373
+
374
+ // handle left aligned and left/right
375
+ if (!SC.none(lL)) {
376
+ if(SC.isPercentage(lL)){
377
+ f.x = dW*lL;
378
+ }else{
379
+ f.x = lL ;
380
+ }
381
+ if (lW !== undefined) {
382
+ if(lW === AUTO) { f.width = AUTO ; }
383
+ else if(SC.isPercentage(lW)) { f.width = dW*lW ; }
384
+ else { f.width = lW ; }
385
+ } else { // better have lR!
386
+ f.width = dW - f.x ;
387
+ if(lR && SC.isPercentage(lR)) { f.width = f.width - (lR*dW) ; }
388
+ else { f.width = f.width - (lR || 0) ; }
389
+ }
390
+ // handle right aligned
391
+ } else if (!SC.none(lR)) {
392
+ if (SC.none(lW)) {
393
+ if (SC.isPercentage(lR)) {
394
+ f.width = dW - (dW*lR) ;
395
+ }
396
+ else f.width = dW - lR ;
397
+ f.x = 0 ;
398
+ } else {
399
+ if(lW === AUTO) f.width = AUTO ;
400
+ else if(SC.isPercentage(lW)) f.width = dW*lW ;
401
+ else f.width = (lW || 0) ;
402
+ if (SC.isPercentage(lW)) f.x = dW - (lR*dW) - f.width ;
403
+ else f.x = dW - lR - f.width ;
404
+ }
405
+
406
+ // handle centered
407
+ } else if (!SC.none(lcX)) {
408
+ if(lW === AUTO) f.width = AUTO ;
409
+ else if (SC.isPercentage(lW)) f.width = lW*dW ;
410
+ else f.width = (lW || 0) ;
411
+ if(SC.isPercentage(lcX)) f.x = (dW - f.width)/2 + (lcX*dW) ;
412
+ else f.x = (dW - f.width)/2 + lcX ;
413
+ } else {
414
+ f.x = 0 ; // fallback
415
+ if (SC.none(lW)) {
416
+ f.width = dW ;
417
+ } else {
418
+ if(lW === AUTO) f.width = AUTO ;
419
+ if (SC.isPercentage(lW)) f.width = lW*dW ;
420
+ else f.width = (lW || 0) ;
421
+ }
422
+ }
423
+
424
+ // handle top aligned and top/bottom
425
+ if (!SC.none(lT)) {
426
+ if(SC.isPercentage(lT)) f.y = lT*dH ;
427
+ else f.y = lT ;
428
+ if (lH !== undefined) {
429
+ if(lH === AUTO) f.height = AUTO ;
430
+ else if(SC.isPercentage(lH)) f.height = lH*dH ;
431
+ else f.height = lH ;
432
+ } else { // better have lB!
433
+ if(lB && SC.isPercentage(lB)) f.height = dH - f.y - (lB*dH) ;
434
+ else f.height = dH - f.y - (lB || 0) ;
435
+ }
436
+
437
+ // handle bottom aligned
438
+ } else if (!SC.none(lB)) {
439
+ if (SC.none(lH)) {
440
+ if (SC.isPercentage(lB)) f.height = dH - (lB*dH) ;
441
+ else f.height = dH - lB ;
442
+ f.y = 0 ;
443
+ } else {
444
+ if(lH === AUTO) f.height = AUTO ;
445
+ if (lH && SC.isPercentage(lH)) f.height = lH*dH ;
446
+ else f.height = (lH || 0) ;
447
+ if (SC.isPercentage(lB)) f.y = dH - (lB*dH) - f.height ;
448
+ else f.y = dH - lB - f.height ;
449
+ }
450
+
451
+ // handle centered
452
+ } else if (!SC.none(lcY)) {
453
+ if(lH === AUTO) f.height = AUTO ;
454
+ if (lH && SC.isPercentage(lH)) f.height = lH*dH ;
455
+ else f.height = (lH || 0) ;
456
+ if (SC.isPercentage(lcY)) f.y = (dH - f.height)/2 + (lcY*dH) ;
457
+ else f.y = (dH - f.height)/2 + lcY ;
458
+
459
+ // fallback
460
+ } else {
461
+ f.y = 0 ; // fallback
462
+ if (SC.none(lH)) {
463
+ f.height = dH ;
464
+ } else {
465
+ if(lH === AUTO) f.height = AUTO ;
466
+ if (SC.isPercentage(lH)) f.height = lH*dH ;
467
+ else f.height = lH || 0 ;
468
+ }
469
+ }
470
+
471
+ f.x = Math.floor(f.x);
472
+ f.y = Math.floor(f.y);
473
+ if(f.height !== AUTO) f.height = Math.floor(f.height);
474
+ if(f.width !== AUTO) f.width = Math.floor(f.width);
475
+
476
+ // if width or height were set to auto and we have a layer, try lookup
477
+ if (f.height === AUTO || f.width === AUTO) {
478
+ layer = this.get('layer');
479
+ if (f.height === AUTO) f.height = layer ? layer.clientHeight : 0;
480
+ if (f.width === AUTO) f.width = layer ? layer.clientWidth : 0;
481
+ }
482
+
483
+ // views with SC.Border mixin applied applied
484
+ if (this.get('hasBorder')) {
485
+ borderTop = this.get('borderTop') || 0;
486
+ borderLeft = this.get('borderLeft') || 0;
487
+ f.height -= borderTop+ (this.get('borderBottom') || 0);
488
+ f.y += borderTop;
489
+ f.width -= borderLeft + (this.get('borderRight') || 0);
490
+ f.x += borderLeft;
491
+ }
492
+
493
+ // Account for special cases inside ScrollView, where we adjust the
494
+ // element's scrollTop/scrollLeft property for performance reasons.
495
+ if (pv && pv.isScrollContainer) {
496
+ pv = pv.get('parentView');
497
+ f.x -= pv.get('horizontalScrollOffset');
498
+ f.y -= pv.get('verticalScrollOffset');
499
+ }
500
+
501
+ // make sure the width/height fix min/max...
502
+ if (!SC.none(layout.maxHeight) && (f.height > layout.maxHeight)) {
503
+ f.height = layout.maxHeight ;
504
+ }
505
+
506
+ if (!SC.none(layout.minHeight) && (f.height < layout.minHeight)) {
507
+ f.height = layout.minHeight ;
508
+ }
509
+
510
+ if (!SC.none(layout.maxWidth) && (f.width > layout.maxWidth)) {
511
+ f.width = layout.maxWidth ;
512
+ }
513
+
514
+ if (!SC.none(layout.minWidth) && (f.width < layout.minWidth)) {
515
+ f.width = layout.minWidth ;
516
+ }
517
+
518
+ // make sure width/height are never < 0
519
+ if (f.height < 0) f.height = 0 ;
520
+ if (f.width < 0) f.width = 0 ;
521
+
522
+ return f;
523
+ },
524
+
525
+ computeParentDimensions: function(frame) {
526
+ var ret, pv = this.get('parentView'), pf = (pv) ? pv.get('frame') : null ;
527
+
528
+ if (pf) {
529
+ ret = { width: pf.width, height: pf.height };
530
+ } else {
531
+ var f = frame || {};
532
+ ret = {
533
+ width: (f.left || 0) + (f.width || 0) + (f.right || 0),
534
+ height: (f.top || 0) + (f.height || 0) + (f.bottom || 0)
535
+ };
536
+ }
537
+ return ret ;
538
+ },
539
+
540
+ /**
541
+ The clipping frame returns the visible portion of the view, taking into
542
+ account the contentClippingFrame of the parent view. Keep in mind that
543
+ the clippingFrame is in the context of the view itself, not it's parent
544
+ view.
545
+
546
+ Normally this will be calculated based on the intersection of your own
547
+ clippingFrame and your parentView's contentClippingFrame.
548
+
549
+ @property {Rect}
550
+ */
551
+ clippingFrame: function() {
552
+ var f = this.get('frame'),
553
+ ret = f,
554
+ pv, cf;
555
+
556
+ if (!f) return null;
557
+ pv = this.get('parentView');
558
+ if (pv) {
559
+ cf = pv.get('contentClippingFrame');
560
+ if (!cf) return f;
561
+ ret = SC.intersectRects(cf, f);
562
+ }
563
+ ret.x -= f.x;
564
+ ret.y -= f.y;
565
+
566
+ return ret;
567
+ }.property('parentView', 'frame').cacheable(),
568
+
569
+ /**
570
+ The clipping frame child views should intersect with. Normally this is
571
+ the same as the regular clippingFrame. However, you may override this
572
+ method if you want the child views to actually draw more or less content
573
+ than is actually visible for some reason.
574
+
575
+ Usually this is only used by the ScrollView to optimize drawing on touch
576
+ devices.
577
+
578
+ @property {Rect}
579
+ */
580
+ contentClippingFrame: function() {
581
+ return this.get('clippingFrame');
582
+ }.property('clippingFrame').cacheable(),
583
+
584
+ /** @private
585
+ This method is invoked whenever the clippingFrame changes, notifying
586
+ each child view that its clippingFrame has also changed.
587
+ */
588
+ _sc_view_clippingFrameDidChange: function() {
589
+ var cvs = this.get('childViews'), len = cvs.length, idx, cv ;
590
+ for (idx=0; idx<len; ++idx) {
591
+ cv = cvs[idx] ;
592
+
593
+ // In SC 1.0 views with static layout did not receive notifications
594
+ // of frame changes because they didn't support frames. In SC 1.1 they
595
+ // do support frames, so they should receive notifications. Also in
596
+ // SC 1.1 SC.StaticLayout is merged into SC.View. The mixin is only
597
+ // for compatibility. This property is defined on the mixin.
598
+ //
599
+ // frame changes should be sent all the time unless this property is
600
+ // present to indicate that we want the old 1.0 API behavior instead.
601
+ //
602
+ if (!cv.useStaticLayout && cv._sc_view_clippingFrameDidChange) {
603
+ cv.notifyPropertyChange('clippingFrame') ;
604
+ cv._sc_view_clippingFrameDidChange();
605
+ }
606
+ }
607
+ },
608
+
609
+ /**
610
+ This method may be called on your view whenever the parent view resizes.
611
+
612
+ The default version of this method will reset the frame and then call
613
+ viewDidResize(). You will not usually override this method, but you may
614
+ override the viewDidResize() method.
615
+
616
+ @returns {void}
617
+ @test in viewDidResize
618
+ */
619
+ parentViewDidResize: function() {
620
+ var frameMayHaveChanged, layout, isFixed, isPercentageFunc, isPercentage;
621
+
622
+ // If this view uses static layout, our "do we think the frame changed?"
623
+ // logic is not applicable and we simply have to assume that the frame may
624
+ // have changed.
625
+ if (this.useStaticLayout) {
626
+ frameMayHaveChanged = YES;
627
+ }
628
+ else {
629
+ layout = this.get('layout');
630
+
631
+ // only resizes if the layout does something other than left/top - fixed
632
+ // size.
633
+ isFixed = (
634
+ (layout.left !== undefined) && (layout.top !== undefined) &&
635
+ (layout.width !== undefined) && (layout.height !== undefined)
636
+ );
637
+
638
+
639
+ // If it's fixed, our frame still could have changed if it's fixed to a
640
+ // percentage of the parent.
641
+ if (isFixed) {
642
+ isPercentageFunc = SC.isPercentage;
643
+ isPercentage = (isPercentageFunc(layout.left) ||
644
+ isPercentageFunc(layout.top) ||
645
+ isPercentageFunc(layout.width) ||
646
+ isPercentageFunc(layout.right) ||
647
+ isPercentageFunc(layout.centerX) ||
648
+ isPercentageFunc(layout.centerY));
649
+ }
650
+
651
+ frameMayHaveChanged = (!isFixed || isPercentage);
652
+ }
653
+
654
+ // Do we think there's a chance our frame will have changed as a result?
655
+ if (frameMayHaveChanged) {
656
+ // There's a chance our frame changed. Invoke viewDidResize(), which
657
+ // will notify about our change to 'frame' (if it actually changed) and
658
+ // appropriately notify our child views.
659
+ this.viewDidResize();
660
+ }
661
+ },
662
+
663
+
664
+
665
+ /**
666
+ This method is invoked on your view when the view resizes due to a layout
667
+ change or potentially due to the parent view resizing (if your view’s size
668
+ depends on the size of your parent view). You can override this method
669
+ to implement your own layout if you like, such as performing a grid
670
+ layout.
671
+
672
+ The default implementation simply notifies about the change to 'frame' and
673
+ then calls parentViewDidResize on all of your children.
674
+
675
+ @returns {void}
676
+ */
677
+ viewDidResize: function() {
678
+ this._viewFrameDidChange();
679
+
680
+ // Also notify our children.
681
+ var cv = this.childViews, len, idx, view ;
682
+ for (idx=0; idx<(len= cv.length); ++idx) {
683
+ view = cv[idx];
684
+ view.tryToPerform('parentViewDidResize');
685
+ }
686
+ },
687
+
688
+ /** @private
689
+ Invoked by other views to notify this view that its frame has changed.
690
+
691
+ This notifies the view that its frame property has changed,
692
+ then propagates those changes to its child views.
693
+ */
694
+ _viewFrameDidChange: function() {
695
+ this.notifyPropertyChange('frame');
696
+ this._sc_view_clippingFrameDidChange();
697
+ },
698
+
699
+ // Implementation note: As a general rule, paired method calls, such as
700
+ // beginLiveResize/endLiveResize that are called recursively on the tree
701
+ // should reverse the order when doing the final half of the call. This
702
+ // ensures that the calls are propertly nested for any cleanup routines.
703
+ //
704
+ // -> View A.beginXXX()
705
+ // -> View B.beginXXX()
706
+ // -> View C.begitXXX()
707
+ // -> View D.beginXXX()
708
+ //
709
+ // ...later on, endXXX methods are called in reverse order of beginXXX...
710
+ //
711
+ // <- View D.endXXX()
712
+ // <- View C.endXXX()
713
+ // <- View B.endXXX()
714
+ // <- View A.endXXX()
715
+ //
716
+ // See the two methods below for an example implementation.
717
+
718
+ /**
719
+ Call this method when you plan to begin a live resize. This will
720
+ notify the receiver view and any of its children that are interested
721
+ that the resize is about to begin.
722
+
723
+ @returns {SC.View} receiver
724
+ @test in viewDidResize
725
+ */
726
+ beginLiveResize: function() {
727
+ // call before children have been notified...
728
+ if (this.willBeginLiveResize) this.willBeginLiveResize() ;
729
+
730
+ // notify children in order
731
+ var ary = this.get('childViews'), len = ary.length, idx, view ;
732
+ for (idx=0; idx<len; ++idx) {
733
+ view = ary[idx] ;
734
+ if (view.beginLiveResize) view.beginLiveResize();
735
+ }
736
+ return this ;
737
+ },
738
+
739
+ /**
740
+ Call this method when you are finished with a live resize. This will
741
+ notify the receiver view and any of its children that are interested
742
+ that the live resize has ended.
743
+
744
+ @returns {SC.View} receiver
745
+ @test in viewDidResize
746
+ */
747
+ endLiveResize: function() {
748
+ // notify children in *reverse* order
749
+ var ary = this.get('childViews'), len = ary.length, idx, view ;
750
+ for (idx=len-1; idx>=0; --idx) { // loop backwards
751
+ view = ary[idx] ;
752
+ if (view.endLiveResize) view.endLiveResize() ;
753
+ }
754
+
755
+ // call *after* all children have been notified...
756
+ if (this.didEndLiveResize) this.didEndLiveResize() ;
757
+ return this ;
758
+ },
759
+
760
+ /**
761
+ The view responsible for laying out this view. The default version
762
+ returns the current parent view.
763
+ */
764
+ layoutView: function() {
765
+ return this.get('parentView') ;
766
+ }.property('parentView').cacheable(),
767
+
768
+ /**
769
+ This method is called whenever a property changes that invalidates the
770
+ layout of the view. Changing the layout will do this automatically, but
771
+ you can add others if you want.
772
+
773
+ Implementation Note: In a traditional setup, we would simply observe
774
+ 'layout' here, but as described above in the documentation for our custom
775
+ implementation of propertyDidChange(), this method must always run
776
+ immediately after 'layout' is updated to avoid the potential for stale
777
+ (incorrect) cached 'frame' values.
778
+
779
+ @returns {SC.View} receiver
780
+ */
781
+ layoutDidChange: function() {
782
+ // Did our layout change in a way that could cause us to be resized? If
783
+ // not, then there's no need to invalidate the frames of our child views.
784
+ var previousLayout = this._previousLayout,
785
+ currentLayout = this.get('layout'),
786
+ didResize = YES,
787
+ previousWidth, previousHeight, currentWidth, currentHeight;
788
+
789
+
790
+ // Handle old style rotation
791
+ if (!SC.none(currentLayout.rotate)) {
792
+ if (SC.none(currentLayout.rotateX)) {
793
+ currentLayout.rotateX = currentLayout.rotate;
794
+ console.warn('Please set rotateX instead of rotate');
795
+ }
796
+ }
797
+ if (!SC.none(currentLayout.rotateX)) {
798
+ currentLayout.rotate = currentLayout.rotateX;
799
+ } else {
800
+ delete currentLayout.rotate;
801
+ }
802
+
803
+ var animations = currentLayout.animations;
804
+ if (animations) {
805
+ if (!SC.none(animations.rotate)) {
806
+ if (SC.none(animations.rotateX)) {
807
+ animations.rotateX = animations.rotate;
808
+ console.warn('Please animate rotateX instead of rotate');
809
+ }
810
+ }
811
+ if (!SC.none(animations.rotateX)) {
812
+ animations.rotate = animations.rotateX;
813
+ } else {
814
+ delete animations.rotate;
815
+ }
816
+ }
817
+
818
+ if (previousLayout && previousLayout !== currentLayout) {
819
+ // This is a simple check to see whether we think the view may have
820
+ // resized. We could look for a number of cases, but for now we'll
821
+ // handle only one simple case: if the width and height are both
822
+ // specified, and they have not changed.
823
+ previousWidth = previousLayout.width;
824
+ if (previousWidth !== undefined) {
825
+ currentWidth = currentLayout.width;
826
+ if (previousWidth === currentWidth) {
827
+ previousHeight = previousLayout.height;
828
+ if (previousLayout !== undefined) {
829
+ currentHeight = currentLayout.height;
830
+ if (previousHeight === currentHeight) didResize = NO;
831
+ }
832
+ }
833
+ }
834
+ }
835
+
836
+ this.beginPropertyChanges() ;
837
+ this.notifyPropertyChange('hasAcceleratedLayer');
838
+ this.notifyPropertyChange('layoutStyle') ;
839
+ if (didResize) {
840
+ this.viewDidResize();
841
+ }
842
+ else {
843
+ // Even if we didn't resize, our frame might have changed.
844
+ // viewDidResize() handles this in the other case.
845
+ this._viewFrameDidChange();
846
+ }
847
+ this.endPropertyChanges() ;
848
+
849
+ // notify layoutView...
850
+ var layoutView = this.get('layoutView');
851
+ if (layoutView) {
852
+ layoutView.set('childViewsNeedLayout', YES);
853
+ layoutView.layoutDidChangeFor(this) ;
854
+ if (layoutView.get('childViewsNeedLayout')) {
855
+ layoutView.invokeOnce(layoutView.layoutChildViewsIfNeeded);
856
+ }
857
+ }
858
+
859
+ this._previousLayout = currentLayout;
860
+
861
+ return this ;
862
+ },
863
+
864
+ /**
865
+ This this property to YES whenever the view needs to layout its child
866
+ views. Normally this property is set automatically whenever the layout
867
+ property for a child view changes.
868
+
869
+ @property {Boolean}
870
+ */
871
+ childViewsNeedLayout: NO,
872
+
873
+ /**
874
+ One of two methods that are invoked whenever one of your childViews
875
+ layout changes. This method is invoked everytime a child view's layout
876
+ changes to give you a chance to record the information about the view.
877
+
878
+ Since this method may be called many times during a single run loop, you
879
+ should keep this method pretty short. The other method called when layout
880
+ changes, layoutChildViews(), is invoked only once at the end of
881
+ the run loop. You should do any expensive operations (including changing
882
+ a childView's actual layer) in this other method.
883
+
884
+ Note that if as a result of running this method you decide that you do not
885
+ need your layoutChildViews() method run later, you can set the
886
+ childViewsNeedsLayout property to NO from this method and the layout
887
+ method will not be called layer.
888
+
889
+ @param {SC.View} childView the view whose layout has changed.
890
+ @returns {void}
891
+ */
892
+ layoutDidChangeFor: function(childView) {
893
+ var set = this._needLayoutViews ;
894
+ if (!set) set = this._needLayoutViews = SC.CoreSet.create();
895
+ set.add(childView);
896
+ },
897
+
898
+ /**
899
+ Called your layout method if the view currently needs to layout some
900
+ child views.
901
+
902
+ @param {Boolean} isVisible if true assume view is visible even if it is not.
903
+ @returns {SC.View} receiver
904
+ @test in layoutChildViews
905
+ */
906
+ layoutChildViewsIfNeeded: function(isVisible) {
907
+ if (!isVisible) isVisible = this.get('isVisibleInWindow');
908
+ if (isVisible && this.get('childViewsNeedLayout')) {
909
+ this.set('childViewsNeedLayout', NO);
910
+ this.layoutChildViews();
911
+ }
912
+ return this ;
913
+ },
914
+
915
+ /**
916
+ Applies the current layout to the layer. This method is usually only
917
+ called once per runloop. You can override this method to provide your
918
+ own layout updating method if you want, though usually the better option
919
+ is to override the layout method from the parent view.
920
+
921
+ The default implementation of this method simply calls the renderLayout()
922
+ method on the views that need layout.
923
+
924
+ @returns {void}
925
+ */
926
+ layoutChildViews: function() {
927
+ var set = this._needLayoutViews,
928
+ len = set ? set.length : 0,
929
+ i;
930
+ for (i = 0; i < len; ++i) {
931
+ set[i].updateLayout();
932
+ }
933
+ set.clear(); // reset & reuse
934
+ },
935
+
936
+ /**
937
+ Invoked by the layoutChildViews method to update the layout on a
938
+ particular view. This method creates a render context and calls the
939
+ renderLayout() method, which is probably what you want to override instead
940
+ of this.
941
+
942
+ You will not usually override this method, but you may call it if you
943
+ implement layoutChildViews() in a view yourself.
944
+
945
+ @returns {SC.View} receiver
946
+ @test in layoutChildViews
947
+ */
948
+ updateLayout: function() {
949
+ var layer = this.get('layer'), context;
950
+ if (layer) {
951
+ context = this.renderContext(layer);
952
+ this.renderLayout(context, NO);
953
+ context.update();
954
+
955
+ // If this view uses static layout, then notify if the frame changed.
956
+ // (viewDidResize will do a comparison)
957
+ if (this.useStaticLayout) this.viewDidResize();
958
+ }
959
+ layer = null ;
960
+ return this ;
961
+ },
962
+
963
+ /**
964
+ Default method called by the layout view to actually apply the current
965
+ layout to the layer. The default implementation simply assigns the
966
+ current layoutStyle to the layer. This method is also called whenever
967
+ the layer is first created.
968
+
969
+ @param {SC.RenderContext} the render context
970
+ @returns {void}
971
+ @test in layoutChildViews
972
+ */
973
+ renderLayout: function(context, firstTime) {
974
+ this.get('layoutStyleCalculator').willRenderAnimations();
975
+ context.addStyle(this.get('layoutStyle'));
976
+ this.get('layoutStyleCalculator').didRenderAnimations();
977
+ },
978
+
979
+ _renderLayerSettings: function(original, context, firstTime) {
980
+ original(context, firstTime);
981
+ this.renderLayout(context, firstTime);
982
+ }.enhance(),
983
+
984
+ applyAttributesToContext: function(original, context) {
985
+ original(context);
986
+
987
+ if (this.get('useStaticLayout')) { context.addClass('sc-static-layout'); }
988
+ if (this.get('backgroundColor')) {
989
+ context.css('backgroundColor', this.get('backgroundColor'));
990
+ }
991
+ }.enhance()
992
+ });
993
+
994
+ SC.View.mixin(
995
+ /** @scope SC.View */ {
996
+
997
+ /**
998
+ Convert any layout to a Top, Left, Width, Height layout
999
+ */
1000
+ convertLayoutToAnchoredLayout: function(layout, parentFrame){
1001
+ var ret = {top: 0, left: 0, width: parentFrame.width, height: parentFrame.height},
1002
+ pFW = parentFrame.width, pFH = parentFrame.height, //shortHand for parentDimensions
1003
+ lR = layout.right,
1004
+ lL = layout.left,
1005
+ lT = layout.top,
1006
+ lB = layout.bottom,
1007
+ lW = layout.width,
1008
+ lH = layout.height,
1009
+ lcX = layout.centerX,
1010
+ lcY = layout.centerY;
1011
+
1012
+ // X Conversion
1013
+ // handle left aligned and left/right
1014
+ if (!SC.none(lL)) {
1015
+ if(SC.isPercentage(lL)) ret.left = lL*pFW;
1016
+ else ret.left = lL;
1017
+ if (lW !== undefined) {
1018
+ if(lW === SC.LAYOUT_AUTO) ret.width = SC.LAYOUT_AUTO ;
1019
+ else if(SC.isPercentage(lW)) ret.width = lW*pFW ;
1020
+ else ret.width = lW ;
1021
+ } else {
1022
+ if (lR && SC.isPercentage(lR)) ret.width = pFW - ret.left - (lR*pFW);
1023
+ else ret.width = pFW - ret.left - (lR || 0);
1024
+ }
1025
+
1026
+ // handle right aligned
1027
+ } else if (!SC.none(lR)) {
1028
+
1029
+ // if no width, calculate it from the parent frame
1030
+ if (SC.none(lW)) {
1031
+ ret.left = 0;
1032
+ if(lR && SC.isPercentage(lR)) ret.width = pFW - (lR*pFW);
1033
+ else ret.width = pFW - (lR || 0);
1034
+
1035
+ // If has width, calculate the left anchor from the width and right and parent frame
1036
+ } else {
1037
+ if(lW === SC.LAYOUT_AUTO) ret.width = SC.LAYOUT_AUTO ;
1038
+ else {
1039
+ if (SC.isPercentage(lW)) ret.width = lW*pFW;
1040
+ else ret.width = lW;
1041
+ if (SC.isPercentage(lR)) ret.left = pFW - (ret.width + lR);
1042
+ else ret.left = pFW - (ret.width + lR);
1043
+ }
1044
+ }
1045
+
1046
+ // handle centered
1047
+ } else if (!SC.none(lcX)) {
1048
+ if(lW && SC.isPercentage(lW)) ret.width = (lW*pFW) ;
1049
+ else ret.width = (lW || 0) ;
1050
+ ret.left = ((pFW - ret.width)/2);
1051
+ if (SC.isPercentage(lcX)) ret.left = ret.left + lcX*pFW;
1052
+ else ret.left = ret.left + lcX;
1053
+
1054
+ // if width defined, assume left of zero
1055
+ } else if (!SC.none(lW)) {
1056
+ ret.left = 0;
1057
+ if(lW === SC.LAYOUT_AUTO) ret.width = SC.LAYOUT_AUTO ;
1058
+ else {
1059
+ if(SC.isPercentage(lW)) ret.width = lW*pFW;
1060
+ else ret.width = lW;
1061
+ }
1062
+
1063
+ // fallback, full width.
1064
+ } else {
1065
+ ret.left = 0;
1066
+ ret.width = 0;
1067
+ }
1068
+
1069
+ // handle min/max
1070
+ if (layout.minWidth !== undefined) ret.minWidth = layout.minWidth ;
1071
+ if (layout.maxWidth !== undefined) ret.maxWidth = layout.maxWidth ;
1072
+
1073
+ // Y Conversion
1074
+ // handle left aligned and top/bottom
1075
+ if (!SC.none(lT)) {
1076
+ if(SC.isPercentage(lT)) ret.top = lT*pFH;
1077
+ else ret.top = lT;
1078
+ if (lH !== undefined) {
1079
+ if(lH === SC.LAYOUT_AUTO) ret.height = SC.LAYOUT_AUTO ;
1080
+ else if (SC.isPercentage(lH)) ret.height = lH*pFH;
1081
+ else ret.height = lH ;
1082
+ } else {
1083
+ ret.height = pFH - ret.top;
1084
+ if(lB && SC.isPercentage(lB)) ret.height = ret.height - (lB*pFH);
1085
+ else ret.height = ret.height - (lB || 0);
1086
+ }
1087
+
1088
+ // handle bottom aligned
1089
+ } else if (!SC.none(lB)) {
1090
+
1091
+ // if no height, calculate it from the parent frame
1092
+ if (SC.none(lH)) {
1093
+ ret.top = 0;
1094
+ if (lB && SC.isPercentage(lB)) ret.height = pFH - (lB*pFH);
1095
+ else ret.height = pFH - (lB || 0);
1096
+
1097
+ // If has height, calculate the top anchor from the height and bottom and parent frame
1098
+ } else {
1099
+ if(lH === SC.LAYOUT_AUTO) ret.height = SC.LAYOUT_AUTO ;
1100
+ else {
1101
+ if (SC.isPercentage(lH)) ret.height = lH*pFH;
1102
+ else ret.height = lH;
1103
+ ret.top = pFH - ret.height;
1104
+ if (SC.isPercentage(lB)) ret.top = ret.top - (lB*pFH);
1105
+ else ret.top = ret.top - lB;
1106
+ }
1107
+ }
1108
+
1109
+ // handle centered
1110
+ } else if (!SC.none(lcY)) {
1111
+ if(lH && SC.isPercentage(lH)) ret.height = (lH*pFH) ;
1112
+ else ret.height = (lH || 0) ;
1113
+ ret.top = ((pFH - ret.height)/2);
1114
+ if(SC.isPercentage(lcY)) ret.top = ret.top + lcY*pFH;
1115
+ else ret.top = ret.top + lcY;
1116
+
1117
+ // if height defined, assume top of zero
1118
+ } else if (!SC.none(lH)) {
1119
+ ret.top = 0;
1120
+ if(lH === SC.LAYOUT_AUTO) ret.height = SC.LAYOUT_AUTO ;
1121
+ else if (SC.isPercentage(lH)) ret.height = lH*pFH;
1122
+ else ret.height = lH;
1123
+
1124
+ // fallback, full height.
1125
+ } else {
1126
+ ret.top = 0;
1127
+ ret.height = 0;
1128
+ }
1129
+
1130
+ if(ret.top) ret.top = Math.floor(ret.top);
1131
+ if(ret.bottom) ret.bottom = Math.floor(ret.bottom);
1132
+ if(ret.left) ret.left = Math.floor(ret.left);
1133
+ if(ret.right) ret.right = Math.floor(ret.right);
1134
+ if(ret.width !== SC.LAYOUT_AUTO) ret.width = Math.floor(ret.width);
1135
+ if(ret.height !== SC.LAYOUT_AUTO) ret.height = Math.floor(ret.height);
1136
+
1137
+ // handle min/max
1138
+ if (layout.minHeight !== undefined) ret.minHeight = layout.minHeight ;
1139
+ if (layout.maxHeight !== undefined) ret.maxHeight = layout.maxHeight ;
1140
+
1141
+ return ret;
1142
+ },
1143
+
1144
+ /**
1145
+ For now can only convert Top/Left/Width/Height to a Custom Layout
1146
+ */
1147
+ convertLayoutToCustomLayout: function(layout, layoutParams, parentFrame){
1148
+ // TODO: [EG] Create Top/Left/Width/Height to a Custom Layout conversion
1149
+ }
1150
+ });