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,242 @@
|
|
1
|
+
rio.SpecRunner = {
|
2
|
+
rootUrl: "/javascripts/specs/",
|
3
|
+
|
4
|
+
SpecPage: rio.Page.create({
|
5
|
+
methods: {
|
6
|
+
buildHtml: function() {
|
7
|
+
return rio.Tag.div();
|
8
|
+
},
|
9
|
+
|
10
|
+
addComponent: function(component) {
|
11
|
+
this.html().insert(component.html());
|
12
|
+
},
|
13
|
+
|
14
|
+
renderExamples: function(attr, env) {
|
15
|
+
this.reset();
|
16
|
+
|
17
|
+
var examplesHtml = rio.Tag.div("");
|
18
|
+
|
19
|
+
var exampleGroup = attr.examples();
|
20
|
+
|
21
|
+
Object.keys(exampleGroup).each(function(name) {
|
22
|
+
examplesHtml.insert(rio.Tag.hr());
|
23
|
+
examplesHtml.insert(rio.Tag.div(name + ":", {
|
24
|
+
style: "padding: 10px; font-style: italic; font-color: #555"
|
25
|
+
}));
|
26
|
+
var exampleHtml = exampleGroup[name].html();
|
27
|
+
var examplePosition = exampleHtml.getStyle("position");
|
28
|
+
var exampleWrapper = rio.Tag.div(exampleHtml, { style: "padding: 0px 20px 10px;" });
|
29
|
+
|
30
|
+
if (examplePosition == "absolute") {
|
31
|
+
exampleHtml.setStyle({
|
32
|
+
left: "20px",
|
33
|
+
top: "0px"
|
34
|
+
});
|
35
|
+
|
36
|
+
exampleWrapper.setStyle({
|
37
|
+
position: "relative"
|
38
|
+
});
|
39
|
+
(function() {
|
40
|
+
exampleWrapper.setStyle({
|
41
|
+
height: (exampleHtml.totalHeight()) + "px"
|
42
|
+
});
|
43
|
+
}).defer();
|
44
|
+
}
|
45
|
+
|
46
|
+
examplesHtml.insert(exampleWrapper);
|
47
|
+
});
|
48
|
+
examplesHtml.insert(rio.Tag.hr());
|
49
|
+
var backLink = rio.Tag.a("Back to application", {
|
50
|
+
href: "#",
|
51
|
+
onclick: "return false;"
|
52
|
+
});
|
53
|
+
backLink.observe("click", function() {
|
54
|
+
env.rio.app.reboot();
|
55
|
+
});
|
56
|
+
examplesHtml.insert(rio.Tag.div(backLink, {
|
57
|
+
style: "padding: 10px"
|
58
|
+
}));
|
59
|
+
|
60
|
+
this.html().insert(examplesHtml);
|
61
|
+
},
|
62
|
+
|
63
|
+
reset: function() {
|
64
|
+
this.html().update("");
|
65
|
+
}
|
66
|
+
}
|
67
|
+
}),
|
68
|
+
|
69
|
+
specPage: function() {
|
70
|
+
if (!this._specPage) { this._specPage = new this.SpecPage(); }
|
71
|
+
return this._specPage;
|
72
|
+
},
|
73
|
+
|
74
|
+
loadSpecPage: function(env) {
|
75
|
+
env.rio.app.clearPage();
|
76
|
+
env.Element.body().insert(this.specPage().html());
|
77
|
+
this.specPage().render();
|
78
|
+
env.rio.app.setCurrentPage(this.specPage());
|
79
|
+
},
|
80
|
+
|
81
|
+
unloadSpecPage: function(env) {
|
82
|
+
env.rio.app.reboot();
|
83
|
+
},
|
84
|
+
|
85
|
+
renderExamples: function(attr, options) {
|
86
|
+
this.loadSpecPage(options.env);
|
87
|
+
this.specPage().renderExamples(attr, options.env);
|
88
|
+
},
|
89
|
+
|
90
|
+
loadFixtures: function(options) {
|
91
|
+
rio.Fixtures.loadFixtures(options);
|
92
|
+
},
|
93
|
+
|
94
|
+
loadFixture: function(options, quietIfNotFound) {
|
95
|
+
rio.Fixtures.loadFixture(options, quietIfNotFound);
|
96
|
+
},
|
97
|
+
|
98
|
+
runAll: function(options) {
|
99
|
+
rio.File.open("/rio/specs", {
|
100
|
+
onSuccess: function(specData) {
|
101
|
+
try {
|
102
|
+
specData = eval("[" + specData + "]")[0];
|
103
|
+
} catch(e) {
|
104
|
+
options.stdout(e);
|
105
|
+
}
|
106
|
+
this.runSpecs({
|
107
|
+
specs: options.env.rio.boot.loadedFiles,
|
108
|
+
specData: specData,
|
109
|
+
stdout: options.stdout,
|
110
|
+
env: options.env,
|
111
|
+
context: options.context,
|
112
|
+
syntaxChecker: options.syntaxChecker,
|
113
|
+
onComplete: options.onComplete
|
114
|
+
});
|
115
|
+
}.bind(this)
|
116
|
+
});
|
117
|
+
},
|
118
|
+
|
119
|
+
runSpecs: function(options) {
|
120
|
+
this.loadSpecPage(options.env);
|
121
|
+
|
122
|
+
options.specs.each(function(specName) {
|
123
|
+
|
124
|
+
var specFunction = options.specData[specName + "_spec"];
|
125
|
+
if (specFunction) {
|
126
|
+
options.stdout("loading spec: " + specName);
|
127
|
+
var spec = specFunction();
|
128
|
+
|
129
|
+
try {
|
130
|
+
options.syntaxChecker(spec, specName);
|
131
|
+
rio.Spec.executeSpec(spec, options.stdout, options.env, options.context, rio.SpecRunner.specPage(), function(c) {
|
132
|
+
if (typeof options.env.execScript != 'undefined') {
|
133
|
+
options.env.execScript(c);
|
134
|
+
} else {
|
135
|
+
options.env.eval(c);
|
136
|
+
}
|
137
|
+
});
|
138
|
+
} catch (e) {
|
139
|
+
options.env.rio.log("Error running spec (" + specName + ") - " + e + " (" + e.fileName + " - " + e.lineNumber + ")", "errorLogItem", "> ");
|
140
|
+
}
|
141
|
+
}
|
142
|
+
}.bind(this));
|
143
|
+
|
144
|
+
this.unloadSpecPage(options.env);
|
145
|
+
options.onComplete();
|
146
|
+
},
|
147
|
+
|
148
|
+
run: function(options) {
|
149
|
+
options.env.rio.File.execute(
|
150
|
+
options.env.rio.boot.root + options.path + ".js", { asynchronous: false }
|
151
|
+
);
|
152
|
+
this.loadFixture(options, true);
|
153
|
+
new Ajax.Request(this.rootUrl + options.path + "_spec.js?" + Math.random(), {
|
154
|
+
asynchronous: true,
|
155
|
+
method: 'get',
|
156
|
+
evalJSON: false,
|
157
|
+
evalJS: false,
|
158
|
+
onSuccess: function(response) {
|
159
|
+
if (!options.skipSpecPage) { this.loadSpecPage(options.env); }
|
160
|
+
options.stdout("loading spec: " + options.path);
|
161
|
+
var spec = response.responseText;
|
162
|
+
|
163
|
+
try {
|
164
|
+
options.syntaxChecker(spec, options.path + "_spec");
|
165
|
+
rio.Spec.executeSpec(spec, options.stdout, options.env, options.context, rio.SpecRunner.specPage(), function(c) {
|
166
|
+
if (typeof options.env.execScript != 'undefined') {
|
167
|
+
options.env.execScript(c);
|
168
|
+
} else {
|
169
|
+
options.env.eval(c);
|
170
|
+
}
|
171
|
+
});
|
172
|
+
} catch (e) {
|
173
|
+
options.env.rio.log("Error running spec (" + specName + ") - " + e + " (" + e.fileName + " - " + e.lineNumber + ")", "errorLogItem", "> ");
|
174
|
+
}
|
175
|
+
|
176
|
+
if (!options.skipSpecPage) { this.unloadSpecPage(options.env); }
|
177
|
+
}.bind(this),
|
178
|
+
onComplete: function() {
|
179
|
+
(options.onComplete || Prototype.emptyFunction)();
|
180
|
+
}
|
181
|
+
});
|
182
|
+
}
|
183
|
+
};
|
184
|
+
|
185
|
+
rio.Fixtures = {
|
186
|
+
loadFixtures: function(options) {
|
187
|
+
rio.File.json("/rio/fixtures", {
|
188
|
+
onSuccess: function(fixtures) {
|
189
|
+
var oldExample = options.env.example;
|
190
|
+
try {
|
191
|
+
options.env.example = function(attr, name) {
|
192
|
+
return {
|
193
|
+
_EXAMPLE: true,
|
194
|
+
attr: attr,
|
195
|
+
name: name
|
196
|
+
};
|
197
|
+
};
|
198
|
+
options.env.rio.boot.loadedFiles.each(function(file) {
|
199
|
+
var fixture = fixtures["fixtures/" + file];
|
200
|
+
if (fixture) {
|
201
|
+
try {
|
202
|
+
options.env.eval(fixture());
|
203
|
+
} catch(e) {
|
204
|
+
options.env.rio.log("Error loading fixture (" + file + ") - " + e, "errorLogItem", "> ");
|
205
|
+
}
|
206
|
+
}
|
207
|
+
});
|
208
|
+
} finally {
|
209
|
+
options.env.example = oldExample;
|
210
|
+
}
|
211
|
+
}.bind(this)
|
212
|
+
});
|
213
|
+
},
|
214
|
+
|
215
|
+
loadFixture: function(options, quietIfNotFound) {
|
216
|
+
rio.File.open("/javascripts/specs/fixtures/" + options.path + ".js", {
|
217
|
+
asynchronous: false,
|
218
|
+
onSuccess: function(fixture) {
|
219
|
+
var example = function(attr, name) {
|
220
|
+
return {
|
221
|
+
_EXAMPLE: true,
|
222
|
+
attr: attr,
|
223
|
+
name: name
|
224
|
+
};
|
225
|
+
};
|
226
|
+
var exampleStub = new rio.Stub(options.env, "example").withValue(example);
|
227
|
+
try {
|
228
|
+
options.env.eval(fixture);
|
229
|
+
} catch(e) {
|
230
|
+
options.env.rio.log("Error loading fixture (" + options.path + ") - " + e, "errorLogItem", "> ");
|
231
|
+
} finally {
|
232
|
+
exampleStub.release();
|
233
|
+
}
|
234
|
+
}.bind(this),
|
235
|
+
onFailure: function(){
|
236
|
+
if (!quietIfNotFound) {
|
237
|
+
options.env.rio.log("Error loading fixture (" + options.path + ") - ", "errorLogItem", "> ");
|
238
|
+
}
|
239
|
+
}
|
240
|
+
});
|
241
|
+
}
|
242
|
+
};
|
@@ -0,0 +1,5 @@
|
|
1
|
+
/* SWFObject v2.0 <http://code.google.com/p/swfobject/>
|
2
|
+
Copyright (c) 2007 Geoff Stearns, Michael Williams, and Bobby van der Sluis
|
3
|
+
This software is released under the MIT License <http://www.opensource.org/licenses/mit-license.php>
|
4
|
+
*/
|
5
|
+
rio.swfobject=function(){var Z="undefined",P="object",B="Shockwave Flash",h="ShockwaveFlash.ShockwaveFlash",W="application/x-shockwave-flash",K="SWFObjectExprInst",G=window,g=document,N=navigator,f=[],H=[],Q=null,L=null,T=null,S=false,C=false;var a=function(){var l=typeof g.getElementById!=Z&&typeof g.getElementsByTagName!=Z&&typeof g.createElement!=Z&&typeof g.appendChild!=Z&&typeof g.replaceChild!=Z&&typeof g.removeChild!=Z&&typeof g.cloneNode!=Z,t=[0,0,0],n=null;if(typeof N.plugins!=Z&&typeof N.plugins[B]==P){n=N.plugins[B].description;if(n){n=n.replace(/^.*\s+(\S+\s+\S+$)/,"$1");t[0]=parseInt(n.replace(/^(.*)\..*$/,"$1"),10);t[1]=parseInt(n.replace(/^.*\.(.*)\s.*$/,"$1"),10);t[2]=/r/.test(n)?parseInt(n.replace(/^.*r(.*)$/,"$1"),10):0}}else{if(typeof G.ActiveXObject!=Z){var o=null,s=false;try{o=new ActiveXObject(h+".7")}catch(k){try{o=new ActiveXObject(h+".6");t=[6,0,21];o.AllowScriptAccess="always"}catch(k){if(t[0]==6){s=true}}if(!s){try{o=new ActiveXObject(h)}catch(k){}}}if(!s&&o){try{n=o.GetVariable("$version");if(n){n=n.split(" ")[1].split(",");t=[parseInt(n[0],10),parseInt(n[1],10),parseInt(n[2],10)]}}catch(k){}}}}var v=N.userAgent.toLowerCase(),j=N.platform.toLowerCase(),r=/webkit/.test(v)?parseFloat(v.replace(/^.*webkit\/(\d+(\.\d+)?).*$/,"$1")):false,i=false,q=j?/win/.test(j):/win/.test(v),m=j?/mac/.test(j):/mac/.test(v);/*@cc_on i=true;@if(@_win32)q=true;@elif(@_mac)m=true;@end@*/return{w3cdom:l,pv:t,webkit:r,ie:i,win:q,mac:m}}();var e=function(){if(!a.w3cdom){return }J(I);if(a.ie&&a.win){try{g.write("<script id=__ie_ondomload defer=true src=//:><\/script>");var i=c("__ie_ondomload");if(i){i.onreadystatechange=function(){if(this.readyState=="complete"){this.parentNode.removeChild(this);V()}}}}catch(j){}}if(a.webkit&&typeof g.readyState!=Z){Q=setInterval(function(){if(/loaded|complete/.test(g.readyState)){V()}},10)}if(typeof g.addEventListener!=Z){g.addEventListener("DOMContentLoaded",V,null)}M(V)}();function V(){if(S){return }if(a.ie&&a.win){var m=Y("span");try{var l=g.getElementsByTagName("body")[0].appendChild(m);l.parentNode.removeChild(l)}catch(n){return }}S=true;if(Q){clearInterval(Q);Q=null}var j=f.length;for(var k=0;k<j;k++){f[k]()}}function J(i){if(S){i()}else{f[f.length]=i}}function M(j){if(typeof G.addEventListener!=Z){G.addEventListener("load",j,false)}else{if(typeof g.addEventListener!=Z){g.addEventListener("load",j,false)}else{if(typeof G.attachEvent!=Z){G.attachEvent("onload",j)}else{if(typeof G.onload=="function"){var i=G.onload;G.onload=function(){i();j()}}else{G.onload=j}}}}}function I(){var l=H.length;for(var j=0;j<l;j++){var m=H[j].id;if(a.pv[0]>0){var k=c(m);if(k){H[j].width=k.getAttribute("width")?k.getAttribute("width"):"0";H[j].height=k.getAttribute("height")?k.getAttribute("height"):"0";if(O(H[j].swfVersion)){if(a.webkit&&a.webkit<312){U(k)}X(m,true)}else{if(H[j].expressInstall&&!C&&O("6.0.65")&&(a.win||a.mac)){D(H[j])}else{d(k)}}}}else{X(m,true)}}}function U(m){var k=m.getElementsByTagName(P)[0];if(k){var p=Y("embed"),r=k.attributes;if(r){var o=r.length;for(var n=0;n<o;n++){if(r[n].nodeName.toLowerCase()=="data"){p.setAttribute("src",r[n].nodeValue)}else{p.setAttribute(r[n].nodeName,r[n].nodeValue)}}}var q=k.childNodes;if(q){var s=q.length;for(var l=0;l<s;l++){if(q[l].nodeType==1&&q[l].nodeName.toLowerCase()=="param"){p.setAttribute(q[l].getAttribute("name"),q[l].getAttribute("value"))}}}m.parentNode.replaceChild(p,m)}}function F(i){if(a.ie&&a.win&&O("8.0.0")){G.attachEvent("onunload",function(){var k=c(i);if(k){for(var j in k){if(typeof k[j]=="function"){k[j]=function(){}}}k.parentNode.removeChild(k)}})}}function D(j){C=true;var o=c(j.id);if(o){if(j.altContentId){var l=c(j.altContentId);if(l){L=l;T=j.altContentId}}else{L=b(o)}if(!(/%$/.test(j.width))&&parseInt(j.width,10)<310){j.width="310"}if(!(/%$/.test(j.height))&&parseInt(j.height,10)<137){j.height="137"}g.title=g.title.slice(0,47)+" - Flash Player Installation";var n=a.ie&&a.win?"ActiveX":"PlugIn",k=g.title,m="MMredirectURL="+G.location+"&MMplayerType="+n+"&MMdoctitle="+k,p=j.id;if(a.ie&&a.win&&o.readyState!=4){var i=Y("div");p+="SWFObjectNew";i.setAttribute("id",p);o.parentNode.insertBefore(i,o);o.style.display="none";G.attachEvent("onload",function(){o.parentNode.removeChild(o)})}R({data:j.expressInstall,id:K,width:j.width,height:j.height},{flashvars:m},p)}}function d(j){if(a.ie&&a.win&&j.readyState!=4){var i=Y("div");j.parentNode.insertBefore(i,j);i.parentNode.replaceChild(b(j),i);j.style.display="none";G.attachEvent("onload",function(){j.parentNode.removeChild(j)})}else{j.parentNode.replaceChild(b(j),j)}}function b(n){var m=Y("div");if(a.win&&a.ie){m.innerHTML=n.innerHTML}else{var k=n.getElementsByTagName(P)[0];if(k){var o=k.childNodes;if(o){var j=o.length;for(var l=0;l<j;l++){if(!(o[l].nodeType==1&&o[l].nodeName.toLowerCase()=="param")&&!(o[l].nodeType==8)){m.appendChild(o[l].cloneNode(true))}}}}}return m}function R(AE,AC,q){var p,t=c(q);if(typeof AE.id==Z){AE.id=q}if(a.ie&&a.win){var AD="";for(var z in AE){if(AE[z]!=Object.prototype[z]){if(z=="data"){AC.movie=AE[z]}else{if(z.toLowerCase()=="styleclass"){AD+=' class="'+AE[z]+'"'}else{if(z!="classid"){AD+=" "+z+'="'+AE[z]+'"'}}}}}var AB="";for(var y in AC){if(AC[y]!=Object.prototype[y]){AB+='<param name="'+y+'" value="'+AC[y]+'" />'}}t.outerHTML='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"'+AD+">"+AB+"</object>";F(AE.id);p=c(AE.id)}else{if(a.webkit&&a.webkit<312){var AA=Y("embed");AA.setAttribute("type",W);for(var x in AE){if(AE[x]!=Object.prototype[x]){if(x=="data"){AA.setAttribute("src",AE[x])}else{if(x.toLowerCase()=="styleclass"){AA.setAttribute("class",AE[x])}else{if(x!="classid"){AA.setAttribute(x,AE[x])}}}}}for(var w in AC){if(AC[w]!=Object.prototype[w]){if(w!="movie"){AA.setAttribute(w,AC[w])}}}t.parentNode.replaceChild(AA,t);p=AA}else{var s=Y(P);s.setAttribute("type",W);for(var v in AE){if(AE[v]!=Object.prototype[v]){if(v.toLowerCase()=="styleclass"){s.setAttribute("class",AE[v])}else{if(v!="classid"){s.setAttribute(v,AE[v])}}}}for(var u in AC){if(AC[u]!=Object.prototype[u]&&u!="movie"){E(s,u,AC[u])}}t.parentNode.replaceChild(s,t);p=s}}return p}function E(k,i,j){var l=Y("param");l.setAttribute("name",i);l.setAttribute("value",j);k.appendChild(l)}function c(i){return g.getElementById(i)}function Y(i){return g.createElement(i)}function O(k){var j=a.pv,i=k.split(".");i[0]=parseInt(i[0],10);i[1]=parseInt(i[1],10);i[2]=parseInt(i[2],10);return(j[0]>i[0]||(j[0]==i[0]&&j[1]>i[1])||(j[0]==i[0]&&j[1]==i[1]&&j[2]>=i[2]))?true:false}function A(m,j){if(a.ie&&a.mac){return }var l=g.getElementsByTagName("head")[0],k=Y("style");k.setAttribute("type","text/css");k.setAttribute("media","screen");if(!(a.ie&&a.win)&&typeof g.createTextNode!=Z){k.appendChild(g.createTextNode(m+" {"+j+"}"))}l.appendChild(k);if(a.ie&&a.win&&typeof g.styleSheets!=Z&&g.styleSheets.length>0){var i=g.styleSheets[g.styleSheets.length-1];if(typeof i.addRule==P){i.addRule(m,j)}}}function X(k,i){var j=i?"visible":"hidden";if(S){c(k).style.visibility=j}else{A("#"+k,"visibility:"+j)}}return{registerObject:function(l,i,k){if(!a.w3cdom||!l||!i){return }var j={};j.id=l;j.swfVersion=i;j.expressInstall=k?k:false;H[H.length]=j;X(l,false)},getObjectById:function(l){var i=null;if(a.w3cdom&&S){var j=c(l);if(j){var k=j.getElementsByTagName(P)[0];if(!k||(k&&typeof j.SetVariable!=Z)){i=j}else{if(typeof k.SetVariable!=Z){i=k}}}}return i},embedSWF:function(n,u,r,t,j,m,k,p,s){if(!a.w3cdom||!n||!u||!r||!t||!j){return }r+="";t+="";if(O(j)){X(u,false);var q=(typeof s==P)?s:{};q.data=n;q.width=r;q.height=t;var o=(typeof p==P)?p:{};if(typeof k==P){for(var l in k){if(k[l]!=Object.prototype[l]){if(typeof o.flashvars!=Z){o.flashvars+="&"+l+"="+k[l]}else{o.flashvars=l+"="+k[l]}}}}J(function(){R(q,o,u);if(q.id==u){X(u,true)}})}else{if(m&&!C&&O("6.0.65")&&(a.win||a.mac)){X(u,false);J(function(){var i={};i.id=i.altContentId=u;i.width=r;i.height=t;i.expressInstall=m;D(i)})}}},getFlashPlayerVersion:function(){return{major:a.pv[0],minor:a.pv[1],release:a.pv[2]}},hasFlashPlayerVersion:O,createSWF:function(k,j,i){if(a.w3cdom&&S){return R(k,j,i)}else{return undefined}},createCSS:function(j,i){if(a.w3cdom){A(j,i)}},addDomLoadEvent:J,addLoadEvent:M,getQueryParamValue:function(m){var l=g.location.search||g.location.hash;if(m==null){return l}if(l){var k=l.substring(1).split("&");for(var j=0;j<k.length;j++){if(k[j].substring(0,k[j].indexOf("="))==m){return k[j].substring((k[j].indexOf("=")+1))}}}return""},expressInstallCallback:function(){if(C&&L){var i=c(K);if(i){i.parentNode.replaceChild(L,i);if(T){X(T,true);if(a.ie&&a.win){L.style.display="block"}}L=null;T=null;C=false}}}}}();
|
@@ -0,0 +1,52 @@
|
|
1
|
+
rio.Tag = {
|
2
|
+
build: function (tag, body, args) {
|
3
|
+
args = args || {};
|
4
|
+
if (Object.isArray(body)) {
|
5
|
+
for (var i=body.length; i--;) {
|
6
|
+
var elt = body[i];
|
7
|
+
body[i] = elt.html ? elt.html() : elt;
|
8
|
+
}
|
9
|
+
} else if (body && body.html) {
|
10
|
+
body = body.html();
|
11
|
+
}
|
12
|
+
|
13
|
+
var node = Builder.node(tag, args, body);
|
14
|
+
|
15
|
+
return $(node);
|
16
|
+
},
|
17
|
+
|
18
|
+
tags: [
|
19
|
+
"span",
|
20
|
+
"div",
|
21
|
+
"table",
|
22
|
+
"thead",
|
23
|
+
"tbody",
|
24
|
+
"tr",
|
25
|
+
"td",
|
26
|
+
"th",
|
27
|
+
"h1",
|
28
|
+
"h2",
|
29
|
+
"hr",
|
30
|
+
"br",
|
31
|
+
"a",
|
32
|
+
"p",
|
33
|
+
"textarea",
|
34
|
+
"label",
|
35
|
+
"input",
|
36
|
+
"button",
|
37
|
+
"img",
|
38
|
+
"option",
|
39
|
+
"pre",
|
40
|
+
"ul",
|
41
|
+
"li",
|
42
|
+
"iframe",
|
43
|
+
"link",
|
44
|
+
"script",
|
45
|
+
"select"
|
46
|
+
]
|
47
|
+
};
|
48
|
+
(function() {
|
49
|
+
rio.Tag.tags.each(function(tag) {
|
50
|
+
rio.Tag[tag] = rio.Tag.build.curry(tag);
|
51
|
+
});
|
52
|
+
})();
|
@@ -0,0 +1,134 @@
|
|
1
|
+
rio.Undo = {
|
2
|
+
setQueue: function(queue) {
|
3
|
+
if (!this._bindingPoints) {
|
4
|
+
this._bindingPoints = new (rio.Attr.create({
|
5
|
+
attrAccessors: [
|
6
|
+
"queue",
|
7
|
+
["hasUndos", false],
|
8
|
+
["hasRedos", false]
|
9
|
+
]
|
10
|
+
}))();
|
11
|
+
|
12
|
+
this._bindingPoints.bind("queue.undos", {
|
13
|
+
empty: function(empty) {
|
14
|
+
this._bindingPoints.setHasUndos(!empty);
|
15
|
+
}.bind(this)
|
16
|
+
});
|
17
|
+
this._bindingPoints.bind("queue.redos", {
|
18
|
+
empty: function(empty) {
|
19
|
+
this._bindingPoints.setHasRedos(!empty);
|
20
|
+
}.bind(this)
|
21
|
+
});
|
22
|
+
|
23
|
+
this.hasUndos = this._bindingPoints.hasUndos;
|
24
|
+
this.hasRedos = this._bindingPoints.hasRedos;
|
25
|
+
}
|
26
|
+
|
27
|
+
this._bindingPoints.setQueue(queue);
|
28
|
+
this._queue = queue;
|
29
|
+
},
|
30
|
+
|
31
|
+
undoQueueEmpty: function() {
|
32
|
+
return this._queue.getUndos().empty();
|
33
|
+
},
|
34
|
+
|
35
|
+
redoQueueEmpty: function() {
|
36
|
+
return this._queue.getRedos().empty();
|
37
|
+
},
|
38
|
+
|
39
|
+
isProcessingUndo: function() {
|
40
|
+
return this._queue.getProcessingUndo();
|
41
|
+
},
|
42
|
+
|
43
|
+
isProcessingRedo: function() {
|
44
|
+
return this._queue.getProcessingRedo();
|
45
|
+
},
|
46
|
+
|
47
|
+
setProcessingUndo: function(val) {
|
48
|
+
this._queue.setProcessingUndo(val);
|
49
|
+
},
|
50
|
+
|
51
|
+
setProcessingRedo: function(val) {
|
52
|
+
this._queue.setProcessingRedo(val);
|
53
|
+
},
|
54
|
+
|
55
|
+
registerUndo: function(undo, dontClearRedos) {
|
56
|
+
if (!dontClearRedos) {
|
57
|
+
this._queue.getRedos().clear();
|
58
|
+
}
|
59
|
+
this._queue.getUndos().push(function() {
|
60
|
+
rio.Undo.setProcessingUndo(true);
|
61
|
+
try {
|
62
|
+
undo();
|
63
|
+
} finally {
|
64
|
+
rio.Undo.setProcessingUndo(false);
|
65
|
+
}
|
66
|
+
});
|
67
|
+
},
|
68
|
+
|
69
|
+
registerRedo: function(redo) {
|
70
|
+
this._queue.getRedos().push(function() {
|
71
|
+
rio.Undo.setProcessingRedo(true);
|
72
|
+
try {
|
73
|
+
redo();
|
74
|
+
} finally {
|
75
|
+
rio.Undo.setProcessingRedo(false);
|
76
|
+
}
|
77
|
+
});
|
78
|
+
},
|
79
|
+
|
80
|
+
undo: function() {
|
81
|
+
this._doAction("undo");
|
82
|
+
},
|
83
|
+
|
84
|
+
redo: function() {
|
85
|
+
this._doAction("redo");
|
86
|
+
},
|
87
|
+
|
88
|
+
_actionProgress: false,
|
89
|
+
_actionQueue: [],
|
90
|
+
_doAction: function(action) {
|
91
|
+
if (this._actionProgress) {
|
92
|
+
this._actionQueue.push(this[action].bind(this));
|
93
|
+
return;
|
94
|
+
}
|
95
|
+
this._actionProgress = true;
|
96
|
+
try {
|
97
|
+
var toDo = this._queue[("get-" + action + "s").camelize()]().pop();
|
98
|
+
if (toDo) {
|
99
|
+
rio.Attr.transaction(function() {
|
100
|
+
toDo();
|
101
|
+
});
|
102
|
+
}
|
103
|
+
} finally {
|
104
|
+
this._afterAction();
|
105
|
+
}
|
106
|
+
},
|
107
|
+
|
108
|
+
_doAfterAction: function() {
|
109
|
+
(function() {
|
110
|
+
this._afterAction();
|
111
|
+
}.bind(this)).defer();
|
112
|
+
},
|
113
|
+
|
114
|
+
_afterAction: function() {
|
115
|
+
var next = this._actionQueue.shift();
|
116
|
+
this._actionProgress = false;
|
117
|
+
if (next) {
|
118
|
+
next();
|
119
|
+
}
|
120
|
+
},
|
121
|
+
|
122
|
+
toString: function() { return "Undo"; }
|
123
|
+
};
|
124
|
+
|
125
|
+
rio.UndoQueue = rio.Attr.create({
|
126
|
+
attrAccessors: [
|
127
|
+
["undos", []],
|
128
|
+
["redos", []],
|
129
|
+
["processingUndo", false],
|
130
|
+
["processingRedo", false]
|
131
|
+
]
|
132
|
+
});
|
133
|
+
|
134
|
+
rio.Undo.setQueue(new rio.UndoQueue());
|
@@ -0,0 +1,80 @@
|
|
1
|
+
/**
|
2
|
+
@namespace Random utility methods
|
3
|
+
*/
|
4
|
+
rio.Utils = {
|
5
|
+
/**
|
6
|
+
Alternates returning the two input arguments.
|
7
|
+
*/
|
8
|
+
cycle: function(var1, var2) {
|
9
|
+
if (!this._CYCLE_COUNT) { this._CYCLE_COUNT = 0; }
|
10
|
+
this._CYCLE_COUNT++;
|
11
|
+
return this._CYCLE_COUNT % 2 == 1 ? var1 : var2;
|
12
|
+
},
|
13
|
+
|
14
|
+
/**
|
15
|
+
Navigates to a given URL, allowing you to set the Rails-style HTTP method.
|
16
|
+
|
17
|
+
@param {String} location The url to goto
|
18
|
+
@param {String} action (optional) The HTTP verb to use. (currently supports get|delete)
|
19
|
+
@param {String} token (optional) A Rails-style authenticity token
|
20
|
+
*/
|
21
|
+
navigateTo: function(location, action, token) {
|
22
|
+
if (action == "delete") {
|
23
|
+
var f = document.createElement('form');
|
24
|
+
f.style.display = 'none';
|
25
|
+
Element.body().appendChild(f);
|
26
|
+
f.method = 'POST';
|
27
|
+
f.action = location;
|
28
|
+
var m = document.createElement('input');
|
29
|
+
m.setAttribute('type', 'hidden');
|
30
|
+
m.setAttribute('name', '_method');
|
31
|
+
m.setAttribute('value', 'delete');
|
32
|
+
f.appendChild(m);
|
33
|
+
var s = document.createElement('input');
|
34
|
+
s.setAttribute('type', 'hidden');
|
35
|
+
s.setAttribute('name', 'authenticity_token');
|
36
|
+
s.setAttribute('value', token);
|
37
|
+
f.appendChild(s);
|
38
|
+
f.submit();
|
39
|
+
} else {
|
40
|
+
document.location.href = location;
|
41
|
+
}
|
42
|
+
},
|
43
|
+
|
44
|
+
/**
|
45
|
+
Returns the singular argument if num == 1, otherwise returns the plural argument.
|
46
|
+
|
47
|
+
@param {Number} num The number to be evaluated for plurality
|
48
|
+
@param {Object} singular The return value if num == 1
|
49
|
+
@param {Object} plural The return value if num != 1
|
50
|
+
*/
|
51
|
+
pluralize: function(num, singular, plural) {
|
52
|
+
return (num == 1) ? singular : plural;
|
53
|
+
},
|
54
|
+
|
55
|
+
browserFromUserAgent: function(agt) {
|
56
|
+
agt = agt.toLowerCase();
|
57
|
+
if (agt.indexOf("opera") != -1) { return 'Opera'; }
|
58
|
+
if (agt.indexOf("firefox") != -1) { return 'Firefox'; }
|
59
|
+
if (agt.indexOf("safari") != -1) { return 'Safari'; }
|
60
|
+
if (agt.indexOf("msie") != -1) { return 'IE'; }
|
61
|
+
if (agt.indexOf("chrome") != -1) { return 'Chrome'; }
|
62
|
+
return "Unknown";
|
63
|
+
},
|
64
|
+
|
65
|
+
osFromUserAgent: function(agt) {
|
66
|
+
agt = agt.toLowerCase();
|
67
|
+
if (agt.indexOf("win") != -1) { return 'Windows'; }
|
68
|
+
if (agt.indexOf("mac") != -1) { return 'Mac'; }
|
69
|
+
if (agt.indexOf("linux") != -1) { return 'Linux'; }
|
70
|
+
return "Unknown";
|
71
|
+
},
|
72
|
+
|
73
|
+
baseUrl: function() {
|
74
|
+
return document.location.protocol + "//" + document.location.host;
|
75
|
+
},
|
76
|
+
|
77
|
+
urlWithoutHash: function() {
|
78
|
+
return this.baseUrl() + document.location.pathname;
|
79
|
+
}
|
80
|
+
};
|