(function (a) { a.fn.jCarouselLite = function (b) { b = a.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, fade: false, beforeStart: null, afterEnd: null }, b || {}); this.jCarouselLiteOptions = b; return this.each(function () { var n = false, m = b.vertical ? "top" : "left", q = b.vertical ? "height" : "width", l = a(this), i = a("ul", l), o = a("li", i), t = o.size(), f = b.visible; if (b.circular && !b.fade) { i.prepend(o.slice(t - f - 1 + 1).clone()).append(o.slice(0, f).clone()); b.start += f } var g = a("li", i), h = g.size(), e = b.start; l.css("visibility", "visible"); g.css({ overflow: "hidden", "float": b.vertical ? "none" : "left" }); i.css({ margin: "0", padding: "0", position: "relative", "list-style-type": "none", "z-index": "1" }); l.css({ overflow: "hidden", position: "relative", "z-index": "2", left: "0px" }); var j = b.vertical ? c(g) : d(g), s = j * h, r = j * f; g.css({ width: g.width(), height: g.height() }); i.css(q, s + "px").css(m, -(e * j)); if (b.fade) { g.css({ position: "absolute", opacity: 0, display: "none" }); a(g[0]).css({ opacity: 1, display: "block" }); i.css({ width: g.width(), height: g.height(), left: "0", top: "0" }) } l.css(q, r + "px"); b.btnPrev && a(b.btnPrev).click(function () { return k(e - b.scroll) }); b.btnNext && a(b.btnNext).click(function () { return k(e + b.scroll) }); b.btnGo && a.each(b.btnGo, function (c, d) { a(d).click(function () { if (b.auto) { clearInterval(b.timer); b.timer = setInterval(function () { k(e + b.scroll) }, b.auto + b.speed) } return k(b.circular && !b.fade ? b.visible + c : c) }) }); b.mouseWheel && l.mousewheel && l.mousewheel(function (c, a) { return a > 0 ? k(e - b.scroll) : k(e + b.scroll) }); if (b.auto) b.timer = setInterval(function () { k(e + b.scroll) }, b.auto + b.speed); function p() { return g.slice(e).slice(0, f) } function k(c) { if (!n && e != c) { var d = e; if (!b.fade) if (b.circular) if (c <= b.start - f - 1) { i.css(m, -((h - f * 2) * j) + "px"); e = c == b.start - f - 1 ? h - f * 2 - 1 : h - f * 2 - b.scroll } else if (c >= h - f + 1) { i.css(m, -(f * j) + "px"); e = c == h - f + 1 ? f + 1 : f + b.scroll } else e = c; else if (c < 0 || c > h - f) return; else e = c; else { if (!b.circular && (c < 0 || c > h - f)) return; c = (c + h) % h; a(g[c]).show() } b.beforeStart && b.beforeStart.call(this, p(), c + 1); n = true; if (!b.fade) i.animate(m == "left" ? { left: -(e * j)} : { top: -(e * j) }, b.speed, b.easing, function () { b.afterEnd && b.afterEnd.call(this, p(), d + 1); n = false }); else { a(g[e]).animate({ opacity: 0 }, b.speed, b.easing, function () { a(g[d]).hide(); b.afterEnd && b.afterEnd.call(this, p(), d + 1); n = false }); a(g[c]).animate({ opacity: 1 }, b.speed, b.easing); e = c } if (!b.circular) { a(b.btnPrev + "," + b.btnNext).removeClass("disabled"); a(e - b.scroll < 0 && b.btnPrev || e + b.scroll > h - f && b.btnNext || []).addClass("disabled") } } return false } }) }; function b(c, b) { return parseInt(a.css(c[0], b)) || 0 } function d(a) { return a[0].offsetWidth + b(a, "marginLeft") + b(a, "marginRight") } function c(a) { return a[0].offsetHeight + b(a, "marginTop") + b(a, "marginBottom") } })(jQuery)
