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,1338 @@
1
+ // lib/handlebars/parser.js
2
+ /* Jison generated parser */
3
+ var handlebars = (function(){
4
+ var parser = {trace: function trace() { },
5
+ yy: {},
6
+ symbols_: {"error":2,"root":3,"program":4,"EOF":5,"statements":6,"simpleInverse":7,"statement":8,"openInverse":9,"closeBlock":10,"openBlock":11,"mustache":12,"partial":13,"CONTENT":14,"COMMENT":15,"OPEN_BLOCK":16,"inMustache":17,"CLOSE":18,"OPEN_INVERSE":19,"OPEN_ENDBLOCK":20,"path":21,"OPEN":22,"OPEN_UNESCAPED":23,"OPEN_PARTIAL":24,"params":25,"param":26,"STRING":27,"pathSegments":28,"SEP":29,"ID":30,"$accept":0,"$end":1},
7
+ terminals_: {2:"error",5:"EOF",14:"CONTENT",15:"COMMENT",16:"OPEN_BLOCK",18:"CLOSE",19:"OPEN_INVERSE",20:"OPEN_ENDBLOCK",22:"OPEN",23:"OPEN_UNESCAPED",24:"OPEN_PARTIAL",27:"STRING",29:"SEP",30:"ID"},
8
+ productions_: [0,[3,2],[4,3],[4,1],[4,0],[6,1],[6,2],[8,3],[8,3],[8,1],[8,1],[8,1],[8,1],[11,3],[9,3],[10,3],[12,3],[12,3],[13,3],[13,4],[7,2],[17,2],[17,1],[25,2],[25,1],[26,1],[26,1],[21,1],[28,3],[28,1]],
9
+ performAction: function anonymous(yytext,yyleng,yylineno,yy,yystate,$$,_$) {
10
+
11
+ var $0 = $$.length - 1;
12
+ switch (yystate) {
13
+ case 1: return $$[$0-1]
14
+ break;
15
+ case 2: this.$ = new yy.ProgramNode($$[$0-2], $$[$0])
16
+ break;
17
+ case 3: this.$ = new yy.ProgramNode($$[$0])
18
+ break;
19
+ case 4: this.$ = new yy.ProgramNode([])
20
+ break;
21
+ case 5: this.$ = [$$[$0]]
22
+ break;
23
+ case 6: $$[$0-1].push($$[$0]); this.$ = $$[$0-1]
24
+ break;
25
+ case 7: this.$ = new yy.InverseNode($$[$0-2], $$[$0-1], $$[$0])
26
+ break;
27
+ case 8: this.$ = new yy.BlockNode($$[$0-2], $$[$0-1], $$[$0])
28
+ break;
29
+ case 9: this.$ = $$[$0]
30
+ break;
31
+ case 10: this.$ = $$[$0]
32
+ break;
33
+ case 11: this.$ = new yy.ContentNode($$[$0])
34
+ break;
35
+ case 12: this.$ = new yy.CommentNode($$[$0])
36
+ break;
37
+ case 13: this.$ = new yy.MustacheNode($$[$0-1])
38
+ break;
39
+ case 14: this.$ = new yy.MustacheNode($$[$0-1])
40
+ break;
41
+ case 15: this.$ = $$[$0-1]
42
+ break;
43
+ case 16: this.$ = new yy.MustacheNode($$[$0-1])
44
+ break;
45
+ case 17: this.$ = new yy.MustacheNode($$[$0-1], true)
46
+ break;
47
+ case 18: this.$ = new yy.PartialNode($$[$0-1])
48
+ break;
49
+ case 19: this.$ = new yy.PartialNode($$[$0-2], $$[$0-1])
50
+ break;
51
+ case 20:
52
+ break;
53
+ case 21: this.$ = [$$[$0-1]].concat($$[$0])
54
+ break;
55
+ case 22: this.$ = [$$[$0]]
56
+ break;
57
+ case 23: $$[$0-1].push($$[$0]); this.$ = $$[$0-1];
58
+ break;
59
+ case 24: this.$ = [$$[$0]]
60
+ break;
61
+ case 25: this.$ = $$[$0]
62
+ break;
63
+ case 26: this.$ = new yy.StringNode($$[$0])
64
+ break;
65
+ case 27: this.$ = new yy.IdNode($$[$0])
66
+ break;
67
+ case 28: $$[$0-2].push($$[$0]); this.$ = $$[$0-2];
68
+ break;
69
+ case 29: this.$ = [$$[$0]]
70
+ break;
71
+ }
72
+ },
73
+ table: [{3:1,4:2,5:[2,4],6:3,8:4,9:5,11:6,12:7,13:8,14:[1,9],15:[1,10],16:[1,12],19:[1,11],22:[1,13],23:[1,14],24:[1,15]},{1:[3]},{5:[1,16]},{5:[2,3],7:17,8:18,9:5,11:6,12:7,13:8,14:[1,9],15:[1,10],16:[1,12],19:[1,19],20:[2,3],22:[1,13],23:[1,14],24:[1,15]},{5:[2,5],14:[2,5],15:[2,5],16:[2,5],19:[2,5],20:[2,5],22:[2,5],23:[2,5],24:[2,5]},{4:20,6:3,8:4,9:5,11:6,12:7,13:8,14:[1,9],15:[1,10],16:[1,12],19:[1,11],20:[2,4],22:[1,13],23:[1,14],24:[1,15]},{4:21,6:3,8:4,9:5,11:6,12:7,13:8,14:[1,9],15:[1,10],16:[1,12],19:[1,11],20:[2,4],22:[1,13],23:[1,14],24:[1,15]},{5:[2,9],14:[2,9],15:[2,9],16:[2,9],19:[2,9],20:[2,9],22:[2,9],23:[2,9],24:[2,9]},{5:[2,10],14:[2,10],15:[2,10],16:[2,10],19:[2,10],20:[2,10],22:[2,10],23:[2,10],24:[2,10]},{5:[2,11],14:[2,11],15:[2,11],16:[2,11],19:[2,11],20:[2,11],22:[2,11],23:[2,11],24:[2,11]},{5:[2,12],14:[2,12],15:[2,12],16:[2,12],19:[2,12],20:[2,12],22:[2,12],23:[2,12],24:[2,12]},{17:22,21:23,28:24,30:[1,25]},{17:26,21:23,28:24,30:[1,25]},{17:27,21:23,28:24,30:[1,25]},{17:28,21:23,28:24,30:[1,25]},{21:29,28:24,30:[1,25]},{1:[2,1]},{6:30,8:4,9:5,11:6,12:7,13:8,14:[1,9],15:[1,10],16:[1,12],19:[1,11],22:[1,13],23:[1,14],24:[1,15]},{5:[2,6],14:[2,6],15:[2,6],16:[2,6],19:[2,6],20:[2,6],22:[2,6],23:[2,6],24:[2,6]},{17:22,18:[1,31],21:23,28:24,30:[1,25]},{10:32,20:[1,33]},{10:34,20:[1,33]},{18:[1,35]},{18:[2,22],21:38,25:36,26:37,27:[1,39],28:24,30:[1,25]},{18:[2,27],27:[2,27],29:[1,40],30:[2,27]},{18:[2,29],27:[2,29],29:[2,29],30:[2,29]},{18:[1,41]},{18:[1,42]},{18:[1,43]},{18:[1,44],21:45,28:24,30:[1,25]},{5:[2,2],8:18,9:5,11:6,12:7,13:8,14:[1,9],15:[1,10],16:[1,12],19:[1,11],20:[2,2],22:[1,13],23:[1,14],24:[1,15]},{14:[2,20],15:[2,20],16:[2,20],19:[2,20],22:[2,20],23:[2,20],24:[2,20]},{5:[2,7],14:[2,7],15:[2,7],16:[2,7],19:[2,7],20:[2,7],22:[2,7],23:[2,7],24:[2,7]},{21:46,28:24,30:[1,25]},{5:[2,8],14:[2,8],15:[2,8],16:[2,8],19:[2,8],20:[2,8],22:[2,8],23:[2,8],24:[2,8]},{14:[2,14],15:[2,14],16:[2,14],19:[2,14],20:[2,14],22:[2,14],23:[2,14],24:[2,14]},{18:[2,21],21:38,26:47,27:[1,39],28:24,30:[1,25]},{18:[2,24],27:[2,24],30:[2,24]},{18:[2,25],27:[2,25],30:[2,25]},{18:[2,26],27:[2,26],30:[2,26]},{30:[1,48]},{14:[2,13],15:[2,13],16:[2,13],19:[2,13],20:[2,13],22:[2,13],23:[2,13],24:[2,13]},{5:[2,16],14:[2,16],15:[2,16],16:[2,16],19:[2,16],20:[2,16],22:[2,16],23:[2,16],24:[2,16]},{5:[2,17],14:[2,17],15:[2,17],16:[2,17],19:[2,17],20:[2,17],22:[2,17],23:[2,17],24:[2,17]},{5:[2,18],14:[2,18],15:[2,18],16:[2,18],19:[2,18],20:[2,18],22:[2,18],23:[2,18],24:[2,18]},{18:[1,49]},{18:[1,50]},{18:[2,23],27:[2,23],30:[2,23]},{18:[2,28],27:[2,28],29:[2,28],30:[2,28]},{5:[2,19],14:[2,19],15:[2,19],16:[2,19],19:[2,19],20:[2,19],22:[2,19],23:[2,19],24:[2,19]},{5:[2,15],14:[2,15],15:[2,15],16:[2,15],19:[2,15],20:[2,15],22:[2,15],23:[2,15],24:[2,15]}],
74
+ defaultActions: {16:[2,1]},
75
+ parseError: function parseError(str, hash) {
76
+ throw new Error(str);
77
+ },
78
+ parse: function parse(input) {
79
+ var self = this,
80
+ stack = [0],
81
+ vstack = [null], // semantic value stack
82
+ lstack = [], // location stack
83
+ table = this.table,
84
+ yytext = '',
85
+ yylineno = 0,
86
+ yyleng = 0,
87
+ recovering = 0,
88
+ TERROR = 2,
89
+ EOF = 1;
90
+
91
+ //this.reductionCount = this.shiftCount = 0;
92
+
93
+ this.lexer.setInput(input);
94
+ this.lexer.yy = this.yy;
95
+ this.yy.lexer = this.lexer;
96
+ var yyloc = this.lexer.yylloc;
97
+ lstack.push(yyloc);
98
+
99
+ if (typeof this.yy.parseError === 'function')
100
+ this.parseError = this.yy.parseError;
101
+
102
+ function popStack (n) {
103
+ stack.length = stack.length - 2*n;
104
+ vstack.length = vstack.length - n;
105
+ lstack.length = lstack.length - n;
106
+ }
107
+
108
+ function lex() {
109
+ var token;
110
+ token = self.lexer.lex() || 1; // $end = 1
111
+ // if token isn't its numeric value, convert
112
+ if (typeof token !== 'number') {
113
+ token = self.symbols_[token] || token;
114
+ }
115
+ return token;
116
+ };
117
+
118
+ var symbol, preErrorSymbol, state, action, a, r, yyval={},p,len,newState, expected;
119
+ while (true) {
120
+ // retreive state number from top of stack
121
+ state = stack[stack.length-1];
122
+
123
+ // use default actions if available
124
+ if (this.defaultActions[state]) {
125
+ action = this.defaultActions[state];
126
+ } else {
127
+ if (symbol == null)
128
+ symbol = lex();
129
+ // read action for current state and first input
130
+ action = table[state] && table[state][symbol];
131
+ }
132
+
133
+ // handle parse error
134
+ if (typeof action === 'undefined' || !action.length || !action[0]) {
135
+
136
+ if (!recovering) {
137
+ // Report error
138
+ expected = [];
139
+ for (p in table[state]) if (this.terminals_[p] && p > 2) {
140
+ expected.push("'"+this.terminals_[p]+"'");
141
+ }
142
+ var errStr = '';
143
+ if (this.lexer.showPosition) {
144
+ errStr = 'Parse error on line '+(yylineno+1)+":\n"+this.lexer.showPosition()+'\nExpecting '+expected.join(', ');
145
+ } else {
146
+ errStr = 'Parse error on line '+(yylineno+1)+": Unexpected " +
147
+ (symbol == 1 /*EOF*/ ? "end of input" :
148
+ ("'"+(this.terminals_[symbol] || symbol)+"'"));
149
+ }
150
+ this.parseError(errStr,
151
+ {text: this.lexer.match, token: this.terminals_[symbol] || symbol, line: this.lexer.yylineno, loc: yyloc, expected: expected});
152
+ }
153
+
154
+ // just recovered from another error
155
+ if (recovering == 3) {
156
+ if (symbol == EOF) {
157
+ throw new Error(errStr || 'Parsing halted.');
158
+ }
159
+
160
+ // discard current lookahead and grab another
161
+ yyleng = this.lexer.yyleng;
162
+ yytext = this.lexer.yytext;
163
+ yylineno = this.lexer.yylineno;
164
+ yyloc = this.lexer.yylloc;
165
+ symbol = lex();
166
+ }
167
+
168
+ // try to recover from error
169
+ while (1) {
170
+ // check for error recovery rule in this state
171
+ if ((TERROR.toString()) in table[state]) {
172
+ break;
173
+ }
174
+ if (state == 0) {
175
+ throw new Error(errStr || 'Parsing halted.');
176
+ }
177
+ popStack(1);
178
+ state = stack[stack.length-1];
179
+ }
180
+
181
+ preErrorSymbol = symbol; // save the lookahead token
182
+ symbol = TERROR; // insert generic error symbol as new lookahead
183
+ state = stack[stack.length-1];
184
+ action = table[state] && table[state][TERROR];
185
+ recovering = 3; // allow 3 real symbols to be shifted before reporting a new error
186
+ }
187
+
188
+ // this shouldn't happen, unless resolve defaults are off
189
+ if (action[0] instanceof Array && action.length > 1) {
190
+ throw new Error('Parse Error: multiple actions possible at state: '+state+', token: '+symbol);
191
+ }
192
+
193
+ switch (action[0]) {
194
+
195
+ case 1: // shift
196
+ //this.shiftCount++;
197
+
198
+ stack.push(symbol);
199
+ vstack.push(this.lexer.yytext);
200
+ lstack.push(this.lexer.yylloc);
201
+ stack.push(action[1]); // push state
202
+ symbol = null;
203
+ if (!preErrorSymbol) { // normal execution/no error
204
+ yyleng = this.lexer.yyleng;
205
+ yytext = this.lexer.yytext;
206
+ yylineno = this.lexer.yylineno;
207
+ yyloc = this.lexer.yylloc;
208
+ if (recovering > 0)
209
+ recovering--;
210
+ } else { // error just occurred, resume old lookahead f/ before error
211
+ symbol = preErrorSymbol;
212
+ preErrorSymbol = null;
213
+ }
214
+ break;
215
+
216
+ case 2: // reduce
217
+ //this.reductionCount++;
218
+
219
+ len = this.productions_[action[1]][1];
220
+
221
+ // perform semantic action
222
+ yyval.$ = vstack[vstack.length-len]; // default to $$ = $1
223
+ // default location, uses first token for firsts, last for lasts
224
+ yyval._$ = {
225
+ first_line: lstack[lstack.length-(len||1)].first_line,
226
+ last_line: lstack[lstack.length-1].last_line,
227
+ first_column: lstack[lstack.length-(len||1)].first_column,
228
+ last_column: lstack[lstack.length-1].last_column,
229
+ };
230
+ r = this.performAction.call(yyval, yytext, yyleng, yylineno, this.yy, action[1], vstack, lstack);
231
+
232
+ if (typeof r !== 'undefined') {
233
+ return r;
234
+ }
235
+
236
+ // pop off stack
237
+ if (len) {
238
+ stack = stack.slice(0,-1*len*2);
239
+ vstack = vstack.slice(0, -1*len);
240
+ lstack = lstack.slice(0, -1*len);
241
+ }
242
+
243
+ stack.push(this.productions_[action[1]][0]); // push nonterminal (reduce)
244
+ vstack.push(yyval.$);
245
+ lstack.push(yyval._$);
246
+ // goto new state = table[STATE][NONTERMINAL]
247
+ newState = table[stack[stack.length-2]][stack[stack.length-1]];
248
+ stack.push(newState);
249
+ break;
250
+
251
+ case 3: // accept
252
+ return true;
253
+ }
254
+
255
+ }
256
+
257
+ return true;
258
+ }};/* Jison generated lexer */
259
+ var lexer = (function(){var lexer = ({EOF:1,
260
+ parseError:function parseError(str, hash) {
261
+ if (this.yy.parseError) {
262
+ this.yy.parseError(str, hash);
263
+ } else {
264
+ throw new Error(str);
265
+ }
266
+ },
267
+ setInput:function (input) {
268
+ this._input = input;
269
+ this._more = this._less = this.done = false;
270
+ this.yylineno = this.yyleng = 0;
271
+ this.yytext = this.matched = this.match = '';
272
+ this.conditionStack = ['INITIAL'];
273
+ this.yylloc = {first_line:1,first_column:0,last_line:1,last_column:0};
274
+ return this;
275
+ },
276
+ input:function () {
277
+ var ch = this._input[0];
278
+ this.yytext+=ch;
279
+ this.yyleng++;
280
+ this.match+=ch;
281
+ this.matched+=ch;
282
+ var lines = ch.match(/\n/);
283
+ if (lines) this.yylineno++;
284
+ this._input = this._input.slice(1);
285
+ return ch;
286
+ },
287
+ unput:function (ch) {
288
+ this._input = ch + this._input;
289
+ return this;
290
+ },
291
+ more:function () {
292
+ this._more = true;
293
+ return this;
294
+ },
295
+ pastInput:function () {
296
+ var past = this.matched.substr(0, this.matched.length - this.match.length);
297
+ return (past.length > 20 ? '...':'') + past.substr(-20).replace(/\n/g, "");
298
+ },
299
+ upcomingInput:function () {
300
+ var next = this.match;
301
+ if (next.length < 20) {
302
+ next += this._input.substr(0, 20-next.length);
303
+ }
304
+ return (next.substr(0,20)+(next.length > 20 ? '...':'')).replace(/\n/g, "");
305
+ },
306
+ showPosition:function () {
307
+ var pre = this.pastInput();
308
+ var c = new Array(pre.length + 1).join("-");
309
+ return pre + this.upcomingInput() + "\n" + c+"^";
310
+ },
311
+ next:function () {
312
+ if (this.done) {
313
+ return this.EOF;
314
+ }
315
+ if (!this._input) this.done = true;
316
+
317
+ var token,
318
+ match,
319
+ col,
320
+ lines;
321
+ if (!this._more) {
322
+ this.yytext = '';
323
+ this.match = '';
324
+ }
325
+ var rules = this._currentRules();
326
+ for (var i=0;i < rules.length; i++) {
327
+ match = this._input.match(this.rules[rules[i]]);
328
+ if (match) {
329
+ lines = match[0].match(/\n.*/g);
330
+ if (lines) this.yylineno += lines.length;
331
+ this.yylloc = {first_line: this.yylloc.last_line,
332
+ last_line: this.yylineno+1,
333
+ first_column: this.yylloc.last_column,
334
+ last_column: lines ? lines[lines.length-1].length-1 : this.yylloc.last_column + match.length}
335
+ this.yytext += match[0];
336
+ this.match += match[0];
337
+ this.matches = match;
338
+ this.yyleng = this.yytext.length;
339
+ this._more = false;
340
+ this._input = this._input.slice(match[0].length);
341
+ this.matched += match[0];
342
+ token = this.performAction.call(this, this.yy, this, rules[i],this.conditionStack[this.conditionStack.length-1]);
343
+ if (token) return token;
344
+ else return;
345
+ }
346
+ }
347
+ if (this._input === "") {
348
+ return this.EOF;
349
+ } else {
350
+ this.parseError('Lexical error on line '+(this.yylineno+1)+'. Unrecognized text.\n'+this.showPosition(),
351
+ {text: "", token: null, line: this.yylineno});
352
+ }
353
+ },
354
+ lex:function lex() {
355
+ var r = this.next();
356
+ if (typeof r !== 'undefined') {
357
+ return r;
358
+ } else {
359
+ return this.lex();
360
+ }
361
+ },
362
+ begin:function begin(condition) {
363
+ this.conditionStack.push(condition);
364
+ },
365
+ popState:function popState() {
366
+ return this.conditionStack.pop();
367
+ },
368
+ _currentRules:function _currentRules() {
369
+ return this.conditions[this.conditionStack[this.conditionStack.length-1]].rules;
370
+ }});
371
+ lexer.performAction = function anonymous(yy,yy_,$avoiding_name_collisions,YY_START) {
372
+
373
+ var YYSTATE=YY_START
374
+ switch($avoiding_name_collisions) {
375
+ case 0: this.begin("mu"); if (yy_.yytext) return 14;
376
+ break;
377
+ case 1: return 14;
378
+ break;
379
+ case 2: return 24;
380
+ break;
381
+ case 3: return 16;
382
+ break;
383
+ case 4: return 20;
384
+ break;
385
+ case 5: return 19;
386
+ break;
387
+ case 6: return 19;
388
+ break;
389
+ case 7: return 23;
390
+ break;
391
+ case 8: return 23;
392
+ break;
393
+ case 9: yy_.yytext = yy_.yytext.substr(3,yy_.yyleng-5); this.begin("INITIAL"); return 15;
394
+ break;
395
+ case 10: return 22;
396
+ break;
397
+ case 11: return 29;
398
+ break;
399
+ case 12: /*ignore whitespace*/
400
+ break;
401
+ case 13: this.begin("INITIAL"); return 18;
402
+ break;
403
+ case 14: this.begin("INITIAL"); return 18;
404
+ break;
405
+ case 15: yy_.yytext = yy_.yytext.substr(1,yy_.yyleng-2).replace(/\\"/g,'"'); return 27;
406
+ break;
407
+ case 16: return 30;
408
+ break;
409
+ case 17: return 'INVALID';
410
+ break;
411
+ case 18: return 5;
412
+ break;
413
+ }
414
+ };
415
+ lexer.rules = [/^[^\x00]*?(?=(\{\{))/,/^[^\x00]+/,/^\{\{>/,/^\{\{#/,/^\{\{\//,/^\{\{\^/,/^\{\{\s*else\b/,/^\{\{\{/,/^\{\{&/,/^\{\{!.*?\}\}/,/^\{\{/,/^\//,/^\s+/,/^\}\}\}/,/^\}\}/,/^"(\\["]|[^"])*"/,/^[a-zA-Z0-9_.]+(?=[} /])/,/^./,/^$/];
416
+ lexer.conditions = {"mu":{"rules":[2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18],"inclusive":false},"INITIAL":{"rules":[0,1,18],"inclusive":true}};return lexer;})()
417
+ parser.lexer = lexer;
418
+ return parser;
419
+ })();
420
+ // lib/handlebars/base.js
421
+ window.Handlebars = {};
422
+
423
+ Handlebars.Parser = handlebars;
424
+
425
+ Handlebars.parse = function(string) {
426
+ Handlebars.Parser.yy = Handlebars.AST;
427
+ return Handlebars.Parser.parse(string);
428
+ };
429
+
430
+ Handlebars.print = function(ast) {
431
+ return new Handlebars.PrintVisitor().accept(ast);
432
+ };
433
+
434
+ Handlebars.Runtime = {};
435
+
436
+ Handlebars.Runtime.compile = function(string) {
437
+ var ast = Handlebars.parse(string);
438
+
439
+ return function(context, helpers, partials) {
440
+ helpers = helpers || Handlebars.helpers;
441
+ partials = partials || Handlebars.partials;
442
+
443
+ var internalContext = new Handlebars.Context(context, helpers, partials);
444
+ var runtime = new Handlebars.Runtime(internalContext);
445
+ runtime.accept(ast);
446
+ return runtime.buffer;
447
+ };
448
+ };
449
+
450
+ Handlebars.helpers = {};
451
+ Handlebars.partials = {};
452
+
453
+ Handlebars.registerHelper = function(name, fn, inverse) {
454
+ if(inverse) { fn.not = inverse; }
455
+ this.helpers[name] = fn;
456
+ };
457
+
458
+ Handlebars.registerPartial = function(name, str) {
459
+ this.partials[name] = str;
460
+ };
461
+
462
+ Handlebars.registerHelper('blockHelperMissing', function(context, fn, inverse) {
463
+ inverse = inverse || function() {};
464
+
465
+ var ret = "";
466
+ var type = Object.prototype.toString.call(context);
467
+
468
+ if(type === "[object Function]") {
469
+ context = context();
470
+ }
471
+
472
+ if(context === true) {
473
+ return fn(this);
474
+ } else if(context === false || context == null) {
475
+ return inverse(this);
476
+ } else if(type === "[object Array]") {
477
+ if(context.length > 0) {
478
+ for(var i=0, j=context.length; i<j; i++) {
479
+ ret = ret + fn(context[i]);
480
+ }
481
+ } else {
482
+ ret = inverse(this);
483
+ }
484
+ return ret;
485
+ } else {
486
+ return fn(context);
487
+ }
488
+ }, function(context, fn) {
489
+ return fn(context);
490
+ });
491
+
492
+ Handlebars.registerHelper('each', function(context, fn, inverse) {
493
+ var ret = "";
494
+
495
+ if(context && context.length > 0) {
496
+ for(var i=0, j=context.length; i<j; i++) {
497
+ ret = ret + fn(context[i]);
498
+ }
499
+ } else {
500
+ ret = inverse(this);
501
+ }
502
+ return ret;
503
+ });
504
+
505
+ Handlebars.registerHelper('if', function(context, fn, inverse) {
506
+ if(!context || context == []) {
507
+ return inverse(this);
508
+ } else {
509
+ return fn(this);
510
+ }
511
+ });
512
+
513
+ Handlebars.registerHelper('unless', function(context, fn, inverse) {
514
+ Handlebars.helpers['if'].call(this, context, inverse, fn);
515
+ });
516
+
517
+ Handlebars.registerHelper('with', function(context, fn) {
518
+ return fn(context);
519
+ });
520
+
521
+ Handlebars.logger = {
522
+ DEBUG: 0, INFO: 1, WARN: 2, ERROR: 3, level: 3,
523
+
524
+ // override in the host environment
525
+ log: function(level, str) {}
526
+ };
527
+
528
+ Handlebars.log = function(level, str) { Handlebars.logger.log(level, str); };
529
+ ;
530
+ // lib/handlebars/ast.js
531
+ (function() {
532
+
533
+ Handlebars.AST = {};
534
+
535
+ Handlebars.AST.ProgramNode = function(statements, inverse) {
536
+ this.type = "program";
537
+ this.statements = statements;
538
+ if(inverse) { this.inverse = new Handlebars.AST.ProgramNode(inverse); }
539
+ };
540
+
541
+ Handlebars.AST.MustacheNode = function(params, unescaped) {
542
+ this.type = "mustache";
543
+ this.id = params[0];
544
+ this.params = params.slice(1);
545
+ this.escaped = !unescaped;
546
+ };
547
+
548
+ Handlebars.AST.PartialNode = function(id, context) {
549
+ this.type = "partial";
550
+
551
+ // TODO: disallow complex IDs
552
+
553
+ this.id = id;
554
+ this.context = context;
555
+ };
556
+
557
+ var verifyMatch = function(open, close) {
558
+ if(open.original !== close.original) {
559
+ throw new Handlebars.Exception(open.original + " doesn't match " + close.original);
560
+ }
561
+ };
562
+
563
+ Handlebars.AST.BlockNode = function(mustache, program, close) {
564
+ verifyMatch(mustache.id, close);
565
+ this.type = "block";
566
+ this.mustache = mustache;
567
+ this.program = program;
568
+ };
569
+
570
+ Handlebars.AST.InverseNode = function(mustache, program, close) {
571
+ verifyMatch(mustache.id, close);
572
+ this.type = "inverse";
573
+ this.mustache = mustache;
574
+ this.program = program;
575
+ };
576
+
577
+ Handlebars.AST.ContentNode = function(string) {
578
+ this.type = "content";
579
+ this.string = string;
580
+ };
581
+
582
+ Handlebars.AST.IdNode = function(parts) {
583
+ this.type = "ID";
584
+ this.original = parts.join("/");
585
+
586
+ var dig = [], depth = 0;
587
+
588
+ for(var i=0,l=parts.length; i<l; i++) {
589
+ var part = parts[i];
590
+
591
+ if(part === "..") { depth++; }
592
+ else if(part === "." || part === "this") { continue; }
593
+ else { dig.push(part); }
594
+ }
595
+
596
+ this.parts = dig;
597
+ this.depth = depth;
598
+ this.isSimple = (dig.length === 1) && (depth === 0);
599
+ };
600
+
601
+ Handlebars.AST.StringNode = function(string) {
602
+ this.type = "STRING";
603
+ this.string = string;
604
+ };
605
+
606
+ Handlebars.AST.CommentNode = function(comment) {
607
+ this.type = "comment";
608
+ this.comment = comment;
609
+ };
610
+
611
+ })();;
612
+ // lib/handlebars/visitor.js
613
+
614
+ Handlebars.Visitor = function() {};
615
+
616
+ Handlebars.Visitor.prototype = {
617
+ accept: function(object) {
618
+ return this[object.type](object);
619
+ }
620
+ };;
621
+ // lib/handlebars/utils.js
622
+ Handlebars.Exception = function(message) {
623
+ this.message = message;
624
+ };
625
+
626
+ // Build out our basic SafeString type
627
+ Handlebars.SafeString = function(string) {
628
+ this.string = string;
629
+ };
630
+ Handlebars.SafeString.prototype.toString = function() {
631
+ return this.string.toString();
632
+ };
633
+
634
+ (function() {
635
+ var escape = {
636
+ "<": "&lt;",
637
+ ">": "&gt;"
638
+ };
639
+
640
+ var badChars = /&(?!\w+;)|[<>]/g;
641
+ var possible = /[&<>]/
642
+
643
+ var escapeChar = function(chr) {
644
+ return escape[chr] || "&amp;"
645
+ };
646
+
647
+ Handlebars.Utils = {
648
+ escapeExpression: function(string) {
649
+ // don't escape SafeStrings, since they're already safe
650
+ if (string instanceof Handlebars.SafeString) {
651
+ return string.toString();
652
+ } else if (string == null || string === false) {
653
+ return "";
654
+ }
655
+
656
+ if(!possible.test(string)) { return string; }
657
+ return string.replace(badChars, escapeChar);
658
+ },
659
+
660
+ isEmpty: function(value) {
661
+ if (typeof value === "undefined") {
662
+ return true;
663
+ } else if (value === null) {
664
+ return true;
665
+ } else if (value === false) {
666
+ return true;
667
+ } else if(Object.prototype.toString.call(value) === "[object Array]" && value.length === 0) {
668
+ return true;
669
+ } else {
670
+ return false;
671
+ }
672
+ }
673
+ };
674
+ })();;
675
+ // lib/handlebars/vm.js
676
+ Handlebars.Compiler = function() {};
677
+ Handlebars.JavaScriptCompiler = function() {};
678
+
679
+ (function(Compiler, JavaScriptCompiler) {
680
+ Compiler.OPCODE_MAP = {
681
+ appendContent: 1,
682
+ getContext: 2,
683
+ lookupWithHelpers: 3,
684
+ lookup: 4,
685
+ append: 5,
686
+ invokeMustache: 6,
687
+ appendEscaped: 7,
688
+ pushString: 8,
689
+ truthyOrFallback: 9,
690
+ functionOrFallback: 10,
691
+ invokeProgram: 11,
692
+ invokePartial: 12,
693
+ push: 13,
694
+ invokeInverse: 14
695
+ };
696
+
697
+ Compiler.MULTI_PARAM_OPCODES = {
698
+ appendContent: 1,
699
+ getContext: 1,
700
+ lookupWithHelpers: 1,
701
+ lookup: 1,
702
+ invokeMustache: 2,
703
+ pushString: 1,
704
+ truthyOrFallback: 1,
705
+ functionOrFallback: 1,
706
+ invokeProgram: 2,
707
+ invokePartial: 1,
708
+ push: 1,
709
+ invokeInverse: 1
710
+ };
711
+
712
+ Compiler.DISASSEMBLE_MAP = {};
713
+
714
+ for(var prop in Compiler.OPCODE_MAP) {
715
+ var value = Compiler.OPCODE_MAP[prop];
716
+ Compiler.DISASSEMBLE_MAP[value] = prop;
717
+ }
718
+
719
+ Compiler.multiParamSize = function(code) {
720
+ return Compiler.MULTI_PARAM_OPCODES[Compiler.DISASSEMBLE_MAP[code]];
721
+ };
722
+
723
+ Compiler.prototype = {
724
+ disassemble: function() {
725
+ var opcodes = this.opcodes, opcode, nextCode;
726
+ var out = [], str, name, value;
727
+
728
+ for(var i=0, l=opcodes.length; i<l; i++) {
729
+ opcode = opcodes[i];
730
+
731
+ if(opcode === 'DECLARE') {
732
+ name = opcodes[++i];
733
+ value = opcodes[++i];
734
+ out.push("DECLARE " + name + " = " + value);
735
+ } else {
736
+ str = Compiler.DISASSEMBLE_MAP[opcode];
737
+
738
+ var extraParams = Compiler.multiParamSize(opcode);
739
+ var codes = [];
740
+
741
+ for(var j=0; j<extraParams; j++) {
742
+ nextCode = opcodes[++i];
743
+
744
+ if(typeof nextCode === "string") {
745
+ nextCode = "\"" + nextCode.replace("\n", "\\n") + "\"";
746
+ }
747
+
748
+ codes.push(nextCode);
749
+ }
750
+
751
+ str = str + " " + codes.join(" ");
752
+
753
+ out.push(str);
754
+ }
755
+ }
756
+
757
+ return out.join("\n");
758
+ },
759
+
760
+ guid: 0,
761
+
762
+ compile: function(program) {
763
+ this.children = [];
764
+ this.depths = {list: []};
765
+ return this.program(program);
766
+ },
767
+
768
+ accept: function(node) {
769
+ return this[node.type](node);
770
+ },
771
+
772
+ program: function(program) {
773
+ var statements = program.statements, statement;
774
+ this.opcodes = [];
775
+
776
+ for(var i=0, l=statements.length; i<l; i++) {
777
+ statement = statements[i];
778
+ this[statement.type](statement);
779
+ }
780
+
781
+ this.depths.list = this.depths.list.sort(function(a, b) {
782
+ return a - b;
783
+ });
784
+
785
+ return this;
786
+ },
787
+
788
+ compileProgram: function(program) {
789
+ var result = new Compiler().compile(program);
790
+ var guid = this.guid++;
791
+
792
+ this.usePartial = this.usePartial || result.usePartial;
793
+
794
+ this.children[guid] = result;
795
+
796
+ for(var i=0, l=result.depths.list.length; i<l; i++) {
797
+ depth = result.depths.list[i];
798
+
799
+ if(depth < 2) { continue; }
800
+ else { this.addDepth(depth - 1); }
801
+ }
802
+
803
+ return guid;
804
+ },
805
+
806
+ block: function(block) {
807
+ var mustache = block.mustache;
808
+ var params = mustache.params, depth, child, inverse, inverseGuid;
809
+
810
+ this.pushParams(params);
811
+
812
+ // ID lookup is now on the stack
813
+ this.ID(mustache.id);
814
+
815
+ var programGuid = this.compileProgram(block.program);
816
+
817
+ if(block.program.inverse) {
818
+ inverseGuid = this.compileProgram(block.program.inverse);
819
+ }
820
+
821
+ if(block.program.inverse) {
822
+ this.declare('inverse', inverseGuid);
823
+ }
824
+
825
+ this.opcode('invokeProgram', programGuid, params.length);
826
+ this.declare('inverse', null);
827
+ this.opcode('append');
828
+ },
829
+
830
+ inverse: function(block) {
831
+ this.ID(block.mustache.id);
832
+ var programGuid = this.compileProgram(block.program);
833
+
834
+ this.opcode('invokeInverse', programGuid);
835
+ this.opcode('append');
836
+ },
837
+
838
+ partial: function(partial) {
839
+ var id = partial.id;
840
+ this.usePartial = true;
841
+
842
+ if(partial.context) {
843
+ this.ID(partial.context);
844
+ } else {
845
+ this.opcode('push', 'context');
846
+ }
847
+
848
+ this.opcode('invokePartial', id.original);
849
+ this.opcode('append');
850
+ },
851
+
852
+ content: function(content) {
853
+ this.opcode('appendContent', content.string);
854
+ },
855
+
856
+ mustache: function(mustache) {
857
+ var params = mustache.params;
858
+
859
+ this.pushParams(params);
860
+ this.ID(mustache.id);
861
+
862
+ this.opcode('invokeMustache', params.length, mustache.id.original);
863
+
864
+ if(mustache.escaped) {
865
+ this.opcode('appendEscaped');
866
+ } else {
867
+ this.opcode('append');
868
+ }
869
+ },
870
+
871
+ ID: function(id) {
872
+ this.addDepth(id.depth);
873
+
874
+ this.opcode('getContext', id.depth);
875
+
876
+ this.opcode('lookupWithHelpers', id.parts[0] || null);
877
+
878
+ for(var i=1, l=id.parts.length; i<l; i++) {
879
+ this.opcode('lookup', id.parts[i]);
880
+ }
881
+ },
882
+
883
+ STRING: function(string) {
884
+ this.opcode('pushString', string.string);
885
+ },
886
+
887
+ comment: function() {},
888
+
889
+ pushParams: function(params) {
890
+ var i = params.length, param;
891
+
892
+ while(i--) {
893
+ param = params[i];
894
+ this[param.type](param);
895
+ }
896
+ },
897
+
898
+ opcode: function(name, val1, val2) {
899
+ this.opcodes.push(Compiler.OPCODE_MAP[name]);
900
+ if(val1 !== undefined) { this.opcodes.push(val1); }
901
+ if(val2 !== undefined) { this.opcodes.push(val2); }
902
+ },
903
+
904
+ declare: function(name, value) {
905
+ this.opcodes.push('DECLARE');
906
+ this.opcodes.push(name);
907
+ this.opcodes.push(value);
908
+ },
909
+
910
+ addDepth: function(depth) {
911
+ if(depth === 0) { return; }
912
+
913
+ if(!this.depths[depth]) {
914
+ this.depths[depth] = true;
915
+ this.depths.list.push(depth);
916
+ }
917
+ }
918
+ };
919
+
920
+ JavaScriptCompiler.prototype = {
921
+ // PUBLIC API: You can override these methods in a subclass to provide
922
+ // alternative compiled forms for name lookup and buffering semantics
923
+ nameLookup: function(parent, name, type) {
924
+ if(JavaScriptCompiler.RESERVED_WORDS[name]) {
925
+ return parent + "['" + name + "']";
926
+ } else {
927
+ return parent + "." + name;
928
+ }
929
+ },
930
+
931
+ appendToBuffer: function(string) {
932
+ return "buffer = buffer + " + string + ";";
933
+ },
934
+
935
+ initializeBuffer: function() {
936
+ return this.quotedString("");
937
+ },
938
+ // END PUBLIC API
939
+
940
+ compile: function(environment, data) {
941
+ this.environment = environment;
942
+ this.data = data;
943
+
944
+ this.preamble();
945
+
946
+ this.stackSlot = 0;
947
+ this.stackVars = [];
948
+ this.registers = {list: []};
949
+
950
+ this.compileChildren(environment, data);
951
+
952
+ Handlebars.log(Handlebars.logger.DEBUG, environment.disassemble() + "\n\n");
953
+
954
+ var opcodes = environment.opcodes, opcode, name, declareName, declareVal;
955
+
956
+ this.i = 0;
957
+
958
+ for(l=opcodes.length; this.i<l; this.i++) {
959
+ opcode = this.nextOpcode(0);
960
+
961
+ if(opcode[0] === 'DECLARE') {
962
+ this.i = this.i + 2;
963
+ this[opcode[1]] = opcode[2];
964
+ } else {
965
+ this.i = this.i + opcode[1].length;
966
+ this[opcode[0]].apply(this, opcode[1]);
967
+ }
968
+ }
969
+
970
+ return this.createFunction();
971
+ },
972
+
973
+ nextOpcode: function(n) {
974
+ var opcodes = this.environment.opcodes, opcode = opcodes[this.i + n], name, val;
975
+ var extraParams, codes;
976
+
977
+ if(opcode === 'DECLARE') {
978
+ name = opcodes[this.i + 1];
979
+ val = opcodes[this.i + 2];
980
+ return ['DECLARE', name, val];
981
+ } else {
982
+ name = Compiler.DISASSEMBLE_MAP[opcode];
983
+
984
+ extraParams = Compiler.multiParamSize(opcode);
985
+ codes = [];
986
+
987
+ for(var j=0; j<extraParams; j++) {
988
+ codes.push(opcodes[this.i + j + 1 + n]);
989
+ }
990
+
991
+ return [name, codes];
992
+ }
993
+ },
994
+
995
+ eat: function(opcode) {
996
+ this.i = this.i + opcode.length;
997
+ },
998
+
999
+ preamble: function() {
1000
+ var out = [];
1001
+ out.push("var buffer = " + this.initializeBuffer() + ", currentContext = context");
1002
+
1003
+ var copies = "helpers = helpers || Handlebars.helpers;";
1004
+ if(this.environment.usePartial) { copies = copies + " partials = partials || Handlebars.partials;"; }
1005
+ out.push(copies);
1006
+
1007
+ // track the last context pushed into place to allow skipping the
1008
+ // getContext opcode when it would be a noop
1009
+ this.lastContext = 0;
1010
+ this.source = out;
1011
+ },
1012
+
1013
+ createFunction: function() {
1014
+ var container = {
1015
+ escapeExpression: Handlebars.Utils.escapeExpression,
1016
+ invokePartial: Handlebars.VM.invokePartial,
1017
+ programs: [],
1018
+ program: function(i, helpers, partials, data) {
1019
+ var programWrapper = this.programs[i];
1020
+ if(data) {
1021
+ return Handlebars.VM.program(this.children[i], helpers, partials, data);
1022
+ } else if(programWrapper) {
1023
+ return programWrapper;
1024
+ } else {
1025
+ programWrapper = this.programs[i] = Handlebars.VM.program(this.children[i], helpers, partials);
1026
+ return programWrapper;
1027
+ }
1028
+ },
1029
+ programWithDepth: Handlebars.VM.programWithDepth,
1030
+ noop: Handlebars.VM.noop
1031
+ };
1032
+ var locals = this.stackVars.concat(this.registers.list);
1033
+
1034
+ if(locals.length > 0) {
1035
+ this.source[0] = this.source[0] + ", " + locals.join(", ");
1036
+ }
1037
+
1038
+ this.source[0] = this.source[0] + ";";
1039
+
1040
+ this.source.push("return buffer;");
1041
+
1042
+ var params = ["Handlebars", "context", "helpers", "partials"];
1043
+
1044
+ if(this.data) { params.push("data"); }
1045
+
1046
+ for(var i=0, l=this.environment.depths.list.length; i<l; i++) {
1047
+ params.push("depth" + this.environment.depths.list[i]);
1048
+ }
1049
+
1050
+
1051
+ if(params.length === 4 && !this.environment.usePartial) { params.pop(); }
1052
+
1053
+ params.push(this.source.join("\n"));
1054
+
1055
+ var fn = Function.apply(this, params);
1056
+ fn.displayName = "Handlebars.js";
1057
+
1058
+ Handlebars.log(Handlebars.logger.DEBUG, fn.toString() + "\n\n");
1059
+
1060
+ container.render = fn;
1061
+
1062
+ container.children = this.environment.children;
1063
+
1064
+ return function(context, helpers, partials, data, $depth) {
1065
+ try {
1066
+ var args = Array.prototype.slice.call(arguments);
1067
+ args.unshift(Handlebars);
1068
+ return container.render.apply(container, args);
1069
+ } catch(e) {
1070
+ throw e;
1071
+ }
1072
+ };
1073
+ },
1074
+
1075
+ appendContent: function(content) {
1076
+ this.source.push(this.appendToBuffer(this.quotedString(content)));
1077
+ },
1078
+
1079
+ append: function() {
1080
+ var local = this.popStack();
1081
+ this.source.push("if(" + local + " || " + local + " === 0) { " + this.appendToBuffer(local) + " }");
1082
+ },
1083
+
1084
+ appendEscaped: function() {
1085
+ var opcode = this.nextOpcode(1), extra = "";
1086
+
1087
+ if(opcode[0] === 'appendContent') {
1088
+ extra = " + " + this.quotedString(opcode[1][0]);
1089
+ this.eat(opcode);
1090
+ }
1091
+
1092
+ this.source.push(this.appendToBuffer("this.escapeExpression(" + this.popStack() + ")" + extra));
1093
+ },
1094
+
1095
+ getContext: function(depth) {
1096
+ if(this.lastContext !== depth) {
1097
+ this.lastContext = depth;
1098
+
1099
+ if(depth === 0) {
1100
+ this.source.push("currentContext = context;");
1101
+ } else {
1102
+ this.source.push("currentContext = depth" + depth + ";");
1103
+ }
1104
+ }
1105
+ },
1106
+
1107
+ lookupWithHelpers: function(name) {
1108
+ if(name) {
1109
+ var topStack = this.nextStack();
1110
+
1111
+ var toPush = "if('" + name + "' in helpers) { " + topStack +
1112
+ " = " + this.nameLookup('helpers', name, 'helper') +
1113
+ "; } else { " + topStack + " = " +
1114
+ this.nameLookup('currentContext', name, 'context') +
1115
+ "; }";
1116
+
1117
+ this.source.push(toPush);
1118
+ } else {
1119
+ this.pushStack("currentContext");
1120
+ }
1121
+ },
1122
+
1123
+ lookup: function(name) {
1124
+ var topStack = this.topStack();
1125
+ this.source.push(topStack + " = " + this.nameLookup(topStack, name, 'context') + ";");
1126
+ },
1127
+
1128
+ pushString: function(string) {
1129
+ this.pushStack(this.quotedString(string));
1130
+ },
1131
+
1132
+ push: function(name) {
1133
+ this.pushStack(name);
1134
+ },
1135
+
1136
+ invokeMustache: function(paramSize, original) {
1137
+ var params = ["context"], fn, slot;
1138
+
1139
+ fn = this.popStack();
1140
+
1141
+ for(var i=0; i<paramSize; i++) {
1142
+ params.push(this.popStack());
1143
+ }
1144
+
1145
+ if(this.data) { params.push("data"); }
1146
+
1147
+ var paramString = params.join(", ");
1148
+ var helperMissing = ["context"].concat(this.quotedString(original)).concat(params.slice(1));
1149
+
1150
+ slot = this.nextStack();
1151
+
1152
+ if(paramSize === 0) {
1153
+ // TODO: This case is not listed in the mustache spec. Is it important?
1154
+ this.source.push("if(typeof " + fn + " === 'function') { " + slot + " = " + fn + ".call(" + paramString + "); }");
1155
+ } else {
1156
+ this.source.push("if(typeof " + fn + " === 'function') { " + slot + " = " + fn + ".call(" + paramString + "); } else { " + slot + " = helpers.helperMissing.call(" + helperMissing + ") }");
1157
+ }
1158
+ },
1159
+
1160
+ invokeProgram: function(guid, paramSize) {
1161
+ var inverse = this.programExpression(this.inverse);
1162
+
1163
+ var fn = this.popStack();
1164
+ var id = fn;
1165
+
1166
+ var params = ["context"];
1167
+ var blockMissingParams = ["context", id];
1168
+
1169
+ for(var i=0; i<paramSize; i++) {
1170
+ var param = this.popStack();
1171
+ params.push(param);
1172
+ blockMissingParams.push(param);
1173
+ }
1174
+
1175
+ var mainProgram = this.programExpression(guid);
1176
+
1177
+ params.push(mainProgram, inverse);
1178
+ blockMissingParams.push(mainProgram, inverse);
1179
+
1180
+ if(this.data) {
1181
+ params.push("data");
1182
+ blockMissingParams.push("data");
1183
+ }
1184
+
1185
+ var nextStack = this.nextStack();
1186
+
1187
+ this.source.push("if(typeof " + id + " === 'function') { " + nextStack + " = " + id + ".call(" + params.join(", ") + "); }");
1188
+ this.source.push("else { " + nextStack + " = helpers.blockHelperMissing.call(" + blockMissingParams.join(", ") + "); }");
1189
+ },
1190
+
1191
+ invokeInverse: function(guid) {
1192
+ var program = this.programExpression(guid);
1193
+
1194
+ var blockMissingParams = ["context", this.topStack(), "this.noop", program];
1195
+ this.pushStack("helpers.blockHelperMissing.call(" + blockMissingParams.join(", ") + ")");
1196
+ },
1197
+
1198
+ invokePartial: function(context) {
1199
+ this.pushStack("this.invokePartial(" + this.nameLookup('partials', context, 'partial') + ", '" + context + "', " + this.popStack() + ", helpers, partials);");
1200
+ },
1201
+
1202
+ // HELPERS
1203
+
1204
+ compiler: JavaScriptCompiler,
1205
+
1206
+ compileChildren: function(environment, data) {
1207
+ var children = environment.children, child, compiler;
1208
+ var compiled = [];
1209
+
1210
+ for(var i=0, l=children.length; i<l; i++) {
1211
+ child = children[i];
1212
+ compiler = new this.compiler();
1213
+
1214
+ compiled[i] = compiler.compile(child, data);
1215
+ }
1216
+
1217
+ environment.rawChildren = children;
1218
+ environment.children = compiled;
1219
+ },
1220
+
1221
+ programExpression: function(guid) {
1222
+ if(guid == null) { return "this.noop"; }
1223
+
1224
+ var programParams = [guid, "helpers", "partials"];
1225
+
1226
+ var depths = this.environment.rawChildren[guid].depths.list;
1227
+
1228
+ if(this.data) { programParams.push("data"); }
1229
+
1230
+ for(var i=0, l = depths.length; i<l; i++) {
1231
+ depth = depths[i];
1232
+
1233
+ if(depth === 1) { programParams.push("context"); }
1234
+ else { programParams.push("depth" + (depth - 1)); }
1235
+ }
1236
+
1237
+ if(!this.environment.usePartial) {
1238
+ if(programParams[3]) {
1239
+ programParams[2] = "null";
1240
+ } else {
1241
+ programParams.pop();
1242
+ }
1243
+ }
1244
+
1245
+ if(depths.length === 0) {
1246
+ return "this.program(" + programParams.join(", ") + ")";
1247
+ } else {
1248
+ programParams[0] = "this.children[" + guid + "]";
1249
+ return "this.programWithDepth(" + programParams.join(", ") + ")";
1250
+ }
1251
+ },
1252
+
1253
+ register: function(name, val) {
1254
+ this.useRegister(name);
1255
+ this.source.push(name + " = " + val + ";");
1256
+ },
1257
+
1258
+ useRegister: function(name) {
1259
+ if(!this.registers[name]) {
1260
+ this.registers[name] = true;
1261
+ this.registers.list.push(name);
1262
+ }
1263
+ },
1264
+
1265
+ pushStack: function(item) {
1266
+ this.source.push(this.nextStack() + " = " + item + ";");
1267
+ return "stack" + this.stackSlot;
1268
+ },
1269
+
1270
+ nextStack: function() {
1271
+ this.stackSlot++;
1272
+ if(this.stackSlot > this.stackVars.length) { this.stackVars.push("stack" + this.stackSlot); }
1273
+ return "stack" + this.stackSlot;
1274
+ },
1275
+
1276
+ popStack: function() {
1277
+ return "stack" + this.stackSlot--;
1278
+ },
1279
+
1280
+ topStack: function() {
1281
+ return "stack" + this.stackSlot;
1282
+ },
1283
+
1284
+ quotedString: function(str) {
1285
+ return '"' + str
1286
+ .replace(/\\/, '\\\\')
1287
+ .replace(/"/g, '\\"')
1288
+ .replace(/\n/g, '\\n')
1289
+ .replace(/\r/g, '\\r') + '"';
1290
+ }
1291
+ };
1292
+
1293
+ var reservedWords = ("break case catch continue default delete do else finally " +
1294
+ "for function if in instanceof new return switch this throw " +
1295
+ "try typeof var void while with null true false").split(" ");
1296
+
1297
+ compilerWords = JavaScriptCompiler.RESERVED_WORDS = {};
1298
+
1299
+ for(var i=0, l=reservedWords.length; i<l; i++) {
1300
+ compilerWords[reservedWords[i]] = true;
1301
+ }
1302
+
1303
+ })(Handlebars.Compiler, Handlebars.JavaScriptCompiler);
1304
+
1305
+ Handlebars.VM = {
1306
+ programWithDepth: function(fn) {
1307
+ var args = Array.prototype.slice.call(arguments, 1);
1308
+ return function(context, helpers, partials, data) {
1309
+ args[0] = helpers || args[0];
1310
+ args[1] = partials || args[1];
1311
+ args[2] = data || args[2];
1312
+ return fn.apply(this, [context].concat(args));
1313
+ };
1314
+ },
1315
+ program: function(fn, helpers, partials, data) {
1316
+ return function(context, h2, p2, d2) {
1317
+ return fn(context, h2 || helpers, p2 || partials, d2 || data);
1318
+ };
1319
+ },
1320
+ noop: function() { return ""; },
1321
+ compile: function(string, data) {
1322
+ var ast = Handlebars.parse(string);
1323
+ var environment = new Handlebars.Compiler().compile(ast);
1324
+ return new Handlebars.JavaScriptCompiler().compile(environment, data);
1325
+ },
1326
+ invokePartial: function(partial, name, context, helpers, partials) {
1327
+ if(partial === undefined) {
1328
+ throw new Handlebars.Exception("The partial " + name + " could not be found");
1329
+ } else if(partial instanceof Function) {
1330
+ return partial(context, helpers, partials);
1331
+ } else {
1332
+ partials[name] = Handlebars.VM.compile(partial);
1333
+ return partials[name](context, helpers, partials);
1334
+ }
1335
+ }
1336
+ };
1337
+
1338
+ Handlebars.compile = Handlebars.VM.compile;;