SCSI Hard Drives
Search
Advanced Search

Categories


Recently Viewed
Pages



My Links
Web Directory Index
A human edited, comprehensive web directory list.
Link Exchange
DesignFirms Link Exchange


Using script.aculo.us in Ruby on Rails

By : yankees26an
Rating : Average Rating : 3.00 From 4 Voter(s)



Script.aculo.us is indeed spectaculous. By writing a few lines of ROR code, you could create UI effects that reqiured great manipulation in javascript using DOM.  The most popular part of script.aculo.us is the visual effects, using the Effect object. These effects are very dynamic, almost flashlike, yet they do not need any plugins and are very reliable in cross-platform compatibility. So, let's get to the eye candy. I promise you that you will spend more time enjoying the effects than writing it :)

 


Lets start by fading, say , a picture from view.


<div id ="fadePic" class = "findMe"> 


<div> <a href = "#">  <img alt = "my_image" src = "images/4"  />


</a>


</div>




Now let's call the function Fade using the link_to_function command.

 

<%= link_to_funcion "Fade", "new.Effect('fadePic')" %>    
   

Notice that we insert the div id into the function. This will fade the picture until it completely disappears. But what if we don't want it to completely disappear? Then we insert an optional parameter. <br /><br />


 

<%= link_to_funcion "Fade", "new.Effect('fadePic', { Duration: 10, to: .5})" %>    
 

 

Here we insered to extra parameters. In this example, the picture will start fading after 10 seconds, not frames, and will only fade to 50 percent of it's original color.
>
Here are all the 16 standard effects that you can use with script.aculo.us:

Fade: Decreases opacity
Appear: Increases opacity

BlindUp, BlindDown: Changes height of the element

SlideUp, SlideDown: Slides the element up or down.

Shrink: Resizes the element( Shrinks)
Grow: Resizes the element( Expands)

Highlight: CHanges background color of element.

Shake: Causes an element to slide left to right a few times.

Pulsate: Rapidly fades in and out several times.

DropOut: Simultaneously fades an element and moves it downward, so it appears to drop off the page

SwitchOff: SImulates an old television bieng turned off; a quick flicker, and then the element collapses into a horizontal line.

Puff: Makes an element incease in size while decreasing opacity.

Squish: Similiar to shrink, but the element's top-left corner remains fixed.

Fold: First redurces the element's height to a thin line and then reduces its width until it disappears.


 






Related Articles

» Ruby Classes and Objects



Comments / Feedback

uday Email
January 21, 2008, 8:19 am

sddsds
ww_boy6 Email
July 15, 2008, 10:09 pm

It is NOT working at all

Please use:
















Andreas Email
October 1, 2008, 5:25 am

Typo link_to_funcion sould be link_to_function
online keno websites Email
March 3, 2009, 9:27 am

Initially it was working fine, but having problems afterwards it was giving problems as these effects there are over 16 additional effects using combinations of the core effects out of the box, but i couldn't make it right.
RSS 2.0: Syndicate this article

Add Comment
* Name


* Email Address


Site



*Image Validation (?)


*Comments / Feedback





Print Article Print Article Send to a friend Send to a friend Save as PDF Save as PDF Social Bookmarking
Add to: Mr. Wong Add to: Webnews Add to: Icio Add to: Oneview Add to: Folkd Add to: Yigg Add to: Linkarena Add to: Digg Add to: Del.icio.us Add to: Reddit Add to: Simpy Add to: StumbleUpon Add to: Slashdot Add to: Netscape Add to: Furl Add to: Yahoo Add to: Spurl Add to: Google Add to: Blinklist Add to: Blogmarks Add to: Diigo Add to: Technorati Add to: Newsvine Add to: Blinkbits Add to: Ma.Gnolia Add to: Smarking Add to: Netvouz Information
Rate this Article :

1

2

3

4

5

6

7

8

9

10
Poor Excellent