opal 0.0.1 → 0.1.0

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 (306) hide show
  1. data/.gitignore +10 -1
  2. data/.gitmodules +0 -0
  3. data/Opalfile +371 -0
  4. data/README.md +45 -0
  5. data/Rakefile +237 -34
  6. data/VERSION +1 -1
  7. data/bin/opal +13 -0
  8. data/demos/apps/browser_demo/index.html +11 -0
  9. data/demos/apps/browser_demo/lib/browser_demo.rb +31 -0
  10. data/demos/apps/simple_opal/Opalfile +13 -0
  11. data/demos/apps/simple_opal/index.html +11 -0
  12. data/demos/apps/simple_opal/lib/app_controller.rb +62 -0
  13. data/demos/apps/simple_opal/lib/main_window.rb +146 -0
  14. data/demos/browser/request/index.html +52 -0
  15. data/demos/browser/request/request.rb +48 -0
  16. data/gen/browser/__PROJECT_NAME__/index.html +10 -0
  17. data/gen/browser/__PROJECT_NAME__/lib/__PROJECT_NAME__.rb +1 -0
  18. data/lib/opal.rb +48 -3
  19. data/lib/opal/builders/base.rb +50 -0
  20. data/lib/opal/builders/css.rb +46 -0
  21. data/lib/opal/builders/javascript.rb +44 -0
  22. data/lib/opal/builders/opal.rb +79 -0
  23. data/lib/opal/builders/ruby.rb +50 -0
  24. data/lib/opal/builders/ruby/generate.rb +1851 -0
  25. data/lib/opal/builders/ruby/nodes.rb +210 -0
  26. data/lib/opal/builders/ruby/ruby.rb +916 -0
  27. data/lib/opal/builders/ruby/ruby_parser.rb +6008 -0
  28. data/lib/opal/builders/ruby/ruby_parser.rb.y +1451 -0
  29. data/lib/opal/models/build_item.rb +104 -0
  30. data/lib/opal/models/hash_struct.rb +40 -0
  31. data/lib/opal/models/project.rb +215 -0
  32. data/lib/opal/models/struct_accessors.rb +58 -0
  33. data/lib/opal/models/target.rb +176 -0
  34. data/lib/opal/opal/env/console.rb +66 -0
  35. data/lib/opal/opal/env/fs.rb +98 -0
  36. data/lib/opal/opal/env/object.rb +48 -0
  37. data/lib/opal/opal/environment.rb +139 -0
  38. data/lib/opal/opal/gen.rb +62 -0
  39. data/lib/opal/opal/opal.rb +68 -0
  40. data/lib/opal/opal/repl.rb +38 -0
  41. data/lib/opal/opalfile/dsl.rb +62 -0
  42. data/lib/opal/opalfile/opalfile.rb +133 -0
  43. data/lib/opal/opalfile/task.rb +96 -0
  44. data/lib/opal/opalfile/task_manager.rb +63 -0
  45. data/lib/opal/opalfile/task_scope.rb +52 -0
  46. data/lib/opal/rack/app_server.rb +119 -0
  47. data/opals/aristo/README.md +16 -0
  48. data/opals/browser/Opalfile +11 -0
  49. data/opals/browser/README.md +146 -0
  50. data/opals/browser/SIZZLE_LICESNSE.txt +148 -0
  51. data/opals/browser/lib/browser.rb +118 -0
  52. data/opals/browser/lib/browser/builder.rb +41 -0
  53. data/opals/browser/lib/browser/canvas_context.rb +115 -0
  54. data/opals/browser/lib/browser/dimensions.rb +50 -0
  55. data/opals/browser/lib/browser/document.rb +146 -0
  56. data/opals/browser/lib/browser/element.rb +487 -0
  57. data/opals/browser/lib/browser/element/attributes.rb +88 -0
  58. data/opals/browser/lib/browser/element/css.rb +290 -0
  59. data/opals/browser/lib/browser/element/form.rb +146 -0
  60. data/opals/browser/lib/browser/event/dom_events.rb +81 -0
  61. data/opals/browser/lib/browser/event/event.rb +177 -0
  62. data/opals/browser/lib/browser/event/trigger_events.rb +53 -0
  63. data/opals/browser/lib/browser/geometry.rb +97 -0
  64. data/opals/browser/lib/browser/json.rb +32 -0
  65. data/opals/browser/lib/browser/json_parse.js +321 -0
  66. data/opals/browser/lib/browser/request/request.rb +201 -0
  67. data/opals/browser/lib/browser/sizzle.js +1068 -0
  68. data/opals/browser/lib/browser/string.rb +42 -0
  69. data/opals/browser/lib/browser/touch.rb +37 -0
  70. data/{runtime/yaml.js → opals/browser/lib/browser/vml_context.js} +8 -8
  71. data/opals/browser/lib/browser/window.rb +36 -0
  72. data/opals/browser/spec/browser/browser_detection_spec.rb +7 -0
  73. data/opals/browser/spec/document/aref_spec.rb +110 -0
  74. data/opals/browser/spec/document/ready_spec.rb +16 -0
  75. data/opals/browser/spec/element/body_spec.rb +11 -0
  76. data/opals/browser/spec/element/clear_spec.rb +26 -0
  77. data/opals/browser/spec/element/empty_spec.rb +29 -0
  78. data/opals/browser/spec/element/has_class_spec.rb +40 -0
  79. data/opals/browser/spec/element/hidden_spec.rb +23 -0
  80. data/opals/browser/spec/element/hide_spec.rb +31 -0
  81. data/opals/browser/spec/element/remove_spec.rb +25 -0
  82. data/opals/browser/spec/element/show_spec.rb +31 -0
  83. data/opals/browser/spec/element/style_spec.rb +69 -0
  84. data/opals/browser/spec/element/toggle_spec.rb +31 -0
  85. data/opals/browser/spec/element/visible_spec.rb +23 -0
  86. data/opals/browser/spec/spec_helper.rb +1 -0
  87. data/opals/cherry_kit/Opalfile +6 -0
  88. data/opals/cherry_kit/bin/cherry_kit.rb +11 -0
  89. data/opals/cherry_kit/lib/cherry_kit.rb +29 -0
  90. data/opals/foundation/Opalfile +11 -0
  91. data/opals/foundation/bin/foundation.rb +12 -0
  92. data/opals/foundation/lib/foundation.rb +32 -0
  93. data/opals/foundation/lib/foundation/__table_view_desktop/outline_view.rb +57 -0
  94. data/opals/foundation/lib/foundation/__table_view_desktop/table_column.rb +59 -0
  95. data/opals/foundation/lib/foundation/__table_view_desktop/table_header_view.rb +34 -0
  96. data/opals/foundation/lib/foundation/__table_view_desktop/table_view.rb +304 -0
  97. data/opals/foundation/lib/foundation/controllers/array_controller.rb +54 -0
  98. data/opals/foundation/lib/foundation/controllers/controller.rb +74 -0
  99. data/opals/foundation/lib/foundation/controllers/controller_selection_proxy.rb +67 -0
  100. data/opals/foundation/lib/foundation/controllers/object_controller.rb +145 -0
  101. data/opals/foundation/lib/foundation/controllers/view.rb +40 -0
  102. data/opals/foundation/lib/foundation/core/application.rb +476 -0
  103. data/opals/foundation/lib/foundation/core/attributes.rb +146 -0
  104. data/opals/foundation/lib/foundation/core/bindings.rb +125 -0
  105. data/opals/foundation/lib/foundation/core/builder.rb +101 -0
  106. data/opals/foundation/lib/foundation/core/event.rb +112 -0
  107. data/opals/foundation/lib/foundation/core/index_path.rb +49 -0
  108. data/opals/foundation/lib/foundation/core/index_set.rb +97 -0
  109. data/opals/foundation/lib/foundation/core/notification.rb +113 -0
  110. data/opals/foundation/lib/foundation/core/observable.rb +275 -0
  111. data/opals/foundation/lib/foundation/core/observable_array.rb +30 -0
  112. data/opals/foundation/lib/foundation/core/responder.rb +85 -0
  113. data/opals/foundation/lib/foundation/core/run_loop.rb +89 -0
  114. data/opals/foundation/lib/foundation/core/touch.rb +95 -0
  115. data/opals/foundation/lib/foundation/gestures/gesture_recognizer.rb +35 -0
  116. data/opals/foundation/lib/foundation/rendering/render_context.rb +100 -0
  117. data/opals/foundation/lib/foundation/rendering/renderer.rb +137 -0
  118. data/opals/foundation/lib/foundation/rendering/root_theme.rb +77 -0
  119. data/opals/foundation/lib/foundation/rendering/root_theme/button.rb +62 -0
  120. data/opals/foundation/lib/foundation/rendering/root_theme/control.rb +72 -0
  121. data/opals/foundation/lib/foundation/rendering/root_theme/label.rb +54 -0
  122. data/opals/foundation/lib/foundation/rendering/root_theme/scroller.rb +58 -0
  123. data/opals/foundation/lib/foundation/rendering/root_theme/slider.rb +72 -0
  124. data/opals/foundation/lib/foundation/rendering/root_theme/table_view.rb +97 -0
  125. data/opals/foundation/lib/foundation/rendering/root_theme/text_field.rb +55 -0
  126. data/opals/foundation/lib/foundation/rendering/root_theme/view.rb +81 -0
  127. data/opals/foundation/lib/foundation/rendering/theme.rb +38 -0
  128. data/opals/foundation/lib/foundation/table_view/cell.rb +39 -0
  129. data/opals/foundation/lib/foundation/table_view/table.rb +171 -0
  130. data/opals/foundation/lib/foundation/views/button.rb +63 -0
  131. data/opals/foundation/lib/foundation/views/checkbox.rb +28 -0
  132. data/opals/foundation/lib/foundation/views/clip.rb +47 -0
  133. data/opals/foundation/lib/foundation/views/control.rb +199 -0
  134. data/opals/foundation/lib/foundation/views/label.rb +54 -0
  135. data/opals/foundation/lib/foundation/views/scroll.rb +294 -0
  136. data/opals/foundation/lib/foundation/views/scroll_view_desktop.rb +152 -0
  137. data/opals/foundation/lib/foundation/views/scroller.rb +54 -0
  138. data/opals/foundation/lib/foundation/views/slider.rb +93 -0
  139. data/opals/foundation/lib/foundation/views/text_field.rb +83 -0
  140. data/opals/foundation/lib/foundation/views/view.rb +426 -0
  141. data/opals/foundation/lib/foundation/windows/window.rb +191 -0
  142. data/opals/foundation/resources/button/button.css +23 -0
  143. data/{runtime/init.js → opals/foundation/resources/foundation.css} +27 -33
  144. data/opals/foundation/resources/scroll/scroll.css +22 -0
  145. data/opals/foundation/resources/scroll_view/scroll_view.css +3 -0
  146. data/opals/foundation/resources/scroll_view/scroller.css +3 -0
  147. data/opals/foundation/resources/slider/regular/slider.css +3 -0
  148. data/opals/foundation/resources/slider/slider.css +27 -0
  149. data/opals/foundation/resources/table_view/outline_view.css +3 -0
  150. data/opals/foundation/resources/table_view/table_view.css +15 -0
  151. data/opals/foundation/resources/text_field/text_field.css +71 -0
  152. data/opals/foundation/spec/spec_helper.rb +1 -0
  153. data/opals/foundation/spec/system/attributes/get_attribute_spec.rb +69 -0
  154. data/opals/foundation/spec/system/attributes/get_path_spec.rb +44 -0
  155. data/opals/foundation/spec/system/attributes/set_path_spec.rb +24 -0
  156. data/opals/foundation/spec/system/attributes/set_spec.rb +58 -0
  157. data/opals/foundation/spec/system/bindings/bindings.rb +85 -0
  158. data/opals/foundation/spec/system/key_value_binding/bind_spec.rb +43 -0
  159. data/opals/foundation/spec/system/observable/dependant_keys_spec.rb +74 -0
  160. data/opals/foundation/spec/system/observable/observe_spec.rb +292 -0
  161. data/opals/foundation/spec/system/observable/remove_observer_spec.rb +60 -0
  162. data/opals/opal/Opalfile +14 -0
  163. data/opals/opal/spec/core/array/append_spec.rb +30 -0
  164. data/opals/opal/spec/core/array/assoc_spec.rb +29 -0
  165. data/opals/opal/spec/core/array/at_spec.rb +37 -0
  166. data/opals/opal/spec/core/array/clear_spec.rb +22 -0
  167. data/opals/opal/spec/core/array/collect_bang_spec.rb +27 -0
  168. data/opals/opal/spec/core/array/collect_spec.rb +27 -0
  169. data/opals/opal/spec/core/array/compact_spec.rb +15 -0
  170. data/opals/opal/spec/core/array/concat_spec.rb +15 -0
  171. data/opals/opal/spec/core/array/constructor_spec.rb +14 -0
  172. data/opals/opal/spec/core/array/each_spec.rb +9 -0
  173. data/opals/opal/spec/core/array/element_reference_spec.rb +4 -0
  174. data/opals/opal/spec/core/array/first_spec.rb +35 -0
  175. data/opals/opal/spec/core/array/include_spec.rb +9 -0
  176. data/opals/opal/spec/core/array/map_spec.rb +31 -0
  177. data/opals/opal/spec/core/builtin_constants/builtin_constants_spec.rb +7 -0
  178. data/opals/opal/spec/core/false/and_spec.rb +10 -0
  179. data/opals/opal/spec/core/false/inspect_spec.rb +6 -0
  180. data/opals/opal/spec/core/false/or_spec.rb +10 -0
  181. data/opals/opal/spec/core/false/to_s_spec.rb +6 -0
  182. data/opals/opal/spec/core/false/xor_spec.rb +10 -0
  183. data/opals/opal/spec/core/file/join_spec.rb +19 -0
  184. data/opals/opal/spec/core/kernel/instance_eval_spec.rb +0 -0
  185. data/opals/opal/spec/core/kernel/loop_spec.rb +24 -0
  186. data/opals/opal/spec/core/kernel/raise_spec.rb +0 -0
  187. data/opals/opal/spec/core/module/attr_accessor_spec.rb +28 -0
  188. data/opals/opal/spec/core/number/lt_spec.rb +12 -0
  189. data/opals/opal/spec/core/true/and_spec.rb +10 -0
  190. data/opals/opal/spec/core/true/inspect_spec.rb +6 -0
  191. data/opals/opal/spec/core/true/or_spec.rb +10 -0
  192. data/opals/opal/spec/core/true/to_s_spec.rb +6 -0
  193. data/opals/opal/spec/core/true/xor_spec.rb +10 -0
  194. data/opals/opal/spec/fixtures/super.rb +70 -0
  195. data/opals/opal/spec/language/____temp_remove_this.rb +12 -0
  196. data/opals/opal/spec/language/and_spec.rb +62 -0
  197. data/opals/opal/spec/language/array_spec.rb +52 -0
  198. data/opals/opal/spec/language/block_spec.rb +18 -0
  199. data/opals/opal/spec/language/break_spec.rb +36 -0
  200. data/opals/opal/spec/language/case_spec.rb +103 -0
  201. data/opals/opal/spec/language/def_spec.rb +11 -0
  202. data/opals/opal/spec/language/eigenclass_spec.rb +60 -0
  203. data/opals/opal/spec/language/hash_spec.rb +29 -0
  204. data/opals/opal/spec/language/if_spec.rb +54 -0
  205. data/opals/opal/spec/language/loop_spec.rb +11 -0
  206. data/opals/opal/spec/language/metaclass_spec.rb +21 -0
  207. data/opals/opal/spec/language/method_spec.rb +64 -0
  208. data/opals/opal/spec/language/next_spec.rb +25 -0
  209. data/opals/opal/spec/language/or_spec.rb +34 -0
  210. data/opals/opal/spec/language/redo_spec.rb +24 -0
  211. data/opals/opal/spec/language/rescue_spec.rb +20 -0
  212. data/opals/opal/spec/language/return_spec.rb +47 -0
  213. data/opals/opal/spec/language/string_spec.rb +25 -0
  214. data/opals/opal/spec/language/super_spec.rb +26 -0
  215. data/opals/opal/spec/language/until_spec.rb +157 -0
  216. data/opals/opal/spec/language/while_spec.rb +163 -0
  217. data/opals/opal/spec/spec_helper.rb +5 -0
  218. data/opals/runtime/Opalfile +68 -0
  219. data/opals/runtime/README.md +12 -0
  220. data/opals/runtime/docs/debugging.md +51 -0
  221. data/opals/runtime/lib/array.rb +1516 -0
  222. data/opals/runtime/lib/basic_object.rb +49 -0
  223. data/opals/runtime/lib/class.rb +54 -0
  224. data/opals/runtime/lib/dir.rb +36 -0
  225. data/opals/runtime/lib/error.rb +49 -0
  226. data/opals/runtime/lib/false_class.rb +52 -0
  227. data/opals/runtime/lib/file.rb +79 -0
  228. data/opals/runtime/lib/hash.rb +791 -0
  229. data/opals/runtime/lib/io.rb +39 -0
  230. data/opals/runtime/lib/kernel.rb +288 -0
  231. data/opals/runtime/lib/match_data.rb +36 -0
  232. data/opals/runtime/lib/module.rb +109 -0
  233. data/opals/runtime/lib/nil_class.rb +69 -0
  234. data/opals/runtime/lib/number.rb +398 -0
  235. data/opals/runtime/lib/proc.rb +77 -0
  236. data/opals/runtime/lib/range.rb +63 -0
  237. data/opals/runtime/lib/regexp.rb +111 -0
  238. data/opals/runtime/lib/ruby.rb +30 -0
  239. data/opals/runtime/lib/string.rb +328 -0
  240. data/opals/runtime/lib/symbol.rb +40 -0
  241. data/opals/runtime/lib/top_self.rb +33 -0
  242. data/opals/runtime/lib/true_class.rb +45 -0
  243. data/opals/runtime/runtime/browser.js +287 -0
  244. data/opals/runtime/runtime/debug.js +182 -0
  245. data/opals/runtime/runtime/opal.js +1010 -0
  246. data/opals/runtime/runtime/post_opal.js +1 -0
  247. data/opals/runtime/runtime/pre_opal.js +2 -0
  248. data/opals/runtime/runtime/server_side.js +50 -0
  249. data/opals/spec/LICENSE.txt +26 -0
  250. data/opals/spec/Opalfile +5 -0
  251. data/opals/spec/bin/spec.rb +43 -0
  252. data/opals/spec/lib/spec.rb +33 -0
  253. data/opals/spec/lib/spec/dsl.rb +41 -0
  254. data/opals/spec/lib/spec/example.rb +35 -0
  255. data/opals/spec/lib/spec/example/before_and_after_hooks.rb +81 -0
  256. data/opals/spec/lib/spec/example/errors.rb +42 -0
  257. data/opals/spec/lib/spec/example/example_group.rb +37 -0
  258. data/opals/spec/lib/spec/example/example_group_factory.rb +43 -0
  259. data/opals/spec/lib/spec/example/example_group_hierarchy.rb +45 -0
  260. data/opals/spec/lib/spec/example/example_group_methods.rb +142 -0
  261. data/opals/spec/lib/spec/example/example_group_proxy.rb +41 -0
  262. data/opals/spec/lib/spec/example/example_methods.rb +73 -0
  263. data/opals/spec/lib/spec/example/example_proxy.rb +48 -0
  264. data/opals/spec/lib/spec/expectations.rb +46 -0
  265. data/opals/spec/lib/spec/expectations/errors.rb +35 -0
  266. data/opals/spec/lib/spec/expectations/fail_with.rb +37 -0
  267. data/opals/spec/lib/spec/expectations/handler.rb +48 -0
  268. data/opals/spec/lib/spec/matchers.rb +50 -0
  269. data/opals/spec/lib/spec/matchers/be.rb +26 -0
  270. data/opals/spec/lib/spec/matchers/generated_descriptions.rb +47 -0
  271. data/opals/spec/lib/spec/matchers/operator_matcher.rb +66 -0
  272. data/opals/spec/lib/spec/runner.rb +48 -0
  273. data/opals/spec/lib/spec/runner/example_group_runner.rb +71 -0
  274. data/opals/spec/lib/spec/runner/formatter/html_formatter.rb +100 -0
  275. data/opals/spec/lib/spec/runner/formatter/terminal_formatter.rb +82 -0
  276. data/opals/spec/lib/spec/runner/options.rb +63 -0
  277. data/opals/spec/lib/spec/runner/reporter.rb +123 -0
  278. data/opals/spec/resources/index.html +25 -0
  279. data/opals/spec/resources/spec.css +132 -0
  280. data/spec/cherry_kit/iseq_spec.rb +38 -0
  281. data/spec/spec_helper.rb +16 -0
  282. data/spec/vienna_spec.rb +7 -0
  283. data/yard/index.html +43 -0
  284. data/yard/style.css +765 -0
  285. metadata +312 -49
  286. data/docs/jarv.rdoc +0 -27
  287. data/runtime/array.js +0 -153
  288. data/runtime/class.js +0 -469
  289. data/runtime/compar.js +0 -73
  290. data/runtime/dir.js +0 -115
  291. data/runtime/enum.js +0 -74
  292. data/runtime/file.js +0 -165
  293. data/runtime/gem.js +0 -241
  294. data/runtime/hash.js +0 -181
  295. data/runtime/load.js +0 -251
  296. data/runtime/module.js +0 -98
  297. data/runtime/number.js +0 -148
  298. data/runtime/object.js +0 -522
  299. data/runtime/opal.js +0 -200
  300. data/runtime/parse.js +0 -2218
  301. data/runtime/range.js +0 -56
  302. data/runtime/re.js +0 -91
  303. data/runtime/string.js +0 -199
  304. data/runtime/variable.js +0 -184
  305. data/runtime/vm.js +0 -1150
  306. data/tasks/build.rb +0 -16
@@ -0,0 +1,28 @@
1
+ #
2
+ # checkbox.rb
3
+ # vienna
4
+ #
5
+ # Created by Adam Beynon.
6
+ # Copyright 2010 Adam Beynon.
7
+ #
8
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
9
+ # of this software and associated documentation files (the "Software"), to deal
10
+ # in the Software without restriction, including without limitation the rights
11
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12
+ # copies of the Software, and to permit persons to whom the Software is
13
+ # furnished to do so, subject to the following conditions:
14
+ #
15
+ # The above copyright notice and this permission notice shall be included in
16
+ # all copies or substantial portions of the Software.
17
+ #
18
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24
+ # THE SOFTWARE.
25
+ #
26
+
27
+ # checbox should just be a button.. register_builder(:checkbox) with extra
28
+ # defaults
@@ -0,0 +1,47 @@
1
+ #
2
+ # clip.rb
3
+ # vienna
4
+ #
5
+ # Created by Adam Beynon.
6
+ # Copyright 2010 Adam Beynon.
7
+ #
8
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
9
+ # of this software and associated documentation files (the "Software"), to deal
10
+ # in the Software without restriction, including without limitation the rights
11
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12
+ # copies of the Software, and to permit persons to whom the Software is
13
+ # furnished to do so, subject to the following conditions:
14
+ #
15
+ # The above copyright notice and this permission notice shall be included in
16
+ # all copies or substantial portions of the Software.
17
+ #
18
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24
+ # THE SOFTWARE.
25
+ #
26
+
27
+ require 'foundation/views/view'
28
+
29
+ module CherryKit
30
+
31
+ class ClipView < View
32
+
33
+ class_names 'ck-clip-view'
34
+
35
+ attr_reader :document_view
36
+
37
+ def document_view=(document_view)
38
+ return if @document_view == document_view
39
+
40
+ # need to observe...
41
+
42
+ @document_view = document_view
43
+
44
+ self << document_view
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,199 @@
1
+ #
2
+ # control.rb
3
+ # vienna
4
+ #
5
+ # Created by Adam Beynon.
6
+ # Copyright 2010 Adam Beynon.
7
+ #
8
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
9
+ # of this software and associated documentation files (the "Software"), to deal
10
+ # in the Software without restriction, including without limitation the rights
11
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12
+ # copies of the Software, and to permit persons to whom the Software is
13
+ # furnished to do so, subject to the following conditions:
14
+ #
15
+ # The above copyright notice and this permission notice shall be included in
16
+ # all copies or substantial portions of the Software.
17
+ #
18
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24
+ # THE SOFTWARE.
25
+ #
26
+
27
+ require 'foundation/views/view'
28
+
29
+ module CherryKit
30
+
31
+ class Control < View
32
+
33
+ display_attributes :enabled, :selected, :highlighted, :control_size
34
+
35
+ attr_writer :enabled, :highlighted, :selected
36
+
37
+ attr_accessor :value
38
+
39
+ # Managing the control size. Valid values are
40
+ #
41
+ # :mini, :small, :regular, :large
42
+ #
43
+ attr_accessor :control_size
44
+
45
+ # Expose our value binding
46
+ #
47
+ # expose_binding :value
48
+
49
+ # Expose our enabled binding
50
+ #
51
+ # expose_binding :enabled
52
+
53
+ def highlighted?
54
+ @highlighted
55
+ end
56
+
57
+ def enabled?
58
+ @enabled
59
+ end
60
+
61
+ def selected?
62
+ @selected
63
+ end
64
+
65
+ def initialize
66
+ super
67
+
68
+ @selected = false
69
+ @highlighted = false
70
+ @control_size = :regular
71
+ @enabled = true
72
+ end
73
+
74
+ def dup
75
+ result = super
76
+ result.enabled = enabled?
77
+
78
+ result
79
+ end
80
+
81
+ # ==================
82
+ # = Event handling =
83
+ # ==================
84
+
85
+ def mouse_down(event)
86
+ # do nothing unless we are enabled
87
+ return unless enabled?
88
+ # start tracking mouse otherwise
89
+ track_mouse event
90
+ end
91
+
92
+ # Track the mouse within the control beginning with the given event (which
93
+ # will more than likely be a :mouse_down event)
94
+ #
95
+ # @param {Event} event to start tracking
96
+ # @returns nil
97
+ #
98
+ def track_mouse(event)
99
+ # puts "tracking mouse!"
100
+ CKApp.handle_events([:mouse_up, :mouse_dragged]) do |event|
101
+ type = event.type
102
+ location = event.location_in_view self
103
+ within_frame = bounds.contains_point? location
104
+ puts "within frame: #{location.x}, #{location.y}"
105
+ puts "#{bounds.x}, #{bounds.y}, #{bounds.width}, #{bounds.height}"
106
+ puts "witjing frame.....? #{within_frame}"
107
+ # puts "event #{type.inspect}, #{location.x}, #{location.y}"
108
+
109
+ if type == :mouse_down
110
+ # puts type
111
+ start_tracking? location
112
+
113
+ elsif type == :mouse_up
114
+ # when mouse is up, just stop tracking and post that we wish to stop
115
+ # receiving events. simples.
116
+ stop_tracking location
117
+ CKApp.finish_handling_events
118
+
119
+ elsif type == :mouse_moved || type == :mouse_dragged
120
+ # we should only actually get mouse dragged events. fixc this later.
121
+ if within_frame
122
+ if !@tracking_was_within_frame
123
+ start_tracking? location
124
+ else
125
+ continue_tracking? location
126
+ end
127
+ else
128
+ stop_tracking location, false
129
+ end
130
+
131
+ # continue_tracking? location
132
+ end
133
+
134
+ @tracking_was_within_frame = within_frame
135
+ end
136
+ end
137
+
138
+ # Should start tracking?
139
+ #
140
+ # @param {Point} location (:left, :top)
141
+ # @returns {true|false}
142
+ #
143
+ def start_tracking?(location)
144
+ # puts "start tracking.."
145
+ end
146
+
147
+ def stop_tracking(location, mouse_up)
148
+ # puts "stop trackinhg.."
149
+ end
150
+
151
+ def continue_tracking?(location)
152
+ # puts "continue tracking.."
153
+ end
154
+
155
+
156
+ # ========================
157
+ # = Touch event tracking =
158
+ # ========================
159
+
160
+ def touches_began(touches, event)
161
+ touch = touches[0]
162
+ location = touch.location_in_view self
163
+ begin_tracking_with_touch? touch, event
164
+ end
165
+
166
+ def touches_ended(touches, event)
167
+ touch = touches[0]
168
+ location = touch.location_in_view self
169
+ end_tracking_with_touch touch, event
170
+ end
171
+
172
+ def touches_moved(touches, event)
173
+ touch = touches[0]
174
+ location = touch.location_in_view self
175
+ continue_tracking_with_touch? touch, event
176
+ end
177
+
178
+ # =========================
179
+ # = Tracking touch events =
180
+ # =========================
181
+
182
+ def begin_tracking_with_touch?(touch, event)
183
+ # puts "Control#begin_tracking_with_touch?(#{touch}, #{event})"
184
+ start_tracking? touch.location_in_view(self)
185
+ end
186
+
187
+ def continue_tracking_with_touch?(touch, event)
188
+ continue_tracking? touch.location_in_view(self)
189
+ end
190
+
191
+ def end_tracking_with_touch(touch, event)
192
+ stop_tracking touch.location_in_view(self)
193
+ end
194
+
195
+ def cancel_tracking_with_event(event)
196
+
197
+ end
198
+ end
199
+ end
@@ -0,0 +1,54 @@
1
+ #
2
+ # label.rb
3
+ # vienna
4
+ #
5
+ # Created by Adam Beynon.
6
+ # Copyright 2010 Adam Beynon.
7
+ #
8
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
9
+ # of this software and associated documentation files (the "Software"), to deal
10
+ # in the Software without restriction, including without limitation the rights
11
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12
+ # copies of the Software, and to permit persons to whom the Software is
13
+ # furnished to do so, subject to the following conditions:
14
+ #
15
+ # The above copyright notice and this permission notice shall be included in
16
+ # all copies or substantial portions of the Software.
17
+ #
18
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24
+ # THE SOFTWARE.
25
+ #
26
+
27
+ module CherryKit
28
+
29
+ class Label < Control
30
+
31
+ class_names 'ck-label'
32
+
33
+ display_attributes :title
34
+
35
+ attr_accessor :title
36
+
37
+ def initialize(layout)
38
+ super layout
39
+ @title = "Label"
40
+ end
41
+
42
+ def value=(value)
43
+ self.title = value
44
+ end
45
+
46
+ def create_renderer(theme)
47
+ theme.label self
48
+ end
49
+
50
+ def mouse_down(event)
51
+ @next_responder.mouse_down event
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,294 @@
1
+ #
2
+ # scroll.rb
3
+ # vienna
4
+ #
5
+ # Created by Adam Beynon.
6
+ # Copyright 2010 Adam Beynon.
7
+ #
8
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
9
+ # of this software and associated documentation files (the "Software"), to deal
10
+ # in the Software without restriction, including without limitation the rights
11
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12
+ # copies of the Software, and to permit persons to whom the Software is
13
+ # furnished to do so, subject to the following conditions:
14
+ #
15
+ # The above copyright notice and this permission notice shall be included in
16
+ # all copies or substantial portions of the Software.
17
+ #
18
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24
+ # THE SOFTWARE.
25
+ #
26
+
27
+ require 'foundation/views/view'
28
+
29
+ module CherryKit
30
+
31
+ class ScrollView < View
32
+
33
+ class_names 'ck-scroll-view'
34
+
35
+ # Desktop (non touch) systems will have a vertical scroller (instance of
36
+ # CherryKit::Scroller). Touch systems render the scroller themselves
37
+ #
38
+ attr_reader :vertical_scroller
39
+
40
+ # Again, non touch systems will have a horizontal scroller
41
+ #
42
+ attr_reader :horizontal_scroller
43
+
44
+ # The size of the content view's content. This is a display property/
45
+ #
46
+ # @attribute {Browser::Size} content_size
47
+ #
48
+ attr_accessor :content_size
49
+
50
+ # The content view. Display property
51
+ #
52
+ # @attribute {CherryKit::ClipView} content_view
53
+ attr_accessor :content_view
54
+
55
+ # Zoomscale. Float to determine the zoomed in scale. Default is 1.0 which
56
+ # means the document/content is zoomed 100%, so the content is actual size.
57
+ #
58
+ # @attribute {Number} zoom_scale
59
+ #
60
+ attr_accessor :zoom_scale
61
+
62
+ # initialize
63
+ def initialize(layout)
64
+ super layout
65
+ # clip view
66
+ self.content_view = ClipView.new(layout)
67
+ self << self.content_view
68
+ # these methods handle the relevant Scroller instances for desktop, or
69
+ # just setting for touch
70
+ self.has_vertical_scroller = true
71
+ self.has_horizontal_scroller = true
72
+
73
+ self.document_view = TestScrollingClass.new(layout)
74
+ document_view.layout = {
75
+ :left => 0,
76
+ :top => 0,
77
+ :width => 700,
78
+ :height => 700
79
+ }
80
+
81
+ # content offset - where are we. starts at 0,0
82
+ @content_offset = Browser::Point.new 0, 0
83
+
84
+ # default zoom level: 1.0 - actual size
85
+ @zoom_scale = 1.0
86
+
87
+ # we can actually receive multi touch
88
+ @multiple_touch_enabled = true
89
+
90
+ # we want to tile as soon as possible
91
+ tile
92
+ end
93
+
94
+ def document_view
95
+ @content_view.document_view
96
+ end
97
+
98
+ def document_view=(document_view)
99
+ @content_view.document_view = document_view
100
+ tile
101
+ end
102
+
103
+ # Set that we want a vertical scroller. (If on touch platform, this is a
104
+ # NO-OP method)
105
+ def has_vertical_scroller=(flag)
106
+ return if @has_vertical_scroller == flag
107
+ @has_vertical_scroller = flag
108
+ # only create a Scroller instance if not on touch
109
+
110
+ if flag && !Browser.touch? && !@vertical_scroller
111
+ self.vertical_scroller = Scroller.build(:vertical => true)
112
+ end
113
+
114
+ tile
115
+ end
116
+
117
+ def capture_touches?
118
+ true
119
+ end
120
+
121
+ # Purely for desktop
122
+ def vertical_scroller=(scroller)
123
+ @vertical_scroller = scroller
124
+ self << scroller
125
+ tile
126
+ end
127
+
128
+ def has_horizontal_scroller=(flag)
129
+ false
130
+ end
131
+
132
+ # =========================
133
+ # = Touch tracking/moving =
134
+ # =========================
135
+
136
+ # for now - single touch, no multitouch
137
+ def touches_began(touches, event)
138
+ # puts "#{self}#touches_began"
139
+ touch = touches[0]
140
+ content_offset = @content_offset
141
+ location = touch.location_in_view self
142
+ # where the last location was
143
+ @touch_last_offset = location
144
+
145
+ @tracking = true
146
+ @dragging = false
147
+ end
148
+
149
+ def touches_moved(touches, event)
150
+ # puts "#{self}#touches_moved"
151
+ touch = touches[0]
152
+ location = touch.location_in_view self
153
+
154
+ # deleta is the new position and its difference from the last position
155
+ delta_x = @touch_last_offset.x - location.x
156
+ delta_y = @touch_last_offset.y - location.y
157
+
158
+ # x direction - vertical
159
+ if true
160
+ @touch_last_offset.x = location.x
161
+ end
162
+
163
+ # horizontal
164
+ if true
165
+ @touch_last_offset.y = location.y
166
+ end
167
+
168
+
169
+ content_offset = @content_offset
170
+
171
+ offset_x = content_offset.x - delta_x
172
+ offset_y = content_offset.y - delta_y
173
+
174
+ set_content_offset Browser::Point.new(offset_x, offset_y), false
175
+
176
+
177
+ false
178
+ end
179
+
180
+ def touches_ended(touches, event)
181
+ puts "#{self}#touches_ended"
182
+ end
183
+
184
+
185
+ def content_offset=(content_offset)
186
+ set_content_offset content_offset, false
187
+ end
188
+
189
+ # Set the offset of the content. 0,0 implies the content will be located at
190
+ # the origin. Animated is not yet implemented
191
+ #
192
+ # @param {Browser::Point} offset for origin
193
+ # @param {true|false} animated
194
+ #
195
+ def set_content_offset(offset, animated)
196
+ element = `#{document_view.render_context.element}.__element__`
197
+
198
+ @content_offset = offset
199
+
200
+ offset_x = "#{offset.x}px"
201
+ offset_y = "#{offset.y}px"
202
+
203
+ transform = "translate3d(#{offset_x}, #{offset_y}, 0px)"
204
+ # transform = "translate"
205
+ class_name = `#{element}.className`
206
+ puts "setting transform to #{transform} for #{class_name}"
207
+ `#{element}.style.webkitTransform = #{transform};`
208
+
209
+ puts `#{element}.style.webkitTransform`
210
+
211
+ # `#{element}.style.left = #{offset_x};`
212
+ # `#{element}.style.top = #{offset_y};`
213
+ end
214
+
215
+
216
+
217
+ def tile
218
+ touch = Browser.touch?
219
+
220
+ vertical = @vertical_scroller
221
+ horizontal = @horizontal_scroller
222
+
223
+ # layout is the eventual layout for our clip view. This will cover the
224
+ # entire view for touch layouts, or will leave room for the scrollers on
225
+ # the desktop unless the scrollers are not visible
226
+ layout = {
227
+ :left => 0,
228
+ :top => 0
229
+ }
230
+
231
+ # tile the vertical scroller
232
+ if vertical
233
+ vertical.layout = {
234
+ :width => 20,
235
+ :top => 0,
236
+ :right => 0,
237
+ :bottom => 0
238
+ }
239
+
240
+ layout[:right] = 20
241
+ else
242
+ # if no vertical scroller, then set right to 0px (fill width)
243
+ layout[:right] = 0
244
+ end
245
+
246
+ # tile the horizontal scroller
247
+ if horizontal
248
+ horizontal.layout = {
249
+ :height => 20,
250
+ :left => 0,
251
+ :right => 0,
252
+ :bottom => 0
253
+ }
254
+
255
+ layout[:bottom] = 20
256
+ else
257
+ # if no vertical scroller, then set right to 0px (fill width)
258
+ layout[:bottom] = 0
259
+ end
260
+
261
+
262
+ @content_view.layout = layout
263
+ end
264
+
265
+ def render(render_context)
266
+ super render_context
267
+
268
+ if Browser.touch?
269
+ # on touch browsers we get built in scrollers
270
+ render_context << "<div class='vertical'><div class='scroller'></div></div><div class='horizontal'><div class='scroller'></div></div>"
271
+ else
272
+ # on non touch (desktop) browsers, we add another div for capturing
273
+ # scroll events for native behaviour
274
+ # render_context << "<div class='scroll-capture'></div>"
275
+ end
276
+ end
277
+ end
278
+
279
+
280
+ class TestScrollingClass < View
281
+
282
+ class_names 'test-scrolling'
283
+
284
+ def render(render_context)
285
+ super render_context
286
+ render_context << ["<div class='tl'></div>", "<div class='tr'></div>", "<div class='bl'></div>", "<div class='br'></div>"].join("")
287
+ end
288
+
289
+ def update
290
+ super
291
+ # render_context.element.div
292
+ end
293
+ end
294
+ end