PageSourceSearch

https://www.valuehomes.ca/modules/widgets/featured_listing/js/jquery.jcarousel.js?1

js valuehomes.ca collected 2026-09-26 19:33:47 UTC 48,174 bytes, 1,484 lines download raw bytes

vendor: 32,228 bytes, lines 1-972
1/*! jCarousel - v0.3.9 - 2018-07-30
2* http://sorgalla.com/jcarousel/
3* Copyright (c) 2006-2018 Jan Sorgalla; Licensed MIT */
4(function($) {
5    'use strict';
6
7    var jCarousel = $.jCarousel = {};
8
9    jCarousel.version = '0.3.9';
10
11    var rRelativeTarget = /^([+\-]=)?(.+)$/;
12
13    jCarousel.parseTarget = function(target) {
14        var relative = false,
15            parts    = typeof target !== 'object' ?
16                           rRelativeTarget.exec(target) :
17                           null;
18
19        if (parts) {
20            target = parseInt(parts[2], 10) || 0;
21
22            if (parts[1]) {
23                relative = true;
24                if (parts[1] === '-=') {
25                    target *= -1;
26                }
27            }
28        } else if (typeof target !== 'object') {
29            target = parseInt(target, 10) || 0;
30        }
31
32        return {
33            target: target,
34            relative: relative
35        };
36    };
37
38    jCarousel.detectCarousel = function(element) {
39        var carousel;
40
41        while (element.length > 0) {
42            carousel = element.filter('[data-jcarousel]');
43
44            if (carousel.length > 0) {
45                return carousel;
46            }
47
48            carousel = element.find('[data-jcarousel]');
49
50            if (carousel.length > 0) {
51                return carousel;
52            }
53
54            element = element.parent();
55        }
56
57        return null;
58    };
59
60    jCarousel.base = function(pluginName) {
61        return {
62            version:  jCarousel.version,
63            _options:  {},
64            _element:  null,
65            _carousel: null,
66            _init:     $.noop,
67            _create:   $.noop,
68            _destroy:  $.noop,
69            _reload:   $.noop,
70            create: function() {
71                this._element
72                    .attr('data-' + pluginName.toLowerCase(), true)
73                    .data(pluginName, this);
74
75                if (false === this._trigger('create')) {
76                    return this;
77                }
78
79                this._create();
80
81                this._trigger('createend');
82
83                return this;
84            },
85            destroy: function() {
86                if (false === this._trigger('destroy')) {
87                    return this;
88                }
89
90                this._destroy();
91
92                this._trigger('destroyend');
93
94                this._element
95                    .removeData(pluginName)
96                    .removeAttr('data-' + pluginName.toLowerCase());
97
98                return this;
99            },
100            reload: function(options) {
101                if (false === this._trigger('reload')) {
102                    return this;
103                }
104
105                if (options) {
106                    this.options(options);
107                }
108
109                this._reload();
110
111                this._trigger('reloadend');
112
113                return this;
114            },
115            element: function() {
116                return this._element;
117            },
118            options: function(key, value) {
119                if (arguments.length === 0) {
120                    return $.extend({}, this._options);
121                }
122
123                if (typeof key === 'string') {
124                    if (typeof value === 'undefined') {
125                        return typeof this._options[key] === 'undefined' ?
126                                null :
127                                this._options[key];
128                    }
129
130                    this._options[key] = value;
131                } else {
132                    this._options = $.extend({}, this._options, key);
133                }
134
135                return this;
136            },
137            carousel: function() {
138                if (!this._carousel) {
139                    this._carousel = jCarousel.detectCarousel(this.options('carousel') || this._element);
140
141                    if (!this._carousel) {
142                        $.error('Could not detect carousel for plugin "' + pluginName + '"');
143                    }
144                }
145
146                return this._carousel;
147            },
148            _trigger: function(type, element, data) {
149                var event,
150                    defaultPrevented = false;
151
152                data = [this].concat(data || []);
153
154                (element || this._element).each(function() {
155                    event = $.Event((pluginName + ':' + type).toLowerCase());
156
157                    $(this).trigger(event, data);
158
159                    if (event.isDefaultPrevented()) {
160                        defaultPrevented = true;
161                    }
162                });
163
164                return !defaultPrevented;
165            }
166        };
167    };
168
169    jCarousel.plugin = function(pluginName, pluginPrototype) {
170        var Plugin = $[pluginName] = function(element, options) {
171            this._element = $(element);
172            this.options(options);
173
174            this._init();
175            this.create();
176        };
177
178        Plugin.fn = Plugin.prototype = $.extend(
179            {},
180            jCarousel.base(pluginName),
181            pluginPrototype
182        );
183
184        $.fn[pluginName] = function(options) {
185            var args        = Array.prototype.slice.call(arguments, 1),
186                returnValue = this;
187
188            if (typeof options === 'string') {
189                this.each(function() {
190                    var instance = $(this).data(pluginName);
191
192                    if (!instance) {
193                        return $.error(
194                            'Cannot call methods on ' + pluginName + ' prior to initialization; ' +
195                            'attempted to call method "' + options + '"'
196                        );
197                    }
198
199                    if (!$.isFunction(instance[options]) || options.charAt(0) === '_') {
200                        return $.error(
201                            'No such method "' + options + '" for ' + pluginName + ' instance'
202                        );
203                    }
204
205                    var methodValue = instance[options].apply(instance, args);
206
207                    if (methodValue !== instance && typeof methodValue !== 'undefined') {
208                        returnValue = methodValue;
209                        return false;
210                    }
211                });
212            } else {
213                this.each(function() {
214                    var instance = $(this).data(pluginName);
215
216                    if (instance instanceof Plugin) {
217                        instance.reload(options);
218                    } else {
219                        new Plugin(this, options);
220                    }
221                });
222            }
223
224            return returnValue;
225        };
226
227        return Plugin;
228    };
229}(jQuery));
230
231(function($, window) {
232    'use strict';
233
234    var $window = $(window);
235
236    var toFloat = function(val) {
237        return parseFloat(val) || 0;
238    };
239
240    $.jCarousel.plugin('jcarousel', {
241        animating:   false,
242        tail:        0,
243        inTail:      false,
244        resizeState: null,
245        resizeTimer: null,
246        lt:          null,
247        vertical:    false,
248        rtl:         false,
249        circular:    false,
250        underflow:   false,
251        relative:    false,
252
253        _options: {
254            list: function() {
255                return this.element().children().eq(0);
256            },
257            items: function() {
258                return this.list().children();
259            },
260            animation:   400,
261            transitions: false,
262            wrap:        null,
263            vertical:    null,
264            rtl:         null,
265            center:      false
266        },
267
268        // Protected, don't access directly
269        _list:         null,
270        _items:        null,
271        _target:       $(),
272        _first:        $(),
273        _last:         $(),
274        _visible:      $(),
275        _fullyvisible: $(),
276        _init: function() {
277            var self = this;
278
279            self.resizeState = $window.width() + 'x' + $window.height();
280
281            this.onWindowResize = function() {
282                if (self.resizeTimer) {
283                    clearTimeout(self.resizeTimer);
284                }
285
286                self.resizeTimer = setTimeout(function() {
287                    var currentResizeState = $window.width() + 'x' + $window.height();
288
289                    // Check if the window size actually changed.
290                    // iOS might trigger resize events on page scroll.
291                    if (currentResizeState === self.resizeState) {
292                        return;
293                    }
294
295                    self.resizeState = currentResizeState;
296                    self.reload();
297                }, 100);
298            };
299
300            return this;
301        },
302        _create: function() {
303            this._reload();
304
305            $window.on('resize.jcarousel', this.onWindowResize);
306        },
307        _destroy: function() {
308            $window.off('resize.jcarousel', this.onWindowResize);
309        },
310        _reload: function() {
311            this.vertical = this.options('vertical');
312
313            if (this.vertical == null) {
314                this.vertical = toFloat(this.list().height()) > toFloat(this.list().width());
315            }
316
317            this.rtl = this.options('rtl');
318
319            if (this.rtl == null) {
320                this.rtl = (function(element) {
321                    if (('' + element.attr('dir')).toLowerCase() === 'rtl') {
322                        return true;
323                    }
324
325                    var found = false;
326
327                    element.parents('[dir]').each(function() {
328                        if ((/rtl/i).test($(this).attr('dir'))) {
329                            found = true;
330                            return false;
331                        }
332                    });
333
334                    return found;
335                }(this._element));
336            }
337
338            this.lt = this.vertical ? 'top' : 'left';
339
340            // Ensure before closest() call
341            this.relative = this.list().css('position') === 'relative';
342
343            // Force list and items reload
344            this._list  = null;
345            this._items = null;
346
347            var item = this.index(this._target) >= 0 ?
348                           this._target :
349                           this.closest();
350
351            // _prepare() needs this here
352            this.circular  = this.options('wrap') === 'circular';
353            this.underflow = false;
354
355            var props = {'left': 0, 'top': 0};
356
357            if (item.length > 0) {
358                this._prepare(item);
359                this.list().find('[data-jcarousel-clone]').remove();
360
361                // Force items reload
362                this._items = null;
363
364                this.underflow = this._fullyvisible.length >= this.items().length;
365                this.circular  = this.circular && !this.underflow;
366
367                props[this.lt] = this._position(item) + 'px';
368            }
369
370            this.move(props);
371
372            return this;
373        },
374        list: function() {
375            if (this._list === null) {
376                var option = this.options('list');
377                this._list = $.isFunction(option) ? option.call(this) : this._element.find(option);
378            }
379
380            return this._list;
381        },
382        items: function() {
383            if (this._items === null) {
384                var option = this.options('items');
385                this._items = ($.isFunction(option) ? option.call(this) : this.list().find(option)).not('[data-jcarousel-clone]');
386            }
387
388            return this._items;
389        },
390        index: function(item) {
391            return this.items().index(item);
392        },
393        closest: function() {
394            var self    = this,
395                pos     = this.list().position()[this.lt],
396                closest = $(), // Ensure we're returning a jQuery instance
397                stop    = false,
398                lrb     = this.vertical ? 'bottom' : (this.rtl && !this.relative ? 'left' : 'right'),
399                width;
400
401            if (this.rtl && this.relative && !this.vertical) {
402                pos += toFloat(this.list().width()) - this.clipping();
403            }
404
405            this.items().each(function() {
406                closest = $(this);
407
408                if (stop) {
409                    return false;
410                }
411
412                var dim = self.dimension(closest);
413
414                pos += dim;
415
416                if (pos >= 0) {
417                    width = dim - toFloat(closest.css('margin-' + lrb));
418
419                    if ((Math.abs(pos) - dim + (width / 2)) <= 0) {
420                        stop = true;
421                    } else {
422                        return false;
423                    }
424                }
425            });
426
427
428            return closest;
429        },
430        target: function() {
431            return this._target;
432        },
433        first: function() {
434            return this._first;
435        },
436        last: function() {
437            return this._last;
438        },
439        visible: function() {
440            return this._visible;
441        },
442        fullyvisible: function() {
443            return this._fullyvisible;
444        },
445        hasNext: function() {
446            if (false === this._trigger('hasnext')) {
447                return true;
448            }
449
450            var wrap = this.options('wrap'),
451                end = this.items().length - 1,
452                check = this.options('center') ? this._target : this._last;
453
454            return end >= 0 && !this.underflow &&
455                ((wrap && wrap !== 'first') ||
456                    (this.index(check) < end) ||
457                    (this.tail && !this.inTail)) ? true : false;
458        },
459        hasPrev: function() {
460            if (false === this._trigger('hasprev')) {
461                return true;
462            }
463
464            var wrap = this.options('wrap');
465
466            return this.items().length > 0 && !this.underflow &&
467                ((wrap && wrap !== 'last') ||
468                    (this.index(this._first) > 0) ||
469                    (this.tail && this.inTail)) ? true : false;
470        },
471        clipping: function() {
472            return toFloat(this._element['inner' + (this.vertical ? 'Height' : 'Width')]());
473        },
474        dimension: function(element) {
475            return toFloat(element['outer' + (this.vertical ? 'Height' : 'Width')](true));
476        },
477        scroll: function(target, animate, callback) {
478            if (this.animating) {
479                return this;
480            }
481
482            if (false === this._trigger('scroll', null, [target, animate])) {
483                return this;
484            }
485
486            if ($.isFunction(animate)) {
487                callback = animate;
488                animate  = true;
489            }
490
491            var parsed = $.jCarousel.parseTarget(target);
492
493            if (parsed.relative) {
494                var end    = this.items().length - 1,
495                    scroll = Math.abs(parsed.target),
496                    wrap   = this.options('wrap'),
497                    current,
498                    first,
499                    index,
500                    start,
501                    curr,
502                    isVisible,
503                    props,
504                    i;
505
506                if (parsed.target > 0) {
507                    var last = this.index(this._last);
508
509                    if (last >= end && this.tail) {
510                        if (!this.inTail) {
511                            this._scrollTail(animate, callback);
512                        } else {
513                            if (wrap === 'both' || wrap === 'last') {
514                                this._scroll(0, animate, callback);
515                            } else {
516                                if ($.isFunction(callback)) {
517                                    callback.call(this, false);
518                                }
519                            }
520                        }
521                    } else {
522                        current = this.index(this._target);
523
524                        if ((this.underflow && current === end && (wrap === 'circular' || wrap === 'both' || wrap === 'last')) ||
525                            (!this.underflow && last === end && (wrap === 'both' || wrap === 'last'))) {
526                            this._scroll(0, animate, callback);
527                        } else {
528                            index = current + scroll;
529
530                            if (this.circular && index > end) {
531                                i = end;
532                                curr = this.items().get(-1);
533
534                                while (i++ < index) {
535                                    curr = this.items().eq(0);
536                                    isVisible = this._visible.index(curr) >= 0;
537
538                                    if (isVisible) {
539                                        curr.after(curr.clone(true).attr('data-jcarousel-clone', true));
540                                    }
541
542                                    this.list().append(curr);
543
544                                    if (!isVisible) {
545                                        props = {};
546                                        props[this.lt] = this.dimension(curr);
547                                        this.moveBy(props);
548                                    }
549
550                                    // Force items reload
551                                    this._items = null;
552                                }
553
554                                this._scroll(curr, animate, callback);
555                            } else {
556                                this._scroll(Math.min(index, end), animate, callback);
557                            }
558                        }
559                    }
560                } else {
561                    if (this.inTail) {
562                        this._scroll(Math.max((this.index(this._first) - scroll) + 1, 0), animate, callback);
563                    } else {
564                        first  = this.index(this._first);
565                        current = this.index(this._target);
566                        start  = this.underflow ? current : first;
567                        index  = start - scroll;
568
569                        if (start <= 0 && ((this.underflow && wrap === 'circular') || wrap === 'both' || wrap === 'first')) {
570                            this._scroll(end, animate, callback);
571                        } else {
572                            if (this.circular && index < 0) {
573                                i    = index;
574                                curr = this.items().get(0);
575
576                                while (i++ < 0) {
577                                    curr = this.items().eq(-1);
578                                    isVisible = this._visible.index(curr) >= 0;
579
580                                    if (isVisible) {
581                                        curr.after(curr.clone(true).attr('data-jcarousel-clone', true));
582                                    }
583
584                                    this.list().prepend(curr);
585
586                                    // Force items reload
587                                    this._items = null;
588
589                                    var dim = this.dimension(curr);
590
591                                    props = {};
592                                    props[this.lt] = -dim;
593                                    this.moveBy(props);
594
595                                }
596
597                                this._scroll(curr, animate, callback);
598                            } else {
599                                this._scroll(Math.max(index, 0), animate, callback);
600                            }
601                        }
602                    }
603                }
604            } else {
605                this._scroll(parsed.target, animate, callback);
606            }
607
608            this._trigger('scrollend');
609
610            return this;
611        },
612        moveBy: function(properties, opts) {
613            var position = this.list().position(),
614                multiplier = 1,
615                correction = 0;
616
617            if (this.rtl && !this.vertical) {
618                multiplier = -1;
619
620                if (this.relative) {
621                    correction = toFloat(this.list().width()) - this.clipping();
622                }
623            }
624
625            if (properties.left) {
626                properties.left = (toFloat(position.left) + correction + toFloat(properties.left) * multiplier) + 'px';
627            }
628
629            if (properties.top) {
630                properties.top = (toFloat(position.top) + correction + toFloat(properties.top) * multiplier) + 'px';
631            }
632
633            return this.move(properties, opts);
634        },
635        move: function(properties, opts) {
636            opts = opts || {};
637
638            var option       = this.options('transitions'),
639                transitions  = !!option,
640                transforms   = !!option.transforms,
641                transforms3d = !!option.transforms3d,
642                duration     = opts.duration || 0,
643                list         = this.list();
644
645            if (!transitions && duration > 0) {
646                list.animate(properties, opts);
647                return;
648            }
649
650            var complete = opts.complete || $.noop,
651                css = {};
652
653            if (transitions) {
654                var backup = {
655                        transitionDuration: list.css('transitionDuration'),
656                        transitionTimingFunction: list.css('transitionTimingFunction'),
657                        transitionProperty: list.css('transitionProperty')
658                    },
659                    oldComplete = complete;
660
661                complete = function() {
662                    $(this).css(backup);
663                    oldComplete.call(this);
664                };
665                css = {
666                    transitionDuration: (duration > 0 ? duration / 1000 : 0) + 's',
667                    transitionTimingFunction: option.easing || opts.easing,
668                    transitionProperty: duration > 0 ? (function() {
669                        if (transforms || transforms3d) {
670                            // We have to use 'all' because jQuery doesn't prefix
671                            // css values, like transition-property: transform;
672                            return 'all';
673                        }
674
675                        return properties.left ? 'left' : 'top';
676                    })() : 'none',
677                    transform: 'none'
678                };
679            }
680
681            if (transforms3d) {
682                css.transform = 'translate3d(' + (properties.left || 0) + ',' + (properties.top || 0) + ',0)';
683            } else if (transforms) {
684                css.transform = 'translate(' + (properties.left || 0) + ',' + (properties.top || 0) + ')';
685            } else {
686                $.extend(css, properties);
687            }
688
689            if (transitions && duration > 0) {
690                list.one('transitionend webkitTransitionEnd oTransitionEnd otransitionend MSTransitionEnd', complete);
691            }
692
693            list.css(css);
694
695            if (duration <= 0) {
696                list.each(function() {
697                    complete.call(this);
698                });
699            }
700        },
701        _scroll: function(item, animate, callback) {
702            if (this.animating) {
703                if ($.isFunction(callback)) {
704                    callback.call(this, false);
705                }
706
707                return this;
708            }
709
710            if (typeof item !== 'object') {
711                item = this.items().eq(item);
712            } else if (typeof item.jquery === 'undefined') {
713                item = $(item);
714            }
715
716            if (item.length === 0) {
717                if ($.isFunction(callback)) {
718                    callback.call(this, false);
719                }
720
721                return this;
722            }
723
724            this.inTail = false;
725
726            this._prepare(item);
727
728            var pos     = this._position(item),
729                currPos = toFloat(this.list().position()[this.lt]);
730
731            if (pos === currPos) {
732                if ($.isFunction(callback)) {
733                    callback.call(this, false);
734                }
735
736                return this;
737            }
738
739            var properties = {};
740            properties[this.lt] = pos + 'px';
741
742            this._animate(properties, animate, callback);
743
744            return this;
745        },
746        _scrollTail: function(animate, callback) {
747            if (this.animating || !this.tail) {
748                if ($.isFunction(callback)) {
749                    callback.call(this, false);
750                }
751
752                return this;
753            }
754
755            var pos = this.list().position()[this.lt];
756
757            if (this.rtl && this.relative && !this.vertical) {
758                pos += toFloat(this.list().width()) - this.clipping();
759            }
760
761            if (this.rtl && !this.vertical) {
762                pos += this.tail;
763            } else {
764                pos -= this.tail;
765            }
766
767            this.inTail = true;
768
769            var properties = {};
770            properties[this.lt] = pos + 'px';
771
772            this._update({
773                target:       this._target.next(),
774                fullyvisible: this._fullyvisible.slice(1).add(this._visible.last())
775            });
776
777            this._animate(properties, animate, callback);
778
779            return this;
780        },
781        _animate: function(properties, animate, callback) {
782            callback = callback || $.noop;
783
784            if (false === this._trigger('animate')) {
785                callback.call(this, false);
786                return this;
787            }
788
789            this.animating = true;
790
791            var animation = this.options('animation'),
792                complete  = $.proxy(function() {
793                    this.animating = false;
794
795                    var c = this.list().find('[data-jcarousel-clone]');
796
797                    if (c.length > 0) {
798                        c.remove();
799                        this._reload();
800                    }
801
802                    this._trigger('animateend');
803
804                    callback.call(this, true);
805                }, this);
806
807            var opts = typeof animation === 'object' ?
808                           $.extend({}, animation) :
809                           {duration: animation},
810                oldComplete = opts.complete || $.noop;
811
812            if (animate === false) {
813                opts.duration = 0;
814            } else if (typeof $.fx.speeds[opts.duration] !== 'undefined') {
815                opts.duration = $.fx.speeds[opts.duration];
816            }
817
818            opts.complete = function() {
819                complete();
820                oldComplete.call(this);
821            };
822
823            this.move(properties, opts);
824
825            return this;
826        },
827        _prepare: function(item) {
828            var index  = this.index(item),
829                idx    = index,
830                wh     = this.dimension(item),
831                clip   = this.clipping(),
832                lrb    = this.vertical ? 'bottom' : (this.rtl ? 'left'  : 'right'),
833                center = this.options('center'),
834                update = {
835                    target:       item,
836                    first:        item,
837                    last:         item,
838                    visible:      item,
839                    fullyvisible: wh <= clip ? item : $()
840                },
841                curr,
842                isVisible,
843                margin,
844                dim;
845
846            if (center) {
847                wh /= 2;
848                clip /= 2;
849            }
850
851            if (wh < clip) {
852                while (true) {
853                    curr = this.items().eq(++idx);
854
855                    if (curr.length === 0) {
856                        if (!this.circular) {
857                            break;
858                        }
859
860                        curr = this.items().eq(0);
861
862                        if (item.get(0) === curr.get(0)) {
863                            break;
864                        }
865
866                        isVisible = this._visible.index(curr) >= 0;
867
868                        if (isVisible) {
869                            curr.after(curr.clone(true).attr('data-jcarousel-clone', true));
870                        }
871
872                        this.list().append(curr);
873
874                        if (!isVisible) {
875                            var props = {};
876                            props[this.lt] = this.dimension(curr);
877                            this.moveBy(props);
878                        }
879
880                        // Force items reload
881                        this._items = null;
882                    }
883
884                    dim = this.dimension(curr);
885
886                    if (dim === 0) {
887                        break;
888                    }
889
890                    wh += dim;
891
892                    update.last    = curr;
893                    update.visible = update.visible.add(curr);
894
895                    // Remove right/bottom margin from total width
896                    margin = toFloat(curr.css('margin-' + lrb));
897
898                    if ((wh - margin) <= clip) {
899                        update.fullyvisible = update.fullyvisible.add(curr);
900                    }
901
902                    if (wh >= clip) {
903                        break;
904                    }
905                }
906            }
907
908            if (!this.circular && !center && wh < clip) {
909                idx = index;
910
911                while (true) {
912                    if (--idx < 0) {
913                        break;
914                    }
915
916                    curr = this.items().eq(idx);
917
918                    if (curr.length === 0) {
919                        break;
920                    }
921
922                    dim = this.dimension(curr);
923
924                    if (dim === 0) {
925                        break;
926                    }
927
928                    wh += dim;
929
930                    update.first   = curr;
931                    update.visible = update.visible.add(curr);
932
933                    // Remove right/bottom margin from total width
934                    margin = toFloat(curr.css('margin-' + lrb));
935
936                    if ((wh - margin) <= clip) {
937                        update.fullyvisible = update.fullyvisible.add(curr);
938                    }
939
940                    if (wh >= clip) {
941                        break;
942                    }
943                }
944            }
945
946            this._update(update);
947
948            this.tail = 0;
949
950            if (!center &&
951                this.options('wrap') !== 'circular' &&
952                this.options('wrap') !== 'custom' &&
953                this.index(update.last) === (this.items().length - 1)) {
954
955                // Remove right/bottom margin from total width
956                wh -= toFloat(update.last.css('margin-' + lrb));
957
958                if (wh > clip) {
959                    this.tail = wh - clip;
960                }
961            }
962
963            return this;
964        },
965        _position: function(item) {
966            var first  = this._first,
967                pos    = toFloat(first.position()[this.lt]),
968                center = this.options('center'),
969                centerOffset = center ? (this.clipping() / 2) - (this.dimension(first) / 2) : 0;
970
971            if (this.rtl && !this.vertical) {
972                if (this.relative) {
vendor: 15,201 bytes, lines 973-1455
973                    pos -= toFloat(this.list().width()) - this.dimension(first);
974                } else {
975                    pos -= this.clipping() - this.dimension(first);
976                }
977
978                pos += centerOffset;
979            } else {
980                pos -= centerOffset;
981            }
982
983            if (!center &&
984                (this.index(item) > this.index(first) || this.inTail) &&
985                this.tail) {
986                pos = this.rtl && !this.vertical ? pos - this.tail : pos + this.tail;
987                this.inTail = true;
988            } else {
989                this.inTail = false;
990            }
991
992            return -pos;
993        },
994        _update: function(update) {
995            var self = this,
996                current = {
997                    target:       this._target,
998                    first:        this._first,
999                    last:         this._last,
1000                    visible:      this._visible,
1001                    fullyvisible: this._fullyvisible
1002                },
1003                back = this.index(update.first || current.first) < this.index(current.first),
1004                key,
1005                doUpdate = function(key) {
1006                    var elIn  = [],
1007                        elOut = [];
1008
1009                    update[key].each(function() {
1010                        if (current[key].index(this) < 0) {
1011                            elIn.push(this);
1012                        }
1013                    });
1014
1015                    current[key].each(function() {
1016                        if (update[key].index(this) < 0) {
1017                            elOut.push(this);
1018                        }
1019                    });
1020
1021                    if (back) {
1022                        elIn = elIn.reverse();
1023                    } else {
1024                        elOut = elOut.reverse();
1025                    }
1026
1027                    self._trigger(key + 'in', $(elIn));
1028                    self._trigger(key + 'out', $(elOut));
1029
1030                    self['_' + key] = update[key];
1031                };
1032
1033            for (key in update) {
1034                doUpdate(key);
1035            }
1036
1037            return this;
1038        }
1039    });
1040}(jQuery, window));
1041
1042(function($) {
1043    'use strict';
1044
1045    $.jcarousel.fn.scrollIntoView = function(target, animate, callback) {
1046        var parsed = $.jCarousel.parseTarget(target),
1047            first  = this.index(this._fullyvisible.first()),
1048            last   = this.index(this._fullyvisible.last()),
1049            index;
1050
1051        if (parsed.relative) {
1052            index = parsed.target < 0 ? Math.max(0, first + parsed.target) : last + parsed.target;
1053        } else {
1054            index = typeof parsed.target !== 'object' ? parsed.target : this.index(parsed.target);
1055        }
1056
1057        if (index < first) {
1058            return this.scroll(index, animate, callback);
1059        }
1060
1061        if (index >= first && index <= last) {
1062            if ($.isFunction(callback)) {
1063                callback.call(this, false);
1064            }
1065
1066            return this;
1067        }
1068
1069        var items = this.items(),
1070            clip = this.clipping(),
1071            lrb  = this.vertical ? 'bottom' : (this.rtl ? 'left'  : 'right'),
1072            wh   = 0,
1073            curr;
1074
1075        while (true) {
1076            curr = items.eq(index);
1077
1078            if (curr.length === 0) {
1079                break;
1080            }
1081
1082            wh += this.dimension(curr);
1083
1084            if (wh >= clip) {
1085                var margin = parseFloat(curr.css('margin-' + lrb)) || 0;
1086                if ((wh - margin) !== clip) {
1087                    index++;
1088                }
1089                break;
1090            }
1091
1092            if (index <= 0) {
1093                break;
1094            }
1095
1096            index--;
1097        }
1098
1099        return this.scroll(index, animate, callback);
1100    };
1101}(jQuery));
1102
1103(function($) {
1104    'use strict';
1105
1106    $.jCarousel.plugin('jcarouselControl', {
1107        _options: {
1108            target: '+=1',
1109            event:  'click',
1110            method: 'scroll'
1111        },
1112        _active: null,
1113        _init: function() {
1114            this.onDestroy = $.proxy(function() {
1115                this._destroy();
1116                this.carousel()
1117                    .one('jcarousel:createend', $.proxy(this._create, this));
1118            }, this);
1119            this.onReload = $.proxy(this._reload, this);
1120            this.onEvent = $.proxy(function(e) {
1121                e.preventDefault();
1122
1123                var method = this.options('method');
1124
1125                if ($.isFunction(method)) {
1126                    method.call(this);
1127                } else {
1128                    this.carousel()
1129                        .jcarousel(this.options('method'), this.options('target'));
1130                }
1131            }, this);
1132        },
1133        _create: function() {
1134            this.carousel()
1135                .one('jcarousel:destroy', this.onDestroy)
1136                .on('jcarousel:reloadend jcarousel:scrollend', this.onReload);
1137
1138            this._element
1139                .on(this.options('event') + '.jcarouselcontrol', this.onEvent);
1140
1141            this._reload();
1142        },
1143        _destroy: function() {
1144            this._element
1145                .off('.jcarouselcontrol', this.onEvent);
1146
1147            this.carousel()
1148                .off('jcarousel:destroy', this.onDestroy)
1149                .off('jcarousel:reloadend jcarousel:scrollend', this.onReload);
1150        },
1151        _reload: function() {
1152            var parsed   = $.jCarousel.parseTarget(this.options('target')),
1153                carousel = this.carousel(),
1154                active;
1155
1156            if (parsed.relative) {
1157                active = carousel
1158                    .jcarousel(parsed.target > 0 ? 'hasNext' : 'hasPrev');
1159            } else {
1160                var target = typeof parsed.target !== 'object' ?
1161                                carousel.jcarousel('items').eq(parsed.target) :
1162                                parsed.target;
1163
1164                active = carousel.jcarousel('target').index(target) >= 0;
1165            }
1166
1167            if (this._active !== active) {
1168                this._trigger(active ? 'active' : 'inactive');
1169                this._active = active;
1170            }
1171
1172            return this;
1173        }
1174    });
1175}(jQuery));
1176
1177(function($) {
1178    'use strict';
1179
1180    $.jCarousel.plugin('jcarouselPagination', {
1181        _options: {
1182            perPage: null,
1183            item: function(page) {
1184                return '<a href="#' + page + '">' + page + '</a>';
1185            },
1186            event:  'click',
1187            method: 'scroll'
1188        },
1189        _carouselItems: null,
1190        _pages: {},
1191        _items: {},
1192        _currentPage: null,
1193        _init: function() {
1194            this.onDestroy = $.proxy(function() {
1195                this._destroy();
1196                this.carousel()
1197                    .one('jcarousel:createend', $.proxy(this._create, this));
1198            }, this);
1199            this.onReload = $.proxy(this._reload, this);
1200            this.onScroll = $.proxy(this._update, this);
1201        },
1202        _create: function() {
1203            this.carousel()
1204                .one('jcarousel:destroy', this.onDestroy)
1205                .on('jcarousel:reloadend', this.onReload)
1206                .on('jcarousel:scrollend', this.onScroll);
1207
1208            this._reload();
1209        },
1210        _destroy: function() {
1211            this._clear();
1212
1213            this.carousel()
1214                .off('jcarousel:destroy', this.onDestroy)
1215                .off('jcarousel:reloadend', this.onReload)
1216                .off('jcarousel:scrollend', this.onScroll);
1217
1218            this._carouselItems = null;
1219        },
1220        _reload: function() {
1221            var perPage = this.options('perPage');
1222
1223            this._pages = {};
1224            this._items = {};
1225
1226            // Calculate pages
1227            if ($.isFunction(perPage)) {
1228                perPage = perPage.call(this);
1229            }
1230
1231            if (perPage == null) {
1232                this._pages = this._calculatePages();
1233            } else {
1234                var pp    = parseInt(perPage, 10) || 0,
1235                    items = this._getCarouselItems(),
1236                    page  = 1,
1237                    i     = 0,
1238                    curr;
1239
1240                while (true) {
1241                    curr = items.eq(i++);
1242
1243                    if (curr.length === 0) {
1244                        break;
1245                    }
1246
1247                    if (!this._pages[page]) {
1248                        this._pages[page] = curr;
1249                    } else {
1250                        this._pages[page] = this._pages[page].add(curr);
1251                    }
1252
1253                    if (i % pp === 0) {
1254                        page++;
1255                    }
1256                }
1257            }
1258
1259            this._clear();
1260
1261            var self     = this,
1262                carousel = this.carousel().data('jcarousel'),
1263                element  = this._element,
1264                item     = this.options('item'),
1265                numCarouselItems = this._getCarouselItems().length;
1266
1267            $.each(this._pages, function(page, carouselItems) {
1268                var currItem = self._items[page] = $(item.call(self, page, carouselItems));
1269
1270                currItem.on(self.options('event') + '.jcarouselpagination', $.proxy(function() {
1271                    var target = carouselItems.eq(0);
1272
1273                    // If circular wrapping enabled, ensure correct scrolling direction
1274                    if (carousel.circular) {
1275                        var currentIndex = carousel.index(carousel.target()),
1276                            newIndex     = carousel.index(target);
1277
1278                        if (parseFloat(page) > parseFloat(self._currentPage)) {
1279                            if (newIndex < currentIndex) {
1280                                target = '+=' + (numCarouselItems - currentIndex + newIndex);
1281                            }
1282                        } else {
1283                            if (newIndex > currentIndex) {
1284                                target = '-=' + (currentIndex + (numCarouselItems - newIndex));
1285                            }
1286                        }
1287                    }
1288
1289                    carousel[this.options('method')](target);
1290                }, self));
1291
1292                element.append(currItem);
1293            });
1294
1295            this._update();
1296        },
1297        _update: function() {
1298            var target = this.carousel().jcarousel('target'),
1299                currentPage;
1300
1301            $.each(this._pages, function(page, carouselItems) {
1302                carouselItems.each(function() {
1303                    if (target.is(this)) {
1304                        currentPage = page;
1305                        return false;
1306                    }
1307                });
1308
1309                if (currentPage) {
1310                    return false;
1311                }
1312            });
1313
1314            if (this._currentPage !== currentPage) {
1315                this._trigger('inactive', this._items[this._currentPage]);
1316                this._trigger('active', this._items[currentPage]);
1317            }
1318
1319            this._currentPage = currentPage;
1320        },
1321        items: function() {
1322            return this._items;
1323        },
1324        reloadCarouselItems: function() {
1325            this._carouselItems = null;
1326            return this;
1327        },
1328        _clear: function() {
1329            this._element.empty();
1330            this._currentPage = null;
1331        },
1332        _calculatePages: function() {
1333            var carousel = this.carousel().data('jcarousel'),
1334                items    = this._getCarouselItems(),
1335                clip     = carousel.clipping(),
1336                wh       = 0,
1337                idx      = 0,
1338                page     = 1,
1339                pages    = {},
1340                curr,
1341                dim;
1342
1343            while (true) {
1344                curr = items.eq(idx++);
1345
1346                if (curr.length === 0) {
1347                    break;
1348                }
1349
1350                dim = carousel.dimension(curr);
1351
1352                if ((wh + dim) > clip) {
1353                    page++;
1354                    wh = 0;
1355                }
1356
1357                wh += dim;
1358
1359                if (!pages[page]) {
1360                    pages[page] = curr;
1361                } else {
1362                    pages[page] = pages[page].add(curr);
1363                }
1364            }
1365
1366            return pages;
1367        },
1368        _getCarouselItems: function() {
1369            if (!this._carouselItems) {
1370                this._carouselItems = this.carousel().jcarousel('items');
1371            }
1372
1373            return this._carouselItems;
1374        }
1375    });
1376}(jQuery));
1377
1378(function($, document) {
1379    'use strict';
1380
1381    var hiddenProp,
1382        visibilityChangeEvent,
1383        visibilityChangeEventNames = {
1384            hidden: 'visibilitychange',
1385            mozHidden: 'mozvisibilitychange',
1386            msHidden: 'msvisibilitychange',
1387            webkitHidden: 'webkitvisibilitychange'
1388        }
1389    ;
1390
1391    $.each(visibilityChangeEventNames, function(key, val) {
1392        if (typeof document[key] !== 'undefined') {
1393            hiddenProp = key;
1394            visibilityChangeEvent = val;
1395            return false;
1396        }
1397    });
1398
1399    $.jCarousel.plugin('jcarouselAutoscroll', {
1400        _options: {
1401            target:    '+=1',
1402            interval:  3000,
1403            autostart: true,
1404            method: 'scroll'
1405        },
1406        _timer: null,
1407        _started: false,
1408        _init: function () {
1409            this.onDestroy = $.proxy(function() {
1410                this._destroy();
1411                this.carousel()
1412                    .one('jcarousel:createend', $.proxy(this._create, this));
1413            }, this);
1414
1415            this.onAnimateEnd = $.proxy(this._start, this);
1416
1417            this.onVisibilityChange = $.proxy(function() {
1418                if (document[hiddenProp]) {
1419                    this._stop();
1420                } else {
1421                    this._start();
1422                }
1423            }, this);
1424        },
1425        _create: function() {
1426            this.carousel()
1427                .one('jcarousel:destroy', this.onDestroy);
1428
1429            $(document)
1430                .on(visibilityChangeEvent, this.onVisibilityChange);
1431
1432            if (this.options('autostart')) {
1433                this.start();
1434            }
1435        },
1436        _destroy: function() {
1437            this._stop();
1438
1439            this.carousel()
1440                .off('jcarousel:destroy', this.onDestroy);
1441
1442            $(document)
1443                .off(visibilityChangeEvent, this.onVisibilityChange);
1444        },
1445        _start: function() {
1446            this._stop();
1447
1448            if (!this._started) {
1449                return;
1450            }
1451
1452            this.carousel()
1453                .one('jcarousel:animateend', this.onAnimateEnd);
1454
1455            this._timer = setTimeout($.proxy(function() {
1456                this.carousel().jcarousel(this.options('method'), this.options('target'));
1457            }, this), this.options('interval'));
1458
1459            return this;
1460        },
1461        _stop: function() {
1462            if (this._timer) {
1463                this._timer = clearTimeout(this._timer);
1464            }
1465
1466            this.carousel()
1467                .off('jcarousel:animateend', this.onAnimateEnd);
1468
1469            return this;
1470        },
1471        start: function() {
1472            this._started = true;
1473            this._start();
1474
1475            return this;
1476        },
1477        stop: function() {
1478            this._started = false;
1479            this._stop();
1480
1481            return this;
1482        }
1483    });
1484}(jQuery, document));

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.