PageSourceSearch

https://urretxu.eus/media/com_ingallery/js/frontend.js?v=3.9.0

js urretxu.eus collected 2026-10-02 10:09:39 UTC 132,731 bytes, 3,908 lines download raw bytes

vendor: 16,305 bytes, lines 1-521
1/*
2     _ _      _       _
3 ___| (_) ___| | __  (_)___
4/ __| | |/ __| |/ /  | / __|
5\__ \ | | (__|   < _ | \__ \
6|___/_|_|\___|_|\_(_)/ |___/
7                   |__/
8
9 Version: 1.6.0
10  Author: Ken Wheeler
11 Website: http://kenwheeler.github.io
12    Docs: http://kenwheeler.github.io/slick
13    Repo: http://github.com/kenwheeler/slick
14  Issues: http://github.com/kenwheeler/slick/issues
15
16 */
17(function($) {
18    'use strict';
19    var Slick = window.a4jSlick || {};
20
21    Slick = (function() {
22
23        var instanceUid = 0;
24
25        function Slick(element, settings) {
26
27            var _ = this, dataSettings;
28
29            _.defaults = {
30                accessibility: true,
31                adaptiveHeight: false,
32                appendArrows: $(element),
33                appendDots: $(element),
34                arrows: true,
35                asNavFor: null,
36                prevArrow: '<span data-role="none" class="a4j-slick-prev" aria-label="Previous" tabindex="0" role="button"><i class="ing-icon-angle-left ing-fw"></i></span>',
37                nextArrow: '<span data-role="none" class="a4j-slick-next" aria-label="Next" tabindex="0" role="button"><i class="ing-icon-angle-right ing-fw"></i></span>',
38                autoplay: false,
39                autoplaySpeed: 3000,
40                centerMode: false,
41                centerPadding: '50px',
42                cssEase: 'ease',
43                customPaging: function(slider, i) {
44                    return $('<i data-role="none" role="button" tabindex="0" />').text(i + 1);
45                },
46                dots: false,
47                dotsClass: 'a4j-slick-dots',
48                draggable: true,
49                easing: 'linear',
50                edgeFriction: 0.35,
51                fade: false,
52                focusOnSelect: false,
53                infinite: false,
54                initialSlide: 0,
55                lazyLoad: 'ondemand',
56                mobileFirst: false,
57                pauseOnHover: true,
58                pauseOnFocus: true,
59                pauseOnDotsHover: false,
60                respondTo: 'window',
61                responsive: null,
62                rows: 1,
63                rtl: false,
64                slide: '',
65                slidesPerRow: 1,
66                slidesToShow: 1,
67                slidesToScroll: 1,
68                speed: 500,
69                swipe: true,
70                swipeToSlide: false,
71                touchMove: true,
72                touchThreshold: 5,
73                useCSS: true,
74                useTransform: true,
75                variableWidth: false,
76                vertical: false,
77                verticalSwiping: false,
78                waitForAnimate: true,
79                zIndex: 1000
80            };
81
82            _.initials = {
83                animating: false,
84                dragging: false,
85                autoPlayTimer: null,
86                currentDirection: 0,
87                currentLeft: null,
88                currentSlide: 0,
89                direction: 1,
90                $dots: null,
91                listWidth: null,
92                listHeight: null,
93                loadIndex: 0,
94                $nextArrow: null,
95                $prevArrow: null,
96                slideCount: null,
97                slideWidth: null,
98                $slideTrack: null,
99                $slides: null,
100                sliding: false,
101                slideOffset: 0,
102                swipeLeft: null,
103                $list: null,
104                touchObject: {},
105                transformsEnabled: false,
106                unslicked: false
107            };
108
109            $.extend(_, _.initials);
110
111            _.activeBreakpoint = null;
112            _.animType = null;
113            _.animProp = null;
114            _.breakpoints = [];
115            _.breakpointSettings = [];
116            _.cssTransitions = false;
117            _.focussed = false;
118            _.interrupted = false;
119            _.hidden = 'hidden';
120            _.paused = true;
121            _.positionProp = null;
122            _.respondTo = null;
123            _.rowCount = 1;
124            _.shouldClick = true;
125            _.$slider = $(element);
126            _.$slidesCache = null;
127            _.transformType = null;
128            _.transitionType = null;
129            _.visibilityChange = 'visibilitychange';
130            _.windowWidth = 0;
131            _.windowTimer = null;
132
133            dataSettings = JSON.parse($(element).attr('data-slick') || '{}');
134
135            _.options = $.extend({}, _.defaults, settings, dataSettings);
136
137            _.currentSlide = _.options.initialSlide;
138
139            _.originalSettings = _.options;
140
141            if (typeof document.mozHidden !== 'undefined') {
142                _.hidden = 'mozHidden';
143                _.visibilityChange = 'mozvisibilitychange';
144            } else if (typeof document.webkitHidden !== 'undefined') {
145                _.hidden = 'webkitHidden';
146                _.visibilityChange = 'webkitvisibilitychange';
147            }
148
149            _.autoPlay = $.proxy(_.autoPlay, _);
150            _.autoPlayClear = $.proxy(_.autoPlayClear, _);
151            _.autoPlayIterator = $.proxy(_.autoPlayIterator, _);
152            _.changeSlide = $.proxy(_.changeSlide, _);
153            _.clickHandler = $.proxy(_.clickHandler, _);
154            _.selectHandler = $.proxy(_.selectHandler, _);
155            _.setPosition = $.proxy(_.setPosition, _);
156            _.swipeHandler = $.proxy(_.swipeHandler, _);
157            _.dragHandler = $.proxy(_.dragHandler, _);
158            _.keyHandler = $.proxy(_.keyHandler, _);
159
160            _.instanceUid = instanceUid++;
161
162            // A simple way to check for HTML strings
163            // Strict HTML recognition (must start with <)
164            // Extracted from jQuery v1.11 source
165            _.htmlExpr = /^(?:\s*(<[\w\W]+>)[^>]*)$/;
166
167
168            _.registerBreakpoints();
169            _.init(true);
170			
171			$(element).data('ingslick',_);
172        }
173
174        return Slick;
175
176    }());
177
178    Slick.prototype.activateADA = function() {
179        var _ = this;
180
181        _.$slideTrack.find('.a4j-slick-active').attr({
182            'aria-hidden': 'false'
183        }).find('a, input, button, select').attr({
184            'tabindex': '0'
185        });
186
187    };
188
189    Slick.prototype.addSlide = Slick.prototype.slickAdd = function(markup, index, addBefore) {
190		var _ = this;
191
192        if (typeof(index) === 'boolean') {
193            addBefore = index;
194            index = null;
195        } else if (index < 0 || (index >= _.slideCount)) {
196            return false;
197        }
198
199        _.unload();
200
201        if (typeof(index) === 'number') {
202            if (index === 0 && _.$slides.length === 0) {
203                _.getRowsItems($(markup)).appendTo(_.$slideTrack);
204            } else if (addBefore) {
205                _.getRowsItems($(markup)).insertBefore(_.$slides.eq(index));
206            } else {
207                _.getRowsItems($(markup)).insertAfter(_.$slides.eq(index));
208            }
209        } else {
210            if (addBefore === true) {
211                _.getRowsItems($(markup)).prependTo(_.$slideTrack);
212            } else {
213                _.getRowsItems($(markup)).appendTo(_.$slideTrack);
214            }
215        }
216
217        _.$slides = _.$slideTrack.children(this.options.slide);
218
219        _.$slideTrack.children(this.options.slide).detach();
220
221        _.$slideTrack.append(_.$slides);
222
223        _.$slides.each(function(index, element) {
224            $(element).attr('data-slick-index', index);
225        });
226
227        _.$slidesCache = _.$slides;
228
229        _.reinit();
230
231    };
232	
233	
234
235    Slick.prototype.animateHeight = function() {
236        var _ = this;
237        if (_.options.slidesToShow === 1 && _.options.adaptiveHeight === true && _.options.vertical === false) {
238            var targetHeight = _.$slides.eq(_.currentSlide).outerHeight(true);
239            _.$list.animate({
240                height: targetHeight
241            }, _.options.speed);
242        }
243    };
244
245    Slick.prototype.animateSlide = function(targetLeft, callback) {
246
247        var animProps = {},
248            _ = this;
249
250        _.animateHeight();
251
252        if (_.options.rtl === true && _.options.vertical === false) {
253            targetLeft = -targetLeft;
254        }
255        if (_.transformsEnabled === false) {
256            if (_.options.vertical === false) {
257                _.$slideTrack.animate({
258                    left: targetLeft
259                }, _.options.speed, _.options.easing, callback);
260            } else {
261                _.$slideTrack.animate({
262                    top: targetLeft
263                }, _.options.speed, _.options.easing, callback);
264            }
265
266        } else {
267
268            if (_.cssTransitions === false) {
269                if (_.options.rtl === true) {
270                    _.currentLeft = -(_.currentLeft);
271                }
272                $({
273                    animStart: _.currentLeft
274                }).animate({
275                    animStart: targetLeft
276                }, {
277                    duration: _.options.speed,
278                    easing: _.options.easing,
279                    step: function(now) {
280                        now = Math.ceil(now);
281                        if (_.options.vertical === false) {
282                            animProps[_.animType] = 'translate(' +
283                                now + 'px, 0px)';
284                            _.$slideTrack.css(animProps);
285                        } else {
286                            animProps[_.animType] = 'translate(0px,' +
287                                now + 'px)';
288                            _.$slideTrack.css(animProps);
289                        }
290                    },
291                    complete: function() {
292                        if (callback) {
293                            callback.call();
294                        }
295                    }
296                });
297
298            } else {
299
300                _.applyTransition();
301                targetLeft = Math.ceil(targetLeft);
302
303                if (_.options.vertical === false) {
304                    animProps[_.animType] = 'translate3d(' + targetLeft + 'px, 0px, 0px)';
305                } else {
306                    animProps[_.animType] = 'translate3d(0px,' + targetLeft + 'px, 0px)';
307                }
308                _.$slideTrack.css(animProps);
309
310                if (callback) {
311                    setTimeout(function() {
312
313                        _.disableTransition();
314
315                        callback.call();
316                    }, _.options.speed);
317                }
318
319            }
320
321        }
322
323    };
324
325    Slick.prototype.getNavTarget = function() {
326
327        var _ = this,
328            asNavFor = _.options.asNavFor;
329
330        if ( asNavFor && asNavFor !== null ) {
331            asNavFor = $(asNavFor).not(_.$slider);
332        }
333
334        return asNavFor;
335
336    };
337
338    Slick.prototype.asNavFor = function(index) {
339
340        var _ = this,
341            asNavFor = _.getNavTarget();
342
343        if ( asNavFor !== null && typeof asNavFor === 'object' ) {
344            asNavFor.each(function() {
345                var target = $(this).a4jslick('getSlick');
346                if(!target.unslicked) {
347                    target.slideHandler(index, true);
348                }
349            });
350        }
351
352    };
353
354    Slick.prototype.applyTransition = function(slide) {
355
356        var _ = this,
357            transition = {};
358
359        if (_.options.fade === false) {
360            transition[_.transitionType] = _.transformType + ' ' + _.options.speed + 'ms ' + _.options.cssEase;
361        } else {
362            transition[_.transitionType] = 'opacity ' + _.options.speed + 'ms ' + _.options.cssEase;
363        }
364
365        if (_.options.fade === false) {
366            _.$slideTrack.css(transition);
367        } else {
368            _.$slides.eq(slide).css(transition);
369        }
370
371    };
372
373    Slick.prototype.autoPlay = function() {
374
375        var _ = this;
376
377        _.autoPlayClear();
378
379        if ( _.slideCount > _.options.slidesToShow ) {
380            _.autoPlayTimer = setInterval( _.autoPlayIterator, _.options.autoplaySpeed );
381        }
382
383    };
384
385    Slick.prototype.autoPlayClear = function() {
386
387        var _ = this;
388
389        if (_.autoPlayTimer) {
390            clearInterval(_.autoPlayTimer);
391        }
392
393    };
394
395    Slick.prototype.autoPlayIterator = function() {
396
397        var _ = this,
398            slideTo = _.currentSlide + _.options.slidesToScroll;
399
400        if ( !_.paused && !_.interrupted && !_.focussed ) {
401
402            if ( _.options.infinite === false ) {
403
404                if ( _.direction === 1 && ( _.currentSlide + 1 ) === ( _.slideCount - 1 )) {
405                    _.direction = 0;
406                }
407
408                else if ( _.direction === 0 ) {
409
410                    slideTo = _.currentSlide - _.options.slidesToScroll;
411
412                    if ( _.currentSlide - 1 === 0 ) {
413                        _.direction = 1;
414                    }
415
416                }
417
418            }
419
420            _.slideHandler( slideTo );
421
422        }
423
424    };
425
426    Slick.prototype.buildArrows = function() {
427
428        var _ = this;
429
430        if (_.options.arrows === true ) {
431
432            _.$prevArrow = $(_.options.prevArrow).addClass('a4j-slick-arrow');
433            _.$nextArrow = $(_.options.nextArrow).addClass('a4j-slick-arrow');
434
435            if( _.slideCount > _.options.slidesToShow ) {
436
437                _.$prevArrow.removeClass('a4j-slick-hidden').removeAttr('aria-hidden tabindex');
438                _.$nextArrow.removeClass('a4j-slick-hidden').removeAttr('aria-hidden tabindex');
439
440                if (_.htmlExpr.test(_.options.prevArrow)) {
441                    _.$prevArrow.appendTo(_.options.appendArrows);
442                }
443
444                if (_.htmlExpr.test(_.options.nextArrow)) {
445                    _.$nextArrow.appendTo(_.options.appendArrows);
446                }
447
448                if (_.options.infinite !== true) {
449                    _.$prevArrow
450                        .addClass('a4j-slick-disabled')
451                        .attr('aria-disabled', 'true');
452                }
453
454            } else {
455
456                _.$prevArrow.add( _.$nextArrow )
457
458                    .addClass('a4j-slick-hidden')
459                    .attr({
460                        'aria-disabled': 'true',
461                        'tabindex': '-1'
462                    });
463
464            }
465
466        }
467
468    };
469
470    Slick.prototype.buildDots = function() {
471
472        var _ = this,
473            i, dot;
474
475        if (_.options.dots === true && _.slideCount > _.options.slidesToShow) {
476
477            _.$slider.addClass('a4j-slick-dotted');
478
479            dot = $('<div />').addClass(_.options.dotsClass);
480
481            for (i = 0; i <= _.getDotCount(); i += 1) {
482                dot.append(_.options.customPaging.call(this, _, i));
483            }
484
485            _.$dots = dot.appendTo(_.options.appendDots);
486
487            _.$dots.find('i').first().addClass('a4j-slick-active').attr('aria-hidden', 'false');
488
489        }
490
491    };
492
493    Slick.prototype.buildOut = function() {
494
495        var _ = this;
496
497        _.$slides =
498            _.$slider
499                .children( _.options.slide + ':not(.a4j-slick-cloned)')
500                .addClass('a4j-slick-slide');
501
502        _.slideCount = _.$slides.length;
503
504        _.$slides.each(function(index, element) {
505            $(element)
506                .attr('data-slick-index', index)
507                .data('originalStyling', $(element).attr('style') || '');
508        });
509
510        _.$slider.addClass('a4j-slick-slider');
511        _.$slider.addClass('a4j-slick-slider');
512
513        _.$slideTrack = (_.slideCount === 0) ?
514            $('<div class="a4j-slick-track"/>').appendTo(_.$slider) :
515            _.$slides.wrapAll('<div class="a4j-slick-track"/>').parent();
516
517        _.$list = _.$slideTrack.wrap(
518            '<div aria-live="polite" class="a4j-slick-list"/>').parent();
519        _.$slideTrack.css('opacity', 0);
520
521        if (_.options.centerMode === true || _.options.swipeToSlide === true) {
522            _.options.slidesToScroll = 1;
523        }
524
525        $('img[data-lazy]', _.$slider).not('[src]').addClass('a4j-slick-loading');
526
527        _.setupInfinite();
528
529        _.buildArrows();
530
531        _.buildDots();
532
533        _.updateDots();
534
535
536        _.setSlideClasses(typeof _.currentSlide === 'number' ? _.currentSlide : 0);
537
538        if (_.options.draggable === true) {
539            _.$list.addClass('draggable');
540        }
541
542    };
543
544    Slick.prototype.buildRows = function() {
545
546        var _ = this, a, b, c, newSlides, numOfSlides, originalSlides,slidesPerSection;
547
548        newSlides = document.createDocumentFragment();
549        originalSlides = _.$slider.children();
550
551        if(_.options.rows > 1) {
552
553            slidesPerSection = _.options.slidesPerRow * _.options.rows;
554            numOfSlides = Math.ceil(
555                originalSlides.length / slidesPerSection
556            );
557
558            for(a = 0; a < numOfSlides; a++){
559                var slide = document.createElement('div');
560                for(b = 0; b < _.options.rows; b++) {
561                    var row = document.createElement('div');
562					row.className = "ingallery-row";
563                    for(c = 0; c < _.options.slidesPerRow; c++) {
564                        var target = (a * slidesPerSection + ((b * _.options.slidesPerRow) + c));
565                        if (originalSlides.get(target)) {
566                            row.appendChild(originalSlides.get(target));
567                        }
568                    }
569                    slide.appendChild(row);
570                }
571                newSlides.appendChild(slide);
572            }
573
574            _.$slider.empty().append(newSlides);
575            _.$slider.children().children().children()
576                .css({
577                    'width':(100 / _.options.slidesPerRow) + '%',
578                });
579
580        }
581
582    };
583	
584    Slick.prototype.getRowsItems = function(_jqItems){
585		var _ = this;
586		if(_.options.rows <= 1){
587			return _jqItems;
588		}
589		var slide = $('<div></div>');
590		var index = 0;
591		for(var a=0;a<_.options.rows;a++) {
592			var row = $('<div class="ingallery-row"></div>');
593			slide.append(row);
594			for(var b=0;b<_.options.slidesPerRow;b++){
595				var _item = $(_jqItems.get(index)).css('width',(100 / _.options.slidesPerRow) + '%');
596				row.append(_item);
597				index++;
598			}
599		}
600        return slide;
601    };
602	
603    Slick.prototype.checkResponsive = function(initial, forceUpdate) {
604
605        var _ = this,
606            breakpoint, targetBreakpoint, respondToWidth, triggerBreakpoint = false;
607        var sliderWidth = _.$slider.width();
608        var windowWidth = window.innerWidth || $(window).width();
609
610        if (_.respondTo === 'window') {
611            respondToWidth = windowWidth;
612        } else if (_.respondTo === 'slider') {
613            respondToWidth = sliderWidth;
614        } else if (_.respondTo === 'min') {
615            respondToWidth = Math.min(windowWidth, sliderWidth);
616        }
617
618        if ( _.options.responsive &&
619            _.options.responsive.length &&
620            _.options.responsive !== null) {
621
622            targetBreakpoint = null;
623
624            for (breakpoint in _.breakpoints) {
625                if (_.breakpoints.hasOwnProperty(breakpoint)) {
626                    if (_.originalSettings.mobileFirst === false) {
627                        if (respondToWidth < _.breakpoints[breakpoint]) {
628                            targetBreakpoint = _.breakpoints[breakpoint];
629                        }
630                    } else {
631                        if (respondToWidth > _.breakpoints[breakpoint]) {
632                            targetBreakpoint = _.breakpoints[breakpoint];
633                        }
634                    }
635                }
636            }
637
638            if (targetBreakpoint !== null) {
639                if (_.activeBreakpoint !== null) {
640                    if (targetBreakpoint !== _.activeBreakpoint || forceUpdate) {
641                        _.activeBreakpoint =
642                            targetBreakpoint;
vendor: 15,717 bytes, lines 643-1132
643                        if (_.breakpointSettings[targetBreakpoint] === 'unslick') {
644                            _.unslick(targetBreakpoint);
645                        } else {
646                            _.options = $.extend({}, _.originalSettings,
647                                _.breakpointSettings[
648                                    targetBreakpoint]);
649                            if (initial === true) {
650                                _.currentSlide = _.options.initialSlide;
651                            }
652                            _.refresh(initial);
653                        }
654                        triggerBreakpoint = targetBreakpoint;
655                    }
656                } else {
657                    _.activeBreakpoint = targetBreakpoint;
658                    if (_.breakpointSettings[targetBreakpoint] === 'unslick') {
659                        _.unslick(targetBreakpoint);
660                    } else {
661                        _.options = $.extend({}, _.originalSettings,
662                            _.breakpointSettings[
663                                targetBreakpoint]);
664                        if (initial === true) {
665                            _.currentSlide = _.options.initialSlide;
666                        }
667                        _.refresh(initial);
668                    }
669                    triggerBreakpoint = targetBreakpoint;
670                }
671            } else {
672                if (_.activeBreakpoint !== null) {
673                    _.activeBreakpoint = null;
674                    _.options = _.originalSettings;
675                    if (initial === true) {
676                        _.currentSlide = _.options.initialSlide;
677                    }
678                    _.refresh(initial);
679                    triggerBreakpoint = targetBreakpoint;
680                }
681            }
682
683            // only trigger breakpoints during an actual break. not on initialize.
684            if( !initial && triggerBreakpoint !== false ) {
685                _.$slider.trigger('breakpoint', [_, triggerBreakpoint]);
686            }
687        }
688
689    };
690
691    Slick.prototype.changeSlide = function(event, dontAnimate) {
692
693        var _ = this,
694            $target = $(event.currentTarget),
695            indexOffset, slideOffset, unevenOffset;
696
697        // If target is a link, prevent default action.
698        if($target.is('a')) {
699            event.preventDefault();
700        }
701
702        // If target is not the <li> element (ie: a child), find the <li>.
703        if(!$target.is('i')) {
704            $target = $target.closest('i');
705        }
706
707        unevenOffset = (_.slideCount % _.options.slidesToScroll !== 0);
708        indexOffset = unevenOffset ? 0 : (_.slideCount - _.currentSlide) % _.options.slidesToScroll;
709
710        switch (event.data.message) {
711
712            case 'previous':
713                slideOffset = indexOffset === 0 ? _.options.slidesToScroll : _.options.slidesToShow - indexOffset;
714                if (_.slideCount > _.options.slidesToShow) {
715                    _.slideHandler(_.currentSlide - slideOffset, false, dontAnimate);
716                }
717                break;
718
719            case 'next':
720                slideOffset = indexOffset === 0 ? _.options.slidesToScroll : indexOffset;
721                if (_.slideCount > _.options.slidesToShow) {
722                    _.slideHandler(_.currentSlide + slideOffset, false, dontAnimate);
723                }
724                break;
725
726            case 'index':
727                var index = event.data.index === 0 ? 0 :
728                    event.data.index || $target.index() * _.options.slidesToScroll;
729
730                _.slideHandler(_.checkNavigable(index), false, dontAnimate);
731                $target.children().trigger('focus');
732                break;
733
734            default:
735                return;
736        }
737
738    };
739
740    Slick.prototype.checkNavigable = function(index) {
741
742        var _ = this,
743            navigables, prevNavigable;
744
745        navigables = _.getNavigableIndexes();
746        prevNavigable = 0;
747        if (index > navigables[navigables.length - 1]) {
748            index = navigables[navigables.length - 1];
749        } else {
750            for (var n in navigables) {
751                if (index < navigables[n]) {
752                    index = prevNavigable;
753                    break;
754                }
755                prevNavigable = navigables[n];
756            }
757        }
758
759        return index;
760    };
761
762    Slick.prototype.cleanUpEvents = function() {
763
764        var _ = this;
765
766        if (_.options.dots && _.$dots !== null) {
767
768            $('i', _.$dots)
769                .off('click.slick', _.changeSlide)
770                .off('mouseenter.slick', $.proxy(_.interrupt, _, true))
771                .off('mouseleave.slick', $.proxy(_.interrupt, _, false));
772
773        }
774
775        _.$slider.off('focus.slick blur.slick');
776
777        if (_.options.arrows === true && _.slideCount > _.options.slidesToShow) {
778            _.$prevArrow && _.$prevArrow.off('click.slick', _.changeSlide);
779            _.$nextArrow && _.$nextArrow.off('click.slick', _.changeSlide);
780        }
781
782        _.$list.off('touchstart.slick mousedown.slick', _.swipeHandler);
783        _.$list.off('touchmove.slick mousemove.slick', _.swipeHandler);
784        _.$list.off('touchend.slick mouseup.slick', _.swipeHandler);
785        _.$list.off('touchcancel.slick mouseleave.slick', _.swipeHandler);
786
787        _.$list.off('click.slick', _.clickHandler);
788
789        $(document).off(_.visibilityChange, _.visibility);
790
791        _.cleanUpSlideEvents();
792
793        if (_.options.accessibility === true) {
794            _.$list.off('keydown.slick', _.keyHandler);
795        }
796
797        if (_.options.focusOnSelect === true) {
798            $(_.$slideTrack).children().off('click.slick', _.selectHandler);
799        }
800
801        $(window).off('orientationchange.slick.slick-' + _.instanceUid, _.orientationChange);
802
803        $(window).off('resize.slick.slick-' + _.instanceUid, _.resize);
804
805        $('[draggable!=true]', _.$slideTrack).off('dragstart', _.preventDefault);
806
807        $(window).off('load.slick.slick-' + _.instanceUid, _.setPosition);
808        $(document).off('ready.slick.slick-' + _.instanceUid, _.setPosition);
809
810    };
811
812    Slick.prototype.cleanUpSlideEvents = function() {
813
814        var _ = this;
815
816        _.$list.off('mouseenter.slick', $.proxy(_.interrupt, _, true));
817        _.$list.off('mouseleave.slick', $.proxy(_.interrupt, _, false));
818
819    };
820
821    Slick.prototype.cleanUpRows = function() {
822
823        var _ = this, originalSlides;
824
825        if(_.options.rows > 1) {
826            originalSlides = _.$slides.children().children();
827            originalSlides.removeAttr('style');
828            _.$slider.empty().append(originalSlides);
829        }
830
831    };
832
833    Slick.prototype.clickHandler = function(event) {
834
835        var _ = this;
836
837        if (_.shouldClick === false) {
838            event.stopImmediatePropagation();
839            event.stopPropagation();
840            event.preventDefault();
841        }
842
843    };
844
845    Slick.prototype.destroy = function(refresh) {
846
847        var _ = this;
848
849        _.autoPlayClear();
850
851        _.touchObject = {};
852
853        _.cleanUpEvents();
854
855        $('.a4j-slick-cloned', _.$slider).detach();
856
857        if (_.$dots) {
858            _.$dots.remove();
859        }
860
861
862        if ( _.$prevArrow && _.$prevArrow.length ) {
863
864            _.$prevArrow
865                .removeClass('a4j-slick-disabled a4j-slick-arrow a4j-slick-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('a4j-slick-disabled a4j-slick-arrow a4j-slick-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
888        if (_.$slides) {
889
890            _.$slides
891                .removeClass('a4j-slick-slide a4j-slick-active a4j-slick-center a4j-slick-visible a4j-slick-current')
892                .removeAttr('aria-hidden')
893                .removeAttr('data-slick-index')
894                .each(function(){
895                    $(this).attr('style', $(this).data('originalStyling'));
896                });
897
898            _.$slideTrack.children(this.options.slide).detach();
899
900            _.$slideTrack.detach();
901
902            _.$list.detach();
903
904            _.$slider.append(_.$slides);
905        }
906
907        _.cleanUpRows();
908
909        _.$slider.removeClass('a4j-slick-slider');
910        _.$slider.removeClass('a4j-slick-initialized');
911        _.$slider.removeClass('a4j-slick-dotted');
912
913        _.unslicked = true;
914
915        if(!refresh) {
916            _.$slider.trigger('destroy', [_]);
917        }
918
919    };
920
921    Slick.prototype.disableTransition = function(slide) {
922
923        var _ = this,
924            transition = {};
925
926        transition[_.transitionType] = '';
927
928        if (_.options.fade === false) {
929            _.$slideTrack.css(transition);
930        } else {
931            _.$slides.eq(slide).css(transition);
932        }
933
934    };
935
936    Slick.prototype.fadeSlide = function(slideIndex, callback) {
937
938        var _ = this;
939
940        if (_.cssTransitions === false) {
941
942            _.$slides.eq(slideIndex).css({
943                zIndex: _.options.zIndex
944            });
945
946            _.$slides.eq(slideIndex).animate({
947                opacity: 1
948            }, _.options.speed, _.options.easing, callback);
949
950        } else {
951
952            _.applyTransition(slideIndex);
953
954            _.$slides.eq(slideIndex).css({
955                opacity: 1,
956                zIndex: _.options.zIndex
957            });
958
959            if (callback) {
960                setTimeout(function() {
961
962                    _.disableTransition(slideIndex);
963
964                    callback.call();
965                }, _.options.speed);
966            }
967
968        }
969
970    };
971
972    Slick.prototype.fadeSlideOut = function(slideIndex) {
973
974        var _ = this;
975
976        if (_.cssTransitions === false) {
977
978            _.$slides.eq(slideIndex).animate({
979                opacity: 0,
980                zIndex: _.options.zIndex - 2
981            }, _.options.speed, _.options.easing);
982
983        } else {
984
985            _.applyTransition(slideIndex);
986
987            _.$slides.eq(slideIndex).css({
988                opacity: 0,
989                zIndex: _.options.zIndex - 2
990            });
991
992        }
993
994    };
995
996    Slick.prototype.filterSlides = Slick.prototype.slickFilter = function(filter) {
997
998        var _ = this;
999
1000        if (filter !== null) {
1001
1002            _.$slidesCache = _.$slides;
1003
1004            _.unload();
1005
1006            _.$slideTrack.children(this.options.slide).detach();
1007
1008            _.$slidesCache.filter(filter).appendTo(_.$slideTrack);
1009
1010            _.reinit();
1011
1012        }
1013
1014    };
1015
1016    Slick.prototype.focusHandler = function() {
1017
1018        var _ = this;
1019
1020        _.$slider
1021            .off('focus.slick blur.slick')
1022            .on('focus.slick blur.slick',
1023                '*:not(.a4j-slick-arrow)', function(event) {
1024
1025            event.stopImmediatePropagation();
1026            var $sf = $(this);
1027
1028            setTimeout(function() {
1029
1030                if( _.options.pauseOnFocus ) {
1031                    _.focussed = $sf.is(':focus');
1032                    _.autoPlay();
1033                }
1034
1035            }, 0);
1036
1037        });
1038    };
1039
1040    Slick.prototype.getCurrent = Slick.prototype.slickCurrentSlide = function() {
1041
1042        var _ = this;
1043        return _.currentSlide;
1044
1045    };
1046
1047    Slick.prototype.getDotCount = function() {
1048
1049        var _ = this;
1050
1051        var breakPoint = 0;
1052        var counter = 0;
1053        var pagerQty = 0;
1054
1055        if (_.options.infinite === true) {
1056            while (breakPoint < _.slideCount) {
1057                ++pagerQty;
1058                breakPoint = counter + _.options.slidesToScroll;
1059                counter += _.options.slidesToScroll <= _.options.slidesToShow ? _.options.slidesToScroll : _.options.slidesToShow;
1060            }
1061        } else if (_.options.centerMode === true) {
1062            pagerQty = _.slideCount;
1063        } else if(!_.options.asNavFor) {
1064            pagerQty = 1 + Math.ceil((_.slideCount - _.options.slidesToShow) / _.options.slidesToScroll);
1065        }else {
1066            while (breakPoint < _.slideCount) {
1067                ++pagerQty;
1068                breakPoint = counter + _.options.slidesToScroll;
1069                counter += _.options.slidesToScroll <= _.options.slidesToShow ? _.options.slidesToScroll : _.options.slidesToShow;
1070            }
1071        }
1072
1073        return pagerQty - 1;
1074
1075    };
1076
1077    Slick.prototype.getLeft = function(slideIndex) {
1078
1079        var _ = this,
1080            targetLeft,
1081            verticalHeight,
1082            verticalOffset = 0,
1083            targetSlide;
1084
1085        _.slideOffset = 0;
1086        verticalHeight = _.$slides.first().outerHeight(true);
1087
1088        if (_.options.infinite === true) {
1089            if (_.slideCount > _.options.slidesToShow) {
1090                _.slideOffset = (_.slideWidth * _.options.slidesToShow) * -1;
1091                verticalOffset = (verticalHeight * _.options.slidesToShow) * -1;
1092            }
1093            if (_.slideCount % _.options.slidesToScroll !== 0) {
1094                if (slideIndex + _.options.slidesToScroll > _.slideCount && _.slideCount > _.options.slidesToShow) {
1095                    if (slideIndex > _.slideCount) {
1096                        _.slideOffset = ((_.options.slidesToShow - (slideIndex - _.slideCount)) * _.slideWidth) * -1;
1097                        verticalOffset = ((_.options.slidesToShow - (slideIndex - _.slideCount)) * verticalHeight) * -1;
1098                    } else {
1099                        _.slideOffset = ((_.slideCount % _.options.slidesToScroll) * _.slideWidth) * -1;
1100                        verticalOffset = ((_.slideCount % _.options.slidesToScroll) * verticalHeight) * -1;
1101                    }
1102                }
1103            }
1104        } else {
1105            if (slideIndex + _.options.slidesToShow > _.slideCount) {
1106                _.slideOffset = ((slideIndex + _.options.slidesToShow) - _.slideCount) * _.slideWidth;
1107                verticalOffset = ((slideIndex + _.options.slidesToShow) - _.slideCount) * verticalHeight;
1108            }
1109        }
1110
1111        if (_.slideCount <= _.options.slidesToShow) {
1112            _.slideOffset = 0;
1113            verticalOffset = 0;
1114        }
1115
1116        if (_.options.centerMode === true && _.slideCount <= _.options.slidesToShow) {
1117            _.slideOffset = ((_.slideWidth * Math.floor(_.options.slidesToShow)) / 2) - ((_.slideWidth * _.slideCount) / 2);
1118        } else if (_.options.centerMode === true && _.options.infinite === true) {
1119            _.slideOffset += _.slideWidth * Math.floor(_.options.slidesToShow / 2) - _.slideWidth;
1120        } else if (_.options.centerMode === true) {
1121            _.slideOffset = 0;
1122            _.slideOffset += _.slideWidth * Math.floor(_.options.slidesToShow / 2);
1123        }
1124
1125        if (_.options.vertical === false) {
1126            targetLeft = ((slideIndex * _.slideWidth) * -1) + _.slideOffset;
1127        } else {
1128            targetLeft = ((slideIndex * verticalHeight) * -1) + verticalOffset;
1129        }
1130
1131        if (_.options.variableWidth === true) {
1132
1133            if (_.slideCount <= _.options.slidesToShow || _.options.infinite === false) {
1134                targetSlide = _.$slideTrack.children('.a4j-slick-slide').eq(slideIndex);
1135            } else {
1136                targetSlide = _.$slideTrack.children('.a4j-slick-slide').eq(slideIndex + _.options.slidesToShow);
1137            }
1138
1139            if (_.options.rtl === true) {
1140                if (targetSlide[0]) {
1141                    targetLeft = (_.$slideTrack.width() - targetSlide[0].offsetLeft - targetSlide.width()) * -1;
1142                } else {
1143                    targetLeft =  0;
1144                }
1145            } else {
1146                targetLeft = targetSlide[0] ? targetSlide[0].offsetLeft * -1 : 0;
1147            }
1148
1149            if (_.options.centerMode === true) {
1150                if (_.slideCount <= _.options.slidesToShow || _.options.infinite === false) {
1151                    targetSlide = _.$slideTrack.children('.a4j-slick-slide').eq(slideIndex);
1152                } else {
1153                    targetSlide = _.$slideTrack.children('.a4j-slick-slide').eq(slideIndex + _.options.slidesToShow + 1);
1154                }
1155
1156                if (_.options.rtl === true) {
1157                    if (targetSlide[0]) {
1158                        targetLeft = (_.$slideTrack.width() - targetSlide[0].offsetLeft - targetSlide.width()) * -1;
1159                    } else {
1160                        targetLeft =  0;
1161                    }
1162                } else {
1163                    targetLeft = targetSlide[0] ? targetSlide[0].offsetLeft * -1 : 0;
1164                }
1165
1166                targetLeft += (_.$list.width() - targetSlide.outerWidth()) / 2;
1167            }
1168        }
1169
1170        return targetLeft;
1171
1172    };
1173
1174    Slick.prototype.getOption = Slick.prototype.slickGetOption = function(option) {
1175
1176        var _ = this;
1177
1178        return _.options[option];
1179
1180    };
1181
1182    Slick.prototype.getNavigableIndexes = function() {
1183
1184        var _ = this,
1185            breakPoint = 0,
1186            counter = 0,
1187            indexes = [],
1188            max;
1189
1190        if (_.options.infinite === false) {
1191            max = _.slideCount;
1192        } else {
1193            breakPoint = _.options.slidesToScroll * -1;
1194            counter = _.options.slidesToScroll * -1;
1195            max = _.slideCount * 2;
1196        }
1197
1198        while (breakPoint < max) {
1199            indexes.push(breakPoint);
1200            breakPoint = counter + _.options.slidesToScroll;
1201            counter += _.options.slidesToScroll <= _.options.slidesToShow ? _.options.slidesToScroll : _.options.slidesToShow;
1202        }
1203
1204        return indexes;
1205
1206    };
1207
1208    Slick.prototype.getSlick = function() {
1209
1210        return this;
1211
1212    };
1213
1214    Slick.prototype.getSlideCount = function() {
1215
1216        var _ = this,
1217            slidesTraversed, swipedSlide, centerOffset;
1218
1219        centerOffset = _.options.centerMode === true ? _.slideWidth * Math.floor(_.options.slidesToShow / 2) : 0;
1220
1221        if (_.options.swipeToSlide === true) {
1222            _.$slideTrack.find('.a4j-slick-slide').each(function(index, slide) {
1223                if (slide.offsetLeft - centerOffset + ($(slide).outerWidth() / 2) > (_.swipeLeft * -1)) {
1224                    swipedSlide = slide;
1225                    return false;
1226                }
1227            });
1228
1229            slidesTraversed = Math.abs($(swipedSlide).attr('data-slick-index') - _.currentSlide) || 1;
1230
1231            return slidesTraversed;
1232
1233        } else {
1234            return _.options.slidesToScroll;
1235        }
1236
1237    };
1238
1239    Slick.prototype.goTo = Slick.prototype.slickGoTo = function(slide, dontAnimate) {
1240
1241        var _ = this;
1242
1243        _.changeSlide({
1244            data: {
1245                message: 'index',
1246                index: parseInt(slide)
1247            }
1248        }, dontAnimate);
1249
1250    };
1251
1252    Slick.prototype.init = function(creation) {
1253
1254        var _ = this;
1255        if (!_.$slider.hasClass('a4j-slick-initialized')) {
1256
1257            _.$slider.addClass('a4j-slick-initialized');
1258
1259            _.buildRows();
1260            _.buildOut();
1261            _.setProps();
1262            _.startLoad();
1263            _.loadSlider();
1264            _.initializeEvents();
1265            _.updateArrows();
1266            _.updateDots();
1267            _.checkResponsive(true);
1268            _.focusHandler();
1269
1270        }
1271
1272        if (creation) {
1273            _.$slider.trigger('init', [_]);
1274        }
1275
1276        if (_.options.accessibility === true) {
1277            _.initADA();
1278        }
1279
1280        if ( _.options.autoplay ) {
1281
1282            _.paused = false;
1283            _.autoPlay();
1284
1285        }
1286
1287    };
1288
1289    Slick.prototype.initADA = function() {
1290        var _ = this;
1291        _.$slides.add(_.$slideTrack.find('.a4j-slick-cloned')).attr({
1292            'aria-hidden': 'true',
1293            'tabindex': '-1'
1294        }).find('a, input, button, select').attr({
1295            'tabindex': '-1'
1296        });
1297
1298        _.$slideTrack.attr('role', 'listbox');
1299
1300        _.$slides.not(_.$slideTrack.find('.a4j-slick-cloned')).each(function(i) {
1301            $(this).attr('role', 'option');
1302            
1303            //Evenly distribute aria-describedby tags through available dots.
1304            var describedBySlideId = _.options.centerMode ? i : Math.floor(i / _.options.slidesToShow);
1305            
1306            if (_.options.dots === true) {
1307                $(this).attr('aria-describedby', 'slick-slide' + _.instanceUid + describedBySlideId + '');
1308            }
1309        });
1310
1311        if (_.$dots !== null) {
1312            _.$dots.attr('role', 'tablist').find('i').each(function(i) {
1313                $(this).attr({
1314                    'role': 'presentation',
1315                    'aria-selected': 'false',
1316                    'aria-controls': 'navigation' + _.instanceUid + i + '',
1317                    'id': 'slick-slide' + _.instanceUid + i + ''
1318                });
1319            })
1320                .first().attr('aria-selected', 'true').end()
1321                .find('button').attr('role', 'button').end()
1322                .closest('div').attr('role', 'toolbar');
1323        }
1324        _.activateADA();
1325
1326    };
1327
1328    Slick.prototype.initArrowEvents = function() {
1329
1330        var _ = this;
1331
1332        if (_.options.arrows === true && _.slideCount > _.options.slidesToShow) {
1333            _.$prevArrow
1334               .off('click.slick')
1335               .on('click.slick', {
1336                    message: 'previous'
1337               }, _.changeSlide);
1338            _.$nextArrow
1339               .off('click.slick')
1340               .on('click.slick', {
1341                    message: 'next'
1342               }, _.changeSlide);
1343        }
1344
1345    };
1346
1347    Slick.prototype.initDotEvents = function() {
1348
1349        var _ = this;
1350
1351        if (_.options.dots === true && _.slideCount > _.options.slidesToShow) {
1352            $('i', _.$dots).on('click.slick', {
1353                message: 'index'
1354            }, _.changeSlide);
1355        }
1356
1357        if ( _.options.dots === true && _.options.pauseOnDotsHover === true ) {
1358
1359            $('i', _.$dots)
1360                .on('mouseenter.slick', $.proxy(_.interrupt, _, true))
vendor: 22,267 bytes, lines 1361-2151
1361                .on('mouseleave.slick', $.proxy(_.interrupt, _, false));
1362
1363        }
1364
1365    };
1366
1367    Slick.prototype.initSlideEvents = function() {
1368
1369        var _ = this;
1370
1371        if ( _.options.pauseOnHover ) {
1372
1373            _.$list.on('mouseenter.slick', $.proxy(_.interrupt, _, true));
1374            _.$list.on('mouseleave.slick', $.proxy(_.interrupt, _, false));
1375
1376        }
1377
1378    };
1379
1380    Slick.prototype.initializeEvents = function() {
1381
1382        var _ = this;
1383
1384        _.initArrowEvents();
1385
1386        _.initDotEvents();
1387        _.initSlideEvents();
1388
1389        _.$list.on('touchstart.slick mousedown.slick', {
1390            action: 'start'
1391        }, _.swipeHandler);
1392        _.$list.on('touchmove.slick mousemove.slick', {
1393            action: 'move'
1394        }, _.swipeHandler);
1395        _.$list.on('touchend.slick mouseup.slick', {
1396            action: 'end'
1397        }, _.swipeHandler);
1398        _.$list.on('touchcancel.slick mouseleave.slick', {
1399            action: 'end'
1400        }, _.swipeHandler);
1401
1402        _.$list.on('click.slick', _.clickHandler);
1403
1404        $(document).on(_.visibilityChange, $.proxy(_.visibility, _));
1405
1406        if (_.options.accessibility === true) {
1407            _.$list.on('keydown.slick', _.keyHandler);
1408        }
1409
1410        if (_.options.focusOnSelect === true) {
1411            $(_.$slideTrack).children().on('click.slick', _.selectHandler);
1412        }
1413
1414        $(window).on('orientationchange.slick.slick-' + _.instanceUid, $.proxy(_.orientationChange, _));
1415
1416        $(window).on('resize.slick.slick-' + _.instanceUid, $.proxy(_.resize, _));
1417
1418        $('[draggable!=true]', _.$slideTrack).on('dragstart', _.preventDefault);
1419
1420        $(window).on('load.slick.slick-' + _.instanceUid, _.setPosition);
1421        $(document).on('ready.slick.slick-' + _.instanceUid, _.setPosition);
1422
1423    };
1424
1425    Slick.prototype.initUI = function() {
1426
1427        var _ = this;
1428
1429        if (_.options.arrows === true && _.slideCount > _.options.slidesToShow) {
1430
1431            _.$prevArrow.show();
1432            _.$nextArrow.show();
1433
1434        }
1435
1436        if (_.options.dots === true && _.slideCount > _.options.slidesToShow) {
1437
1438            _.$dots.show();
1439
1440        }
1441
1442    };
1443
1444    Slick.prototype.keyHandler = function(event) {
1445
1446        var _ = this;
1447         //Dont slide if the cursor is inside the form fields and arrow keys are pressed
1448        if(!event.target.tagName.match('TEXTAREA|INPUT|SELECT')) {
1449            if (event.keyCode === 37 && _.options.accessibility === true) {
1450                _.changeSlide({
1451                    data: {
1452                        message: _.options.rtl === true ? 'next' :  'previous'
1453                    }
1454                });
1455            } else if (event.keyCode === 39 && _.options.accessibility === true) {
1456                _.changeSlide({
1457                    data: {
1458                        message: _.options.rtl === true ? 'previous' : 'next'
1459                    }
1460                });
1461            }
1462        }
1463
1464    };
1465
1466    Slick.prototype.lazyLoad = function() {
1467
1468        var _ = this,
1469            loadRange, cloneRange, rangeStart, rangeEnd;
1470
1471        function loadImages(imagesScope) {
1472
1473            $('img[data-lazy]', imagesScope).each(function() {
1474
1475                var image = $(this),
1476                    imageSource = $(this).attr('data-lazy'),
1477                    imageToLoad = document.createElement('img');
1478
1479                imageToLoad.onload = function() {
1480
1481                    image
1482                        .animate({ opacity: 0 }, 100, function() {
1483                            image
1484                                .attr('src', imageSource)
1485                                .animate({ opacity: 1 }, 200, function() {
1486                                    image
1487                                        .removeAttr('data-lazy')
1488                                        .removeClass('a4j-slick-loading');
1489                                });
1490                            _.$slider.trigger('lazyLoaded', [_, image, imageSource]);
1491                        });
1492
1493                };
1494
1495                imageToLoad.onerror = function() {
1496
1497                    image
1498                        .removeAttr( 'data-lazy' )
1499                        .removeClass( 'a4j-slick-loading' )
1500                        .addClass( 'a4j-slick-lazyload-error' );
1501
1502                    _.$slider.trigger('lazyLoadError', [ _, image, imageSource ]);
1503
1504                };
1505
1506                imageToLoad.src = imageSource;
1507
1508            });
1509
1510        }
1511
1512        if (_.options.centerMode === true) {
1513            if (_.options.infinite === true) {
1514                rangeStart = _.currentSlide + (_.options.slidesToShow / 2 + 1);
1515                rangeEnd = rangeStart + _.options.slidesToShow + 2;
1516            } else {
1517                rangeStart = Math.max(0, _.currentSlide - (_.options.slidesToShow / 2 + 1));
1518                rangeEnd = 2 + (_.options.slidesToShow / 2 + 1) + _.currentSlide;
1519            }
1520        } else {
1521            rangeStart = _.options.infinite ? _.options.slidesToShow + _.currentSlide : _.currentSlide;
1522            rangeEnd = Math.ceil(rangeStart + _.options.slidesToShow);
1523            if (_.options.fade === true) {
1524                if (rangeStart > 0) rangeStart--;
1525                if (rangeEnd <= _.slideCount) rangeEnd++;
1526            }
1527        }
1528
1529        loadRange = _.$slider.find('.a4j-slick-slide').slice(rangeStart, rangeEnd);
1530        loadImages(loadRange);
1531
1532        if (_.slideCount <= _.options.slidesToShow) {
1533            cloneRange = _.$slider.find('.a4j-slick-slide');
1534            loadImages(cloneRange);
1535        } else
1536        if (_.currentSlide >= _.slideCount - _.options.slidesToShow) {
1537            cloneRange = _.$slider.find('.a4j-slick-cloned').slice(0, _.options.slidesToShow);
1538            loadImages(cloneRange);
1539        } else if (_.currentSlide === 0) {
1540            cloneRange = _.$slider.find('.a4j-slick-cloned').slice(_.options.slidesToShow * -1);
1541            loadImages(cloneRange);
1542        }
1543
1544    };
1545
1546    Slick.prototype.loadSlider = function() {
1547
1548        var _ = this;
1549
1550        _.setPosition();
1551
1552        _.$slideTrack.css({
1553            opacity: 1
1554        });
1555
1556        _.$slider.removeClass('a4j-slick-loading');
1557
1558        _.initUI();
1559
1560        if (_.options.lazyLoad === 'progressive') {
1561            _.progressiveLazyLoad();
1562        }
1563
1564    };
1565
1566    Slick.prototype.next = Slick.prototype.slickNext = function() {
1567
1568        var _ = this;
1569
1570        _.changeSlide({
1571            data: {
1572                message: 'next'
1573            }
1574        });
1575
1576    };
1577
1578    Slick.prototype.orientationChange = function() {
1579
1580        var _ = this;
1581
1582        _.checkResponsive();
1583        _.setPosition();
1584
1585    };
1586
1587    Slick.prototype.pause = Slick.prototype.slickPause = function() {
1588
1589        var _ = this;
1590
1591        _.autoPlayClear();
1592        _.paused = true;
1593
1594    };
1595
1596    Slick.prototype.play = Slick.prototype.slickPlay = function() {
1597
1598        var _ = this;
1599
1600        _.autoPlay();
1601        _.options.autoplay = true;
1602        _.paused = false;
1603        _.focussed = false;
1604        _.interrupted = false;
1605
1606    };
1607
1608    Slick.prototype.postSlide = function(index) {
1609
1610        var _ = this;
1611
1612        if( !_.unslicked ) {
1613
1614            _.$slider.trigger('afterChange', [_, index]);
1615
1616            _.animating = false;
1617
1618            _.setPosition();
1619
1620            _.swipeLeft = null;
1621
1622            if ( _.options.autoplay ) {
1623                _.autoPlay();
1624            }
1625
1626            if (_.options.accessibility === true) {
1627                _.initADA();
1628            }
1629
1630        }
1631
1632    };
1633
1634    Slick.prototype.prev = Slick.prototype.slickPrev = function() {
1635
1636        var _ = this;
1637
1638        _.changeSlide({
1639            data: {
1640                message: 'previous'
1641            }
1642        });
1643
1644    };
1645
1646    Slick.prototype.preventDefault = function(event) {
1647
1648        event.preventDefault();
1649
1650    };
1651
1652    Slick.prototype.progressiveLazyLoad = function( tryCount ) {
1653
1654        tryCount = tryCount || 1;
1655
1656        var _ = this,
1657            $imgsToLoad = $( 'img[data-lazy]', _.$slider ),
1658            image,
1659            imageSource,
1660            imageToLoad;
1661
1662        if ( $imgsToLoad.length ) {
1663
1664            image = $imgsToLoad.first();
1665            imageSource = image.attr('data-lazy');
1666            imageToLoad = document.createElement('img');
1667
1668            imageToLoad.onload = function() {
1669
1670                image
1671                    .attr( 'src', imageSource )
1672                    .removeAttr('data-lazy')
1673                    .removeClass('a4j-slick-loading');
1674
1675                if ( _.options.adaptiveHeight === true ) {
1676                    _.setPosition();
1677                }
1678
1679                _.$slider.trigger('lazyLoaded', [ _, image, imageSource ]);
1680                _.progressiveLazyLoad();
1681
1682            };
1683
1684            imageToLoad.onerror = function() {
1685
1686                if ( tryCount < 3 ) {
1687
1688                    /**
1689                     * try to load the image 3 times,
1690                     * leave a slight delay so we don't get
1691                     * servers blocking the request.
1692                     */
1693                    setTimeout( function() {
1694                        _.progressiveLazyLoad( tryCount + 1 );
1695                    }, 500 );
1696
1697                } else {
1698
1699                    image
1700                        .removeAttr( 'data-lazy' )
1701                        .removeClass( 'a4j-slick-loading' )
1702                        .addClass( 'a4j-slick-lazyload-error' );
1703
1704                    _.$slider.trigger('lazyLoadError', [ _, image, imageSource ]);
1705
1706                    _.progressiveLazyLoad();
1707
1708                }
1709
1710            };
1711
1712            imageToLoad.src = imageSource;
1713
1714        } else {
1715
1716            _.$slider.trigger('allImagesLoaded', [ _ ]);
1717
1718        }
1719
1720    };
1721
1722    Slick.prototype.refresh = function( initializing ) {
1723
1724        var _ = this, currentSlide, lastVisibleIndex;
1725
1726        lastVisibleIndex = _.slideCount - _.options.slidesToShow;
1727
1728        // in non-infinite sliders, we don't want to go past the
1729        // last visible index.
1730        if( !_.options.infinite && ( _.currentSlide > lastVisibleIndex )) {
1731            _.currentSlide = lastVisibleIndex;
1732        }
1733
1734        // if less slides than to show, go to start.
1735        if ( _.slideCount <= _.options.slidesToShow ) {
1736            _.currentSlide = 0;
1737
1738        }
1739
1740        currentSlide = _.currentSlide;
1741
1742        _.destroy(true);
1743
1744        $.extend(_, _.initials, { currentSlide: currentSlide });
1745
1746        _.init();
1747
1748        if( !initializing ) {
1749
1750            _.changeSlide({
1751                data: {
1752                    message: 'index',
1753                    index: currentSlide
1754                }
1755            }, false);
1756
1757        }
1758
1759    };
1760
1761    Slick.prototype.registerBreakpoints = function() {
1762
1763        var _ = this, breakpoint, currentBreakpoint, l,
1764            responsiveSettings = _.options.responsive || null;
1765
1766        if ( $.type(responsiveSettings) === 'array' && responsiveSettings.length ) {
1767
1768            _.respondTo = _.options.respondTo || 'window';
1769
1770            for ( breakpoint in responsiveSettings ) {
1771
1772                l = _.breakpoints.length-1;
1773                currentBreakpoint = responsiveSettings[breakpoint].breakpoint;
1774
1775                if (responsiveSettings.hasOwnProperty(breakpoint)) {
1776
1777                    // loop through the breakpoints and cut out any existing
1778                    // ones with the same breakpoint number, we don't want dupes.
1779                    while( l >= 0 ) {
1780                        if( _.breakpoints[l] && _.breakpoints[l] === currentBreakpoint ) {
1781                            _.breakpoints.splice(l,1);
1782                        }
1783                        l--;
1784                    }
1785
1786                    _.breakpoints.push(currentBreakpoint);
1787                    _.breakpointSettings[currentBreakpoint] = responsiveSettings[breakpoint].settings;
1788
1789                }
1790
1791            }
1792
1793            _.breakpoints.sort(function(a, b) {
1794                return ( _.options.mobileFirst ) ? a-b : b-a;
1795            });
1796
1797        }
1798
1799    };
1800
1801    Slick.prototype.reinit = function() {
1802
1803        var _ = this;
1804
1805        _.$slides =
1806            _.$slideTrack
1807                .children(_.options.slide)
1808                .addClass('a4j-slick-slide');
1809
1810        _.slideCount = _.$slides.length;
1811
1812        if (_.currentSlide >= _.slideCount && _.currentSlide !== 0) {
1813            _.currentSlide = _.currentSlide - _.options.slidesToScroll;
1814        }
1815
1816        if (_.slideCount <= _.options.slidesToShow) {
1817            _.currentSlide = 0;
1818        }
1819
1820        _.registerBreakpoints();
1821
1822        _.setProps();
1823        _.setupInfinite();
1824        _.buildArrows();
1825        _.updateArrows();
1826        _.initArrowEvents();
1827        _.buildDots();
1828        _.updateDots();
1829        _.initDotEvents();
1830        _.cleanUpSlideEvents();
1831        _.initSlideEvents();
1832
1833        _.checkResponsive(false, true);
1834
1835        if (_.options.focusOnSelect === true) {
1836            $(_.$slideTrack).children().on('click.slick', _.selectHandler);
1837        }
1838
1839        _.setSlideClasses(typeof _.currentSlide === 'number' ? _.currentSlide : 0);
1840
1841        _.setPosition();
1842        _.focusHandler();
1843
1844        _.paused = !_.options.autoplay;
1845        _.autoPlay();
1846
1847        _.$slider.trigger('reInit', [_]);
1848
1849    };
1850
1851    Slick.prototype.resize = function() {
1852
1853        var _ = this;
1854
1855        if ($(window).width() !== _.windowWidth) {
1856            clearTimeout(_.windowDelay);
1857            _.windowDelay = window.setTimeout(function() {
1858                _.windowWidth = $(window).width();
1859                _.checkResponsive();
1860                if( !_.unslicked ) { _.setPosition(); }
1861            }, 50);
1862        }
1863    };
1864
1865    Slick.prototype.removeSlide = Slick.prototype.slickRemove = function(index, removeBefore, removeAll) {
1866
1867        var _ = this;
1868
1869        if (typeof(index) === 'boolean') {
1870            removeBefore = index;
1871            index = removeBefore === true ? 0 : _.slideCount - 1;
1872        } else {
1873            index = removeBefore === true ? --index : index;
1874        }
1875
1876        if (_.slideCount < 1 || index < 0 || index > _.slideCount - 1) {
1877            return false;
1878        }
1879
1880        _.unload();
1881
1882        if (removeAll === true) {
1883            _.$slideTrack.children().remove();
1884        } else {
1885            _.$slideTrack.children(this.options.slide).eq(index).remove();
1886        }
1887
1888        _.$slides = _.$slideTrack.children(this.options.slide);
1889
1890        _.$slideTrack.children(this.options.slide).detach();
1891
1892        _.$slideTrack.append(_.$slides);
1893
1894        _.$slidesCache = _.$slides;
1895
1896        _.reinit();
1897
1898    };
1899
1900    Slick.prototype.setCSS = function(position) {
1901
1902        var _ = this,
1903            positionProps = {},
1904            x, y;
1905
1906        if (_.options.rtl === true) {
1907            position = -position;
1908        }
1909        x = _.positionProp == 'left' ? Math.ceil(position) + 'px' : '0px';
1910        y = _.positionProp == 'top' ? Math.ceil(position) + 'px' : '0px';
1911
1912        positionProps[_.positionProp] = position;
1913
1914        if (_.transformsEnabled === false) {
1915            _.$slideTrack.css(positionProps);
1916        } else {
1917            positionProps = {};
1918            if (_.cssTransitions === false) {
1919                positionProps[_.animType] = 'translate(' + x + ', ' + y + ')';
1920                _.$slideTrack.css(positionProps);
1921            } else {
1922                positionProps[_.animType] = 'translate3d(' + x + ', ' + y + ', 0px)';
1923                _.$slideTrack.css(positionProps);
1924            }
1925        }
1926
1927    };
1928
1929    Slick.prototype.setDimensions = function() {
1930
1931        var _ = this;
1932
1933        if (_.options.vertical === false) {
1934            if (_.options.centerMode === true) {
1935                _.$list.css({
1936                    padding: ('0px ' + _.options.centerPadding)
1937                });
1938            }
1939        } else {
1940            _.$list.height(_.$slides.first().outerHeight(true) * _.options.slidesToShow);
1941            if (_.options.centerMode === true) {
1942                _.$list.css({
1943                    padding: (_.options.centerPadding + ' 0px')
1944                });
1945            }
1946        }
1947
1948        _.listWidth = _.$list.width();
1949        _.listHeight = _.$list.height();
1950
1951
1952        if (_.options.vertical === false && _.options.variableWidth === false) {
1953            _.slideWidth = Math.ceil(_.listWidth / _.options.slidesToShow);
1954            _.$slideTrack.width(Math.ceil((_.slideWidth * _.$slideTrack.children('.a4j-slick-slide').length)));
1955
1956        } else if (_.options.variableWidth === true) {
1957            _.$slideTrack.width(5000 * _.slideCount);
1958        } else {
1959            _.slideWidth = Math.ceil(_.listWidth);
1960            _.$slideTrack.height(Math.ceil((_.$slides.first().outerHeight(true) * _.$slideTrack.children('.a4j-slick-slide').length)));
1961        }
1962
1963        var offset = _.$slides.first().outerWidth(true) - _.$slides.first().width();
1964        if (_.options.variableWidth === false) _.$slideTrack.children('.a4j-slick-slide').width(_.slideWidth - offset);
1965
1966    };
1967
1968    Slick.prototype.setFade = function() {
1969
1970        var _ = this,
1971            targetLeft;
1972
1973        _.$slides.each(function(index, element) {
1974            targetLeft = (_.slideWidth * index) * -1;
1975            if (_.options.rtl === true) {
1976                $(element).css({
1977                    position: 'relative',
1978                    right: targetLeft,
1979                    top: 0,
1980                    zIndex: _.options.zIndex - 2,
1981                    opacity: 0
1982                });
1983            } else {
1984                $(element).css({
1985                    position: 'relative',
1986                    left: targetLeft,
1987                    top: 0,
1988                    zIndex: _.options.zIndex - 2,
1989                    opacity: 0
1990                });
1991            }
1992        });
1993
1994        _.$slides.eq(_.currentSlide).css({
1995            zIndex: _.options.zIndex - 1,
1996            opacity: 1
1997        });
1998
1999    };
2000
2001    Slick.prototype.setHeight = function() {
2002
2003        var _ = this;
2004
2005        if (_.options.slidesToShow === 1 && _.options.adaptiveHeight === true && _.options.vertical === false) {
2006            var targetHeight = _.$slides.eq(_.currentSlide).outerHeight(true);
2007            _.$list.css('height', targetHeight);
2008        }
2009
2010    };
2011
2012    Slick.prototype.setOption =
2013    Slick.prototype.slickSetOption = function() {
2014
2015        /**
2016         * accepts arguments in format of:
2017         *
2018         *  - for changing a single option's value:
2019         *     .a4jslick("setOption", option, value, refresh )
2020         *
2021         *  - for changing a set of responsive options:
2022         *     .a4jslick("setOption", 'responsive', [{}, ...], refresh )
2023         *
2024         *  - for updating multiple values at once (not responsive)
2025         *     .a4jslick("setOption", { 'option': value, ... }, refresh )
2026         */
2027
2028        var _ = this, l, item, option, value, refresh = false, type;
2029
2030        if( $.type( arguments[0] ) === 'object' ) {
2031
2032            option =  arguments[0];
2033            refresh = arguments[1];
2034            type = 'multiple';
2035
2036        } else if ( $.type( arguments[0] ) === 'string' ) {
2037
2038            option =  arguments[0];
2039            value = arguments[1];
2040            refresh = arguments[2];
2041
2042            if ( arguments[0] === 'responsive' && $.type( arguments[1] ) === 'array' ) {
2043
2044                type = 'responsive';
2045
2046            } else if ( typeof arguments[1] !== 'undefined' ) {
2047
2048                type = 'single';
2049
2050            }
2051
2052        }
2053
2054        if ( type === 'single' ) {
2055
2056            _.options[option] = value;
2057
2058
2059        } else if ( type === 'multiple' ) {
2060
2061            $.each( option , function( opt, val ) {
2062
2063                _.options[opt] = val;
2064
2065            });
2066
2067
2068        } else if ( type === 'responsive' ) {
2069
2070            for ( item in value ) {
2071
2072                if( $.type( _.options.responsive ) !== 'array' ) {
2073
2074                    _.options.responsive = [ value[item] ];
2075
2076                } else {
2077
2078                    l = _.options.responsive.length-1;
2079
2080                    // loop through the responsive object and splice out duplicates.
2081                    while( l >= 0 ) {
2082
2083                        if( _.options.responsive[l].breakpoint === value[item].breakpoint ) {
2084
2085                            _.options.responsive.splice(l,1);
2086
2087                        }
2088
2089                        l--;
2090
2091                    }
2092
2093                    _.options.responsive.push( value[item] );
2094
2095                }
2096
2097            }
2098
2099        }
2100
2101        if ( refresh ) {
2102
2103            _.unload();
2104            _.reinit();
2105
2106        }
2107
2108    };
2109
2110    Slick.prototype.setPosition = function() {
2111
2112        var _ = this;
2113
2114        _.setDimensions();
2115
2116        _.setHeight();
2117
2118        if (_.options.fade === false) {
2119            _.setCSS(_.getLeft(_.currentSlide));
2120        } else {
2121            _.setFade();
2122        }
2123
2124        _.$slider.trigger('setPosition', [_]);
2125
2126    };
2127
2128    Slick.prototype.setProps = function() {
2129
2130        var _ = this,
2131            bodyStyle = document.body.style;
2132
2133        _.positionProp = _.options.vertical === true ? 'top' : 'left';
2134
2135        if (_.positionProp === 'top') {
2136            _.$slider.addClass('a4j-slick-vertical');
2137        } else {
2138            _.$slider.removeClass('a4j-slick-vertical');
2139        }
2140
2141        if (bodyStyle.WebkitTransition !== undefined ||
2142            bodyStyle.MozTransition !== undefined ||
2143            bodyStyle.msTransition !== undefined) {
2144            if (_.options.useCSS === true) {
2145                _.cssTransitions = true;
2146            }
2147        }
2148
2149        if ( _.options.fade ) {
2150            if ( typeof _.options.zIndex === 'number' ) {
2151                if( _.options.zIndex < 3 ) {
2152                    _.options.zIndex = 3;
2153                }
2154            } else {
2155                _.options.zIndex = _.defaults.zIndex;
2156            }
2157        }
2158
2159        if (bodyStyle.OTransform !== undefined) {
2160            _.animType = 'OTransform';
2161            _.transformType = '-o-transform';
2162            _.transitionType = 'OTransition';
2163            if (bodyStyle.perspectiveProperty === undefined && bodyStyle.webkitPerspective === undefined) _.animType = false;
2164        }
2165        if (bodyStyle.MozTransform !== undefined) {
2166            _.animType = 'MozTransform';
2167            _.transformType = '-moz-transform';
2168            _.transitionType = 'MozTransition';
2169            if (bodyStyle.perspectiveProperty === undefined && bodyStyle.MozPerspective === undefined) _.animType = false;
2170        }
2171        if (bodyStyle.webkitTransform !== undefined) {
2172            _.animType = 'webkitTransform';
2173            _.transformType = '-webkit-transform';
2174            _.transitionType = 'webkitTransition';
2175            if (bodyStyle.perspectiveProperty === undefined && bodyStyle.webkitPerspective === undefined) _.animType = false;
2176        }
2177        if (bodyStyle.msTransform !== undefined) {
2178            _.animType = 'msTransform';
2179            _.transformType = '-ms-transform';
2180            _.transitionType = 'msTransition';
2181            if (bodyStyle.msTransform === undefined) _.animType = false;
2182        }
2183        if (bodyStyle.transform !== undefined && _.animType !== false) {
2184            _.animType = 'transform';
2185            _.transformType = 'transform';
2186            _.transitionType = 'transition';
2187        }
2188        _.transformsEnabled = _.options.useTransform && (_.animType !== null && _.animType !== false);
2189    };
2190
2191
2192    Slick.prototype.setSlideClasses = function(index) {
2193
2194        var _ = this,
2195            centerOffset, allSlides, indexOffset, remainder;
2196
2197        allSlides = _.$slider
2198            .find('.a4j-slick-slide')
2199            .removeClass('a4j-slick-active a4j-slick-center a4j-slick-current')
2200            .attr('aria-hidden', 'true');
2201
2202        _.$slides
2203            .eq(index)
2204            .addClass('a4j-slick-current');
2205
2206        if (_.options.centerMode === true) {
2207
2208            centerOffset = Math.floor(_.options.slidesToShow / 2);
2209
2210            if (_.options.infinite === true) {
2211
2212                if (index >= centerOffset && index <= (_.slideCount - 1) - centerOffset) {
2213
2214                    _.$slides
2215                        .slice(index - centerOffset, index + centerOffset + 1)
2216                        .addClass('a4j-slick-active')
2217                        .attr('aria-hidden', 'false');
2218
2219                } else {
2220
2221                    indexOffset = _.options.slidesToShow + index;
2222                    allSlides
2223                        .slice(indexOffset - centerOffset + 1, indexOffset + centerOffset + 2)
2224                        .addClass('a4j-slick-active')
2225                        .attr('aria-hidden', 'false');
2226
2227                }
2228
2229                if (index === 0) {
2230
2231                    allSlides
2232                        .eq(allSlides.length - 1 - _.options.slidesToShow)
2233                        .addClass('a4j-slick-center');
2234
2235                } else if (index === _.slideCount - 1) {
2236
2237                    allSlides
2238                        .eq(_.options.slidesToShow)
2239                        .addClass('a4j-slick-center');
2240
2241                }
2242
2243            }
2244
2245            _.$slides
2246                .eq(index)
2247                .addClass('a4j-slick-center');
2248
2249        } else {
2250
2251            if (index >= 0 && index <= (_.slideCount - _.options.slidesToShow)) {
2252
2253                _.$slides
2254                    .slice(index, index + _.options.slidesToShow)
2255                    .addClass('a4j-slick-active')
2256                    .attr('aria-hidden', 'false');
2257
2258            } else if (allSlides.length <= _.options.slidesToShow) {
2259
2260                allSlides
2261                    .addClass('a4j-slick-active')
2262                    .attr('aria-hidden', 'false');
2263
2264            } else {
2265
2266                remainder = _.slideCount % _.options.slidesToShow;
vendor: 15,835 bytes, lines 2267-2807
2267                indexOffset = _.options.infinite === true ? _.options.slidesToShow + index : index;
2268
2269                if (_.options.slidesToShow == _.options.slidesToScroll && (_.slideCount - index) < _.options.slidesToShow) {
2270
2271                    allSlides
2272                        .slice(indexOffset - (_.options.slidesToShow - remainder), indexOffset + remainder)
2273                        .addClass('a4j-slick-active')
2274                        .attr('aria-hidden', 'false');
2275
2276                } else {
2277
2278                    allSlides
2279                        .slice(indexOffset, indexOffset + _.options.slidesToShow)
2280                        .addClass('a4j-slick-active')
2281                        .attr('aria-hidden', 'false');
2282
2283                }
2284
2285            }
2286
2287        }
2288
2289        if (_.options.lazyLoad === 'ondemand') {
2290            _.lazyLoad();
2291        }
2292
2293    };
2294
2295    Slick.prototype.setupInfinite = function() {
2296
2297        var _ = this,
2298            i, slideIndex, infiniteCount;
2299
2300        if (_.options.fade === true) {
2301            _.options.centerMode = false;
2302        }
2303
2304        if (_.options.infinite === true && _.options.fade === false) {
2305
2306            slideIndex = null;
2307
2308            if (_.slideCount > _.options.slidesToShow) {
2309
2310                if (_.options.centerMode === true) {
2311                    infiniteCount = _.options.slidesToShow + 1;
2312                } else {
2313                    infiniteCount = _.options.slidesToShow;
2314                }
2315
2316                for (i = _.slideCount; i > (_.slideCount -
2317                        infiniteCount); i -= 1) {
2318                    slideIndex = i - 1;
2319                    $(_.$slides[slideIndex]).clone(true).attr('id', '')
2320                        .attr('data-slick-index', slideIndex - _.slideCount)
2321                        .prependTo(_.$slideTrack).addClass('a4j-slick-cloned');
2322                }
2323                for (i = 0; i < infiniteCount; i += 1) {
2324                    slideIndex = i;
2325                    $(_.$slides[slideIndex]).clone(true).attr('id', '')
2326                        .attr('data-slick-index', slideIndex + _.slideCount)
2327                        .appendTo(_.$slideTrack).addClass('a4j-slick-cloned');
2328                }
2329                _.$slideTrack.find('.a4j-slick-cloned').find('[id]').each(function() {
2330                    $(this).attr('id', '');
2331                });
2332
2333            }
2334
2335        }
2336
2337    };
2338
2339    Slick.prototype.interrupt = function( toggle ) {
2340
2341        var _ = this;
2342
2343        if( !toggle ) {
2344            _.autoPlay();
2345        }
2346        _.interrupted = toggle;
2347
2348    };
2349
2350    Slick.prototype.selectHandler = function(event) {
2351
2352        var _ = this;
2353
2354        var targetElement =
2355            $(event.target).is('.a4j-slick-slide') ?
2356                $(event.target) :
2357                $(event.target).parents('.a4j-slick-slide');
2358
2359        var index = parseInt(targetElement.attr('data-slick-index'));
2360
2361        if (!index) index = 0;
2362
2363        if (_.slideCount <= _.options.slidesToShow) {
2364
2365            _.setSlideClasses(index);
2366            _.asNavFor(index);
2367            return;
2368
2369        }
2370
2371        _.slideHandler(index);
2372
2373    };
2374
2375    Slick.prototype.slideHandler = function(index, sync, dontAnimate) {
2376
2377        var targetSlide, animSlide, oldSlide, slideLeft, targetLeft = null,
2378            _ = this, navTarget;
2379
2380        sync = sync || false;
2381
2382        if (_.animating === true && _.options.waitForAnimate === true) {
2383            return;
2384        }
2385
2386        if (_.options.fade === true && _.currentSlide === index) {
2387            return;
2388        }
2389
2390        if (_.slideCount <= _.options.slidesToShow) {
2391            return;
2392        }
2393
2394        if (sync === false) {
2395            _.asNavFor(index);
2396        }
2397
2398        targetSlide = index;
2399        targetLeft = _.getLeft(targetSlide);
2400        slideLeft = _.getLeft(_.currentSlide);
2401
2402        _.currentLeft = _.swipeLeft === null ? slideLeft : _.swipeLeft;
2403
2404        if (_.options.infinite === false && _.options.centerMode === false && (index < 0 || index > _.getDotCount() * _.options.slidesToScroll)) {
2405            if (_.options.fade === false) {
2406                targetSlide = _.currentSlide;
2407                if (dontAnimate !== true) {
2408                    _.animateSlide(slideLeft, function() {
2409                        _.postSlide(targetSlide);
2410                    });
2411                } else {
2412                    _.postSlide(targetSlide);
2413                }
2414            }
2415            return;
2416        } else if (_.options.infinite === false && _.options.centerMode === true && (index < 0 || index > (_.slideCount - _.options.slidesToScroll))) {
2417            if (_.options.fade === false) {
2418                targetSlide = _.currentSlide;
2419                if (dontAnimate !== true) {
2420                    _.animateSlide(slideLeft, function() {
2421                        _.postSlide(targetSlide);
2422                    });
2423                } else {
2424                    _.postSlide(targetSlide);
2425                }
2426            }
2427            return;
2428        }
2429
2430        if ( _.options.autoplay ) {
2431            clearInterval(_.autoPlayTimer);
2432        }
2433
2434        if (targetSlide < 0) {
2435            if (_.slideCount % _.options.slidesToScroll !== 0) {
2436                animSlide = _.slideCount - (_.slideCount % _.options.slidesToScroll);
2437            } else {
2438                animSlide = _.slideCount + targetSlide;
2439            }
2440        } else if (targetSlide >= _.slideCount) {
2441            if (_.slideCount % _.options.slidesToScroll !== 0) {
2442                animSlide = 0;
2443            } else {
2444                animSlide = targetSlide - _.slideCount;
2445            }
2446        } else {
2447            animSlide = targetSlide;
2448        }
2449
2450        _.animating = true;
2451		
2452		_.$slider.closest('.ingallery').trigger('beforeCarouselChange', [_, _.currentSlide, animSlide]);
2453        _.$slider.trigger('beforeChange', [_, _.currentSlide, animSlide]);
2454
2455        oldSlide = _.currentSlide;
2456        _.currentSlide = animSlide;
2457
2458        _.setSlideClasses(_.currentSlide);
2459
2460        if ( _.options.asNavFor ) {
2461
2462            navTarget = _.getNavTarget();
2463            navTarget = navTarget.a4jslick('getSlick');
2464
2465            if ( navTarget.slideCount <= navTarget.options.slidesToShow ) {
2466                navTarget.setSlideClasses(_.currentSlide);
2467            }
2468
2469        }
2470
2471        _.updateDots();
2472        _.updateArrows();
2473
2474        if (_.options.fade === true) {
2475            if (dontAnimate !== true) {
2476
2477                _.fadeSlideOut(oldSlide);
2478
2479                _.fadeSlide(animSlide, function() {
2480                    _.postSlide(animSlide);
2481                });
2482
2483            } else {
2484                _.postSlide(animSlide);
2485            }
2486            _.animateHeight();
2487            return;
2488        }
2489
2490        if (dontAnimate !== true) {
2491            _.animateSlide(targetLeft, function() {
2492                _.postSlide(animSlide);
2493            });
2494        } else {
2495            _.postSlide(animSlide);
2496        }
2497
2498    };
2499
2500    Slick.prototype.startLoad = function() {
2501
2502        var _ = this;
2503
2504        if (_.options.arrows === true && _.slideCount > _.options.slidesToShow) {
2505
2506            _.$prevArrow.hide();
2507            _.$nextArrow.hide();
2508
2509        }
2510
2511        if (_.options.dots === true && _.slideCount > _.options.slidesToShow) {
2512
2513            _.$dots.hide();
2514
2515        }
2516
2517        _.$slider.addClass('a4j-slick-loading');
2518
2519    };
2520
2521    Slick.prototype.swipeDirection = function() {
2522
2523        var xDist, yDist, r, swipeAngle, _ = this;
2524
2525        xDist = _.touchObject.startX - _.touchObject.curX;
2526        yDist = _.touchObject.startY - _.touchObject.curY;
2527        r = Math.atan2(yDist, xDist);
2528
2529        swipeAngle = Math.round(r * 180 / Math.PI);
2530        if (swipeAngle < 0) {
2531            swipeAngle = 360 - Math.abs(swipeAngle);
2532        }
2533
2534        if ((swipeAngle <= 45) && (swipeAngle >= 0)) {
2535            return (_.options.rtl === false ? 'left' : 'right');
2536        }
2537        if ((swipeAngle <= 360) && (swipeAngle >= 315)) {
2538            return (_.options.rtl === false ? 'left' : 'right');
2539        }
2540        if ((swipeAngle >= 135) && (swipeAngle <= 225)) {
2541            return (_.options.rtl === false ? 'right' : 'left');
2542        }
2543        if (_.options.verticalSwiping === true) {
2544            if ((swipeAngle >= 35) && (swipeAngle <= 135)) {
2545                return 'down';
2546            } else {
2547                return 'up';
2548            }
2549        }
2550
2551        return 'vertical';
2552
2553    };
2554
2555    Slick.prototype.swipeEnd = function(event) {
2556
2557        var _ = this,
2558            slideCount,
2559            direction;
2560
2561        _.dragging = false;
2562        _.interrupted = false;
2563        _.shouldClick = ( _.touchObject.swipeLength > 10 ) ? false : true;
2564
2565        if ( _.touchObject.curX === undefined ) {
2566            return false;
2567        }
2568
2569        if ( _.touchObject.edgeHit === true ) {
2570            _.$slider.trigger('edge', [_, _.swipeDirection() ]);
2571        }
2572
2573        if ( _.touchObject.swipeLength >= _.touchObject.minSwipe ) {
2574
2575            direction = _.swipeDirection();
2576
2577            switch ( direction ) {
2578
2579                case 'left':
2580                case 'down':
2581
2582                    slideCount =
2583                        _.options.swipeToSlide ?
2584                            _.checkNavigable( _.currentSlide + _.getSlideCount() ) :
2585                            _.currentSlide + _.getSlideCount();
2586
2587                    _.currentDirection = 0;
2588
2589                    break;
2590
2591                case 'right':
2592                case 'up':
2593
2594                    slideCount =
2595                        _.options.swipeToSlide ?
2596                            _.checkNavigable( _.currentSlide - _.getSlideCount() ) :
2597                            _.currentSlide - _.getSlideCount();
2598
2599                    _.currentDirection = 1;
2600
2601                    break;
2602
2603                default:
2604
2605
2606            }
2607
2608            if( direction != 'vertical' ) {
2609
2610                _.slideHandler( slideCount );
2611                _.touchObject = {};
2612                _.$slider.trigger('swipe', [_, direction ]);
2613
2614            }
2615
2616        } else {
2617
2618            if ( _.touchObject.startX !== _.touchObject.curX ) {
2619
2620                _.slideHandler( _.currentSlide );
2621                _.touchObject = {};
2622
2623            }
2624
2625        }
2626
2627    };
2628
2629    Slick.prototype.swipeHandler = function(event) {
2630
2631        var _ = this;
2632
2633        if ((_.options.swipe === false) || ('ontouchend' in document && _.options.swipe === false)) {
2634            return;
2635        } else if (_.options.draggable === false && event.type.indexOf('mouse') !== -1) {
2636            return;
2637        }
2638
2639        _.touchObject.fingerCount = event.originalEvent && event.originalEvent.touches !== undefined ?
2640            event.originalEvent.touches.length : 1;
2641
2642        _.touchObject.minSwipe = _.listWidth / _.options
2643            .touchThreshold;
2644
2645        if (_.options.verticalSwiping === true) {
2646            _.touchObject.minSwipe = _.listHeight / _.options
2647                .touchThreshold;
2648        }
2649
2650        switch (event.data.action) {
2651
2652            case 'start':
2653                _.swipeStart(event);
2654                break;
2655
2656            case 'move':
2657                _.swipeMove(event);
2658                break;
2659
2660            case 'end':
2661                _.swipeEnd(event);
2662                break;
2663
2664        }
2665
2666    };
2667
2668    Slick.prototype.swipeMove = function(event) {
2669
2670        var _ = this,
2671            edgeWasHit = false,
2672            curLeft, swipeDirection, swipeLength, positionOffset, touches;
2673
2674        touches = event.originalEvent !== undefined ? event.originalEvent.touches : null;
2675
2676        if (!_.dragging || touches && touches.length !== 1) {
2677            return false;
2678        }
2679
2680        curLeft = _.getLeft(_.currentSlide);
2681
2682        _.touchObject.curX = touches !== undefined ? touches[0].pageX : event.clientX;
2683        _.touchObject.curY = touches !== undefined ? touches[0].pageY : event.clientY;
2684
2685        _.touchObject.swipeLength = Math.round(Math.sqrt(
2686            Math.pow(_.touchObject.curX - _.touchObject.startX, 2)));
2687
2688        if (_.options.verticalSwiping === true) {
2689            _.touchObject.swipeLength = Math.round(Math.sqrt(
2690                Math.pow(_.touchObject.curY - _.touchObject.startY, 2)));
2691        }
2692
2693        swipeDirection = _.swipeDirection();
2694
2695        if (swipeDirection === 'vertical') {
2696            return;
2697        }
2698
2699        if (event.originalEvent !== undefined && _.touchObject.swipeLength > 4) {
2700            event.preventDefault();
2701        }
2702
2703        positionOffset = (_.options.rtl === false ? 1 : -1) * (_.touchObject.curX > _.touchObject.startX ? 1 : -1);
2704        if (_.options.verticalSwiping === true) {
2705            positionOffset = _.touchObject.curY > _.touchObject.startY ? 1 : -1;
2706        }
2707
2708
2709        swipeLength = _.touchObject.swipeLength;
2710
2711        _.touchObject.edgeHit = false;
2712
2713        if (_.options.infinite === false) {
2714            if ((_.currentSlide === 0 && swipeDirection === 'right') || (_.currentSlide >= _.getDotCount() && swipeDirection === 'left')) {
2715                swipeLength = _.touchObject.swipeLength * _.options.edgeFriction;
2716                _.touchObject.edgeHit = true;
2717            }
2718        }
2719
2720        if (_.options.vertical === false) {
2721            _.swipeLeft = curLeft + swipeLength * positionOffset;
2722        } else {
2723            _.swipeLeft = curLeft + (swipeLength * (_.$list.height() / _.listWidth)) * positionOffset;
2724        }
2725        if (_.options.verticalSwiping === true) {
2726            _.swipeLeft = curLeft + swipeLength * positionOffset;
2727        }
2728
2729        if (_.options.fade === true || _.options.touchMove === false) {
2730            return false;
2731        }
2732
2733        if (_.animating === true) {
2734            _.swipeLeft = null;
2735            return false;
2736        }
2737
2738        _.setCSS(_.swipeLeft);
2739
2740    };
2741
2742    Slick.prototype.swipeStart = function(event) {
2743
2744        var _ = this,
2745            touches;
2746
2747        _.interrupted = true;
2748
2749        if (_.touchObject.fingerCount !== 1 || _.slideCount <= _.options.slidesToShow) {
2750            _.touchObject = {};
2751            return false;
2752        }
2753
2754        if (event.originalEvent !== undefined && event.originalEvent.touches !== undefined) {
2755            touches = event.originalEvent.touches[0];
2756        }
2757
2758        _.touchObject.startX = _.touchObject.curX = touches !== undefined ? touches.pageX : event.clientX;
2759        _.touchObject.startY = _.touchObject.curY = touches !== undefined ? touches.pageY : event.clientY;
2760
2761        _.dragging = true;
2762
2763    };
2764
2765    Slick.prototype.unfilterSlides = Slick.prototype.slickUnfilter = function() {
2766
2767        var _ = this;
2768
2769        if (_.$slidesCache !== null) {
2770
2771            _.unload();
2772
2773            _.$slideTrack.children(this.options.slide).detach();
2774
2775            _.$slidesCache.appendTo(_.$slideTrack);
2776
2777            _.reinit();
2778
2779        }
2780
2781    };
2782
2783    Slick.prototype.unload = function() {
2784
2785        var _ = this;
2786
2787        $('.a4j-slick-cloned', _.$slider).remove();
2788
2789        if (_.$dots) {
2790            _.$dots.remove();
2791        }
2792
2793        if (_.$prevArrow && _.htmlExpr.test(_.options.prevArrow)) {
2794            _.$prevArrow.remove();
2795        }
2796
2797        if (_.$nextArrow && _.htmlExpr.test(_.options.nextArrow)) {
2798            _.$nextArrow.remove();
2799        }
2800
2801        _.$slides
2802            .removeClass('a4j-slick-slide a4j-slick-active a4j-slick-visible a4j-slick-current')
2803            .attr('aria-hidden', 'true')
2804            .css('width', '');
2805
2806    };
2807
2808    Slick.prototype.unslick = function(fromBreakpoint) {
2809
2810        var _ = this;
2811        _.$slider.trigger('unslick', [_, fromBreakpoint]);
2812        _.destroy();
2813
2814    };
2815
2816    Slick.prototype.updateArrows = function() {
2817
2818        var _ = this,
2819            centerOffset;
2820
2821        centerOffset = Math.floor(_.options.slidesToShow / 2);
2822
2823        if ( _.options.arrows === true &&
2824            _.slideCount > _.options.slidesToShow &&
2825            !_.options.infinite ) {
2826
2827            _.$prevArrow.removeClass('a4j-slick-disabled').attr('aria-disabled', 'false');
2828            _.$nextArrow.removeClass('a4j-slick-disabled').attr('aria-disabled', 'false');
2829
2830            if (_.currentSlide === 0) {
2831
2832                _.$prevArrow.addClass('a4j-slick-disabled').attr('aria-disabled', 'true');
2833                _.$nextArrow.removeClass('a4j-slick-disabled').attr('aria-disabled', 'false');
2834
2835            } else if (_.currentSlide >= _.slideCount - _.options.slidesToShow && _.options.centerMode === false) {
2836
2837                _.$nextArrow.addClass('a4j-slick-disabled').attr('aria-disabled', 'true');
2838                _.$prevArrow.removeClass('a4j-slick-disabled').attr('aria-disabled', 'false');
2839
2840            } else if (_.currentSlide >= _.slideCount - 1 && _.options.centerMode === true) {
2841
2842                _.$nextArrow.addClass('a4j-slick-disabled').attr('aria-disabled', 'true');
2843                _.$prevArrow.removeClass('a4j-slick-disabled').attr('aria-disabled', 'false');
2844
2845            }
2846
2847        }
2848
2849    };
2850
2851    Slick.prototype.updateDots = function() {
2852
2853        var _ = this;
2854
2855        if (_.$dots !== null) {
2856
2857            _.$dots
2858                .find('i')
2859                .removeClass('a4j-slick-active')
2860                .attr('aria-hidden', 'true');
2861
2862            _.$dots
2863                .find('i')
2864                .eq(Math.floor(_.currentSlide / _.options.slidesToScroll))
2865                .addClass('a4j-slick-active')
2866                .attr('aria-hidden', 'false');
2867
2868        }
2869
2870    };
2871
2872    Slick.prototype.visibility = function() {
2873
2874        var _ = this;
2875
2876        if ( _.options.autoplay ) {
2877
2878            if ( document[_.hidden] ) {
2879
2880                _.interrupted = true;
2881
2882            } else {
2883
2884                _.interrupted = false;
2885
2886            }
2887
2888        }
2889
2890    };
2891
2892    $.fn.a4jSlick = function() {
2893        var _ = this,
2894            opt = arguments[0],
2895            args = Array.prototype.slice.call(arguments, 1),
2896            l = _.length,
2897            i,
2898            ret;
2899        for (i = 0; i < l; i++) {
2900            if (typeof opt == 'object' || typeof opt == 'undefined')
2901                _[i].a4jslick = new Slick(_[i], opt);
2902            else
2903                ret = _[i].a4jslick[opt].apply(_[i].a4jslick, args);
2904            if (typeof ret != 'undefined') return ret;
2905        }
2906        return _;
2907    };
2908
2909})(jQuery);
2910
2911(function ($) {
2912    'use strict';
2913
2914    if (window.inGallery) {
2915        return;
2916    }
2917
2918    var popupShown = false;
2919    var fitPopupTimeout = 0;
2920    var popupShade = null;
2921    var popup = null;
2922    var loaderHTML = '<div class="ingLoaderWrap"><i class="ing-icon-spin2 animate-spin"></i></div>';
2923
2924    var InGallery = function (htmlNode, config, items) {
2925        this.jqNode = $(htmlNode);
2926        this.container = this.jqNode.parent('.ingallery-container');
2927        this.id = this.jqNode.attr('data-id');
2928        this.cfg = config;
2929        this.page = parseInt(this.jqNode.attr('data-page'));
2930        this.commentsCache = {};
2931        this.layoutFitTimeout = 0;
2932        this.layoutResetCounter = 0;
2933        this.masonry = null;
2934        this.visible = false;
2935        this.items = items;
2936
2937        var self = this;
2938
2939        var loadMoreBtn = this.jqNode.find('.ingallery-loadmore-btn');
2940        var infScroll = this.jqNode.find('.ingallery-loadmore.ingallery-inf-scroll');
2941
2942        this.jqNode.find('.ingallery-album').off('click').on('click', function () {
2943            self.filterGallery($(this).attr('data-id'));
2944        });
2945        if (this.cfg.layout_type == 'carousel') {
2946            this.jqNode.find('.ingallery-items').not('.a4j-slick-initialized').a4jSlick({
2947                'prevArrow': '<span data-role="none" class="a4j-slick-prev" aria-label="Previous" tabindex="0" role="button"><i class="ing-icon-angle-left ing-fw"></i></span>',
2948                'nextArrow': '<span data-role="none" class="a4j-slick-next" aria-label="Next" tabindex="0" role="button"><i class="ing-icon-angle-right ing-fw"></i></span>'
2949            });
2950            this.jqNode.off('beforeCarouselChange').on('beforeCarouselChange', function (e, _slick, _prevSlideID, _nextSlideID) {
2951                self.checkCarouselLoad(_nextSlideID);
2952            });
2953        } else if (this.cfg.layout_type.indexOf('masonry') >= 0) {
2954            this.buildMasonryLayout();
2955            this.activateMasonry();
2956        }
2957        this.bindItemsLinks();
2958
2959        loadMoreBtn.off('click').on('click', function () {
2960            var $this = $(this);
2961            if ($this.hasClass('disabled')) {
2962                return false;
2963            }
2964            var btnContent = $this.html();
2965            self.page++;
2966            self.jqNode.attr('data-page', self.page);
2967            var currentPage = self.page;
2968            var data = 'id=' + self.id + '&page=' + currentPage;
2969            var messageContainer = self.jqNode.find('.ingallery-loadmore');
2970            var addData = window.inGallery.addRequestData(self.jqNode);
2971            if (addData) {
2972                data += '&' + addData;
2973            }
2974            $this.addClass('disabled').html('<i class="ing-icon-spin2 animate-spin"></i>');
2975            $.ajax({
2976                'url': window.inGallery.getParam('ajax_url'),
2977                'type': 'get',
2978                'dataType': 'json',
2979                'data': data,
2980                'success': function (response, statusText, xhr, $form) {
2981                    if (!response) {
2982                        messageContainer.html(getMessageHTML(window.inGallery.getLangString('system_error'), 'error'));
2983                        return false;
2984                    }
2985                    if (response.status && response.status == 'success') {
2986                        self.addItems(response.items);
2987                        var gallery = self.jqNode;
2988                        var newItems = $(response.html).find('.ingallery-cell');
2989                        var itemsContainer = gallery.find('.ingallery-items');
2990                        if (self.cfg.layout_type == 'carousel') {
2991                            gallery.css('min-height', gallery.height());
2992                            itemsContainer.a4jSlick('slickAdd', newItems);
2993                            gallery.css('min-height', 'auto');
2994                        } else if (self.cfg.layout_type.indexOf('masonry') >= 0) {
2995                            itemsContainer.append(newItems)
2996                            self.buildMasonryLayout(gallery);
2997                            itemsContainer.masonry('appended', newItems);
2998                        } else {
2999                            itemsContainer.append(newItems);
3000                        }
3001                        self.lazyImages();
3002                        /*newItems.css('opacity',0).stop().animate({
3003                         'opacity': 1
3004                         },300);*/
3005                        self.bindItemsLinks();
3006                        var galleryFiltered = gallery.attr('data-filtered');
3007                        if (galleryFiltered && galleryFiltered != '' && galleryFiltered != '0') {
3008                            self.filterGallery(galleryFiltered, true);
3009                        } else {
3010                            self.fitLayout();
3011                        }
3012                        if (response.has_more) {
3013                            $this.removeClass('disabled').html(btnContent);
3014                            if (gallery.hasClass('ingallery-layout-carousel')) {
3015                                self.checkCarouselLoad(null);
3016                            } else if (infScroll.length) {
3017                                self.checkInfScroll(loadMoreBtn);
3018                            }
3019                        } else {
3020                            var tmp = gallery.find('.ingallery-loadmore');
3021                            tmp.slideUp(200, 'swing', function () {
3022                                tmp.remove();
3023                            });
3024                        }
3025                        $(window).trigger('resize');
3026                    } else if (response.status && response.status == 'error') {
3027                        messageContainer.html(getMessageHTML(response.message, 'error'));
3028                    } else {
3029                        messageContainer.html(getMessageHTML(window.inGallery.getLangString('system_error'), 'error'));
3030                    }
3031                },
3032                error: function (jqXHR, textStatus, errorThrown) {
3033                    messageContainer.html(getMessageHTML(window.inGallery.getLangString('system_error') + '<br><i>' + textStatus + ' (' + errorThrown + ')</i>', 'error'));
3034                }
3035            });
3036
3037            return false;
3038        });
3039        if (this.cfg.layout_type == 'carousel') {
3040            loadMoreBtn.click();
3041        } else if (infScroll.length) {
3042            $(window).on('scroll', function () {
3043                self.checkInfScroll(loadMoreBtn);
3044            });
3045            self.checkInfScroll(loadMoreBtn);
3046        }
3047
3048        this.jqNode.off('updateLayout').on('updateLayout', function () {
3049            self.updateLayout();
3050        });
3051
3052
3053        $(window).on('resize scroll', function () {
3054            self.updateLayout();
3055        }).trigger('resize');
3056        
3057        window.setTimeout(function(){
3058            self.updateLayout();
3059        }, 1000);
3060        
3061        window.setInterval(function () {
3062            self.checkIsVisible();
3063        }, 100);
3064        
3065        this.container.trigger('IngInit');
3066    }
3067
3068    InGallery.prototype = {
3069        getItem: function(value, key="code"){
3070            for(var i=0;i<this.items.length;i++){
3071                if(this.items[i][key]==value){
3072                    return this.items[i];
3073                }
3074            }
3075            return false;
3076        },
3077        addItems: function(items){
3078            for(var i=0;i<items.length;i++){
3079                var item = items[i];
3080                if(this.getItem(item.code)===false){
3081                    this.items.push(item);
3082                }
3083            }
3084        },
3085        checkIsVisible: function () {
3086            this.lazyImages();
3087            var visible = this.jqNode.is(':visible');
3088            if (!this.visible && visible) {
3089                this.updateLayout();
3090            }
3091            this.visible = visible;
3092        },
3093        lazyImages: function(){
3094            var winY = parseInt($(window).scrollTop()+$(window).height());
3095            var thisY = this.jqNode.offset().top;
3096            if((winY+200)>=thisY){
3097                this.jqNode.find('img').each(function(){
3098                    var img = $(this);
3099                    if(img.data('src')){
3100                        img.css('opacity', 0);
3101                        img.on('load', function () {
3102                            if(this.complete && this.naturalWidth) {
3103                                img.animate({'opacity': 1}, 300);
3104                            }
3105                        });
3106                        img.attr('src', img.data('src'));
3107                        img.data('src', null);
3108                    }
3109                });
3110            }
3111        },
3112        updateLayout: function () {
3113            if (this.layoutFitTimeout > 0) {
3114                window.clearTimeout(this.layoutFitTimeout);
3115                this.layoutFitTimeout = 0;
3116            }
3117            if(this.layoutResetCounter>50){
3118                this.layoutResetCounter = 0;
3119                this.fitLayout();
3120            }
3121            else{
3122                this.layoutResetCounter++;
3123                this.layoutFitTimeout = window.setTimeout(this.fitLayout.bind(this), 150);
3124            }
3125        },
3126        fitLayout: function () {
3127            if (this.layoutFitTimeout > 0) {
3128                window.clearTimeout(this.layoutFitTimeout);
3129                this.layoutFitTimeout = 0;
3130            }
3131            var winWidth = $(window).width();
3132            var respCfg = {
3133                "cols": parseInt(this.cfg.layout_cols),
3134                "rows": parseInt(this.cfg.layout_rows),
3135                "gutter": parseInt(this.cfg.layout_gutter)
3136            };
3137            for (var w in this.cfg.layout_responsive) {
3138                if (parseInt(w) >= winWidth) {
3139                    respCfg = this.cfg.layout_responsive[w];
3140                    break;
3141                }
3142            }
3143            var $margin = (respCfg.gutter > 0 ? Math.floor(respCfg.gutter / 2) : 0);
3144            var $widthPercent = (respCfg.cols > 1 ? precisionRound(100 / respCfg.cols, 5) : 100);
3145            if (this.cfg.layout_type == 'masonry') {
3146                $widthPercent = (respCfg.cols > 1 ? precisionRound(100 / (respCfg.cols + 1), 5) : 100);
3147            }
3148
3149            var css = "";
3150            if (this.cfg.layout_type == 'carousel') {
3151                css += "#ingallery-" + this.id + " .ingallery-col, #ingallery-" + this.id + " .ingallery-cell{padding:" + $margin + "px;}";
3152            } else {
3153                css += "#ingallery-" + this.id + " .ingallery-items{margin-left:-" + $margin + "px;margin-right:-" + $margin + "px;}";
3154                css += "#ingallery-" + this.id + " .ingallery-col, #ingallery-" + this.id + " .ingallery-cell{padding-left:" + $margin + "px;padding-right:" + $margin + "px;padding-bottom:" + respCfg.gutter + "px;
3154width:" + $widthPercent + "%;}";
3155                css += "#ingallery-" + this.id + " .grid-sizer{width:" + $widthPercent + "%;}";
3156                css += "#ingallery-" + this.id + " .ingallery-col-big, #ingallery-" + this.id + " .ingallery-cell-big{width:" + ($widthPercent * 2) + "%;}";
3157            }
3158
3159            var customCSSNode = this.jqNode.find('.custom-css-node');
3160            if (customCSSNode.length == 0) {
3161                customCSSNode = $('<style type="text/css" class="custom-css-node"></style>');
3162                this.jqNode.append(customCSSNode);
3163            }
3164            customCSSNode.text(css);
3165
3166            if (this.masonry) {
3167                var feed = this;
3168                this.masonry.masonry();
3169                var images = this.masonry.find('img');
3170                var imagesLoaded = 0;
3171                var imagesTotal = images.length;
3172                var imgLoaded = function (img) {
3173                    imagesLoaded++;
3174                    feed.masonry.masonry('layout');
3175                };
3176                images.each(function () {
3177                    if (this.complete && this.naturalWidth) {
3178                        imgLoaded(this);
3179                    }
3180                });
3181                if (imagesLoaded < imagesTotal) {
3182                    images.on('load', function () {
3183                        if (this.complete && this.naturalWidth) {
3184                            imgLoaded(this);
3185                        }
3186                    });
3187                }
3188            }
3189            var newImages = this.jqNode.find('.ingallery-item img').not('.ing-loading, .ing-loaded');
3190            newImages.each(function () {
3191                if (this.complete && this.naturalWidth) {
3192                    return
3193                }
3194                var $img = $(this);
3195                $img.addClass('ing-loading').css('opacity', 0);
3196                $img.on('load', function () {
3197                    if (this.complete && this.naturalWidth) {
3198                        $(this).removeClass('ing-loading').addClass('ing-loaded').stop().animate({'opacity': 1}, 300);
3199                    }
3200                });
3201            });
3202            this.container.trigger('IngLayout');
3203        },
3204        showInPopup: function (_item) {
3205            if (popupShown) {
3206                this.updatePopup(_item);
3207            } else {
3208                this.createPopup(_item);
3209            }
3210        },
3211
3212        createPopup: function (_item) {
3213            if (popupShown) {
3214                return;
3215            }
3216            var gallery = this;
3217            var popupHTML;
3218            popupHTML = '<div id="ingallery-shade">';
3219            popupHTML += '<div id="ingallery-popup" class="' + this.id + ' ingallery-' + this.id + '">';
3220            popupHTML += '<div id="ingallery-popup-close"><i class="ing-icon-cancel-1"></i></div>';
3221            popupHTML += '<div id="ingallery-popup-wrap">';
3222            popupHTML += '<div id="ingallery-popup-wrap-img">';
3223            popupHTML += '<div id="ingallery-popup-left"><i class="ing-icon-angle-left"></i></div>';
3224            popupHTML += '<div id="ingallery-popup-right"><i class="ing-icon-angle-right"></i></div>';
3225            popupHTML += '<div id="ingallery-popup-wrap-img-cnt"></div>';
3226            popupHTML += '</div>';
3227            popupHTML += '<div id="ingallery-popup-wrap-content"></div>';
3228            popupHTML += '</div>';
3229            popupHTML += '</div>';
3230            popupHTML += '</div>';
3231            popupShade = $(popupHTML);
3232            var _body = $('body');
3233            popup = popupShade.find('#ingallery-popup');
3234            _body.append(popupShade);
3235            popupShown = true;
3236            popupShade.fadeIn(300);
3237            popup.css('opacity', 0).css('margin-top', '30px').stop().animate({
3238                opacity: 1,
3239                'margin-top': 0
3240            }, 300);
3241
3242            popupShade.on('click', function (e) {
3243                var _target = $(e.target);
3244                var _close = _target.closest('#ingallery-popup-close');
3245                if (_target.is(popupShade) || _close.length) {
3246                    gallery.closePopup.call(this);
3247                }
3248            });
3249
3250            $(document).on('keydown', this.processKeydown);
3251
3252            this.placeDataToPopup(_item);
3253        },
3254        updatePopup: function (_item) {
3255            if (!popupShown) {
3256                return;
3257            }
3258            var gallery = this;
3259            var popupWraps = $('#ingallery-popup-wrap-img-cnt > img,#ingallery-popup-wrap-content');
3260            popupWraps.stop().animate({
3261                'opacity': 0
3262            }, 100, 'swing', function () {
3263                gallery.placeDataToPopup(_item);
3264                popupWraps.stop().animate({
3265                    'opacity': 1
3266                }, 100);
3267            });
3268        },
3269        closePopup: function () {
3270            if (!popupShown) {
3271                return;
3272            }
3273            var _body = $('body');
3274            popupShade.fadeOut(300, 'swing', function () {
3275                popupShade.remove();
3276                popupShown = false;
3277            });
3278            popup.stop().animate({
3279                opacity: 0,
3280                'margin-top': 30
3281            }, 300);
3282            $(document).off('keydown', this.processKeydown);
3283        },
3284
3285        processKeydown: function (e) {
3286            if (!e.which) {
3287                return;
3288            }
3289            if (e.which == 37) {
3290                $('#ingallery-popup-left:visible').click();
3291            } else if (e.which == 39) {
3292                $('#ingallery-popup-right:visible').click();
3293            }
3294        },
3295
3296        placeDataToPopup: function (_item) {
3297            var popupWrap = $('#ingallery-popup-wrap');
3298            var popupImgWrap = $('#ingallery-popup-wrap-img');
3299            var popupContentWrap = $('#ingallery-popup-wrap-content');
3300            if (popupImgWrap.length == 0 || popupContentWrap.length == 0) {
3301                return false;
3302            }
3303            var gallery = this;
3304            popupImgWrap.attr('data-img-size', this.cfg.display_popup_img_size);
3305            popupImgWrap.attr('data-ratio', _item.ratio);
3306            popupImgWrap.attr('data-width', _item.full_width);
3307            popupImgWrap.attr('data-height', _item.full_height);
3308            var imgPlaceholder = popupImgWrap.find('#ingallery-popup-wrap-img-cnt');
3309            imgPlaceholder.off('click').removeClass('ing-video').removeClass('ing-playing');
3310            if (_item.type=='video') {
3311                this.showVideo(_item);
3312            } else if (_item.items.length) {
3313                this.showSubgallery(_item);
3314            } else {
3315                var _img = $('<img />').css('opacity', 0);
3316                _img.on('load', function () {
3317                    _img.animate({
3318                        'opacity': 1
3319                    }, 200);
3320                });
3321                _img.attr('src', _item.picture_url);
3322                imgPlaceholder.empty().append(_img);
3323            }
3324            
3325            var needToLoadData = false;
3326            var contentHTML = '';
3327            if (this.cfg.display_popup_user) {
3328                contentHTML += '<div class="ingallery-popup-content-user '+(_item.author_picture_url!=''?'':'ing-loading')+'">';
3329                if(_item.author_picture_url!=''){
3330                    if (this.cfg.display_popup_instagram_link) {
3331                        contentHTML += '<a href="https://www.instagram.com/' + _item.author_username + '/" title="' + _item.author_username + '" target="_blank"><img src="' + _item.author_picture_url + '"> ' + _item.author_name+'</a>';
3332                    }
3333                    else{
3334                        contentHTML += '<img src="' + _item.author_picture_url + '"> ' + _item.author_name;
3335                    }
3336                }
3337                else{
3338                    needToLoadData = true;
3339                }
3340                contentHTML += '</div>';
3341            }
3342            if (this.cfg.display_popup_likes || this.cfg.display_popup_comments || this.cfg.display_popup_plays || this.cfg.display_popup_date) {
3343                contentHTML += '<div class="ingallery-popup-content-stats">';
3344                if (this.cfg.display_popup_date) {
3345                    contentHTML += '<time title="' + _item.full_date + '" datetime="' + _item.date_iso + '">' + _item.time_passed + '</time>';
3346                }
3347                if (this.cfg.display_popup_likes) {
3348                    contentHTML += '<span class="ingallery-popup-content-stats-likes"><i class="ing-icon-heart-1"></i> ' + _item.likes_count + '</span>';
3349                }
3350                if (this.cfg.display_popup_comments) {
3351                    contentHTML += '<span class="ingallery-popup-content-stats-comments"><i class="ing-icon-comment-1"></i> ' + _item.comments_count + '</span>';
3352                }
3353                contentHTML += '</div>';
3354            }
3355            if (this.cfg.display_popup_description || this.cfg.display_popup_comments_listx) {
3356                contentHTML += '<div class="ingallery-popup-content-stretch">';
3357                if (this.cfg.display_popup_description) {
3358                    contentHTML += '<div class="ingallery-popup-content-descr">';
3359                    if(_item.text_html){
3360                        contentHTML += _item.text_html;
3361                    }
3362                    else{
3363                        needToLoadData = true;
3364                    }
3365                    contentHTML += '</div>';
3366                }
3367                if (this.cfg.display_popup_comments_listx){
3368                    contentHTML += '<div class="ingallery-popup-content-comments ing-loading"></div>';
3369                    needToLoadData = true;
3370                }
3371                contentHTML += '</div>';
3372            }
3373            
3374            if (contentHTML != '') {
3375                popupWrap.removeClass('noRight');
3376                popupContentWrap.html(contentHTML);
3377            } else {
3378                popupWrap.addClass('noRight');
3379            }
3380            
3381            $('#ingallery-popup-c2a-btn').remove();
3382            var c2a_cfg = this.getC1A_ItemConfig(_item.code);
3383            if(c2a_cfg){
3384                console.info(c2a_cfg.label);
3385                var btn = $('<a href="'+c2a_cfg.uri+'" target="_blank" rel="nofollow" id="ingallery-popup-c2a-btn"><svg class="eapps-instagram-feed-popup-item-cta-button-icon" viewBox="0 0 6 10"><path d="M5.71,4.286L1.727,0.302c-0.39-0.392-1.023-0.392-1.414,0c-0.39,0.39-0.39,1.023,0,1.414L3.59,4.992 L0.289,8.284c-0.39,0.39-0.39,1.025,0,1.415c0.39,0.39,1.023,0.39,1.414,0l4.008-4C6.101,5.309,6.101,4.675,5.71,4.286z"></path></svg>'+c2a_cfg.label+'</a>');
3386                switch(c2a_cfg.position){
3387                    case 'top':
3388                    case 'middle':
3389                    case 'bottom':
3390                        btn.addClass('ingallery-position-'+c2a_cfg.position);
3391                        popupImgWrap.append(btn);
3392                    break;
3393                    case 'descr.top':
3394                        if(popupContentWrap.find('.ingallery-popup-content-stretch')){
3395                            popupContentWrap.find('.ingallery-popup-content-stretch').prepend(btn);
3396                        }
3397                    break;
3398                    case 'descr.bottom':
3399                        if(popupContentWrap.find('.ingallery-popup-content-stretch')){
3400                            popupContentWrap.find('.ingallery-popup-content-stretch').append(btn);
3401                        }
3402                    break;
3403                }
3404            }
3405
3406
3407            if (needToLoadData) {
3408                $.ajax({
3409                    url: window.inGallery.getParam('ajax_data_url'),
3410                    type: 'get',
3411                    dataType: 'json',
3412                    cache: true,
3413                    data: 'galleryID='+this.id+'&pictureID='+_item.id,
3414                    success: function (response){
3415                        if (response && response.status && response.status == 'success') {
3416                            if(_item.code==response.data.code){
3417                                gallery.updatePopupData(response.data, response.comments);
3418                                if(response.data.type=='video'){
3419                                    gallery.showVideo(response.data);
3420                                }
3421                                else if(response.data.items.length){
3422                                    gallery.showSubgallery(response.data);
3423                                }
3424                            }
3425                        }
3426                    },
3427                    error: function(jqXHR, textStatus, errorThrown){
3428                        console.info(textStatus, errorThrown);
3429                    }
3430                });
3431            }
3432
3433            var _items = this.jqNode.find('a.ingallery-item-link-popup:visible');
3434            var goPrev = $('#ingallery-popup-left');
3435            var goNext = $('#ingallery-popup-right');
3436            var itemIndex = _items.index(_item.jqItem);
3437            if (itemIndex > 0) {
3438                goPrev.show();
3439                goPrev.off('click').on('click', function () {
3440                    _items.get(itemIndex - 1).click();
3441                });
3442            } else {
3443                goPrev.hide();
3444            }
3445            if (itemIndex + 1 < _items.length) {
3446                goNext.show();
3447                goNext.off('click').on('click', function () {
3448                    _items.get(itemIndex + 1).click();
3449                });
3450            } else {
3451                goNext.hide();
3452            }
3453
3454            if (itemIndex > _items.length - 4) {
3455                this.jqNode.find('.ingallery-loadmore-btn').click();
3456            }
3457
3458            setFitPopup();
3459
3460            return true;
3461        },
3462        
3463        getC1A_ItemConfig: function(code){
3464            if(this.cfg.c2a){
3465                for(var i=0;i<this.cfg.c2a.length;i++){
3466                    if(this.cfg.c2a[i]['post']=='https://www.instagram.com/p/'+code || this.cfg.c2a[i]['post']=='https://www.instagram.com/p/'+code+'/'){
3467                        return this.cfg.c2a[i];
3468                    }
3469                }
3470            }
3471            return false;
3472        },
3473        
3474        showVideo: function(_item){
3475            var popupImgWrap = $('#ingallery-popup-wrap-img');
3476            var imgPlaceholder = popupImgWrap.find('#ingallery-popup-wrap-img-cnt');
3477            imgPlaceholder.addClass('ing-video');
3478            var _video = $('<video poster="' + _item.picture_url + '" src="' + _item.video_url + '" preload="false" ' + (this.cfg.display_popup_loop_video ? 'loop="loop"' : '') + ' playsinline type="video/mp4"><source src="' + _item.video_url + '" type="video/mp4"></video>');
3479            imgPlaceholder.empty().append(_video);
3480
3481            _video.on('click', function () {
3482                var player = _video.get(0);
3483                if (player.paused) {
3484                    imgPlaceholder.addClass('ing-playing');
3485                    player.play();
3486                } else {
3487                    imgPlaceholder.removeClass('ing-playing');
3488                    player.pause();
3489                }
3490            });
3491        },
3492        
3493        showSubgallery: function(_item){
3494            var popupImgWrap = $('#ingallery-popup-wrap-img');
3495            var imgPlaceholder = popupImgWrap.find('#ingallery-popup-wrap-img-cnt');
3496            
3497            var _subgallery = $('<div id="ingallery-popup-wrap-img-subgallery"></div>');
3498            var _subgalleryItems = $('<div id="ingallery-popup-wrap-img-subgallery-items"></div>');
3499            var _subgalleryNav = $('<div id="ingallery-popup-wrap-img-subgallery-nav"></div>');
3500            var _subgalleryPrev = $('<div id="ingallery-popup-wrap-img-subgallery-prev"><i class="ing-icon-angle-left ing-fw"></i></div>');
3501            var _subgalleryNext = $('<div id="ingallery-popup-wrap-img-subgallery-next"><i class="ing-icon-angle-right ing-fw"></i></div>');
3502            var _subgalleryCurrentIdx = 0;
3503            for (var i = 0; i < _item.items.length; i++) {
3504                var _subgalleryItemClass = '';
3505                if (i == _subgalleryCurrentIdx) {
3506                    _subgalleryItemClass = 'active';
3507                }
3508                var _subgalleryItem = '<div class="ingallery-popup-subgallery-item ' + _subgalleryItemClass + '" data-ratio="' + _item.items[i].ratio + '" data-width="' + _item.items[i].full_width + '" data-height="' + _item.items[i].full_height + '">';
3509                if (_item.items[i].type=='video') {
3510                    imgPlaceholder.addClass('ing-video');
3511                    _subgalleryItem += '<video poster="' + _item.items[i].picture_url + '" src="' + _item.items[i].video_url + '" preload="false" ' + (this.cfg.display_popup_loop_video ? 'loop="loop"' : '') + ' playsinline type="video/mp4"><source src="' + _item.items[i].video_url + '" type="video/mp4"></video>';
3512                } else {
3513                    _subgalleryItem += '<img src="' + _item.items[i].picture_url + '" />';
3514                }
3515                _subgalleryItem += '</div>';
3516                _subgalleryItems.append(_subgalleryItem);
3517                _subgalleryNav.append('<i class="' + _subgalleryItemClass + '"></i>');
3518            }
3519            _subgallery.append(_subgalleryItems);
3520            _subgallery.append(_subgalleryNav);
3521            _subgallery.append(_subgalleryPrev);
3522            _subgallery.append(_subgalleryNext);
3523            imgPlaceholder.empty().append(_subgallery);
3524
3525            _subgallery.find('video').each(function () {
3526                var _video = $(this);
3527                _video.on('click', function () {
3528                    var player = _video.get(0);
3529                    if (player.paused) {
3530                        imgPlaceholder.addClass('ing-playing');
3531                        player.play();
3532                    } else {
3533                        imgPlaceholder.removeClass('ing-playing');
3534                        player.pause();
3535                    }
3536                });
3537            });
3538
3539            var checkNav = function () {
3540                if (_subgalleryCurrentIdx == 0) {
3541                    _subgalleryPrev.hide();
3542                } else {
3543                    _subgalleryPrev.show();
3544                }
3545                if (_subgalleryCurrentIdx == _item.items.length - 1) {
3546                    _subgalleryNext.hide();
3547                } else {
3548                    _subgalleryNext.show();
3549                }
3550            }
3551            checkNav();
3552            var switchItem = function (_index) {
3553                if (_index < 0 || _index > _item.items.length - 1) {
3554                    return false;
3555                }
3556                if (imgPlaceholder.hasClass('ing-playing')) {
3557                    _subgalleryItems.children('.active').find('video').click();
3558                }
3559                var _direction = (_subgalleryCurrentIdx > _index ? 'backward' : 'forward');
3560                var _csgitemEx = $(_subgalleryItems.children().get(_subgalleryCurrentIdx));
3561                var _csgitem = $(_subgalleryItems.children().get(_index));
3562
3563                _subgalleryCurrentIdx = _index;
3564                popupImgWrap.attr('data-ratio', _csgitem.attr('data-ratio'));
3565                popupImgWrap.attr('data-width', _csgitem.attr('data-width'));
3566                popupImgWrap.attr('data-height', _csgitem.attr('data-height'));
3567                _subgalleryItems.children().removeClass('active prev next');
3568                _csgitem.addClass('active');
3569                _csgitem.prev().addClass('prev');
3570                _csgitem.next().addClass('next');
3571                _subgalleryNav.children().removeClass('active');
3572                $(_subgalleryNav.children().get(_index)).addClass('active');
3573                if (_csgitem.find('video').length) {
3574                    imgPlaceholder.addClass('ing-video');
3575                } else {
3576                    imgPlaceholder.removeClass('ing-video');
3577                }
3578                checkNav();
3579                if (_direction == 'forward') {
3580                    _csgitemEx.animate({
3581                        'left': '-100%'
3582                    }, 100);
3583                    _csgitem.css('left', '100%').animate({
3584                        'left': 0
3585                    }, 100);
3586                } else {
3587                    _csgitemEx.animate({
3588                        'left': '100%'
3589                    }, 100);
3590                    _csgitem.css('left', '-100%').animate({
3591                        'left': 0
3592                    }, 100);
3593                }
3594
3595                setFitPopup();
3596            }
3597            _subgalleryNav.children().on('click', function () {
3598                switchItem($(this).index());
3599                return false;
3600            });
3601            _subgalleryPrev.on('click', function () {
3602                switchItem(_subgalleryCurrentIdx - 1);
3603                return false;
3604            });
3605            _subgalleryNext.on('click', function () {
3606                switchItem(_subgalleryCurrentIdx + 1);
3607                return false;
3608            });
3609            switchItem(0);
3610        },
3611        
3612        updatePopupData: function(_data, _comments){
3613            //gallery.commentsCache[response.media_code] = response.html;
3614            var popupWrap = $('#ingallery-popup-wrap');
3615            
3616            var html = '';
3617            
3618            html = '<img src="' + _data.author_picture_url + '"> ' + _data.author_name;
3619            if (this.cfg.display_popup_instagram_link) {
3620                html = '<a href="https://www.instagram.com/' + _data.author_username + '/" title="' + _data.author_username + '" target="_blank"><img src="' + _data.author_picture_url + '"> ' + _data.author_name+'</a>';
3621            }    
3622            popupWrap.find('.ingallery-popup-content-user').removeClass('ing-loading').html(html).css('opacity', 0).stop().animate({
3623                'opacity': 1
3624            }, 300);
3625            
3626            popupWrap.find('.ingallery-popup-content-descr').removeClass('ing-loading').html(_data.text_html).css('opacity', 0).stop().animate({
3627                'opacity': 1
3628            }, 300);
3629            
3630            html = '';
3631            for(var i=0;i<_comments.length;i++){
3632                html+= '<div class="ingallery-popup-content-comments-item">';
3633		html+= '<strong><a href="https://www.instagram.com/'+_comments[i]['author_username']+'/" target="_blank" rel="nofollow">@'+_comments[i]['author_username']+'</a></strong>';
3634		html+= '<span>'+_comments[i]['text_html']+'</span>';
3635                html+= '</div>';
3636            }
3637            popupWrap.find('.ingallery-popup-content-comments').removeClass('ing-loading').html(html).css('opacity', 0).stop().animate({
3638                'opacity': 1
3639            }, 300);
3640        },
3641
3642        filterGallery: function (albumID, _force) {
3643            this.jqNode.css('height', this.jqNode.height());
3644            var oldAlbum = this.jqNode.find('.ingallery-album.active');
3645            if (oldAlbum.attr('data-id') == albumID && !_force) {
3646                return;
3647            }
3648            var newAlbum = this.jqNode.find('.ingallery-album[data-id="' + albumID + '"]');
3649            var itemsToShow;
3650            var itemsToHide;
3651
3652            this.jqNode.attr('data-filtered', newAlbum.attr('data-id'));
3653            oldAlbum.removeClass('active');
3654            newAlbum.addClass('active');
3655
3656            itemsToHide = this.jqNode.find('.ingallery-cell');
3657
3658            if (newAlbum.attr('data-id') == '0') {
3659                itemsToShow = this.jqNode.find('.ingallery-cell');
3660            } else {
3661                itemsToShow = this.jqNode.find('.ingallery-cell[data-album="' + newAlbum.attr('data-id') + '"]');
3662            }
3663            itemsToHide.stop().hide();
3664            itemsToShow.stop().show().css('opacity', 0).animate({
3665                'opacity': 1
3666            }, 300);
3667
3668            this.jqNode.css('height', 'auto');
3669            this.fitLayout();
3670
3671            if (this.masonry) {
3672                this.buildMasonryLayout();
3673                this.masonry.masonry('layout');
3674            }
3675        },
3676
3677        checkCarouselLoad: function (_nextSlideID) {
3678            var carousel = this.jqNode.find('.ingallery-items').data('ingslick');
3679            if (!carousel) {
3680                return;
3681            }
3682            var curSlide;
3683            var totalSlides;
3684            if (_nextSlideID) {
3685                carousel.currentSlide = _nextSlideID;
3686            }
3687            if (carousel.options.rows > 1) {
3688                curSlide = carousel.currentSlide;
3689                totalSlides = carousel.slideCount;
3690                //carousel.options.slidesPerRow
3691            } else {
3692                curSlide = Math.floor((parseInt(carousel.currentSlide) + 1) / parseInt(carousel.options.slidesToShow));
3693                totalSlides = Math.ceil((parseInt(carousel.slideCount) - parseInt(carousel.options.slidesToShow)) / parseInt(carousel.options.slidesToShow));
3694            }
3695            if (curSlide > totalSlides - 3) {
3696                this.jqNode.find('.ingallery-loadmore-btn').click();
3697            }
3698        },
3699
3700        checkInfScroll: function (loadMoreBtn) {
3701            if (loadMoreBtn.hasClass('disabled')) {
3702                return false;
3703            }
3704            var top = $(window).scrollTop() + ($(window).height() * 1.4);
3705            if (top > loadMoreBtn.offset().top) {
3706                loadMoreBtn.click();
3707            }
3708        },
3709
3710        buildMasonryLayout: function () {
3711            if (this.cfg.layout_type != 'masonry') {
3712                return this;
3713            }
3714            var cols = this.cfg.layout_cols;
3715            var maxColPos = cols - 1;
3716            var curColPos = -1;
3717            var colPosDir = 1;
3718            var lastRowNum = -1;
3719
3720            this.jqNode.find('.ingallery-cell:visible').each(function (index) {
3721                var itemRowNum = Math.floor(index / (cols * 2 - 1));
3722                var itemColNum = index % (cols * 2 - 1);
3723                if (lastRowNum != itemRowNum) {
3724                    if (curColPos + colPosDir > maxColPos) {
3725                        colPosDir = -1;
3726                    } else if (curColPos + colPosDir < 0) {
3727                        colPosDir = 1;
3728                    }
3729                    curColPos += colPosDir;
3730                }
3731                if (curColPos == itemColNum) {
3732                    $(this).addClass('ingallery-cell-big');
3733                } else {
3734                    $(this).removeClass('ingallery-cell-big');
3735                }
3736                lastRowNum = itemRowNum;
3737            });
3738            this.fitLayout();
3739        },
3740
3741        activateMasonry: function () {
3742            this.masonry = this.jqNode.find('.ingallery-items').masonry({
3743                'itemSelector': '.ingallery-cell',
3744                'percentPosition': true,
3745                'columnWidth': '.grid-sizer',
3746                'masonry': {
3747                    'columnWidth': '.grid-sizer'
3748                },
3749                'originLeft': $('body').css('direction')!=='rtl'
3750            });
3751        },
3752
3753        bindItemsLinks: function () {
3754            var gallery = this;
3755            this.jqNode.find('a.ingallery-item-link-popup').off('click').on('click', function (e) {
3756                e.preventDefault();
3757                var $this = $(this);
3758                var code = $this.closest('.ingallery-item').data('code');
3759                var _item = gallery.getItem(code);
3760                _item.jqItem = $this;
3761                gallery.showInPopup(_item);
3762                return false;
3763            });
3764        },
3765
3766    }
3767
3768    function getMessageHTML(msg, type) {
3769        var html = '<div class="ingallery-message ing-' + type + '">';
3770        html += '<div class="ingallery-message-title">' + window.inGallery.getLangString('error_title') + '</div>';
3771        html += '<div class="ingallery-message-text">' + msg + '</div>';
3772        html += '</div>';
3773        return html;
3774    }
3775
3776    function setFitPopup() {
3777        if (fitPopupTimeout > 0) {
3778            window.clearTimeout(fitPopupTimeout);
3779            fitPopupTimeout = 0;
3780        }
3781        fitPopupTimeout = window.setTimeout(fitPopup, 100);
3782    }
3783
3784    function fitPopup() {
3785        if (fitPopupTimeout > 0) {
3786            window.clearTimeout(fitPopupTimeout);
3787            fitPopupTimeout = 0;
3788        }
3789        if (!popupShown) {
3790            return;
3791        }
3792        var popupImgWrap = $('#ingallery-popup-wrap-img');
3793        var popupWrap = $('#ingallery-popup-wrap');
3794        var winH = $(window).height();
3795        var winW = $(window).width();
3796        var ratio = popupImgWrap.attr('data-ratio');
3797        if (popupImgWrap.length == 0 || popupWrap.length == 0) {
3798            return false;
3799        }
3800        if (winW < 750) {
3801            popup.addClass('ing-smallest');
3802            popupWrap.height(winW / ratio);
3803            return false;
3804        } else {
3805            popup.removeClass('ing-smallest');
3806        }
3807        var maxH = winH - 100;
3808        var minH = 550;
3809        var maxw = winW - 330 - 100;
3810        if (popupImgWrap.attr('data-img-size') == 'try_to_fit') {
3811            maxH = Math.min(maxH, popupImgWrap.attr('data-height'));
3812            maxw = Math.min(maxw, popupImgWrap.attr('data-width'));
3813        }
3814        var width = 750;
3815        var height = width / ratio;
3816        if (height > maxH) {
3817            height = maxH;
3818            width = height * ratio;
3819        }
3820        if (height < minH) {
3821            height = minH;
3822            width = height * ratio;
3823        }
3824        if (width > maxw) {
3825            width = maxw;
3826            height = width / ratio;
3827        }
3828        var top = Math.max((winH - height) / 2, 50);
3829        popup.css('top', top);
3830        popupWrap.height(height);
3831        popupImgWrap.width(width);
3832
3833    }
3834
3835    function precisionRound(number, precision) {
3836        var factor = Math.pow(10, precision);
3837        return Math.round(number * factor) / factor;
3838    }
3839
3840    window.inGallery = {
3841        config: null,
3842        create: function (htmlNode, config, items) {
3843            return new InGallery(htmlNode, config, items);
3844        },
3845        addRequestData: function (gallery) {
3846            return '';
3847        },
3848        getParams: function () {
3849            if (this.config !== null) {
3850                return this.config;
3851            } else if ($('#ingallery-cfg').length) {
3852                this.config = JSON.parse($('#ingallery-cfg').html());
3853                if (!this.config || !this.config['ajax_url']) {
3854                    console.log('No InGallery config');
3855                }
3856                return this.config;
3857            } else {
3858                console.log('No InGallery config');
3859            }
3860        },
3861        getLangString: function (key) {
3862            var params = this.getParams();
3863            return params.lang[key];
3864        },
3865        getParam: function (paramName) {
3866            var params = this.getParams();
3867            return params[paramName];
3868        },
3869    }
3870    
3871    $(window).on('resize', function () {
3872        setFitPopup();
3873    });
3874    
3875    $(document).ready(function (e) {
3876        $('.ingallery-container').each(function () {
3877            var self = $(this);
3878            self.html(loaderHTML);
3879            var $aj = {
3880                url: window.inGallery.getParam('ajax_url'),
3881                type: 'get',
3882                dataType: 'json',
3883                cache: true,
3884                data: 'task=gallery.view&id=' + self.attr('data-id'),
3885                success: function (response, statusText, xhr, $form) {
3886                    if (!response) {
3887                        self.html(getMessageHTML(window.inGallery.getLangString('system_error'), 'error'));
3888                        return false;
3889                    }
3890                    if (response && response.status && response.status == 'success') {
3891                        var node = $(response.html);
3892                        self.empty().append(node);
3893                        window.inGallery.create(node.get(0), response.config, response.items);
3894                    } else if (response && response.status && response.status == 'error') {
3895                        self.html(getMessageHTML(response.message, 'error'));
3896                    } else {
3897                        self.html(getMessageHTML(window.inGallery.getLangString('system_error'), 'error'));
3898                    }
3899                },
3900                error: function (jqXHR, textStatus, errorThrown) {
3901                    self.html(getMessageHTML(window.inGallery.getLangString('system_error') + '<br><i>' + textStatus + ' (' + errorThrown + ')</i>', 'error'));
3902                },
3903            }
3904            $.ajax($aj);
3905        });
3906    });
3907
3908})(jQuery);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.