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,482 @@
|
|
1
|
+
/**
|
2
|
+
@class
|
3
|
+
|
4
|
+
Application is used to create new rio application classes. It provides functionality for dependency management,
|
5
|
+
routing, history management and page management.
|
6
|
+
|
7
|
+
@extends rio.Attr
|
8
|
+
*/
|
9
|
+
rio.Application = {
|
10
|
+
/**
|
11
|
+
Creates an instance of rio.Application.
|
12
|
+
|
13
|
+
@param {String} name (optional) The name of this Application. Used primarily for testing reports.
|
14
|
+
@param {Object} extends (optional) An Attr class to use as a superclass.
|
15
|
+
@param {Object} args (optional) The definition of the class.
|
16
|
+
@returns a new instance of type Application
|
17
|
+
@type rio.Application
|
18
|
+
@example
|
19
|
+
rio.apps.example = rio.Application.create({
|
20
|
+
require: ["pages/example_page"],
|
21
|
+
requireCss: ["css_reset", "example"],
|
22
|
+
routes: {
|
23
|
+
"": "examplePage"
|
24
|
+
},
|
25
|
+
attrAccessors: [],
|
26
|
+
attrReaders: [],
|
27
|
+
methods: {
|
28
|
+
initialize: function(options) {
|
29
|
+
},
|
30
|
+
|
31
|
+
examplePage: function() {
|
32
|
+
return new rio.pages.ExamplePage();
|
33
|
+
}
|
34
|
+
}
|
35
|
+
});
|
36
|
+
*/
|
37
|
+
create: function() {
|
38
|
+
var args = $A(arguments);
|
39
|
+
if (args.length > 0 && args.last() != undefined && !args.last().ATTR) {
|
40
|
+
args[args.size() - 1] = Object.extend({ noExtend: true }, args.last());
|
41
|
+
}
|
42
|
+
var app = rio.Attr.create.apply(this, args);
|
43
|
+
|
44
|
+
app.addMethods(
|
45
|
+
/**
|
46
|
+
@scope rio.Application.prototype
|
47
|
+
*/
|
48
|
+
{
|
49
|
+
|
50
|
+
/** @private */
|
51
|
+
initHistory: function() {
|
52
|
+
dhtmlHistory.initialize();
|
53
|
+
dhtmlHistory.addListener(this.applyHistoryEntry.bind(this));
|
54
|
+
},
|
55
|
+
|
56
|
+
/** @private */
|
57
|
+
applyHistoryEntry: function(location, historyData) {
|
58
|
+
if (this.__revertingTransientHistoryEntry) {
|
59
|
+
this.addHistoryEntry(this.__revertingTransientHistoryEntry[0], this.__revertingTransientHistoryEntry[1]);
|
60
|
+
this.__revertingTransientHistoryEntry = false;
|
61
|
+
} else {
|
62
|
+
this.navigateTo(location, true);
|
63
|
+
}
|
64
|
+
},
|
65
|
+
|
66
|
+
/** @private */
|
67
|
+
addHistoryEntry: function(location, transient) {
|
68
|
+
if (historyStorage.hasKey(this.getCurrentLocation()) && historyStorage.get(this.getCurrentLocation()).transient) {
|
69
|
+
this.__revertingTransientHistoryEntry = [location, transient];
|
70
|
+
history.back(1);
|
71
|
+
} else {
|
72
|
+
dhtmlHistory.add(location, { transient: transient });
|
73
|
+
}
|
74
|
+
},
|
75
|
+
|
76
|
+
/** @private */
|
77
|
+
resize: function() {
|
78
|
+
this.getCurrentPage().resize();
|
79
|
+
},
|
80
|
+
|
81
|
+
/** @private */
|
82
|
+
keyPress: function(e) {
|
83
|
+
var currentPage = this.getCurrentPage();
|
84
|
+
if (currentPage) {
|
85
|
+
this.getCurrentPage().keyPress(e);
|
86
|
+
}
|
87
|
+
},
|
88
|
+
|
89
|
+
/** @private */
|
90
|
+
keyDown: function(e) {
|
91
|
+
var keyMap = this.getKeyMap();
|
92
|
+
if (keyMap) {
|
93
|
+
keyMap.handle(e);
|
94
|
+
}
|
95
|
+
var currentPage = this.getCurrentPage();
|
96
|
+
if (currentPage) {
|
97
|
+
this.getCurrentPage()._keyDown(e);
|
98
|
+
}
|
99
|
+
},
|
100
|
+
|
101
|
+
/**
|
102
|
+
This method is called just before the page is unloaded. This can be triggered by
|
103
|
+
following a link, closing the window, using the back button, etc.
|
104
|
+
|
105
|
+
<i>This method is meant to be overriden</i>
|
106
|
+
*/
|
107
|
+
unload: function() {
|
108
|
+
// meant to be overriden
|
109
|
+
},
|
110
|
+
|
111
|
+
/** @private */
|
112
|
+
getKeyMap: function() {
|
113
|
+
if (this._keyMap) { return this._keyMap; }
|
114
|
+
if (!this.keyMap) { return; }
|
115
|
+
|
116
|
+
this._keyMap = rio.KeyMap.build(this.keyMap());
|
117
|
+
|
118
|
+
return this._keyMap;
|
119
|
+
},
|
120
|
+
|
121
|
+
/** @private */
|
122
|
+
launch: function() {
|
123
|
+
document.observe("keypress", this.keyPress.bind(this));
|
124
|
+
document.observe("keydown", this.keyDown.bind(this));
|
125
|
+
Event.observe(window, "beforeunload", this.unload.bind(this));
|
126
|
+
|
127
|
+
if (this.noRoutes()) { return; }
|
128
|
+
|
129
|
+
this.initHistory();
|
130
|
+
this.navigateTo(this.getCurrentLocation());
|
131
|
+
|
132
|
+
Event.observe(window, "resize", this.resize.bind(this));
|
133
|
+
|
134
|
+
rio.Application._afterLaunchFunctions.each(function(fcn) {
|
135
|
+
fcn(this);
|
136
|
+
});
|
137
|
+
rio.Application._afterLaunchFunctions.clear();
|
138
|
+
|
139
|
+
this._launched = true;
|
140
|
+
},
|
141
|
+
|
142
|
+
/** @private */
|
143
|
+
launched: function() {
|
144
|
+
return this._launched || false;
|
145
|
+
},
|
146
|
+
|
147
|
+
/** @private */
|
148
|
+
noRoutes: function() {
|
149
|
+
return (app.__routes == undefined) || ($H(app.__routes).keys().size() == 0);
|
150
|
+
},
|
151
|
+
|
152
|
+
/** @private */
|
153
|
+
avoidAnimation: function() {
|
154
|
+
return Prototype.Browser.IE;
|
155
|
+
},
|
156
|
+
|
157
|
+
/** @private */
|
158
|
+
matchRoutePath: function(path) {
|
159
|
+
return Object.keys(app.__routes).detect(function(routePath) {
|
160
|
+
if (routePath == "") { return true; }
|
161
|
+
var routeParts = routePath.split("/");
|
162
|
+
var pathParts = path.split("/");
|
163
|
+
var match = true;
|
164
|
+
for(var i=0; i<routeParts.length; i++) {
|
165
|
+
match = match && (routeParts[i].startsWith(":") || routeParts[i].startsWith("*") || routeParts[i] == pathParts[i]);
|
166
|
+
}
|
167
|
+
return match;
|
168
|
+
});
|
169
|
+
},
|
170
|
+
|
171
|
+
/** @private */
|
172
|
+
matchRouteTarget: function(path) {
|
173
|
+
return app.__routes[this.matchRoutePath(path)];
|
174
|
+
},
|
175
|
+
|
176
|
+
/** @private */
|
177
|
+
remainingPath: function(path) {
|
178
|
+
var match = this.matchRoutePath(path);
|
179
|
+
if (match == "") { return path; }
|
180
|
+
|
181
|
+
var matchParts = match.split("/");
|
182
|
+
var matchLength = matchParts.last().startsWith("*") ? matchParts.length - 1 : matchParts.length;
|
183
|
+
|
184
|
+
return path.split("/").slice(matchLength).join("/");
|
185
|
+
},
|
186
|
+
|
187
|
+
/** @private */
|
188
|
+
pathParts: function(path) {
|
189
|
+
var parts = {};
|
190
|
+
var pathParts = path.split("/");
|
191
|
+
var routePathParts = this.matchRoutePath(path).split("/");
|
192
|
+
for(var i=0; i<routePathParts.length; i++) {
|
193
|
+
var routePathPart = routePathParts[i];
|
194
|
+
if (routePathPart.startsWith(":") || routePathPart.startsWith("*")) {
|
195
|
+
parts[routePathPart.slice(1)] = pathParts[i];
|
196
|
+
}
|
197
|
+
}
|
198
|
+
return parts;
|
199
|
+
},
|
200
|
+
|
201
|
+
/** @private */
|
202
|
+
navigateTo: function(path, noHistoryEntry) {
|
203
|
+
var subPath = this.matchRoutePath(path);
|
204
|
+
var target = this.matchRouteTarget(path);
|
205
|
+
if (!target) { rio.Application.fail("Path not found."); }
|
206
|
+
|
207
|
+
if (path != "" && !noHistoryEntry) {
|
208
|
+
this.addHistoryEntry(path);
|
209
|
+
}
|
210
|
+
var remainingPath = this.remainingPath(path);
|
211
|
+
var pathParts = this.pathParts(path);
|
212
|
+
|
213
|
+
if (!this.__pages) { this.__pages = {}; }
|
214
|
+
// Right now the && this.__pages[target] == this.getCurrentPage() prevents double rendering.
|
215
|
+
var page;
|
216
|
+
if (this.__pages[target] && this.__pages[target] == this.getCurrentPage()) {
|
217
|
+
page = this.__pages[target];
|
218
|
+
} else {
|
219
|
+
page = this[target]();
|
220
|
+
this.__pages[target] = page;
|
221
|
+
}
|
222
|
+
|
223
|
+
if (page != this.getCurrentPage()) {
|
224
|
+
if (this.getCurrentPage()) {
|
225
|
+
this.clearPage();
|
226
|
+
}
|
227
|
+
[Element.body(), Element.html()].each(function(elt) {
|
228
|
+
elt.setStyle({
|
229
|
+
width: page.isManagingLayout() ? "100%" : "",
|
230
|
+
height: page.isManagingLayout() ? "100%" : ""
|
231
|
+
// overflow: page.isManagingLayout() ? "hidden" : ""
|
232
|
+
});
|
233
|
+
});
|
234
|
+
Element.body().insert(page.html());
|
235
|
+
page.render();
|
236
|
+
this.setCurrentPage(page);
|
237
|
+
}
|
238
|
+
|
239
|
+
page.applyHistoryEntry(remainingPath, pathParts);
|
240
|
+
},
|
241
|
+
|
242
|
+
/** @private */
|
243
|
+
clearPage: function() {
|
244
|
+
Element.body().childElements().each(function(elt) {
|
245
|
+
if (elt.tagName.toLowerCase() == 'iframe' || elt.id == 'rshStorageForm' || elt.id == 'rshStorageField' || elt.id == 'juggernaut_flash' || elt.hasClassName("preserve")) {
|
246
|
+
// keep it
|
247
|
+
} else {
|
248
|
+
elt.remove();
|
249
|
+
}
|
250
|
+
});
|
251
|
+
},
|
252
|
+
|
253
|
+
/**
|
254
|
+
Refreshes the browser. This will reload your app's source code
|
255
|
+
and reinitialize your app. This is more severe than rebooting.
|
256
|
+
*/
|
257
|
+
refresh: function() {
|
258
|
+
document.location.reload();
|
259
|
+
},
|
260
|
+
|
261
|
+
/**
|
262
|
+
Reboots your application. Rebooting your application will reset and reload the
|
263
|
+
current page.
|
264
|
+
*/
|
265
|
+
reboot: function() {
|
266
|
+
this.clearPage();
|
267
|
+
this.setCurrentPage(null);
|
268
|
+
this.navigateTo(this.getCurrentLocation());
|
269
|
+
},
|
270
|
+
|
271
|
+
/** @private */
|
272
|
+
getCurrentLocation: function() {
|
273
|
+
return dhtmlHistory.getCurrentLocation();
|
274
|
+
},
|
275
|
+
|
276
|
+
/**
|
277
|
+
Returns the instance of the currently loaded page in the app.
|
278
|
+
|
279
|
+
@returns the instance of the currently loaded page
|
280
|
+
@type rio.Page
|
281
|
+
*/
|
282
|
+
getCurrentPage: function() {
|
283
|
+
return this._currentPage;
|
284
|
+
},
|
285
|
+
|
286
|
+
/** @private */
|
287
|
+
setCurrentPage: function(page) {
|
288
|
+
this._currentPage = page;
|
289
|
+
},
|
290
|
+
|
291
|
+
/** @private */
|
292
|
+
rootUrl: function() {
|
293
|
+
return document.location.protocol + "//" + document.location.host;
|
294
|
+
},
|
295
|
+
|
296
|
+
toString: function() {
|
297
|
+
return "[rio.apps.*]";
|
298
|
+
}
|
299
|
+
});
|
300
|
+
|
301
|
+
Object.extend(app,
|
302
|
+
/**
|
303
|
+
@scope rio.Application
|
304
|
+
*/
|
305
|
+
{
|
306
|
+
/**
|
307
|
+
Specifies the lowest priority route for an application class.
|
308
|
+
|
309
|
+
<b>You are better off specifying routes when creating an
|
310
|
+
application with a 'routes' parameter.</b>
|
311
|
+
*/
|
312
|
+
route: function(path, target){
|
313
|
+
if (!this.__routes) { this.__routes = {}; }
|
314
|
+
this.__routes[path] = target;
|
315
|
+
|
316
|
+
var parts = path.split("/");
|
317
|
+
if (parts.length > 1) {
|
318
|
+
for (var i=0; i<parts.length - 1; i++) {
|
319
|
+
if (parts[i].startsWith("*")) {
|
320
|
+
throw("Only the final part of a route can be designated as optional by the *");
|
321
|
+
}
|
322
|
+
}
|
323
|
+
}
|
324
|
+
}
|
325
|
+
});
|
326
|
+
|
327
|
+
if (args.length > 0 && args.last() != undefined && !args.last().ATTR) {
|
328
|
+
var initializers = args.last();
|
329
|
+
if (initializers.requireCss) {
|
330
|
+
rio.Application.includeCss(initializers.requireCss);
|
331
|
+
}
|
332
|
+
Object.keys(initializers.routes || {}).each(function(name) {
|
333
|
+
app.route(name, initializers.routes[name]);
|
334
|
+
});
|
335
|
+
|
336
|
+
rio.Application.extend(app, initializers.methods || {});
|
337
|
+
}
|
338
|
+
|
339
|
+
return app;
|
340
|
+
},
|
341
|
+
|
342
|
+
/** @private */
|
343
|
+
extend: function(app, extension) {
|
344
|
+
rio.Attr.extend(app, extension);
|
345
|
+
},
|
346
|
+
|
347
|
+
/**
|
348
|
+
Alias of rio.Application.require
|
349
|
+
|
350
|
+
@param {String} fileName The path to the javascript file that will be loaded.
|
351
|
+
*/
|
352
|
+
include: function(fileName) {
|
353
|
+
this.require(fileName);
|
354
|
+
// rio.boot.loadFile(fileName);
|
355
|
+
},
|
356
|
+
|
357
|
+
/**
|
358
|
+
Alias of rio.Application.require
|
359
|
+
|
360
|
+
@param {String} fileName The path to the javascript file that will be loaded.
|
361
|
+
*/
|
362
|
+
require: function(fileName) {
|
363
|
+
rio.require(fileName);
|
364
|
+
},
|
365
|
+
|
366
|
+
/** @private */
|
367
|
+
injectCss: function() {
|
368
|
+
var toLoad = [];
|
369
|
+
rio.boot.loadedStylesheets.each(function(s) {
|
370
|
+
if (!rio.preloadedStylesheets.include(s)) { toLoad.push(s); }
|
371
|
+
});
|
372
|
+
if (toLoad.empty()) { return; }
|
373
|
+
|
374
|
+
var query = toLoad.map(function(f) {
|
375
|
+
return "files[]=" + f;
|
376
|
+
}).join("&");
|
377
|
+
var linkHtml = rio.Tag.link("", {
|
378
|
+
href: rio.url("/rio/stylesheets?" + query + "&" + rio.cacheKey),
|
379
|
+
media: "screen",
|
380
|
+
rel: "stylesheet",
|
381
|
+
type: "text/css"
|
382
|
+
});
|
383
|
+
Element.head().insert({ bottom: linkHtml });
|
384
|
+
|
385
|
+
if (rio.ContainerLayout) {
|
386
|
+
rio.ContainerLayout.resize();
|
387
|
+
}
|
388
|
+
},
|
389
|
+
|
390
|
+
/*
|
391
|
+
Requires a css file
|
392
|
+
|
393
|
+
@param {String} toInclude The path to the stylesheet that will be loaded.
|
394
|
+
*/
|
395
|
+
includeCss: function(toInclude) {
|
396
|
+
// Because of a bug in IE, we need to remove and readd all link tags every time a new one is added.
|
397
|
+
var include = function(fileName) {
|
398
|
+
if (rio.boot.loadedStylesheets.include(fileName)) { return; }
|
399
|
+
rio.boot.loadedStylesheets.push(fileName);
|
400
|
+
if (rio.preloadedStylesheets.include(fileName)) { return; }
|
401
|
+
|
402
|
+
if (rio.environment.autoConcatCss && !(rio.app && rio.app.launched())) {
|
403
|
+
// Do nothing
|
404
|
+
} else {
|
405
|
+
var linkHtml = rio.Tag.link("", {
|
406
|
+
href: rio.url("/stylesheets/" + fileName + ".css"),
|
407
|
+
media: "screen",
|
408
|
+
rel: "stylesheet",
|
409
|
+
type: "text/css"
|
410
|
+
});
|
411
|
+
Element.head().insert({ bottom: linkHtml });
|
412
|
+
}
|
413
|
+
}.bind(this);
|
414
|
+
if (Object.isString(toInclude)) {
|
415
|
+
include(toInclude);
|
416
|
+
}
|
417
|
+
if (Object.isArray(toInclude)) {
|
418
|
+
toInclude.reverse().each(function(css) {
|
419
|
+
include(css);
|
420
|
+
});
|
421
|
+
}
|
422
|
+
},
|
423
|
+
|
424
|
+
/** @private */
|
425
|
+
getToken: function() {
|
426
|
+
return this._token || rio.environment.railsToken;
|
427
|
+
},
|
428
|
+
|
429
|
+
/** @private */
|
430
|
+
setToken: function(token) {
|
431
|
+
this._token = token;
|
432
|
+
},
|
433
|
+
|
434
|
+
/** @private */
|
435
|
+
_afterLaunchFunctions: [],
|
436
|
+
|
437
|
+
/** @private */
|
438
|
+
afterLaunch: function(afterLoadFunction) {
|
439
|
+
if (rio.app && rio.app.launched()) {
|
440
|
+
afterLoadFunction(rio.app);
|
441
|
+
} else {
|
442
|
+
this._afterLaunchFunctions.push(afterLoadFunction);
|
443
|
+
}
|
444
|
+
},
|
445
|
+
|
446
|
+
/**
|
447
|
+
This causes the application to fail and log a 'fail' error message. If the application class
|
448
|
+
has a fail method, that method will be called with the message passed in here.
|
449
|
+
|
450
|
+
@param {String} msg The application failure message
|
451
|
+
@param {String} msg A more in depth description of the application failure
|
452
|
+
*/
|
453
|
+
fail: function(msg, description) {
|
454
|
+
try {
|
455
|
+
if (rio.app && rio.app.fail) {
|
456
|
+
rio.app.fail(msg);
|
457
|
+
rio.error("FAIL: " + msg, description || "", true);
|
458
|
+
} else {
|
459
|
+
alert("OOPS: " + msg + "\n\nTry refreshing the page or come back later.");
|
460
|
+
}
|
461
|
+
} catch(e) {
|
462
|
+
// Ignore errors during fail
|
463
|
+
}
|
464
|
+
},
|
465
|
+
|
466
|
+
toString: function() {
|
467
|
+
return "Application";
|
468
|
+
}
|
469
|
+
};
|
470
|
+
|
471
|
+
if (!window.dhtmlHistoryCreated) {
|
472
|
+
window.dhtmlHistory.create({
|
473
|
+
toJSON: function(o) {
|
474
|
+
return Object.toJSON(o);
|
475
|
+
},
|
476
|
+
fromJSON: function(s) {
|
477
|
+
return s.evalJSON();
|
478
|
+
}
|
479
|
+
});
|
480
|
+
window.dhtmlHistoryCreated = true;
|
481
|
+
}
|
482
|
+
|