1(function($) { // Compliant with jquery.noConflict() 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 20 return this.each(function() { // Returns the element collection. Chainable. 21 22 var running = false, animCss=o.vertical?"top":"left", sizeCss=o.vertical?"height":"width"; 23 var div = $(this), ul = $("ul:first", div), tLi = $(".car", ul), tl = tLi.size(), v = o.visible; 24 25 if(o.circular) { 26 ul.prepend(tLi.slice(tl-v-1+1).clone()) 27 .append(tLi.slice(0,v).clone()); 28 o.start += v; 29 } 30 31 var li = $(".car", ul), itemLength = li.size(), curr = o.start; 32 div.css("visibility", "visible"); 33 34 li.css({overflow: "hidden", float: o.vertical ? "none" : "left"}); 35 ul.css({ padding: "0", position: "relative", "list-style-type": "none", "z-index": "1"}); 36 //div.css({overflow: "hidden", position: "relative", "z-index": "2", left: "29px"}); 37 div.css({overflow: "hidden", "z-index": "2"}); 38 39 var liSize = o.vertical ? height(li) : width(li); // Full li size(incl margin)-Used for animation 40 var ulSize = liSize * itemLength; // size of full ul(total length, not just for the visible items) 41 var divSize = liSize * v; // size of entire div(total length for just the visible items) 42 43 li.css({width: li.width()}); 44 ul.css(sizeCss, ulSize+"px").css(animCss, -(curr*liSize)); 45 46 div.css(sizeCss, divSize+"px");
46 // Width of the DIV. length of visible images 47 48 if(o.btnPrev) 49 $(o.btnPrev).click(function() { 50 return go(curr-o.scroll); 51 }); 52 53 if(o.btnNext) 54 $(o.btnNext).click(function() { 55 return go(curr+o.scroll); 56 }); 57 58 if(o.btnGo) 59 $.each(o.btnGo, function(i, val) { 60 $(val).click(function() { 61 return go(o.circular ? o.visible+i : i); 62 }); 63 }); 64 65 if(o.mouseWheel && div.mousewheel) 66 div.mousewheel(function(e, d) { 67 return d>0 ? go(curr-o.scroll) : go(curr+o.scroll); 68 }); 69 70 if(o.auto) 71 setInterval(function() { 72 go(curr+o.scroll); 73 }, o.auto+o.speed); 74 75 function vis() { 76 return li.slice(curr).slice(0,v); 77 }; 78 79 function go(to) { 80 if(!running) { 81 82 if(o.beforeStart) 83 o.beforeStart.call(this, vis()); 84 85 if(o.circular) { // If circular we are in first or last, then goto the other end 86 if(to<=o.start-v-1) { // If first, then goto last 87 ul.css(animCss, -((itemLength-(v*2))*liSize)+"px"); 88 // If "scroll" > 1, then the "to" might not be equal to the condition; it can be lesser depending on the number of elements. 89 curr = to==o.start-v-1 ? itemLength-(v*2)-1 : itemLength-(v*2)-o.scroll; 90 } else if(to>=itemLength-v+1) { // If last, then goto first 91 ul.css(animCss, -( (v) * liSize ) + "px" ); 92 // If "scroll" > 1, then the "to" might not be equal to the condition; it can be greater depending on the number of elements. 93 curr = to==itemLength-v+1 ? v+1 : v+o.scroll; 94 } else curr = to; 95 } else { // If non-circular and to points to first or last, we just return. 96 if(to<0 || to>itemLength-v) return; 97 else curr = to; 98 } // If neither overrides it, the curr will still be "to" and we can proceed. 99 100 running = true; 101 102 ul.animate( 103 animCss == "left" ? { left: -(curr*liSize) } : { top: -(curr*liSize) } , o.speed, o.easing, 104 function() { 105 if(o.afterEnd) 106 o.afterEnd.call(this, vis()); 107 running = false; 108 } 109 ); 110 // Disable buttons when the carousel reaches the last/first, and enable when not 111 if(!o.circular) { 112 $(o.btnPrev + "," + o.btnNext).removeClass("disabled"); 113 $( (curr-o.scroll<0 && o.btnPrev) 114 || 115 (curr+o.scroll > itemLength-v && o.btnNext) 116 || 117 [] 118 ).addClass("disabled"); 119 } 120 121 } 122 return false; 123 }; 124 }); 125}; 126 127function css(el, prop) { 128 return parseInt($.css(el[0], prop)) || 0; 129}; 130function width(el) { 131 return el[0].offsetWidth + css(el, 'marginLeft') + css(el, 'marginRight'); 132}; 133function height(el) { 134 return el[0].offsetHeight + css(el, 'marginTop') + css(el, 'marginBottom'); 135}; 136 137})(jQuery);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.