On Wed, 2007-07-18 at 21:25 -0600, Wade Preston Shearer wrote:
> Would someone be willing to walk me through the following javascript  
> snippet, line-by-line? I do not understand what is happening exactly  
> in the second, fourth, and sixth lines. The values being passed into  
> the function are being picked up as an array, but I am not familiar  
> with the syntax.
> 
> <a onclick="javascript:Effect.Combo('drawer_one', {duration:  
> 0.5});"></a>

{ x: 17, y: -2 } is an object literal, in other words it creates an
unnamed object with two properties, x having a value of 17 and y having
a value of -2.  Or in the above example, an object with one property
named duration and a value of 0.5 .

>   Effect.Combo = function(element) {
>       element = $(element);

$ is a legal identifier name in JavaScript.  Apparently there is
a function defined somewhere whose name is $, or there is a variable
named $ which has had a function assigned as its value.

>       if(element.style.display == 'none') {
>            new Effect.OpenUp(element, arguments[1] || {});

arguments[] is an array containing the arguments to the enclosing
function.  arguments[1] may or may not exist, if it exists that means
there is a second argument in the call to Effect.Combo.  If there is a
second argument then the expression

  arguments[1] || {}

evaluates to the value of arguments[1] if that value is not false,
otherwise the expression evaluates to an object literal with no methods
and no properties.
>       }else {
>            new Effect.CloseDown(element, arguments[1] || {});
>       }
>   }

-- Walt


_______________________________________________

UPHPU mailing list
[email protected]
http://uphpu.org/mailman/listinfo/uphpu
IRC: #uphpu on irc.freenode.net

Reply via email to