PageSourceSearch

https://corvinakiado.hu/inc/old/slider/js/jquery.jcarousellite.js

js corvinakiado.hu collected 2026-10-02 11:16:18 UTC 8,108 bytes, 213 lines download raw bytes

1(function($) {                                          // Compliant with jquery.noConflict()
2$.fn.jCarouselLite = function(o) {   
3    o = $.extend({
4        btnPrev: null,
5        btnNext: null,
6        btnDoubleNext: null,
7        btnGo: null,
8        mouseWheel: false,
9        auto: 5000,
10
11        speed: 200,
12        easing: null,
13
14        vertical: false,
15        circular: true,
16        visible: 3,
17        start: 0,
18        scroll: 1,
19
20        beforeStart: null,
21        afterEnd: null,
22        onBuild: null,
23        onClick: null
24    }, o || {});
25
26    return this.each(function() {                           // Returns the element collection. Chainable.
27            
28        var running = false, animCss=o.vertical?"top":"left", sizeCss=o.vertical?"height":"width";
29        var div = $(this), ul = $("ul", div), tLi = $("li", ul), tl = tLi.size(), v = o.visible;
30		var tmpHtml = "";
31		
32        if(o.circular) {
33            ul.prepend(tLi.gt(tl-v-1).clone()).append(tLi.lt(v).clone());
34            o.start += v;
35        }
36        
37        var li = $("li", ul), itemLength = li.size(), curr = o.start;                       
38        div.css("visibility", "visible");
39
40        li.css("overflow", "hidden")                        // If the list item size is bigger than required
41            .css("float", o.vertical ? "none" : "left")     // Horizontal list
42            .children().css("overflow", "hidden");          // If the item within li overflows its size, hide'em
43		
44		//x=1;
45		//li.each(function(){
46		//	$(this).append(x);		
47		//	x++
48		//});
49		
50        ul.css("margin", "0")                               // Browsers apply default margin 
51            .css("padding", "0")                            // and padding. It is reset here.
52            .css("position", "relative")                    // IE BUG - width as min-width
53            .css("list-style-type", "none")                 // We dont need any icons representing each list item.
54            .css("z-index", "1");                           // IE doesnt respect width. So z-index smaller than div
55
56        div.css("overflow", "hidden")                       // Overflows - works in FF
57            .css("position", "relative")                    // position relative and z-index for IE
58            .css("z-index", "2")                            // more than ul so that div displays on top of ul
59            .css("left", "0px");                            // after creating carousel show it on screen
60                
61        var liSize = o.vertical ? height(li) : width(li);   // Full li size(incl margin)-Used for animation
62        var ulSize = liSize * itemLength;                   // size of full ul(total length, not just for the visible items)
63        var divSize = liSize * v;                           // size of entire div(total length for just the visible items)
64
65        li.css("width", li.width())                         // inner li width. this is the box model width
66            .css("height", li.height());                    // inner li height. this is the box model height
67
68        ul.css(sizeCss, ulSize+"px")                        // W
68idth of the UL is the full length for all the images
69            .css(animCss, -(curr*liSize));                  // Set the starting item
70
71        div.css(sizeCss, divSize+"px");                     // Width of the DIV. length of visible images
72
73		if(o.onBuild)
74        	o.onBuild.call(this, vis());
75		
76        if(o.btnPrev)                 
77            $(o.btnPrev).click(function() {
78				if (o.onClick) o.onClick.call(this);
79                return go(curr-o.scroll); 
80            });
81        
82        if(o.btnNext) {
83			$(o.btnNext).click(function(){
84				if (o.onClick) o.onClick.call(this);
85				return go(curr+o.scroll);
86			});
87		}
88
89		if (o.btnDoubleNext){
90            $(o.btnDoubleNext).click(function() {
91			   // increase the scroll # to 2 momentarily
92			   o.scroll++;
93			   o.speed -= 500;
94               go(curr+o.scroll,true);
95			   o.scroll--;
96			   o.speed += 500;
97			   	return false;
98 		   });
99		}
100
101        if(o.btnGo)
102            $.each(o.btnGo, function(i, val) {
103                $(val).click(function() {
104                    return go(o.circular ? o.visible+i : i);
105                });
106            });
107
108        if(o.mouseWheel && div.mousewheel)
109            div.mousewheel(function(e, d) { 
110                return d>0 ? go(curr-o.scroll) : go(curr+o.scroll);
111            });
112
113        if(o.auto)
114            setInterval(function() { 
115                go(curr+o.scroll); 
116            }, o.auto+o.speed);
117
118        function vis() {
119            return li.gt(curr-1).lt(v);
120        };  
121
122        function go(to,isDouble) {
123            if(!running) {
124
125                if(o.beforeStart)
126                    o.beforeStart.call(this, vis());
127
128                if(o.circular) {            // If circular we are in first or last, then goto the other end
129                    if(to<=o.start-v-1) {           // If first, then goto last
130                        ul.css(animCss, -((itemLength-(v*2))*liSize)+"px");
131                        // If "scroll" > 1, then the "to" might not be equal to the condition; it can be lesser depending on the number of elements. 
132                        curr = to==o.start-v-1 ? itemLength-(v*2)-1 : itemLength-(v*2)-o.scroll;
133
134					} else if(to>=itemLength-v+1) { // If last, then goto first
135						
136						if (isDouble && o.visible == 1)
137							{
138								tmpHtml = $(li).eq(v).html();
139								$(li).eq(v).html($(li).eq(li.length -1).html());
140							}
141						ul.css(animCss, -( (v) * liSize ) + "px" );
142						
143						//	
144						//} else {
145						//	//console.log($(li[curr]).prev().attr('class'));
146						//	tmpHTML = $(li).eq(1).html();
147						//	console.log("here");
148						//	$(li).eq(1).html($(li).eq(curr+1).html());
149						//	
150						//	ul.css(animCss, -( ((v) * liSize) ) + "px" );
151						//	return;
152						//}
153						
154						// If "scroll" > 1, then the "to" might not be equal to the condition; it can be greater depending on the number of elements. 
155                        curr = to==itemLength-v+1 ? v+1 : v+o.scroll;
156                    } else curr = to;
157                } else {                    // If non-circular and to points to first or last, we just return.
158                    if(to<0 || to>itemLength-v) return;
159                    else curr = to;
160                }                           // If neither overrides it, the curr will still be "to" and we can proceed.
161
162                running = true;
163
164				if (!isDouble) {
165					tmpSpeed = o.speed;	
166				} else {
167					tmpSpeed = o.speed;	
168				}
169
170                ul.animate(
171                    animCss == "left" ? { left: -(curr*liSize) } : { top: -(curr*liSize) } , tmpSpeed, o.easing,
172                    function() {
173						if (isDouble && tmpHtml != "")
174							{
175								//console.log(tmpHtml);
176								$(li).eq(v).html(tmpHtml);
177								tmpHtml = "";
178							}
179                        if(o.afterEnd)
180                            o.afterEnd.call(this, vis());
181                        running = false;
182                    }
183                );
184
185
186                // Disable buttons when the carousel reaches the last/first, and enable when not
187                if(!o.circular) {
188                    $(o.btnPrev + "," + o.btnNext).removeClass("disabled");
189                    $( (curr-o.scroll<0 && o.btnPrev) 
190                        || 
191                       (curr+o.scroll > itemLength-v && o.btnNext)
192                        ||
193                       []
194                     ).addClass("disabled");
195                }
196
197            }
198            return false;
199        };
200    });
201};
202
203function css(el, prop) {
204    return parseInt($.css(el[0], prop)) || 0;
205};
206function width(el) {
207    return  el[0].offsetWidth + css(el, 'marginLeft') + css(el, 'marginRight');
208};
209function height(el) {
210    return el[0].offsetHeight + css(el, 'marginTop') + css(el, 'marginBottom');
211};
212
213})(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.