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,295 @@
|
|
1
|
+
/*
|
2
|
+
Copyright (c) 2008 Alexander MacCaw
|
3
|
+
|
4
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
5
|
+
a copy of this software and associated documentation files (the
|
6
|
+
"Software"), to deal in the Software without restriction, including
|
7
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
8
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
9
|
+
permit persons to whom the Software is furnished to do so, subject to
|
10
|
+
the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be
|
13
|
+
included in all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
16
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
17
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
18
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
19
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
20
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
21
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
22
|
+
*/
|
23
|
+
|
24
|
+
/* This variable has to be left here because Juggernaut.swf expects it. */
|
25
|
+
var juggernaut;
|
26
|
+
|
27
|
+
/**
|
28
|
+
@class
|
29
|
+
|
30
|
+
<p>Juggernaut is a utility that allows the server to initiate connections with the browser.</p>
|
31
|
+
<p>This is what facilitates the client-server bindings that allow for automatic-collborative models.</p>
|
32
|
+
<p><i>Note: this version of Juggernaut has been altered to work better with the rio framework.</i></p>
|
33
|
+
*/
|
34
|
+
rio.Juggernaut = Class.create({
|
35
|
+
initialize: function(options) {
|
36
|
+
this.is_connected = false;
|
37
|
+
this.attempting_to_reconnect = false;
|
38
|
+
this.ever_been_connected = false;
|
39
|
+
this.options = options;
|
40
|
+
if(!this.options.client_id) {
|
41
|
+
this.options.client_id = this.options.session_id;
|
42
|
+
}
|
43
|
+
|
44
|
+
this.bindToWindow();
|
45
|
+
|
46
|
+
var connectionAttr = new rio.Attr.create({
|
47
|
+
attrAccessors: [["live", false]]
|
48
|
+
});
|
49
|
+
this.live = (new connectionAttr()).live;
|
50
|
+
},
|
51
|
+
|
52
|
+
logger: function(msg) {
|
53
|
+
if (this.options.debug) {
|
54
|
+
msg = "Juggernaut: " + msg + " on " + this.options.host + ':' + this.options.port;
|
55
|
+
rio.log(msg);
|
56
|
+
}
|
57
|
+
},
|
58
|
+
|
59
|
+
initialized: function(){
|
60
|
+
this.fire_event('initialized');
|
61
|
+
this.connect();
|
62
|
+
},
|
63
|
+
|
64
|
+
broadcast: function(body, type, client_ids, channels){
|
65
|
+
var msg = { command: 'broadcast', body: body, type: (type||'to_channels') };
|
66
|
+
if(channels) { msg.channels = channels; }
|
67
|
+
if(client_ids) { msg.client_ids = client_ids; }
|
68
|
+
msg.client_id = this.options.client_id;
|
69
|
+
msg.session_id = this.options.session_id;
|
70
|
+
this.sendData(this.toJSON(msg));
|
71
|
+
},
|
72
|
+
|
73
|
+
sendData: function(data){
|
74
|
+
this.swf().sendData(escape(data));
|
75
|
+
},
|
76
|
+
|
77
|
+
connect: function(){
|
78
|
+
if(!this.is_connected){
|
79
|
+
this.fire_event('connect');
|
80
|
+
this.swf().connect(this.options.host, this.options.port);
|
81
|
+
}
|
82
|
+
},
|
83
|
+
|
84
|
+
disconnect: function(){
|
85
|
+
if(this.is_connected) {
|
86
|
+
this.swf().disconnect();
|
87
|
+
this.is_connected = false;
|
88
|
+
this.live.update(false);
|
89
|
+
}
|
90
|
+
},
|
91
|
+
|
92
|
+
addChannel: function(channelName) {
|
93
|
+
this.options.channels.push(channelName);
|
94
|
+
this.resetConnection();
|
95
|
+
},
|
96
|
+
|
97
|
+
// Added to facilitate subscription to new channels
|
98
|
+
resetConnection: function() {
|
99
|
+
if (!this._resetTask) { this._resetTask = new rio.DelayedTask(); }
|
100
|
+
this._resetTask.delay(100, function() {
|
101
|
+
if (!(this.swf() && this.swf().connect)) {
|
102
|
+
this.resetConnection.bind(this).delay(500);
|
103
|
+
return;
|
104
|
+
}
|
105
|
+
this.disconnect();
|
106
|
+
this.connect();
|
107
|
+
}.bind(this));
|
108
|
+
},
|
109
|
+
|
110
|
+
handshake: function() {
|
111
|
+
var handshake = {};
|
112
|
+
handshake.command = 'subscribe';
|
113
|
+
if(this.options.session_id) { handshake.session_id = this.options.session_id; }
|
114
|
+
if(this.options.client_id) { handshake.client_id = this.options.client_id; }
|
115
|
+
if(this.options.channels) { handshake.channels = this.options.channels; }
|
116
|
+
if(this.currentMsgId) {
|
117
|
+
handshake.last_msg_id = this.currentMsgId;
|
118
|
+
handshake.signature = this.currentSignature;
|
119
|
+
}
|
120
|
+
|
121
|
+
return handshake;
|
122
|
+
},
|
123
|
+
|
124
|
+
connected: function(e) {
|
125
|
+
var json = this.toJSON(this.handshake());
|
126
|
+
this.sendData(json);
|
127
|
+
this.ever_been_connected = true;
|
128
|
+
this.is_connected = true;
|
129
|
+
this.live.update(true);
|
130
|
+
setTimeout(function(){
|
131
|
+
if(this.is_connected) { this.attempting_to_reconnect = false; }
|
132
|
+
}.bind(this), 1 * 1000);
|
133
|
+
this.logger('Connected');
|
134
|
+
this.fire_event('connected');
|
135
|
+
},
|
136
|
+
|
137
|
+
// OVERRIDE FOR CHAT STYLE APPS - POSSIBLE MALICIOUS CONTENT CAN BE EVALED
|
138
|
+
receiveData: function(e) {
|
139
|
+
var msg = this.parseJSON(unescape(e.toString()));
|
140
|
+
this.currentMsgId = msg.id;
|
141
|
+
this.currentSignature = msg.signature;
|
142
|
+
|
143
|
+
if (msg.body.startsWith("rio.console.touch")) {
|
144
|
+
// don't log autospec stuff
|
145
|
+
} else {
|
146
|
+
this.logger("Received data:\n" + msg.body + "\n");
|
147
|
+
}
|
148
|
+
eval(msg.body);
|
149
|
+
},
|
150
|
+
|
151
|
+
/*** START PROTOTYPE SPECIFIC - OVERRIDE FOR OTHER FRAMEWORKS ***/
|
152
|
+
fire_event: function(fx_name) {
|
153
|
+
$(document).fire("juggernaut:" + fx_name);
|
154
|
+
},
|
155
|
+
|
156
|
+
bindToWindow: function() {
|
157
|
+
window.juggernaut = this;
|
158
|
+
this.appendFlashObject();
|
159
|
+
},
|
160
|
+
|
161
|
+
toJSON: function(hash) {
|
162
|
+
return Object.toJSON(hash);
|
163
|
+
},
|
164
|
+
|
165
|
+
parseJSON: function(string) {
|
166
|
+
return string.evalJSON();
|
167
|
+
},
|
168
|
+
|
169
|
+
swf: function(){
|
170
|
+
return $(this.options.swf_name);
|
171
|
+
},
|
172
|
+
|
173
|
+
appendElement: function() {
|
174
|
+
this.element = new Element('div', { id: 'juggernaut' });
|
175
|
+
$(document.body).insert({ bottom: this.element });
|
176
|
+
},
|
177
|
+
|
178
|
+
/*** END PROTOTYPE SPECIFIC ***/
|
179
|
+
|
180
|
+
appendFlashObject: function(){
|
181
|
+
if(this.swf()) {
|
182
|
+
throw("Juggernaut error. 'swf_name' must be unique per juggernaut instance.");
|
183
|
+
}
|
184
|
+
this.appendElement();
|
185
|
+
rio.swfobject.embedSWF(
|
186
|
+
this.options.swf_address,
|
187
|
+
'juggernaut',
|
188
|
+
this.options.width,
|
189
|
+
this.options.height,
|
190
|
+
String(this.options.flash_version),
|
191
|
+
this.options.ei_swf_address,
|
192
|
+
{'bridgeName': this.options.bridge_name},
|
193
|
+
{},
|
194
|
+
{'id': this.options.swf_name, 'name': this.options.swf_name}
|
195
|
+
);
|
196
|
+
},
|
197
|
+
|
198
|
+
refreshFlashObject: function(){
|
199
|
+
this.swf().remove();
|
200
|
+
this.appendFlashObject();
|
201
|
+
},
|
202
|
+
|
203
|
+
errorConnecting: function(e) {
|
204
|
+
this.is_connected = false;
|
205
|
+
this.live.update(false);
|
206
|
+
if(!this.attempting_to_reconnect) {
|
207
|
+
this.logger('There has been an error connecting');
|
208
|
+
this.fire_event('errorConnecting');
|
209
|
+
this.reconnect();
|
210
|
+
}
|
211
|
+
},
|
212
|
+
|
213
|
+
disconnected: function(e) {
|
214
|
+
this.is_connected = false;
|
215
|
+
this.live.update(false);
|
216
|
+
if(!this.attempting_to_reconnect) {
|
217
|
+
this.logger('Connection has been lost');
|
218
|
+
this.fire_event('disconnected');
|
219
|
+
this.reconnect();
|
220
|
+
}
|
221
|
+
},
|
222
|
+
|
223
|
+
reconnect: function(){
|
224
|
+
if(this.options.reconnect_attempts){
|
225
|
+
this.attempting_to_reconnect = true;
|
226
|
+
this.live.update(false);
|
227
|
+
this.fire_event('reconnect');
|
228
|
+
this.logger('Will attempt to reconnect ' + this.options.reconnect_attempts + ' times,' +
|
229
|
+
'the first in ' + (this.options.reconnect_intervals || 3) + ' seconds');
|
230
|
+
var attemptReconnect = function(){
|
231
|
+
if(!this.is_connected){
|
232
|
+
this.logger('Attempting reconnect');
|
233
|
+
if(!this.ever_been_connected){
|
234
|
+
this.refreshFlashObject();
|
235
|
+
} else {
|
236
|
+
this.connect();
|
237
|
+
}
|
238
|
+
}
|
239
|
+
}.bind(this);
|
240
|
+
for(var i=0; i < this.options.reconnect_attempts; i++){
|
241
|
+
setTimeout(attemptReconnect, (this.options.reconnect_intervals || 3) * 1000 * (i + 1));
|
242
|
+
}
|
243
|
+
}
|
244
|
+
}
|
245
|
+
});
|
246
|
+
|
247
|
+
rio.Juggernaut.boot = function() {
|
248
|
+
var push = new rio.Juggernaut({
|
249
|
+
ei_swf_address: "/javascripts/lib/expressinstall.swf",
|
250
|
+
reconnect_intervals: 3,
|
251
|
+
flash_version: 8,
|
252
|
+
channels: [],
|
253
|
+
session_id: rio.environment.sessionId,
|
254
|
+
client_id: rio.environment.userId || Math.round(Math.random() * -1000000000),
|
255
|
+
host: rio.environment.pushUrl,
|
256
|
+
width: "0px",
|
257
|
+
height: "0px",
|
258
|
+
flash_color: "#fff",
|
259
|
+
swf_name: "juggernaut_flash",
|
260
|
+
port: rio.environment.pushPort,
|
261
|
+
bridge_name: "juggernaut",
|
262
|
+
debug: rio.environment.pushDebug,
|
263
|
+
swf_address: "/javascripts/lib/juggernaut.swf",
|
264
|
+
reconnect_attempts: 3
|
265
|
+
});
|
266
|
+
|
267
|
+
setInterval(function() {
|
268
|
+
if (rio.push) {
|
269
|
+
if (!rio.push.is_connected) {
|
270
|
+
rio.push.connect();
|
271
|
+
} else {
|
272
|
+
new Ajax.Request("/push/test_connection", {
|
273
|
+
method: "get",
|
274
|
+
asynchronous: true,
|
275
|
+
evalJS: false,
|
276
|
+
evalJSON: false,
|
277
|
+
onSuccess: function(response) {
|
278
|
+
if (response.responseText != "CONNECTED") {
|
279
|
+
rio.warn("Juggernaut connection silently failed");
|
280
|
+
rio.push.resetConnection();
|
281
|
+
}
|
282
|
+
}
|
283
|
+
});
|
284
|
+
}
|
285
|
+
}
|
286
|
+
}, 60000);
|
287
|
+
|
288
|
+
return push;
|
289
|
+
};
|
290
|
+
|
291
|
+
|
292
|
+
|
293
|
+
|
294
|
+
|
295
|
+
|
Binary file
|
@@ -0,0 +1,60 @@
|
|
1
|
+
rio.KeyMap = Class.create({
|
2
|
+
initialize: function(map, isMac) {
|
3
|
+
this.map = map;
|
4
|
+
this.isMac = isMac;
|
5
|
+
},
|
6
|
+
|
7
|
+
handle: function(e) {
|
8
|
+
this.map.each(function(m) {
|
9
|
+
var map = m.map || (this.isMac ? m.mac : m.win);
|
10
|
+
|
11
|
+
if (Object.isString(map.key)) {
|
12
|
+
map.key = rio.KeyMap.specialKeys()[map.key] || rio.KeyMap.charCode(map.key);
|
13
|
+
}
|
14
|
+
|
15
|
+
var effectiveKeyCode = (e.keyCode >= 96 && e.keyCode <= 105) ? e.keyCode - 48 : e.keyCode;
|
16
|
+
if (map.key == effectiveKeyCode) {
|
17
|
+
if (map.ctrl == undefined || map.ctrl == e.ctrlKey) {
|
18
|
+
if (map.alt == undefined || map.alt == e.altKey) {
|
19
|
+
if (map.shift == undefined || map.shift == e.shiftKey) {
|
20
|
+
if (map.meta == undefined || map.meta == e.metaKey) {
|
21
|
+
(m.handler || Prototype.emptyFunction)(e);
|
22
|
+
|
23
|
+
if (m.stop) {
|
24
|
+
e.stop();
|
25
|
+
}
|
26
|
+
}
|
27
|
+
}
|
28
|
+
}
|
29
|
+
}
|
30
|
+
}
|
31
|
+
}.bind(this));
|
32
|
+
}
|
33
|
+
});
|
34
|
+
|
35
|
+
Object.extend(rio.KeyMap, {
|
36
|
+
build: function(map) {
|
37
|
+
return new rio.KeyMap(map, rio.boot.isMac);
|
38
|
+
},
|
39
|
+
charCode: function(c) {
|
40
|
+
return "0123456789_______abcdefghijklmnopqrstuvwxyz".indexOf(c) + 48;
|
41
|
+
},
|
42
|
+
specialKeys: function() {
|
43
|
+
return {
|
44
|
+
"left": Event.KEY_LEFT,
|
45
|
+
"right": Event.KEY_RIGHT,
|
46
|
+
"up": Event.KEY_UP,
|
47
|
+
"down": Event.KEY_DOWN,
|
48
|
+
"tab": Event.KEY_TAB,
|
49
|
+
"enter": Event.KEY_RETURN,
|
50
|
+
"home": Event.KEY_HOME,
|
51
|
+
"end": Event.KEY_END,
|
52
|
+
"backspace": Event.KEY_BACKSPACE,
|
53
|
+
"delete": Event.KEY_DELETE,
|
54
|
+
"space": 32,
|
55
|
+
"esc": Event.KEY_ESC,
|
56
|
+
",": 188
|
57
|
+
};
|
58
|
+
},
|
59
|
+
toString: function() { return "KeyMap"; }
|
60
|
+
});
|
@@ -0,0 +1,167 @@
|
|
1
|
+
// Layout container to handle one container with lm_left, lm_right, lm_top, lm_bottom, and lm_center
|
2
|
+
rio.LayoutContainer = Class.create({
|
3
|
+
initialize: function(root) {
|
4
|
+
this.parent = $(root.parentNode);
|
5
|
+
root.setStyle("padding:0; margin:0; border:0");
|
6
|
+
// Pre-compute paddings
|
7
|
+
$w("top left right bottom").each(function(key) {
|
8
|
+
this.parent[key] = this.padding(this.parent, key);
|
9
|
+
}.bind(this));
|
10
|
+
|
11
|
+
// Init arrays
|
12
|
+
$w("lm_top lm_left lm_right lm_bottom lm_center").each(function(key) {
|
13
|
+
this[key] = [];
|
14
|
+
}.bind(this));
|
15
|
+
|
16
|
+
root.childElements().each(function(element) {
|
17
|
+
element.style.position = "absolute";
|
18
|
+
element.paddingWidth = this.fullPadding(element, "left") + this.fullPadding(element, "right");
|
19
|
+
element.paddingHeight = this.fullPadding(element, "top") + this.fullPadding(element, "bottom");
|
20
|
+
element.marginWidth = this.margin(element, "left") + this.margin(element, "right");
|
21
|
+
element.marginHeight = this.margin(element, "top") + this.margin(element, "bottom");
|
22
|
+
|
23
|
+
if (element.hasClassName("lm_top")) {
|
24
|
+
this.lm_top.push(element);
|
25
|
+
} else if (element.hasClassName("lm_left")) {
|
26
|
+
this.lm_left.push(element);
|
27
|
+
} else if (element.hasClassName("lm_right")) {
|
28
|
+
this.lm_right.unshift(element);
|
29
|
+
} else if (element.hasClassName("lm_bottom")) {
|
30
|
+
this.lm_bottom.unshift(element);
|
31
|
+
} else if (element.hasClassName("lm_center")) {
|
32
|
+
if (this.lm_center.length > 0) {
|
33
|
+
throw("Only one lm_center per lm_container");
|
34
|
+
}
|
35
|
+
this.lm_center.push(element);
|
36
|
+
}
|
37
|
+
}.bind(this));
|
38
|
+
},
|
39
|
+
|
40
|
+
updateSize: function() {
|
41
|
+
var d = this.parent.getDimensions();
|
42
|
+
var w = d.width - this.parent.left - this.border(this.parent, "left") - this.border(this.parent, "right");
|
43
|
+
var h = d.height - this.parent.top - this.parent.bottom - this.border(this.parent, "top") - this.border(this.parent, "bottom");
|
44
|
+
var that = this; // To avoid too many binds
|
45
|
+
|
46
|
+
// Set position and size of all top elements
|
47
|
+
var top = this.parent.top;
|
48
|
+
this.lm_top.each(function(element) {
|
49
|
+
var s = element.style;
|
50
|
+
that.setPositivePxValue(s, 'width', w - element.paddingWidth);
|
51
|
+
s.top = top + "px";
|
52
|
+
top += element.getHeight() + element.marginHeight;
|
53
|
+
});
|
54
|
+
h -= top - this.parent.top;
|
55
|
+
|
56
|
+
// Set position and size of all bottom elements
|
57
|
+
var bottom = this.parent.bottom;
|
58
|
+
this.lm_bottom.each(function(element) {
|
59
|
+
var s = element.style;
|
60
|
+
that.setPositivePxValue(s, 'width', w - element.paddingWidth);
|
61
|
+
s.bottom = bottom + "px";
|
62
|
+
bottom += element.getHeight() + element.marginHeight;
|
63
|
+
});
|
64
|
+
h -= bottom - this.parent.bottom;
|
65
|
+
|
66
|
+
// Set position and size of all left elements
|
67
|
+
var left = this.parent.left;
|
68
|
+
this.lm_left.each(function(element) {
|
69
|
+
var s = element.style;
|
70
|
+
that.setPositivePxValue(s, 'height', h - element.paddingHeight);
|
71
|
+
s.top = top + "px";
|
72
|
+
s.left = left + "px";
|
73
|
+
left += element.getWidth() + element.marginWidth;
|
74
|
+
});
|
75
|
+
w -= left;
|
76
|
+
|
77
|
+
// Set position and size of all right elements
|
78
|
+
var right = this.parent.right;
|
79
|
+
this.lm_right.each(function(element) {
|
80
|
+
var s = element.style;
|
81
|
+
that.setPositivePxValue(s, 'height', h - element.paddingHeight);
|
82
|
+
s.top = top + "px";
|
83
|
+
s.right = right + "px";
|
84
|
+
right += element.getWidth() + element.marginWidth;
|
85
|
+
});
|
86
|
+
w -= right;
|
87
|
+
|
88
|
+
// Set position and size of all center elements
|
89
|
+
// Only one center for this version
|
90
|
+
var center = this.lm_center.first();
|
91
|
+
var s = center.style;
|
92
|
+
s.top = top + "px";
|
93
|
+
s.left = left + "px";
|
94
|
+
this.setPositivePxValue(s, 'width', w - center.paddingWidth);
|
95
|
+
this.setPositivePxValue(s, 'height', h - center.paddingHeight);
|
96
|
+
},
|
97
|
+
|
98
|
+
// Private functions
|
99
|
+
fullPadding: function(element, s) {
|
100
|
+
return this.padding(element, s) + this.border(element, s) + this.margin(element, s);
|
101
|
+
},
|
102
|
+
|
103
|
+
border: function(element, s) {
|
104
|
+
var border = parseInt(element.getStyle("border-" + s + "-width") || 0, 10);
|
105
|
+
if (isNaN(border)) { // Test for IE!!
|
106
|
+
border = 0;
|
107
|
+
}
|
108
|
+
return border;
|
109
|
+
},
|
110
|
+
|
111
|
+
padding: function(element, s) {
|
112
|
+
var padding = parseInt(element.getStyle("padding-" + s) || 0, 10);
|
113
|
+
if (isNaN(padding)) { // Test for IE!!
|
114
|
+
padding = 0;
|
115
|
+
}
|
116
|
+
return padding;
|
117
|
+
},
|
118
|
+
|
119
|
+
margin: function(element, s) {
|
120
|
+
var margin = parseInt(element.getStyle("margin-" + s) || 0, 10);
|
121
|
+
if (isNaN(margin)) { // Test for IE!!
|
122
|
+
margin = 0;
|
123
|
+
}
|
124
|
+
return margin;
|
125
|
+
},
|
126
|
+
|
127
|
+
setPositivePxValue:function(objet, key, value) {
|
128
|
+
objet[key] = (value > 0 ? value : 0) + "px";
|
129
|
+
}
|
130
|
+
});
|
131
|
+
|
132
|
+
// Layout manager: handles N layout container
|
133
|
+
rio.LayoutManager = Class.create({
|
134
|
+
initialize: function(root) {
|
135
|
+
this.root = root || document.body;
|
136
|
+
this.init();
|
137
|
+
Event.observe(window, "resize", this.resize.bind(this));
|
138
|
+
},
|
139
|
+
|
140
|
+
reset: function() {
|
141
|
+
this.init.bind(this).defer();
|
142
|
+
},
|
143
|
+
|
144
|
+
add: function(root) {
|
145
|
+
this.addElement.bind(this, root, true).defer();
|
146
|
+
},
|
147
|
+
|
148
|
+
// Private functions
|
149
|
+
init: function() {
|
150
|
+
this.containers = [];
|
151
|
+
this.addElement(this.root);
|
152
|
+
this.resize();
|
153
|
+
},
|
154
|
+
|
155
|
+
resize: function() {
|
156
|
+
this.containers.invoke("updateSize");
|
157
|
+
},
|
158
|
+
|
159
|
+
addElement: function(element, doResize) {
|
160
|
+
$(element).getElementsBySelector(".lm_container").each(function(element) {
|
161
|
+
this.containers.push(new rio.LayoutContainer(element));
|
162
|
+
}.bind(this));
|
163
|
+
if (doResize) {
|
164
|
+
this.resize();
|
165
|
+
}
|
166
|
+
}
|
167
|
+
});
|