/*! * jCarousel Lite - v1.9.2 - 2014-08-18 * http://kswedberg.github.com/jquery-carousel-lite/ * Copyright (c) 2014 Karl Swedberg * based on the original by Ganeshji Marwaha (gmarwaha.com) * Licensed MIT (http://kswedberg.github.com/jquery-carousel-lite/blob/master/LICENSE-MIT) */ !function(a){function b(a,b){return b.autoStop&&(b.circular?b.autoStop:Math.min(a,b.autoStop))}function c(a){this.id&&(this.id+=a)}a.jCarouselLite={version:"1.9.2",curr:0},a.fn.anim="undefined"!=typeof a.fn.velocity?a.fn.velocity:a.fn.animate,a.fn.jCarouselLite=function(d){var e=a.extend(!0,{},a.fn.jCarouselLite.defaults,d),f=Math.ceil,g=Math.abs;return this.each(function(){function d(){return n.slice(p).slice(0,G)}function h(b,c){if(v)return!1;c=c||{};var f=p,g=b>p,h="undefined"!=typeof c.speed?c.speed:e.speed,i=c.offset||0;return e.beforeStart&&e.beforeStart.call(B,d(),g),e.circular?(b>p&&b>o-G?(b-=p,p%=E,b=p+b,C.css(w,-p*u.liSize-i)):p>b&&0>b&&(p+=E,b+=E,C.css(w,-p*u.liSize-i)),p=b+b%1):(0>b?b=0:b>o-H&&(b=o-H),p=b,0===p&&e.first&&e.first.call(this,d(),g),p===o-H&&e.last&&e.last.call(this,d(),g),e.btnPrev&&e.$btnPrev.toggleClass(e.btnDisabledClass,0===p),e.btnNext&&e.$btnNext.toggleClass(e.btnDisabledClass,p===o-H)),S(p,L),a.jCarouselLite.curr=p,f!==p||c.force?(v=!0,x[w]=-(p*u.liSize),C.anim(x,h,e.easing,function(){e.afterEnd&&e.afterEnd.call(B,d(),g),v=!1}),p):(e.afterEnd&&e.afterEnd.call(B,d(),g),p)}var i,j,k,l,m,n,o,p,q,r,s,t="ontouchend"in document,u={div:{},ul:{},li:{}},v=!1,w=e.vertical?"top":"left",x={},y=e.vertical?"height":"width",z=e.vertical?"outerHeight":"outerWidth",A=this,B=a(this),C=B.find(e.containerSelector).eq(0),D=C.children(e.itemSelector),E=D.length,F=e.visible,G=f(F),H=Math.floor(F),I=Math.min(e.start,E-1),J=1,K=0,L={},M={},N={},O=e.vertical?"y":"x",P=e.vertical?"x":"y",Q=e.init.call(this,e,D);if(Q!==!1){var R=function(){i&&i.length&&(i.remove(),j.remove()),D=C.children(e.liSelector),E=D.length,i=D.slice(E-G).clone(!0).each(c),j=D.slice(0,G).clone(!0).each(c),C.prepend(i).append(j),n=C.children(e.liSelector),o=n.length};B.data("dirjc",J),B.data(w+"jc",B.css(w)),e.circular?(R(),I+=G,K=G):(n=C.children(e.liSelector),o=n.length),e.btnGo&&e.btnGo.length&&(s=a(a.isArray(e.btnGo)&&"string"==typeof e.btnGo[0]?e.btnGo.join():e.btnGo),s.each(function(b){a(this).bind("click.jc",function(a){return a.preventDefault(),h(e.circular?F+b:b)})}),L.go=1);var S=function(a,b){a=f(a),n.filter("."+e.activeClass).removeClass(e.activeClass),n.eq(a).addClass(e.activeClass);var c=(a-K)%E,d=c+H;return b.go&&(s.removeClass(e.activeClass).removeClass(e.visibleClass),s.eq(c).addClass(e.activeClass),s.slice(c,c+H).addClass(e.visibleClass),d>s.length&&s.slice(0,d-s.length).addClass(e.visibleClass)),b.pager&&(k.removeClass(e.activeClass),k.eq(f(c/F)).addClass(e.activeClass)),c};p=I,a.jCarouselLite.curr=p;var T=function(a){var b,c,d;return a?(u.div[y]="",u.li={width:"",height:""},u):(b=n[z](!0),c=b*o,d=b*F,u.div[y]=d+"px",u.ul[y]=c+"px",u.ul[w]=-(p*b)+"px",u.li={width:n.width(),height:n.height()},u.liSize=b,u)},U=function(b){var c,d,f={div:{visibility:"visible",position:"relative",zIndex:2,left:"0"},ul:{margin:"0",padding:"0",position:"relative",listStyleType:"none",zIndex:1},li:{overflow:e.vertical?"hidden":"visible","float":e.vertical?"none":"left"}};b&&(c=T(!0),B.css(c.div),C.css(c.ul),n.css(c.li)),c=T(),e.autoCSS&&a.extend(!0,c,f),e.autoWidth&&(d=parseInt(B.css(y),10),u.liSize=d/e.visible,c.li[y]=u.liSize-(n[z](!0)-parseInt(n.css(y),10)),c.ul[y]=u.liSize*o+"px",c.ul[w]=-(p*u.liSize)+"px",c.div[y]=d),e.autoCSS&&(n.css(c.li),C.css(c.ul),B.css(c.div))};U();var V=0,W=b(E,e),X="number"==typeof e.auto?e.auto:e.scroll,Y=function(){A.setAutoAdvance=setTimeout(function(){(!W||W>V)&&(J=B.data("dirjc"),h(p+J*X,{auto:!0}),V++,Y())},e.timeout)};if(a.each(["btnPrev","btnNext"],function(b,c){e[c]&&(e["$"+c]=a.isFunction(e[c])?e[c].call(B[0]):a(e[c]),e["$"+c].bind("click.jc",function(a){a.preventDefault();var c=0===b?p-e.scroll:p+e.scroll;return e.directional&&B.data("dirjc",b?1:-1),h(c)}))}),e.circular||(e.btnPrev&&0===I&&e.$btnPrev.addClass(e.btnDisabledClass),e.btnNext&&I+H>=o&&e.$btnNext.addClass(e.btnDisabledClass)),e.autoPager){l=f(E/F),k=[];for(var Z=0;l>Z;Z++)k.push('
  • '+(Z+1)+"
  • ");k.length>1&&(k=a("").appendTo(e.autoPager).find("li"),k.find("a").each(function(b){a(this).bind("click.jc",function(a){a.preventDefault();var c=b*F;return e.circular&&(c+=F),h(c)})}),L.pager=1)}S(I,L),e.mouseWheel&&B.mousewheel&&B.bind("mousewheel.jc",function(a,b){return h(b>0?p-e.scroll:p+e.scroll)}),e.pause&&e.auto&&!t&&B.bind("mouseenter.jc",function(){B.trigger("pauseCarousel.jc")}).bind("mouseleave.jc",function(){B.trigger("resumeCarousel.jc")}),e.auto&&Y(),a.jCarouselLite.vis=d,B.bind("go.jc",function(a,b,c){"undefined"==typeof b&&(b="+=1");var d="string"==typeof b&&/(\+=|-=)(\d+)/.exec(b);d?b="-="===d[1]?p-1*d[2]:p+1*d[2]:b+=I,h(b,c)}).bind("startCarousel.jc",function(){clearTimeout(A.setAutoAdvance),A.setAutoAdvance=void 0,B.trigger("go","+="+e.scroll),Y(),B.removeData("pausedjc").removeData("stoppedjc")}).bind("resumeCarousel.jc",function(a,b){if(!A.setAutoAdvance){clearTimeout(A.setAutoAdvance),A.setAutoAdvance=void 0;var c=B.data("stoppedjc");(b||!c)&&(Y(),B.removeData("pausedjc"),c&&B.removeData("stoppedjc"))}}).bind("pauseCarousel.jc",function(){clearTimeout(A.setAutoAdvance),A.setAutoAdvance=void 0,B.data("pausedjc",!0)}).bind("stopCarousel.jc",function(){clearTimeout(A.setAutoAdvance),A.setAutoAdvance=void 0,B.data("stoppedjc",!0)}).bind("refreshCarousel.jc",function(a,b){b&&e.circular&&R(),U(e.autoCSS)}).bind("endCarousel.jc",function(){A.setAutoAdvance&&(clearTimeout(A.setAutoAdvance),A.setAutoAdvance=void 0),e.btnPrev&&e.$btnPrev.addClass(e.btnDisabledClass).unbind(".jc"),e.btnNext&&e.$btnNext.addClass(e.btnDisabledClass).unbind(".jc"),e.btnGo&&a.each(e.btnGo,function(b,c){a(c).unbind(".jc")}),e.circular&&(n.slice(0,G).remove(),n.slice(-G).remove()),a.each([w+"jc","pausedjc","stoppedjc","dirjc"],function(a,b){B.removeData(b)}),B.unbind(".jc")}),r={touchstart:function(a){N.x=0,N.y=0,M.x=a.targetTouches[0].pageX,M.y=a.targetTouches[0].pageY,M[w]=parseFloat(C.css(w)),M.time=+new Date},touchmove:function(a){var b=a.targetTouches.length;1===b?(N.x=a.targetTouches[0].pageX,N.y=a.targetTouches[0].pageY,x[w]=M[w]+(N[O]-M[O]),C.css(x),e.preventTouchWindowScroll&&a.preventDefault()):(N.x=M.x,N.y=M.y)},touchend:function(){if(N.x){var a=M[O]-N[O],b=g(a),c=b>e.swipeThresholds[O],d=g(M[P]-N[P])0?"+=":"-=",j=i+e.scroll,k={force:!0};h&&c&&d?k.speed=e.speed/2:!h&&bu.liSize/2&&(j=Math.round(b/u.liSize),j=i+(j>e.visible?e.visible:j),k.offset=a),B.trigger("go.jc",[j,k]),N={}}},handle:function(a){a=a.originalEvent,r[a.type](a)}},t&&e.swipe&&B.bind("touchstart.jc touchmove.jc touchend.jc",r.handle),e.responsive&&(q=e.autoCSS,a(window).bind("resize",function(){q&&(C.width(2*C.width()),q=!1),clearTimeout(m),m=setTimeout(function(){B.trigger("refreshCarousel.jc",[!0]),q=e.autoCSS},100)}))}}),this},a.fn.jCarouselLite.defaults={containerSelector:"ul",itemSelector:"li",btnPrev:null,btnNext:null,btnGo:null,autoPager:null,btnDisabledClass:"disabled",activeClass:"active",visibleClass:"vis",mouseWheel:!1,speed:200,easing:null,timeout:4e3,auto:!1,directional:!1,autoStop:!1,pause:!0,vertical:!1,circular:!0,visible:3,start:0,scroll:1,autoCSS:!0,responsive:!1,autoWidth:!1,swipe:!0,swipeThresholds:{x:80,y:40,time:150},preventTouchWindowScroll:!0,init:function(){},first:null,last:null,beforeStart:null,afterEnd:null}}(jQuery);