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