PageSourceSearch

http://www.consulatalgeriemontreal.com/v1.0/js/jcarousellite_1.0.1.js

js consulatalgeriemontreal.com collected 2026-10-06 09:04:38 UTC 5,359 bytes, 140 lines download raw bytes

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