PageSourceSearch

https://www.tours-tourism.co.uk/sites/all/themes/zen/zen/js/jcarousel/lib/jquery.jcarousel_W.js

js tours-tourism.co.uk collected 2026-10-08 05:53:20 UTC 29,263 bytes, 878 lines download raw bytes

1/**
2 * jCarousel - Riding carousels with jQuery
3 *   http://sorgalla.com/jcarousel/
4 *
5 * Copyright (c) 2006 Jan Sorgalla (http://sorgalla.com)
6 * Dual licensed under the MIT (MIT-LICENSE.txt)
7 * and GPL (GPL-LICENSE.txt) licenses.
8 *
9 * Built on top of the jQuery library
10 *   http://jquery.com
11 *
12 * Inspired by the "Carousel Component" by Bill Scott
13 *   http://billwscott.com/carousel/
14 */
15
16(function($) {
17    /**
18     * Creates a carousel for all matched elements.
19     *
20     * @example $("#mycarousel").jcarousel();
21     * @before <ul id="mycarousel" class="jcarousel-skin-name"><li>First item</li><li>Second item</li></ul>
22     * @result
23     *
24     * <div class="jcarousel-skin-name">
25     *   <div class="jcarousel-container">
26     *     <div disabled="disabled" class="jcarousel-prev jcarousel-prev-disabled"></div>
27     *     <div class="jcarousel-next"></div>
28     *     <div class="jcarousel-clip">
29     *       <ul class="jcarousel-list">
30     *         <li class="jcarousel-item-1">First item</li>
31     *         <li class="jcarousel-item-2">Second item</li>
32     *       </ul>
33     *     </div>
34     *   </div>
35     * </div>
36     *
37     * @name jcarousel
38     * @type jQuery
39     * @param Hash o A set of key/value pairs to set as configuration properties.
40     * @cat Plugins/jCarousel
41     */
42    $.fn.jcarousel = function(o) {
43        return this.each(function() {
44            new $jc(this, o);
45        });
46    };
47
48    // Default configuration properties.
49    var defaults = {
50        vertical: false,
51        start: 1,
52        offset: 1,
53        size: null,
54        scroll: 3,
55        visible: null,
56        animation: 'normal',
57        easing: 'swing',
58        auto: 0,
59        wrap: null,
60        initCallback: null,
61        reloadCallback: null,
62        itemLoadCallback: null,
63        itemFirstInCallback: null,
64        itemFirstOutCallback: null,
65        itemLastInCallback: null,
66        itemLastOutCallback: null,
67        itemVisibleInCallback: null,
68        itemVisibleOutCallback: null,
69        buttonNextHTML: '<div></div>',
70        buttonPrevHTML: '<div></div>',
71        buttonNextEvent: 'click',
72        buttonPrevEvent: 'click',
73        buttonNextCallback: null,
74        buttonPrevCallback: null
75    };
76
77    /**
78     * The jCarousel object.
79     *
80     * @constructor
81     * @name $.jcarousel
82     * @param Object e The element to create the carousel for.
83     * @param Hash o A set of key/value pairs to set as configuration properties.
84     * @cat Plugins/jCarousel
85     */
86    $.jcarousel = function(e, o) {
87        this.options    = $.extend({}, defaults, o || {});
88
89        this.locked     = false;
90
91        this.container  = null;
92        this.clip       = null;
93        this.list       = null;
94        this.buttonNext = null;
95        this.buttonPrev = null;
96
97        this.wh = !this.options.vertical ? 'width' : 'height';
98        this.lt = !this.options.vertical ? 'left' : 'top';
99
100        // Extract skin class
101        var skin = '', split = e.className.split(' ');
102
103        for (var i = 0; i < split.length; i++) {
104            if (split[i].indexOf('jcarousel-skin') != -1) {
105                $(e).removeClass(split[i]);
106                var skin = split[i];
107                break;
108            }
109        }
110
111        if (e.nodeName == 'UL' || e.nodeName == 'OL') {
112            this.list = $(e);
113            this.container = this.list.parent();
114
115            if (this.container.hasClass('jcarousel-clip')) {
116                if (!this.container.parent().hasClass('jcarousel-container'))
117                    this.container = this.container.wrap('<div></div>');
118
119                this.container = this.container.parent();
120            } else if (!this.container.hasClass('jcarousel-container'))
121                this.container = this.list.wrap('<div></div>').parent();
122        } else {
123            this.container = $(e);
124            this.list = $(e).find('>ul,>ol,div>ul,div>ol');
125        }
126
127        if (skin != '' && this.container.parent()[0].className.indexOf('jcarousel-skin') == -1)
128        	this.container.wrap('<div class=" '+ skin + '"></div>');
129
130        this.clip = this.list.parent();
131
132        if (!this.clip.length || !this.clip.hasClass('jcarousel-clip'))
133            this.clip = this.list.wrap('<div></div>').parent();
134
135        this.buttonPrev = $('.jcarousel-prev', this.container);
136
137        if (this.buttonPrev.size() == 0 && this.options.buttonPrevHTML != null)
138            this.buttonPrev = this.clip.before(this.options.buttonPrevHTML).prev();
139
140        this.buttonPrev.addClass(this.className('jcarousel-prev'));
141
142        this.buttonNext = $('.jcarousel-next', this.container);
143
144        if (this.buttonNext.size() == 0 && this.options.buttonNextHTML != null)
145            this.buttonNext = this.clip.before(this.options.buttonNextHTML).prev();
146
147        this.buttonNext.addClass(this.className('jcarousel-next'));
148
149        this.clip.addClass(this.className('jcarousel-clip'));
150        this.list.addClass(this.className('jcarousel-list'));
151        this.container.addClass(this.className('jcarousel-container'));
152
153        var di = this.options.visible != null ? Math.ceil(this.clipping() / this.options.visible) : null;
154        var li = this.list.children('li');
155
156        var self = this;
157
158        if (li.size() > 0) {
159            var wh = 0, i = this.options.offset;
160            li.each(function() {
161                self.format(this, i++);
162                wh += self.dimension(this, di);
163            });
164
165            this.list.css(this.wh, wh + 'px');
166
167            // Only set if not explicitly passed as option
168            if (!o || o.size === undefined)
169                this.options.size = li.size();
170        }
171
172        // For whatever reason, .show() does not work in Safari...
173        this.container.css('display', 'block');
174        this.buttonNext.css('display', 'block');
175        this.buttonPrev.css('display', 'block');
176
177        this.funcNext   = function() { self.next(); };
178        this.funcPrev   = function() { self.prev(); };
179        this.funcResize = function() { self.reload(); };
180
181        if (this.options.initCallback != null)
182            this.options.initCallback(this, 'init');
183
184        if ($.browser.safari) {
185            this.buttons(false, false);
186            $(window).bind('load', function() { self.setup(); });
187        } else
188            this.setup();
189    };
190
191    // Create shortcut for internal use
192    var $jc = $.jcarousel;
193
194    $jc.fn = $jc.prototype = {
195        jcarousel: '0.2.3'
196    };
197
198    $jc.fn.extend = $jc.extend = $.extend;
199
200    $jc.fn.extend({
201        /**
202         * Setups the carousel.
203         *
204         * @name setup
205         * @type undefined
206         * @cat Plugins/jCarousel
207         */
208        setup: function() {
209            this.first     = null;
210            this.last      = null;
211            this.prevFirst = null;
212            this.prevLast  = null;
213            this.animating = false;
214            this.timer     = null;
215            this.tail      = null;
216            this.inTail    = false;
217
218            if (this.locked)
219                return;
220
221            this.list.css(this.lt, this.pos(this.options.offset) + 'px');
222            var p = this.pos(this.options.start);
223            this.prevFirst = this.prevLast = null;
224            this.animate(p, false);
225
226            $(window).unbind('resize', this.funcResize).bind('resize', this.funcResize);
227        },
228
229        /**
230         * Clears the list and resets the carousel.
231         *
232         * @name reset
233         * @type undefined
234         * @cat Plugins/jCarousel
235         */
236        reset: function() {
237            this.list.empty();
238
239            this.list.css(this.lt, '0px');
240            this.list.css(this.wh, '10px');
241
242            if (this.options.initCallback != null)
243                this.options.initCallback(this, 'reset');
244
245            this.setup();
246        },
247
248        /**
249         * Reloads the carousel and adjusts positions.
250         *
251         * @name reload
252         * @type undefined
253         * @cat Plugins/jCarousel
254         */
255        reload: function() {
256            if (this.tail != null && this.inTail)
257                this.list.css(this.lt, $jc.intval(this.list.css(this.lt)) + this.tail);
258
259            this.tail   = null;
260            this.inTail = false;
261
262            if (this.options.reloadCallback != null)
263                this.options.reloadCallback(this);
264
265            if (this.options.visible != null) {
266                var self = this;
267                var di = Math.ceil(this.clipping() / this.options.visible), wh = 0, lt = 0;
268                $('li', this.list).each(function(i) {
269                    wh += self.dimension(this, di);
270                    if (i + 1 < self.first)
271                        lt = wh;
272                });
273
274                this.list.css(this.wh, wh + 'px');
275                this.list.css(this.lt, -lt + 'px');
276            }
277
278            this.scroll(this.first, false);
279        },
280
281        /**
282         * Locks the carousel.
283         *
284         * @name lock
285         * @type undefined
286         * @cat Plugins/jCarousel
287         */
288        lock: function() {
289            this.locked = true;
290            this.buttons();
291        },
292
293        /**
294         * Unlocks the carousel.
295         *
296         * @name unlock
297         * @type undefined
298         * @cat Plugins/jCarousel
299         */
300        unlock: function() {
301            this.locked = false;
302            this.buttons();
303        },
304
305        /**
306         * Sets the size of the carousel.
307         *
308         * @name size
309         * @type undefined
310         * @param Number s The size of the carousel.
311         * @cat Plugins/jCarousel
312         */
313        size: function(s) {
314            if (s != undefined) {
315                this.options.size = s;
316                if (!this.locked)
317                    this.buttons();
318            }
319
320            return this.options.size;
321        },
322
323        /**
324         * Checks whether a list element exists for the given index (or index range).
325         *
326         * @name get
327         * @type bool
328         * @param Number i The index of the (first) element.
329         * @param Number i2 The index of the last element.
330         * @cat Plugins/jCarousel
331         */
332        has: function(i, i2) {
333            if (i2 == undefined || !i2)
334                i2 = i;
335
336            if (this.options.size !== null && i2 > this.options.size)
337            	i2 = this.options.size;
338
339            for (var j = i; j <= i2; j++) {
340                var e = this.get(j);
341                if (!e.length || e.hasClass('jcarousel-item-placeholder'))
342                    return false;
343            }
344
345            return true;
346        },
347
348        /**
349         * Returns a jQuery object with list element for the given index.
350         *
351         * @name get
352         * @type jQuery
353         * @param Number i The index of the element.
354         * @cat Plugins/jCarousel
355         */
356        get: function(i) {
357            return $('.jcarousel-item-' + i, this.list);
358        },
359
360        /**
361         * Adds an element for the given index to the list.
362         * If the element already exists, it updates the inner html.
363         * Returns the created element as jQuery object.
364         *
365         * @name add
366         * @type jQuery
367         * @param Number i The index of the element.
368         * @param String s The innerHTML of the element.
369         * @cat Plugins/jCarousel
370         */
371        add: function(i, s) {
372            var e = this.get(i), old = 0, add = 0;
373
374            if (e.length == 0) {
375                var c, e = this.create(i), j = $jc.intval(i);
376                while (c = this.get(--j)) {
377                    if (j <= 0 || c.length) {
378                        j <= 0 ? this.list.prepend(e) : c.after(e);
379                        break;
380                    }
381                }
382            } else
383                old = this.dimension(e);
384
385            e.removeClass(this.className('jcarousel-item-placeholder'));
386            typeof s == 'string' ? e.html(s) : e.empty().append(s);
387
388            var di = this.options.visible != null ? Math.ceil(this.clipping() / this.options.visible) : null;
389            var wh = this.dimension(e, di) - old;
390
391            if (i > 0 && i < this.first)
392                this.list.css(this.lt, $jc.intval(this.list.css(this.lt)) - wh + 'px');
393
394            this.list.css(this.wh, $jc.intval(this.list.css(this.wh)) + wh + 'px');
395
396            return e;
397        },
398
399        /**
400         * Removes an element for the given index from the list.
401         *
402         * @name remove
403         * @type undefined
404         * @param Number i The index of the element.
405         * @cat Plugins/jCarousel
406         */
407        remove: function(i) {
408            var e = this.get(i);
409
410            // Check if item exists and is not currently visible
411            if (!e.length || (i >= this.first && i <= this.last))
412                return;
413
414            var d = this.dimension(e);
415
416            if (i < this.first)
417                this.list.css(this.lt, $jc.intval(this.list.css(this.lt)) + d + 'px');
418
419            e.remove();
420
421            this.list.css(this.wh, $jc.intval(this.list.css(this.wh)) - d + 'px');
422        },
423
424        /**
425         * Moves the carousel forwards.
426         *
427         * @name next
428         * @type undefined
429         * @cat Plugins/jCarousel
430         */
431        next: function() {
432            this.stopAuto();
433
434            if (this.tail != null && !this.inTail)
435                this.scrollTail(false);
436            else
437                this.scroll(((this.options.wrap == 'both' || this.options.wrap == 'last') && this.options.size != null && this.last == this.options.size) ? 1 : this.first + this.options.scroll);
438        },
439
440        /**
441         * Moves the carousel backwards.
442         *
443         * @name prev
444         * @type undefined
445         * @cat Plugins/jCarousel
446         */
447        prev: function() {
448            this.stopAuto();
449
450            if (this.tail != null && this.inTail)
451                this.scrollTail(true);
452            else
453                this.scroll(((this.options.wrap == 'both' || this.options.wrap == 'first') && this.options.size != null && this.first == 1) ? this.options.size : this.first - this.options.scroll);
454        },
455
456        /**
457         * Scrolls the tail of the carousel.
458         *
459         * @name scrollTail
460         * @type undefined
461         * @param Bool b Whether scroll the tail back or forward.
462         * @cat Plugins/jCarousel
463         */
464        scrollTail: function(b) {
465            if (this.locked || this.animating || !this.tail)
466                return;
467
468            var pos  = $jc.intval(this.list.css(this.lt));
469
470            !b ? pos -= this.tail : pos += this.tail;
471            this.inTail = !b;
472
473            // Save for callbacks
474            this.prevFirst = this.first;
475            this.prevLast  = this.last;
476
477            this.animate(pos);
478        },
479
480        /**
481         * Scrolls the carousel to a certain position.
482         *
483         * @name scroll
484         * @type undefined
485         * @param Number i The index of the element to scoll to.
486         * @param Bool a Flag indicating whether to perform animation.
487         * @cat Plugins/jCarousel
488         */
489        scroll: function(i, a) {
490            if (this.locked || this.animating)
491                return;
492
493            this.animate(this.pos(i), a);
494        },
495
496        /**
497         * Prepares the carousel and return the position for a certian index.
498         *
499         * @name pos
500         * @type Number
501         * @param Number i The index of the element to scoll to.
502         * @cat Plugins/jCarousel
503         */
504        pos: function(i) {
505            if (this.locked || this.animating)
506                return;
507
508            i = $jc.intval(i);
509            if (this.options.wrap != 'circular')
510                i = i < 1 ? 1 : (this.options.size && i > this.options.size ? this.options.size : i);
511
512            var back = this.first > i;
513            var pos  = $jc.intval(this.list.css(this.lt));
514
515            // Create placeholders, new list width/height
516            // and new list position
517            var f = this.options.wrap != 'circular' && this.first <= 1 ? 1 : this.first;
518            var c = back ? this.get(f) : this.get(this.last);
519            var j = back ? f : f - 1;
520            var e = null, l = 0, p = false, d = 0;
521
522            while (back ? --j >= i : ++j < i) {
523                e = this.get(j);
524                p = !e.length;
525                if (e.length == 0) {
526                    e = this.create(j).addClass(this.className('jcarousel-item-placeholder'));
527                    c[back ? 'before' : 'after' ](e);
528                }
529
530                c = e;
531                d = this.dimension(e);
532
533                if (p)
534                    l += d;
535
536                if (this.first != null && (this.options.wrap == 'circular' || (j >= 1 && (this.options.size == null || j <= this.options.size))))
537                    pos = back ? pos + d : pos - d;
538            }
539
540            // Calculate visible items
541            var clipping = this.clipping();
542            var cache = [];
543            var visible = 0, j = i, v = 0;
544            var c = this.get(i - 1);
545
546            while (++visible) {
547                e = this.get(j);
548                p = !e.length;
549                if (e.length == 0) {
550                    e = this.create(j).addClass(this.className('jcarousel-item-placeholder'));
551                    // This should only happen on a next scroll
552                    c.length == 0 ? this.list.prepend(e) : c[back ? 'before' : 'after' ](e);
553                }
554
555                c = e;
556                var d = this.dimension(e);
557                if (d == 0) {
558                    alert('jCarousel: No width/height set for items. This will cause an infinite loop. Aborting...');
559                    return 0;
560                }
561
562                if (this.options.wrap != 'circular' && this.options.size !== null && j > this.options.size)
563                    cache.push(e);
564                else if (p)
565                    l += d;
566
567                v += d;
568
569                if (v >= clipping)
570                    break;
571
572                j++;
573            }
574
575             // Remove out-of-range placeholders
576            for (var x = 0; x < cache.length; x++)
577                cache[x].remove();
578
579            // Resize list
580            if (l > 0) {
581                this.list.css(this.wh, this.dimension(this.list) + l + 'px');
582
583                if (back) {
584                    pos -= l;
585                    this.list.css(this.lt, $jc.intval(this.list.css(this.lt)) - l + 'px');
586                }
587            }
588
589            // Calculate first and last item
590            var last = i + visible - 1;
591            if (this.options.wrap != 'circular' && this.options.size && last > this.options.size)
592                last = this.options.size;
593
594            if (j > last) {
595                visible = 0, j = last, v = 0;
596                while (++visible) {
597                    var e = this.get(j--);
598                    if (!e.length)
599                        break;
600                    v += this.dimension(e);
601                    if (v >= clipping)
602                        break;
603                }
604            }
605
606            var first = last - visible + 1;
607            if (this.options.wrap != 'circular' && first < 1)
608                first = 1;
609
610            if (this.inTail && back) {
611                pos += this.tail;
612                this.inTail = false;
613            }
614
615            this.tail = null;
616            if (this.options.wrap != 'circular' && last == this.options.size && (last - visible + 1) >= 1) {
617                var m = $jc.margin(this.get(last), !this.options.vertical ? 'marginRight' : 'marginBottom');
618                if ((v - m) > clipping)
619                    this.tail = v - clipping - m;
620            }
621
622            // Adjust position
623            while (i-- > first)
624                pos += this.dimension(this.get(i));
625
626            // Save visible item range
627            this.prevFirst = this.first;
628            this.prevLast  = this.last;
629            this.first     = first;
630            this.last      = last;
631
632            return pos;
633        },
634
635        /**
636         * Animates the carousel to a certain position.
637         *
638         * @name animate
639         * @type undefined
640         * @param mixed p Position to scroll to.
641         * @param Bool a Flag indicating whether to perform animation.
642         * @cat Plugins/jCarousel
643         */
644        animate: function(p, a) {
645            if (this.locked || this.animating)
646                return;
647
648            this.animating = true;
649
650            var self = this;
651            var scrolled = function() {
652                self.animating = false;
653
654                if (p == 0)
655                    self.list.css(self.lt,  0);
656
657                if (self.options.wrap == 'both' || self.options.wrap == 'last' || self.options.size == null || self.last < self.options.size)
658                    self.startAuto();
659
660                self.buttons();
661                self.notify('onAfterAnimation');
662            };
663
664            this.notify('onBeforeAnimation');
665
666            // Animate
667            if (!this.options.animation || a == false) {
668                this.list.css(this.lt, p + 'px');
669                scrolled();
670            } else {
671                var o = !this.options.vertical ? {'left': p} : {'top': p};
672                this.list.animate(o, this.options.animation, this.options.easing, scrolled);
673            }
674        },
675
676        /**
677         * Starts autoscrolling.
678         *
679         * @name auto
680         * @type undefined
681         * @param Number s Seconds to periodically autoscroll the content.
682         * @cat Plugins/jCarousel
683         */
684        startAuto: function(s) {
685            if (s != undefined)
686                this.options.auto = s;
687
688            if (this.options.auto == 0)
689                return this.stopAuto();
690
691            if (this.timer != null)
692                return;
693
694            var self = this;
695            this.timer = setTimeout(function() { self.next(); }, this.options.auto * 1000);
696        },
697
698        /**
699         * Stops autoscrolling.
700         *
701         * @name stopAuto
702         * @type undefined
703         * @cat Plugins/jCarousel
704         */
705        stopAuto: function() {
706            if (this.timer == null)
707                return;
708
709            clearTimeout(this.timer);
710            this.timer = null;
711        },
712
713        /**
714         * Sets the states of the prev/next buttons.
715         *
716         * @name buttons
717         * @type undefined
718         * @cat Plugins/jCarousel
719         */
720        buttons: function(n, p) {
721            if (n == undefined || n == null) {
722                var n = !this.locked && this.options.size !== 0 && ((this.options.wrap && this.options.wrap != 'first') || this.options.size == null || this.last < this.options.size);
723                if (!this.locked && (!this.options.wrap || this.options.wrap == 'first') && this.options.size != null && this.last >= this.options.size)
724                    n = this.tail != null && !this.inTail;
725            }
726
727            if (p == undefined || p == null) {
728                var p = !this.locked && this.options.size !== 0 && ((this.options.wrap && this.options.wrap != 'last') || this.first > 1);
729                if (!this.locked && (!this.options.wrap || this.options.wrap == 'last') && this.options.size != null && this.first == 1)
730                    p = this.tail != null && this.inTail;
731            }
732
733            var self = this;
734
735            this.buttonNext[n ? 'bind' : 'unbind'](this.options.buttonNextEvent, this.funcNext)[n ? 'removeClass' : 'addClass'](this.className('jcarousel-next-disabled')).attr('disabled', n ? false : true);
736            this.buttonPrev[p ? 'bind' : 'unbind'](this.options.buttonPrevEvent, this.funcPrev)[p ? 'removeClass' : 'addClass'](this.className('jcarousel-prev-disabled')).attr('disabled', p ? false : true);
737
738            if (this.buttonNext.length >
738 0 && (this.buttonNext[0].jcarouselstate == undefined || this.buttonNext[0].jcarouselstate != n) && this.options.buttonNextCallback != null) {
739                this.buttonNext.each(function() { self.options.buttonNextCallback(self, this, n); });
740                this.buttonNext[0].jcarouselstate = n;
741            }
742
743            if (this.buttonPrev.length > 0 && (this.buttonPrev[0].jcarouselstate == undefined || this.buttonPrev[0].jcarouselstate != p) && this.options.buttonPrevCallback != null) {
744                this.buttonPrev.each(function() { self.options.buttonPrevCallback(self, this, p); });
745                this.buttonPrev[0].jcarouselstate = p;
746            }
747        },
748
749        notify: function(evt) {
750            var state = this.prevFirst == null ? 'init' : (this.prevFirst < this.first ? 'next' : 'prev');
751
752            // Load items
753            this.callback('itemLoadCallback', evt, state);
754
755            if (this.prevFirst !== this.first) {
756                this.callback('itemFirstInCallback', evt, state, this.first);
757                this.callback('itemFirstOutCallback', evt, state, this.prevFirst);
758            }
759
760            if (this.prevLast !== this.last) {
761                this.callback('itemLastInCallback', evt, state, this.last);
762                this.callback('itemLastOutCallback', evt, state, this.prevLast);
763            }
764
765            this.callback('itemVisibleInCallback', evt, state, this.first, this.last, this.prevFirst, this.prevLast);
766            this.callback('itemVisibleOutCallback', evt, state, this.prevFirst, this.prevLast, this.first, this.last);
767        },
768
769        callback: function(cb, evt, state, i1, i2, i3, i4) {
770            if (this.options[cb] == undefined || (typeof this.options[cb] != 'object' && evt != 'onAfterAnimation'))
771                return;
772
773            var callback = typeof this.options[cb] == 'object' ? this.options[cb][evt] : this.options[cb];
774
775            if (!$.isFunction(callback))
776                return;
777
778            var self = this;
779
780            if (i1 === undefined)
781                callback(self, state, evt);
782            else if (i2 === undefined)
783                this.get(i1).each(function() { callback(self, this, i1, state, evt); });
784            else {
785                for (var i = i1; i <= i2; i++)
786                    if (i !== null && !(i >= i3 && i <= i4))
787                        this.get(i).each(function() { callback(self, this, i, state, evt); });
788            }
789        },
790
791        create: function(i) {
792            return this.format('<li></li>', i);
793        },
794
795        format: function(e, i) {
796            var $e = $(e).addClass(this.className('jcarousel-item')).addClass(this.className('jcarousel-item-' + i));
797            $e.attr('jcarouselindex', i);
798            return $e;
799        },
800
801        className: function(c) {
802            return c + ' ' + c + (!this.options.vertical ? '-horizontal' : '-vertical');
803        },
804
805        dimension: function(e, d) {
806            var el = e.jquery != undefined ? e[0] : e;
807
808            var old = !this.options.vertical ?
809                el.offsetWidth + $jc.margin(el, 'marginLeft') + $jc.margin(el, 'marginRight') :
810                el.offsetHeight + $jc.margin(el, 'marginTop') + $jc.margin(el, 'marginBottom');
811
812            if (d == undefined || old == d)
813                return old;
814
815            var w = !this.options.vertical ?
816                d - $jc.margin(el, 'marginLeft') - $jc.margin(el, 'marginRight') :
817                d - $jc.margin(el, 'marginTop') - $jc.margin(el, 'marginBottom');
818
819            $(el).css(this.wh, w + 'px');
820
821            return this.dimension(el);
822        },
823
824        clipping: function() {
825            return !this.options.vertical ?
826                this.clip[0].offsetWidth - $jc.intval(this.clip.css('borderLeftWidth')) - $jc.intval(this.clip.css('borderRightWidth')) :
827                this.clip[0].offsetHeight - $jc.intval(this.clip.css('borderTopWidth')) - $jc.intval(this.clip.css('borderBottomWidth'));
828        },
829
830        index: function(i, s) {
831            if (s == undefined)
832                s = this.options.size;
833
834            return Math.round((((i-1) / s) - Math.floor((i-1) / s)) * s) + 1;
835        }
836    });
837
838    $jc.extend({
839        /**
840         * Gets/Sets the global default configuration properties.
841         *
842         * @name defaults
843         * @descr Gets/Sets the global default configuration properties.
844         * @type Hash
845         * @param Hash d A set of key/value pairs to set as configuration properties.
846         * @cat Plugins/jCarousel
847         */
848        defaults: function(d) {
849            return $.extend(defaults, d || {});
850        },
851
852        margin: function(e, p) {
853            if (!e)
854                return 0;
855
856            var el = e.jquery != undefined ? e[0] : e;
857
858            if (p == 'marginRight' && $.browser.safari) {
859                var old = {'display': 'block', 'float': 'none', 'width': 'auto'}, oWidth, oWidth2;
860
861                $.swap(el, old, function() { oWidth = el.offsetWidth; });
862
863                old['marginRight'] = 0;
864                $.swap(el, old, function() { oWidth2 = el.offsetWidth; });
865
866                return oWidth2 - oWidth;
867            }
868
869            return $jc.intval($.css(el, p));
870        },
871
872        intval: function(v) {
873            v = parseInt(v);
874            return isNaN(v) ? 0 : v;
875        }
876    });
877
878})(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.