riojs 0.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (270) hide show
  1. data/LICENSE +20 -0
  2. data/README.rdoc +24 -0
  3. data/VERSION +1 -0
  4. data/bin/rio +5 -0
  5. data/generators/rio_app/USAGE +19 -0
  6. data/generators/rio_app/rio_app_generator.rb +40 -0
  7. data/generators/rio_app/templates/app.build +10 -0
  8. data/generators/rio_app/templates/app.css +0 -0
  9. data/generators/rio_app/templates/app.js +20 -0
  10. data/generators/rio_app/templates/app_view.html.erb +19 -0
  11. data/generators/rio_app/templates/fixture.js +4 -0
  12. data/generators/rio_app/templates/rio.html.erb +18 -0
  13. data/generators/rio_app/templates/rio_controller.rb +2 -0
  14. data/generators/rio_app/templates/spec.js +7 -0
  15. data/generators/rio_component/USAGE +13 -0
  16. data/generators/rio_component/rio_component_generator.rb +16 -0
  17. data/generators/rio_component/templates/component.css +0 -0
  18. data/generators/rio_component/templates/component.js +11 -0
  19. data/generators/rio_component/templates/fixture.js +3 -0
  20. data/generators/rio_component/templates/spec.js +6 -0
  21. data/generators/rio_model/USAGE +12 -0
  22. data/generators/rio_model/rio_model_generator.rb +21 -0
  23. data/generators/rio_model/templates/fixture.js +3 -0
  24. data/generators/rio_model/templates/model.js +9 -0
  25. data/generators/rio_model/templates/spec.js +6 -0
  26. data/generators/rio_page/USAGE +14 -0
  27. data/generators/rio_page/rio_page_generator.rb +16 -0
  28. data/generators/rio_page/templates/fixture.js +3 -0
  29. data/generators/rio_page/templates/page.css +12 -0
  30. data/generators/rio_page/templates/page.js +12 -0
  31. data/generators/rio_page/templates/page.jst +64 -0
  32. data/generators/rio_page/templates/spec.js +6 -0
  33. data/generators/rio_resource/USAGE +20 -0
  34. data/generators/rio_resource/rio_resource_generator.rb +10 -0
  35. data/generators/rio_resource/templates/controller.rb +3 -0
  36. data/init.rb +4 -0
  37. data/install/config/juggernaut_hosts.yml +18 -0
  38. data/install/lib/tasks/rio.rake +1 -0
  39. data/install/script/rio_server +37 -0
  40. data/lib/rio/autospec.rb +86 -0
  41. data/lib/rio/install.rb +90 -0
  42. data/lib/rio/juggernaut.rb +212 -0
  43. data/lib/rio/path.rb +3 -0
  44. data/lib/rio/rio_compressor.rb +219 -0
  45. data/lib/rio/rio_file_controller.rb +16 -0
  46. data/lib/rio/rio_on_rails.rb +586 -0
  47. data/lib/rio/rio_proxy_controller.rb +60 -0
  48. data/lib/rio/rio_push_controller.rb +48 -0
  49. data/lib/rio/rio_routes.rb +24 -0
  50. data/lib/rio/rio_spec_controller.rb +70 -0
  51. data/lib/riojs.rb +14 -0
  52. data/lib/tasks/rio.rb +63 -0
  53. data/public/images/background-chiffon.png +0 -0
  54. data/public/images/button-gradient-overlay-down.png +0 -0
  55. data/public/images/button-gradient-overlay.png +0 -0
  56. data/public/images/icons/add.png +0 -0
  57. data/public/images/icons/error-big.png +0 -0
  58. data/public/images/icons/warning-big.png +0 -0
  59. data/public/images/rio-logo-big.png +0 -0
  60. data/public/images/rio-logo.png +0 -0
  61. data/public/images/splitter-handle-horizontal.png +0 -0
  62. data/public/images/splitter-handle-vertical.png +0 -0
  63. data/public/images/tab-bar-gradient-overlay.png +0 -0
  64. data/public/images/title-gradient-overlay.png +0 -0
  65. data/public/images/trash.gif +0 -0
  66. data/public/javascripts/components/accordion.js +144 -0
  67. data/public/javascripts/components/alert_box.js +59 -0
  68. data/public/javascripts/components/base.js +47 -0
  69. data/public/javascripts/components/box.js +63 -0
  70. data/public/javascripts/components/button.js +98 -0
  71. data/public/javascripts/components/checkbox.js +44 -0
  72. data/public/javascripts/components/container.js +265 -0
  73. data/public/javascripts/components/grid_view.js +107 -0
  74. data/public/javascripts/components/image.js +19 -0
  75. data/public/javascripts/components/input.js +171 -0
  76. data/public/javascripts/components/label.js +15 -0
  77. data/public/javascripts/components/lightbox.js +160 -0
  78. data/public/javascripts/components/link.js +43 -0
  79. data/public/javascripts/components/list_item.js +44 -0
  80. data/public/javascripts/components/list_view.js +192 -0
  81. data/public/javascripts/components/marquee.js +131 -0
  82. data/public/javascripts/components/menu.js +89 -0
  83. data/public/javascripts/components/notification.js +75 -0
  84. data/public/javascripts/components/overlay.js +134 -0
  85. data/public/javascripts/components/panel.js +146 -0
  86. data/public/javascripts/components/radio.js +46 -0
  87. data/public/javascripts/components/splitter.js +65 -0
  88. data/public/javascripts/components/tab_bar.js +64 -0
  89. data/public/javascripts/components/tab_panel.js +57 -0
  90. data/public/javascripts/components/textarea.js +223 -0
  91. data/public/javascripts/components/toggle_button.js +22 -0
  92. data/public/javascripts/components/tooltip.js +80 -0
  93. data/public/javascripts/lib/application.js +482 -0
  94. data/public/javascripts/lib/attr.js +760 -0
  95. data/public/javascripts/lib/benchmark.js +235 -0
  96. data/public/javascripts/lib/blank.html +39 -0
  97. data/public/javascripts/lib/boot.js +300 -0
  98. data/public/javascripts/lib/clipboard.js +96 -0
  99. data/public/javascripts/lib/collection_entity.js +46 -0
  100. data/public/javascripts/lib/component.js +129 -0
  101. data/public/javascripts/lib/console.js +75 -0
  102. data/public/javascripts/lib/console/apps/console.build +43 -0
  103. data/public/javascripts/lib/console/apps/console.js +28 -0
  104. data/public/javascripts/lib/console/blank.html +39 -0
  105. data/public/javascripts/lib/console/components/benchmark.js +196 -0
  106. data/public/javascripts/lib/console/components/console.js +352 -0
  107. data/public/javascripts/lib/console/components/dependencies_list.js +17 -0
  108. data/public/javascripts/lib/console/components/docs.js +66 -0
  109. data/public/javascripts/lib/console/components/playground.js +30 -0
  110. data/public/javascripts/lib/console/console.html +27 -0
  111. data/public/javascripts/lib/console/console_commands.js +287 -0
  112. data/public/javascripts/lib/console/console_commands.js.rej +21 -0
  113. data/public/javascripts/lib/console/console_mixin.js +22 -0
  114. data/public/javascripts/lib/console/docs/files.html +579 -0
  115. data/public/javascripts/lib/console/docs/index.html +323 -0
  116. data/public/javascripts/lib/console/docs/symbols/Object.html +291 -0
  117. data/public/javascripts/lib/console/docs/symbols/_global_.html +413 -0
  118. data/public/javascripts/lib/console/docs/symbols/rio.AIM.html +490 -0
  119. data/public/javascripts/lib/console/docs/symbols/rio.Application.html +841 -0
  120. data/public/javascripts/lib/console/docs/symbols/rio.Attr.html +1075 -0
  121. data/public/javascripts/lib/console/docs/symbols/rio.Binding.html +272 -0
  122. data/public/javascripts/lib/console/docs/symbols/rio.Component.html +419 -0
  123. data/public/javascripts/lib/console/docs/symbols/rio.Cookie.html +543 -0
  124. data/public/javascripts/lib/console/docs/symbols/rio.DelayedTask#initialize.html +270 -0
  125. data/public/javascripts/lib/console/docs/symbols/rio.DelayedTask.html +391 -0
  126. data/public/javascripts/lib/console/docs/symbols/rio.JsTemplate.html +271 -0
  127. data/public/javascripts/lib/console/docs/symbols/rio.Juggernaut.html +329 -0
  128. data/public/javascripts/lib/console/docs/symbols/rio.Model.html +822 -0
  129. data/public/javascripts/lib/console/docs/symbols/rio.Page.html +383 -0
  130. data/public/javascripts/lib/console/docs/symbols/rio.Template.html +328 -0
  131. data/public/javascripts/lib/console/docs/symbols/rio.Utils.html +617 -0
  132. data/public/javascripts/lib/console/docs/symbols/rio.html +506 -0
  133. data/public/javascripts/lib/console/docs/symbols/src/public_javascripts_components_base.js.html +54 -0
  134. data/public/javascripts/lib/console/docs/symbols/src/public_javascripts_lib_application.js.html +490 -0
  135. data/public/javascripts/lib/console/docs/symbols/src/public_javascripts_lib_attr.js.html +768 -0
  136. data/public/javascripts/lib/console/docs/symbols/src/public_javascripts_lib_boot.js.html +308 -0
  137. data/public/javascripts/lib/console/docs/symbols/src/public_javascripts_lib_clipboard.js.html +103 -0
  138. data/public/javascripts/lib/console/docs/symbols/src/public_javascripts_lib_collection_entity.js.html +53 -0
  139. data/public/javascripts/lib/console/docs/symbols/src/public_javascripts_lib_component.js.html +137 -0
  140. data/public/javascripts/lib/console/docs/symbols/src/public_javascripts_lib_cookie.js.html +81 -0
  141. data/public/javascripts/lib/console/docs/symbols/src/public_javascripts_lib_delayed_task.js.html +68 -0
  142. data/public/javascripts/lib/console/docs/symbols/src/public_javascripts_lib_file.js.html +80 -0
  143. data/public/javascripts/lib/console/docs/symbols/src/public_javascripts_lib_flash_detect.js.html +129 -0
  144. data/public/javascripts/lib/console/docs/symbols/src/public_javascripts_lib_form.js.html +95 -0
  145. data/public/javascripts/lib/console/docs/symbols/src/public_javascripts_lib_id.js.html +50 -0
  146. data/public/javascripts/lib/console/docs/symbols/src/public_javascripts_lib_inflector.js.html +167 -0
  147. data/public/javascripts/lib/console/docs/symbols/src/public_javascripts_lib_js_template.js.html +283 -0
  148. data/public/javascripts/lib/console/docs/symbols/src/public_javascripts_lib_juggernaut.js.html +303 -0
  149. data/public/javascripts/lib/console/docs/symbols/src/public_javascripts_lib_key_map.js.html +68 -0
  150. data/public/javascripts/lib/console/docs/symbols/src/public_javascripts_lib_layout_manager.js.html +175 -0
  151. data/public/javascripts/lib/console/docs/symbols/src/public_javascripts_lib_log.js.html +17 -0
  152. data/public/javascripts/lib/console/docs/symbols/src/public_javascripts_lib_model.js.html +1074 -0
  153. data/public/javascripts/lib/console/docs/symbols/src/public_javascripts_lib_page.js.html +246 -0
  154. data/public/javascripts/lib/console/docs/symbols/src/public_javascripts_lib_parameters.js.html +66 -0
  155. data/public/javascripts/lib/console/docs/symbols/src/public_javascripts_lib_protohack.js.html +305 -0
  156. data/public/javascripts/lib/console/docs/symbols/src/public_javascripts_lib_push.js.html +12 -0
  157. data/public/javascripts/lib/console/docs/symbols/src/public_javascripts_lib_rsh.js.html +659 -0
  158. data/public/javascripts/lib/console/docs/symbols/src/public_javascripts_lib_swfobject.js.html +12 -0
  159. data/public/javascripts/lib/console/docs/symbols/src/public_javascripts_lib_tag.js.html +60 -0
  160. data/public/javascripts/lib/console/docs/symbols/src/public_javascripts_lib_template.js.html +64 -0
  161. data/public/javascripts/lib/console/docs/symbols/src/public_javascripts_lib_theme.js.html +105 -0
  162. data/public/javascripts/lib/console/docs/symbols/src/public_javascripts_lib_undo.js.html +142 -0
  163. data/public/javascripts/lib/console/docs/symbols/src/public_javascripts_lib_utils.js.html +87 -0
  164. data/public/javascripts/lib/console/docs/symbols/src/public_javascripts_lib_yaml.js.html +88 -0
  165. data/public/javascripts/lib/console/file-small.png +0 -0
  166. data/public/javascripts/lib/console/green-circle.png +0 -0
  167. data/public/javascripts/lib/console/loading.gif +0 -0
  168. data/public/javascripts/lib/console/pages/console_page.js +149 -0
  169. data/public/javascripts/lib/console/pages/console_page.jst +27 -0
  170. data/public/javascripts/lib/console/red-circle.png +0 -0
  171. data/public/javascripts/lib/cookie.js +74 -0
  172. data/public/javascripts/lib/delayed_task.js +61 -0
  173. data/public/javascripts/lib/dependencies.js +76 -0
  174. data/public/javascripts/lib/environment.js +30 -0
  175. data/public/javascripts/lib/event.simulate.js +137 -0
  176. data/public/javascripts/lib/expressinstall.swf +0 -0
  177. data/public/javascripts/lib/file.js +72 -0
  178. data/public/javascripts/lib/flash_detect.js +122 -0
  179. data/public/javascripts/lib/flashembed.min.js +16 -0
  180. data/public/javascripts/lib/form.js +88 -0
  181. data/public/javascripts/lib/id.js +43 -0
  182. data/public/javascripts/lib/inflector.js +160 -0
  183. data/public/javascripts/lib/instrumenter.js +106 -0
  184. data/public/javascripts/lib/js_template.js +275 -0
  185. data/public/javascripts/lib/jslint.js +4950 -0
  186. data/public/javascripts/lib/juggernaut.js +295 -0
  187. data/public/javascripts/lib/juggernaut.swf +0 -0
  188. data/public/javascripts/lib/key_map.js +60 -0
  189. data/public/javascripts/lib/layout_manager.js +167 -0
  190. data/public/javascripts/lib/model.js +1067 -0
  191. data/public/javascripts/lib/page.js +238 -0
  192. data/public/javascripts/lib/parameters.js +59 -0
  193. data/public/javascripts/lib/png_fix.js +75 -0
  194. data/public/javascripts/lib/protohack.js +297 -0
  195. data/public/javascripts/lib/push.js +5 -0
  196. data/public/javascripts/lib/rio.build +28 -0
  197. data/public/javascripts/lib/rio_development.build +5 -0
  198. data/public/javascripts/lib/rio_lint.js +66 -0
  199. data/public/javascripts/lib/rsh.js +651 -0
  200. data/public/javascripts/lib/spec.js +545 -0
  201. data/public/javascripts/lib/spec_runner.js +242 -0
  202. data/public/javascripts/lib/swfobject.js +5 -0
  203. data/public/javascripts/lib/tag.js +52 -0
  204. data/public/javascripts/lib/undo.js +134 -0
  205. data/public/javascripts/lib/utils.js +80 -0
  206. data/public/javascripts/lib/yaml.js +80 -0
  207. data/public/javascripts/pages/playground_page.js +15 -0
  208. data/public/javascripts/prototype/builder.js +146 -0
  209. data/public/javascripts/prototype/controls.js +1004 -0
  210. data/public/javascripts/prototype/dragdrop.js +1030 -0
  211. data/public/javascripts/prototype/effects.js +1137 -0
  212. data/public/javascripts/prototype/prototype.js +4320 -0
  213. data/public/javascripts/prototype/slider.js +283 -0
  214. data/public/javascripts/prototype/sound.js +67 -0
  215. data/public/javascripts/specs/components/box_spec.js +6 -0
  216. data/public/javascripts/specs/components/checkbox_spec.js +26 -0
  217. data/public/javascripts/specs/components/container_spec.js +6 -0
  218. data/public/javascripts/specs/components/input_spec.js +71 -0
  219. data/public/javascripts/specs/components/panel_spec.js +6 -0
  220. data/public/javascripts/specs/components/radio_spec.js +40 -0
  221. data/public/javascripts/specs/fixtures/components/box.js +3 -0
  222. data/public/javascripts/specs/fixtures/components/checkbox.js +9 -0
  223. data/public/javascripts/specs/fixtures/components/container.js +3 -0
  224. data/public/javascripts/specs/fixtures/components/input.js +12 -0
  225. data/public/javascripts/specs/fixtures/components/menu.js +19 -0
  226. data/public/javascripts/specs/fixtures/components/menu_item.js +18 -0
  227. data/public/javascripts/specs/fixtures/components/radio.js +11 -0
  228. data/public/javascripts/specs/lib/application_spec.js +281 -0
  229. data/public/javascripts/specs/lib/attr_spec.js +1514 -0
  230. data/public/javascripts/specs/lib/benchmark_spec.js +361 -0
  231. data/public/javascripts/specs/lib/collection_entity_spec.js +131 -0
  232. data/public/javascripts/specs/lib/component_spec.js +86 -0
  233. data/public/javascripts/specs/lib/form_spec.js +171 -0
  234. data/public/javascripts/specs/lib/id_spec.js +21 -0
  235. data/public/javascripts/specs/lib/instrumenter_spec.js +5 -0
  236. data/public/javascripts/specs/lib/js_template_spec.js +131 -0
  237. data/public/javascripts/specs/lib/key_map_spec.js +227 -0
  238. data/public/javascripts/specs/lib/model_spec.js +2268 -0
  239. data/public/javascripts/specs/lib/parameters_spec.js +94 -0
  240. data/public/javascripts/specs/lib/spec_spec.js +943 -0
  241. data/public/javascripts/specs/lib/undo_spec.js +105 -0
  242. data/public/javascripts/specs/lib/yaml_spec.js +127 -0
  243. data/public/sounds/basso.wav +0 -0
  244. data/public/sounds/purr.wav +0 -0
  245. data/public/stylesheets/components/accordion.css +24 -0
  246. data/public/stylesheets/components/alert_box.css +35 -0
  247. data/public/stylesheets/components/box.css +0 -0
  248. data/public/stylesheets/components/button.css +39 -0
  249. data/public/stylesheets/components/checkbox.css +9 -0
  250. data/public/stylesheets/components/container.css +3 -0
  251. data/public/stylesheets/components/grid_view.css +52 -0
  252. data/public/stylesheets/components/input.css +10 -0
  253. data/public/stylesheets/components/label.css +3 -0
  254. data/public/stylesheets/components/lightbox.css +31 -0
  255. data/public/stylesheets/components/link.css +4 -0
  256. data/public/stylesheets/components/list_view.css +23 -0
  257. data/public/stylesheets/components/marquee.css +29 -0
  258. data/public/stylesheets/components/menu.css +34 -0
  259. data/public/stylesheets/components/notification.css +52 -0
  260. data/public/stylesheets/components/overlay.css +8 -0
  261. data/public/stylesheets/components/panel.css +36 -0
  262. data/public/stylesheets/components/radio.css +9 -0
  263. data/public/stylesheets/components/splitter.css +35 -0
  264. data/public/stylesheets/components/tab_bar.css +59 -0
  265. data/public/stylesheets/components/tab_panel.css +15 -0
  266. data/public/stylesheets/components/textarea.css +11 -0
  267. data/public/stylesheets/components/tooltip.css +10 -0
  268. data/public/stylesheets/console.css +151 -0
  269. data/public/stylesheets/css_reset.css +55 -0
  270. metadata +343 -0
@@ -0,0 +1,283 @@
1
+ // Copyright (c) 2005-2009 Marty Haught, Thomas Fuchs
2
+ //
3
+ // script.aculo.us is freely distributable under the terms of an MIT-style license.
4
+ // For details, see the script.aculo.us web site: http://script.aculo.us/
5
+
6
+ // var Control = (window.Control == undefined ? {} : window.Control);
7
+ Control = {};
8
+
9
+ // options:
10
+ // axis: 'vertical', or 'horizontal' (default)
11
+ //
12
+ // callbacks:
13
+ // onChange(value)
14
+ // onSlide(value)
15
+ Control.Slider = Class.create({
16
+ initialize: function(handle, track, options) {
17
+ var slider = this;
18
+
19
+ if (Object.isArray(handle)) {
20
+ this.handles = handle.collect( function(e) { return $(e); });
21
+ } else {
22
+ this.handles = [$(handle)];
23
+ }
24
+
25
+ this.track = $(track);
26
+ this.options = options || { };
27
+
28
+ this.axis = this.options.axis || 'horizontal';
29
+ this.increment = this.options.increment || 1;
30
+ this.step = parseInt(this.options.step || '1', 10);
31
+ this.range = this.options.range || $R(0,1);
32
+
33
+ this.value = 0; // assure backwards compat
34
+ this.values = this.handles.map( function() { return 0; });
35
+ this.spans = this.options.spans ? this.options.spans.map(function(s){ return $(s); }) : false;
36
+ this.options.startSpan = $(this.options.startSpan || null);
37
+ this.options.endSpan = $(this.options.endSpan || null);
38
+
39
+ this.restricted = this.options.restricted || false;
40
+
41
+ this.maximum = this.options.maximum || this.range.end;
42
+ this.minimum = this.options.minimum || this.range.start;
43
+
44
+ // Will be used to align the handle onto the track, if necessary
45
+ this.alignX = parseInt(this.options.alignX || '0', 10);
46
+ this.alignY = parseInt(this.options.alignY || '0', 10);
47
+
48
+ this.trackLength = this.maximumOffset() - this.minimumOffset();
49
+
50
+ this.handleLength = this.isVertical() ?
51
+ (this.handles[0].offsetHeight != 0 ?
52
+ this.handles[0].offsetHeight : this.handles[0].style.height.replace(/px$/,"")) :
53
+ (this.handles[0].offsetWidth != 0 ? this.handles[0].offsetWidth :
54
+ this.handles[0].style.width.replace(/px$/,""));
55
+
56
+ this.active = false;
57
+ this.dragging = false;
58
+ this.disabled = false;
59
+
60
+ if (this.options.disabled) { this.setDisabled(); }
61
+
62
+ // Allowed values array
63
+ this.allowedValues = this.options.values ? this.options.values.sortBy(Prototype.K) : false;
64
+ if (this.allowedValues) {
65
+ this.minimum = this.allowedValues.min();
66
+ this.maximum = this.allowedValues.max();
67
+ }
68
+
69
+ this.eventMouseDown = this.startDrag.bindAsEventListener(this);
70
+ this.eventMouseUp = this.endDrag.bindAsEventListener(this);
71
+ this.eventMouseMove = this.update.bindAsEventListener(this);
72
+
73
+ // Initialize handles in reverse (make sure first handle is active)
74
+ this.handles.each( function(h,i) {
75
+ i = slider.handles.length-1-i;
76
+ slider.setValue(parseFloat(
77
+ (Object.isArray(slider.options.sliderValue) ?
78
+ slider.options.sliderValue[i] : slider.options.sliderValue) ||
79
+ slider.range.start), i);
80
+ h.makePositioned().observe("mousedown", slider.eventMouseDown);
81
+ });
82
+
83
+ this.track.observe("mousedown", this.eventMouseDown);
84
+ document.observe("mouseup", this.eventMouseUp);
85
+ document.observe("mousemove", this.eventMouseMove);
86
+
87
+ this.initialized = true;
88
+ },
89
+ dispose: function() {
90
+ var slider = this;
91
+ Event.stopObserving(this.track, "mousedown", this.eventMouseDown);
92
+ Event.stopObserving(document, "mouseup", this.eventMouseUp);
93
+ Event.stopObserving(document, "mousemove", this.eventMouseMove);
94
+ this.handles.each( function(h) {
95
+ Event.stopObserving(h, "mousedown", slider.eventMouseDown);
96
+ });
97
+ },
98
+ setDisabled: function(){
99
+ this.disabled = true;
100
+ },
101
+ setEnabled: function(){
102
+ this.disabled = false;
103
+ },
104
+ getNearestValue: function(value){
105
+ if (this.allowedValues){
106
+ if (value >= this.allowedValues.max()) { return(this.allowedValues.max()); }
107
+ if (value <= this.allowedValues.min()) { return(this.allowedValues.min()); }
108
+
109
+ var offset = Math.abs(this.allowedValues[0] - value);
110
+ var newValue = this.allowedValues[0];
111
+ this.allowedValues.each( function(v) {
112
+ var currentOffset = Math.abs(v - value);
113
+ if (currentOffset <= offset){
114
+ newValue = v;
115
+ offset = currentOffset;
116
+ }
117
+ });
118
+ return newValue;
119
+ }
120
+ if (value > this.range.end) { return this.range.end; }
121
+ if (value < this.range.start) { return this.range.start; }
122
+ return value;
123
+ },
124
+ setValue: function(sliderValue, handleIdx){
125
+ if (!this.active) {
126
+ this.activeHandleIdx = handleIdx || 0;
127
+ this.activeHandle = this.handles[this.activeHandleIdx];
128
+ this.updateStyles();
129
+ }
130
+ handleIdx = handleIdx || this.activeHandleIdx || 0;
131
+ if (this.initialized && this.restricted) {
132
+ if ((handleIdx>0) && (sliderValue<this.values[handleIdx-1])) {
133
+ sliderValue = this.values[handleIdx-1];
134
+ }
135
+ if ((handleIdx < (this.handles.length-1)) && (sliderValue>this.values[handleIdx+1])) {
136
+ sliderValue = this.values[handleIdx+1];
137
+ }
138
+ }
139
+ sliderValue = this.getNearestValue(sliderValue);
140
+ this.values[handleIdx] = sliderValue;
141
+ this.value = this.values[0]; // assure backwards compat
142
+
143
+ this.handles[handleIdx].style[this.isVertical() ? 'top' : 'left'] =
144
+ this.translateToPx(sliderValue);
145
+
146
+ this.drawSpans();
147
+ if (!this.dragging || !this.event) { this.updateFinished(); }
148
+ },
149
+ setValueBy: function(delta, handleIdx) {
150
+ this.setValue(this.values[handleIdx || this.activeHandleIdx || 0] + delta,
151
+ handleIdx || this.activeHandleIdx || 0);
152
+ },
153
+ translateToPx: function(value) {
154
+ return Math.round(
155
+ ((this.trackLength-this.handleLength)/(this.range.end-this.range.start)) *
156
+ (value - this.range.start)) + "px";
157
+ },
158
+ translateToValue: function(offset) {
159
+ return ((offset/(this.trackLength-this.handleLength) *
160
+ (this.range.end-this.range.start)) + this.range.start);
161
+ },
162
+ getRange: function(range) {
163
+ var v = this.values.sortBy(Prototype.K);
164
+ range = range || 0;
165
+ return $R(v[range],v[range+1]);
166
+ },
167
+ minimumOffset: function(){
168
+ return(this.isVertical() ? this.alignY : this.alignX);
169
+ },
170
+ maximumOffset: function(){
171
+ return(this.isVertical() ?
172
+ (this.track.offsetHeight != 0 ? this.track.offsetHeight :
173
+ this.track.style.height.replace(/px$/,"")) - this.alignY :
174
+ (this.track.offsetWidth != 0 ? this.track.offsetWidth :
175
+ this.track.style.width.replace(/px$/,"")) - this.alignX);
176
+ },
177
+ isVertical: function(){
178
+ return (this.axis == 'vertical');
179
+ },
180
+ drawSpans: function() {
181
+ var slider = this;
182
+ if (this.spans) {
183
+ $R(0, this.spans.length-1).each(function(r) { slider.setSpan(slider.spans[r], slider.getRange(r)); });
184
+ }
185
+ if (this.options.startSpan) {
186
+ this.setSpan(this.options.startSpan,
187
+ $R(0, this.values.length>1 ? this.getRange(0).min() : this.value ));
188
+ }
189
+ if (this.options.endSpan) {
190
+ this.setSpan(this.options.endSpan,
191
+ $R(this.values.length>1 ? this.getRange(this.spans.length-1).max() : this.value, this.maximum));
192
+ }
193
+ },
194
+ setSpan: function(span, range) {
195
+ if (this.isVertical()) {
196
+ span.style.top = this.translateToPx(range.start);
197
+ span.style.height = this.translateToPx(range.end - range.start + this.range.start);
198
+ } else {
199
+ span.style.left = this.translateToPx(range.start);
200
+ span.style.width = this.translateToPx(range.end - range.start + this.range.start);
201
+ }
202
+ },
203
+ updateStyles: function() {
204
+ this.handles.each( function(h){ Element.removeClassName(h, 'selected'); });
205
+ Element.addClassName(this.activeHandle, 'selected');
206
+ },
207
+ startDrag: function(event) {
208
+ if (Event.isLeftClick(event)) {
209
+ if (!this.disabled){
210
+ this.active = true;
211
+
212
+ var offsets;
213
+ var handle = Event.element(event);
214
+ var pointer = [Event.pointerX(event), Event.pointerY(event)];
215
+ var track = handle;
216
+ if (track==this.track) {
217
+ offsets = Position.cumulativeOffset(this.track);
218
+ this.event = event;
219
+ this.setValue(this.translateToValue(
220
+ (this.isVertical() ? pointer[1]-offsets[1] : pointer[0]-offsets[0])-(this.handleLength/2)
221
+ ));
222
+ offsets = Position.cumulativeOffset(this.activeHandle);
223
+ this.offsetX = (pointer[0] - offsets[0]);
224
+ this.offsetY = (pointer[1] - offsets[1]);
225
+ } else {
226
+ // find the handle (prevents issues with Safari)
227
+ while((this.handles.indexOf(handle) == -1) && handle.parentNode) {
228
+ handle = handle.parentNode;
229
+ }
230
+
231
+ if (this.handles.indexOf(handle)!=-1) {
232
+ this.activeHandle = handle;
233
+ this.activeHandleIdx = this.handles.indexOf(this.activeHandle);
234
+ this.updateStyles();
235
+
236
+ offsets = Position.cumulativeOffset(this.activeHandle);
237
+ this.offsetX = (pointer[0] - offsets[0]);
238
+ this.offsetY = (pointer[1] - offsets[1]);
239
+ }
240
+ }
241
+ }
242
+ Event.stop(event);
243
+ }
244
+ },
245
+ update: function(event) {
246
+ if (this.active) {
247
+ if (!this.dragging) { this.dragging = true; }
248
+ this.draw(event);
249
+ if (Prototype.Browser.WebKit) { window.scrollBy(0,0); }
250
+ Event.stop(event);
251
+ }
252
+ },
253
+ draw: function(event) {
254
+ var pointer = [Event.pointerX(event), Event.pointerY(event)];
255
+ var offsets = Position.cumulativeOffset(this.track);
256
+ pointer[0] -= this.offsetX + offsets[0];
257
+ pointer[1] -= this.offsetY + offsets[1];
258
+ this.event = event;
259
+ this.setValue(this.translateToValue( this.isVertical() ? pointer[1] : pointer[0] ));
260
+ if (this.initialized && this.options.onSlide) {
261
+ this.options.onSlide(this.values.length>1 ? this.values : this.value, this);
262
+ }
263
+ },
264
+ endDrag: function(event) {
265
+ if (this.active && this.dragging) {
266
+ this.finishDrag(event, true);
267
+ Event.stop(event);
268
+ }
269
+ this.active = false;
270
+ this.dragging = false;
271
+ },
272
+ finishDrag: function(event, success) {
273
+ this.active = false;
274
+ this.dragging = false;
275
+ this.updateFinished();
276
+ },
277
+ updateFinished: function() {
278
+ if (this.initialized && this.options.onChange) {
279
+ this.options.onChange(this.values.length>1 ? this.values : this.value, this);
280
+ }
281
+ this.event = null;
282
+ }
283
+ });
@@ -0,0 +1,67 @@
1
+ // Copyright (c) 2005-2008 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
2
+ //
3
+ // Based on code created by Jules Gravinese (http://www.webveteran.com/)
4
+ //
5
+ // script.aculo.us is freely distributable under the terms of an MIT-style license.
6
+ // For details, see the script.aculo.us web site: http://script.aculo.us/
7
+
8
+ Sound = {
9
+ tracks: {},
10
+ _enabled: true,
11
+ template:
12
+ new Template('<embed style="height:0" id="sound_#{track}_#{id}" src="#{url}" loop="false" autostart="true" hidden="true"/>'),
13
+ enable: function(){
14
+ Sound._enabled = true;
15
+ },
16
+ disable: function(){
17
+ Sound._enabled = false;
18
+ },
19
+ stop: function(track) {
20
+ $R(0, this.tracks[track].id).each(function(id){
21
+ var sound = $('sound_' + track + '_' + id);
22
+ if (sound.Stop) { sound.Stop(); }
23
+ sound.remove();
24
+ });
25
+ delete this.tracks[track];
26
+ },
27
+ play: function(url){
28
+ if(!Sound._enabled) { return; }
29
+ var options = Object.extend({
30
+ track: 'global', url: url, replace: false
31
+ }, arguments[1] || {});
32
+
33
+ if(options.replace && this.tracks[options.track]) {
34
+ $R(0, this.tracks[options.track].id).each(function(id){
35
+ var sound = $('sound_'+options.track+'_'+id);
36
+ if (sound.Stop) { sound.Stop(); }
37
+ sound.remove();
38
+ });
39
+ this.tracks[options.track] = null;
40
+ }
41
+
42
+ if(!this.tracks[options.track]) {
43
+ this.tracks[options.track] = { id: 0 };
44
+ } else {
45
+ this.tracks[options.track].id++;
46
+ }
47
+
48
+ options.id = this.tracks[options.track].id;
49
+ $$('body')[0].insert(
50
+ Prototype.Browser.IE ? new Element('bgsound',{
51
+ id: 'sound_'+options.track+'_'+options.id,
52
+ src: options.url, loop: 1, autostart: true
53
+ }) : Sound.template.evaluate(options));
54
+ }
55
+ };
56
+
57
+ if(Prototype.Browser.Gecko && navigator.userAgent.indexOf("Win") > 0){
58
+ if(navigator.plugins && $A(navigator.plugins).detect(function(p){ return p.name.indexOf('QuickTime') != -1; })) {
59
+ Sound.template = new Template('<object id="sound_#{track}_#{id}" width="0" height="0" type="audio/mpeg" data="#{url}"/>');
60
+ } else if(navigator.plugins && $A(navigator.plugins).detect(function(p){ return p.name.indexOf('Windows Media') != -1; })) {
61
+ Sound.template = new Template('<object id="sound_#{track}_#{id}" type="application/x-mplayer2" data="#{url}"></object>');
62
+ } else if(navigator.plugins && $A(navigator.plugins).detect(function(p){ return p.name.indexOf('RealPlayer') != -1; })) {
63
+ Sound.template = new Template('<embed type="audio/x-pn-realaudio-plugin" style="height:0" id="sound_#{track}_#{id}" src="#{url}" loop="false" autostart="true" hidden="true"/>');
64
+ } else {
65
+ Sound.play = function(){};
66
+ }
67
+ }
@@ -0,0 +1,6 @@
1
+ describe(rio.components.Box, {
2
+ beforeEach: function() {
3
+
4
+ }
5
+
6
+ });
@@ -0,0 +1,26 @@
1
+ describe(rio.components.Checkbox, {
2
+ beforeEach: function() {
3
+ this.checkbox = rio.components.Checkbox.example("checked");
4
+ insertComponent(this.checkbox);
5
+ },
6
+
7
+ "should have an html checkbox element": function() {
8
+ this.checkbox.html().childElements()[0].tagName.shouldEqual("INPUT");
9
+ this.checkbox.html().childElements()[0].type.shouldEqual("checkbox");
10
+ },
11
+
12
+ "should have a checked html element": function() {
13
+ this.checkbox.html().childElements()[0].checked.shouldBeTrue();
14
+ },
15
+
16
+ "should update the checked attribute when updating the html checkbox": function() {
17
+ this.checkbox.html().childElements()[0].simulate("click");
18
+ this.checkbox.getChecked().shouldBeFalse();
19
+ },
20
+
21
+ "should update the html checked attribute when update the checked attribute": function() {
22
+ this.checkbox.setChecked(false);
23
+ this.checkbox.html().childElements()[0].checked.shouldBeFalse();
24
+ }
25
+
26
+ });
@@ -0,0 +1,6 @@
1
+ describe(rio.components.Container, {
2
+ beforeEach: function() {
3
+
4
+ }
5
+
6
+ });
@@ -0,0 +1,71 @@
1
+ describe(rio.components.Input, {
2
+
3
+ "with no value or class names": {
4
+ beforeEach: function() {
5
+ this.inputBox = rio.components.Input.example("empty");
6
+ insertComponent(this.inputBox);
7
+ },
8
+
9
+ "should have an empty string for value": function() {
10
+ this.inputBox.getValue().shouldEqual("");
11
+ },
12
+
13
+ "should have an html input box value of empty string": function() {
14
+ this.inputBox.html().value.shouldEqual("");
15
+ },
16
+
17
+ "should update the html input box value when the value is set": function() {
18
+ this.inputBox.setValue("new value");
19
+ this.inputBox.html().value.shouldEqual("new value");
20
+ },
21
+
22
+ "should update the value when the html input box value is updated": function() {
23
+ this.inputBox.html().enterText("some typed in value");
24
+ this.inputBox.getValue().shouldEqual("some typed in value");
25
+ },
26
+
27
+ "should blur when the enter key is pressed": function() {
28
+ this.inputBox.html().simulate("focus");
29
+ focus();
30
+ this.inputBox.html().observe("blur", function() {}.shouldBeCalled);
31
+ this.inputBox.html().simulate("keypress", { character: "\n" });
32
+ },
33
+
34
+ "should have a className of input": function() {
35
+ this.inputBox.html().className.strip().shouldEqual("input");
36
+ }
37
+ },
38
+
39
+ "with a starting value of hello, a class name of world, and hover/focus class names": {
40
+ beforeEach: function() {
41
+ this.inputBox = rio.components.Input.example("helloWorld");
42
+ insertComponent(this.inputBox);
43
+ },
44
+
45
+ "should have a value of 'hello'": function() {
46
+ this.inputBox.getValue().shouldEqual("hello");
47
+ },
48
+
49
+ "should have an html input box value of hello": function() {
50
+ this.inputBox.html().value.shouldEqual("hello");
51
+ },
52
+
53
+ "should have a className of 'input world'": function() {
54
+ this.inputBox.html().className.shouldEqual("input world");
55
+ },
56
+
57
+ "should include the hover className on hover": function() {
58
+ this.inputBox.html().simulate("mouseover");
59
+ this.inputBox.html().hasClassName("hover").shouldBeTrue();
60
+ this.inputBox.html().simulate("mouseout");
61
+ this.inputBox.html().hasClassName("hover").shouldBeFalse();
62
+ },
63
+
64
+ "should include the focus className on focus": function() {
65
+ this.inputBox.html().simulate("focus");
66
+ this.inputBox.html().hasClassName("focus").shouldBeTrue();
67
+ this.inputBox.html().simulate("blur");
68
+ this.inputBox.html().hasClassName("focus").shouldBeFalse();
69
+ }
70
+ }
71
+ });