{"id":153,"date":"2006-08-12T00:34:36","date_gmt":"2006-08-12T05:34:36","guid":{"rendered":"http:\/\/www.juixe.com\/techknow\/index.php\/2006\/08\/12\/scriptaculous-rails\/"},"modified":"2006-08-12T00:34:36","modified_gmt":"2006-08-12T05:34:36","slug":"scriptaculous-rails","status":"publish","type":"post","link":"http:\/\/juixe.com\/techknow\/index.php\/2006\/08\/12\/scriptaculous-rails\/","title":{"rendered":"Scriptaculous Rails"},"content":{"rendered":"<p>The <a href=\"http:\/\/script.aculo.us\">script.aculo.us<\/a> JavaScript library is ridiculously simple, and Ruby on Rails makes using it just as simple.  Ruby on Rails provides a view helper <b>visual_effect<\/b> method which can be used in any event, such as an onclick event.  Here is an example of the rails visual_effect helper method in action:<\/p>\n<p>[source:html]<br \/>\n&lt;%= content_tag &#8216;DIV&#8217;, &#8216;Hello, World&#8217;, :id =&gt; &#8216;msg&#8217; %&gt;<br \/>\n&lt;%= content_tag &#8216;DIV&#8217;, &#8216;Click Here&#8217;,<br \/>\n  :onclick =&gt; visual_effect(:highlight, &#8216;msg&#8217;, :duration =&gt; 1.0)  %&gt;<br \/>\n[\/source]<\/p>\n<p>In the above example, when the user clicks where indicated the Hello, World message will highlight for a second.  You can also group a series of effects by wrapping them in a SCRIPT tag such as the following opacity effects:<br \/>\n<!--more--><br \/>\n[source:html]<br \/>\n&lt;SCRIPT type=&#8221;text\/javascript&#8221;&gt;<br \/>\n  &lt;%= visual_effect :opacity, &#8216;idOne&#8217;, :duration =&gt; 2.0,<br \/>\n    :from =&gt; 1.0, :to =&gt; 0.5 %&gt;<br \/>\n  &lt;%= visual_effect :opacity, &#8216;idTwo&#8217;, :duration =&gt; 2.0,<br \/>\n    :from =&gt; 1.0, :to =&gt; 0.5, :transition =&gt; &#8216;Effect.Transitions.wobble&#8217; %&gt;<br \/>\n&lt;\/SCRIPT&gt;<br \/>\n[\/source]<\/p>\n<p>In addition to the highlight and opacity effects, script.aculo.us and the visual_effect helper method supports the following combination effects: fade, appear, puff, blindUp, blindDown, switchOff, dropOut, shake, slideDown, slideUp, squish, grow, shrink, pulsate, and fold.<\/p>\n<p>The combination effects listed above support the duration and delay options.<\/p>\n<p>[source:html]<br \/>\n&lt;SCRIPT type=&#8221;text\/javascript&#8221;&gt;<br \/>\n  &lt;%= visual_effect :fade, &#8216;idOne&#8217;, :duration =&gt; 5.0,<br \/>\n    :delay =&gt; 5.0 %&gt;<br \/>\n  &lt;%= visual_effect :puff, &#8216;idTwo&#8217;, :duration =&gt; 1.0,<br \/>\n    :delay =&gt; 5.0 %&gt;<br \/>\n&lt;\/SCRIPT&gt;<br \/>\n[\/source]<\/p>\n<p>You can also cut and paste effects submitted by script.aculo.us <a href=\"http:\/\/wiki.script.aculo.us\/scriptaculous\/show\/EffectsTreasureChest\">users<\/a> and the visual_effect will also work for those effects.<\/p>\n<p>Script.aculo.us also has some great drag and drop controls.  To make a DIV element draggable use code similar to the following:<\/p>\n<p>[source:html]<br \/>\n&lt;%= draggable_element &#8216;idOne&#8217;, :revert =&gt; true,<br \/>\n  :zindex =&gt; -1 %&gt;<br \/>\n[\/source]<\/p>\n<p>Technorati Tags: <a href=\"http:\/\/technorati.com\/tag\/ruby\" rel=\"tag\">ruby<\/a>, <a href=\"http:\/\/technorati.com\/tag\/rubyonrails\" rel=\"tag\"> rubyonrails<\/a>, <a href=\"http:\/\/technorati.com\/tag\/rails\" rel=\"tag\"> rails<\/a>, <a href=\"http:\/\/technorati.com\/tag\/script.aculo.us\" rel=\"tag\"> script.aculo.us<\/a>, <a href=\"http:\/\/technorati.com\/tag\/javascript\" rel=\"tag\"> javascript<\/a>, <a href=\"http:\/\/technorati.com\/tag\/web2.0\" rel=\"tag\"> web2.0<\/a>, <a href=\"http:\/\/technorati.com\/tag\/web+design\" rel=\"tag\"> web design<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>The script.aculo.us JavaScript library is ridiculously simple, and Ruby on Rails makes using it just as simple. Ruby on Rails provides a view helper visual_effect method which can be used in any event, such as an onclick event. Here is an example of the rails visual_effect helper method in action: [source:html] &lt;%= content_tag &#8216;DIV&#8217;, &#8216;Hello, [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"spay_email":"","footnotes":""},"categories":[16,22,3],"tags":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p902K-2t","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"http:\/\/juixe.com\/techknow\/index.php\/wp-json\/wp\/v2\/posts\/153"}],"collection":[{"href":"http:\/\/juixe.com\/techknow\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/juixe.com\/techknow\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/juixe.com\/techknow\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/juixe.com\/techknow\/index.php\/wp-json\/wp\/v2\/comments?post=153"}],"version-history":[{"count":0,"href":"http:\/\/juixe.com\/techknow\/index.php\/wp-json\/wp\/v2\/posts\/153\/revisions"}],"wp:attachment":[{"href":"http:\/\/juixe.com\/techknow\/index.php\/wp-json\/wp\/v2\/media?parent=153"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/juixe.com\/techknow\/index.php\/wp-json\/wp\/v2\/categories?post=153"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/juixe.com\/techknow\/index.php\/wp-json\/wp\/v2\/tags?post=153"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}