riojs 0.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (270) hide show
  1. data/LICENSE +20 -0
  2. data/README.rdoc +24 -0
  3. data/VERSION +1 -0
  4. data/bin/rio +5 -0
  5. data/generators/rio_app/USAGE +19 -0
  6. data/generators/rio_app/rio_app_generator.rb +40 -0
  7. data/generators/rio_app/templates/app.build +10 -0
  8. data/generators/rio_app/templates/app.css +0 -0
  9. data/generators/rio_app/templates/app.js +20 -0
  10. data/generators/rio_app/templates/app_view.html.erb +19 -0
  11. data/generators/rio_app/templates/fixture.js +4 -0
  12. data/generators/rio_app/templates/rio.html.erb +18 -0
  13. data/generators/rio_app/templates/rio_controller.rb +2 -0
  14. data/generators/rio_app/templates/spec.js +7 -0
  15. data/generators/rio_component/USAGE +13 -0
  16. data/generators/rio_component/rio_component_generator.rb +16 -0
  17. data/generators/rio_component/templates/component.css +0 -0
  18. data/generators/rio_component/templates/component.js +11 -0
  19. data/generators/rio_component/templates/fixture.js +3 -0
  20. data/generators/rio_component/templates/spec.js +6 -0
  21. data/generators/rio_model/USAGE +12 -0
  22. data/generators/rio_model/rio_model_generator.rb +21 -0
  23. data/generators/rio_model/templates/fixture.js +3 -0
  24. data/generators/rio_model/templates/model.js +9 -0
  25. data/generators/rio_model/templates/spec.js +6 -0
  26. data/generators/rio_page/USAGE +14 -0
  27. data/generators/rio_page/rio_page_generator.rb +16 -0
  28. data/generators/rio_page/templates/fixture.js +3 -0
  29. data/generators/rio_page/templates/page.css +12 -0
  30. data/generators/rio_page/templates/page.js +12 -0
  31. data/generators/rio_page/templates/page.jst +64 -0
  32. data/generators/rio_page/templates/spec.js +6 -0
  33. data/generators/rio_resource/USAGE +20 -0
  34. data/generators/rio_resource/rio_resource_generator.rb +10 -0
  35. data/generators/rio_resource/templates/controller.rb +3 -0
  36. data/init.rb +4 -0
  37. data/install/config/juggernaut_hosts.yml +18 -0
  38. data/install/lib/tasks/rio.rake +1 -0
  39. data/install/script/rio_server +37 -0
  40. data/lib/rio/autospec.rb +86 -0
  41. data/lib/rio/install.rb +90 -0
  42. data/lib/rio/juggernaut.rb +212 -0
  43. data/lib/rio/path.rb +3 -0
  44. data/lib/rio/rio_compressor.rb +219 -0
  45. data/lib/rio/rio_file_controller.rb +16 -0
  46. data/lib/rio/rio_on_rails.rb +586 -0
  47. data/lib/rio/rio_proxy_controller.rb +60 -0
  48. data/lib/rio/rio_push_controller.rb +48 -0
  49. data/lib/rio/rio_routes.rb +24 -0
  50. data/lib/rio/rio_spec_controller.rb +70 -0
  51. data/lib/riojs.rb +14 -0
  52. data/lib/tasks/rio.rb +63 -0
  53. data/public/images/background-chiffon.png +0 -0
  54. data/public/images/button-gradient-overlay-down.png +0 -0
  55. data/public/images/button-gradient-overlay.png +0 -0
  56. data/public/images/icons/add.png +0 -0
  57. data/public/images/icons/error-big.png +0 -0
  58. data/public/images/icons/warning-big.png +0 -0
  59. data/public/images/rio-logo-big.png +0 -0
  60. data/public/images/rio-logo.png +0 -0
  61. data/public/images/splitter-handle-horizontal.png +0 -0
  62. data/public/images/splitter-handle-vertical.png +0 -0
  63. data/public/images/tab-bar-gradient-overlay.png +0 -0
  64. data/public/images/title-gradient-overlay.png +0 -0
  65. data/public/images/trash.gif +0 -0
  66. data/public/javascripts/components/accordion.js +144 -0
  67. data/public/javascripts/components/alert_box.js +59 -0
  68. data/public/javascripts/components/base.js +47 -0
  69. data/public/javascripts/components/box.js +63 -0
  70. data/public/javascripts/components/button.js +98 -0
  71. data/public/javascripts/components/checkbox.js +44 -0
  72. data/public/javascripts/components/container.js +265 -0
  73. data/public/javascripts/components/grid_view.js +107 -0
  74. data/public/javascripts/components/image.js +19 -0
  75. data/public/javascripts/components/input.js +171 -0
  76. data/public/javascripts/components/label.js +15 -0
  77. data/public/javascripts/components/lightbox.js +160 -0
  78. data/public/javascripts/components/link.js +43 -0
  79. data/public/javascripts/components/list_item.js +44 -0
  80. data/public/javascripts/components/list_view.js +192 -0
  81. data/public/javascripts/components/marquee.js +131 -0
  82. data/public/javascripts/components/menu.js +89 -0
  83. data/public/javascripts/components/notification.js +75 -0
  84. data/public/javascripts/components/overlay.js +134 -0
  85. data/public/javascripts/components/panel.js +146 -0
  86. data/public/javascripts/components/radio.js +46 -0
  87. data/public/javascripts/components/splitter.js +65 -0
  88. data/public/javascripts/components/tab_bar.js +64 -0
  89. data/public/javascripts/components/tab_panel.js +57 -0
  90. data/public/javascripts/components/textarea.js +223 -0
  91. data/public/javascripts/components/toggle_button.js +22 -0
  92. data/public/javascripts/components/tooltip.js +80 -0
  93. data/public/javascripts/lib/application.js +482 -0
  94. data/public/javascripts/lib/attr.js +760 -0
  95. data/public/javascripts/lib/benchmark.js +235 -0
  96. data/public/javascripts/lib/blank.html +39 -0
  97. data/public/javascripts/lib/boot.js +300 -0
  98. data/public/javascripts/lib/clipboard.js +96 -0
  99. data/public/javascripts/lib/collection_entity.js +46 -0
  100. data/public/javascripts/lib/component.js +129 -0
  101. data/public/javascripts/lib/console.js +75 -0
  102. data/public/javascripts/lib/console/apps/console.build +43 -0
  103. data/public/javascripts/lib/console/apps/console.js +28 -0
  104. data/public/javascripts/lib/console/blank.html +39 -0
  105. data/public/javascripts/lib/console/components/benchmark.js +196 -0
  106. data/public/javascripts/lib/console/components/console.js +352 -0
  107. data/public/javascripts/lib/console/components/dependencies_list.js +17 -0
  108. data/public/javascripts/lib/console/components/docs.js +66 -0
  109. data/public/javascripts/lib/console/components/playground.js +30 -0
  110. data/public/javascripts/lib/console/console.html +27 -0
  111. data/public/javascripts/lib/console/console_commands.js +287 -0
  112. data/public/javascripts/lib/console/console_commands.js.rej +21 -0
  113. data/public/javascripts/lib/console/console_mixin.js +22 -0
  114. data/public/javascripts/lib/console/docs/files.html +579 -0
  115. data/public/javascripts/lib/console/docs/index.html +323 -0
  116. data/public/javascripts/lib/console/docs/symbols/Object.html +291 -0
  117. data/public/javascripts/lib/console/docs/symbols/_global_.html +413 -0
  118. data/public/javascripts/lib/console/docs/symbols/rio.AIM.html +490 -0
  119. data/public/javascripts/lib/console/docs/symbols/rio.Application.html +841 -0
  120. data/public/javascripts/lib/console/docs/symbols/rio.Attr.html +1075 -0
  121. data/public/javascripts/lib/console/docs/symbols/rio.Binding.html +272 -0
  122. data/public/javascripts/lib/console/docs/symbols/rio.Component.html +419 -0
  123. data/public/javascripts/lib/console/docs/symbols/rio.Cookie.html +543 -0
  124. data/public/javascripts/lib/console/docs/symbols/rio.DelayedTask#initialize.html +270 -0
  125. data/public/javascripts/lib/console/docs/symbols/rio.DelayedTask.html +391 -0
  126. data/public/javascripts/lib/console/docs/symbols/rio.JsTemplate.html +271 -0
  127. data/public/javascripts/lib/console/docs/symbols/rio.Juggernaut.html +329 -0
  128. data/public/javascripts/lib/console/docs/symbols/rio.Model.html +822 -0
  129. data/public/javascripts/lib/console/docs/symbols/rio.Page.html +383 -0
  130. data/public/javascripts/lib/console/docs/symbols/rio.Template.html +328 -0
  131. data/public/javascripts/lib/console/docs/symbols/rio.Utils.html +617 -0
  132. data/public/javascripts/lib/console/docs/symbols/rio.html +506 -0
  133. data/public/javascripts/lib/console/docs/symbols/src/public_javascripts_components_base.js.html +54 -0
  134. data/public/javascripts/lib/console/docs/symbols/src/public_javascripts_lib_application.js.html +490 -0
  135. data/public/javascripts/lib/console/docs/symbols/src/public_javascripts_lib_attr.js.html +768 -0
  136. data/public/javascripts/lib/console/docs/symbols/src/public_javascripts_lib_boot.js.html +308 -0
  137. data/public/javascripts/lib/console/docs/symbols/src/public_javascripts_lib_clipboard.js.html +103 -0
  138. data/public/javascripts/lib/console/docs/symbols/src/public_javascripts_lib_collection_entity.js.html +53 -0
  139. data/public/javascripts/lib/console/docs/symbols/src/public_javascripts_lib_component.js.html +137 -0
  140. data/public/javascripts/lib/console/docs/symbols/src/public_javascripts_lib_cookie.js.html +81 -0
  141. data/public/javascripts/lib/console/docs/symbols/src/public_javascripts_lib_delayed_task.js.html +68 -0
  142. data/public/javascripts/lib/console/docs/symbols/src/public_javascripts_lib_file.js.html +80 -0
  143. data/public/javascripts/lib/console/docs/symbols/src/public_javascripts_lib_flash_detect.js.html +129 -0
  144. data/public/javascripts/lib/console/docs/symbols/src/public_javascripts_lib_form.js.html +95 -0
  145. data/public/javascripts/lib/console/docs/symbols/src/public_javascripts_lib_id.js.html +50 -0
  146. data/public/javascripts/lib/console/docs/symbols/src/public_javascripts_lib_inflector.js.html +167 -0
  147. data/public/javascripts/lib/console/docs/symbols/src/public_javascripts_lib_js_template.js.html +283 -0
  148. data/public/javascripts/lib/console/docs/symbols/src/public_javascripts_lib_juggernaut.js.html +303 -0
  149. data/public/javascripts/lib/console/docs/symbols/src/public_javascripts_lib_key_map.js.html +68 -0
  150. data/public/javascripts/lib/console/docs/symbols/src/public_javascripts_lib_layout_manager.js.html +175 -0
  151. data/public/javascripts/lib/console/docs/symbols/src/public_javascripts_lib_log.js.html +17 -0
  152. data/public/javascripts/lib/console/docs/symbols/src/public_javascripts_lib_model.js.html +1074 -0
  153. data/public/javascripts/lib/console/docs/symbols/src/public_javascripts_lib_page.js.html +246 -0
  154. data/public/javascripts/lib/console/docs/symbols/src/public_javascripts_lib_parameters.js.html +66 -0
  155. data/public/javascripts/lib/console/docs/symbols/src/public_javascripts_lib_protohack.js.html +305 -0
  156. data/public/javascripts/lib/console/docs/symbols/src/public_javascripts_lib_push.js.html +12 -0
  157. data/public/javascripts/lib/console/docs/symbols/src/public_javascripts_lib_rsh.js.html +659 -0
  158. data/public/javascripts/lib/console/docs/symbols/src/public_javascripts_lib_swfobject.js.html +12 -0
  159. data/public/javascripts/lib/console/docs/symbols/src/public_javascripts_lib_tag.js.html +60 -0
  160. data/public/javascripts/lib/console/docs/symbols/src/public_javascripts_lib_template.js.html +64 -0
  161. data/public/javascripts/lib/console/docs/symbols/src/public_javascripts_lib_theme.js.html +105 -0
  162. data/public/javascripts/lib/console/docs/symbols/src/public_javascripts_lib_undo.js.html +142 -0
  163. data/public/javascripts/lib/console/docs/symbols/src/public_javascripts_lib_utils.js.html +87 -0
  164. data/public/javascripts/lib/console/docs/symbols/src/public_javascripts_lib_yaml.js.html +88 -0
  165. data/public/javascripts/lib/console/file-small.png +0 -0
  166. data/public/javascripts/lib/console/green-circle.png +0 -0
  167. data/public/javascripts/lib/console/loading.gif +0 -0
  168. data/public/javascripts/lib/console/pages/console_page.js +149 -0
  169. data/public/javascripts/lib/console/pages/console_page.jst +27 -0
  170. data/public/javascripts/lib/console/red-circle.png +0 -0
  171. data/public/javascripts/lib/cookie.js +74 -0
  172. data/public/javascripts/lib/delayed_task.js +61 -0
  173. data/public/javascripts/lib/dependencies.js +76 -0
  174. data/public/javascripts/lib/environment.js +30 -0
  175. data/public/javascripts/lib/event.simulate.js +137 -0
  176. data/public/javascripts/lib/expressinstall.swf +0 -0
  177. data/public/javascripts/lib/file.js +72 -0
  178. data/public/javascripts/lib/flash_detect.js +122 -0
  179. data/public/javascripts/lib/flashembed.min.js +16 -0
  180. data/public/javascripts/lib/form.js +88 -0
  181. data/public/javascripts/lib/id.js +43 -0
  182. data/public/javascripts/lib/inflector.js +160 -0
  183. data/public/javascripts/lib/instrumenter.js +106 -0
  184. data/public/javascripts/lib/js_template.js +275 -0
  185. data/public/javascripts/lib/jslint.js +4950 -0
  186. data/public/javascripts/lib/juggernaut.js +295 -0
  187. data/public/javascripts/lib/juggernaut.swf +0 -0
  188. data/public/javascripts/lib/key_map.js +60 -0
  189. data/public/javascripts/lib/layout_manager.js +167 -0
  190. data/public/javascripts/lib/model.js +1067 -0
  191. data/public/javascripts/lib/page.js +238 -0
  192. data/public/javascripts/lib/parameters.js +59 -0
  193. data/public/javascripts/lib/png_fix.js +75 -0
  194. data/public/javascripts/lib/protohack.js +297 -0
  195. data/public/javascripts/lib/push.js +5 -0
  196. data/public/javascripts/lib/rio.build +28 -0
  197. data/public/javascripts/lib/rio_development.build +5 -0
  198. data/public/javascripts/lib/rio_lint.js +66 -0
  199. data/public/javascripts/lib/rsh.js +651 -0
  200. data/public/javascripts/lib/spec.js +545 -0
  201. data/public/javascripts/lib/spec_runner.js +242 -0
  202. data/public/javascripts/lib/swfobject.js +5 -0
  203. data/public/javascripts/lib/tag.js +52 -0
  204. data/public/javascripts/lib/undo.js +134 -0
  205. data/public/javascripts/lib/utils.js +80 -0
  206. data/public/javascripts/lib/yaml.js +80 -0
  207. data/public/javascripts/pages/playground_page.js +15 -0
  208. data/public/javascripts/prototype/builder.js +146 -0
  209. data/public/javascripts/prototype/controls.js +1004 -0
  210. data/public/javascripts/prototype/dragdrop.js +1030 -0
  211. data/public/javascripts/prototype/effects.js +1137 -0
  212. data/public/javascripts/prototype/prototype.js +4320 -0
  213. data/public/javascripts/prototype/slider.js +283 -0
  214. data/public/javascripts/prototype/sound.js +67 -0
  215. data/public/javascripts/specs/components/box_spec.js +6 -0
  216. data/public/javascripts/specs/components/checkbox_spec.js +26 -0
  217. data/public/javascripts/specs/components/container_spec.js +6 -0
  218. data/public/javascripts/specs/components/input_spec.js +71 -0
  219. data/public/javascripts/specs/components/panel_spec.js +6 -0
  220. data/public/javascripts/specs/components/radio_spec.js +40 -0
  221. data/public/javascripts/specs/fixtures/components/box.js +3 -0
  222. data/public/javascripts/specs/fixtures/components/checkbox.js +9 -0
  223. data/public/javascripts/specs/fixtures/components/container.js +3 -0
  224. data/public/javascripts/specs/fixtures/components/input.js +12 -0
  225. data/public/javascripts/specs/fixtures/components/menu.js +19 -0
  226. data/public/javascripts/specs/fixtures/components/menu_item.js +18 -0
  227. data/public/javascripts/specs/fixtures/components/radio.js +11 -0
  228. data/public/javascripts/specs/lib/application_spec.js +281 -0
  229. data/public/javascripts/specs/lib/attr_spec.js +1514 -0
  230. data/public/javascripts/specs/lib/benchmark_spec.js +361 -0
  231. data/public/javascripts/specs/lib/collection_entity_spec.js +131 -0
  232. data/public/javascripts/specs/lib/component_spec.js +86 -0
  233. data/public/javascripts/specs/lib/form_spec.js +171 -0
  234. data/public/javascripts/specs/lib/id_spec.js +21 -0
  235. data/public/javascripts/specs/lib/instrumenter_spec.js +5 -0
  236. data/public/javascripts/specs/lib/js_template_spec.js +131 -0
  237. data/public/javascripts/specs/lib/key_map_spec.js +227 -0
  238. data/public/javascripts/specs/lib/model_spec.js +2268 -0
  239. data/public/javascripts/specs/lib/parameters_spec.js +94 -0
  240. data/public/javascripts/specs/lib/spec_spec.js +943 -0
  241. data/public/javascripts/specs/lib/undo_spec.js +105 -0
  242. data/public/javascripts/specs/lib/yaml_spec.js +127 -0
  243. data/public/sounds/basso.wav +0 -0
  244. data/public/sounds/purr.wav +0 -0
  245. data/public/stylesheets/components/accordion.css +24 -0
  246. data/public/stylesheets/components/alert_box.css +35 -0
  247. data/public/stylesheets/components/box.css +0 -0
  248. data/public/stylesheets/components/button.css +39 -0
  249. data/public/stylesheets/components/checkbox.css +9 -0
  250. data/public/stylesheets/components/container.css +3 -0
  251. data/public/stylesheets/components/grid_view.css +52 -0
  252. data/public/stylesheets/components/input.css +10 -0
  253. data/public/stylesheets/components/label.css +3 -0
  254. data/public/stylesheets/components/lightbox.css +31 -0
  255. data/public/stylesheets/components/link.css +4 -0
  256. data/public/stylesheets/components/list_view.css +23 -0
  257. data/public/stylesheets/components/marquee.css +29 -0
  258. data/public/stylesheets/components/menu.css +34 -0
  259. data/public/stylesheets/components/notification.css +52 -0
  260. data/public/stylesheets/components/overlay.css +8 -0
  261. data/public/stylesheets/components/panel.css +36 -0
  262. data/public/stylesheets/components/radio.css +9 -0
  263. data/public/stylesheets/components/splitter.css +35 -0
  264. data/public/stylesheets/components/tab_bar.css +59 -0
  265. data/public/stylesheets/components/tab_panel.css +15 -0
  266. data/public/stylesheets/components/textarea.css +11 -0
  267. data/public/stylesheets/components/tooltip.css +10 -0
  268. data/public/stylesheets/console.css +151 -0
  269. data/public/stylesheets/css_reset.css +55 -0
  270. metadata +343 -0
@@ -0,0 +1,86 @@
1
+ describe(rio.Component, {
2
+ "inheritance": {
3
+ beforeEach: function() {
4
+ var SuperComponent = rio.Component.create("SuperComponent", {
5
+ attrAccessors: ["a"],
6
+ attrHtmls: ["super"],
7
+ methods: {
8
+ buildSuperHtml: function() { return "foo"; },
9
+ superHello: function() { return "super world"; }
10
+ }
11
+ });
12
+ var SubComponent = rio.Component.create(SuperComponent, "SubComponent", {
13
+ attrAccessors: ["b"],
14
+ attrHtmls: ["sub"],
15
+ methods: {
16
+ buildSubHtml: function() { return "bar"; },
17
+ subHello: function() { return "sub world"; }
18
+ }
19
+ });
20
+ var SubSubComponent = rio.Component.create(SubComponent, "SubSubComponent", {
21
+ attrAccessors: ["c"],
22
+ attrHtmls: ["subSub"],
23
+ methods: {
24
+ buildSubSubHtml: function() { return "baz"; },
25
+ subSubHello: function() { return "sub sub world"; }
26
+ }
27
+ });
28
+
29
+ this.component = new SubSubComponent({ a: 1, b: 2, c: 3 });
30
+ },
31
+
32
+ "should support attrHtmls": function() {
33
+ this.component.subSubHtml().shouldEqual("baz");
34
+ },
35
+
36
+ "should inherit parent's attrHtmls": function() {
37
+ this.component.subHtml().shouldEqual("bar");
38
+ },
39
+
40
+ "should inherit grandparent's attrHtmls": function() {
41
+ this.component.superHtml().shouldEqual("foo");
42
+ },
43
+
44
+ "should support attrAccessors": function() {
45
+ this.component.getC().shouldEqual(3);
46
+ },
47
+
48
+ "should inherit parent's attrAccessors": function() {
49
+ this.component.getB().shouldEqual(2);
50
+ },
51
+
52
+ "should inherit grandparent's attrAccessors": function() {
53
+ this.component.getA().shouldEqual(1);
54
+ },
55
+
56
+ "should support methods": function() {
57
+ this.component.subSubHello().shouldEqual("sub sub world");
58
+ },
59
+
60
+ "should inherit parent's methods": function() {
61
+ this.component.subHello().shouldEqual("sub world");
62
+ },
63
+
64
+ "should inherit grandparent's methods": function() {
65
+ this.component.superHello().shouldEqual("super world");
66
+ }
67
+ }
68
+ });
69
+
70
+
71
+
72
+
73
+
74
+
75
+
76
+
77
+
78
+
79
+
80
+
81
+
82
+
83
+
84
+
85
+
86
+
@@ -0,0 +1,171 @@
1
+ describe(rio.Form, {
2
+ "with no validators": {
3
+ beforeEach: function() {
4
+ this.company = new (rio.Attr.create({ attrAccessors: ["name"] }))({ name: "Thinklink" });
5
+
6
+ this.form = rio.Form.build({
7
+ attributes: {
8
+ name: {},
9
+ email: { initialValue: "tilleryj@gmail.com" },
10
+ company: { initialValue: this.company.name }
11
+ }
12
+ });
13
+ },
14
+
15
+ "should accept a set of attributes and make them available as bindable attributes": function() {
16
+ this.form.getName().shouldEqual("");
17
+ this.form.setName("Hello");
18
+ this.form.getName().shouldEqual("Hello");
19
+
20
+ (this.form.name.constructor == rio.Binding).shouldBeTrue();
21
+ },
22
+
23
+ "should accept custom initial values for attributes": function() {
24
+ this.form.getEmail().shouldEqual("tilleryj@gmail.com");
25
+ },
26
+
27
+ "should reset values back to their initial values": function() {
28
+ this.form.setName("Jason");
29
+ this.form.setEmail("asdf@thinklinkr.com");
30
+ this.form.reset();
31
+
32
+ this.form.getName().shouldEqual("");
33
+ this.form.getEmail().shouldEqual("tilleryj@gmail.com");
34
+ },
35
+
36
+ "should allow bindable initial values": function() {
37
+ this.form.getCompany().shouldEqual("Thinklink");
38
+ this.company.setName("Apple");
39
+ this.form.getCompany().shouldEqual("Thinklink");
40
+ this.form.reset();
41
+ this.form.getCompany().shouldEqual("Apple");
42
+ },
43
+
44
+ "should provide a commit method that invokes the onCommit function with the forms values": function() {
45
+ var onCommit = function(values) {
46
+ values.email.shouldEqual("tilleryj@gmail.com");
47
+ }.shouldBeCalled();
48
+ var form = rio.Form.build({
49
+ attributes: {
50
+ email: { initialValue: "tilleryj@gmail.com" }
51
+ },
52
+ onCommit: onCommit
53
+ });
54
+ form.commit();
55
+ },
56
+
57
+ "should be valid": function() {
58
+ this.form.valid().shouldBeTrue();
59
+ }
60
+ },
61
+
62
+ "with validators": {
63
+ beforeEach: function() {
64
+ this.form = rio.Form.build({
65
+ attributes: {
66
+ name: {
67
+ validates: [function(values) {
68
+ if (values.name.length > 5) {
69
+ return "Name cannot be longer than 5 characters.";
70
+ }
71
+ }]
72
+ },
73
+ email: {
74
+ initialValue: "tilleryj@gmail.com",
75
+ validates: ["email"]
76
+ }
77
+ }
78
+ });
79
+ },
80
+
81
+ "should be valid initially": function() {
82
+ this.form.valid().shouldBeTrue();
83
+ },
84
+
85
+ "should not be valid email is not a valid email address": function() {
86
+ this.form.setEmail("");
87
+ this.form.valid().shouldBeFalse();
88
+ this.form.setEmail("asdf");
89
+ this.form.valid().shouldBeFalse();
90
+ this.form.setEmail("asdf@thinklinkr.");
91
+ this.form.valid().shouldBeFalse();
92
+ this.form.setEmail("asdf@thinklinkr.com");
93
+ this.form.valid().shouldBeTrue();
94
+ },
95
+
96
+ "should not be valid if a validator function returns an error message": function() {
97
+ this.form.setName("Hello World");
98
+ this.form.valid().shouldBeFalse();
99
+ this.form.setName("Hello");
100
+ this.form.valid().shouldBeTrue();
101
+ },
102
+
103
+ "should not commit if in an invalid state": function() {
104
+ var form = rio.Form.build({
105
+ attributes: {
106
+ name: {
107
+ validates: [function(values) { return "Never valid"; }]
108
+ }
109
+ },
110
+ onCommit: function() {}.shouldNotBeCalled()
111
+ });
112
+ form.commit();
113
+ },
114
+
115
+ "should expose bindable error messages": function() {
116
+ var emailErrors = this.form.errorsFor('email');
117
+ (emailErrors.constructor == rio.Binding).shouldBeTrue();
118
+ emailErrors.value().shouldEqual("");
119
+ this.form.setEmail("asdf");
120
+ emailErrors.value().shouldEqual("not a valid email address");
121
+ },
122
+
123
+ "should remove erros on reset even if the form is still in a bad state": function() {
124
+ this.form = rio.Form.build({
125
+ attributes: {
126
+ email: {
127
+ initialValue: "",
128
+ validates: ["email"]
129
+ }
130
+ }
131
+ });
132
+ this.form.validate();
133
+ this.form.errorsFor("email").value().shouldNotEqual("");
134
+ this.form.reset();
135
+ this.form.errorsFor("email").value().shouldEqual("");
136
+ }
137
+ }
138
+ });
139
+
140
+ describe(rio.Validators, {
141
+ "should validate email": function() {
142
+ var emailErrorMessage = "not a valid email address";
143
+ rio.Validators.email("").shouldEqual(emailErrorMessage);
144
+ rio.Validators.email("asdf@").shouldEqual(emailErrorMessage);
145
+ rio.Validators.email("asdf@thinklinkr").shouldEqual(emailErrorMessage);
146
+ rio.Validators.email("asdf@thinklinkr.").shouldEqual(emailErrorMessage);
147
+ rio.Validators.email("@thinklinkr.com").shouldEqual(emailErrorMessage);
148
+ rio.Validators.email("thinklinkr.com").shouldEqual(emailErrorMessage);
149
+ rio.Validators.email("asdf@thinklinkr.com").shouldEqual("");
150
+ rio.Validators.email("asdf+extra@thinklinkr.com").shouldEqual("");
151
+ },
152
+
153
+ "should validate presence": function() {
154
+ var errorMessage = "cannot be blank";
155
+ rio.Validators.presence().shouldEqual(errorMessage);
156
+ rio.Validators.presence("").shouldEqual(errorMessage);
157
+ rio.Validators.presence(" ").shouldEqual(errorMessage);
158
+ rio.Validators.presence(" ").shouldEqual(errorMessage);
159
+ rio.Validators.presence("anything").shouldEqual("");
160
+ }
161
+ });
162
+
163
+
164
+
165
+
166
+
167
+
168
+
169
+
170
+
171
+
@@ -0,0 +1,21 @@
1
+ describe(rio.Id, {
2
+ "that is reified": {
3
+ "should immediately call anything passed in to doAfterReification": function() {
4
+ var rioId = new rio.Id(25);
5
+ rioId.doAfterReification(function(){}.shouldBeCalled());
6
+ }
7
+ },
8
+
9
+ "that is not reified": {
10
+ beforeEach: function() {
11
+ this.rioId = new rio.Id();
12
+ },
13
+ "should not call anything passed into doAfterReification right away": function() {
14
+ this.rioId.doAfterReification(function(){}.shouldNotBeCalled());
15
+ },
16
+ "should call whatever is passed into doAfterReification after reification": function() {
17
+ this.rioId.doAfterReification(function(){}.shouldBeCalled());
18
+ this.rioId.reify(1234);
19
+ }
20
+ }
21
+ });
@@ -0,0 +1,5 @@
1
+ describe(rio.Instrumenter, {
2
+ "should ...": function() {
3
+ rio.Instrumenter.instrument("lib/utils");
4
+ }
5
+ });
@@ -0,0 +1,131 @@
1
+ describe(rio.JsTemplate, {
2
+ "with no custom tags": {
3
+ beforeEach: function() {
4
+ this.template = new rio.JsTemplate({
5
+ text: '<div><span rio:id="hello">world</span></div>'
6
+ });
7
+ },
8
+
9
+ "should have a default name of 'tempate'": function() {
10
+ this.template.name().shouldEqual("template");
11
+ },
12
+
13
+ "should remove the rio:id tag and mix an accessor into the context": function() {
14
+ var context = {};
15
+ var html = this.template.render(context);
16
+ html.childElements()[0].tagName.shouldEqual("DIV");
17
+ html.childElements()[0].childElements()[0].tagName.shouldEqual("SPAN");
18
+ html.childElements()[0].childElements()[0].innerHTML.shouldEqual("world");
19
+ html.childElements()[0].childElements()[0].id.shouldEqual("");
20
+ context.getHelloElement().tagName.shouldEqual("SPAN");
21
+ },
22
+
23
+ "should provide a build HTML method in the context mixin methods": function() {
24
+ var html = this.template.mixinMethods().buildHtml();
25
+ html.childElements()[0].tagName.shouldEqual("DIV");
26
+ html.childElements()[0].childElements()[0].tagName.shouldEqual("SPAN");
27
+ html.childElements()[0].childElements()[0].innerHTML.shouldEqual("world");
28
+ html.childElements()[0].childElements()[0].id.shouldEqual("");
29
+ }
30
+ },
31
+
32
+ "with custom tags": {
33
+ beforeEach: function() {
34
+ if (!rio.components.Box) { rio.File.execute(rio.boot.root + "components/box.js", { asynchronous: false }); }
35
+ this.template = new rio.JsTemplate({
36
+ text: '<rio:Box rio:id="hello" height="10" />',
37
+ name: "editor"
38
+ });
39
+ this.context = {};
40
+ this.template.render(this.context);
41
+ },
42
+
43
+ "should have the correct name": function() {
44
+ this.template.name().shouldEqual("editor");
45
+ },
46
+
47
+ "should mixin component accessors": function() {
48
+ this.context.getHello().html().tagName.shouldEqual("DIV");
49
+ },
50
+
51
+ "should build components with attributes": function() {
52
+ this.context.getHello().getHeight().shouldEqual("10");
53
+ }
54
+ },
55
+
56
+ "with complex custom tags": {
57
+ beforeEach: function() {
58
+ if (!rio.components.Box) { rio.File.execute(rio.boot.root + "components/box.js", { asynchronous: false }); }
59
+ this.template = new rio.JsTemplate({
60
+ text: '<rio:Box rio:id="hello" height="{ 1 + 2 }"><className>world</className><width>13px</width><region><rio:Object><attribute>b</attribute></rio:Object></region></rio:Box>',
61
+ name: "editor"
62
+ });
63
+ this.context = {};
64
+ this.template.render(this.context);
65
+ },
66
+
67
+ "should build components with evaluative {} attributes": function() {
68
+ this.context.getHello().getHeight().shouldEqual(3);
69
+ },
70
+
71
+ "should build components with elemental attributes": function() {
72
+ this.context.getHello().getClassName().shouldEqual("world");
73
+ },
74
+
75
+ "should build components with more than one elemental attribute": function() {
76
+ this.context.getHello().getWidth().shouldEqual("13px");
77
+ },
78
+
79
+ "should allow you to pass in an object as an elemental attribute using <rio:Object>": function() {
80
+ this.context.getHello().getRegion().attribute.shouldEqual("b");
81
+ }
82
+ },
83
+
84
+ "with the <select> tag": {
85
+ beforeEach: function() {
86
+ this.template = new rio.JsTemplate({
87
+ text: '<select rio:id="cardType" class="popupForm" style="width: 300px"><option>asdf</option></select>',
88
+ name: "editor"
89
+ });
90
+ this.context = {};
91
+ this.template.render(this.context);
92
+ },
93
+
94
+ "should build a select tag correctly": function() {
95
+ this.context.getCardTypeElement().tagName.shouldEqual("SELECT");
96
+ }
97
+ },
98
+
99
+ /* Safari <4 serializes the \u00a0 representation back into a \u00a0 */
100
+ "with nbsp; tags": {
101
+ "should properly render a space": function() {
102
+ var template = new rio.JsTemplate({
103
+ text: '<div rio:id="divWithSpace">&nbsp;</div>',
104
+ name: "editor"
105
+ });
106
+ var context = {};
107
+ template.render(context);
108
+
109
+ context.getDivWithSpaceElement().tagName.shouldEqual("DIV");
110
+ var value = context.getDivWithSpaceElement().innerHTML;
111
+ (value == "\u00a0" || value == "&nbsp;").shouldBeTrue();
112
+ },
113
+
114
+ "should properly render two spaces": function() {
115
+ var template = new rio.JsTemplate({
116
+ text: '<div rio:id="divWithSpace">&nbsp;&nbsp;</div>',
117
+ name: "editor"
118
+ });
119
+ var context = {};
120
+ template.render(context);
121
+
122
+ context.getDivWithSpaceElement().tagName.shouldEqual("DIV");
123
+ var value = context.getDivWithSpaceElement().innerHTML;
124
+ (value == "\u00a0\u00a0" || value == "&nbsp;&nbsp;").shouldBeTrue();
125
+ }
126
+ }
127
+ });
128
+
129
+
130
+
131
+
@@ -0,0 +1,227 @@
1
+ describe(rio.KeyMap, {
2
+ beforeEach: function() {
3
+ this.shouldMatchOrNot = function(m, e, h) {
4
+ new rio.KeyMap([
5
+ {
6
+ map: m,
7
+ handler: h
8
+ }
9
+ ]).handle(e);
10
+ };
11
+
12
+ this.shouldMatch = function(map, e) {
13
+ this.shouldMatchOrNot(map, e, function() {}.shouldBeCalled());
14
+ };
15
+
16
+ this.shouldNotMatch = function(map, e) {
17
+ this.shouldMatchOrNot(map, e, function() {}.shouldNotBeCalled());
18
+ };
19
+ },
20
+
21
+ "should fire the handler if the event keyCode matches the key": function() {
22
+ this.shouldMatch({ key: 65 }, { keyCode: 65 });
23
+ },
24
+
25
+ "should not fire the handler if the event keyCode does not match the key": function() {
26
+ this.shouldNotMatch({ key: 65 }, { keyCode: 64 });
27
+ },
28
+
29
+ "should fire all matching handlers": function() {
30
+ var e = { keyCode: 65, ctrlKey: true };
31
+ new rio.KeyMap([
32
+ {
33
+ map: { key: 65 },
34
+ handler: function() {}.shouldBeCalled()
35
+ },
36
+ {
37
+ map: { key: 65, ctrl: true },
38
+ handler: function() {}.shouldBeCalled()
39
+ }
40
+ ]).handle(e);
41
+ },
42
+
43
+ "should fire the handler and pass the event if the event keyCode matches the key": function() {
44
+ var e = { keyCode: 65 };
45
+ new rio.KeyMap([
46
+ {
47
+ map: { key: 65 },
48
+ handler: function(ev) { (ev === e).shouldBeTrue(); }.shouldBeCalled()
49
+ }
50
+ ]).handle(e);
51
+ },
52
+
53
+ "should match the windows mappings if provided and isMac is not true": function() {
54
+ new rio.KeyMap([
55
+ {
56
+ win: { key: 65 },
57
+ mac: { key: 67 },
58
+ handler: function() {}.shouldBeCalled()
59
+ }
60
+ ]).handle({ keyCode: 65 });
61
+ },
62
+
63
+ "should not match the mac mappings if isMac is not true": function() {
64
+ new rio.KeyMap([
65
+ {
66
+ win: { key: 65 },
67
+ mac: { key: 67 },
68
+ handler: function() {}.shouldNotBeCalled()
69
+ }
70
+ ]).handle({ keyCode: 67 });
71
+ },
72
+
73
+ "should match the mac mappings if isMac is true": function() {
74
+ new rio.KeyMap([
75
+ {
76
+ win: { key: 65 },
77
+ mac: { key: 67 },
78
+ handler: function() {}.shouldBeCalled()
79
+ }
80
+ ], true).handle({ keyCode: 67 });
81
+ },
82
+
83
+ "should not match the windows mappings if isMac is true": function() {
84
+ new rio.KeyMap([
85
+ {
86
+ win: { key: 65 },
87
+ mac: { key: 67 },
88
+ handler: function() {}.shouldNotBeCalled()
89
+ }
90
+ ], true).handle({ keyCode: 65 });
91
+ },
92
+
93
+ "should support modifiers by": {
94
+ builder: function() {
95
+ var specs = {};
96
+ ["ctrl", "alt", "shift", "meta"].each(function(modifier) {
97
+ var map = { key: 65 };
98
+ var e = { keyCode: 65 };
99
+
100
+ specs["matching when the " + modifier + " map is true and the event " + modifier + " is true"] = function() {
101
+ map[modifier] = true;
102
+ e[modifier + "Key"] = true;
103
+ this.shouldMatch(map, e);
104
+ };
105
+
106
+ specs["not matching when the " + modifier + " map is true and the event " + modifier + " is false"] = function() {
107
+ map[modifier] = true;
108
+ e[modifier + "Key"] = false;
109
+ this.shouldNotMatch(map, e);
110
+ };
111
+
112
+ specs["not matching when the " + modifier + " map is undefined and the event " + modifier + " is true"] = function() {
113
+ delete map[modifier];
114
+ e[modifier + "Key"] = true;
115
+ this.shouldMatch(map, e);
116
+ };
117
+
118
+ });
119
+ return specs;
120
+ }
121
+ },
122
+
123
+ "should fire the handler if the key charCode matches the event keyCode": function() {
124
+ this.shouldMatch({ key: 'a' }, { keyCode: 65 });
125
+ },
126
+
127
+ "should not fire the handler if the key charCode does not match the event keyCode": function() {
128
+ this.shouldNotMatch({ key: 'b' }, { keyCode: 65 });
129
+ },
130
+
131
+ "should fire the handler if the number matches the event keyCode for the top numbers": function() {
132
+ $R(0, 9).each(function(n) {
133
+ this.shouldMatch({ key: "" + n }, { keyCode: 48 + n });
134
+ }.bind(this));
135
+ },
136
+
137
+ "should fire the handler if the number matches the event keyCode for the side numbers": function() {
138
+ $R(0, 9).each(function(n) {
139
+ this.shouldMatch({ key: "" + n }, { keyCode: 96 + n });
140
+ }.bind(this));
141
+ },
142
+
143
+ "should not fire the handler if the number does not match the event keyCode for the any numbers": function() {
144
+ $R(0, 9).each(function(n) {
145
+ this.shouldNotMatch({ key: "" + n }, { keyCode: 49 + n });
146
+ }.bind(this));
147
+ },
148
+
149
+ "should stop the event if the mapping stop parameter is true and the mapping matches the event": function() {
150
+ var e = { keyCode: 65, stop: function() {}.shouldBeCalled() };
151
+ new rio.KeyMap([
152
+ {
153
+ map: { key: 65 },
154
+ handler: function() {},
155
+ stop: true
156
+ }
157
+ ]).handle(e);
158
+ },
159
+
160
+ "should not stop the event if the mapping stop parameter is true and the mapping does not match the event": function() {
161
+ var e = { keyCode: 65, stop: function() {}.shouldNotBeCalled() };
162
+ new rio.KeyMap([
163
+ {
164
+ map: { key: 66 },
165
+ handler: function() {},
166
+ stop: true
167
+ }
168
+ ]).handle(e);
169
+ },
170
+
171
+ "should not stop the event if the mapping stop parameter is false and the mapping matches the event": function() {
172
+ var e = { keyCode: 65, stop: function() {}.shouldNotBeCalled() };
173
+ new rio.KeyMap([
174
+ {
175
+ map: { key: 65 },
176
+ handler: function() {},
177
+ stop: false
178
+ }
179
+ ]).handle(e);
180
+ },
181
+
182
+ "should not stop the event by default": function() {
183
+ var e = { keyCode: 65, stop: function() {}.shouldNotBeCalled() };
184
+ new rio.KeyMap([
185
+ {
186
+ map: { key: 65 },
187
+ handler: function() {}
188
+ }
189
+ ]).handle(e);
190
+ },
191
+
192
+ "should still stop an event if stop is true and it matches but has no handler": function() {
193
+ var e = { keyCode: 65, stop: function() {}.shouldNotBeCalled() };
194
+ new rio.KeyMap([
195
+ {
196
+ map: { key: 65 },
197
+ stop: false
198
+ }
199
+ ]).handle(e);
200
+ },
201
+
202
+ "should match the key": {
203
+ builder: function() {
204
+ var specs = {};
205
+ [
206
+ { key: "left", code: Event.KEY_LEFT },
207
+ { key: "right", code: Event.KEY_RIGHT },
208
+ { key: "up", code: Event.KEY_UP },
209
+ { key: "down", code: Event.KEY_DOWN },
210
+ { key: "tab", code: Event.KEY_TAB },
211
+ { key: "enter", code: Event.KEY_RETURN },
212
+ { key: "home", code: Event.KEY_HOME },
213
+ { key: "end", code: Event.KEY_END },
214
+ { key: "backspace", code: Event.KEY_BACKSPACE },
215
+ { key: "delete", code: Event.KEY_DELETE },
216
+ { key: "space", code: 32 },
217
+ { key: "esc", code: Event.KEY_ESC },
218
+ { key: ",", code: 188 }
219
+ ].each(function(k) {
220
+ specs["'" + k.key + "' to the keyCode for the " + k.key.toUpperCase() + " key"] = function() {
221
+ this.shouldMatch({ key: k.key }, { keyCode: k.code });
222
+ };
223
+ });
224
+ return specs;
225
+ }
226
+ }
227
+ });