[jQuery] Re: can someone translate this syntax ?

2009-06-05 Thread Vincent Robert

options = $.extend({ ... }, options) is a popular construct in
plugins.

It allows to define default values for a options hash that is passed
as the only parameter.

On Jun 5, 4:22 am, runrunforest  wrote:
> thank you, I don't see that in other plugin, acutually so far i've not
> yet see the same plugin structure.


[jQuery] Re: can someone translate this syntax ?

2009-06-04 Thread runrunforest

thank you, I don't see that in other plugin, acutually so far i've not
yet see the same plugin structure.


[jQuery] Re: can someone translate this syntax ?

2009-06-04 Thread Andy Matthews

The || is "or". Whichever is "true" first is the result.

So "this" || "that" would equal "this".

But null || "that" would equal "that".


-Original Message-
From: jquery-en@googlegroups.com [mailto:jquery...@googlegroups.com] On
Behalf Of runrunforest
Sent: Thursday, June 04, 2009 11:47 AM
To: jQuery (English)
Subject: [jQuery] Re: can someone translate this syntax ?


ah one more thing

in  o = $.extend({ afterEnd: null }, o || {});

the  o || {}  means ?




[jQuery] Re: can someone translate this syntax ?

2009-06-04 Thread MorningZ

if the value is null, it will assign it as an empty object


On Jun 4, 12:47 pm, runrunforest  wrote:
> ah one more thing
>
> in  o = $.extend({ afterEnd: null }, o || {});
>
> the  o || {}  means ?


[jQuery] Re: can someone translate this syntax ?

2009-06-04 Thread runrunforest

ah one more thing

in  o = $.extend({ afterEnd: null }, o || {});

the  o || {}  means ?


[jQuery] Re: can someone translate this syntax ?

2009-06-04 Thread runrunforest

thank you so much


[jQuery] Re: can someone translate this syntax ?

2009-06-04 Thread Andy Matthews

That syntax looks for any ul tag in the context of the div variable (which
would have to be a jQuery variable. That might look like this:

var div = $('#myDiv');
var ulInDiv = $("ul", div);

 

-Original Message-
From: jquery-en@googlegroups.com [mailto:jquery...@googlegroups.com] On
Behalf Of runrunforest
Sent: Thursday, June 04, 2009 10:54 AM
To: jQuery (English)
Subject: [jQuery] Re: can someone translate this syntax ?


thanks man

how about $("ul", div)




[jQuery] Re: can someone translate this syntax ?

2009-06-04 Thread runrunforest

thanks man

how about $("ul", div)


[jQuery] Re: can someone translate this syntax ?

2009-06-04 Thread MorningZ

The commas are just allowing multiple values to be set in one single
line, ie/

var running = false, animCss=o.vertical?"top":"left"

is the same as

var running = false;
var animCss=o.vertical?"top":"left";

if you don't understand conditional if statements, an example is that
the value of "animCss" is set to "top" or "left" depending on whether
o.vertical evaluates to true or false



On Jun 4, 9:37 am, runrunforest  wrote:
> (function($) {
> $.fn.jCarouselLite = function(o) {
>     o = $.extend({
>         btnPrev: null,
>         btnNext: null,
>         btnGo: null,
>         mouseWheel: false,
>         auto: null,
>
>         speed: 200,
>         easing: null,
>
>         vertical: false,
>         circular: true,
>         visible: 3,
>         start: 0,
>         scroll: 1,
>
>         beforeStart: null,
>         afterEnd: null
>     }, o || {});
>
>     return this.each(function() {
>
>         var running = false, animCss=o.vertical?"top":"left",
> sizeCss=o.vertical?"height":"width";
>         var div = $(this), ul = $("ul", div), tLi = $("li", ul), tl =
> tLi.size(), v = o.visible;
>
>     });
>
> };
> })(jQuery);
>
> I don't understand this part
>
>  var running = false, animCss=o.vertical?"top":"left",
> sizeCss=o.vertical?"height":"width";
>  var div = $(this), ul = $("ul", div), tLi = $("li", ul), tl = tLi.size
> (), v = o.visible;
>
> Can you fully translate it for me please.


[jQuery] Re: can someone translate this syntax ?

2009-06-04 Thread Andy Matthews

That's called ternary syntax:

(expression) ? True : false;

If the expression evaluates to true, then the true portion is run, else the
false portion is run. A real world example:

Var total = (myValue == 15) ? 15 * 3 : myValue / 2;

Not helpful, but that's how it's used.

As for the other portion, Javascript allows you to set multiples values at
once. Because the author is performing an assignment (animCss = blah), it
doesn't return anything so the value of running is set to false. 


andy


-Original Message-
From: jquery-en@googlegroups.com [mailto:jquery...@googlegroups.com] On
Behalf Of runrunforest
Sent: Thursday, June 04, 2009 8:38 AM
To: jQuery (English)
Subject: [jQuery] can someone translate this syntax ?


(function($) {
$.fn.jCarouselLite = function(o) {
o = $.extend({
btnPrev: null,
btnNext: null,
btnGo: null,
mouseWheel: false,
auto: null,

speed: 200,
easing: null,

vertical: false,
circular: true,
visible: 3,
start: 0,
scroll: 1,

beforeStart: null,
afterEnd: null
}, o || {});

return this.each(function() {

var running = false, animCss=o.vertical?"top":"left",
sizeCss=o.vertical?"height":"width";
var div = $(this), ul = $("ul", div), tLi = $("li", ul), tl =
tLi.size(), v = o.visible;

});
};

})(jQuery);




I don't understand this part

 var running = false, animCss=o.vertical?"top":"left",
sizeCss=o.vertical?"height":"width";
 var div = $(this), ul = $("ul", div), tLi = $("li", ul), tl = tLi.size (),
v = o.visible;

Can you fully translate it for me please.