Thursday, June 4, 2009

[jQuery] Re: can someone translate this syntax ?

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-en@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.

No comments: