riojs 0.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +20 -0
- data/README.rdoc +24 -0
- data/VERSION +1 -0
- data/bin/rio +5 -0
- data/generators/rio_app/USAGE +19 -0
- data/generators/rio_app/rio_app_generator.rb +40 -0
- data/generators/rio_app/templates/app.build +10 -0
- data/generators/rio_app/templates/app.css +0 -0
- data/generators/rio_app/templates/app.js +20 -0
- data/generators/rio_app/templates/app_view.html.erb +19 -0
- data/generators/rio_app/templates/fixture.js +4 -0
- data/generators/rio_app/templates/rio.html.erb +18 -0
- data/generators/rio_app/templates/rio_controller.rb +2 -0
- data/generators/rio_app/templates/spec.js +7 -0
- data/generators/rio_component/USAGE +13 -0
- data/generators/rio_component/rio_component_generator.rb +16 -0
- data/generators/rio_component/templates/component.css +0 -0
- data/generators/rio_component/templates/component.js +11 -0
- data/generators/rio_component/templates/fixture.js +3 -0
- data/generators/rio_component/templates/spec.js +6 -0
- data/generators/rio_model/USAGE +12 -0
- data/generators/rio_model/rio_model_generator.rb +21 -0
- data/generators/rio_model/templates/fixture.js +3 -0
- data/generators/rio_model/templates/model.js +9 -0
- data/generators/rio_model/templates/spec.js +6 -0
- data/generators/rio_page/USAGE +14 -0
- data/generators/rio_page/rio_page_generator.rb +16 -0
- data/generators/rio_page/templates/fixture.js +3 -0
- data/generators/rio_page/templates/page.css +12 -0
- data/generators/rio_page/templates/page.js +12 -0
- data/generators/rio_page/templates/page.jst +64 -0
- data/generators/rio_page/templates/spec.js +6 -0
- data/generators/rio_resource/USAGE +20 -0
- data/generators/rio_resource/rio_resource_generator.rb +10 -0
- data/generators/rio_resource/templates/controller.rb +3 -0
- data/init.rb +4 -0
- data/install/config/juggernaut_hosts.yml +18 -0
- data/install/lib/tasks/rio.rake +1 -0
- data/install/script/rio_server +37 -0
- data/lib/rio/autospec.rb +86 -0
- data/lib/rio/install.rb +90 -0
- data/lib/rio/juggernaut.rb +212 -0
- data/lib/rio/path.rb +3 -0
- data/lib/rio/rio_compressor.rb +219 -0
- data/lib/rio/rio_file_controller.rb +16 -0
- data/lib/rio/rio_on_rails.rb +586 -0
- data/lib/rio/rio_proxy_controller.rb +60 -0
- data/lib/rio/rio_push_controller.rb +48 -0
- data/lib/rio/rio_routes.rb +24 -0
- data/lib/rio/rio_spec_controller.rb +70 -0
- data/lib/riojs.rb +14 -0
- data/lib/tasks/rio.rb +63 -0
- data/public/images/background-chiffon.png +0 -0
- data/public/images/button-gradient-overlay-down.png +0 -0
- data/public/images/button-gradient-overlay.png +0 -0
- data/public/images/icons/add.png +0 -0
- data/public/images/icons/error-big.png +0 -0
- data/public/images/icons/warning-big.png +0 -0
- data/public/images/rio-logo-big.png +0 -0
- data/public/images/rio-logo.png +0 -0
- data/public/images/splitter-handle-horizontal.png +0 -0
- data/public/images/splitter-handle-vertical.png +0 -0
- data/public/images/tab-bar-gradient-overlay.png +0 -0
- data/public/images/title-gradient-overlay.png +0 -0
- data/public/images/trash.gif +0 -0
- data/public/javascripts/components/accordion.js +144 -0
- data/public/javascripts/components/alert_box.js +59 -0
- data/public/javascripts/components/base.js +47 -0
- data/public/javascripts/components/box.js +63 -0
- data/public/javascripts/components/button.js +98 -0
- data/public/javascripts/components/checkbox.js +44 -0
- data/public/javascripts/components/container.js +265 -0
- data/public/javascripts/components/grid_view.js +107 -0
- data/public/javascripts/components/image.js +19 -0
- data/public/javascripts/components/input.js +171 -0
- data/public/javascripts/components/label.js +15 -0
- data/public/javascripts/components/lightbox.js +160 -0
- data/public/javascripts/components/link.js +43 -0
- data/public/javascripts/components/list_item.js +44 -0
- data/public/javascripts/components/list_view.js +192 -0
- data/public/javascripts/components/marquee.js +131 -0
- data/public/javascripts/components/menu.js +89 -0
- data/public/javascripts/components/notification.js +75 -0
- data/public/javascripts/components/overlay.js +134 -0
- data/public/javascripts/components/panel.js +146 -0
- data/public/javascripts/components/radio.js +46 -0
- data/public/javascripts/components/splitter.js +65 -0
- data/public/javascripts/components/tab_bar.js +64 -0
- data/public/javascripts/components/tab_panel.js +57 -0
- data/public/javascripts/components/textarea.js +223 -0
- data/public/javascripts/components/toggle_button.js +22 -0
- data/public/javascripts/components/tooltip.js +80 -0
- data/public/javascripts/lib/application.js +482 -0
- data/public/javascripts/lib/attr.js +760 -0
- data/public/javascripts/lib/benchmark.js +235 -0
- data/public/javascripts/lib/blank.html +39 -0
- data/public/javascripts/lib/boot.js +300 -0
- data/public/javascripts/lib/clipboard.js +96 -0
- data/public/javascripts/lib/collection_entity.js +46 -0
- data/public/javascripts/lib/component.js +129 -0
- data/public/javascripts/lib/console.js +75 -0
- data/public/javascripts/lib/console/apps/console.build +43 -0
- data/public/javascripts/lib/console/apps/console.js +28 -0
- data/public/javascripts/lib/console/blank.html +39 -0
- data/public/javascripts/lib/console/components/benchmark.js +196 -0
- data/public/javascripts/lib/console/components/console.js +352 -0
- data/public/javascripts/lib/console/components/dependencies_list.js +17 -0
- data/public/javascripts/lib/console/components/docs.js +66 -0
- data/public/javascripts/lib/console/components/playground.js +30 -0
- data/public/javascripts/lib/console/console.html +27 -0
- data/public/javascripts/lib/console/console_commands.js +287 -0
- data/public/javascripts/lib/console/console_commands.js.rej +21 -0
- data/public/javascripts/lib/console/console_mixin.js +22 -0
- data/public/javascripts/lib/console/docs/files.html +579 -0
- data/public/javascripts/lib/console/docs/index.html +323 -0
- data/public/javascripts/lib/console/docs/symbols/Object.html +291 -0
- data/public/javascripts/lib/console/docs/symbols/_global_.html +413 -0
- data/public/javascripts/lib/console/docs/symbols/rio.AIM.html +490 -0
- data/public/javascripts/lib/console/docs/symbols/rio.Application.html +841 -0
- data/public/javascripts/lib/console/docs/symbols/rio.Attr.html +1075 -0
- data/public/javascripts/lib/console/docs/symbols/rio.Binding.html +272 -0
- data/public/javascripts/lib/console/docs/symbols/rio.Component.html +419 -0
- data/public/javascripts/lib/console/docs/symbols/rio.Cookie.html +543 -0
- data/public/javascripts/lib/console/docs/symbols/rio.DelayedTask#initialize.html +270 -0
- data/public/javascripts/lib/console/docs/symbols/rio.DelayedTask.html +391 -0
- data/public/javascripts/lib/console/docs/symbols/rio.JsTemplate.html +271 -0
- data/public/javascripts/lib/console/docs/symbols/rio.Juggernaut.html +329 -0
- data/public/javascripts/lib/console/docs/symbols/rio.Model.html +822 -0
- data/public/javascripts/lib/console/docs/symbols/rio.Page.html +383 -0
- data/public/javascripts/lib/console/docs/symbols/rio.Template.html +328 -0
- data/public/javascripts/lib/console/docs/symbols/rio.Utils.html +617 -0
- data/public/javascripts/lib/console/docs/symbols/rio.html +506 -0
- data/public/javascripts/lib/console/docs/symbols/src/public_javascripts_components_base.js.html +54 -0
- data/public/javascripts/lib/console/docs/symbols/src/public_javascripts_lib_application.js.html +490 -0
- data/public/javascripts/lib/console/docs/symbols/src/public_javascripts_lib_attr.js.html +768 -0
- data/public/javascripts/lib/console/docs/symbols/src/public_javascripts_lib_boot.js.html +308 -0
- data/public/javascripts/lib/console/docs/symbols/src/public_javascripts_lib_clipboard.js.html +103 -0
- data/public/javascripts/lib/console/docs/symbols/src/public_javascripts_lib_collection_entity.js.html +53 -0
- data/public/javascripts/lib/console/docs/symbols/src/public_javascripts_lib_component.js.html +137 -0
- data/public/javascripts/lib/console/docs/symbols/src/public_javascripts_lib_cookie.js.html +81 -0
- data/public/javascripts/lib/console/docs/symbols/src/public_javascripts_lib_delayed_task.js.html +68 -0
- data/public/javascripts/lib/console/docs/symbols/src/public_javascripts_lib_file.js.html +80 -0
- data/public/javascripts/lib/console/docs/symbols/src/public_javascripts_lib_flash_detect.js.html +129 -0
- data/public/javascripts/lib/console/docs/symbols/src/public_javascripts_lib_form.js.html +95 -0
- data/public/javascripts/lib/console/docs/symbols/src/public_javascripts_lib_id.js.html +50 -0
- data/public/javascripts/lib/console/docs/symbols/src/public_javascripts_lib_inflector.js.html +167 -0
- data/public/javascripts/lib/console/docs/symbols/src/public_javascripts_lib_js_template.js.html +283 -0
- data/public/javascripts/lib/console/docs/symbols/src/public_javascripts_lib_juggernaut.js.html +303 -0
- data/public/javascripts/lib/console/docs/symbols/src/public_javascripts_lib_key_map.js.html +68 -0
- data/public/javascripts/lib/console/docs/symbols/src/public_javascripts_lib_layout_manager.js.html +175 -0
- data/public/javascripts/lib/console/docs/symbols/src/public_javascripts_lib_log.js.html +17 -0
- data/public/javascripts/lib/console/docs/symbols/src/public_javascripts_lib_model.js.html +1074 -0
- data/public/javascripts/lib/console/docs/symbols/src/public_javascripts_lib_page.js.html +246 -0
- data/public/javascripts/lib/console/docs/symbols/src/public_javascripts_lib_parameters.js.html +66 -0
- data/public/javascripts/lib/console/docs/symbols/src/public_javascripts_lib_protohack.js.html +305 -0
- data/public/javascripts/lib/console/docs/symbols/src/public_javascripts_lib_push.js.html +12 -0
- data/public/javascripts/lib/console/docs/symbols/src/public_javascripts_lib_rsh.js.html +659 -0
- data/public/javascripts/lib/console/docs/symbols/src/public_javascripts_lib_swfobject.js.html +12 -0
- data/public/javascripts/lib/console/docs/symbols/src/public_javascripts_lib_tag.js.html +60 -0
- data/public/javascripts/lib/console/docs/symbols/src/public_javascripts_lib_template.js.html +64 -0
- data/public/javascripts/lib/console/docs/symbols/src/public_javascripts_lib_theme.js.html +105 -0
- data/public/javascripts/lib/console/docs/symbols/src/public_javascripts_lib_undo.js.html +142 -0
- data/public/javascripts/lib/console/docs/symbols/src/public_javascripts_lib_utils.js.html +87 -0
- data/public/javascripts/lib/console/docs/symbols/src/public_javascripts_lib_yaml.js.html +88 -0
- data/public/javascripts/lib/console/file-small.png +0 -0
- data/public/javascripts/lib/console/green-circle.png +0 -0
- data/public/javascripts/lib/console/loading.gif +0 -0
- data/public/javascripts/lib/console/pages/console_page.js +149 -0
- data/public/javascripts/lib/console/pages/console_page.jst +27 -0
- data/public/javascripts/lib/console/red-circle.png +0 -0
- data/public/javascripts/lib/cookie.js +74 -0
- data/public/javascripts/lib/delayed_task.js +61 -0
- data/public/javascripts/lib/dependencies.js +76 -0
- data/public/javascripts/lib/environment.js +30 -0
- data/public/javascripts/lib/event.simulate.js +137 -0
- data/public/javascripts/lib/expressinstall.swf +0 -0
- data/public/javascripts/lib/file.js +72 -0
- data/public/javascripts/lib/flash_detect.js +122 -0
- data/public/javascripts/lib/flashembed.min.js +16 -0
- data/public/javascripts/lib/form.js +88 -0
- data/public/javascripts/lib/id.js +43 -0
- data/public/javascripts/lib/inflector.js +160 -0
- data/public/javascripts/lib/instrumenter.js +106 -0
- data/public/javascripts/lib/js_template.js +275 -0
- data/public/javascripts/lib/jslint.js +4950 -0
- data/public/javascripts/lib/juggernaut.js +295 -0
- data/public/javascripts/lib/juggernaut.swf +0 -0
- data/public/javascripts/lib/key_map.js +60 -0
- data/public/javascripts/lib/layout_manager.js +167 -0
- data/public/javascripts/lib/model.js +1067 -0
- data/public/javascripts/lib/page.js +238 -0
- data/public/javascripts/lib/parameters.js +59 -0
- data/public/javascripts/lib/png_fix.js +75 -0
- data/public/javascripts/lib/protohack.js +297 -0
- data/public/javascripts/lib/push.js +5 -0
- data/public/javascripts/lib/rio.build +28 -0
- data/public/javascripts/lib/rio_development.build +5 -0
- data/public/javascripts/lib/rio_lint.js +66 -0
- data/public/javascripts/lib/rsh.js +651 -0
- data/public/javascripts/lib/spec.js +545 -0
- data/public/javascripts/lib/spec_runner.js +242 -0
- data/public/javascripts/lib/swfobject.js +5 -0
- data/public/javascripts/lib/tag.js +52 -0
- data/public/javascripts/lib/undo.js +134 -0
- data/public/javascripts/lib/utils.js +80 -0
- data/public/javascripts/lib/yaml.js +80 -0
- data/public/javascripts/pages/playground_page.js +15 -0
- data/public/javascripts/prototype/builder.js +146 -0
- data/public/javascripts/prototype/controls.js +1004 -0
- data/public/javascripts/prototype/dragdrop.js +1030 -0
- data/public/javascripts/prototype/effects.js +1137 -0
- data/public/javascripts/prototype/prototype.js +4320 -0
- data/public/javascripts/prototype/slider.js +283 -0
- data/public/javascripts/prototype/sound.js +67 -0
- data/public/javascripts/specs/components/box_spec.js +6 -0
- data/public/javascripts/specs/components/checkbox_spec.js +26 -0
- data/public/javascripts/specs/components/container_spec.js +6 -0
- data/public/javascripts/specs/components/input_spec.js +71 -0
- data/public/javascripts/specs/components/panel_spec.js +6 -0
- data/public/javascripts/specs/components/radio_spec.js +40 -0
- data/public/javascripts/specs/fixtures/components/box.js +3 -0
- data/public/javascripts/specs/fixtures/components/checkbox.js +9 -0
- data/public/javascripts/specs/fixtures/components/container.js +3 -0
- data/public/javascripts/specs/fixtures/components/input.js +12 -0
- data/public/javascripts/specs/fixtures/components/menu.js +19 -0
- data/public/javascripts/specs/fixtures/components/menu_item.js +18 -0
- data/public/javascripts/specs/fixtures/components/radio.js +11 -0
- data/public/javascripts/specs/lib/application_spec.js +281 -0
- data/public/javascripts/specs/lib/attr_spec.js +1514 -0
- data/public/javascripts/specs/lib/benchmark_spec.js +361 -0
- data/public/javascripts/specs/lib/collection_entity_spec.js +131 -0
- data/public/javascripts/specs/lib/component_spec.js +86 -0
- data/public/javascripts/specs/lib/form_spec.js +171 -0
- data/public/javascripts/specs/lib/id_spec.js +21 -0
- data/public/javascripts/specs/lib/instrumenter_spec.js +5 -0
- data/public/javascripts/specs/lib/js_template_spec.js +131 -0
- data/public/javascripts/specs/lib/key_map_spec.js +227 -0
- data/public/javascripts/specs/lib/model_spec.js +2268 -0
- data/public/javascripts/specs/lib/parameters_spec.js +94 -0
- data/public/javascripts/specs/lib/spec_spec.js +943 -0
- data/public/javascripts/specs/lib/undo_spec.js +105 -0
- data/public/javascripts/specs/lib/yaml_spec.js +127 -0
- data/public/sounds/basso.wav +0 -0
- data/public/sounds/purr.wav +0 -0
- data/public/stylesheets/components/accordion.css +24 -0
- data/public/stylesheets/components/alert_box.css +35 -0
- data/public/stylesheets/components/box.css +0 -0
- data/public/stylesheets/components/button.css +39 -0
- data/public/stylesheets/components/checkbox.css +9 -0
- data/public/stylesheets/components/container.css +3 -0
- data/public/stylesheets/components/grid_view.css +52 -0
- data/public/stylesheets/components/input.css +10 -0
- data/public/stylesheets/components/label.css +3 -0
- data/public/stylesheets/components/lightbox.css +31 -0
- data/public/stylesheets/components/link.css +4 -0
- data/public/stylesheets/components/list_view.css +23 -0
- data/public/stylesheets/components/marquee.css +29 -0
- data/public/stylesheets/components/menu.css +34 -0
- data/public/stylesheets/components/notification.css +52 -0
- data/public/stylesheets/components/overlay.css +8 -0
- data/public/stylesheets/components/panel.css +36 -0
- data/public/stylesheets/components/radio.css +9 -0
- data/public/stylesheets/components/splitter.css +35 -0
- data/public/stylesheets/components/tab_bar.css +59 -0
- data/public/stylesheets/components/tab_panel.css +15 -0
- data/public/stylesheets/components/textarea.css +11 -0
- data/public/stylesheets/components/tooltip.css +10 -0
- data/public/stylesheets/console.css +151 -0
- data/public/stylesheets/css_reset.css +55 -0
- 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,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"> </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 == " ").shouldBeTrue();
|
112
|
+
},
|
113
|
+
|
114
|
+
"should properly render two spaces": function() {
|
115
|
+
var template = new rio.JsTemplate({
|
116
|
+
text: '<div rio:id="divWithSpace"> </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 == " ").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
|
+
});
|