PageSourceSearch

https://www.starrett.co.uk/wp-content/plugins/tp-woocommerce-product-gallery/public/js/tpslick.js?ver=2.2.3

js starrett.co.uk collected 2026-10-04 23:17:44 UTC 89,875 bytes, 3,013 lines download raw bytes

1/*
2     _ _      _       _
3 ___| (_) ___| | __  (_)___
4/ __| | |/ __| |/ /  | / __|
5\__ \ | | (__|   < _ | \__ \
6|___/_|_|\___|_|\_(_)/ |___/
7                   |__/
8
9 Version: 1.8.0
10  Author: Ken Wheeler
11 Website: http://kenwheeler.github.io
12    Docs: http://kenwheeler.github.io/tpslick
13    Repo: http://github.com/kenwheeler/tpslick
14  Issues: http://github.com/kenwheeler/tpslick/issues
15
16 */
17/* global window, document, define, jQuery, setInterval, clearInterval */
18;(function(factory) {
19    'use strict';
20    if (typeof define === 'function' && define.amd) {
21        define(['jquery'], factory);
22    } else if (typeof exports !== 'undefined') {
23        module.exports = factory(require('jquery'));
24    } else {
25        factory(jQuery);
26    }
27
28}(function($) {
29    'use strict';
30    var TPSlick = window.TPSlick || {};
31
32    TPSlick = (function() {
33
34        var instanceUid = 0;
35
36        function TPSlick(element, settings) {
37
38            var _ = this, dataSettings;
39
40            _.defaults = {
41                accessibility: true,
42                adaptiveHeight: false,
43                appendArrows: $(element),
44                appendDots: $(element),
45                arrows: true,
46                asNavFor: null,
47                //prevArrow: '<button class="tpslick-prev" aria-label="Previous" type="button">Previous</button>',
48                //nextArrow: '<button class="tpslick-next" aria-label="Next" type="button">Next</button>',
49                prevArrow: '<button class="tpslick-prev" aria-label="Previous" type="button"><span class="t"></span><span class="p"></span></button>',
50                nextArrow: '<button class="tpslick-next" aria-label="Next" type="button"><span class="t"></span><span class="p"></span></button>',
51                autoplay: false,
52                autoplaySpeed: 3000,
53                centerMode: false,
54                centerPadding: '50px',
55                cssEase: 'ease',
56                customPaging: function(slider, i) {
57                    return $('<button type="button" />').text(i + 1);
58                },
59                dots: false,
60                dotsClass: 'tpslick-dots',
61                draggable: true,
62                easing: 'linear',
63                edgeFriction: 0.35,
64                fade: false,
65                focusOnSelect: false,
66                focusOnChange: false,
67                infinite: true,
68                initialSlide: 0,
69                lazyLoad: 'ondemand',
70                mobileFirst: false,
71                pauseOnHover: true,
72                pauseOnFocus: true,
73                pauseOnDotsHover: false,
74                respondTo: 'window',
75                responsive: null,
76                rows: 1,
77                rtl: false,
78                slide: '',
79                slidesPerRow: 1,
80                slidesToShow: 1,
81                slidesToScroll: 1,
82                speed: 500,
83                swipe: true,
84                swipeToSlide: false,
85                touchMove: true,
86                touchThreshold: 5,
87                useCSS: true,
88                useTransform: true,
89                variableWidth: false,
90                vertical: false,
91                verticalSwiping: false,
92                waitForAnimate: true,
93                zIndex: 1000
94            };
95
96            _.initials = {
97                animating: false,
98                dragging: false,
99                autoPlayTimer: null,
100                currentDirection: 0,
101                currentLeft: null,
102                currentSlide: 0,
103                direction: 1,
104                $dots: null,
105                listWidth: null,
106                listHeight: null,
107                loadIndex: 0,
108                $nextArrow: null,
109                $prevArrow: null,
110                scrolling: false,
111                slideCount: null,
112                slideWidth: null,
113                $slideTrack: null,
114                $slides: null,
115                sliding: false,
116                slideOffset: 0,
117                swipeLeft: null,
118                swiping: false,
119                $list: null,
120                touchObject: {},
121                transformsEnabled: false,
vendor: 29,410 bytes, lines 122-1100
122                untpslicked: false
123            };
124
125            $.extend(_, _.initials);
126
127            _.activeBreakpoint = null;
128            _.animType = null;
129            _.animProp = null;
130            _.breakpoints = [];
131            _.breakpointSettings = [];
132            _.cssTransitions = false;
133            _.focussed = false;
134            _.interrupted = false;
135            _.hidden = 'hidden';
136            _.paused = true;
137            _.positionProp = null;
138            _.respondTo = null;
139            _.rowCount = 1;
140            _.shouldClick = true;
141            _.$slider = $(element);
142            _.$slidesCache = null;
143            _.transformType = null;
144            _.transitionType = null;
145            _.visibilityChange = 'visibilitychange';
146            _.windowWidth = 0;
147            _.windowTimer = null;
148
149            dataSettings = $(element).data('tpslick') || {};
150
151            _.options = $.extend({}, _.defaults, settings, dataSettings);
152
153            _.currentSlide = _.options.initialSlide;
154
155            _.originalSettings = _.options;
156
157            if (typeof document.mozHidden !== 'undefined') {
158                _.hidden = 'mozHidden';
159                _.visibilityChange = 'mozvisibilitychange';
160            } else if (typeof document.webkitHidden !== 'undefined') {
161                _.hidden = 'webkitHidden';
162                _.visibilityChange = 'webkitvisibilitychange';
163            }
164
165            _.autoPlay = $.proxy(_.autoPlay, _);
166            _.autoPlayClear = $.proxy(_.autoPlayClear, _);
167            _.autoPlayIterator = $.proxy(_.autoPlayIterator, _);
168            _.changeSlide = $.proxy(_.changeSlide, _);
169            _.clickHandler = $.proxy(_.clickHandler, _);
170            _.selectHandler = $.proxy(_.selectHandler, _);
171            _.setPosition = $.proxy(_.setPosition, _);
172            _.swipeHandler = $.proxy(_.swipeHandler, _);
173            _.dragHandler = $.proxy(_.dragHandler, _);
174            _.keyHandler = $.proxy(_.keyHandler, _);
175
176            _.instanceUid = instanceUid++;
177
178            // A simple way to check for HTML strings
179            // Strict HTML recognition (must start with <)
180            // Extracted from jQuery v1.11 source
181            _.htmlExpr = /^(?:\s*(<[\w\W]+>)[^>]*)$/;
182
183
184            _.registerBreakpoints();
185            _.init(true);
186
187        }
188
189        return TPSlick;
190
191    }());
192
193    TPSlick.prototype.activateADA = function() {
194        var _ = this;
195
196        _.$slideTrack.find('.tpslick-active').attr({
197            'aria-hidden': 'false'
198        }).find('a, input, button, select').attr({
199            'tabindex': '0'
200        });
201
202    };
203
204    TPSlick.prototype.addSlide = TPSlick.prototype.tpslickAdd = function(markup, index, addBefore) {
205
206        var _ = this;
207
208        if (typeof(index) === 'boolean') {
209            addBefore = index;
210            index = null;
211        } else if (index < 0 || (index >= _.slideCount)) {
212            return false;
213        }
214
215        _.unload();
216
217        if (typeof(index) === 'number') {
218            if (index === 0 && _.$slides.length === 0) {
219                $(markup).appendTo(_.$slideTrack);
220            } else if (addBefore) {
221                $(markup).insertBefore(_.$slides.eq(index));
222            } else {
223                $(markup).insertAfter(_.$slides.eq(index));
224            }
225        } else {
226            if (addBefore === true) {
227                $(markup).prependTo(_.$slideTrack);
228            } else {
229                $(markup).appendTo(_.$slideTrack);
230            }
231        }
232
233        _.$slides = _.$slideTrack.children(this.options.slide);
234
235        _.$slideTrack.children(this.options.slide).detach();
236
237        _.$slideTrack.append(_.$slides);
238
239        _.$slides.each(function(index, element) {
240            $(element).attr('data-tpslick-index', index);
241        });
242
243        _.$slidesCache = _.$slides;
244
245        _.reinit();
246
247    };
248
249    TPSlick.prototype.animateHeight = function() {
250        var _ = this;
251        if (_.options.slidesToShow === 1 && _.options.adaptiveHeight === true && _.options.vertical === false) {
252            var targetHeight = _.$slides.eq(_.currentSlide).outerHeight(true);
253            _.$list.animate({
254                height: targetHeight
255            }, _.options.speed);
256        }
257    };
258
259    TPSlick.prototype.animateSlide = function(targetLeft, callback) {
260
261        var animProps = {},
262            _ = this;
263
264        _.animateHeight();
265
266        if (_.options.rtl === true && _.options.vertical === false) {
267            targetLeft = -targetLeft;
268        }
269        if (_.transformsEnabled === false) {
270            if (_.options.vertical === false) {
271                _.$slideTrack.animate({
272                    left: targetLeft
273                }, _.options.speed, _.options.easing, callback);
274            } else {
275                _.$slideTrack.animate({
276                    top: targetLeft
277                }, _.options.speed, _.options.easing, callback);
278            }
279
280        } else {
281
282            if (_.cssTransitions === false) {
283                if (_.options.rtl === true) {
284                    _.currentLeft = -(_.currentLeft);
285                }
286                $({
287                    animStart: _.currentLeft
288                }).animate({
289                    animStart: targetLeft
290                }, {
291                    duration: _.options.speed,
292                    easing: _.options.easing,
293                    step: function(now) {
294                        now = Math.ceil(now);
295                        if (_.options.vertical === false) {
296                            animProps[_.animType] = 'translate(' +
297                                now + 'px, 0px)';
298                            _.$slideTrack.css(animProps);
299                        } else {
300                            animProps[_.animType] = 'translate(0px,' +
301                                now + 'px)';
302                            _.$slideTrack.css(animProps);
303                        }
304                    },
305                    complete: function() {
306                        if (callback) {
307                            callback.call();
308                        }
309                    }
310                });
311
312            } else {
313
314                _.applyTransition();
315                targetLeft = Math.ceil(targetLeft);
316
317                if (_.options.vertical === false) {
318                    animProps[_.animType] = 'translate3d(' + targetLeft + 'px, 0px, 0px)';
319                } else {
320                    animProps[_.animType] = 'translate3d(0px,' + targetLeft + 'px, 0px)';
321                }
322                _.$slideTrack.css(animProps);
323
324                if (callback) {
325                    setTimeout(function() {
326
327                        _.disableTransition();
328
329                        callback.call();
330                    }, _.options.speed);
331                }
332
333            }
334
335        }
336
337    };
338
339    TPSlick.prototype.getNavTarget = function() {
340
341        var _ = this,
342            asNavFor = _.options.asNavFor;
343
344        if ( asNavFor && asNavFor !== null ) {
345            asNavFor = $(asNavFor).not(_.$slider);
346        }
347
348        return asNavFor;
349
350    };
351
352    TPSlick.prototype.asNavFor = function(index) {
353
354        var _ = this,
355            asNavFor = _.getNavTarget();
356
357        if ( asNavFor !== null && typeof asNavFor === 'object' ) {
358            asNavFor.each(function() {
359                var target = $(this).tpslick('getTPSlick');
360                if(!target.untpslicked) {
361                    target.slideHandler(index, true);
362                }
363            });
364        }
365
366    };
367
368    TPSlick.prototype.applyTransition = function(slide) {
369
370        var _ = this,
371            transition = {};
372
373        if (_.options.fade === false) {
374            transition[_.transitionType] = _.transformType + ' ' + _.options.speed + 'ms ' + _.options.cssEase;
375        } else {
376            transition[_.transitionType] = 'opacity ' + _.options.speed + 'ms ' + _.options.cssEase;
377        }
378
379        if (_.options.fade === false) {
380            _.$slideTrack.css(transition);
381        } else {
382            _.$slides.eq(slide).css(transition);
383        }
384
385    };
386
387    TPSlick.prototype.autoPlay = function() {
388
389        var _ = this;
390
391        _.autoPlayClear();
392
393        if ( _.slideCount > _.options.slidesToShow ) {
394            _.autoPlayTimer = setInterval( _.autoPlayIterator, _.options.autoplaySpeed );
395        }
396
397    };
398
399    TPSlick.prototype.autoPlayClear = function() {
400
401        var _ = this;
402
403        if (_.autoPlayTimer) {
404            clearInterval(_.autoPlayTimer);
405        }
406
407    };
408
409    TPSlick.prototype.autoPlayIterator = function() {
410
411        var _ = this,
412            slideTo = _.currentSlide + _.options.slidesToScroll;
413
414        if ( !_.paused && !_.interrupted && !_.focussed ) {
415
416            if ( _.options.infinite === false ) {
417
418                if ( _.direction === 1 && ( _.currentSlide + 1 ) === ( _.slideCount - 1 )) {
419                    _.direction = 0;
420                }
421
422                else if ( _.direction === 0 ) {
423
424                    slideTo = _.currentSlide - _.options.slidesToScroll;
425
426                    if ( _.currentSlide - 1 === 0 ) {
427                        _.direction = 1;
428                    }
429
430                }
431
432            }
433
434            _.slideHandler( slideTo );
435
436        }
437
438    };
439
440    TPSlick.prototype.buildArrows = function() {
441
442        var _ = this;
443
444        if (_.options.arrows === true ) {
445
446            _.$prevArrow = $(_.options.prevArrow).addClass('tpslick-arrow');
447            _.$nextArrow = $(_.options.nextArrow).addClass('tpslick-arrow');
448
449            if( _.slideCount > _.options.slidesToShow ) {
450
451                _.$prevArrow.removeClass('tpslick-hidden').removeAttr('aria-hidden tabindex');
452                _.$nextArrow.removeClass('tpslick-hidden').removeAttr('aria-hidden tabindex');
453
454                if (_.htmlExpr.test(_.options.prevArrow)) {
455                    _.$prevArrow.prependTo(_.options.appendArrows);
456                }
457
458                if (_.htmlExpr.test(_.options.nextArrow)) {
459                    _.$nextArrow.appendTo(_.options.appendArrows);
460                }
461
462                if (_.options.infinite !== true) {
463                    _.$prevArrow
464                        .addClass('tpslick-disabled')
465                        .attr('aria-disabled', 'true');
466                }
467
468            } else {
469
470                _.$prevArrow.add( _.$nextArrow )
471
472                    .addClass('tpslick-hidden')
473                    .attr({
474                        'aria-disabled': 'true',
475                        'tabindex': '-1'
476                    });
477
478            }
479
480        }
481
482    };
483
484    TPSlick.prototype.buildDots = function() {
485
486        var _ = this,
487            i, dot;
488
489        if (_.options.dots === true && _.slideCount > _.options.slidesToShow) {
490
491            _.$slider.addClass('tpslick-dotted');
492
493            dot = $('<ul />').addClass(_.options.dotsClass);
494
495            for (i = 0; i <= _.getDotCount(); i += 1) {
496                dot.append($('<li />').append(_.options.customPaging.call(this, _, i)));
497            }
498
499            _.$dots = dot.appendTo(_.options.appendDots);
500
501            _.$dots.find('li').first().addClass('tpslick-active');
502
503        }
504
505    };
506
507    TPSlick.prototype.buildOut = function() {
508
509        var _ = this;
510
511        _.$slides =
512            _.$slider
513                .children( _.options.slide + ':not(.tpslick-cloned)')
514                .addClass('tpslick-slide');
515
516        _.slideCount = _.$slides.length;
517
518        _.$slides.each(function(index, element) {
519            $(element)
520                .attr('data-tpslick-index', index)
521                .data('originalStyling', $(element).attr('style') || '');
522        });
523
524        _.$slider.addClass('tpslick-slider');
525
526        _.$slideTrack = (_.slideCount === 0) ?
527            $('<div class="tpslick-track"/>').appendTo(_.$slider) :
528            _.$slides.wrapAll('<div class="tpslick-track"/>').parent();
529
530        _.$list = _.$slideTrack.wrap(
531            '<div class="tpslick-list"/>').parent();
532        _.$slideTrack.css('opacity', 0);
533
534        if (_.options.centerMode === true || _.options.swipeToSlide === true) {
535            _.options.slidesToScroll = 1;
536        }
537
538        $('img[data-lazy]', _.$slider).not('[src]').addClass('tpslick-loading');
539
540        _.setupInfinite();
541
542        _.buildArrows();
543
544        _.buildDots();
545
546        _.updateDots();
547
548
549        _.setSlideClasses(typeof _.currentSlide === 'number' ? _.currentSlide : 0);
550
551        if (_.options.draggable === true) {
552            _.$list.addClass('draggable');
553        }
554
555    };
556
557    TPSlick.prototype.buildRows = function() {
558
559        var _ = this, a, b, c, newSlides, numOfSlides, originalSlides,slidesPerSection;
560
561        newSlides = document.createDocumentFragment();
562        originalSlides = _.$slider.children();
563
564        if(_.options.rows > 0) {
565
566            slidesPerSection = _.options.slidesPerRow * _.options.rows;
567            numOfSlides = Math.ceil(
568                originalSlides.length / slidesPerSection
569            );
570
571            for(a = 0; a < numOfSlides; a++){
572                var slide = document.createElement('div');
573                for(b = 0; b < _.options.rows; b++) {
574                    var row = document.createElement('div');
575                    for(c = 0; c < _.options.slidesPerRow; c++) {
576                        var target = (a * slidesPerSection + ((b * _.options.slidesPerRow) + c));
577                        if (originalSlides.get(target)) {
578                            row.appendChild(originalSlides.get(target));
579                        }
580                    }
581                    slide.appendChild(row);
582                }
583                newSlides.appendChild(slide);
584            }
585
586            _.$slider.empty().append(newSlides);
587            _.$slider.children().children().children()
588                .css({
589                    'width':(100 / _.options.slidesPerRow) + '%',
590                    'display': 'inline-block'
591                });
592
593        }
594
595    };
596
597    TPSlick.prototype.checkResponsive = function(initial, forceUpdate) {
598
599        var _ = this,
600            breakpoint, targetBreakpoint, respondToWidth, triggerBreakpoint = false;
601        var sliderWidth = _.$slider.width();
602        var windowWidth = window.innerWidth || $(window).width();
603
604        if (_.respondTo === 'window') {
605            respondToWidth = windowWidth;
606        } else if (_.respondTo === 'slider') {
607            respondToWidth = sliderWidth;
608        } else if (_.respondTo === 'min') {
609            respondToWidth = Math.min(windowWidth, sliderWidth);
610        }
611
612        if ( _.options.responsive &&
613            _.options.responsive.length &&
614            _.options.responsive !== null) {
615
616            targetBreakpoint = null;
617
618            for (breakpoint in _.breakpoints) {
619                if (_.breakpoints.hasOwnProperty(breakpoint)) {
620                    if (_.originalSettings.mobileFirst === false) {
621                        if (respondToWidth < _.breakpoints[breakpoint]) {
622                            targetBreakpoint = _.breakpoints[breakpoint];
623                        }
624                    } else {
625                        if (respondToWidth > _.breakpoints[breakpoint]) {
626                            targetBreakpoint = _.breakpoints[breakpoint];
627                        }
628                    }
629                }
630            }
631
632            if (targetBreakpoint !== null) {
633                if (_.activeBreakpoint !== null) {
634                    if (targetBreakpoint !== _.activeBreakpoint || forceUpdate) {
635                        _.activeBreakpoint =
636                            targetBreakpoint;
637                        if (_.breakpointSettings[targetBreakpoint] === 'untpslick') {
638                            _.untpslick(targetBreakpoint);
639                        } else {
640                            _.options = $.extend({}, _.originalSettings,
641                                _.breakpointSettings[
642                                    targetBreakpoint]);
643                            if (initial === true) {
644                                _.currentSlide = _.options.initialSlide;
645                            }
646                            _.refresh(initial);
647                        }
648                        triggerBreakpoint = targetBreakpoint;
649                    }
650                } else {
651                    _.activeBreakpoint = targetBreakpoint;
652                    if (_.breakpointSettings[targetBreakpoint] === 'untpslick') {
653                        _.untpslick(targetBreakpoint);
654                    } else {
655                        _.options = $.extend({}, _.originalSettings,
656                            _.breakpointSettings[
657                                targetBreakpoint]);
658                        if (initial === true) {
659                            _.currentSlide = _.options.initialSlide;
660                        }
661                        _.refresh(initial);
662                    }
663                    triggerBreakpoint = targetBreakpoint;
664                }
665            } else {
666                if (_.activeBreakpoint !== null) {
667                    _.activeBreakpoint = null;
668                    _.options = _.originalSettings;
669                    if (initial === true) {
670                        _.currentSlide = _.options.initialSlide;
671                    }
672                    _.refresh(initial);
673                    triggerBreakpoint = targetBreakpoint;
674                }
675            }
676
677            // only trigger breakpoints during an actual break. not on initialize.
678            if( !initial && triggerBreakpoint !== false ) {
679                _.$slider.trigger('breakpoint', [_, triggerBreakpoint]);
680            }
681        }
682
683    };
684
685    TPSlick.prototype.changeSlide = function(event, dontAnimate) {
686
687        var _ = this,
688            $target = $(event.currentTarget),
689            indexOffset, slideOffset, unevenOffset;
690
691        // If target is a link, prevent default action.
692        if($target.is('a')) {
693            event.preventDefault();
694        }
695
696        // If target is not the <li> element (ie: a child), find the <li>.
697        if(!$target.is('li')) {
698            $target = $target.closest('li');
699        }
700
701        unevenOffset = (_.slideCount % _.options.slidesToScroll !== 0);
702        indexOffset = unevenOffset ? 0 : (_.slideCount - _.currentSlide) % _.options.slidesToScroll;
703
704        switch (event.data.message) {
705
706            case 'previous':
707                slideOffset = indexOffset === 0 ? _.options.slidesToScroll : _.options.slidesToShow - indexOffset;
708                if (_.slideCount > _.options.slidesToShow) {
709                    _.slideHandler(_.currentSlide - slideOffset, false, dontAnimate);
710                }
711                break;
712
713            case 'next':
714                slideOffset = indexOffset === 0 ? _.options.slidesToScroll : indexOffset;
715                if (_.slideCount > _.options.slidesToShow) {
716                    _.slideHandler(_.currentSlide + slideOffset, false, dontAnimate);
717                }
718                break;
719
720            case 'index':
721                var index = event.data.index === 0 ? 0 :
722                    event.data.index || $target.index() * _.options.slidesToScroll;
723
724                _.slideHandler(_.checkNavigable(index), false, dontAnimate);
725                $target.children().trigger('focus');
726                break;
727
728            default:
729                return;
730        }
731
732    };
733
734    TPSlick.prototype.checkNavigable = function(index) {
735
736        var _ = this,
737            navigables, prevNavigable;
738
739        navigables = _.getNavigableIndexes();
740        prevNavigable = 0;
741        if (index > navigables[navigables.length - 1]) {
742            index = navigables[navigables.length - 1];
743        } else {
744            for (var n in navigables) {
745                if (index < navigables[n]) {
746                    index = prevNavigable;
747                    break;
748                }
749                prevNavigable = navigables[n];
750            }
751        }
752
753        return index;
754    };
755
756    TPSlick.prototype.cleanUpEvents = function() {
757
758        var _ = this;
759
760        if (_.options.dots && _.$dots !== null) {
761
762            $('li', _.$dots)
763                .off('click.tpslick', _.changeSlide)
764                .off('mouseenter.tpslick', $.proxy(_.interrupt, _, true))
765                .off('mouseleave.tpslick', $.proxy(_.interrupt, _, false));
766
767            if (_.options.accessibility === true) {
768                _.$dots.off('keydown.tpslick', _.keyHandler);
769            }
770        }
771
772        _.$slider.off('focus.tpslick blur.tpslick');
773
774        if (_.options.arrows === true && _.slideCount > _.options.slidesToShow) {
775            _.$prevArrow && _.$prevArrow.off('click.tpslick', _.changeSlide);
776            _.$nextArrow && _.$nextArrow.off('click.tpslick', _.changeSlide);
777
778            if (_.options.accessibility === true) {
779                _.$prevArrow && _.$prevArrow.off('keydown.tpslick', _.keyHandler);
780                _.$nextArrow && _.$nextArrow.off('keydown.tpslick', _.keyHandler);
781            }
782        }
783
784        _.$list.off('touchstart.tpslick mousedown.tpslick', _.swipeHandler);
785        _.$list.off('touchmove.tpslick mousemove.tpslick', _.swipeHandler);
786        _.$list.off('touchend.tpslick mouseup.tpslick', _.swipeHandler);
787        _.$list.off('touchcancel.tpslick mouseleave.tpslick', _.swipeHandler);
788
789        _.$list.off('click.tpslick', _.clickHandler);
790
791        $(document).off(_.visibilityChange, _.visibility);
792
793        _.cleanUpSlideEvents();
794
795        if (_.options.accessibility === true) {
796            _.$list.off('keydown.tpslick', _.keyHandler);
797        }
798
799        if (_.options.focusOnSelect === true) {
800            $(_.$slideTrack).children().off('click.tpslick', _.selectHandler);
801        }
802
803        $(window).off('orientationchange.tpslick.tpslick-' + _.instanceUid, _.orientationChange);
804
805        $(window).off('resize.tpslick.tpslick-' + _.instanceUid, _.resize);
806
807        $('[draggable!=true]', _.$slideTrack).off('dragstart', _.preventDefault);
808
809        $(window).off('load.tpslick.tpslick-' + _.instanceUid, _.setPosition);
810
811    };
812
813    TPSlick.prototype.cleanUpSlideEvents = function() {
814
815        var _ = this;
816
817        _.$list.off('mouseenter.tpslick', $.proxy(_.interrupt, _, true));
818        _.$list.off('mouseleave.tpslick', $.proxy(_.interrupt, _, false));
819
820    };
821
822    TPSlick.prototype.cleanUpRows = function() {
823
824        var _ = this, originalSlides;
825
826        if(_.options.rows > 0) {
827            originalSlides = _.$slides.children().children();
828            originalSlides.removeAttr('style');
829            _.$slider.empty().append(originalSlides);
830        }
831
832    };
833
834    TPSlick.prototype.clickHandler = function(event) {
835
836        var _ = this;
837
838        if (_.shouldClick === false) {
839            event.stopImmediatePropagation();
840            event.stopPropagation();
841            event.preventDefault();
842        }
843
844    };
845
846    TPSlick.prototype.destroy = function(refresh) {
847
848        var _ = this;
849
850        _.autoPlayClear();
851
852        _.touchObject = {};
853
854        _.cleanUpEvents();
855
856        $('.tpslick-cloned', _.$slider).detach();
857
858        if (_.$dots) {
859            _.$dots.remove();
860        }
861
862        if ( _.$prevArrow && _.$prevArrow.length ) {
863
864            _.$prevArrow
865                .removeClass('tpslick-disabled tpslick-arrow tpslick-hidden')
866                .removeAttr('aria-hidden aria-disabled tabindex')
867                .css('display','');
868
869            if ( _.htmlExpr.test( _.options.prevArrow )) {
870                _.$prevArrow.remove();
871            }
872        }
873
874        if ( _.$nextArrow && _.$nextArrow.length ) {
875
876            _.$nextArrow
877                .removeClass('tpslick-disabled tpslick-arrow tpslick-hidden')
878                .removeAttr('aria-hidden aria-disabled tabindex')
879                .css('display','');
880
881            if ( _.htmlExpr.test( _.options.nextArrow )) {
882                _.$nextArrow.remove();
883            }
884        }
885
886
887        if (_.$slides) {
888
889            _.$slides
890                .removeClass('tpslick-slide tpslick-active tpslick-center tpslick-visible tpslick-current')
891                .removeAttr('aria-hidden')
892                .removeAttr('data-tpslick-index')
893                .each(function(){
894                    $(this).attr('style', $(this).data('originalStyling'));
895                });
896
897            _.$slideTrack.children(this.options.slide).detach();
898
899            _.$slideTrack.detach();
900
901            _.$list.detach();
902
903            _.$slider.append(_.$slides);
904        }
905
906        _.cleanUpRows();
907
908        _.$slider.removeClass('tpslick-slider');
909        _.$slider.removeClass('tpslick-initialized');
910        _.$slider.removeClass('tpslick-dotted');
911
912        _.untpslicked = true;
913
914        if(!refresh) {
915            _.$slider.trigger('destroy', [_]);
916        }
917
918    };
919
920    TPSlick.prototype.disableTransition = function(slide) {
921
922        var _ = this,
923            transition = {};
924
925        transition[_.transitionType] = '';
926
927        if (_.options.fade === false) {
928            _.$slideTrack.css(transition);
929        } else {
930            _.$slides.eq(slide).css(transition);
931        }
932
933    };
934
935    TPSlick.prototype.fadeSlide = function(slideIndex, callback) {
936
937        var _ = this;
938
939        if (_.cssTransitions === false) {
940
941            _.$slides.eq(slideIndex).css({
942                zIndex: _.options.zIndex
943            });
944
945            _.$slides.eq(slideIndex).animate({
946                opacity: 1
947            }, _.options.speed, _.options.easing, callback);
948
949        } else {
950
951            _.applyTransition(slideIndex);
952
953            _.$slides.eq(slideIndex).css({
954                opacity: 1,
955                zIndex: _.options.zIndex
956            });
957
958            if (callback) {
959                setTimeout(function() {
960
961                    _.disableTransition(slideIndex);
962
963                    callback.call();
964                }, _.options.speed);
965            }
966
967        }
968
969    };
970
971    TPSlick.prototype.fadeSlideOut = function(slideIndex) {
972
973        var _ = this;
974
975        if (_.cssTransitions === false) {
976
977            _.$slides.eq(slideIndex).animate({
978                opacity: 0,
979                zIndex: _.options.zIndex - 2
980            }, _.options.speed, _.options.easing);
981
982        } else {
983
984            _.applyTransition(slideIndex);
985
986            _.$slides.eq(slideIndex).css({
987                opacity: 0,
988                zIndex: _.options.zIndex - 2
989            });
990
991        }
992
993    };
994
995    TPSlick.prototype.filterSlides = TPSlick.prototype.tpslickFilter = function(filter) {
996
997        var _ = this;
998
999        if (filter !== null) {
1000
1001            _.$slidesCache = _.$slides;
1002
1003            _.unload();
1004
1005            _.$slideTrack.children(this.options.slide).detach();
1006
1007            _.$slidesCache.filter(filter).appendTo(_.$slideTrack);
1008
1009            _.reinit();
1010
1011        }
1012
1013    };
1014
1015    TPSlick.prototype.focusHandler = function() {
1016
1017        var _ = this;
1018
1019        _.$slider
1020            .off('focus.tpslick blur.tpslick')
1021            .on('focus.tpslick blur.tpslick', '*', function(event) {
1022
1023            event.stopImmediatePropagation();
1024            var $sf = $(this);
1025
1026            setTimeout(function() {
1027
1028                if( _.options.pauseOnFocus ) {
1029                    _.focussed = $sf.is(':focus');
1030                    _.autoPlay();
1031                }
1032
1033            }, 0);
1034
1035        });
1036    };
1037
1038    TPSlick.prototype.getCurrent = TPSlick.prototype.tpslickCurrentSlide = function() {
1039
1040        var _ = this;
1041        return _.currentSlide;
1042
1043    };
1044
1045    TPSlick.prototype.getDotCount = function() {
1046
1047        var _ = this;
1048
1049        var breakPoint = 0;
1050        var counter = 0;
1051        var pagerQty = 0;
1052
1053        if (_.options.infinite === true) {
1054            if (_.slideCount <= _.options.slidesToShow) {
1055                 ++pagerQty;
1056            } else {
1057                while (breakPoint < _.slideCount) {
1058                    ++pagerQty;
1059                    breakPoint = counter + _.options.slidesToScroll;
1060                    counter += _.options.slidesToScroll <= _.options.slidesToShow ? _.options.slidesToScroll : _.options.slidesToShow;
1061                }
1062            }
1063        } else if (_.options.centerMode === true) {
1064            pagerQty = _.slideCount;
1065        } else if(!_.options.asNavFor) {
1066            pagerQty = 1 + Math.ceil((_.slideCount - _.options.slidesToShow) / _.options.slidesToScroll);
1067        }else {
1068            while (breakPoint < _.slideCount) {
1069                ++pagerQty;
1070                breakPoint = counter + _.options.slidesToScroll;
1071                counter += _.options.slidesToScroll <= _.options.slidesToShow ? _.options.slidesToScroll : _.options.slidesToShow;
1072            }
1073        }
1074
1075        return pagerQty - 1;
1076
1077    };
1078
1079    TPSlick.prototype.getLeft = function(slideIndex) {
1080
1081        var _ = this,
1082            targetLeft,
1083            verticalHeight,
1084            verticalOffset = 0,
1085            targetSlide,
1086            coef;
1087
1088        _.slideOffset = 0;
1089        verticalHeight = _.$slides.first().outerHeight(true);
1090
1091        if (_.options.infinite === true) {
1092            if (_.slideCount > _.options.slidesToShow) {
1093                _.slideOffset = (_.slideWidth * _.options.slidesToShow) * -1;
1094                coef = -1
1095
1096                if (_.options.vertical === true && _.options.centerMode === true) {
1097                    if (_.options.slidesToShow === 2) {
1098                        coef = -1.5;
1099                    } else if (_.options.slidesToShow === 1) {
1100                        coef = -2
vendor: 2,352 bytes, lines 1100-1146
1100
1101                    }
1102                }
1103                verticalOffset = (verticalHeight * _.options.slidesToShow) * coef;
1104            }
1105            if (_.slideCount % _.options.slidesToScroll !== 0) {
1106                if (slideIndex + _.options.slidesToScroll > _.slideCount && _.slideCount > _.options.slidesToShow) {
1107                    if (slideIndex > _.slideCount) {
1108                        _.slideOffset = ((_.options.slidesToShow - (slideIndex - _.slideCount)) * _.slideWidth) * -1;
1109                        verticalOffset = ((_.options.slidesToShow - (slideIndex - _.slideCount)) * verticalHeight) * -1;
1110                    } else {
1111                        _.slideOffset = ((_.slideCount % _.options.slidesToScroll) * _.slideWidth) * -1;
1112                        verticalOffset = ((_.slideCount % _.options.slidesToScroll) * verticalHeight) * -1;
1113                    }
1114                }
1115            }
1116        } else {
1117            if (slideIndex + _.options.slidesToShow > _.slideCount) {
1118                _.slideOffset = ((slideIndex + _.options.slidesToShow) - _.slideCount) * _.slideWidth;
1119                verticalOffset = ((slideIndex + _.options.slidesToShow) - _.slideCount) * verticalHeight;
1120            }
1121        }
1122
1123        if (_.slideCount <= _.options.slidesToShow) {
1124            _.slideOffset = 0;
1125            verticalOffset = 0;
1126        }
1127
1128        if (_.options.centerMode === true && _.slideCount <= _.options.slidesToShow) {
1129            _.slideOffset = ((_.slideWidth * Math.floor(_.options.slidesToShow)) / 2) - ((_.slideWidth * _.slideCount) / 2);
1130        } else if (_.options.centerMode === true && _.options.infinite === true) {
1131            _.slideOffset += _.slideWidth * Math.floor(_.options.slidesToShow / 2) - _.slideWidth;
1132        } else if (_.options.centerMode === true) {
1133            _.slideOffset = 0;
1134            _.slideOffset += _.slideWidth * Math.floor(_.options.slidesToShow / 2);
1135        }
1136
1137        if (_.options.vertical === false) {
1138            targetLeft = ((slideIndex * _.slideWidth) * -1) + _.slideOffset;
1139        } else {
1140            targetLeft = ((slideIndex * verticalHeight) * -1) + verticalOffset;
1141        }
1142
1143        if (_.options.variableWidth === true) {
1144
1145            if (_.slideCount <= _.options.slidesToShow || _.options.infinite === false) {
1146                targetSlide = _.$slideTrack.children('.
vendor: 53,992 bytes, lines 1146-3013
1146tpslick-slide').eq(slideIndex);
1147            } else {
1148                targetSlide = _.$slideTrack.children('.tpslick-slide').eq(slideIndex + _.options.slidesToShow);
1149            }
1150
1151            if (_.options.rtl === true) {
1152                if (targetSlide[0]) {
1153                    targetLeft = (_.$slideTrack.width() - targetSlide[0].offsetLeft - targetSlide.width()) * -1;
1154                } else {
1155                    targetLeft =  0;
1156                }
1157            } else {
1158                targetLeft = targetSlide[0] ? targetSlide[0].offsetLeft * -1 : 0;
1159            }
1160
1161            if (_.options.centerMode === true) {
1162                if (_.slideCount <= _.options.slidesToShow || _.options.infinite === false) {
1163                    targetSlide = _.$slideTrack.children('.tpslick-slide').eq(slideIndex);
1164                } else {
1165                    targetSlide = _.$slideTrack.children('.tpslick-slide').eq(slideIndex + _.options.slidesToShow + 1);
1166                }
1167
1168                if (_.options.rtl === true) {
1169                    if (targetSlide[0]) {
1170                        targetLeft = (_.$slideTrack.width() - targetSlide[0].offsetLeft - targetSlide.width()) * -1;
1171                    } else {
1172                        targetLeft =  0;
1173                    }
1174                } else {
1175                    targetLeft = targetSlide[0] ? targetSlide[0].offsetLeft * -1 : 0;
1176                }
1177
1178                targetLeft += (_.$list.width() - targetSlide.outerWidth()) / 2;
1179            }
1180        }
1181
1182        return targetLeft;
1183
1184    };
1185
1186    TPSlick.prototype.getOption = TPSlick.prototype.tpslickGetOption = function(option) {
1187
1188        var _ = this;
1189
1190        return _.options[option];
1191
1192    };
1193
1194    TPSlick.prototype.getNavigableIndexes = function() {
1195
1196        var _ = this,
1197            breakPoint = 0,
1198            counter = 0,
1199            indexes = [],
1200            max;
1201
1202        if (_.options.infinite === false) {
1203            max = _.slideCount;
1204        } else {
1205            breakPoint = _.options.slidesToScroll * -1;
1206            counter = _.options.slidesToScroll * -1;
1207            max = _.slideCount * 2;
1208        }
1209
1210        while (breakPoint < max) {
1211            indexes.push(breakPoint);
1212            breakPoint = counter + _.options.slidesToScroll;
1213            counter += _.options.slidesToScroll <= _.options.slidesToShow ? _.options.slidesToScroll : _.options.slidesToShow;
1214        }
1215
1216        return indexes;
1217
1218    };
1219
1220    TPSlick.prototype.getTPSlick = function() {
1221
1222        return this;
1223
1224    };
1225
1226    TPSlick.prototype.getSlideCount = function() {
1227
1228        var _ = this,
1229            slidesTraversed, swipedSlide, centerOffset;
1230
1231        centerOffset = _.options.centerMode === true ? _.slideWidth * Math.floor(_.options.slidesToShow / 2) : 0;
1232
1233        if (_.options.swipeToSlide === true) {
1234            _.$slideTrack.find('.tpslick-slide').each(function(index, slide) {
1235                if (slide.offsetLeft - centerOffset + ($(slide).outerWidth() / 2) > (_.swipeLeft * -1)) {
1236                    swipedSlide = slide;
1237                    return false;
1238                }
1239            });
1240
1241            slidesTraversed = Math.abs($(swipedSlide).attr('data-tpslick-index') - _.currentSlide) || 1;
1242
1243            return slidesTraversed;
1244
1245        } else {
1246            return _.options.slidesToScroll;
1247        }
1248
1249    };
1250
1251    TPSlick.prototype.goTo = TPSlick.prototype.tpslickGoTo = function(slide, dontAnimate) {
1252
1253        var _ = this;
1254
1255        _.changeSlide({
1256            data: {
1257                message: 'index',
1258                index: parseInt(slide)
1259            }
1260        }, dontAnimate);
1261
1262    };
1263
1264    TPSlick.prototype.init = function(creation) {
1265
1266        var _ = this;
1267
1268        if (!$(_.$slider).hasClass('tpslick-initialized')) {
1269
1270            $(_.$slider).addClass('tpslick-initialized');
1271
1272            _.buildRows();
1273            _.buildOut();
1274            _.setProps();
1275            _.startLoad();
1276            _.loadSlider();
1277            _.initializeEvents();
1278            _.updateArrows();
1279            _.updateDots();
1280            _.checkResponsive(true);
1281            _.focusHandler();
1282
1283        }
1284
1285        if (creation) {
1286            _.$slider.trigger('init', [_]);
1287        }
1288
1289        if (_.options.accessibility === true) {
1290            _.initADA();
1291        }
1292
1293        if ( _.options.autoplay ) {
1294
1295            _.paused = false;
1296            _.autoPlay();
1297
1298        }
1299
1300    };
1301
1302    TPSlick.prototype.initADA = function() {
1303        var _ = this,
1304                numDotGroups = Math.ceil(_.slideCount / _.options.slidesToShow),
1305                tabControlIndexes = _.getNavigableIndexes().filter(function(val) {
1306                    return (val >= 0) && (val < _.slideCount);
1307                });
1308
1309        _.$slides.add(_.$slideTrack.find('.tpslick-cloned')).attr({
1310            'aria-hidden': 'true',
1311            'tabindex': '-1'
1312        }).find('a, input, button, select').attr({
1313            'tabindex': '-1'
1314        });
1315
1316        if (_.$dots !== null) {
1317            _.$slides.not(_.$slideTrack.find('.tpslick-cloned')).each(function(i) {
1318                var slideControlIndex = tabControlIndexes.indexOf(i);
1319
1320                $(this).attr({
1321                    'role': 'tabpanel',
1322                    'id': 'tpslick-slide' + _.instanceUid + i,
1323                    'tabindex': -1
1324                });
1325
1326                if (slideControlIndex !== -1) {
1327                   var ariaButtonControl = 'tpslick-slide-control' + _.instanceUid + slideControlIndex
1328                   if ($('#' + ariaButtonControl).length) {
1329                     $(this).attr({
1330                         'aria-describedby': ariaButtonControl
1331                     });
1332                   }
1333                }
1334            });
1335
1336            _.$dots.attr('role', 'tablist').find('li').each(function(i) {
1337                var mappedSlideIndex = tabControlIndexes[i];
1338
1339                $(this).attr({
1340                    'role': 'presentation'
1341                });
1342
1343                $(this).find('button').first().attr({
1344                    'role': 'tab',
1345                    'id': 'tpslick-slide-control' + _.instanceUid + i,
1346                    'aria-controls': 'tpslick-slide' + _.instanceUid + mappedSlideIndex,
1347                    'aria-label': (i + 1) + ' of ' + numDotGroups,
1348                    'aria-selected': null,
1349                    'tabindex': '-1'
1350                });
1351
1352            }).eq(_.currentSlide).find('button').attr({
1353                'aria-selected': 'true',
1354                'tabindex': '0'
1355            }).end();
1356        }
1357
1358        for (var i=_.currentSlide, max=i+_.options.slidesToShow; i < max; i++) {
1359          if (_.options.focusOnChange) {
1360            _.$slides.eq(i).attr({'tabindex': '0'});
1361          } else {
1362            _.$slides.eq(i).removeAttr('tabindex');
1363          }
1364        }
1365
1366        _.activateADA();
1367
1368    };
1369
1370    TPSlick.prototype.initArrowEvents = function() {
1371
1372        var _ = this;
1373
1374        if (_.options.arrows === true && _.slideCount > _.options.slidesToShow) {
1375            _.$prevArrow
1376               .off('click.tpslick')
1377               .on('click.tpslick', {
1378                    message: 'previous'
1379               }, _.changeSlide);
1380            _.$nextArrow
1381               .off('click.tpslick')
1382               .on('click.tpslick', {
1383                    message: 'next'
1384               }, _.changeSlide);
1385
1386            if (_.options.accessibility === true) {
1387                _.$prevArrow.on('keydown.tpslick', _.keyHandler);
1388                _.$nextArrow.on('keydown.tpslick', _.keyHandler);
1389            }
1390        }
1391
1392    };
1393
1394    TPSlick.prototype.initDotEvents = function() {
1395
1396        var _ = this;
1397
1398        if (_.options.dots === true && _.slideCount > _.options.slidesToShow) {
1399            $('li', _.$dots).on('click.tpslick', {
1400                message: 'index'
1401            }, _.changeSlide);
1402
1403            if (_.options.accessibility === true) {
1404                _.$dots.on('keydown.tpslick', _.keyHandler);
1405            }
1406        }
1407
1408        if (_.options.dots === true && _.options.pauseOnDotsHover === true && _.slideCount > _.options.slidesToShow) {
1409
1410            $('li', _.$dots)
1411                .on('mouseenter.tpslick', $.proxy(_.interrupt, _, true))
1412                .on('mouseleave.tpslick', $.proxy(_.interrupt, _, false));
1413
1414        }
1415
1416    };
1417
1418    TPSlick.prototype.initSlideEvents = function() {
1419
1420        var _ = this;
1421
1422        if ( _.options.pauseOnHover ) {
1423
1424            _.$list.on('mouseenter.tpslick', $.proxy(_.interrupt, _, true));
1425            _.$list.on('mouseleave.tpslick', $.proxy(_.interrupt, _, false));
1426
1427        }
1428
1429    };
1430
1431    TPSlick.prototype.initializeEvents = function() {
1432
1433        var _ = this;
1434
1435        _.initArrowEvents();
1436
1437        _.initDotEvents();
1438        _.initSlideEvents();
1439
1440        _.$list.on('touchstart.tpslick mousedown.tpslick', {
1441            action: 'start'
1442        }, _.swipeHandler);
1443        _.$list.on('touchmove.tpslick mousemove.tpslick', {
1444            action: 'move'
1445        }, _.swipeHandler);
1446        _.$list.on('touchend.tpslick mouseup.tpslick', {
1447            action: 'end'
1448        }, _.swipeHandler);
1449        _.$list.on('touchcancel.tpslick mouseleave.tpslick', {
1450            action: 'end'
1451        }, _.swipeHandler);
1452
1453        _.$list.on('click.tpslick', _.clickHandler);
1454
1455        $(document).on(_.visibilityChange, $.proxy(_.visibility, _));
1456
1457        if (_.options.accessibility === true) {
1458            _.$list.on('keydown.tpslick', _.keyHandler);
1459        }
1460
1461        if (_.options.focusOnSelect === true) {
1462            $(_.$slideTrack).children().on('click.tpslick', _.selectHandler);
1463        }
1464
1465        $(window).on('orientationchange.tpslick.tpslick-' + _.instanceUid, $.proxy(_.orientationChange, _));
1466
1467        $(window).on('resize.tpslick.tpslick-' + _.instanceUid, $.proxy(_.resize, _));
1468
1469        $('[draggable!=true]', _.$slideTrack).on('dragstart', _.preventDefault);
1470
1471        $(window).on('load.tpslick.tpslick-' + _.instanceUid, _.setPosition);
1472        $(_.setPosition);
1473
1474    };
1475
1476    TPSlick.prototype.initUI = function() {
1477
1478        var _ = this;
1479
1480        if (_.options.arrows === true && _.slideCount > _.options.slidesToShow) {
1481
1482            _.$prevArrow.show();
1483            _.$nextArrow.show();
1484
1485        }
1486
1487        if (_.options.dots === true && _.slideCount > _.options.slidesToShow) {
1488
1489            _.$dots.show();
1490
1491        }
1492
1493    };
1494
1495    TPSlick.prototype.keyHandler = function(event) {
1496
1497        var _ = this;
1498         //Dont slide if the cursor is inside the form fields and arrow keys are pressed
1499        if(!event.target.tagName.match('TEXTAREA|INPUT|SELECT')) {
1500            if (event.keyCode === 37 && _.options.accessibility === true) {
1501                _.changeSlide({
1502                    data: {
1503                        message: _.options.rtl === true ? 'next' :  'previous'
1504                    }
1505                });
1506            } else if (event.keyCode === 39 && _.options.accessibility === true) {
1507                _.changeSlide({
1508                    data: {
1509                        message: _.options.rtl === true ? 'previous' : 'next'
1510                    }
1511                });
1512            }
1513        }
1514
1515    };
1516
1517    TPSlick.prototype.lazyLoad = function() {
1518
1519        var _ = this,
1520            loadRange, cloneRange, rangeStart, rangeEnd;
1521
1522        function loadImages(imagesScope) {
1523
1524            $('img[data-lazy]', imagesScope).each(function() {
1525
1526                var image = $(this),
1527                    imageSource = $(this).attr('data-lazy'),
1528                    imageSrcSet = $(this).attr('data-srcset'),
1529                    imageSizes  = $(this).attr('data-sizes') || _.$slider.attr('data-sizes'),
1530                    imageToLoad = document.createElement('img');
1531
1532                imageToLoad.onload = function() {
1533
1534                    image
1535                        .animate({ opacity: 0 }, 100, function() {
1536
1537                            if (imageSrcSet) {
1538                                image
1539                                    .attr('srcset', imageSrcSet );
1540
1541                                if (imageSizes) {
1542                                    image
1543                                        .attr('sizes', imageSizes );
1544                                }
1545                            }
1546
1547                            image
1548                                .attr('src', imageSource)
1549                                .animate({ opacity: 1 }, 200, function() {
1550                                    image
1551                                        .removeAttr('data-lazy data-srcset data-sizes')
1552                                        .removeClass('tpslick-loading');
1553                                });
1554                            _.$slider.trigger('lazyLoaded', [_, image, imageSource]);
1555                        });
1556
1557                };
1558
1559                imageToLoad.onerror = function() {
1560
1561                    image
1562                        .removeAttr( 'data-lazy' )
1563                        .removeClass( 'tpslick-loading' )
1564                        .addClass( 'tpslick-lazyload-error' );
1565
1566                    _.$slider.trigger('lazyLoadError', [ _, image, imageSource ]);
1567
1568                };
1569
1570                imageToLoad.src = imageSource;
1571
1572            });
1573
1574        }
1575
1576        if (_.options.centerMode === true) {
1577            if (_.options.infinite === true) {
1578                rangeStart = _.currentSlide + (_.options.slidesToShow / 2 + 1);
1579                rangeEnd = rangeStart + _.options.slidesToShow + 2;
1580            } else {
1581                rangeStart = Math.max(0, _.currentSlide - (_.options.slidesToShow / 2 + 1));
1582                rangeEnd = 2 + (_.options.slidesToShow / 2 + 1) + _.currentSlide;
1583            }
1584        } else {
1585            rangeStart = _.options.infinite ? _.options.slidesToShow + _.currentSlide : _.currentSlide;
1586            rangeEnd = Math.ceil(rangeStart + _.options.slidesToShow);
1587            if (_.options.fade === true) {
1588                if (rangeStart > 0) rangeStart--;
1589                if (rangeEnd <= _.slideCount) rangeEnd++;
1590            }
1591        }
1592
1593        loadRange = _.$slider.find('.tpslick-slide').slice(rangeStart, rangeEnd);
1594
1595        if (_.options.lazyLoad === 'anticipated') {
1596            var prevSlide = rangeStart - 1,
1597                nextSlide = rangeEnd,
1598                $slides = _.$slider.find('.tpslick-slide');
1599
1600            for (var i = 0; i < _.options.slidesToScroll; i++) {
1601                if (prevSlide < 0) prevSlide = _.slideCount - 1;
1602                loadRange = loadRange.add($slides.eq(prevSlide));
1603                loadRange = loadRange.add($slides.eq(nextSlide));
1604                prevSlide--;
1605                nextSlide++;
1606            }
1607        }
1608
1609        loadImages(loadRange);
1610
1611        if (_.slideCount <= _.options.slidesToShow) {
1612            cloneRange = _.$slider.find('.tpslick-slide');
1613            loadImages(cloneRange);
1614        } else
1615        if (_.currentSlide >= _.slideCount - _.options.slidesToShow) {
1616            cloneRange = _.$slider.find('.tpslick-cloned').slice(0, _.options.slidesToShow);
1617            loadImages(cloneRange);
1618        } else if (_.currentSlide === 0) {
1619            cloneRange = _.$slider.find('.tpslick-cloned').slice(_.options.slidesToShow * -1);
1620            loadImages(cloneRange);
1621        }
1622
1623    };
1624
1625    TPSlick.prototype.loadSlider = function() {
1626
1627        var _ = this;
1628
1629        _.setPosition();
1630
1631        _.$slideTrack.css({
1632            opacity: 1
1633        });
1634
1635        _.$slider.removeClass('tpslick-loading');
1636
1637        _.initUI();
1638
1639        if (_.options.lazyLoad === 'progressive') {
1640            _.progressiveLazyLoad();
1641        }
1642
1643    };
1644
1645    TPSlick.prototype.next = TPSlick.prototype.tpslickNext = function() {
1646
1647        var _ = this;
1648
1649        _.changeSlide({
1650            data: {
1651                message: 'next'
1652            }
1653        });
1654
1655    };
1656
1657    TPSlick.prototype.orientationChange = function() {
1658
1659        var _ = this;
1660
1661        _.checkResponsive();
1662        _.setPosition();
1663
1664    };
1665
1666    TPSlick.prototype.pause = TPSlick.prototype.tpslickPause = function() {
1667
1668        var _ = this;
1669
1670        _.autoPlayClear();
1671        _.paused = true;
1672
1673    };
1674
1675    TPSlick.prototype.play = TPSlick.prototype.tpslickPlay = function() {
1676
1677        var _ = this;
1678
1679        _.autoPlay();
1680        _.options.autoplay = true;
1681        _.paused = false;
1682        _.focussed = false;
1683        _.interrupted = false;
1684
1685    };
1686
1687    TPSlick.prototype.postSlide = function(index) {
1688
1689        var _ = this;
1690
1691        if( !_.untpslicked ) {
1692
1693            _.$slider.trigger('afterChange', [_, index]);
1694
1695            _.animating = false;
1696
1697            if (_.slideCount > _.options.slidesToShow) {
1698                _.setPosition();
1699            }
1700
1701            _.swipeLeft = null;
1702
1703            if ( _.options.autoplay ) {
1704                _.autoPlay();
1705            }
1706
1707            if (_.options.accessibility === true) {
1708                _.initADA();
1709
1710                if (_.options.focusOnChange) {
1711                    var $currentSlide = $(_.$slides.get(_.currentSlide));
1712                    $currentSlide.attr('tabindex', 0).focus();
1713                }
1714            }
1715
1716        }
1717
1718    };
1719
1720    TPSlick.prototype.prev = TPSlick.prototype.tpslickPrev = function() {
1721
1722        var _ = this;
1723
1724        _.changeSlide({
1725            data: {
1726                message: 'previous'
1727            }
1728        });
1729
1730    };
1731
1732    TPSlick.prototype.preventDefault = function(event) {
1733
1734        event.preventDefault();
1735
1736    };
1737
1738    TPSlick.prototype.progressiveLazyLoad = function( tryCount ) {
1739
1740        tryCount = tryCount || 1;
1741
1742        var _ = this,
1743            $imgsToLoad = $( 'img[data-lazy]', _.$slider ),
1744            image,
1745            imageSource,
1746            imageSrcSet,
1747            imageSizes,
1748            imageToLoad;
1749
1750        if ( $imgsToLoad.length ) {
1751
1752            image = $imgsToLoad.first();
1753            imageSource = image.attr('data-lazy');
1754            imageSrcSet = image.attr('data-srcset');
1755            imageSizes  = image.attr('data-sizes') || _.$slider.attr('data-sizes');
1756            imageToLoad = document.createElement('img');
1757
1758            imageToLoad.onload = function() {
1759
1760                if (imageSrcSet) {
1761                    image
1762                        .attr('srcset', imageSrcSet );
1763
1764                    if (imageSizes) {
1765                        image
1766                            .attr('sizes', imageSizes );
1767                    }
1768                }
1769
1770                image
1771                    .attr( 'src', imageSource )
1772                    .removeAttr('data-lazy data-srcset data-sizes')
1773                    .removeClass('tpslick-loading');
1774
1775                if ( _.options.adaptiveHeight === true ) {
1776                    _.setPosition();
1777                }
1778
1779                _.$slider.trigger('lazyLoaded', [ _, image, imageSource ]);
1780                _.progressiveLazyLoad();
1781
1782            };
1783
1784            imageToLoad.onerror = function() {
1785
1786                if ( tryCount < 3 ) {
1787
1788                    /**
1789                     * try to load the image 3 times,
1790                     * leave a slight delay so we don't get
1791                     * servers blocking the request.
1792                     */
1793                    setTimeout( function() {
1794                        _.progressiveLazyLoad( tryCount + 1 );
1795                    }, 500 );
1796
1797                } else {
1798
1799                    image
1800                        .removeAttr( 'data-lazy' )
1801                        .removeClass( 'tpslick-loading' )
1802                        .addClass( 'tpslick-lazyload-error' );
1803
1804                    _.$slider.trigger('lazyLoadError', [ _, image, imageSource ]);
1805
1806                    _.progressiveLazyLoad();
1807
1808                }
1809
1810            };
1811
1812            imageToLoad.src = imageSource;
1813
1814        } else {
1815
1816            _.$slider.trigger('allImagesLoaded', [ _ ]);
1817
1818        }
1819
1820    };
1821
1822    TPSlick.prototype.refresh = function( initializing ) {
1823
1824        var _ = this, currentSlide, lastVisibleIndex;
1825
1826        lastVisibleIndex = _.slideCount - _.options.slidesToShow;
1827
1828        // in non-infinite sliders, we don't want to go past the
1829        // last visible index.
1830        if( !_.options.infinite && ( _.currentSlide > lastVisibleIndex )) {
1831            _.currentSlide = lastVisibleIndex;
1832        }
1833
1834        // if less slides than to show, go to start.
1835        if ( _.slideCount <= _.options.slidesToShow ) {
1836            _.currentSlide = 0;
1837
1838        }
1839
1840        currentSlide = _.currentSlide;
1841
1842        _.destroy(true);
1843
1844        $.extend(_, _.initials, { currentSlide: currentSlide });
1845
1846        _.init();
1847
1848        if( !initializing ) {
1849
1850            _.changeSlide({
1851                data: {
1852                    message: 'index',
1853                    index: currentSlide
1854                }
1855            }, false);
1856
1857        }
1858
1859    };
1860
1861    TPSlick.prototype.registerBreakpoints = function() {
1862
1863        var _ = this, breakpoint, currentBreakpoint, l,
1864            responsiveSettings = _.options.responsive || null;
1865
1866        if ( $.type(responsiveSettings) === 'array' && responsiveSettings.length ) {
1867
1868            _.respondTo = _.options.respondTo || 'window';
1869
1870            for ( breakpoint in responsiveSettings ) {
1871
1872                l = _.breakpoints.length-1;
1873
1874                if (responsiveSettings.hasOwnProperty(breakpoint)) {
1875                    currentBreakpoint = responsiveSettings[breakpoint].breakpoint;
1876
1877                    // loop through the breakpoints and cut out any existing
1878                    // ones with the same breakpoint number, we don't want dupes.
1879                    while( l >= 0 ) {
1880                        if( _.breakpoints[l] && _.breakpoints[l] === currentBreakpoint ) {
1881                            _.breakpoints.splice(l,1);
1882                        }
1883                        l--;
1884                    }
1885
1886                    _.breakpoints.push(currentBreakpoint);
1887                    _.breakpointSettings[currentBreakpoint] = responsiveSettings[breakpoint].settings;
1888
1889                }
1890
1891            }
1892
1893            _.breakpoints.sort(function(a, b) {
1894                return ( _.options.mobileFirst ) ? a-b : b-a;
1895            });
1896
1897        }
1898
1899    };
1900
1901    TPSlick.prototype.reinit = function() {
1902
1903        var _ = this;
1904
1905        _.$slides =
1906            _.$slideTrack
1907                .children(_.options.slide)
1908                .addClass('tpslick-slide');
1909
1910        _.slideCount = _.$slides.length;
1911
1912        if (_.currentSlide >= _.slideCount && _.currentSlide !== 0) {
1913            _.currentSlide = _.currentSlide - _.options.slidesToScroll;
1914        }
1915
1916        if (_.slideCount <= _.options.slidesToShow) {
1917            _.currentSlide = 0;
1918        }
1919
1920        _.registerBreakpoints();
1921
1922        _.setProps();
1923        _.setupInfinite();
1924        _.buildArrows();
1925        _.updateArrows();
1926        _.initArrowEvents();
1927        _.buildDots();
1928        _.updateDots();
1929        _.initDotEvents();
1930        _.cleanUpSlideEvents();
1931        _.initSlideEvents();
1932
1933        _.checkResponsive(false, true);
1934
1935        if (_.options.focusOnSelect === true) {
1936            $(_.$slideTrack).children().on('click.tpslick', _.selectHandler);
1937        }
1938
1939        _.setSlideClasses(typeof _.currentSlide === 'number' ? _.currentSlide : 0);
1940
1941        _.setPosition();
1942        _.focusHandler();
1943
1944        _.paused = !_.options.autoplay;
1945        _.autoPlay();
1946
1947        _.$slider.trigger('reInit', [_]);
1948
1949    };
1950
1951    TPSlick.prototype.resize = function() {
1952
1953        var _ = this;
1954
1955        if ($(window).width() !== _.windowWidth) {
1956            clearTimeout(_.windowDelay);
1957            _.windowDelay = window.setTimeout(function() {
1958                _.windowWidth = $(window).width();
1959                _.checkResponsive();
1960                if( !_.untpslicked ) { _.setPosition(); }
1961            }, 50);
1962        }
1963    };
1964
1965    TPSlick.prototype.removeSlide = TPSlick.prototype.tpslickRemove = function(index, removeBefore, removeAll) {
1966
1967        var _ = this;
1968
1969        if (typeof(index) === 'boolean') {
1970            removeBefore = index;
1971            index = removeBefore === true ? 0 : _.slideCount - 1;
1972        } else {
1973            index = removeBefore === true ? --index : index;
1974        }
1975
1976        if (_.slideCount < 1 || index < 0 || index > _.slideCount - 1) {
1977            return false;
1978        }
1979
1980        _.unload();
1981
1982        if (removeAll === true) {
1983            _.$slideTrack.children().remove();
1984        } else {
1985            _.$slideTrack.children(this.options.slide).eq(index).remove();
1986        }
1987
1988        _.$slides = _.$slideTrack.children(this.options.slide);
1989
1990        _.$slideTrack.children(this.options.slide).detach();
1991
1992        _.$slideTrack.append(_.$slides);
1993
1994        _.$slidesCache = _.$slides;
1995
1996        _.reinit();
1997
1998    };
1999
2000    TPSlick.prototype.setCSS = function(position) {
2001
2002        var _ = this,
2003            positionProps = {},
2004            x, y;
2005
2006        if (_.options.rtl === true) {
2007            position = -position;
2008        }
2009        x = _.positionProp == 'left' ? Math.ceil(position) + 'px' : '0px';
2010        y = _.positionProp == 'top' ? Math.ceil(position) + 'px' : '0px';
2011
2012        positionProps[_.positionProp] = position;
2013
2014        if (_.transformsEnabled === false) {
2015            _.$slideTrack.css(positionProps);
2016        } else {
2017            positionProps = {};
2018            if (_.cssTransitions === false) {
2019                positionProps[_.animType] = 'translate(' + x + ', ' + y + ')';
2020                _.$slideTrack.css(positionProps);
2021            } else {
2022                positionProps[_.animType] = 'translate3d(' + x + ', ' + y + ', 0px)';
2023                _.$slideTrack.css(positionProps);
2024            }
2025        }
2026
2027    };
2028
2029    TPSlick.prototype.setDimensions = function() {
2030
2031        var _ = this;
2032
2033        if (_.options.vertical === false) {
2034            if (_.options.centerMode === true) {
2035                _.$list.css({
2036                    padding: ('0px ' + _.options.centerPadding)
2037                });
2038            }
2039        } else {
2040            _.$list.height(_.$slides.first().outerHeight(true) * _.options.slidesToShow);
2041            if (_.options.centerMode === true) {
2042                _.$list.css({
2043                    padding: (_.options.centerPadding + ' 0px')
2044                });
2045            }
2046        }
2047
2048        _.listWidth = _.$list.width();
2049        _.listHeight = _.$list.height();
2050
2051
2052        if (_.options.vertical === false && _.options.variableWidth === false) {
2053            _.slideWidth = Math.ceil(_.listWidth / _.options.slidesToShow);
2054            _.$slideTrack.width(Math.ceil((_.slideWidth * _.$slideTrack.children('.tpslick-slide').length)));
2055
2056        } else if (_.options.variableWidth === true) {
2057            _.$slideTrack.width(5000 * _.slideCount);
2058        } else {
2059            _.slideWidth = Math.ceil(_.listWidth);
2060            _.$slideTrack.height(Math.ceil((_.$slides.first().outerHeight(true) * _.$slideTrack.children('.tpslick-slide').length)));
2061        }
2062
2063        var offset = _.$slides.first().outerWidth(true) - _.$slides.first().width();
2064        if (_.options.variableWidth === false) _.$slideTrack.children('.tpslick-slide').width(_.slideWidth - offset);
2065
2066    };
2067
2068    TPSlick.prototype.setFade = function() {
2069
2070        var _ = this,
2071            targetLeft;
2072
2073        _.$slides.each(function(index, element) {
2074            targetLeft = (_.slideWidth * index) * -1;
2075            if (_.options.rtl === true) {
2076                $(element).css({
2077                    position: 'relative',
2078                    right: targetLeft,
2079                    top: 0,
2080                    zIndex: _.options.zIndex - 2,
2081                    opacity: 0
2082                });
2083            } else {
2084                $(element).css({
2085                    position: 'relative',
2086                    left: targetLeft,
2087                    top: 0,
2088                    zIndex: _.options.zIndex - 2,
2089                    opacity: 0
2090                });
2091            }
2092        });
2093
2094        _.$slides.eq(_.currentSlide).css({
2095            zIndex: _.options.zIndex - 1,
2096            opacity: 1
2097        });
2098
2099    };
2100
2101    TPSlick.prototype.setHeight = function() {
2102
2103        var _ = this;
2104
2105        if (_.options.slidesToShow === 1 && _.options.adaptiveHeight === true && _.options.vertical === false) {
2106            var targetHeight = _.$slides.eq(_.currentSlide).outerHeight(true);
2107            _.$list.css('height', targetHeight);
2108        }
2109
2110    };
2111
2112    TPSlick.prototype.setOption =
2113    TPSlick.prototype.tpslickSetOption = function() {
2114
2115        /**
2116         * accepts arguments in format of:
2117         *
2118         *  - for changing a single option's value:
2119         *     .tpslick("setOption", option, value, refresh )
2120         *
2121         *  - for changing a set of responsive options:
2122         *     .tpslick("setOption", 'responsive', [{}, ...], refresh )
2123         *
2124         *  - for updating multiple values at once (not responsive)
2125         *     .tpslick("setOption", { 'option': value, ... }, refresh )
2126         */
2127
2128        var _ = this, l, item, option, value, refresh = false, type;
2129
2130        if( $.type( arguments[0] ) === 'object' ) {
2131
2132            option =  arguments[0];
2133            refresh = arguments[1];
2134            type = 'multiple';
2135
2136        } else if ( $.type( arguments[0] ) === 'string' ) {
2137
2138            option =  arguments[0];
2139            value = arguments[1];
2140            refresh = arguments[2];
2141
2142            if ( arguments[0] === 'responsive' && $.type( arguments[1] ) === 'array' ) {
2143
2144                type = 'responsive';
2145
2146            } else if ( typeof arguments[1] !== 'undefined' ) {
2147
2148                type = 'single';
2149
2150            }
2151
2152        }
2153
2154        if ( type === 'single' ) {
2155
2156            _.options[option] = value;
2157
2158
2159        } else if ( type === 'multiple' ) {
2160
2161            $.each( option , function( opt, val ) {
2162
2163                _.options[opt] = val;
2164
2165            });
2166
2167
2168        } else if ( type === 'responsive' ) {
2169
2170            for ( item in value ) {
2171
2172                if( $.type( _.options.responsive ) !== 'array' ) {
2173
2174                    _.options.responsive = [ value[item] ];
2175
2176                } else {
2177
2178                    l = _.options.responsive.length-1;
2179
2180                    // loop through the responsive object and splice out duplicates.
2181                    while( l >= 0 ) {
2182
2183                        if( _.options.responsive[l].breakpoint === value[item].breakpoint ) {
2184
2185                            _.options.responsive.splice(l,1);
2186
2187                        }
2188
2189                        l--;
2190
2191                    }
2192
2193                    _.options.responsive.push( value[item] );
2194
2195                }
2196
2197            }
2198
2199        }
2200
2201        if ( refresh ) {
2202
2203            _.unload();
2204            _.reinit();
2205
2206        }
2207
2208    };
2209
2210    TPSlick.prototype.setPosition = function() {
2211
2212        var _ = this;
2213
2214        _.setDimensions();
2215
2216        _.setHeight();
2217
2218        if (_.options.fade === false) {
2219            _.setCSS(_.getLeft(_.currentSlide));
2220        } else {
2221            _.setFade();
2222        }
2223
2224        _.$slider.trigger('setPosition', [_]);
2225
2226    };
2227
2228    TPSlick.prototype.setProps = function() {
2229
2230        var _ = this,
2231            bodyStyle = document.body.style;
2232
2233        _.positionProp = _.options.vertical === true ? 'top' : 'left';
2234
2235        if (_.positionProp === 'top') {
2236            _.$slider.addClass('tpslick-vertical');
2237        } else {
2238            _.$slider.removeClass('tpslick-vertical');
2239        }
2240
2241        if (bodyStyle.WebkitTransition !== undefined ||
2242            bodyStyle.MozTransition !== undefined ||
2243            bodyStyle.msTransition !== undefined) {
2244            if (_.options.useCSS === true) {
2245                _.cssTransitions = true;
2246            }
2247        }
2248
2249        if ( _.options.fade ) {
2250            if ( typeof _.options.zIndex === 'number' ) {
2251                if( _.options.zIndex < 3 ) {
2252                    _.options.zIndex = 3;
2253                }
2254            } else {
2255                _.options.zIndex = _.defaults.zIndex;
2256            }
2257        }
2258
2259        if (bodyStyle.OTransform !== undefined) {
2260            _.animType = 'OTransform';
2261            _.transformType = '-o-transform';
2262            _.transitionType = 'OTransition';
2263            if (bodyStyle.perspectiveProperty === undefined && bodyStyle.webkitPerspective === undefined) _.animType = false;
2264        }
2265        if (bodyStyle.MozTransform !== undefined) {
2266            _.animType = 'MozTransform';
2267            _.transformType = '-moz-transform';
2268            _.transitionType = 'MozTransition';
2269            if (bodyStyle.perspectiveProperty === undefined && bodyStyle.MozPerspective === undefined) _.animType = false;
2270        }
2271        if (bodyStyle.webkitTransform !== undefined) {
2272            _.animType = 'webkitTransform';
2273            _.transformType = '-webkit-transform';
2274            _.transitionType = 'webkitTransition';
2275            if (bodyStyle.perspectiveProperty === undefined && bodyStyle.webkitPerspective === undefined) _.animType = false;
2276        }
2277        if (bodyStyle.msTransform !== undefined) {
2278            _.animType = 'msTransform';
2279            _.transformType = '-ms-transform';
2280            _.transitionType = 'msTransition';
2281            if (bodyStyle.msTransform === undefined) _.animType = false;
2282        }
2283        if (bodyStyle.transform !== undefined && _.animType !== false) {
2284            _.animType = 'transform';
2285            _.transformType = 'transform';
2286            _.transitionType = 'transition';
2287        }
2288        _.transformsEnabled = _.options.useTransform && (_.animType !== null && _.animType !== false);
2289    };
2290
2291
2292    TPSlick.prototype.setSlideClasses = function(index) {
2293
2294        var _ = this,
2295            centerOffset, allSlides, indexOffset, remainder;
2296
2297        allSlides = _.$slider
2298            .find('.tpslick-slide')
2299            .removeClass('tpslick-active tpslick-center tpslick-current')
2300            .attr('aria-hidden', 'true');
2301
2302        _.$slides
2303            .eq(index)
2304            .addClass('tpslick-current');
2305
2306        if (_.options.centerMode === true) {
2307
2308            var evenCoef = _.options.slidesToShow % 2 === 0 ? 1 : 0;
2309
2310            centerOffset = Math.floor(_.options.slidesToShow / 2);
2311
2312            if (_.options.infinite === true) {
2313
2314                if (index >= centerOffset && index <= (_.slideCount - 1) - centerOffset) {
2315                    _.$slides
2316                        .slice(index - centerOffset + evenCoef, index + centerOffset + 1)
2317                        .addClass('tpslick-active')
2318                        .attr('aria-hidden', 'false');
2319
2320                } else {
2321
2322                    indexOffset = _.options.slidesToShow + index;
2323                    allSlides
2324                        .slice(indexOffset - centerOffset + 1 + evenCoef, indexOffset + centerOffset + 2)
2325                        .addClass('tpslick-active')
2326                        .attr('aria-hidden', 'false');
2327
2328                }
2329
2330                if (index === 0) {
2331
2332                    allSlides
2333                        .eq(allSlides.length - 1 - _.options.slidesToShow)
2334                        .addClass('tpslick-center');
2335
2336                } else if (index === _.slideCount - 1) {
2337
2338                    allSlides
2339                        .eq(_.options.slidesToShow)
2340                        .addClass('tpslick-center');
2341
2342                }
2343
2344            }
2345
2346            _.$slides
2347                .eq(index)
2348                .addClass('tpslick-center');
2349
2350        } else {
2351
2352            if (index >= 0 && index <= (_.slideCount - _.options.slidesToShow)) {
2353
2354                _.$slides
2355                    .slice(index, index + _.options.slidesToShow)
2356                    .addClass('tpslick-active')
2357                    .attr('aria-hidden', 'false');
2358
2359            } else if (allSlides.length <= _.options.slidesToShow) {
2360
2361                allSlides
2362                    .addClass('tpslick-active')
2363                    .attr('aria-hidden', 'false');
2364
2365            } else {
2366
2367                remainder = _.slideCount % _.options.slidesToShow;
2368                indexOffset = _.options.infinite === true ? _.options.slidesToShow + index : index;
2369
2370                if (_.options.slidesToShow == _.options.slidesToScroll && (_.slideCount - index) < _.options.slidesToShow) {
2371
2372                    allSlides
2373                        .slice(indexOffset - (_.options.slidesToShow - remainder), indexOffset + remainder)
2374                        .addClass('tpslick-active')
2375                        .attr('aria-hidden', 'false');
2376
2377                } else {
2378
2379                    allSlides
2380                        .slice(indexOffset, indexOffset + _.options.slidesToShow)
2381                        .addClass('tpslick-active')
2382                        .attr('aria-hidden', 'false');
2383
2384                }
2385
2386            }
2387
2388        }
2389
2390        if (_.options.lazyLoad === 'ondemand' || _.options.lazyLoad === 'anticipated') {
2391            _.lazyLoad();
2392        }
2393    };
2394
2395    TPSlick.prototype.setupInfinite = function() {
2396
2397        var _ = this,
2398            i, slideIndex, infiniteCount;
2399
2400        if (_.options.fade === true) {
2401            _.options.centerMode = false;
2402        }
2403
2404        if (_.options.infinite === true && _.options.fade === false) {
2405
2406            slideIndex = null;
2407
2408            if (_.slideCount > _.options.slidesToShow) {
2409
2410                if (_.options.centerMode === true) {
2411                    infiniteCount = _.options.slidesToShow + 1;
2412                } else {
2413                    infiniteCount = _.options.slidesToShow;
2414                }
2415
2416                for (i = _.slideCount; i > (_.slideCount -
2417                        infiniteCount); i -= 1) {
2418                    slideIndex = i - 1;
2419                    $(_.$slides[slideIndex]).clone(true).attr('id', '')
2420                        .attr('data-tpslick-index', slideIndex - _.slideCount)
2421                        .prependTo(_.$slideTrack).addClass('tpslick-cloned');
2422                }
2423                for (i = 0; i < infiniteCount  + _.slideCount; i += 1) {
2424                    slideIndex = i;
2425                    $(_.$slides[slideIndex]).clone(true).attr('id', '')
2426                        .attr('data-tpslick-index', slideIndex + _.slideCount)
2427                        .appendTo(_.$slideTrack).addClass('tpslick-cloned');
2428                }
2429                _.$slideTrack.find('.tpslick-cloned').find('[id]').each(function() {
2430                    $(this).attr('id', '');
2431                });
2432
2433            }
2434
2435        }
2436
2437    };
2438
2439    TPSlick.prototype.interrupt = function( toggle ) {
2440
2441        var _ = this;
2442
2443        if( !toggle ) {
2444            _.autoPlay();
2445        }
2446        _.interrupted = toggle;
2447
2448    };
2449
2450    TPSlick.prototype.selectHandler = function(event) {
2451
2452        var _ = this;
2453
2454        var targetElement =
2455            $(event.target).is('.tpslick-slide') ?
2456                $(event.target) :
2457                $(event.target).parents('.tpslick-slide');
2458
2459        var index = parseInt(targetElement.attr('data-tpslick-index'));
2460
2461        if (!index) index = 0;
2462
2463        if (_.slideCount <= _.options.slidesToShow) {
2464
2465            _.slideHandler(index, false, true);
2466            return;
2467
2468        }
2469
2470        _.slideHandler(index);
2471
2472    };
2473
2474    TPSlick.prototype.slideHandler = function(index, sync, dontAnimate) {
2475
2476        var targetSlide, animSlide, oldSlide, slideLeft, targetLeft = null,
2477            _ = this, navTarget;
2478
2479        sync = sync || false;
2480
2481        if (_.animating === true && _.options.waitForAnimate === true) {
2482            return;
2483        }
2484
2485        if (_.options.fade === true && _.currentSlide === index) {
2486            return;
2487        }
2488
2489        if (sync === false) {
2490            _.asNavFor(index);
2491        }
2492
2493        targetSlide = index;
2494        targetLeft = _.getLeft(targetSlide);
2495        slideLeft = _.getLeft(_.currentSlide);
2496
2497        _.currentLeft = _.swipeLeft === null ? slideLeft : _.swipeLeft;
2498
2499        if (_.options.infinite === false && _.options.centerMode === false && (index < 0 || index > _.getDotCount() * _.options.slidesToScroll)) {
2500            if (_.options.fade === false) {
2501                targetSlide = _.currentSlide;
2502                if (dontAnimate !== true && _.slideCount > _.options.slidesToShow) {
2503                    _.animateSlide(slideLeft, function() {
2504                        _.postSlide(targetSlide);
2505                    });
2506                } else {
2507                    _.postSlide(targetSlide);
2508                }
2509            }
2510            return;
2511        } else if (_.options.infinite === false && _.options.centerMode === true && (index < 0 || index > (_.slideCount - _.options.slidesToScroll))) {
2512            if (_.options.fade === false) {
2513                targetSlide = _.currentSlide;
2514                if (dontAnimate !== true && _.slideCount > _.options.slidesToShow) {
2515                    _.animateSlide(slideLeft, function() {
2516                        _.postSlide(targetSlide);
2517                    });
2518                } else {
2519                    _.postSlide(targetSlide);
2520                }
2521            }
2522            return;
2523        }
2524
2525        if ( _.options.autoplay ) {
2526            clearInterval(_.autoPlayTimer);
2527        }
2528
2529        if (targetSlide < 0) {
2530            if (_.slideCount % _.options.slidesToScroll !== 0) {
2531                animSlide = _.slideCount - (_.slideCount % _.options.slidesToScroll);
2532            } else {
2533                animSlide = _.slideCount + targetSlide;
2534            }
2535        } else if (targetSlide >= _.slideCount) {
2536            if (_.slideCount % _.options.slidesToScroll !== 0) {
2537                animSlide = 0;
2538            } else {
2539                animSlide = targetSlide - _.slideCount;
2540            }
2541        } else {
2542            animSlide = targetSlide;
2543        }
2544
2545        _.animating = true;
2546
2547        _.$slider.trigger('beforeChange', [_, _.currentSlide, animSlide]);
2548
2549        oldSlide = _.currentSlide;
2550        _.currentSlide = animSlide;
2551
2552        _.setSlideClasses(_.currentSlide);
2553
2554        if ( _.options.asNavFor ) {
2555
2556            navTarget = _.getNavTarget();
2557            navTarget = navTarget.tpslick('getTPSlick');
2558
2559            if ( navTarget.slideCount <= navTarget.options.slidesToShow ) {
2560                navTarget.setSlideClasses(_.currentSlide);
2561            }
2562
2563        }
2564
2565        _.updateDots();
2566        _.updateArrows();
2567
2568        if (_.options.fade === true) {
2569            if (dontAnimate !== true) {
2570
2571                _.fadeSlideOut(oldSlide);
2572
2573                _.fadeSlide(animSlide, function() {
2574                    _.postSlide(animSlide);
2575                });
2576
2577            } else {
2578                _.postSlide(animSlide);
2579            }
2580            _.animateHeight();
2581            return;
2582        }
2583
2584        if (dontAnimate !== true && _.slideCount > _.options.slidesToShow) {
2585            _.animateSlide(targetLeft, function() {
2586                _.postSlide(animSlide);
2587            });
2588        } else {
2589            _.postSlide(animSlide);
2590        }
2591
2592    };
2593
2594    TPSlick.prototype.startLoad = function() {
2595
2596        var _ = this;
2597
2598        if (_.options.arrows === true && _.slideCount > _.options.slidesToShow) {
2599
2600            _.$prevArrow.hide();
2601            _.$nextArrow.hide();
2602
2603        }
2604
2605        if (_.options.dots === true && _.slideCount > _.options.slidesToShow) {
2606
2607            _.$dots.hide();
2608
2609        }
2610
2611        _.$slider.addClass('tpslick-loading');
2612
2613    };
2614
2615    TPSlick.prototype.swipeDirection = function() {
2616
2617        var xDist, yDist, r, swipeAngle, _ = this;
2618
2619        xDist = _.touchObject.startX - _.touchObject.curX;
2620        yDist = _.touchObject.startY - _.touchObject.curY;
2621        r = Math.atan2(yDist, xDist);
2622
2623        swipeAngle = Math.round(r * 180 / Math.PI);
2624        if (swipeAngle < 0) {
2625            swipeAngle = 360 - Math.abs(swipeAngle);
2626        }
2627
2628        if ((swipeAngle <= 45) && (swipeAngle >= 0)) {
2629            return (_.options.rtl === false ? 'left' : 'right');
2630        }
2631        if ((swipeAngle <= 360) && (swipeAngle >= 315)) {
2632            return (_.options.rtl === false ? 'left' : 'right');
2633        }
2634        if ((swipeAngle >= 135) && (swipeAngle <= 225)) {
2635            return (_.options.rtl === false ? 'right' : 'left');
2636        }
2637        if (_.options.verticalSwiping === true) {
2638            if ((swipeAngle >= 35) && (swipeAngle <= 135)) {
2639                return 'down';
2640            } else {
2641                return 'up';
2642            }
2643        }
2644
2645        return 'vertical';
2646
2647    };
2648
2649    TPSlick.prototype.swipeEnd = function(event) {
2650
2651        var _ = this,
2652            slideCount,
2653            direction;
2654
2655        _.dragging = false;
2656        _.swiping = false;
2657
2658        if (_.scrolling) {
2659            _.scrolling = false;
2660            return false;
2661        }
2662
2663        _.interrupted = false;
2664        _.shouldClick = ( _.touchObject.swipeLength > 10 ) ? false : true;
2665
2666        if ( _.touchObject.curX === undefined ) {
2667            return false;
2668        }
2669
2670        if ( _.touchObject.edgeHit === true ) {
2671            _.$slider.trigger('edge', [_, _.swipeDirection() ]);
2672        }
2673
2674        if ( _.touchObject.swipeLength >= _.touchObject.minSwipe ) {
2675
2676            direction = _.swipeDirection();
2677
2678            switch ( direction ) {
2679
2680                case 'left':
2681                case 'down':
2682
2683                    slideCount =
2684                        _.options.swipeToSlide ?
2685                            _.checkNavigable( _.currentSlide + _.getSlideCount() ) :
2686                            _.currentSlide + _.getSlideCount();
2687
2688                    _.currentDirection = 0;
2689
2690                    break;
2691
2692                case 'right':
2693                case 'up':
2694
2695                    slideCount =
2696                        _.options.swipeToSlide ?
2697                            _.checkNavigable( _.currentSlide - _.getSlideCount() ) :
2698                            _.currentSlide - _.getSlideCount();
2699
2700                    _.currentDirection = 1;
2701
2702                    break;
2703
2704                default:
2705
2706
2707            }
2708
2709            if( direction != 'vertical' ) {
2710
2711                _.slideHandler( slideCount );
2712                _.touchObject = {};
2713                _.$slider.trigger('swipe', [_, direction ]);
2714
2715            }
2716
2717        } else {
2718
2719            if ( _.touchObject.startX !== _.touchObject.curX ) {
2720
2721                _.slideHandler( _.currentSlide );
2722                _.touchObject = {};
2723
2724            }
2725
2726        }
2727
2728    };
2729
2730    TPSlick.prototype.swipeHandler = function(event) {
2731
2732        var _ = this;
2733
2734        if ((_.options.swipe === false) || ('ontouchend' in document && _.options.swipe === false)) {
2735            return;
2736        } else if (_.options.draggable === false && event.type.indexOf('mouse') !== -1) {
2737            return;
2738        }
2739
2740        _.touchObject.fingerCount = event.originalEvent && event.originalEvent.touches !== undefined ?
2741            event.originalEvent.touches.length : 1;
2742
2743        _.touchObject.minSwipe = _.listWidth / _.options
2744            .touchThreshold;
2745
2746        if (_.options.verticalSwiping === true) {
2747            _.touchObject.minSwipe = _.listHeight / _.options
2748                .touchThreshold;
2749        }
2750
2751        switch (event.data.action) {
2752
2753            case 'start':
2754                _.swipeStart(event);
2755                break;
2756
2757            case 'move':
2758                _.swipeMove(event);
2759                break;
2760
2761            case 'end':
2762                _.swipeEnd(event);
2763                break;
2764
2765        }
2766
2767    };
2768
2769    TPSlick.prototype.swipeMove = function(event) {
2770
2771        var _ = this,
2772            edgeWasHit = false,
2773            curLeft, swipeDirection, swipeLength, positionOffset, touches, verticalSwipeLength;
2774
2775        touches = event.originalEvent !== undefined ? event.originalEvent.touches : null;
2776
2777        if (!_.dragging || _.scrolling || touches && touches.length !== 1) {
2778            return false;
2779        }
2780
2781        curLeft = _.getLeft(_.currentSlide);
2782
2783        _.touchObject.curX = touches !== undefined ? touches[0].pageX : event.clientX;
2784        _.touchObject.curY = touches !== undefined ? touches[0].pageY : event.clientY;
2785
2786        _.touchObject.swipeLength = Math.round(Math.sqrt(
2787            Math.pow(_.touchObject.curX - _.touchObject.startX, 2)));
2788
2789        verticalSwipeLength = Math.round(Math.sqrt(
2790            Math.pow(_.touchObject.curY - _.touchObject.startY, 2)));
2791
2792        if (!_.options.verticalSwiping && !_.swiping && verticalSwipeLength > 4) {
2793            _.scrolling = true;
2794            return false;
2795        }
2796
2797        if (_.options.verticalSwiping === true) {
2798            _.touchObject.swipeLength = verticalSwipeLength;
2799        }
2800
2801        swipeDirection = _.swipeDirection();
2802
2803        if (event.originalEvent !== undefined && _.touchObject.swipeLength > 4) {
2804            _.swiping = true;
2805            event.preventDefault();
2806        }
2807
2808        positionOffset = (_.options.rtl === false ? 1 : -1) * (_.touchObject.curX > _.touchObject.startX ? 1 : -1);
2809        if (_.options.verticalSwiping === true) {
2810            positionOffset = _.touchObject.curY > _.touchObject.startY ? 1 : -1;
2811        }
2812
2813
2814        swipeLength = _.touchObject.swipeLength;
2815
2816        _.touchObject.edgeHit = false;
2817
2818        if (_.options.infinite === false) {
2819            if ((_.currentSlide === 0 && swipeDirection === 'right') || (_.currentSlide >= _.getDotCount() && swipeDirection === 'left')) {
2820                swipeLength = _.touchObject.swipeLength * _.options.edgeFriction;
2821                _.touchObject.edgeHit = true;
2822            }
2823        }
2824
2825        if (_.options.vertical === false) {
2826            _.swipeLeft = curLeft + swipeLength * positionOffset;
2827        } else {
2828            _.swipeLeft = curLeft + (swipeLength * (_.$list.height() / _.listWidth)) * positionOffset;
2829        }
2830        if (_.options.verticalSwiping === true) {
2831            _.swipeLeft = curLeft + swipeLength * positionOffset;
2832        }
2833
2834        if (_.options.fade === true || _.options.touchMove === false) {
2835            return false;
2836        }
2837
2838        if (_.animating === true) {
2839            _.swipeLeft = null;
2840            return false;
2841        }
2842
2843        _.setCSS(_.swipeLeft);
2844
2845    };
2846
2847    TPSlick.prototype.swipeStart = function(event) {
2848
2849        var _ = this,
2850            touches;
2851
2852        _.interrupted = true;
2853
2854        if (_.touchObject.fingerCount !== 1 || _.slideCount <= _.options.slidesToShow) {
2855            _.touchObject = {};
2856            return false;
2857        }
2858
2859        if (event.originalEvent !== undefined && event.originalEvent.touches !== undefined) {
2860            touches = event.originalEvent.touches[0];
2861        }
2862
2863        _.touchObject.startX = _.touchObject.curX = touches !== undefined ? touches.pageX : event.clientX;
2864        _.touchObject.startY = _.touchObject.curY = touches !== undefined ? touches.pageY : event.clientY;
2865
2866        _.dragging = true;
2867
2868    };
2869
2870    TPSlick.prototype.unfilterSlides = TPSlick.prototype.tpslickUnfilter = function() {
2871
2872        var _ = this;
2873
2874        if (_.$slidesCache !== null) {
2875
2876            _.unload();
2877
2878            _.$slideTrack.children(this.options.slide).detach();
2879
2880            _.$slidesCache.appendTo(_.$slideTrack);
2881
2882            _.reinit();
2883
2884        }
2885
2886    };
2887
2888    TPSlick.prototype.unload = function() {
2889
2890        var _ = this;
2891
2892        $('.tpslick-cloned', _.$slider).remove();
2893
2894        if (_.$dots) {
2895            _.$dots.remove();
2896        }
2897
2898        if (_.$prevArrow && _.htmlExpr.test(_.options.prevArrow)) {
2899            _.$prevArrow.remove();
2900        }
2901
2902        if (_.$nextArrow && _.htmlExpr.test(_.options.nextArrow)) {
2903            _.$nextArrow.remove();
2904        }
2905
2906        _.$slides
2907            .removeClass('tpslick-slide tpslick-active tpslick-visible tpslick-current')
2908            .attr('aria-hidden', 'true')
2909            .css('width', '');
2910
2911    };
2912
2913    TPSlick.prototype.untpslick = function(fromBreakpoint) {
2914
2915        var _ = this;
2916        _.$slider.trigger('untpslick', [_, fromBreakpoint]);
2917        _.destroy();
2918
2919    };
2920
2921    TPSlick.prototype.updateArrows = function() {
2922
2923        var _ = this,
2924            centerOffset;
2925
2926        centerOffset = Math.floor(_.options.slidesToShow / 2);
2927
2928        if ( _.options.arrows === true &&
2929            _.slideCount > _.options.slidesToShow &&
2930            !_.options.infinite ) {
2931
2932            _.$prevArrow.removeClass('tpslick-disabled').attr('aria-disabled', 'false');
2933            _.$nextArrow.removeClass('tpslick-disabled').attr('aria-disabled', 'false');
2934
2935            if (_.currentSlide === 0) {
2936
2937                _.$prevArrow.addClass('tpslick-disabled').attr('aria-disabled', 'true');
2938                _.$nextArrow.removeClass('tpslick-disabled').attr('aria-disabled', 'false');
2939
2940            } else if (_.currentSlide >= _.slideCount - _.options.slidesToShow && _.options.centerMode === false) {
2941
2942                _.$nextArrow.addClass('tpslick-disabled').attr('aria-disabled', 'true');
2943                _.$prevArrow.removeClass('tpslick-disabled').attr('aria-disabled', 'false');
2944
2945            } else if (_.currentSlide >= _.slideCount - 1 && _.options.centerMode === true) {
2946
2947                _.$nextArrow.addClass('tpslick-disabled').attr('aria-disabled', 'true');
2948                _.$prevArrow.removeClass('tpslick-disabled').attr('aria-disabled', 'false');
2949
2950            }
2951
2952        }
2953
2954    };
2955
2956    TPSlick.prototype.updateDots = function() {
2957
2958        var _ = this;
2959
2960        if (_.$dots !== null) {
2961
2962            _.$dots
2963                .find('li')
2964                    .removeClass('tpslick-active')
2965                    .end();
2966
2967            _.$dots
2968                .find('li')
2969                .eq(Math.floor(_.currentSlide / _.options.slidesToScroll))
2970                .addClass('tpslick-active');
2971
2972        }
2973
2974    };
2975
2976    TPSlick.prototype.visibility = function() {
2977
2978        var _ = this;
2979
2980        if ( _.options.autoplay ) {
2981
2982            if ( document[_.hidden] ) {
2983
2984                _.interrupted = true;
2985
2986            } else {
2987
2988                _.interrupted = false;
2989
2990            }
2991
2992        }
2993
2994    };
2995
2996    $.fn.tpslick = function() {
2997        var _ = this,
2998            opt = arguments[0],
2999            args = Array.prototype.slice.call(arguments, 1),
3000            l = _.length,
3001            i,
3002            ret;
3003        for (i = 0; i < l; i++) {
3004            if (typeof opt == 'object' || typeof opt == 'undefined')
3005                _[i].tpslick = new TPSlick(_[i], opt);
3006            else
3007                ret = _[i].tpslick[opt].apply(_[i].tpslick, args);
3008            if (typeof ret != 'undefined') return ret;
3009        }
3010        return _;
3011    };
3012
3013}));

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.