PageSourceSearch

https://www.alderac.com/wp-content/themes/magazine-hoot-premium/premium/js/lightGallery.js?ver=1.1.4

js alderac.com collected 2026-09-24 18:01:39 UTC 106,893 bytes, 3,123 lines download raw bytes

1/*! lightgallery - v1.6.0 - 2017-08-08
2* {WPHOOT modified} removed lg-hash, lg-share
3* http://sachinchoolur.github.io/lightGallery/
4* Copyright (c) 2017 Sachin N; Licensed GPLv3 */
5/*! lightgallery - v1.6.0 - 2017-08-08
6* http://sachinchoolur.github.io/lightGallery/
7* Copyright (c) 2017 Sachin N; Licensed GPLv3 */
8(function (root, factory) {
9  if (typeof define === 'function' && define.amd) {
10    // AMD. Register as an anonymous module unless amdModuleId is set
11    define(['jquery'], function (a0) {
12      return (factory(a0));
13    });
14  } else if (typeof exports === 'object') {
15    // Node. Does not work with strict CommonJS, but
16    // only CommonJS-like environments that support module.exports,
17    // like Node.
18    module.exports = factory(require('jquery'));
19  } else {
20    factory(root["jQuery"]);
21  }
22}(this, function ($) {
23
24(function() {
25    'use strict';
26
27    var defaults = {
28
29        mode: 'lg-slide',
30
31        // Ex : 'ease'
32        cssEasing: 'ease',
33
34        //'for jquery animation'
35        easing: 'linear',
36        speed: 600,
37        height: '100%',
38        width: '100%',
39        addClass: '',
40        startClass: 'lg-start-zoom',
41        backdropDuration: 150,
42        hideBarsDelay: 6000,
43
44        useLeft: false,
45
46        closable: true,
47        loop: true,
48        escKey: true,
49        keyPress: true,
50        controls: true,
51        slideEndAnimatoin: true,
52        hideControlOnEnd: false,
53        mousewheel: true,
54
55        getCaptionFromTitleOrAlt: true,
56
57        // .lg-item || '.lg-sub-html'
58        appendSubHtmlTo: '.lg-sub-html',
59
60        subHtmlSelectorRelative: false,
61
62        /**
63         * @desc number of preload slides
64         * will exicute only after the current slide is fully loaded.
65         *
66         * @ex you clicked on 4th image and if preload = 1 then 3rd slide and 5th
67         * slide will be loaded in the background after the 4th slide is fully loaded..
68         * if preload is 2 then 2nd 3rd 5th 6th slides will be preloaded.. ... ...
69         *
70         */
71        preload: 1,
72        showAfterLoad: true,
73        selector: '',
74        selectWithin: '',
75        nextHtml: '',
76        prevHtml: '',
77
78        // 0, 1
79        index: false,
80
81        iframeMaxWidth: '100%',
82
83        download: true,
84        counter: true,
85        appendCounterTo: '.lg-toolbar',
86
87        swipeThreshold: 50,
88        enableSwipe: true,
89        enableDrag: true,
90
91        dynamic: false,
92        dynamicEl: [],
93        galleryId: 1
94    };
95
96    function Plugin(element, options) {
97
98        // Current lightGallery element
99        this.el = element;
100
101        // Current jquery element
102        this.$el = $(element);
103
104        // lightGallery settings
105        this.s = $.extend({}, defaults, options);
106
107        // When using dynamic mode, ensure dynamicEl is an array
108        if (this.s.dynamic && this.s.dynamicEl !== 'undefined' && this.s.dynamicEl.constructor === Array && !this.s.dynamicEl.length) {
109            throw ('When using dynamic mode, you must also define dynamicEl as an Array.');
110        }
111
112        // lightGallery modules
113        this.modules = {};
114
115        // false when lightgallery complete first slide;
116        this.lGalleryOn = false;
117
118        this.lgBusy = false;
119
120        // Timeout function for hiding controls;
121        this.hideBartimeout = false;
122
123        // To determine browser supports for touch events;
124        this.isTouch = ('ontouchstart' in document.documentElement);
125
126        // Disable hideControlOnEnd if sildeEndAnimation is true
127        if (this.s.slideEndAnimatoin) {
128            this.s.hideControlOnEnd = false;
129        }
130
131        // Gallery items
132        if (this.s.dynamic) {
133            this.$items = this.s.dynamicEl;
134        } else {
135            if (this.s.selector === 'this') {
136                this.$items = this.$el;
137            } else if (this.s.selector !== '') {
138                if (this.s.selectWithin) {
139                    this.$items = $(this.s.selectWithin).find(this.s.selector);
140                } else {
141                    this.$items = this.$el.find($(this.s.selector));
142                }
143            } else {
144                this.$items = this.$el.children();
145            }
146        }
147
148        // .lg-item
149        this.$slide = '';
150
151        // .lg-outer
152        this.$outer = '';
153
154        this.init();
155
156        return this;
157    }
158
159    Plugin.prototype.init = function() {
160
161        var _this = this;
162
163        // s.preload should not be more than $item.length
164        if (_this.s.preload > _this.$items.length) {
165            _this.s.preload = _this.$items.length;
166        }
167
168        // if dynamic option is enabled execute immediately
169        var _hash = window.location.hash;
170        if (_hash.indexOf('lg=' + this.s.galleryId) > 0) {
171
172            _this.index = parseInt(_hash.split('&slide=')[1], 10);
173
174            $('body').addClass('lg-from-hash');
175            if (!$('body').hasClass('lg-on')) {
176                setTimeout(function() {
177                    _this.build(_this.index);
178                });
179
180                $('body').addClass('lg-on');
181            }
182        }
183
184        if (_this.s.dynamic) {
185
186            _this.$el.trigger('onBeforeOpen.lg');
187
188            _this.index = _this.s.index || 0;
189
190            // prevent accidental double execution
191            if (!$('body').hasClass('lg-on')) {
192                setTimeout(function() {
193                    _this.build(_this.index);
194                    $('body').addClass('lg-on');
195                });
196            }
197        } else {
198
199            // Using different namespace for click because click event should not unbind if selector is same object('this')
200            _this.$items.on('click.lgcustom', function(event) {
201
202                // For IE8
203                try {
204                    event.preventDefault();
205                    event.preventDefault();
206                } catch (er) {
207                    event.returnValue = false;
208                }
209
210                _this.$el.trigger('onBeforeOpen.lg');
211
212                _this.index = _this.s.index || _this.$items.index(this);
213
214                // prevent accidental double execution
215                if (!$('body').hasClass('lg-on')) {
216                    _this.build(_this.index);
217                    $('body').addClass('lg-on');
218                }
219            });
220        }
221
222    };
223
224    Plugin.prototype.build = function(index) {
225
226        var _this = this;
227
228        _this.structure();
229
230        // module constructor
231        $.each($.fn.lightGallery.modules, function(key) {
232            _this.modules[key] = new $.fn.lightGallery.modules[key](_this.el);
233        });
234
235        // initiate slide function
236        _this.slide(index, false, false, false);
237
238        if (_this.s.keyPress) {
239            _this.keyPress();
240        }
241
242        if (_this.$items.length > 1) {
243
244            _this.arrow();
245
246            setTimeout(function() {
247                _this.enableDrag();
248                _this.enableSwipe();
249            }, 50);
250
251            if (_this.s.mousewheel) {
252                _this.mousewheel();
253            }
254        } else {
255            _this.$slide.on('click.lg', function() {
256                _this.$el.trigger('onSlideClick.lg');
257            });
258        }
259
260        _this.counter();
261
262        _this.closeGallery();
263
264        _this.$el.trigger('onAfterOpen.lg');
265
266        // Hide controllers if mouse doesn't move for some period
267        _this.$outer.on('mousemove.lg click.lg touchstart.lg', function() {
268
269            _this.$outer.removeClass('lg-hide-items');
270
271            clearTimeout(_this.hideBartimeout);
272
273            // Timeout will be cleared on each slide movement also
274            _this.hideBartimeout = setTimeout(function() {
275                _this.$outer.addClass('lg-hide-items');
276            }, _this.s.hideBarsDelay);
277
278        });
279
280        _this.$outer.trigger('mousemove.lg');
281
282    };
283
284    Plugin.prototype.structure = function() {
285        var list = '';
286        var controls = '';
287        var i = 0;
288        var subHtmlCont = '';
289        var template;
290        var _this = this;
291
292        $('body').append('<div class="lg-backdrop"></div>');
293        $('.lg-backdrop').css('transition-duration', this.s.backdropDuration + 'ms');
294
295        // Create gallery items
296        for (i = 0; i < this.$items.length; i++) {
297            list += '<div class="lg-item"></div>';
298        }
299
300        // Create controlls
301        if (this.s.controls && this.$items.length > 1) {
302            controls = '<div class="lg-actions">' +
303                '<button class="lg-prev lg-icon">' + this.s.prevHtml + '</button>' +
304                '<button class="lg-next lg-icon">' + this.s.nextHtml + '</button>' +
305                '</div>';
306        }
307
308        if (this.s.appendSubHtmlTo === '.lg-sub-html') {
309            subHtmlCont = '<div class="lg-sub-html"></div>';
310        }
311
312        template = '<div class="lg-outer ' + this.s.addClass + ' ' + this.s.startClass + '">' +
313            '<div class="lg" style="width:' + this.s.width + '; height:' + this.s.height + '">' +
314            '<div class="lg-inner">
314' + list + '</div>' +
315            '<div class="lg-toolbar lg-group">' +
316            '<span class="lg-close lg-icon"></span>' +
317            '</div>' +
318            controls +
319            subHtmlCont +
320            '</div>' +
321            '</div>';
322
323        $('body').append(template);
324        this.$outer = $('.lg-outer');
325        this.$slide = this.$outer.find('.lg-item');
326
327        if (this.s.useLeft) {
328            this.$outer.addClass('lg-use-left');
329
330            // Set mode lg-slide if use left is true;
331            this.s.mode = 'lg-slide';
332        } else {
333            this.$outer.addClass('lg-use-css3');
334        }
335
336        // For fixed height gallery
337        _this.setTop();
338        $(window).on('resize.lg orientationchange.lg', function() {
339            setTimeout(function() {
340                _this.setTop();
341            }, 100);
342        });
343
344        // add class lg-current to remove initial transition
345        this.$slide.eq(this.index).addClass('lg-current');
346
347        // add Class for css support and transition mode
348        if (this.doCss()) {
349            this.$outer.addClass('lg-css3');
350        } else {
351            this.$outer.addClass('lg-css');
352
353            // Set speed 0 because no animation will happen if browser doesn't support css3
354            this.s.speed = 0;
355        }
356
357        this.$outer.addClass(this.s.mode);
358
359        if (this.s.enableDrag && this.$items.length > 1) {
360            this.$outer.addClass('lg-grab');
361        }
362
363        if (this.s.showAfterLoad) {
364            this.$outer.addClass('lg-show-after-load');
365        }
366
367        if (this.doCss()) {
368            var $inner = this.$outer.find('.lg-inner');
369            $inner.css('transition-timing-function', this.s.cssEasing);
370            $inner.css('transition-duration', this.s.speed + 'ms');
371        }
372
373        setTimeout(function() {
374            $('.lg-backdrop').addClass('in');
375        });
376
377        setTimeout(function() {
378            _this.$outer.addClass('lg-visible');
379        }, this.s.backdropDuration);
380
381        if (this.s.download) {
382            this.$outer.find('.lg-toolbar').append('<a id="lg-download" target="_blank" download class="lg-download lg-icon"></a>');
383        }
384
385        // Store the current scroll top value to scroll back after closing the gallery..
386        this.prevScrollTop = $(window).scrollTop();
387
388    };
389
390    // For fixed height gallery
391    Plugin.prototype.setTop = function() {
392        if (this.s.height !== '100%') {
393            var wH = $(window).height();
394            var top = (wH - parseInt(this.s.height, 10)) / 2;
395            var $lGallery = this.$outer.find('.lg');
396            if (wH >= parseInt(this.s.height, 10)) {
397                $lGallery.css('top', top + 'px');
398            } else {
399                $lGallery.css('top', '0px');
400            }
401        }
402    };
403
404    // Find css3 support
405    Plugin.prototype.doCss = function() {
406        // check for css animation support
407        var support = function() {
408            var transition = ['transition', 'MozTransition', 'WebkitTransition', 'OTransition', 'msTransition', 'KhtmlTransition'];
409            var root = document.documentElement;
410            var i = 0;
411            for (i = 0; i < transition.length; i++) {
412                if (transition[i] in root.style) {
413                    return true;
414                }
415            }
416        };
417
418        if (support()) {
419            return true;
420        }
421
422        return false;
423    };
424
425    /**
426     *  @desc Check the given src is video
427     *  @param {String} src
428     *  @return {Object} video type
429     *  Ex:{ youtube  :  ["//www.youtube.com/watch?v=c0asJgSyxcY", "c0asJgSyxcY"] }
430     */
431    Plugin.prototype.isVideo = function(src, index) {
432
433        var html;
434        if (this.s.dynamic) {
435            html = this.s.dynamicEl[index].html;
436        } else {
437            html = this.$items.eq(index).attr('data-html');
438        }
439
440        if (!src) {
441            if(html) {
442                return {
443                    html5: true
444                };
445            } else {
446                console.error('lightGallery :- data-src is not pvovided on slide item ' + (index + 1) + '. Please make sure the selector property is properly configured. More info - http://sachinchoolur.github.io/lightGallery/demos/html-markup.html');
447                return false;
448            }
449        }
450
451        var youtube = src.match(/\/\/(?:www\.)?youtu(?:\.be|be\.com)\/(?:watch\?v=|embed\/)?([a-z0-9\-\_\%]+)/i);
452        var vimeo = src.match(/\/\/(?:www\.)?vimeo.com\/(\d+)(?:\/([0-9a-z]+))?/i);
453        var dailymotion = src.match(/\/\/(?:www\.)?dai.ly\/([0-9a-z\-_]+)/i);
454        var vk = src.match(/\/\/(?:www\.)?(?:vk\.com|vkontakte\.ru)\/(?:video_ext\.php\?)(.*)/i);
455
456        if (youtube) {
457            return {
458                youtube: youtube
459            };
460        } else if (vimeo) {
461            return {
462                vimeo: vimeo
463            };
464        } else if (dailymotion) {
465            return {
466                dailymotion: dailymotion
467            };
468        } else if (vk) {
469            return {
470                vk: vk
471            };
472        }
473    };
474
475    /**
476     *  @desc Create image counter
477     *  Ex: 1/10
478     */
479    Plugin.prototype.counter = function() {
480        if (this.s.counter) {
481            $(this.s.appendCounterTo).append('<div id="lg-counter"><span id="lg-counter-current">' + (parseInt(this.index, 10) + 1) + '</span> / <span id="lg-counter-all">' + this.$items.length + '</span></div>');
482        }
483    };
484
485    /**
486     *  @desc add sub-html into the slide
487     *  @param {Number} index - index of the slide
488     */
489    Plugin.prototype.addHtml = function(index) {
490        var subHtml = null;
491        var subHtmlUrl;
492        var $currentEle;
493        if (this.s.dynamic) {
494            if (this.s.dynamicEl[index].subHtmlUrl) {
495                subHtmlUrl = this.s.dynamicEl[index].subHtmlUrl;
496            } else {
497                subHtml = this.s.dynamicEl[index].subHtml;
498            }
499        } else {
500            $currentEle = this.$items.eq(index);
501            if ($currentEle.attr('data-sub-html-url')) {
502                subHtmlUrl = $currentEle.attr('data-sub-html-url');
503            } else {
504                subHtml = $currentEle.attr('data-sub-html');
505                if (this.s.getCaptionFromTitleOrAlt && !subHtml) {
506                    subHtml = $currentEle.attr('title') || $currentEle.find('img').first().attr('alt');
507                }
508            }
509        }
510
511        if (!subHtmlUrl) {
512            if (typeof subHtml !== 'undefined' && subHtml !== null) {
513
514                // get first letter of subhtml
515                // if first letter starts with . or # get the html form the jQuery object
516                var fL = subHtml.substring(0, 1);
517                if (fL === '.' || fL === '#') {
518                    if (this.s.subHtmlSelectorRelative && !this.s.dynamic) {
519                        subHtml = $currentEle.find(subHtml).html();
520                    } else {
521                        subHtml = $(subHtml).html();
522                    }
523                }
524            } else {
525                subHtml = '';
526            }
527        }
528
529        if (this.s.appendSubHtmlTo === '.lg-sub-html') {
530
531            if (subHtmlUrl) {
532                this.$outer.find(this.s.appendSubHtmlTo).load(subHtmlUrl);
533            } else {
534                this.$outer.find(this.s.appendSubHtmlTo).html(subHtml);
535            }
536
537        } else {
538
539            if (subHtmlUrl) {
540                this.$slide.eq(index).load(subHtmlUrl);
541            } else {
542                this.$slide.eq(index).append(subHtml);
543            }
544        }
545
546        // Add lg-empty-html class if title doesn't exist
547        if (typeof subHtml !== 'undefined' && subHtml !== null) {
548            if (subHtml === '') {
549                this.$outer.find(this.s.appendSubHtmlTo).addClass('lg-empty-html');
550            } else {
551                this.$outer.find(this.s.appendSubHtmlTo).removeClass('lg-empty-html');
552            }
553        }
554
555        this.$el.trigger('onAfterAppendSubHtml.lg', [index]);
556    };
557
558    /**
559     *  @desc Preload slides
560     *  @param {Number} index - index of the slide
561     */
562    Plugin.prototype.preload = function(index) {
563        var i = 1;
564        var j = 1;
565        for (i = 1; i <= this.s.preload; i++) {
566            if (i >= this.$items.length - index) {
567                break;
568            }
569
570            this.loadContent(index + i, false, 0);
571        }
572
573        for (j = 1; j <= this.s.preload; j++) {
574            if (index - j < 0) {
575                break;
576            }
577
578            this.loadContent(index - j, false, 0);
579        }
580    };
581
582    /**
583     *  @desc Load slide content into slide.
584     *  @param {Number} index - index of the slide.
585     *  @param {Boolean} rec - if true call loadcontent() function again.
586     *  @param {Boolean} delay - delay for adding complete class. it is 0 except first time.
587     */
588    Plugin.prototype.loadContent = function(index, rec, delay) {
589
590        var _this = this;
591        var _hasPoster = false;
592        var _$img;
593        var _src;
594        var _poster;
595        var _srcset;
596        var _sizes;
597        var _html;
598        var getResponsiveSrc = function(srcItms) {
599            var rsWidth = [];
600            var rsSrc = [];
601            for (var i = 0; i < srcItms.length; i++) {
602                var __src = srcItms[i].split(' ');
603
604                // Manage empty space
605                if (__src[0] === '') {
606                    __src.splice(0, 1);
607                }
608
609                rsSrc.push(__src[0]);
610                rsWidth.push(__src[1]);
611            }
612
613            var wWidth = $(window).width();
614            for (var j = 0; j < rsWidth.length; j++) {
615                if (parseInt(rsWidth[j], 10) > wWidth) {
616                    _src = rsSrc[j];
617                    break;
618                }
619            }
620        };
621
622        if (_this.s.dynamic) {
623
624            if (_this.s.dynamicEl[index].poster) {
625                _hasPoster = true;
626                _poster = _this.s.dynamicEl[index].poster;
627            }
628
629            _html = _this.s.dynamicEl[index].html;
630            _src = _this.s.dynamicEl[index].src;
631
632            if (_this.s.dynamicEl[index].responsive) {
633                var srcDyItms = _this.s.dynamicEl[index].responsive.split(',');
634                getResponsiveSrc(srcDyItms);
635            }
636
637            _srcset = _this.s.dynamicEl[index].srcset;
638            _sizes = _this.s.dynamicEl[index].sizes;
639
640        } else {
641
642            if (_this.$items.eq(index).attr('data-poster')) {
643                _hasPoster = true;
644                _poster = _this.$items.eq(index).attr('data-poster');
645            }
646
647            _html = _this.$items.eq(index).attr('data-html');
648            _src = _this.$items.eq(index).attr('href') || _this.$items.eq(index).attr('data-src');
649
650            if (_this.$items.eq(index).attr('data-responsive')) {
651                var srcItms = _this.$items.eq(index).attr('data-responsive').split(',');
652                getResponsiveSrc(srcItms);
653            }
654
655            _srcset = _this.$items.eq(index).attr('data-srcset');
656            _sizes = _this.$items.eq(index).attr('data-sizes');
657
658        }
659
660        //if (_src || _srcset || _sizes || _poster) {
661
662        var iframe = false;
663        if (_this.s.dynamic) {
664            if (_this.s.dynamicEl[index].iframe) {
665                iframe = true;
666            }
667        } else {
668            if (_this.$items.eq(index).attr('data-iframe') === 'true') {
669                iframe = true;
670            }
671        }
672
673        var _isVideo = _this.isVideo(_src, index);
674        if (!_this.$slide.eq(index).hasClass('lg-loaded')) {
675            if (iframe) {
676                _this.$slide.eq(index).prepend('<div class="lg-video-cont lg-has-iframe" style="max-width:' + _this.s.iframeMaxWidth + '"><div class="lg-video"><iframe class="lg-object" frameborder="0" src="' + _src + '"  allowfullscreen="true"></iframe></div></div>');
677            } else if (_hasPoster) {
678                var videoClass = '';
679                if (_isVideo && _isVideo.youtube) {
680                    videoClass = 'lg-has-youtube';
681                } else if (_isVideo && _isVideo.vimeo) {
682                    videoClass = 'lg-has-vimeo';
683                } else {
684                    videoClass = 'lg-has-html5';
685                }
686
687                _this.$slide.eq(index).prepend('<div class="lg-video-cont ' + videoClass + ' "><div class="lg-video"><span class="lg-video-play"></span><img class="lg-object lg-has-poster" src="' + _poster + '" /></div></div>');
688
689            } else if (_isVideo) {
690                _this.$slide.eq(index).prepend('<div class="lg-video-cont "><div class="lg-video"></div></div>');
691                _this.$el.trigger('hasVideo.lg', [index, _src, _html]);
692            } else {
693                _this.$slide.eq(index).prepend('<div class="lg-img-wrap"><img class="lg-object lg-image" src="' + _src + '" /></div>');
694            }
695
696            _this.$el.trigger('onAferAppendSlide.lg', [index]);
697
698            _$img = _this.$slide.eq(index).find('.lg-object');
699            if (_sizes) {
700                _$img.attr('sizes', _sizes);
701            }
702
703            if (_srcset) {
704                _$img.attr('srcset', _srcset);
705                try {
706                    picturefill({
707                        elements: [_$img[0]]
708                    });
709                } catch (e) {
710                    console.warn('lightGallery :- If you want srcset to be supported for older browser please include picturefil version 2 javascript library in your document.');
711                }
712            }
713
714            if (this.s.appendSubHtmlTo !== '.lg-sub-html') {
715                _this.addHtml(index);
716            }
717
718            _this.$slide.eq(index).addClass('lg-loaded');
719        }
720
721        _this.$slide.eq(index).find('.lg-object').on('load.lg error.lg', function() {
722
723            // For first time add some delay for displaying the start animation.
724            var _speed = 0;
725
726            // Do not change the delay value because it is required for zoom plugin.
727            // If gallery opened from direct url (hash) speed value should be 0
728            if (delay && !$('body').hasClass('lg-from-hash')) {
729                _speed = delay;
730            }
731
732            setTimeout(function() {
733                _this.$slide.eq(index).addClass('lg-complete');
734                _this.$el.trigger('onSlideItemLoad.lg', [index, delay || 0]);
735            }, _speed);
736
737        });
738
739        // @todo check load state for html5 videos
740        if (_isVideo && _isVideo.html5 && !_hasPoster) {
741            _this.$slide.eq(index).addClass('lg-complete');
742        }
743
744        if (rec === true) {
745            if (!_this.$slide.eq(index).hasClass('lg-complete')) {
746                _this.$slide.eq(index).find('.lg-object').on('load.lg error.lg', function() {
747                    _this.preload(index);
748                });
749            } else {
750                _this.preload(index);
751            }
752        }
753
754        //}
755    };
756
757    /**
758    *   @desc slide function for lightgallery
759        ** Slide() gets call on start
760        ** ** Set lg.on true once slide() function gets called.
761        ** Call loadContent() on slide() function inside setTimeout
762        ** ** On first slide we do not want any animation like slide of fade
763        ** ** So on first slide( if lg.on if false that is first slide) loadContent() should start loading immediately
764        ** ** Else loadContent() should wait for the transition to complete.
765        ** ** So set timeout s.speed + 50
766    <=> ** loadContent() will load slide content in to the particular slide
767        ** ** It has recursion (rec) parameter. if rec === true loadContent() will call preload() function.
768        ** ** preload will execute only when the previous slide is fully loaded (images iframe)
769        ** ** avoid simultaneous image load
770    <=> ** Preload() will check for s.preload value and call loadContent() again accoring to preload value
771        ** loadContent()  <====> Preload();
772
773    *   @param {Number} index - index of the slide
774    *   @param {Boolean} fromTouch - true if slide function called via touch event or mouse drag
775    *   @param {Boolean} fromThumb - true if slide function called via thumbnail click
776    *   @param {String} direction - Direction of the slide(next/prev)
777    */
778    Plugin.prototype.slide = function(index, fromTouch, fromThumb, direction) {
779
780        var _prevIndex = this.$outer.find('.lg-current').index();
781        var _this = this;
782
783        // Prevent if multiple call
784        // Required for hsh plugin
785        if (_this.lGalleryOn && (_prevIndex === index)) {
786            return;
787        }
788
789        var _length = this.$slide.length;
790        var _time = _this.lGalleryOn ? this.s.speed : 0;
791
792        if (!_this.lgBusy) {
793
794            if (this.s.download) {
795                var _src;
796                if (_this.s.dynamic) {
797                    _src = _this.s.dynamicEl[index].downloadUrl !== false && (_this.s.dynamicEl[index].downloadUrl || _this.s.dynamicEl[index].src);
798                } else {
799                    _src = _this.$items.eq(index).attr('data-download-url') !== 'false' && (_this.$items.eq(index).attr('data-download-url') || _this.$items.eq(index).attr('href') || _this.$items.eq(index).attr('data-src'));
800
801                }
802
803                if (_src) {
804                    $('#lg-download').attr('href', _src);
805                    _this.$outer.removeClass('lg-hide-download');
806                } else {
807                    _this.$outer.addClass('lg-hide-download');
808                }
809            }
810
811            this.$el.trigger('onBeforeSlide.lg', [_prevIndex, index, fromTouch, fromThumb]);
812
813            _this.lgBusy = true;
814
815            clearTimeout(_this.hideBartimeout);
816
817            // Add title if this.s.appendSubHtmlTo === lg-sub-html
818            if (this.s.appendSubHtmlTo === '.lg-sub-html') {
819
820                // wait for slide animation to complete
821                setTimeout(function() {
822                    _this.addHtml(index);
823                }, _time);
824            }
825
826            this.arrowDisable(index);
827
828            if (!direction) {
829                if (index < _prevIndex) {
830                    direction = 'prev';
831                } else if (index > _prevIndex) {
832                    direction = 'next';
833                }
834            }
835
836            if (!fromTouch) {
837
838                // remove all transitions
839                _this.$outer.addClass('lg-no-trans');
840
841                this.$slide.removeClass('lg-prev-slide lg-next-slide');
842
843                if (direction === 'prev') {
844
845                    //prevslide
846                    this.$slide.eq(index).addClass('lg-prev-slide');
847                    this.$slide.eq(_prevIndex).addClass('lg-next-slide');
848                } else {
849
850                    // next slide
851                    this.$slide.eq(index).addClass('lg-next-slide');
852                    this.$slide.eq(_prevIndex).addClass('lg-prev-slide');
853                }
854
855                // give 50 ms for browser to add/remove class
856                setTimeout(function() {
857                    _this.$slide.removeClass('lg-current');
858
859                    //_this.$slide.eq(_prevIndex).removeClass('lg-current');
860                    _this.$slide.eq(index).addClass('lg-current');
861
862                    // reset all transitions
863                    _this.$outer.removeClass('lg-no-trans');
864                }, 50);
865            } else {
866
867                this.$slide.removeClass('lg-prev-slide lg-current lg-next-slide');
868                var touchPrev;
869                var touchNext;
870                if (_length > 2) {
871                    touchPrev = index - 1;
872                    touchNext = index + 1;
873
874                    if ((index === 0) && (_prevIndex === _length - 1)) {
875
876                        // next slide
877                        touchNext = 0;
878                        touchPrev = _length - 1;
879                    } else if ((index === _length - 1) && (_prevIndex === 0)) {
880
881                        // prev slide
882                        touchNext = 0;
883                        touchPrev = _length - 1;
884                    }
885
886                } else {
887                    touchPrev = 0;
888                    touchNext = 1;
889                }
890
891                if (direction === 'prev') {
892                    _this.$slide.eq(touchNext).addClass('lg-next-slide');
893                } else {
894                    _this.$slide.eq(touchPrev).addClass('lg-prev-slide');
895                }
896
897                _this.$slide.eq(index).addClass('lg-current');
898            }
899
900            if (_this.lGalleryOn) {
901                setTimeout(function() {
902                    _this.loadContent(index, true, 0);
903                }, this.s.speed + 50);
904
905                setTimeout(function() {
906                    _this.lgBusy = false;
907                    _this.$el.trigger('onAfterSlide.lg', [_prevIndex, index, fromTouch, fromThumb]);
908                }, this.s.speed);
909
910            } else {
911                _this.loadContent(index, true, _this.s.backdropDuration);
912
913                _this.lgBusy = false;
914                _this.$el.trigger('onAfterSlide.lg', [_prevIndex, index, fromTouch, fromThumb]);
915            }
916
917            _this.lGalleryOn = true;
918
919            if (this.s.counter) {
920                $('#lg-counter-current').text(index + 1);
921            }
922
923        }
924
925    };
926
927    /**
928     *  @desc Go to next slide
929     *  @param {Boolean} fromTouch - true if slide function called via touch event
930     */
931    Plugin.prototype.goToNextSlide = function(fromTouch) {
932        var _this = this;
933        var _loop = _this.s.loop;
934        if (fromTouch && _this.$slide.length < 3) {
935            _loop = false;
936        }
937
938        if (!_this.lgBusy) {
939            if ((_this.index + 1) < _this.$slide.length) {
940                _this.index++;
941                _this.$el.trigger('onBeforeNextSlide.lg', [_this.index]);
942                _this.slide(_this.index, fromTouch, false, 'next');
943            } else {
944                if (_loop) {
945                    _this.index = 0;
946                    _this.$el.trigger('onBeforeNextSlide.lg', [_this.index]);
947                    _this.slide(_this.index, fromTouch, false, 'next');
948                } else if (_this.s.slideEndAnimatoin && !fromTouch) {
949                    _this.$outer.addClass('lg-right-end');
950                    setTimeout(function() {
951                        _this.$outer.removeClass('lg-right-end');
952                    }, 400);
953                }
954            }
955        }
956    };
957
958    /**
959     *  @desc Go to previous slide
960     *  @param {Boolean} fromTouch - true if slide function called via touch event
961     */
962    Plugin.prototype.goToPrevSlide = function(fromTouch) {
963        var _this = this;
964        var _loop = _this.s.loop;
965        if (fromTouch && _this.$slide.length < 3) {
966            _loop = false;
967        }
968
969        if (!_this.lgBusy) {
970            if (_this.index > 0) {
971                _this.index--;
972                _this.$el.trigger('onBeforePrevSlide.lg', [_this.index, fromTouch]);
973                _this.slide(_this.index, fromTouch, false, 'prev');
974            } else {
975                if (_loop) {
976                    _this.index = _this.$items.length - 1;
977                    _this.$el.trigger('onBeforePrevSlide.lg', [_this.index, fromTouch]);
978                    _this.slide(_this.index, fromTouch, false, 'prev');
979                } else if (_this.s.slideEndAnimatoin && !fromTouch) {
980                    _this.$outer.addClass('lg-left-end');
981                    setTimeout(function() {
982                        _this.$outer.removeClass('lg-left-end');
983                    }, 400);
984                }
985            }
986        }
987    };
988
989    Plugin.prototype.keyPress = function() {
990        var _this = this;
991        if (this.$items.length > 1) {
992            $(window).on('keyup.lg', function(e) {
993                if (_this.$items.length > 1) {
994                    if (e.keyCode === 37) {
995                        e.preventDefault();
996                        _this.goToPrevSlide();
997                    }
998
999                    if (e.keyCode === 39) {
1000                        e.preventDefault();
1001                        _this.goToNextSlide();
1002                    }
1003                }
1004            });
1005        }
1006
1007        $(window).on('keydown.lg', function(e) {
1008            if (_this.s.escKey === true && e.keyCode === 27) {
1009                e.preventDefault();
1010                if (!_this.$outer.hasClass('lg-thumb-open')) {
1011                    _this.destroy();
1012                } else {
1013                    _this.$outer.removeClass('lg-thumb-open');
1014                }
1015            }
1016        });
1017    };
1018
1019    Plugin.prototype.arrow = function() {
1020        var _this = this;
1021        this.$outer.find('.lg-prev').on('click.lg', function() {
1022            _this.goToPrevSlide();
1023        });
1024
1025        this.$outer.find('.lg-next').on('click.lg', function() {
1026            _this.goToNextSlide();
1027        });
1028    };
1029
1030    Plugin.prototype.arrowDisable = function(index) {
1031
1032        // Disable arrows if s.hideControlOnEnd is true
1033        if (!this.s.loop && this.s.hideControlOnEnd) {
1034            if ((index + 1) < this.$slide.length) {
1035                this.$outer.find('.lg-next').removeAttr('disabled').removeClass('disabled');
1036            } else {
1037                this.$outer.find('.lg-next').attr('disabled', 'disabled').addClass('disabled');
1038            }
1039
1040            if (index > 0) {
1041                this.$outer.find('.lg-prev').removeAttr('disabled').removeClass('disabled');
1042            } else {
1043                this.$outer.find('.lg-prev').attr('disabled', 'disabled').addClass('disabled');
1044            }
1045        }
1046    };
1047
1048    Plugin.prototype.setTranslate = function($el, xValue, yValue) {
1049        // jQuery supports Automatic CSS prefixing since jQuery 1.8.0
1050        if (this.s.useLeft) {
1051            $el.css('left', xValue);
1052        } else {
1053            $el.css({
1054                transform: 'translate3d(' + (xValue) + 'px, ' + yValue + 'px, 0px)'
1055            });
1056        }
1057    };
1058
1059    Plugin.prototype.touchMove = function(startCoords, endCoords) {
1060
1061        var distance = endCoords - startCoords;
1062
1063        if (Math.abs(distance) > 15) {
1064            // reset opacity and transition duration
1065            this.$outer.addClass('lg-dragging');
1066
1067            // move current slide
1068            this.setTranslate(this.$slide.eq(this.index), distance, 0);
1069
1070            // move next and prev slide with current slide
1071            this.setTranslate($('.lg-prev-slide'), -this.$slide.eq(this.index).width() + distance, 0);
1072            this.setTranslate($('.lg-next-slide'), this.$slide.eq(this.index).width() + distance, 0);
1073        }
1074    };
1075
1076    Plugin.prototype.touchEnd = function(distance) {
1077        var _this = this;
1078
1079        // keep slide animation for any mode while dragg/swipe
1080        if (_this.s.mode !== 'lg-slide') {
1081            _this.$outer.addClass('lg-slide');
1082        }
1083
1084        this.$slide.not('.lg-current, .lg-prev-slide, .lg-next-slide').css('opacity', '0');
1085
1086        // set transition duration
1087        setTimeout(function() {
1088            _this.$outer.removeClass('lg-dragging');
1089            if ((distance < 0) && (Math.abs(distance) > _this.s.swipeThreshold)) {
1090                _this.goToNextSlide(true);
1091            } else if ((distance > 0) && (Math.abs(distance) > _this.s.swipeThreshold)) {
1092                _this.goToPrevSlide(true);
1093            } else if (Math.abs(distance) < 5) {
1094
1095                // Trigger click if distance is less than 5 pix
1096                _this.$el.trigger('onSlideClick.lg');
1097            }
1098
1099            _this.$slide.removeAttr('style');
1100        });
1101
1102        // remove slide class once drag/swipe is completed if mode is not slide
1103        setTimeout(function() {
1104            if (!_this.$outer.hasClass('lg-dragging') && _this.s.mode !== 'lg-slide') {
1105                _this.$outer.removeClass('lg-slide');
1106            }
1107        }, _this.s.speed + 100);
1108
1109    };
1110
1111    Plugin.prototype.enableSwipe = function() {
1112        var _this = this;
1113        var startCoords = 0;
1114        var endCoords = 0;
1115        var isMoved = false;
1116
1117        if (_this.s.enableSwipe && _this.doCss()) {
1118
1119            _this.$slide.on('touchstart.lg', function(e) {
1120                if (!_this.$outer.hasClass('lg-zoomed') && !_this.lgBusy) {
1121                    e.preventDefault();
1122                    _this.manageSwipeClass();
1123                    startCoords = e.originalEvent.targetTouches[0].pageX;
1124                }
1125            });
1126
1127            _this.$slide.on('touchmove.lg', function(e) {
1128                if (!_this.$outer.hasClass('lg-zoomed')) {
1129                    e.preventDefault();
1130                    endCoords = e.originalEvent.targetTouches[0].pageX;
1131                    _this.touchMove(startCoords, endCoords);
1132                    isMoved = true;
1133                }
1134            });
1135
1136            _this.$slide.on('touchend.lg', function() {
1137                if (!_this.$outer.hasClass('lg-zoomed')) {
1138                    if (isMoved) {
1139                        isMoved = false;
1140                        _this.touchEnd(endCoords - startCoords);
1141                    } else {
1142                        _this.$el.trigger('onSlideClick.lg');
1143                    }
1144                }
1145            });
1146        }
1147
1148    };
1149
1150    Plugin.prototype.enableDrag = function() {
1151        var _this = this;
1152        var startCoords = 0;
1153        var endCoords = 0;
1154        var isDraging = false;
1155        var isMoved = false;
1156        if (_this.s.enableDrag && _this.doCss()) {
1157            _this.$slide.on('mousedown.lg', function(e) {
1158                // execute only on .lg-object
1159                if (!_this.$outer.hasClass('lg-zoomed')) {
1160                    if ($(e.target).hasClass('lg-object') || $(e.target).hasClass('lg-video-play')) {
1161                        e.preventDefault();
1162
1163                        if (!_this.lgBusy) {
1164                            _this.manageSwipeClass();
1165                            startCoords = e.pageX;
1166                            isDraging = true;
1167
1168                            // ** Fix for webkit cursor issue https://code.google.com/p/chromium/issues/detail?id=26723
1169                            _this.$outer.scrollLeft += 1;
1170                            _this.$outer.scrollLeft -= 1;
1171
1172                            // *
1173
1174                            _this.$outer.removeClass('lg-grab').addClass('lg-grabbing');
1175
1176                            _this.$el.trigger('onDragstart.lg');
1177                        }
1178
1179                    }
1180                }
1181            });
1182
1183            $(window).on('mousemove.lg', function(e) {
1184                if (isDraging) {
1185                    isMoved = true;
1186                    endCoords = e.pageX;
1187                    _this.touchMove(startCoords, endCoords);
1188                    _this.$el.trigger('onDragmove.lg');
1189                }
1190            });
1191
1192            $(window).on('mouseup.lg', function(e) {
1193                if (isMoved) {
1194                    isMoved = false;
1195                    _this.touchEnd(endCoords - startCoords);
1196                    _this.$el.trigger('onDragend.lg');
1197                } else if ($(e.target).hasClass('lg-object') || $(e.target).hasClass('lg-video-play')) {
1198                    _this.$el.trigger('onSlideClick.lg');
1199                }
1200
1201                // Prevent execution on click
1202                if (isDraging) {
1203                    isDraging = false;
1204                    _this.$outer.removeClass('lg-grabbing').addClass('lg-grab');
1205                }
1206            });
1207
1208        }
1209    };
1210
1211    Plugin.prototype.manageSwipeClass = function() {
1212        var _touchNext = this.index + 1;
1213        var _touchPrev = this.index - 1;
1214        if (this.s.loop && this.$slide.length > 2) {
1215            if (this.index === 0) {
1216                _touchPrev = this.$slide.length - 1;
1217            } else if (this.index === this.$slide.length - 1) {
1218                _touchNext = 0;
1219            }
1220        }
1221
1222        this.$slide.removeClass('lg-next-slide lg-prev-slide');
1223        if (_touchPrev > -1) {
1224            this.$slide.eq(_touchPrev).addClass('lg-prev-slide');
1225        }
1226
1227        this.$slide.eq(_touchNext).addClass('lg-next-slide');
1228    };
1229
1230    Plugin.prototype.mousewheel = function() {
1231        var _this = this;
1232        _this.$outer.on('mousewheel.lg', function(e) {
1233
1234            if (!e.deltaY) {
1235                return;
1236            }
1237
1238            if (e.deltaY > 0) {
1239                _this.goToPrevSlide();
1240            } else {
1241                _this.goToNextSlide();
1242            }
1243
1244            e.preventDefault();
1245        });
1246
1247    };
1248
1249    Plugin.prototype.closeGallery = function() {
1250
1251        var _this = this;
1252        var mousedown = false;
1253        this.$outer.find('.lg-close').on('click.lg', function() {
1254            _this.destroy();
1255        });
1256
1257        if (_this.s.closable) {
1258
1259            // If you drag the slide and release outside gallery gets close on chrome
1260            // for preventing this check mousedown and mouseup happened on .lg-item or lg-outer
1261            _this.$outer.on('mousedown.lg', function(e) {
1262
1263                if ($(e.target).is('.lg-outer') || $(e.target).is('.lg-item ') || $(e.target).is('.lg-img-wrap')) {
1264                    mousedown = true;
1265                } else {
1266                    mousedown = false;
1267                }
1268
1269            });
1270
1271            _this.$outer.on('mouseup.lg', function(e) {
1272
1273                if ($(e.target).is('.lg-outer') || $(e.target).is('.lg-item ') || $(e.target).is('.lg-img-wrap') && mousedown) {
1274                    if (!_this.$outer.hasClass('lg-dragging')) {
1275                        _this.destroy();
1276                    }
1277                }
1278
1279            });
1280
1281        }
1282
1283    };
1284
1285    Plugin.prototype.destroy = function(d) {
1286
1287        var _this = this;
1288
1289        if (!d) {
1290            _this.$el.trigger('onBeforeClose.lg');
1291            $(window).scrollTop(_this.prevScrollTop);
1292        }
1293
1294
1295        /**
1296         * if d is false or undefined destroy will only close the gallery
1297         * plugins instance remains with the element
1298         *
1299         * if d is true destroy will completely remove the plugin
1300         */
1301
1302        if (d) {
1303            if (!_this.s.dynamic) {
1304                // only when not using dynamic mode is $items a jquery collection
1305                this.$items.off('click.lg click.lgcustom');
1306            }
1307
1308            $.removeData(_this.el, 'lightGallery');
1309        }
1310
1311        // Unbind all events added by lightGallery
1312        this.$el.off('.lg.tm');
1313
1314        // Distroy all lightGallery modules
1315        $.each($.fn.lightGallery.modules, function(key) {
1316            if (_this.modules[key]) {
1317                _this.modules[key].destroy();
1318            }
1319        });
1320
1321        this.lGalleryOn = false;
1322
1323        clearTimeout(_this.hideBartimeout);
1324        this.hideBartimeout = false;
1325        $(window).off('.lg');
1326        $('body').removeClass('lg-on lg-from-hash');
1327
1328        if (_this.$outer) {
1329            _this.$outer.removeClass('lg-visible');
1330        }
1331
1332        $('.lg-backdrop').removeClass('in');
1333
1334        setTimeout(function() {
1335            if (_this.$outer) {
1336                _this.$outer.remove();
1337            }
1338
1339            $('.lg-backdrop').remove();
1340
1341            if (!d) {
1342                _this.$el.trigger('onCloseAfter.lg');
1343            }
1344
1345        }, _this.s.backdropDuration + 50);
1346    };
1347
1348    $.fn.lightGallery = function(options) {
1349        return this.each(function() {
1350            if (!$.data(this, 'lightGallery')) {
1351                $.data(this, 'lightGallery', new Plugin(this, options));
1352            } else {
1353                try {
1354                    $(this).data('lightGallery').init();
1355                } catch (err) {
1356                    console.error('lightGallery has not initiated properly');
1357                }
1358            }
1359        });
1360    };
1361
1362    $.fn.lightGallery.modules = {};
1363
1364})();
1365
1366
1367}));
1368
1369/*! lg-autoplay - v1.0.4 - 2017-03-28
1370* http://sachinchoolur.github.io/lightGallery
1371* Copyright (c) 2017 Sachin N; Licensed GPLv3 */
1372
1373(function (root, factory) {
1374  if (typeof define === 'function' && define.amd) {
1375    // AMD. Register as an anonymous module unless amdModuleId is set
1376    define(['jquery'], function (a0) {
1377      return (factory(a0));
1378    });
vendor: 6,521 bytes, lines 1379-1585
1379  } else if (typeof exports === 'object') {
1380    // Node. Does not work with strict CommonJS, but
1381    // only CommonJS-like environments that support module.exports,
1382    // like Node.
1383    module.exports = factory(require('jquery'));
1384  } else {
1385    factory(jQuery);
1386  }
1387}(this, function ($) {
1388
1389
1390(function() {
1391
1392    'use strict';
1393
1394    var defaults = {
1395        autoplay: false,
1396        pause: 5000,
1397        progressBar: true,
1398        fourceAutoplay: false,
1399        autoplayControls: true,
1400        appendAutoplayControlsTo: '.lg-toolbar'
1401    };
1402
1403    /**
1404     * Creates the autoplay plugin.
1405     * @param {object} element - lightGallery element
1406     */
1407    var Autoplay = function(element) {
1408
1409        this.core = $(element).data('lightGallery');
1410
1411        this.$el = $(element);
1412
1413        // Execute only if items are above 1
1414        if (this.core.$items.length < 2) {
1415            return false;
1416        }
1417
1418        this.core.s = $.extend({}, defaults, this.core.s);
1419        this.interval = false;
1420
1421        // Identify if slide happened from autoplay
1422        this.fromAuto = true;
1423
1424        // Identify if autoplay canceled from touch/drag
1425        this.canceledOnTouch = false;
1426
1427        // save fourceautoplay value
1428        this.fourceAutoplayTemp = this.core.s.fourceAutoplay;
1429
1430        // do not allow progress bar if browser does not support css3 transitions
1431        if (!this.core.doCss()) {
1432            this.core.s.progressBar = false;
1433        }
1434
1435        this.init();
1436
1437        return this;
1438    };
1439
1440    Autoplay.prototype.init = function() {
1441        var _this = this;
1442
1443        // append autoplay controls
1444        if (_this.core.s.autoplayControls) {
1445            _this.controls();
1446        }
1447
1448        // Create progress bar
1449        if (_this.core.s.progressBar) {
1450            _this.core.$outer.find('.lg').append('<div class="lg-progress-bar"><div class="lg-progress"></div></div>');
1451        }
1452
1453        // set progress
1454        _this.progress();
1455
1456        // Start autoplay
1457        if (_this.core.s.autoplay) {
1458            _this.$el.one('onSlideItemLoad.lg.tm', function() {
1459                _this.startlAuto();
1460            });
1461        }
1462
1463        // cancel interval on touchstart and dragstart
1464        _this.$el.on('onDragstart.lg.tm touchstart.lg.tm', function() {
1465            if (_this.interval) {
1466                _this.cancelAuto();
1467                _this.canceledOnTouch = true;
1468            }
1469        });
1470
1471        // restore autoplay if autoplay canceled from touchstart / dragstart
1472        _this.$el.on('onDragend.lg.tm touchend.lg.tm onSlideClick.lg.tm', function() {
1473            if (!_this.interval && _this.canceledOnTouch) {
1474                _this.startlAuto();
1475                _this.canceledOnTouch = false;
1476            }
1477        });
1478
1479    };
1480
1481    Autoplay.prototype.progress = function() {
1482
1483        var _this = this;
1484        var _$progressBar;
1485        var _$progress;
1486
1487        _this.$el.on('onBeforeSlide.lg.tm', function() {
1488
1489            // start progress bar animation
1490            if (_this.core.s.progressBar && _this.fromAuto) {
1491                _$progressBar = _this.core.$outer.find('.lg-progress-bar');
1492                _$progress = _this.core.$outer.find('.lg-progress');
1493                if (_this.interval) {
1494                    _$progress.removeAttr('style');
1495                    _$progressBar.removeClass('lg-start');
1496                    setTimeout(function() {
1497                        _$progress.css('transition', 'width ' + (_this.core.s.speed + _this.core.s.pause) + 'ms ease 0s');
1498                        _$progressBar.addClass('lg-start');
1499                    }, 20);
1500                }
1501            }
1502
1503            // Remove setinterval if slide is triggered manually and fourceautoplay is false
1504            if (!_this.fromAuto && !_this.core.s.fourceAutoplay) {
1505                _this.cancelAuto();
1506            }
1507
1508            _this.fromAuto = false;
1509
1510        });
1511    };
1512
1513    // Manage autoplay via play/stop buttons
1514    Autoplay.prototype.controls = function() {
1515        var _this = this;
1516        var _html = '<span class="lg-autoplay-button lg-icon"></span>';
1517
1518        // Append autoplay controls
1519        $(this.core.s.appendAutoplayControlsTo).append(_html);
1520
1521        _this.core.$outer.find('.lg-autoplay-button').on('click.lg', function() {
1522            if ($(_this.core.$outer).hasClass('lg-show-autoplay')) {
1523                _this.cancelAuto();
1524                _this.core.s.fourceAutoplay = false;
1525            } else {
1526                if (!_this.interval) {
1527                    _this.startlAuto();
1528                    _this.core.s.fourceAutoplay = _this.fourceAutoplayTemp;
1529                }
1530            }
1531        });
1532    };
1533
1534    // Autostart gallery
1535    Autoplay.prototype.startlAuto = function() {
1536        var _this = this;
1537
1538        _this.core.$outer.find('.lg-progress').css('transition', 'width ' + (_this.core.s.speed + _this.core.s.pause) + 'ms ease 0s');
1539        _this.core.$outer.addClass('lg-show-autoplay');
1540        _this.core.$outer.find('.lg-progress-bar').addClass('lg-start');
1541
1542        _this.interval = setInterval(function() {
1543            if (_this.core.index + 1 < _this.core.$items.length) {
1544                _this.core.index++;
1545            } else {
1546                _this.core.index = 0;
1547            }
1548
1549            _this.fromAuto = true;
1550            _this.core.slide(_this.core.index, false, false, 'next');
1551        }, _this.core.s.speed + _this.core.s.pause);
1552    };
1553
1554    // cancel Autostart
1555    Autoplay.prototype.cancelAuto = function() {
1556        clearInterval(this.interval);
1557        this.interval = false;
1558        this.core.$outer.find('.lg-progress').removeAttr('style');
1559        this.core.$outer.removeClass('lg-show-autoplay');
1560        this.core.$outer.find('.lg-progress-bar').removeClass('lg-start');
1561    };
1562
1563    Autoplay.prototype.destroy = function() {
1564
1565        this.cancelAuto();
1566        this.core.$outer.find('.lg-progress-bar').remove();
1567    };
1568
1569    $.fn.lightGallery.modules.autoplay = Autoplay;
1570
1571})();
1572
1573
1574}));
1575
1576/*! lg-fullscreen - v1.0.1 - 2016-09-30
1577* http://sachinchoolur.github.io/lightGallery
1578* Copyright (c) 2016 Sachin N; Licensed GPLv3 */
1579
1580(function (root, factory) {
1581  if (typeof define === 'function' && define.amd) {
1582    // AMD. Register as an anonymous module unless amdModuleId is set
1583    define(['jquery'], function (a0) {
1584      return (factory(a0));
1585    });
1586  } else if (typeof exports === 'object') {
1587    // Node. Does not work with strict CommonJS, but
1588    // only CommonJS-like environments that support module.exports,
1589    // like Node.
1590    module.exports = factory(require('jquery'));
1591  } else {
1592    factory(jQuery);
1593  }
1594}(this, function ($) {
1595
1596(function() {
1597
1598    'use strict';
1599
1600    var defaults = {
1601        fullScreen: true
1602    };
1603
1604    var Fullscreen = function(element) {
1605
1606        // get lightGallery core plugin data
1607        this.core = $(element).data('lightGallery');
1608
1609        this.$el = $(element);
1610
1611        // extend module defalut settings with lightGallery core settings
1612        this.core.s = $.extend({}, defaults, this.core.s);
1613
1614        this.init();
1615
1616        return this;
1617    };
1618
1619    Fullscreen.prototype.init = function() {
1620        var fullScreen = '';
1621        if (this.core.s.fullScreen) {
1622
1623            // check for fullscreen browser support
1624            if (!document.fullscreenEnabled && !document.webkitFullscreenEnabled &&
1625                !document.mozFullScreenEnabled && !document.msFullscreenEnabled) {
1626                return;
1627            } else {
1628                fullScreen = '<span class="lg-fullscreen lg-icon"></span>';
1629                this.core.$outer.find('.lg-toolbar').append(fullScreen);
1630                this.fullScreen();
1631            }
1632        }
1633    };
1634
1635    Fullscreen.prototype.requestFullscreen = function() {
1636        var el = document.documentElement;
1637        if (el.requestFullscreen) {
1638            el.requestFullscreen();
1639        } else if (el.msRequestFullscreen) {
1640            el.msRequestFullscreen();
1641        } else if (el.mozRequestFullScreen) {
1642            el.mozRequestFullScreen();
1643        } else if (el.webkitRequestFullscreen) {
1644            el.webkitRequestFullscreen();
1645        }
1646    };
1647
1648    Fullscreen.prototype.exitFullscreen = function() {
1649        if (document.exitFullscreen) {
1650            document.exitFullscreen();
1651        } else if (document.msExitFullscreen) {
1652            document.msExitFullscreen();
1653        } else if (document.mozCancelFullScreen) {
1654            document.mozCancelFullScreen();
1655        } else if (document.webkitExitFullscreen) {
1656            document.webkitExitFullscreen();
1657        }
1658    };
1659
1660    // https://developer.mozilla.org/en-US/docs/Web/Guide/API/DOM/Using_full_screen_mode
1661    Fullscreen.prototype.fullScreen = function() {
1662        var _this = this;
1663
1664        $(document).on('fullscreenchange.lg webkitfullscreenchange.lg mozfullscreenchange.lg MSFullscreenChange.lg', function() {
1665            _this.core.$outer.toggleClass('lg-fullscreen-on');
1666        });
1667
1668        this.core.$outer.find('.lg-fullscreen').on('click.lg', function() {
1669            if (!document.fullscreenElement &&
1670                !document.mozFullScreenElement && !document.webkitFullscreenElement && !document.msFullscreenElement) {
1671                _this.requestFullscreen();
1672            } else {
1673                _this.exitFullscreen();
1674            }
1675        });
1676
1677    };
1678
1679    Fullscreen.prototype.destroy = function() {
1680
1681        // exit from fullscreen if activated
1682        this.exitFullscreen();
1683
1684        $(document).off('fullscreenchange.lg webkitfullscreenchange.lg mozfullscreenchange.lg MSFullscreenChange.lg');
1685    };
1686
1687    $.fn.lightGallery.modules.fullscreen = Fullscreen;
1688
1689})();
1690
1691}));
1692
1693/*! lg-pager - v1.0.2 - 2017-01-22
1694* http://sachinchoolur.github.io/lightGallery
1695* Copyright (c) 2017 Sachin N; Licensed GPLv3 */
1696
1697(function (root, factory) {
1698  if (typeof define === 'function' && define.amd) {
1699    // AMD. Register as an anonymous module unless amdModuleId is set
1700    define(['jquery'], function (a0) {
1701      return (factory(a0));
1702    });
1703  } else if (typeof exports === 'object') {
1704    // Node. Does not work with strict CommonJS, but
1705    // only CommonJS-like environments that support module.exports,
1706    // like Node.
1707    module.exports = factory(require('jquery'));
1708  } else {
1709    factory(jQuery);
1710  }
1711}(this, function ($) {
1712
1713(function() {
1714
1715    'use strict';
1716
1717    var defaults = {
1718        pager: false
1719    };
1720
1721    var Pager = function(element) {
1722
1723        this.core = $(element).data('lightGallery');
1724
1725        this.$el = $(element);
1726        this.core.s = $.extend({}, defaults, this.core.s);
1727        if (this.core.s.pager && this.core.$items.length > 1) {
1728            this.init();
1729        }
1730
1731        return this;
1732    };
1733
1734    Pager.prototype.init = function() {
1735        var _this = this;
1736        var pagerList = '';
1737        var $pagerCont;
1738        var $pagerOuter;
1739        var timeout;
1740
1741        _this.core.$outer.find('.lg').append('<div class="lg-pager-outer"></div>');
1742
1743        if (_this.core.s.dynamic) {
1744            for (var i = 0; i < _this.core.s.dynamicEl.length; i++) {
1745                pagerList += '<span class="lg-pager-cont"> <span class="lg-pager"></span><div class="lg-pager-thumb-cont"><span class="lg-caret"></span> <img src="' + _this.core.s.dynamicEl[i].thumb + '" /></div></span>';
1746            }
1747        } else {
1748            _this.core.$items.each(function() {
1749
1750                if (!_this.core.s.exThumbImage) {
1751                    pagerList += '<span class="lg-pager-cont"> <span class="lg-pager"></span><div class="lg-pager-thumb-cont"><span class="lg-caret"></span> <img src="' + $(this).find('img').attr('src') + '" /></div></span>';
1752                } else {
1753                    pagerList += '<span class="lg-pager-cont"> <span class="lg-pager"></span><div class="lg-pager-thumb-cont"><span class="lg-caret"></span> <img src="' + $(this).attr(_this.core.s.exThumbImage) + '" /></div></span>';
1754                }
1755
1756            });
1757        }
1758
1759        $pagerOuter = _this.core.$outer.find('.lg-pager-outer');
1760
vendor: 17,682 bytes, lines 1761-2287
1761        $pagerOuter.html(pagerList);
1762
1763        $pagerCont = _this.core.$outer.find('.lg-pager-cont');
1764        $pagerCont.on('click.lg touchend.lg', function() {
1765            var _$this = $(this);
1766            _this.core.index = _$this.index();
1767            _this.core.slide(_this.core.index, false, true, false);
1768        });
1769
1770        $pagerOuter.on('mouseover.lg', function() {
1771            clearTimeout(timeout);
1772            $pagerOuter.addClass('lg-pager-hover');
1773        });
1774
1775        $pagerOuter.on('mouseout.lg', function() {
1776            timeout = setTimeout(function() {
1777                $pagerOuter.removeClass('lg-pager-hover');
1778            });
1779        });
1780
1781        _this.core.$el.on('onBeforeSlide.lg.tm', function(e, prevIndex, index) {
1782            $pagerCont.removeClass('lg-pager-active');
1783            $pagerCont.eq(index).addClass('lg-pager-active');
1784        });
1785
1786    };
1787
1788    Pager.prototype.destroy = function() {
1789
1790    };
1791
1792    $.fn.lightGallery.modules.pager = Pager;
1793
1794})();
1795
1796
1797}));
1798
1799/*! lg-thumbnail - v1.1.0 - 2017-08-08
1800* http://sachinchoolur.github.io/lightGallery
1801* Copyright (c) 2017 Sachin N; Licensed GPLv3 */
1802
1803(function (root, factory) {
1804  if (typeof define === 'function' && define.amd) {
1805    // AMD. Register as an anonymous module unless amdModuleId is set
1806    define(['jquery'], function (a0) {
1807      return (factory(a0));
1808    });
1809  } else if (typeof exports === 'object') {
1810    // Node. Does not work with strict CommonJS, but
1811    // only CommonJS-like environments that support module.exports,
1812    // like Node.
1813    module.exports = factory(require('jquery'));
1814  } else {
1815    factory(jQuery);
1816  }
1817}(this, function ($) {
1818
1819(function() {
1820
1821    'use strict';
1822
1823    var defaults = {
1824        thumbnail: true,
1825
1826        animateThumb: true,
1827        currentPagerPosition: 'middle',
1828
1829        thumbWidth: 100,
1830        thumbHeight: '80px',
1831        thumbContHeight: 100,
1832        thumbMargin: 5,
1833
1834        exThumbImage: false,
1835        showThumbByDefault: true,
1836        toogleThumb: true,
1837        pullCaptionUp: true,
1838
1839        enableThumbDrag: true,
1840        enableThumbSwipe: true,
1841        swipeThreshold: 50,
1842
1843        loadYoutubeThumbnail: true,
1844        youtubeThumbSize: 1,
1845
1846        loadVimeoThumbnail: true,
1847        vimeoThumbSize: 'thumbnail_small',
1848
1849        loadDailymotionThumbnail: true
1850    };
1851
1852    var Thumbnail = function(element) {
1853
1854        // get lightGallery core plugin data
1855        this.core = $(element).data('lightGallery');
1856
1857        // extend module default settings with lightGallery core settings
1858        this.core.s = $.extend({}, defaults, this.core.s);
1859
1860        this.$el = $(element);
1861        this.$thumbOuter = null;
1862        this.thumbOuterWidth = 0;
1863        this.thumbTotalWidth = (this.core.$items.length * (this.core.s.thumbWidth + this.core.s.thumbMargin));
1864        this.thumbIndex = this.core.index;
1865
1866        if (this.core.s.animateThumb) {
1867            this.core.s.thumbHeight = '100%';
1868        }
1869
1870        // Thumbnail animation value
1871        this.left = 0;
1872
1873        this.init();
1874
1875        return this;
1876    };
1877
1878    Thumbnail.prototype.init = function() {
1879        var _this = this;
1880        if (this.core.s.thumbnail && this.core.$items.length > 1) {
1881            if (this.core.s.showThumbByDefault) {
1882                setTimeout(function(){
1883                    _this.core.$outer.addClass('lg-thumb-open');
1884                }, 700);
1885            }
1886
1887            if (this.core.s.pullCaptionUp) {
1888                this.core.$outer.addClass('lg-pull-caption-up');
1889            }
1890
1891            this.build();
1892            if (this.core.s.animateThumb && this.core.doCss()) {
1893                if (this.core.s.enableThumbDrag) {
1894                    this.enableThumbDrag();
1895                }
1896
1897                if (this.core.s.enableThumbSwipe) {
1898                    this.enableThumbSwipe();
1899                }
1900
1901                this.thumbClickable = false;
1902            } else {
1903                this.thumbClickable = true;
1904            }
1905
1906            this.toogle();
1907            this.thumbkeyPress();
1908        }
1909    };
1910
1911    Thumbnail.prototype.build = function() {
1912        var _this = this;
1913        var thumbList = '';
1914        var vimeoErrorThumbSize = '';
1915        var $thumb;
1916        var html = '<div class="lg-thumb-outer">' +
1917            '<div class="lg-thumb lg-group">' +
1918            '</div>' +
1919            '</div>';
1920
1921        switch (this.core.s.vimeoThumbSize) {
1922            case 'thumbnail_large':
1923                vimeoErrorThumbSize = '640';
1924                break;
1925            case 'thumbnail_medium':
1926                vimeoErrorThumbSize = '200x150';
1927                break;
1928            case 'thumbnail_small':
1929                vimeoErrorThumbSize = '100x75';
1930        }
1931
1932        _this.core.$outer.addClass('lg-has-thumb');
1933
1934        _this.core.$outer.find('.lg').append(html);
1935
1936        _this.$thumbOuter = _this.core.$outer.find('.lg-thumb-outer');
1937        _this.thumbOuterWidth = _this.$thumbOuter.width();
1938
1939        if (_this.core.s.animateThumb) {
1940            _this.core.$outer.find('.lg-thumb').css({
1941                width: _this.thumbTotalWidth + 'px',
1942                position: 'relative'
1943            });
1944        }
1945
1946        if (this.core.s.animateThumb) {
1947            _this.$thumbOuter.css('height', _this.core.s.thumbContHeight + 'px');
1948        }
1949
1950        function getThumb(src, thumb, index) {
1951            var isVideo = _this.core.isVideo(src, index) || {};
1952            var thumbImg;
1953            var vimeoId = '';
1954
1955            if (isVideo.youtube || isVideo.vimeo || isVideo.dailymotion) {
1956                if (isVideo.youtube) {
1957                    if (_this.core.s.loadYoutubeThumbnail) {
1958                        thumbImg = '//img.youtube.com/vi/' + isVideo.youtube[1] + '/' + _this.core.s.youtubeThumbSize + '.jpg';
1959                    } else {
1960                        thumbImg = thumb;
1961                    }
1962                } else if (isVideo.vimeo) {
1963                    if (_this.core.s.loadVimeoThumbnail) {
1964                        thumbImg = '//i.vimeocdn.com/video/error_' + vimeoErrorThumbSize + '.jpg';
1965                        vimeoId = isVideo.vimeo[1];
1966                    } else {
1967                        thumbImg = thumb;
1968                    }
1969                } else if (isVideo.dailymotion) {
1970                    if (_this.core.s.loadDailymotionThumbnail) {
1971                        thumbImg = '//www.dailymotion.com/thumbnail/video/' + isVideo.dailymotion[1];
1972                    } else {
1973                        thumbImg = thumb;
1974                    }
1975                }
1976            } else {
1977                thumbImg = thumb;
1978            }
1979
1980            thumbList += '<div data-vimeo-id="' + vimeoId + '" class="lg-thumb-item" style="width:' + _this.core.s.thumbWidth + 'px; height: ' + _this.core.s.thumbHeight + '; margin-right: ' + _this.core.s.thumbMargin + 'px"><img src="' + thumbImg + '" /></div>';
1981            vimeoId = '';
1982        }
1983
1984        if (_this.core.s.dynamic) {
1985            for (var i = 0; i < _this.core.s.dynamicEl.length; i++) {
1986                getThumb(_this.core.s.dynamicEl[i].src, _this.core.s.dynamicEl[i].thumb, i);
1987            }
1988        } else {
1989            _this.core.$items.each(function(i) {
1990
1991                if (!_this.core.s.exThumbImage) {
1992                    getThumb($(this).attr('href') || $(this).attr('data-src'), $(this).find('img').attr('src'), i);
1993                } else {
1994                    getThumb($(this).attr('href') || $(this).attr('data-src'), $(this).attr(_this.core.s.exThumbImage), i);
1995                }
1996
1997            });
1998        }
1999
2000        _this.core.$outer.find('.lg-thumb').html(thumbList);
2001
2002        $thumb = _this.core.$outer.find('.lg-thumb-item');
2003
2004        // Load vimeo thumbnails
2005        $thumb.each(function() {
2006            var $this = $(this);
2007            var vimeoVideoId = $this.attr('data-vimeo-id');
2008
2009            if (vimeoVideoId) {
2010                $.getJSON('//www.vimeo.com/api/v2/video/' + vimeoVideoId + '.json?callback=?', {
2011                    format: 'json'
2012                }, function(data) {
2013                    $this.find('img').attr('src', data[0][_this.core.s.vimeoThumbSize]);
2014                });
2015            }
2016        });
2017
2018        // manage active class for thumbnail
2019        $thumb.eq(_this.core.index).addClass('active');
2020        _this.core.$el.on('onBeforeSlide.lg.tm', function() {
2021            $thumb.removeClass('active');
2022            $thumb.eq(_this.core.index).addClass('active');
2023        });
2024
2025        $thumb.on('click.lg touchend.lg', function() {
2026            var _$this = $(this);
2027            setTimeout(function() {
2028
2029                // In IE9 and bellow touch does not support
2030                // Go to slide if browser does not support css transitions
2031                if ((_this.thumbClickable && !_this.core.lgBusy) || !_this.core.doCss()) {
2032                    _this.core.index = _$this.index();
2033                    _this.core.slide(_this.core.index, false, true, false);
2034                }
2035            }, 50);
2036        });
2037
2038        _this.core.$el.on('onBeforeSlide.lg.tm', function() {
2039            _this.animateThumb(_this.core.index);
2040        });
2041
2042        $(window).on('resize.lg.thumb orientationchange.lg.thumb', function() {
2043            setTimeout(function() {
2044                _this.animateThumb(_this.core.index);
2045                _this.thumbOuterWidth = _this.$thumbOuter.width();
2046            }, 200);
2047        });
2048
2049    };
2050
2051    Thumbnail.prototype.setTranslate = function(value) {
2052        // jQuery supports Automatic CSS prefixing since jQuery 1.8.0
2053        this.core.$outer.find('.lg-thumb').css({
2054            transform: 'translate3d(-' + (value) + 'px, 0px, 0px)'
2055        });
2056    };
2057
2058    Thumbnail.prototype.animateThumb = function(index) {
2059        var $thumb = this.core.$outer.find('.lg-thumb');
2060        if (this.core.s.animateThumb) {
2061            var position;
2062            switch (this.core.s.currentPagerPosition) {
2063                case 'left':
2064                    position = 0;
2065                    break;
2066                case 'middle':
2067                    position = (this.thumbOuterWidth / 2) - (this.core.s.thumbWidth / 2);
2068                    break;
2069                case 'right':
2070                    position = this.thumbOuterWidth - this.core.s.thumbWidth;
2071            }
2072            this.left = ((this.core.s.thumbWidth + this.core.s.thumbMargin) * index - 1) - position;
2073            if (this.left > (this.thumbTotalWidth - this.thumbOuterWidth)) {
2074                this.left = this.thumbTotalWidth - this.thumbOuterWidth;
2075            }
2076
2077            if (this.left < 0) {
2078                this.left = 0;
2079            }
2080
2081            if (this.core.lGalleryOn) {
2082                if (!$thumb.hasClass('on')) {
2083                    this.core.$outer.find('.lg-thumb').css('transition-duration', this.core.s.speed + 'ms');
2084                }
2085
2086                if (!this.core.doCss()) {
2087                    $thumb.animate({
2088                        left: -this.left + 'px'
2089                    }, this.core.s.speed);
2090                }
2091            } else {
2092                if (!this.core.doCss()) {
2093                    $thumb.css('left', -this.left + 'px');
2094                }
2095            }
2096
2097            this.setTranslate(this.left);
2098
2099        }
2100    };
2101
2102    // Enable thumbnail dragging and swiping
2103    Thumbnail.prototype.enableThumbDrag = function() {
2104
2105        var _this = this;
2106        var startCoords = 0;
2107        var endCoords = 0;
2108        var isDraging = false;
2109        var isMoved = false;
2110        var tempLeft = 0;
2111
2112        _this.$thumbOuter.addClass('lg-grab');
2113
2114        _this.core.$outer.find('.lg-thumb').on('mousedown.lg.thumb', function(e) {
2115            if (_this.thumbTotalWidth > _this.thumbOuterWidth) {
2116                // execute only on .lg-object
2117                e.preventDefault();
2118                startCoords = e.pageX;
2119                isDraging = true;
2120
2121                // ** Fix for webkit cursor issue https://code.google.com/p/chromium/issues/detail?id=26723
2122                _this.core.$outer.scrollLeft += 1;
2123                _this.core.$outer.scrollLeft -= 1;
2124
2125                // *
2126                _this.thumbClickable = false;
2127                _this.$thumbOuter.removeClass('lg-grab').addClass('lg-grabbing');
2128            }
2129        });
2130
2131        $(window).on('mousemove.lg.thumb', function(e) {
2132            if (isDraging) {
2133                tempLeft = _this.left;
2134                isMoved = true;
2135                endCoords = e.pageX;
2136
2137                _this.$thumbOuter.addClass('lg-dragging');
2138
2139                tempLeft = tempLeft - (endCoords - startCoords);
2140
2141                if (tempLeft > (_this.thumbTotalWidth - _this.thumbOuterWidth)) {
2142                    tempLeft = _this.thumbTotalWidth - _this.thumbOuterWidth;
2143                }
2144
2145                if (tempLeft < 0) {
2146                    tempLeft = 0;
2147                }
2148
2149                // move current slide
2150                _this.setTranslate(tempLeft);
2151
2152            }
2153        });
2154
2155        $(window).on('mouseup.lg.thumb', function() {
2156            if (isMoved) {
2157                isMoved = false;
2158                _this.$thumbOuter.removeClass('lg-dragging');
2159
2160                _this.left = tempLeft;
2161
2162                if (Math.abs(endCoords - startCoords) < _this.core.s.swipeThreshold) {
2163                    _this.thumbClickable = true;
2164                }
2165
2166            } else {
2167                _this.thumbClickable = true;
2168            }
2169
2170            if (isDraging) {
2171                isDraging = false;
2172                _this.$thumbOuter.removeClass('lg-grabbing').addClass('lg-grab');
2173            }
2174        });
2175
2176    };
2177
2178    Thumbnail.prototype.enableThumbSwipe = function() {
2179        var _this = this;
2180        var startCoords = 0;
2181        var endCoords = 0;
2182        var isMoved = false;
2183        var tempLeft = 0;
2184
2185        _this.core.$outer.find('.lg-thumb').on('touchstart.lg', function(e) {
2186            if (_this.thumbTotalWidth > _this.thumbOuterWidth) {
2187                e.preventDefault();
2188                startCoords = e.originalEvent.targetTouches[0].pageX;
2189                _this.thumbClickable = false;
2190            }
2191        });
2192
2193        _this.core.$outer.find('.lg-thumb').on('touchmove.lg', function(e) {
2194            if (_this.thumbTotalWidth > _this.thumbOuterWidth) {
2195                e.preventDefault();
2196                endCoords = e.originalEvent.targetTouches[0].pageX;
2197                isMoved = true;
2198
2199                _this.$thumbOuter.addClass('lg-dragging');
2200
2201                tempLeft = _this.left;
2202
2203                tempLeft = tempLeft - (endCoords - startCoords);
2204
2205                if (tempLeft > (_this.thumbTotalWidth - _this.thumbOuterWidth)) {
2206                    tempLeft = _this.thumbTotalWidth - _this.thumbOuterWidth;
2207                }
2208
2209                if (tempLeft < 0) {
2210                    tempLeft = 0;
2211                }
2212
2213                // move current slide
2214                _this.setTranslate(tempLeft);
2215
2216            }
2217        });
2218
2219        _this.core.$outer.find('.lg-thumb').on('touchend.lg', function() {
2220            if (_this.thumbTotalWidth > _this.thumbOuterWidth) {
2221
2222                if (isMoved) {
2223                    isMoved = false;
2224                    _this.$thumbOuter.removeClass('lg-dragging');
2225                    if (Math.abs(endCoords - startCoords) < _this.core.s.swipeThreshold) {
2226                        _this.thumbClickable = true;
2227                    }
2228
2229                    _this.left = tempLeft;
2230                } else {
2231                    _this.thumbClickable = true;
2232                }
2233            } else {
2234                _this.thumbClickable = true;
2235            }
2236        });
2237
2238    };
2239
2240    Thumbnail.prototype.toogle = function() {
2241        var _this = this;
2242        if (_this.core.s.toogleThumb) {
2243            _this.core.$outer.addClass('lg-can-toggle');
2244            _this.$thumbOuter.append('<span class="lg-toogle-thumb lg-icon"></span>');
2245            _this.core.$outer.find('.lg-toogle-thumb').on('click.lg', function() {
2246                _this.core.$outer.toggleClass('lg-thumb-open');
2247            });
2248        }
2249    };
2250
2251    Thumbnail.prototype.thumbkeyPress = function() {
2252        var _this = this;
2253        $(window).on('keydown.lg.thumb', function(e) {
2254            if (e.keyCode === 38) {
2255                e.preventDefault();
2256                _this.core.$outer.addClass('lg-thumb-open');
2257            } else if (e.keyCode === 40) {
2258                e.preventDefault();
2259                _this.core.$outer.removeClass('lg-thumb-open');
2260            }
2261        });
2262    };
2263
2264    Thumbnail.prototype.destroy = function() {
2265        if (this.core.s.thumbnail && this.core.$items.length > 1) {
2266            $(window).off('resize.lg.thumb orientationchange.lg.thumb keydown.lg.thumb');
2267            this.$thumbOuter.remove();
2268            this.core.$outer.removeClass('lg-has-thumb');
2269        }
2270    };
2271
2272    $.fn.lightGallery.modules.Thumbnail = Thumbnail;
2273
2274})();
2275
2276}));
2277
2278/*! lg-video - v1.1.0 - 2017-08-08
2279* http://sachinchoolur.github.io/lightGallery
2280* Copyright (c) 2017 Sachin N; Licensed GPLv3 */
2281
2282(function (root, factory) {
2283  if (typeof define === 'function' && define.amd) {
2284    // AMD. Register as an anonymous module unless amdModuleId is set
2285    define(['jquery'], function (a0) {
2286      return (factory(a0));
2287    });
vendor: 12,503 bytes, lines 2288-2606
2288  } else if (typeof exports === 'object') {
2289    // Node. Does not work with strict CommonJS, but
2290    // only CommonJS-like environments that support module.exports,
2291    // like Node.
2292    module.exports = factory(require('jquery'));
2293  } else {
2294    factory(jQuery);
2295  }
2296}(this, function ($) {
2297
2298(function() {
2299
2300    'use strict';
2301
2302    var defaults = {
2303        videoMaxWidth: '855px',
2304        youtubePlayerParams: false,
2305        vimeoPlayerParams: false,
2306        dailymotionPlayerParams: false,
2307        vkPlayerParams: false,
2308        videojs: false,
2309        videojsOptions: {}
2310    };
2311
2312    var Video = function(element) {
2313
2314        this.core = $(element).data('lightGallery');
2315
2316        this.$el = $(element);
2317        this.core.s = $.extend({}, defaults, this.core.s);
2318        this.videoLoaded = false;
2319
2320        this.init();
2321
2322        return this;
2323    };
2324
2325    Video.prototype.init = function() {
2326        var _this = this;
2327
2328        // Event triggered when video url found without poster
2329        _this.core.$el.on('hasVideo.lg.tm', function(event, index, src, html) {
2330            _this.core.$slide.eq(index).find('.lg-video').append(_this.loadVideo(src, 'lg-object', true, index, html));
2331            if (html) {
2332                if (_this.core.s.videojs) {
2333                    try {
2334                        videojs(_this.core.$slide.eq(index).find('.lg-html5').get(0), _this.core.s.videojsOptions, function() {
2335                            if (!_this.videoLoaded) {
2336                                this.play();
2337                            }
2338                        });
2339                    } catch (e) {
2340                        console.error('Make sure you have included videojs');
2341                    }
2342                } else {
2343                    if(!_this.videoLoaded) {
2344                        _this.core.$slide.eq(index).find('.lg-html5').get(0).play();
2345                    }
2346                }
2347            }
2348        });
2349
2350        // Set max width for video
2351        _this.core.$el.on('onAferAppendSlide.lg.tm', function(event, index) {
2352            var $videoCont = _this.core.$slide.eq(index).find('.lg-video-cont');
2353            if (!$videoCont.hasClass('lg-has-iframe')) {
2354                $videoCont.css('max-width', _this.core.s.videoMaxWidth);
2355                _this.videoLoaded = true;
2356            }
2357        });
2358
2359        var loadOnClick = function($el) {
2360            // check slide has poster
2361            if ($el.find('.lg-object').hasClass('lg-has-poster') && $el.find('.lg-object').is(':visible')) {
2362
2363                // check already video element present
2364                if (!$el.hasClass('lg-has-video')) {
2365
2366                    $el.addClass('lg-video-playing lg-has-video');
2367
2368                    var _src;
2369                    var _html;
2370                    var _loadVideo = function(_src, _html) {
2371
2372                        $el.find('.lg-video').append(_this.loadVideo(_src, '', false, _this.core.index, _html));
2373
2374                        if (_html) {
2375                            if (_this.core.s.videojs) {
2376                                try {
2377                                    videojs(_this.core.$slide.eq(_this.core.index).find('.lg-html5').get(0), _this.core.s.videojsOptions, function() {
2378                                        this.play();
2379                                    });
2380                                } catch (e) {
2381                                    console.error('Make sure you have included videojs');
2382                                }
2383                            } else {
2384                                _this.core.$slide.eq(_this.core.index).find('.lg-html5').get(0).play();
2385                            }
2386                        }
2387
2388                    };
2389
2390                    if (_this.core.s.dynamic) {
2391
2392                        _src = _this.core.s.dynamicEl[_this.core.index].src;
2393                        _html = _this.core.s.dynamicEl[_this.core.index].html;
2394
2395                        _loadVideo(_src, _html);
2396
2397                    } else {
2398
2399                        _src = _this.core.$items.eq(_this.core.index).attr('href') || _this.core.$items.eq(_this.core.index).attr('data-src');
2400                        _html = _this.core.$items.eq(_this.core.index).attr('data-html');
2401
2402                        _loadVideo(_src, _html);
2403
2404                    }
2405
2406                    var $tempImg = $el.find('.lg-object');
2407                    $el.find('.lg-video').append($tempImg);
2408
2409                    // @todo loading icon for html5 videos also
2410                    // for showing the loading indicator while loading video
2411                    if (!$el.find('.lg-video-object').hasClass('lg-html5')) {
2412                        $el.removeClass('lg-complete');
2413                        $el.find('.lg-video-object').on('load.lg error.lg', function() {
2414                            $el.addClass('lg-complete');
2415                        });
2416                    }
2417
2418                } else {
2419
2420                    var youtubePlayer = $el.find('.lg-youtube').get(0);
2421                    var vimeoPlayer = $el.find('.lg-vimeo').get(0);
2422                    var dailymotionPlayer = $el.find('.lg-dailymotion').get(0);
2423                    var html5Player = $el.find('.lg-html5').get(0);
2424                    if (youtubePlayer) {
2425                        youtubePlayer.contentWindow.postMessage('{"event":"command","func":"playVideo","args":""}', '*');
2426                    } else if (vimeoPlayer) {
2427                        try {
2428                            $f(vimeoPlayer).api('play');
2429                        } catch (e) {
2430                            console.error('Make sure you have included froogaloop2 js');
2431                        }
2432                    } else if (dailymotionPlayer) {
2433                        dailymotionPlayer.contentWindow.postMessage('play', '*');
2434
2435                    } else if (html5Player) {
2436                        if (_this.core.s.videojs) {
2437                            try {
2438                                videojs(html5Player).play();
2439                            } catch (e) {
2440                                console.error('Make sure you have included videojs');
2441                            }
2442                        } else {
2443                            html5Player.play();
2444                        }
2445                    }
2446
2447                    $el.addClass('lg-video-playing');
2448
2449                }
2450            }
2451        };
2452
2453        if (_this.core.doCss() && (_this.core.$items.length > 1) && (_this.core.s.enableSwipe || _this.core.s.enableDrag)) {
2454            _this.core.$el.on('onSlideClick.lg.tm', function() {
2455                var $el = _this.core.$slide.eq(_this.core.index);
2456                loadOnClick($el);
2457            });
2458        } else {
2459
2460            // For IE 9 and bellow
2461            _this.core.$slide.on('click.lg', function() {
2462                loadOnClick($(this));
2463            });
2464        }
2465
2466        _this.core.$el.on('onBeforeSlide.lg.tm', function(event, prevIndex, index) {
2467
2468            var $videoSlide = _this.core.$slide.eq(prevIndex);
2469            var youtubePlayer = $videoSlide.find('.lg-youtube').get(0);
2470            var vimeoPlayer = $videoSlide.find('.lg-vimeo').get(0);
2471            var dailymotionPlayer = $videoSlide.find('.lg-dailymotion').get(0);
2472            var vkPlayer = $videoSlide.find('.lg-vk').get(0);
2473            var html5Player = $videoSlide.find('.lg-html5').get(0);
2474            if (youtubePlayer) {
2475                youtubePlayer.contentWindow.postMessage('{"event":"command","func":"pauseVideo","args":""}', '*');
2476            } else if (vimeoPlayer) {
2477                try {
2478                    $f(vimeoPlayer).api('pause');
2479                } catch (e) {
2480                    console.error('Make sure you have included froogaloop2 js');
2481                }
2482            } else if (dailymotionPlayer) {
2483                dailymotionPlayer.contentWindow.postMessage('pause', '*');
2484
2485            } else if (html5Player) {
2486                if (_this.core.s.videojs) {
2487                    try {
2488                        videojs(html5Player).pause();
2489                    } catch (e) {
2490                        console.error('Make sure you have included videojs');
2491                    }
2492                } else {
2493                    html5Player.pause();
2494                }
2495            } if (vkPlayer) {
2496                $(vkPlayer).attr('src', $(vkPlayer).attr('src').replace('&autoplay', '&noplay'));
2497            }
2498
2499            var _src;
2500            if (_this.core.s.dynamic) {
2501                _src = _this.core.s.dynamicEl[index].src;
2502            } else {
2503                _src = _this.core.$items.eq(index).attr('href') || _this.core.$items.eq(index).attr('data-src');
2504
2505            }
2506
2507            var _isVideo = _this.core.isVideo(_src, index) || {};
2508            if (_isVideo.youtube || _isVideo.vimeo || _isVideo.dailymotion || _isVideo.vk) {
2509                _this.core.$outer.addClass('lg-hide-download');
2510            }
2511
2512            //$videoSlide.addClass('lg-complete');
2513
2514        });
2515
2516        _this.core.$el.on('onAfterSlide.lg.tm', function(event, prevIndex) {
2517            _this.core.$slide.eq(prevIndex).removeClass('lg-video-playing');
2518        });
2519    };
2520
2521    Video.prototype.loadVideo = function(src, addClass, noposter, index, html) {
2522        var video = '';
2523        var autoplay = 1;
2524        var a = '';
2525        var isVideo = this.core.isVideo(src, index) || {};
2526
2527        // Enable autoplay for first video if poster doesn't exist
2528        if (noposter) {
2529            if (this.videoLoaded) {
2530                autoplay = 0;
2531            } else {
2532                autoplay = 1;
2533            }
2534        }
2535
2536        if (isVideo.youtube) {
2537
2538            a = '?wmode=opaque&autoplay=' + autoplay + '&enablejsapi=1';
2539            if (this.core.s.youtubePlayerParams) {
2540                a = a + '&' + $.param(this.core.s.youtubePlayerParams);
2541            }
2542
2543            video = '<iframe class="lg-video-object lg-youtube ' + addClass + '" width="560" height="315" src="//www.youtube.com/embed/' + isVideo.youtube[1] + a + '" frameborder="0" allowfullscreen></iframe>';
2544
2545        } else if (isVideo.vimeo) {
2546
2547            a = '?autoplay=' + autoplay + '&api=1';
2548            if (this.core.s.vimeoPlayerParams) {
2549                a = a + '&' + $.param(this.core.s.vimeoPlayerParams);
2550            }
2551
2552            if ( isVideo.vimeo[2] ) a += '&h=' + isVideo.vimeo[2];
2553            video = '<iframe class="lg-video-object lg-vimeo ' + addClass + '" width="560" height="315"  src="//player.vimeo.com/video/' + isVideo.vimeo[1] + a + '" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>';
2554
2555        } else if (isVideo.dailymotion) {
2556
2557            a = '?wmode=opaque&autoplay=' + autoplay + '&api=postMessage';
2558            if (this.core.s.dailymotionPlayerParams) {
2559                a = a + '&' + $.param(this.core.s.dailymotionPlayerParams);
2560            }
2561
2562            video = '<iframe class="lg-video-object lg-dailymotion ' + addClass + '" width="560" height="315" src="//www.dailymotion.com/embed/video/' + isVideo.dailymotion[1] + a + '" frameborder="0" allowfullscreen></iframe>';
2563
2564        } else if (isVideo.html5) {
2565            var fL = html.substring(0, 1);
2566            if (fL === '.' || fL === '#') {
2567                html = $(html).html();
2568            }
2569
2570            video = html;
2571
2572        } else if (isVideo.vk) {
2573
2574            a = '&autoplay=' + autoplay;
2575            if (this.core.s.vkPlayerParams) {
2576                a = a + '&' + $.param(this.core.s.vkPlayerParams);
2577            }
2578
2579            video = '<iframe class="lg-video-object lg-vk ' + addClass + '" width="560" height="315" src="http://vk.com/video_ext.php?' + isVideo.vk[1] + a + '" frameborder="0" allowfullscreen></iframe>';
2580
2581        }
2582
2583        return video;
2584    };
2585
2586    Video.prototype.destroy = function() {
2587        this.videoLoaded = false;
2588    };
2589
2590    $.fn.lightGallery.modules.video = Video;
2591
2592})();
2593
2594
2595}));
2596
2597/*! lg-zoom - v1.1.0 - 2017-08-08
2598* http://sachinchoolur.github.io/lightGallery
2599* Copyright (c) 2017 Sachin N; Licensed GPLv3 */
2600
2601(function (root, factory) {
2602  if (typeof define === 'function' && define.amd) {
2603    // AMD. Register as an anonymous module unless amdModuleId is set
2604    define(['jquery'], function (a0) {
2605      return (factory(a0));
2606    });
vendor: 17,833 bytes, lines 2607-3123
2607  } else if (typeof exports === 'object') {
2608    // Node. Does not work with strict CommonJS, but
2609    // only CommonJS-like environments that support module.exports,
2610    // like Node.
2611    module.exports = factory(require('jquery'));
2612  } else {
2613    factory(jQuery);
2614  }
2615}(this, function ($) {
2616
2617(function() {
2618
2619    'use strict';
2620
2621    var getUseLeft = function() {
2622        var useLeft = false;
2623        var isChrome = navigator.userAgent.match(/Chrom(e|ium)\/([0-9]+)\./);
2624        if (isChrome && parseInt(isChrome[2], 10) < 54) {
2625            useLeft = true;
2626        }
2627
2628        return useLeft;
2629    };
2630
2631    var defaults = {
2632        scale: 1,
2633        zoom: true,
2634        actualSize: true,
2635        enableZoomAfter: 300,
2636        useLeftForZoom: getUseLeft()
2637    };
2638
2639    var Zoom = function(element) {
2640
2641        this.core = $(element).data('lightGallery');
2642
2643        this.core.s = $.extend({}, defaults, this.core.s);
2644
2645        if (this.core.s.zoom && this.core.doCss()) {
2646            this.init();
2647
2648            // Store the zoomable timeout value just to clear it while closing
2649            this.zoomabletimeout = false;
2650
2651            // Set the initial value center
2652            this.pageX = $(window).width() / 2;
2653            this.pageY = ($(window).height() / 2) + $(window).scrollTop();
2654        }
2655
2656        return this;
2657    };
2658
2659    Zoom.prototype.init = function() {
2660
2661        var _this = this;
2662        var zoomIcons = '<span id="lg-zoom-in" class="lg-icon"></span><span id="lg-zoom-out" class="lg-icon"></span>';
2663
2664        if (_this.core.s.actualSize) {
2665            zoomIcons += '<span id="lg-actual-size" class="lg-icon"></span>';
2666        }
2667
2668        if (_this.core.s.useLeftForZoom) {
2669            _this.core.$outer.addClass('lg-use-left-for-zoom');
2670        } else {
2671            _this.core.$outer.addClass('lg-use-transition-for-zoom');
2672        }
2673
2674        this.core.$outer.find('.lg-toolbar').append(zoomIcons);
2675
2676        // Add zoomable class
2677        _this.core.$el.on('onSlideItemLoad.lg.tm.zoom', function(event, index, delay) {
2678
2679            // delay will be 0 except first time
2680            var _speed = _this.core.s.enableZoomAfter + delay;
2681
2682            // set _speed value 0 if gallery opened from direct url and if it is first slide
2683            if ($('body').hasClass('lg-from-hash') && delay) {
2684
2685                // will execute only once
2686                _speed = 0;
2687            } else {
2688
2689                // Remove lg-from-hash to enable starting animation.
2690                $('body').removeClass('lg-from-hash');
2691            }
2692
2693            _this.zoomabletimeout = setTimeout(function() {
2694                _this.core.$slide.eq(index).addClass('lg-zoomable');
2695            }, _speed + 30);
2696        });
2697
2698        var scale = 1;
2699        /**
2700         * @desc Image zoom
2701         * Translate the wrap and scale the image to get better user experience
2702         *
2703         * @param {String} scaleVal - Zoom decrement/increment value
2704         */
2705        var zoom = function(scaleVal) {
2706
2707            var $image = _this.core.$outer.find('.lg-current .lg-image');
2708            var _x;
2709            var _y;
2710
2711            // Find offset manually to avoid issue after zoom
2712            var offsetX = ($(window).width() - $image.prop('offsetWidth')) / 2;
2713            var offsetY = (($(window).height() - $image.prop('offsetHeight')) / 2) + $(window).scrollTop();
2714
2715            _x = _this.pageX - offsetX;
2716            _y = _this.pageY - offsetY;
2717
2718            var x = (scaleVal - 1) * (_x);
2719            var y = (scaleVal - 1) * (_y);
2720
2721            $image.css('transform', 'scale3d(' + scaleVal + ', ' + scaleVal + ', 1)').attr('data-scale', scaleVal);
2722
2723            if (_this.core.s.useLeftForZoom) {
2724                $image.parent().css({
2725                    left: -x + 'px',
2726                    top: -y + 'px'
2727                }).attr('data-x', x).attr('data-y', y);
2728            } else {
2729                $image.parent().css('transform', 'translate3d(-' + x + 'px, -' + y + 'px, 0)').attr('data-x', x).attr('data-y', y);
2730            }
2731        };
2732
2733        var callScale = function() {
2734            if (scale > 1) {
2735                _this.core.$outer.addClass('lg-zoomed');
2736            } else {
2737                _this.resetZoom();
2738            }
2739
2740            if (scale < 1) {
2741                scale = 1;
2742            }
2743
2744            zoom(scale);
2745        };
2746
2747        var actualSize = function(event, $image, index, fromIcon) {
2748            var w = $image.prop('offsetWidth');
2749            var nw;
2750            if (_this.core.s.dynamic) {
2751                nw = _this.core.s.dynamicEl[index].width || $image[0].naturalWidth || w;
2752            } else {
2753                nw = _this.core.$items.eq(index).attr('data-width') || $image[0].naturalWidth || w;
2754            }
2755
2756            var _scale;
2757
2758            if (_this.core.$outer.hasClass('lg-zoomed')) {
2759                scale = 1;
2760            } else {
2761                if (nw > w) {
2762                    _scale = nw / w;
2763                    scale = _scale || 2;
2764                }
2765            }
2766
2767            if (fromIcon) {
2768                _this.pageX = $(window).width() / 2;
2769                _this.pageY = ($(window).height() / 2) + $(window).scrollTop();
2770            } else {
2771                _this.pageX = event.pageX || event.originalEvent.targetTouches[0].pageX;
2772                _this.pageY = event.pageY || event.originalEvent.targetTouches[0].pageY;
2773            }
2774
2775            callScale();
2776            setTimeout(function() {
2777                _this.core.$outer.removeClass('lg-grabbing').addClass('lg-grab');
2778            }, 10);
2779        };
2780
2781        var tapped = false;
2782
2783        // event triggered after appending slide content
2784        _this.core.$el.on('onAferAppendSlide.lg.tm.zoom', function(event, index) {
2785
2786            // Get the current element
2787            var $image = _this.core.$slide.eq(index).find('.lg-image');
2788
2789            $image.on('dblclick', function(event) {
2790                actualSize(event, $image, index);
2791            });
2792
2793            $image.on('touchstart', function(event) {
2794                if (!tapped) {
2795                    tapped = setTimeout(function() {
2796                        tapped = null;
2797                    }, 300);
2798                } else {
2799                    clearTimeout(tapped);
2800                    tapped = null;
2801                    actualSize(event, $image, index);
2802                }
2803
2804                event.preventDefault();
2805            });
2806
2807        });
2808
2809        // Update zoom on resize and orientationchange
2810        $(window).on('resize.lg.zoom scroll.lg.zoom orientationchange.lg.zoom', function() {
2811            _this.pageX = $(window).width() / 2;
2812            _this.pageY = ($(window).height() / 2) + $(window).scrollTop();
2813            zoom(scale);
2814        });
2815
2816        $('#lg-zoom-out').on('click.lg', function() {
2817            if (_this.core.$outer.find('.lg-current .lg-image').length) {
2818                scale -= _this.core.s.scale;
2819                callScale();
2820            }
2821        });
2822
2823        $('#lg-zoom-in').on('click.lg', function() {
2824            if (_this.core.$outer.find('.lg-current .lg-image').length) {
2825                scale += _this.core.s.scale;
2826                callScale();
2827            }
2828        });
2829
2830        $('#lg-actual-size').on('click.lg', function(event) {
2831            actualSize(event, _this.core.$slide.eq(_this.core.index).find('.lg-image'), _this.core.index, true);
2832        });
2833
2834        // Reset zoom on slide change
2835        _this.core.$el.on('onBeforeSlide.lg.tm', function() {
2836            scale = 1;
2837            _this.resetZoom();
2838        });
2839
2840        // Drag option after zoom
2841        _this.zoomDrag();
2842
2843        _this.zoomSwipe();
2844
2845    };
2846
2847    // Reset zoom effect
2848    Zoom.prototype.resetZoom = function() {
2849        this.core.$outer.removeClass('lg-zoomed');
2850        this.core.$slide.find('.lg-img-wrap').removeAttr('style data-x data-y');
2851        this.core.$slide.find('.lg-image').removeAttr('style data-scale');
2852
2853        // Reset pagx pagy values to center
2854        this.pageX = $(window).width() / 2;
2855        this.pageY = ($(window).height() / 2) + $(window).scrollTop();
2856    };
2857
2858    Zoom.prototype.zoomSwipe = function() {
2859        var _this = this;
2860        var startCoords = {};
2861        var endCoords = {};
2862        var isMoved = false;
2863
2864        // Allow x direction drag
2865        var allowX = false;
2866
2867        // Allow Y direction drag
2868        var allowY = false;
2869
2870        _this.core.$slide.on('touchstart.lg', function(e) {
2871
2872            if (_this.core.$outer.hasClass('lg-zoomed')) {
2873                var $image = _this.core.$slide.eq(_this.core.index).find('.lg-object');
2874
2875                allowY = $image.prop('offsetHeight') * $image.attr('data-scale') > _this.core.$outer.find('.lg').height();
2876                allowX = $image.prop('offsetWidth') * $image.attr('data-scale') > _this.core.$outer.find('.lg').width();
2877                if ((allowX || allowY)) {
2878                    e.preventDefault();
2879                    startCoords = {
2880                        x: e.originalEvent.targetTouches[0].pageX,
2881                        y: e.originalEvent.targetTouches[0].pageY
2882                    };
2883                }
2884            }
2885
2886        });
2887
2888        _this.core.$slide.on('touchmove.lg', function(e) {
2889
2890            if (_this.core.$outer.hasClass('lg-zoomed')) {
2891
2892                var _$el = _this.core.$slide.eq(_this.core.index).find('.lg-img-wrap');
2893                var distanceX;
2894                var distanceY;
2895
2896                e.preventDefault();
2897                isMoved = true;
2898
2899                endCoords = {
2900                    x: e.originalEvent.targetTouches[0].pageX,
2901                    y: e.originalEvent.targetTouches[0].pageY
2902                };
2903
2904                // reset opacity and transition duration
2905                _this.core.$outer.addClass('lg-zoom-dragging');
2906
2907                if (allowY) {
2908                    distanceY = (-Math.abs(_$el.attr('data-y'))) + (endCoords.y - startCoords.y);
2909                } else {
2910                    distanceY = -Math.abs(_$el.attr('data-y'));
2911                }
2912
2913                if (allowX) {
2914                    distanceX = (-Math.abs(_$el.attr('data-x'))) + (endCoords.x - startCoords.x);
2915                } else {
2916                    distanceX = -Math.abs(_$el.attr('data-x'));
2917                }
2918
2919                if ((Math.abs(endCoords.x - startCoords.x) > 15) || (Math.abs(endCoords.y - startCoords.y) > 15)) {
2920
2921                    if (_this.core.s.useLeftForZoom) {
2922                        _$el.css({
2923                            left: distanceX + 'px',
2924                            top: distanceY + 'px'
2925                        });
2926                    } else {
2927                        _$el.css('transform', 'translate3d(' + distanceX + 'px, ' + distanceY + 'px, 0)');
2928                    }
2929                }
2930
2931            }
2932
2933        });
2934
2935        _this.core.$slide.on('touchend.lg', function() {
2936            if (_this.core.$outer.hasClass('lg-zoomed')) {
2937                if (isMoved) {
2938                    isMoved = false;
2939                    _this.core.$outer.removeClass('lg-zoom-dragging');
2940                    _this.touchendZoom(startCoords, endCoords, allowX, allowY);
2941
2942                }
2943            }
2944        });
2945
2946    };
2947
2948    Zoom.prototype.zoomDrag = function() {
2949
2950        var _this = this;
2951        var startCoords = {};
2952        var endCoords = {};
2953        var isDraging = false;
2954        var isMoved = false;
2955
2956        // Allow x direction drag
2957        var allowX = false;
2958
2959        // Allow Y direction drag
2960        var allowY = false;
2961
2962        _this.core.$slide.on('mousedown.lg.zoom', function(e) {
2963
2964            // execute only on .lg-object
2965            var $image = _this.core.$slide.eq(_this.core.index).find('.lg-object');
2966
2967            allowY = $image.prop('offsetHeight') * $image.attr('data-scale') > _this.core.$outer.find('.lg').height();
2968            allowX = $image.prop('offsetWidth') * $image.attr('data-scale') > _this.core.$outer.find('.lg').width();
2969
2970            if (_this.core.$outer.hasClass('lg-zoomed')) {
2971                if ($(e.target).hasClass('lg-object') && (allowX || allowY)) {
2972                    e.preventDefault();
2973                    startCoords = {
2974                        x: e.pageX,
2975                        y: e.pageY
2976                    };
2977
2978                    isDraging = true;
2979
2980                    // ** Fix for webkit cursor issue https://code.google.com/p/chromium/issues/detail?id=26723
2981                    _this.core.$outer.scrollLeft += 1;
2982                    _this.core.$outer.scrollLeft -= 1;
2983
2984                    _this.core.$outer.removeClass('lg-grab').addClass('lg-grabbing');
2985                }
2986            }
2987        });
2988
2989        $(window).on('mousemove.lg.zoom', function(e) {
2990            if (isDraging) {
2991                var _$el = _this.core.$slide.eq(_this.core.index).find('.lg-img-wrap');
2992                var distanceX;
2993                var distanceY;
2994
2995                isMoved = true;
2996                endCoords = {
2997                    x: e.pageX,
2998                    y: e.pageY
2999                };
3000
3001                // reset opacity and transition duration
3002                _this.core.$outer.addClass('lg-zoom-dragging');
3003
3004                if (allowY) {
3005                    distanceY = (-Math.abs(_$el.attr('data-y'))) + (endCoords.y - startCoords.y);
3006                } else {
3007                    distanceY = -Math.abs(_$el.attr('data-y'));
3008                }
3009
3010                if (allowX) {
3011                    distanceX = (-Math.abs(_$el.attr('data-x'))) + (endCoords.x - startCoords.x);
3012                } else {
3013                    distanceX = -Math.abs(_$el.attr('data-x'));
3014                }
3015
3016                if (_this.core.s.useLeftForZoom) {
3017                    _$el.css({
3018                        left: distanceX + 'px',
3019                        top: distanceY + 'px'
3020                    });
3021                } else {
3022                    _$el.css('transform', 'translate3d(' + distanceX + 'px, ' + distanceY + 'px, 0)');
3023                }
3024            }
3025        });
3026
3027        $(window).on('mouseup.lg.zoom', function(e) {
3028
3029            if (isDraging) {
3030                isDraging = false;
3031                _this.core.$outer.removeClass('lg-zoom-dragging');
3032
3033                // Fix for chrome mouse move on click
3034                if (isMoved && ((startCoords.x !== endCoords.x) || (startCoords.y !== endCoords.y))) {
3035                    endCoords = {
3036                        x: e.pageX,
3037                        y: e.pageY
3038                    };
3039                    _this.touchendZoom(startCoords, endCoords, allowX, allowY);
3040
3041                }
3042
3043                isMoved = false;
3044            }
3045
3046            _this.core.$outer.removeClass('lg-grabbing').addClass('lg-grab');
3047
3048        });
3049    };
3050
3051    Zoom.prototype.touchendZoom = function(startCoords, endCoords, allowX, allowY) {
3052
3053        var _this = this;
3054        var _$el = _this.core.$slide.eq(_this.core.index).find('.lg-img-wrap');
3055        var $image = _this.core.$slide.eq(_this.core.index).find('.lg-object');
3056        var distanceX = (-Math.abs(_$el.attr('data-x'))) + (endCoords.x - startCoords.x);
3057        var distanceY = (-Math.abs(_$el.attr('data-y'))) + (endCoords.y - startCoords.y);
3058        var minY = (_this.core.$outer.find('.lg').height() - $image.prop('offsetHeight')) / 2;
3059        var maxY = Math.abs(($image.prop('offsetHeight') * Math.abs($image.attr('data-scale'))) - _this.core.$outer.find('.lg').height() + minY);
3060        var minX = (_this.core.$outer.find('.lg').width() - $image.prop('offsetWidth')) / 2;
3061        var maxX = Math.abs(($image.prop('offsetWidth') * Math.abs($image.attr('data-scale'))) - _this.core.$outer.find('.lg').width() + minX);
3062
3063        if ((Math.abs(endCoords.x - startCoords.x) > 15) || (Math.abs(endCoords.y - startCoords.y) > 15)) {
3064            if (allowY) {
3065                if (distanceY <= -maxY) {
3066                    distanceY = -maxY;
3067                } else if (distanceY >= -minY) {
3068                    distanceY = -minY;
3069                }
3070            }
3071
3072            if (allowX) {
3073                if (distanceX <= -maxX) {
3074                    distanceX = -maxX;
3075                } else if (distanceX >= -minX) {
3076                    distanceX = -minX;
3077                }
3078            }
3079
3080            if (allowY) {
3081                _$el.attr('data-y', Math.abs(distanceY));
3082            } else {
3083                distanceY = -Math.abs(_$el.attr('data-y'));
3084            }
3085
3086            if (allowX) {
3087                _$el.attr('data-x', Math.abs(distanceX));
3088            } else {
3089                distanceX = -Math.abs(_$el.attr('data-x'));
3090            }
3091
3092            if (_this.core.s.useLeftForZoom) {
3093                _$el.css({
3094                    left: distanceX + 'px',
3095                    top: distanceY + 'px'
3096                });
3097            } else {
3098                _$el.css('transform', 'translate3d(' + distanceX + 'px, ' + distanceY + 'px, 0)');
3099            }
3100
3101        }
3102    };
3103
3104    Zoom.prototype.destroy = function() {
3105
3106        var _this = this;
3107
3108        // Unbind all events added by lightGallery zoom plugin
3109        _this.core.$el.off('.lg.zoom');
3110        $(window).off('.lg.zoom');
3111        _this.core.$slide.off('.lg.zoom');
3112        _this.core.$el.off('.lg.tm.zoom');
3113        _this.resetZoom();
3114        clearTimeout(_this.zoomabletimeout);
3115        _this.zoomabletimeout = false;
3116    };
3117
3118    $.fn.lightGallery.modules.zoom = Zoom;
3119
3120})();
3121
3122
3123}));

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.