Advertisement
johnburn

Decoded for: [email protected]

Sep 12th, 2011
299
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. (function ($) {
  2.     $.fn.jCarouselLite = function (o) {
  3.         o = $.extend({
  4.             btnPrev: null,
  5.             btnNext: null,
  6.             btnGo: null,
  7.             mouseWheel: false,
  8.             auto: null,
  9.             speed: 200,
  10.             easing: null,
  11.             vertical: false,
  12.             circular: true,
  13.             visible: 3,
  14.             start: 0,
  15.             scroll: 1,
  16.             beforeStart: null,
  17.             afterEnd: null
  18.         }, o || {});
  19.         return this.each(function () {
  20.             var b = false,
  21.                 animCss = o.vertical ? "top" : "left",
  22.                 sizeCss = o.vertical ? "height" : "width";
  23.             var c = $(this),
  24.                 ul = $("ul", c),
  25.                 tLi = $("li", ul),
  26.                 tl = tLi.size(),
  27.                 v = o.visible;
  28.             if (o.circular) {
  29.                 ul.prepend(tLi.slice(tl - v - 1 + 1).clone()).append(tLi.slice(0, v).clone());
  30.                 o.start += v
  31.             }
  32.             var f = $("li", ul),
  33.                 itemLength = f.size(),
  34.                 curr = o.start;
  35.             c.css("visibility", "visible");
  36.             f.css({
  37.                 overflow: "hidden",
  38.                 float: o.vertical ? "none" : "left"
  39.             });
  40.             ul.css({
  41.                 margin: "0",
  42.                 padding: "0",
  43.                 position: "relative",
  44.                 "list-style-type": "none",
  45.                 "z-index": "1"
  46.             });
  47.             c.css({
  48.                 overflow: "hidden",
  49.                 position: "relative",
  50.                 "z-index": "2",
  51.                 left: "0px"
  52.             });
  53.             var g = o.vertical ? height(f) : width(f);
  54.             var h = g * itemLength;
  55.             var j = g * v;
  56.             f.css({
  57.                 width: f.width(),
  58.                 height: f.height()
  59.             });
  60.             ul.css(sizeCss, h + "px").css(animCss, -(curr * g));
  61.             c.css(sizeCss, j + "px");
  62.             if (o.btnPrev) $(o.btnPrev).click(function () {
  63.                 return go(curr - o.scroll)
  64.             });
  65.             if (o.btnNext) $(o.btnNext).click(function () {
  66.                 return go(curr + o.scroll)
  67.             });
  68.             if (o.btnGo) $.each(o.btnGo, function (i, a) {
  69.                 $(a).click(function () {
  70.                     return go(o.circular ? o.visible + i : i)
  71.                 })
  72.             });
  73.             if (o.mouseWheel && c.mousewheel) c.mousewheel(function (e, d) {
  74.                 return d > 0 ? go(curr - o.scroll) : go(curr + o.scroll)
  75.             });
  76.             if (o.auto) setInterval(function () {
  77.                 go(curr + o.scroll)
  78.             }, o.auto + o.speed);
  79.  
  80.             function vis() {
  81.                 return f.slice(curr).slice(0, v)
  82.             };
  83.  
  84.             function go(a) {
  85.                 if (!b) {
  86.                     if (o.beforeStart) o.beforeStart.call(this, vis());
  87.                     if (o.circular) {
  88.                         if (a <= o.start - v - 1) {
  89.                             ul.css(animCss, -((itemLength - (v * 2)) * g) + "px");
  90.                             curr = a == o.start - v - 1 ? itemLength - (v * 2) - 1 : itemLength - (v * 2) - o.scroll
  91.                         } else if (a >= itemLength - v + 1) {
  92.                             ul.css(animCss, -((v) * g) + "px");
  93.                             curr = a == itemLength - v + 1 ? v + 1 : v + o.scroll
  94.                         } else curr = a
  95.                     } else {
  96.                         if (a < 0 || a > itemLength - v) return;
  97.                         else curr = a
  98.                     }
  99.                     b = true;
  100.                     ul.animate(animCss == "left" ? {
  101.                         left: -(curr * g)
  102.                     } : {
  103.                         top: -(curr * g)
  104.                     }, o.speed, o.easing, function () {
  105.                         if (o.afterEnd) o.afterEnd.call(this, vis());
  106.                         b = false
  107.                     });
  108.                     if (!o.circular) {
  109.                         $(o.btnPrev + "," + o.btnNext).removeClass("disabled");
  110.                         $((curr - o.scroll < 0 && o.btnPrev) || (curr + o.scroll > itemLength - v && o.btnNext) || []).addClass("disabled")
  111.                     }
  112.                 }
  113.                 return false
  114.             }
  115.         })
  116.     };
  117.  
  118.     function css(a, b) {
  119.         return parseInt($.css(a[0], b)) || 0
  120.     };
  121.  
  122.     function width(a) {
  123.         return a[0].offsetWidth + css(a, 'marginLeft') + css(a, 'marginRight')
  124.     };
  125.  
  126.     function height(a) {
  127.         return a[0].offsetHeight + css(a, 'marginTop') + css(a, 'marginBottom')
  128.     }
  129. })(jQuery);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement