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,43 @@
1
+ rio.components.Link = rio.Component.create(rio.components.Base, "Link", {
2
+ requireCss: "link",
3
+ attrAccessors: ["content", "href"],
4
+ attrReaders: ["className", ["realLink", false]],
5
+ attrEvents: ["click"],
6
+ styles: ["color"],
7
+ methods: {
8
+ buildHtml: function() {
9
+ var linkHtml = rio.Tag.a("", {
10
+ href: "",
11
+ className: this.getClassName() || "link"
12
+ });
13
+
14
+ this.bind("href", function(href) {
15
+ linkHtml.href = href || "";
16
+ });
17
+
18
+ this.bind("content", function(content) {
19
+ if (Object.isArray(content)) {
20
+ linkHtml.update();
21
+ for (var i=0, length=content.length; i<length; i++) {
22
+ linkHtml.insert(content[i]);
23
+ }
24
+ } else {
25
+ linkHtml.update(content);
26
+ }
27
+ }.bind(this));
28
+
29
+ linkHtml.observe("click", function(e) {
30
+ this.fire("click");
31
+ if(this.getRealLink()) {
32
+ rio.Utils.navigateTo(this.getHref());
33
+ } else {
34
+ e.stop();
35
+ }
36
+ }.bindAsEventListener(this));
37
+
38
+ linkHtml.applyStyle({ color: this.color });
39
+
40
+ return linkHtml;
41
+ }
42
+ }
43
+ });
@@ -0,0 +1,44 @@
1
+ rio.components.ListItem = rio.Component.create(rio.components.Base, "ListItem", {
2
+ attrAccessors: [["selected", false]],
3
+ attrReaders: [
4
+ "item",
5
+ "renderer",
6
+ ["className", "listItem"],
7
+ ["hoverClassName", "listItemHover"],
8
+ ["selectedClassName", "listItemSelected"],
9
+ ["stopClickPropogation", false]
10
+ ],
11
+ attrEvents: ["click"],
12
+ methods: {
13
+ buildHtml: function() {
14
+ var listItemHtml = this.getRenderer()(this.getItem());
15
+
16
+ listItemHtml.observe("mouseover", function() {
17
+ listItemHtml.addClassName(this.getHoverClassName());
18
+ }.bind(this));
19
+ listItemHtml.observe("mouseout", function() {
20
+ listItemHtml.removeClassName(this.getHoverClassName());
21
+ }.bind(this));
22
+ listItemHtml.observe("click", function(e) {
23
+ this.click();
24
+ if (this.getStopClickPropogation()) {
25
+ e.stop();
26
+ }
27
+ }.bindAsEventListener(this));
28
+
29
+ this.bind("selected", function(selected) {
30
+ listItemHtml[selected ? "addClassName" : "removeClassName"](this.getSelectedClassName());
31
+ }.bind(this));
32
+
33
+ return listItemHtml;
34
+ },
35
+
36
+ click: function() {
37
+ this.fire("click");
38
+ },
39
+
40
+ scrollTo: function() {
41
+ this.fire("scrollTo");
42
+ }
43
+ }
44
+ });
@@ -0,0 +1,192 @@
1
+ rio.Application.require("components/box");
2
+ rio.Application.require("components/list_item");
3
+
4
+ rio.components.ListView = rio.Component.create(rio.components.Box, "ListView", {
5
+ requireCss: "list_view",
6
+ attrAccessors: [
7
+ "items",
8
+ "selectedItem",
9
+ ["listItems", []],
10
+ ["overflow", "auto"]
11
+ ],
12
+ attrReaders: [
13
+ ['className', 'listView'],
14
+ ["itemRenderer", function(val) { return rio.Tag.div(val); }],
15
+ ["listItemBuilder", function(item, renderer){ return new rio.components.ListItem({item: item, renderer: renderer}); }],
16
+ ["autoSelectFirstItem", false]
17
+ ],
18
+ attrEvents: ["selectNext", "selectPrevious", "itemClick"],
19
+ methods: {
20
+ buildHtml: function() {
21
+ var listHtml = this.boxHtml();
22
+ // listHtml.addClassName("listView");
23
+ this.addBindings(listHtml);
24
+
25
+ return listHtml;
26
+ },
27
+
28
+ addBindings: function(listHtml) {
29
+ if (!this._unbindings) { this._unbindings = []; }
30
+ var unbindItems = this.bind("items", {
31
+ set: function(items) {
32
+ listHtml.update();
33
+ this.setListItems([]);
34
+ if (items) {
35
+ for (var i=0, len=items.length; i < len; i++) {
36
+ this.insertItem(items[i], this.getListItems().size(), listHtml);
37
+ }
38
+ }
39
+ }.bind(this),
40
+ insert: function(val, atIndex) {
41
+ this.insertItem(val, atIndex, listHtml);
42
+ }.bind(this),
43
+ remove: function(val) {
44
+ this.removeItem(val, listHtml);
45
+ }.bind(this)
46
+ });
47
+ this._unbindings.push(unbindItems);
48
+
49
+ this.bind("selectedItem", function(item) {
50
+ if(item) {
51
+ this.getListItems().each(function(li) {
52
+ if (li.getItem() != item) {
53
+ li.setSelected(false);
54
+ }
55
+ });
56
+ if(this.getListItemForItem(item)){
57
+ this.getListItemForItem(item).setSelected(true);
58
+ }
59
+ }
60
+ }.bind(this));
61
+ },
62
+
63
+ insertItem: function(val, atIndex, insertInto) {
64
+ insertInto = insertInto || this.html();
65
+ var listItem = this.getListItemBuilder()(val, this.getItemRenderer());
66
+ if (this.getSelectedItem() == listItem.getItem()) {
67
+ listItem.setSelected(true);
68
+ }
69
+ listItem.bind("selected", function(selected) {
70
+ if (selected) {
71
+ this.setSelectedItem(listItem.getItem());
72
+ } else {
73
+ if (listItem.getItem() == this.getSelectedItem()) {
74
+ this.setSelectedItem(null);
75
+ }
76
+ }
77
+ }.bind(this));
78
+
79
+ listItem.observe("click", function() {
80
+ this.setSelectedItem(listItem.getItem());
81
+ this.fire("itemClick", listItem.getItem());
82
+ }.bind(this));
83
+ listItem.observe("scrollTo", function() {
84
+ var listItemHtml = listItem.html();
85
+ var listItemTop = listItemHtml.positionedOffset().top;
86
+ var listItemBottom = listItemTop + listItemHtml.getDimensions().height;
87
+ var bottomOfList = insertInto.scrollTop + insertInto.getDimensions().height;
88
+ if (bottomOfList < listItemBottom || listItemTop < insertInto.scrollTop) {
89
+ insertInto.scrollTop = listItemTop;
90
+ }
91
+ }.bind(this));
92
+
93
+ if (atIndex == 0) {
94
+ if (this.getListItems().size() == 0) {
95
+ insertInto.insert(listItem);
96
+ } else {
97
+ this.getListItems()[atIndex].html().insert({ before: listItem.html() });
98
+ }
99
+ } else {
100
+ this.getListItems()[atIndex - 1].html().insert({ after: listItem.html() });
101
+ }
102
+
103
+ this.getListItems().splice(atIndex, 0, listItem);
104
+
105
+ if (this.getAutoSelectFirstItem() && this.getListItems().size() == 1) {
106
+ this.setSelectedItem(listItem.getItem());
107
+ }
108
+ },
109
+
110
+ removeItem: function(val, removeFrom) {
111
+ removeFrom = removeFrom || this.html();
112
+ var foundItem = this.getListItems().detect(function(listItem) { return listItem.getItem() == val; });
113
+ if (foundItem) {
114
+ var index = this.getListItems().indexOf(foundItem);
115
+ if (foundItem.html().parentNode == removeFrom) {
116
+ var foundWasSelected = this.getSelectedIndex() == index;
117
+ foundItem.html().remove();
118
+ if(foundWasSelected) {
119
+ this.pendingSelect(index);
120
+ }
121
+ }
122
+ this.getListItems().splice(index, 1);
123
+ }
124
+ },
125
+
126
+ pendingSelect: function(index) {
127
+ this._pendingId = (function() {
128
+ this.selectIndex(index);
129
+ delete this._pendingId;
130
+ }.bind(this)).defer();
131
+ },
132
+
133
+ clearPendingSelect: function() {
134
+ if (this._pendingId != undefined) {
135
+ clearTimeout(this._pendingId);
136
+ }
137
+ },
138
+
139
+ getSelectedIndex: function(){
140
+ return this.getListItems().indexOf(this.getSelectedListItem());
141
+ },
142
+
143
+ selectNext: function(){
144
+ this.selectIndex(this.getSelectedIndex() + 1);
145
+ },
146
+
147
+ selectLast: function() {
148
+ this.selectIndex(this.getListItems().length - 1);
149
+ },
150
+
151
+ selectFirst: function() {
152
+ this.selectIndex(0);
153
+ },
154
+
155
+ selectAfterItem: function(item) {
156
+ this.selectIndex(this.getIndexOfItem(item) + 1);
157
+ },
158
+
159
+ selectPrevious: function(){
160
+ this.selectIndex(this.getSelectedIndex() - 1);
161
+ },
162
+
163
+ selectIndex: function(indexToSelect){
164
+ if(this.getListItems().length == 0){return;}
165
+ if(indexToSelect < 0){
166
+ this.fire("selectPrevious");
167
+ return;
168
+ }
169
+ if(indexToSelect >= this.getListItems().length){
170
+ this.fire("selectNext");
171
+ return;
172
+ }
173
+
174
+ this.setSelectedItem(this.getListItems()[indexToSelect].getItem());
175
+ },
176
+ getIndexOfItem: function(item){
177
+ return this.getListItems().indexOf(this.getListItemForItem(item));
178
+ },
179
+ getIndexOfListItem: function(listItem){
180
+ return this.getListItems().indexOf(listItem);
181
+ },
182
+ getSelectedListItem: function(){
183
+ return this.getListItemForItem(this.getSelectedItem());
184
+ },
185
+ getListItemForItem: function(item){
186
+ return this.getListItems().detect(function(listItem){
187
+ return listItem.getItem() == item;
188
+ });
189
+ }
190
+ }
191
+ });
192
+
@@ -0,0 +1,131 @@
1
+ rio.components.Marquee = rio.Component.create();
2
+
3
+ rio.components.Marquee.requireCss("marquee");
4
+
5
+ rio.components.Marquee.attrReader("initLeft");
6
+ rio.components.Marquee.attrReader("initTop");
7
+ rio.components.Marquee.attrReader("backgroundColor", "#669");
8
+ rio.components.Marquee.attrReader("onComplete", Prototype.emptyFunction);
9
+
10
+ rio.components.Marquee.attrHtml("background", "antsTop", "antsLeft", "antsBottom", "antsRight");
11
+
12
+ rio.Component.extend(rio.components.Marquee, {
13
+ initialize: function(options) {
14
+ this._marqueeMove = this.marqueeMove.bindAsEventListener(this);
15
+ this._marqueeComplete = this.marqueeComplete.bindAsEventListener(this);
16
+ this._keyPress = this.keyPress.bindAsEventListener(this);
17
+
18
+ Event.observe(document, "mousemove", this._marqueeMove);
19
+ Event.observe(document, "mouseup", this._marqueeComplete);
20
+ Event.observe(document, "keypress", this._keyPress);
21
+
22
+ var bod = Element.body();
23
+ bod.insert(this.html());
24
+ },
25
+
26
+ buildHtml: function() {
27
+ return rio.Tag.div([this.antsTopHtml(), this.antsLeftHtml(), this.antsBottomHtml(), this.antsRightHtml(), this.backgroundHtml()], {
28
+ style: "z-index: 9999; left: " + this.getInitLeft() + "px; top: " + this.getInitTop() + "px; width: 0px; height: 0px; font-size: 0px;",
29
+ className: "marquee"
30
+ });
31
+ },
32
+
33
+ buildBackgroundHtml: function() {
34
+ return rio.Tag.div('', {
35
+ className: "marqueeBackground",
36
+ style: "background-color: " + this.getBackgroundColor()
37
+ });
38
+ },
39
+
40
+ buildAntsHtml: function(pos) {
41
+ return rio.Tag.span('', { className: pos + "Ants" });
42
+ },
43
+
44
+ buildAntsTopHtml: function() { return this.buildAntsHtml("top"); },
45
+ buildAntsLeftHtml: function() { return this.buildAntsHtml("left"); },
46
+ buildAntsBottomHtml: function() { return this.buildAntsHtml("bottom"); },
47
+ buildAntsRightHtml: function() { return this.buildAntsHtml("right"); },
48
+
49
+ marqueeMove: function(e) {
50
+ var offsets = document.viewport.getScrollOffsets();
51
+ var x = e.clientX + offsets[0];
52
+ var y = e.clientY + offsets[1];
53
+ var initLeft = this.getInitLeft();
54
+ var initTop = this.getInitTop();
55
+
56
+ if (initLeft < x) {
57
+ this.setLeft(initLeft);
58
+ this.setWidth(x - initLeft);
59
+ } else {
60
+ this.setLeft(x);
61
+ this.setWidth(initLeft - x);
62
+ }
63
+
64
+ if (initTop < y) {
65
+ this.setTop(initTop);
66
+ this.setHeight(y - initTop);
67
+ } else {
68
+ this.setTop(y);
69
+ this.setHeight(initTop - y);
70
+ }
71
+ },
72
+
73
+ setLeft: function(newLeft) {
74
+ this.html().style.left = newLeft + "px";
75
+ },
76
+
77
+ getLeft: function() {
78
+ return this.html().cumulativeOffset()[0];
79
+ },
80
+
81
+ setTop: function(newTop) {
82
+ this.html().style.top = newTop + "px";
83
+ },
84
+
85
+ getTop: function() {
86
+ return this.html().cumulativeOffset()[1];
87
+ },
88
+
89
+ getWidth: function() {
90
+ return this.html().getWidth();
91
+ },
92
+
93
+ setWidth: function(newWidth) {
94
+ this.html().style.width = newWidth + "px";
95
+ this.backgroundHtml().style.width = newWidth + "px";
96
+ },
97
+
98
+ getHeight: function() {
99
+ return this.html().getHeight();
100
+ },
101
+
102
+ setHeight: function(newHeight) {
103
+ this.html().style.height = newHeight + "px";
104
+ this.backgroundHtml().style.height = newHeight + "px";
105
+ },
106
+
107
+ marqueeComplete: function(e) {
108
+ this.getOnComplete()({
109
+ left: this.getLeft(),
110
+ top: this.getTop(),
111
+ width: this.getWidth(),
112
+ height: this.getHeight()
113
+ });
114
+ this.killMarquee();
115
+ },
116
+
117
+ killMarquee: function() {
118
+ Event.stopObserving(document, "mousemove", this._marqueeMove);
119
+ Event.stopObserving(document, "mouseup", this._marqueeComplete);
120
+ Event.stopObserving(document, "keypress", this._keyPress);
121
+
122
+ this.html().remove();
123
+ },
124
+
125
+ keyPress: function(e) {
126
+ if (e.keyCode == Event.KEY_ESC) {
127
+ this.killMarquee();
128
+ e.stop();
129
+ }
130
+ }
131
+ });
@@ -0,0 +1,89 @@
1
+ rio.components.Menu = rio.Component.create("Menu", {
2
+ requireCss: "menu",
3
+
4
+ attrAccessors: [
5
+ ["items", []],
6
+ ["left", 0],
7
+ ["top", 0]
8
+ ],
9
+
10
+ attrHtmls: ["overlay"],
11
+
12
+ methods: {
13
+ buildHtml: function() {
14
+ var menuHtml = rio.Tag.div("", { className: "menu" });
15
+
16
+ menuHtml.setStyle({
17
+ left: this.getLeft() + "px",
18
+ top: this.getTop() + "px"
19
+ });
20
+
21
+ var insertItem = function(item) {
22
+ menuHtml.insert(item.html());
23
+ item.observe("click", this.click.bind(this));
24
+ }.bind(this);
25
+
26
+ var removeItem = function(item) {
27
+ item.html().remove();
28
+ }.bind(this);
29
+
30
+ this.bind("items", {
31
+ set: function(items) {
32
+ if (items) {
33
+ items.each(function(item) {
34
+ insertItem(item);
35
+ }.bind(this));
36
+ }
37
+ }.bind(this),
38
+
39
+ insert: insertItem,
40
+ remove: removeItem
41
+ });
42
+
43
+ return menuHtml;
44
+ },
45
+
46
+ buildOverlayHtml: function() {
47
+ var overlayHtml = rio.Tag.div("", { className: "menuOverlay" });
48
+ Event.observe(overlayHtml, "mousedown", this.click.bind(this));
49
+ return overlayHtml;
50
+ },
51
+
52
+ render: function() {
53
+ Element.body().insert(this.overlayHtml());
54
+ Element.body().insert(this.html());
55
+ },
56
+
57
+ click: function() {
58
+ this.close();
59
+ },
60
+
61
+ close: function() {
62
+ this.html().remove();
63
+ this.overlayHtml().remove();
64
+ }
65
+ }
66
+ });
67
+
68
+ rio.components.MenuItem = rio.Component.create("MenuItem", {
69
+ attrAccessors: ["text"],
70
+ attrEvents: ["click"],
71
+ methods: {
72
+ buildHtml: function() {
73
+ var itemHtml = rio.Tag.div("", { className: "menuItem" });
74
+ itemHtml.addHoverClass("menuItemHover");
75
+
76
+ this.bind("text", function(text) {
77
+ itemHtml.update(text);
78
+ });
79
+
80
+ itemHtml.observe("click", this.click.bind(this));
81
+
82
+ return itemHtml;
83
+ },
84
+
85
+ click: function() {
86
+ this.fire("click");
87
+ }
88
+ }
89
+ });