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,64 @@
1
+ rio.Application.require("components/box");
2
+
3
+ rio.components.TabBar = rio.Component.create(rio.components.Box, "TabBar", {
4
+ requireCss: "tab_bar",
5
+ attrReaders: [["tabs", []]],
6
+ attrHtmls: ["tabs"],
7
+ methods: {
8
+ buildHtml: function() {
9
+ var tabBarHtml = rio.Tag.ul(this.tabsHtml(), { className: "tabBar" });
10
+ var tabBarBottom = rio.Tag.div("", { className: "tabBarBottom" });
11
+ var html = rio.Tag.div([tabBarHtml, tabBarBottom], { className: "tabBarWrapper" });
12
+ html.applyStyle(this.boxStyles());
13
+ return html;
14
+ },
15
+
16
+ buildTabsHtml: function() {
17
+ var tabs = this.getTabs();
18
+ tabs.each(function(tab) {
19
+ tab.selected.bind(function(selected) {
20
+ if (selected) {
21
+ tabs.without(tab).each(function(toDeselect) { toDeselect.setSelected(false); });
22
+ }
23
+ });
24
+ });
25
+ if (!tabs.any(function(tab) { return tab.getSelected(); })) {
26
+ tabs.first().setSelected(true);
27
+ }
28
+ return tabs.map(function(tab) { return tab.html(); });
29
+ },
30
+
31
+ selectNext: function() {
32
+ this.getTabs()[(this.selectedIndex() + 1) % this.getTabs().length].setSelected(true);
33
+ },
34
+
35
+ selectPrevious: function() {
36
+ this.getTabs()[(this.selectedIndex() - 1 + this.getTabs().length) % this.getTabs().length].setSelected(true);
37
+ },
38
+
39
+ selectedIndex: function() {
40
+ return this.getTabs().indexOf(this.getTabs().detect(function(t) { return t.getSelected(); }));
41
+ }
42
+ }
43
+ });
44
+
45
+ rio.components.Tab = rio.Component.create("Tab", {
46
+ attrAccessors: ["name", ["selected", false]],
47
+ methods: {
48
+ buildHtml: function() {
49
+
50
+ var html = rio.Tag.li("");
51
+ html.addHoverClass("tabHover");
52
+ this.name.bind(function(name) {
53
+ html.update(name);
54
+ });
55
+ this.selected.bind(function(selected) {
56
+ html.className = selected ? "tabSelected" : "tab";
57
+ }.bind(this));
58
+
59
+ html.observe("click", this.setSelected.bind(this, true));
60
+
61
+ return html;
62
+ }
63
+ }
64
+ });
@@ -0,0 +1,57 @@
1
+ rio.Application.require("components/box");
2
+
3
+ rio.components.TabPanel = rio.Component.create(rio.components.Box, "TabPanel", {
4
+ require: ["components/panel", "components/tab_bar"],
5
+ requireCss: "tab_panel",
6
+ attrReaders: [
7
+ ["resizable", false],
8
+ "maxWidth",
9
+ "minWidth",
10
+ "maxHeight",
11
+ "minHeight",
12
+ ["layout", false],
13
+ ["tabs", []],
14
+ "panel"
15
+ ],
16
+ attrHtmls: ["tab"],
17
+ methods: {
18
+ initialize: function() {
19
+ this._panel = new rio.components.Panel({
20
+ resizable: this.getResizable(),
21
+ maxWidth: this.getMaxWidth(),
22
+ minWidth: this.getMinWidth(),
23
+ maxHeight: this.getMaxHeight(),
24
+ minHeight: this.getMinHeight(),
25
+ layout: this.getLayout(),
26
+ region: this.getRegion(),
27
+ className: "tabPanel"
28
+ });
29
+ },
30
+
31
+ buildHtml: function() {
32
+ this.getPanel().buildTitleHtml = function() {
33
+ return this.tabHtml();
34
+ }.bind(this);
35
+ return this.getPanel().html();
36
+ },
37
+
38
+ buildTabHtml: function() {
39
+ return new rio.components.TabBar({
40
+ className: "tabPanelTabBar",
41
+ tabs: this.getTabs().map(function(tab) {
42
+ var tabComponent = new rio.components.Tab({ name: tab.title, selected: tab.selected });
43
+ tabComponent.selected.bind(function(selected) {
44
+ if (selected) {
45
+ this.getPanel().setItems(tab.items);
46
+ }
47
+ }.bind(this));
48
+ return tabComponent;
49
+ }.bind(this))
50
+ }).html();
51
+ },
52
+
53
+ resize: function() {
54
+ this.getPanel().resize();
55
+ }
56
+ }
57
+ });
@@ -0,0 +1,223 @@
1
+ rio.components.Textarea = rio.Component.create(rio.components.Base, "Textarea", {
2
+ requireCss: "textarea",
3
+ attrReaders: [
4
+ ["className", "textarea"],
5
+ ["hoverClassName", ""],
6
+ ["focusClassName", ""],
7
+ ["sync", "blur"], // options are "blur", "type", "none", "always"
8
+ ["typeSyncDelay", 250],
9
+ ["tabIndex", 0],
10
+ ["revertOnEscape", false],
11
+ ["stopEnterEvent", false],
12
+ ["autoGrow", false],
13
+ ["rioUndo", false]
14
+ ],
15
+ attrAccessors: [
16
+ ["value", ""],
17
+ ["focus", false],
18
+ ["readOnly", false]
19
+ ],
20
+ attrEvents: ["enter", "keyPress", "keyDown", "keyUp", "focus", "blur", "resize"],
21
+ attrHtmls: ["textarea"],
22
+ styles: ["height"],
23
+ methods: {
24
+ buildHtml: function() {
25
+ var html = rio.Tag.div("", {
26
+ className: this.getClassName(),
27
+ style: "padding-bottom: 1px"
28
+ });
29
+ html.addHoverClass(this.getHoverClassName());
30
+ html.insert(this.textareaHtml());
31
+ html.applyStyle({ height: this.height });
32
+ return html;
33
+ },
34
+
35
+ buildTextareaHtml: function() {
36
+ var textareaHtml = rio.Tag.textarea("", {
37
+ href: "",
38
+ onclick: "return false;",
39
+ tabIndex: this.getTabIndex(),
40
+ rows: 1,
41
+ style: "backgroundColor: transparent; border: none; width: 100%;"
42
+ });
43
+
44
+ this.readOnly.bind(function(readOnly) {
45
+ textareaHtml.readOnly = readOnly;
46
+ });
47
+
48
+ var updateHeight = Prototype.emptyFunction;
49
+ if (this.getAutoGrow()) {
50
+ updateHeight = this.resize.bind(this, textareaHtml);
51
+ updateHeight.defer();
52
+ Event.observe(window, "resize", updateHeight);
53
+ } else {
54
+ textareaHtml.setStyle({ height: "100%" });
55
+ }
56
+
57
+ this.bind("value", function(value) {
58
+ if (textareaHtml.value != value) {
59
+ textareaHtml.value = value;
60
+ updateHeight();
61
+ }
62
+ });
63
+ // this.cursorEnd.bind(this).defer();
64
+ this.bind("focus", function(focus){
65
+ if(focus){
66
+ if (!this._nativeFocus) {
67
+ textareaHtml.focus();
68
+ }
69
+ } else {
70
+ // if this is a native blur we shouldn't follow it up with another call to blur. It will result in weird behavior.
71
+ if (!this._nativeBlur) {
72
+ textareaHtml.blur();
73
+ }
74
+ }
75
+ }.bind(this));
76
+
77
+ textareaHtml.observe('blur', function(){
78
+ this.html().removeClassName(this.getFocusClassName());
79
+ this._nativeBlur = true;
80
+ this.setFocus(false);
81
+ this.fire("blur");
82
+ this._nativeBlur = false;
83
+ this._valueAtLastBlur = textareaHtml.value;
84
+ }.bind(this));
85
+ textareaHtml.observe('focus', function(){
86
+ this.html().addClassName(this.getFocusClassName());
87
+ this._nativeFocus = true;
88
+ this.setFocus(true);
89
+ this.fire("focus");
90
+ this._nativeFocus = false;
91
+ }.bind(this));
92
+
93
+ textareaHtml.observe('change', function() {
94
+ if (this.getSync() != "none") {
95
+ this.setValue(textareaHtml.value);
96
+ }
97
+ updateHeight();
98
+ this.fire("change");
99
+ }.bind(this));
100
+ textareaHtml.observe('keypress', function(e) {
101
+ if (e.keyCode == Event.KEY_RETURN) {
102
+ this.fire('enter');
103
+ if (this.getStopEnterEvent()) { e.stop(); }
104
+ }
105
+ if (e.keyCode == Event.KEY_ESC && this.getRevertOnEscape()) {
106
+ this.revert();
107
+ textareaHtml.blur();
108
+ }
109
+ this.fire("keyPress", e);
110
+ }.bindAsEventListener(this));
111
+
112
+ var undoKeyMap = rio.KeyMap.build([
113
+ {
114
+ mac: { meta: true, alt: false, shift: false, key: "z" },
115
+ win: { ctrl: true, alt: false, key: "z" },
116
+ handler: function(e) {
117
+ if (this.getRioUndo() && (this.getValue() == textareaHtml.value)) {
118
+ rio.Undo.undo();
119
+ e.stop();
120
+ }
121
+ }.bind(this)
122
+ },
123
+ {
124
+ mac: { meta: true, alt: false, shift: true, key: "z" },
125
+ win: { ctrl: true, alt: false, key: "y" },
126
+ handler: function(e) {
127
+ if (this.getRioUndo() && (this.getValue() == textareaHtml.value)) {
128
+ rio.Undo.redo();
129
+ e.stop();
130
+ }
131
+ }.bind(this)
132
+ }
133
+ ]);
134
+
135
+ textareaHtml.observe('keydown', function(e) {
136
+ if (!this.getReadOnly()) {
137
+ undoKeyMap.handle(e);
138
+ }
139
+
140
+ if (this.getSync() == "type") {
141
+ if (!this._syncAfter) { this._syncAfter = new rio.DelayedTask(); }
142
+ this._syncAfter.delay(this.getTypeSyncDelay(), function() {
143
+ this.setValue(textareaHtml.value);
144
+ }, this);
145
+ } else if (this.getSync() == "always") {
146
+ (function() {
147
+ this.setValue(textareaHtml.value);
148
+ }.bind(this)).defer();
149
+ }
150
+ updateHeight();
151
+ this.fire("keyDown", e);
152
+ }.bindAsEventListener(this));
153
+ textareaHtml.observe('keyup', function() {
154
+ updateHeight();
155
+ this.fire("keyUp");
156
+ }.bind(this));
157
+
158
+ return textareaHtml;
159
+ },
160
+ clear: function() {
161
+ this.setValue("");
162
+ },
163
+ cursorEnd: function() {
164
+ this.setSelectionRange(this.getValue().length, this.getValue().length);
165
+ },
166
+ forceFocus: function() {
167
+ this.setFocus(true);
168
+ this.textareaHtml().focus();
169
+ },
170
+ revert: function() {
171
+ this.textareaHtml().value = this.getValue();
172
+ },
173
+ commit: function() {
174
+ this.setValue(this.textareaHtml().value);
175
+ },
176
+ resize: function(html) {
177
+ if (this.getAutoGrow()) {
178
+ var textareaHtml = html || this.textareaHtml();
179
+ if (!textareaHtml.rows || textareaHtml.rows < 1) { textareaHtml.rows = 1; }
180
+ var rowCount = textareaHtml.rows;
181
+ while (textareaHtml.clientHeight >= textareaHtml.scrollHeight && textareaHtml.rows > 1) { textareaHtml.rows -= 1; }
182
+ while (textareaHtml.clientHeight + 1 < textareaHtml.scrollHeight) { textareaHtml.rows += 1; }
183
+ if (textareaHtml.rows != rowCount) {
184
+ this.fire("resize");
185
+ }
186
+ }
187
+ },
188
+ backingValue: function() {
189
+ return this.textareaHtml().value;
190
+ },
191
+ getCursorLocation: function() {
192
+ try {
193
+ return this.textareaHtml().selectionStart;
194
+ } catch(e) {
195
+ return 0;
196
+ }
197
+ },
198
+ setCursorLocation: function(location) {
199
+ return this.setSelectionRange(location, location);
200
+ },
201
+ hasSelectedText: function() {
202
+ return this.textareaHtml().selectionStart != this.textareaHtml().selectionEnd;
203
+ },
204
+ selectEnd: function() {
205
+ this.setCursorLocation(this.backingValue().length);
206
+ },
207
+ selectAll: function() {
208
+ this.setSelectionRange(0, this.textareaHtml().value.length);
209
+ },
210
+ setSelectionRange: function(selectionStart, selectionEnd) {
211
+ var input = this.textareaHtml();
212
+ if (input.setSelectionRange) {
213
+ input.setSelectionRange(selectionStart, selectionEnd);
214
+ } else if (input.createTextRange) {
215
+ var range = input.createTextRange();
216
+ range.collapse(true);
217
+ range.moveEnd('character', selectionEnd);
218
+ range.moveStart('character', selectionStart);
219
+ range.select();
220
+ }
221
+ }
222
+ }
223
+ });
@@ -0,0 +1,22 @@
1
+ rio.components.ToggleButton = rio.Component.create(rio.components.Base, {
2
+ attrReaders: ["offImage", "onImage"],
3
+ attrAccessors: ["state"],
4
+ attrEvents: ["click"],
5
+ methods: {
6
+ buildHtml: function() {
7
+ var imgHtml = new rio.components.Image();
8
+ this.bind("state", function(state) {
9
+ imgHtml.setSrc(state ? this.getOnImage() : this.getOffImage());
10
+ }.bind(this));
11
+ var linkHtml = rio.Tag.a(imgHtml, {
12
+ href: "",
13
+ onclick: "return false;"
14
+ });
15
+ linkHtml.observe("click", function() {
16
+ this.setState(!this.getState());
17
+ this.fire("toggle");
18
+ }.bind(this));
19
+ return linkHtml;
20
+ }
21
+ }
22
+ });
@@ -0,0 +1,80 @@
1
+ rio.components.Tooltip = rio.Component.create("Tooltip", {
2
+ requireCss: "tooltip",
3
+ attrReaders: [
4
+ ["offsetX", 12],
5
+ ["offsetY", 8],
6
+ "elt",
7
+ ["fixed", false]
8
+ ],
9
+ attrAccessors: [
10
+ ["tip", ""]
11
+ ],
12
+ methods: {
13
+ initialize: function(options) {
14
+
15
+ this._showAfter = new rio.DelayedTask();
16
+
17
+ this.getElt().observe('mouseover', function() {
18
+ this._showAfter.delay(500, this.show.bind(this));
19
+ }.bind(this));
20
+ this.getElt().observe('mouseout', this.hide.bind(this));
21
+ this.getElt().observe('mousemove', this.move.bindAsEventListener(this));
22
+
23
+ Element.body().insert(this.html());
24
+ },
25
+
26
+ buildHtml: function() {
27
+ var html = rio.Tag.div("", { className: "tooltip", style: "display: none" });
28
+ this.tip.bind(function(tip) {
29
+ html.update(tip);
30
+ });
31
+ return html;
32
+ },
33
+
34
+ show: function() {
35
+ if (this.blank()) { return; }
36
+
37
+ if (this.getFixed()) {
38
+ var offset = this.getElt().viewportOffset();
39
+ this.html().setStyle({
40
+ top: offset.top + this.getElt().getHeight() + 5 + "px",
41
+ left: offset.left + (this.getElt().getWidth() / 2) + "px"
42
+ });
43
+ }
44
+
45
+ this.html().show();
46
+ this.resetHideDelay();
47
+ },
48
+
49
+ hide: function() {
50
+ if (this.blank()) { return; }
51
+ this._showAfter.cancel();
52
+ this.html().hide();
53
+ },
54
+
55
+ blank: function() {
56
+ if (!this.getTip()) { return true; }
57
+ if (Object.isString(this.getTip())) {
58
+ if (this.getTip().blank()) { return true; }
59
+ }
60
+ return false;
61
+ },
62
+
63
+ move: function(e) {
64
+ if (this.getFixed()) { return; }
65
+ this.html().setStyle({
66
+ left: e.pointerX() + this.getOffsetX() + 'px',
67
+ top: e.pointerY() + this.getOffsetY() + 'px'
68
+ });
69
+ this.resetHideDelay();
70
+ },
71
+
72
+ resetHideDelay: function() {
73
+ if (!this._hideAfter) { this._hideAfter = new rio.DelayedTask(); }
74
+ this._hideAfter.delay(5000, function() {
75
+ this.hide();
76
+ }, this);
77
+ }
78
+ }
79
+ });
80
+