PageSourceSearch

https://edinburghcityfc.com/wp-content/plugins/joomsport-sports-le…/js/jquery.jcarousellite.min.js?ver=7.1.2

js edinburghcityfc.com collected 2026-09-27 21:59:56 UTC 12,891 bytes, 290 lines download raw bytes

1/*!
2 * jCarouselLite - v1.1 - 2014-09-28
3 * http://www.gmarwaha.com/jquery/jcarousellite/
4 * Copyright (c) 2014 Ganeshji Marwaha
5 * Licensed MIT (https://github.com/ganeshmax/jcarousellite/blob/master/LICENSE)
6 */
7
8(function($) {                                          // Compliant with jquery.noConflict()
9    $.jCarouselLite = {
10        version: '1.1'
11    };
12
13    $.fn.jCarouselLite = function(options) {
14
15        options = $.extend({}, $.fn.jCarouselLite.options, options || {});
16
17        return this.each(function() {   // Returns the element collection. Chainable.
18
19            var running,
20                animCss, sizeCss,
21                div = $(this), ul, initialLi, li,
22                liSize, ulSize, divSize,
23                numVisible, initialItemLength, itemLength, calculatedTo, autoTimeout;
24
25            initVariables();                    // Set the above variables after initial calculations
26            initStyles();                       // Set the appropriate styles for the carousel div, ul and li
27            initSizes();                        // Set appropriate sizes for the carousel div, ul and li
28            attachEventHandlers();              // Attach event handlers for carousel to respond
29
30            function go(to) {
31                if(!running) {
32                    clearTimeout(autoTimeout);  // Prevents multiple clicks while auto-scrolling - edge case
33                    calculatedTo = to;
34
35                    if(options.beforeStart) {   // Call the beforeStart() callback
36                        options.beforeStart.call(this, visibleItems());
37                    }
38
39                    if(options.circular) {      // If circular, and "to" is going OOB, adjust it
40                        adjustOobForCircular(to);
41                    } else {                    // If non-circular and "to" is going OOB, adjust it.
42                        adjustOobForNonCircular(to);
43                    }                           // If neither overrides "calculatedTo", we are not in edge cases.
44
45                    animateToPosition({         // Animate carousel item to position based on calculated values.
46                        start: function() {
47                            running = true;
48                        },
49                        done: function() {
50                            if(options.afterEnd) {
51                                options.afterEnd.call(this, visibleItems());
52                            }
53                            if(options.auto) {
54                                setupAutoScroll();
55                            }
56                            running = false;
57                        }
58                    });
59
60                    if(!options.circular) {     // Enabling / Disabling buttons is applicable in non-circular mode only.
61                        disableOrEnableButtons();
62                    }
63
64                }
65                return false;
66            }
67
68            function initVariables() {
69                running = false;
70                animCss = options.vertical ? "top" : "left";
71                sizeCss = options.vertical ? "height" : "width";
72                ul = div.find(">ul");
73                initialLi = ul.find(">li");
74               
75                initialItemLength = initialLi.size();
76                
77                // To avoid a scenario where number of items is just 1 and visible is 3 for example.
78                numVisible = initialItemLength < options.visible ? initialItemLength : options.visible;
79
80                if(options.circular) {
81                    var $lastItemSet = initialLi.slice(initialItemLength-numVisible).clone();
82                    var $firstItemSet = initialLi.slice(0,numVisible).clone();
83
84                    ul.prepend($lastItemSet)        // Prepend the lis with final items so that the user can click the back button to start with
85                        .append($firstItemSet);     // Append the lis with first items so that the user can click the next button even after reaching the end
86
87                    options.start += numVisible;    // Since we have a few artificial lis in the front, we will have to move the pointer to point to the real first item
88                }
89
90                li = $("li", ul);
91                
92                itemLength = li.size();
93                calculatedTo = options.start;
94            }
95
96            function initStyles() {
97                // div.css("visibility", "visible");   // If the div was set to hidden in CSS, make it visible now
98
99                // li.css({
100                //     overflow: "hidden",
101                //     "float": options.vertical ? "none" : "left" // Some minification tools fail if "" is not used
102                // });
103
104                // ul.css({
105                //     margin: "0",
106                //     padding: "0",
107                //     position: "relative",
108                //     "list-style": "none",
109                //     "z-index": "1"
110                // });
111
112                // div.css({
113                //     overflow: "hidden",
114                //     position: "relative",
115                //     "z-index": "2",
116                //     left: "0px"
117                // });
118                // For a non-circular carousel, if the start is 0 and btnPrev is supplied, disable the prev button
119                if(!options.circular && options.btnPrev && options.start == 0) {
120                    $(options.btnPrev).addClass("disabled");
121                }
122                disableOrEnableButtons();
123            }
124
125            function initSizes() {
126
127                liSize = options.vertical ?         // Full li size(incl margin)-Used for animation and to set ulSize
128                    li.outerHeight(true) :
129                    li.outerWidth(true);
130                ulSize = liSize * itemLength;       // size of full ul(total length, not just for the visible items)
131                divSize = liSize * numVisible;      // size of entire div(total length for just the visible items)
132
133                // Generally, LI's dimensions should be specified explicitly in a style-sheet
134                // But in the case of img (with width and height attr), we can derive L
134I's dimensions and set here
135                // May be applicable for other types of LI children if their dimensions are explicitly specified
136                // Individual LI dimensions
137                
138                li.css({
139                    width: li.width(),
140                    height: li.height()
141                });
142
143                // Size of the entire UL. Including hidden and visible elements
144                // Will include LI's (width + padding + border + margin) * itemLength - Using outerwidth(true)
145                ul.css(sizeCss, ulSize+"px")
146                    .css(animCss, -(calculatedTo * liSize));
147
148                // Width of the DIV. Only the width of the visible elements
149                // Will include LI's (width + padding + border + margin) * numVisible - Using outerwidth(true)
150                div.css(sizeCss, divSize+"px");
151
152            }
153
154            function attachEventHandlers() {
155                if(options.btnPrev) {
156                    $(options.btnPrev).click(function() {
157                        return go(calculatedTo - options.scroll);
158                    });
159                }
160
161                if(options.btnNext) {
162                    $(options.btnNext).click(function() {
163                        return go(calculatedTo + options.scroll);
164                    });
165                }
166
167                if(options.btnGo) {
168                    $.each(options.btnGo, function(i, val) {
169                        $(val).click(function() {
170                            return go(options.circular ? numVisible + i : i);
171                        });
172                    });
173                }
174
175                if(options.mouseWheel && div.mousewheel) {
176                    div.mousewheel(function(e, d) {
177                        return d > 0 ?
178                            go(calculatedTo - options.scroll) :
179                            go(calculatedTo + options.scroll);
180                    });
181                }
182
183                if(options.auto) {
184                    setupAutoScroll();
185                }
186            }
187
188            function setupAutoScroll() {
189                autoTimeout = setTimeout(function() {
190                    go(calculatedTo + options.scroll);
191                }, options.auto);
192            }
193
194            function visibleItems() {
195                return li.slice(calculatedTo).slice(0,numVisible);
196            }
197
198            function adjustOobForCircular(to) {
199                var newPosition;
200
201                // If first, then goto last
202                if(to <= options.start - numVisible - 1) {
203                    newPosition = to + initialItemLength + options.scroll;
204                    ul.css(animCss, -(newPosition * liSize) + "px");
205                    calculatedTo = newPosition - options.scroll;
206
207                    console.log("Before - Positioned at: " + newPosition + " and Moving to: " + calculatedTo);
208                }
209
210                // If last, then goto first
211                else if(to >= itemLength - numVisible + 1) {
212                    newPosition = to - initialItemLength - options.scroll;
213                    ul.css(animCss, -(newPosition * liSize) + "px");
214                    calculatedTo = newPosition + options.scroll;
215
216                    console.log("After - Positioned at: " + newPosition + " and Moving to: " + calculatedTo);
217                }
218            }
219
220            function adjustOobForNonCircular(to) {
221                // If user clicks "prev" and tries to go before the first element, reset it to first element.
222                if(to < 0) {
223                    calculatedTo = 0;
224                }
225                // If "to" is greater than the max index that we can use to show another set of elements
226                // it means that we will have to reset "to" to a smallest possible index that can show it
227                else if(to > itemLength - numVisible) {
228                    calculatedTo = itemLength - numVisible;
229                }
230
231                /*console.log("Item Length: " + itemLength + "; " +
232                    "To: " + to + "; " +
233                    "CalculatedTo: " + calculatedTo + "; " +
234                    "Num Visible: " + numVisible);*/
235            }
236
237            function disableOrEnableButtons() {
238                
239                $(options.btnPrev + "," + options.btnNext).removeClass("disabled");
240                $( (calculatedTo-options.scroll<0 && options.btnPrev)
241                    ||
242                    (calculatedTo+options.scroll > itemLength-numVisible && options.btnNext)
243                    ||
244                    []
245                ).addClass("disabled");
246                if(itemLength-numVisible <= 0){
247                    $(options.btnNext).addClass("disabled");
248                    $(options.btnPrev).addClass("disabled");
249                }
250                
251            }
252
253            function animateToPosition(animationOptions) {
254                running = true;
255
256                ul.animate(
257                    animCss == "left" ?
258                    { left: -(calculatedTo*liSize) } :
259                    { top: -(calculatedTo*liSize) },
260
261                    $.extend({
262                        duration: options.speed,
263                        easing: options.easing
264                    }, animationOptions)
265                );
266            }
267        });
268    };
269
270    $.fn.jCarouselLite.options = {
271        btnPrev: null,              // CSS Selector for the previous button
272        btnNext: null,              // CSS Selector for the next button
273        btnGo: null,                // CSS Selector for the go button
274        mouseWheel: false,          // Set "true" if you want the carousel scrolled using mouse wheel
275        auto: null,                 // Set to a numeric value (800) in millis. Time period between auto scrolls
276
277        speed: 200,                 // Set to a numeric value in millis. Speed of scroll
278        easing: null,               // Set to easing (bounceout) to specify the animation easing
279
280        vertical: false,            // Set to "true" to make the carousel scroll vertically
281        circular: true,             // Set to "true" to make it an infinite carousel
282        visible: 3,                 // Set to a numeric value to specify the number of visible elements at a time
283        start: 0,                   // Set to a numeric value to specify which item to start from
284        scroll: 1,                  // Set to a numeric value to specify how many items to scroll for one scroll event
285
286        beforeStart: null,          // Set to a function to receive a callback before every scroll start
287        afterEnd: null              // Set to a function to receive a callback after every scroll end
288    };
289
290})(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.