PageSourceSearch

https://tovari-golubei.ru/js/jquery.jcarousel.js

js tovari-golubei.ru collected 2026-10-08 01:03:57 UTC 44,689 bytes, 1,419 lines download raw bytes

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