PageSourceSearch

https://carzone-html.vercel.app/plugins/imagegallery/js/lightgallery.js

js carzone-html.vercel.app collected 2026-10-03 06:22:14 UTC 57,262 bytes, 1,604 lines download raw bytes

1/**!
2 * lightgallery.js | 1.0.2 | January 14th 2018
3 * http://sachinchoolur.github.io/lightgallery.js/
4 * Copyright (c) 2016 Sachin N; 
5 * @license GPLv3 
6 */(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.Lightgallery = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
7(function (global, factory) {
8    if (typeof define === "function" && define.amd) {
9        define(['exports'], factory);
10    } else if (typeof exports !== "undefined") {
11        factory(exports);
12    } else {
13        var mod = {
14            exports: {}
15        };
16        factory(mod.exports);
17        global.lgUtils = mod.exports;
18    }
19})(this, function (exports) {
20    'use strict';
21
22    Object.defineProperty(exports, "__esModule", {
23        value: true
24    });
25
26    /*
27     *@todo remove function from window and document. Update on and off functions
28     */
29    window.getAttribute = function (label) {
30        return window[label];
31    };
32
33    window.setAttribute = function (label, value) {
34        window[label] = value;
35    };
36
37    document.getAttribute = function (label) {
38        return document[label];
39    };
40
41    document.setAttribute = function (label, value) {
42        document[label] = value;
43    };
44
45    var utils = {
46        wrap: function wrap(el, className) {
47            if (!el) {
48                return;
49            }
50
51            var wrapper = document.createElement('div');
52            wrapper.className = className;
53            el.parentNode.insertBefore(wrapper, el);
54            el.parentNode.removeChild(el);
55            wrapper.appendChild(el);
56        },
57
58        addClass: function addClass(el, className) {
59            if (!el) {
60                return;
61            }
62
63            if (el.classList) {
64                el.classList.add(className);
65            } else {
66                el.className += ' ' + className;
67            }
68        },
69
70        removeClass: function removeClass(el, className) {
71            if (!el) {
72                return;
73            }
74
75            if (el.classList) {
76                el.classList.remove(className);
77            } else {
78                el.className = el.className.replace(new RegExp('(^|\\b)' + className.split(' ').join('|') + '(\\b|$)', 'gi'), ' ');
79            }
80        },
81
82        hasClass: function hasClass(el, className) {
83            if (el.classList) {
84                return el.classList.contains(className);
85            } else {
86                return new RegExp('(^| )' + className + '( |$)', 'gi').test(el.className);
87            }
88
89            return false;
90        },
91
92        // ex Transform
93        // ex TransitionTimingFunction
94        setVendor: function setVendor(el, property, value) {
95            if (!el) {
96                return;
97            }
98
99            el.style[property.charAt(0).toLowerCase() + property.slice(1)] = value;
100            el.style['webkit' + property] = value;
101            el.style['moz' + property] = value;
102            el.style['ms' + property] = value;
103            el.style['o' + property] = value;
104        },
105
106        trigger: function trigger(el, event) {
107            var detail = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
108
109            if (!el) {
110                return;
111            }
112
113            var customEvent = new CustomEvent(event, {
114                detail: detail
115            });
116            el.dispatchEvent(customEvent);
117        },
118
119        Listener: {
120            uid: 0
121        },
122        on: function on(el, events, fn) {
123            if (!el) {
124                return;
125            }
126
127            events.split(' ').forEach(function (event) {
128                var _id = el.getAttribute('lg-event-uid') || '';
129                utils.Listener.uid++;
130                _id += '&' + utils.Listener.uid;
131                el.setAttribute('lg-event-uid', _id);
132                utils.Listener[event + utils.Listener.uid] = fn;
133                el.addEventListener(event.split('.')[0], fn, false);
134            });
135        },
136
137        off: function off(el, event) {
138            if (!el) {
139                return;
140            }
141
142            var _id = el.getAttribute('lg-event-uid');
143            if (_id) {
144                _id = _id.split('&');
145                for (var i = 0; i < _id.length; i++) {
146                    if (_id[i]) {
147                        var _event = event + _id[i];
148                        if (_event.substring(0, 1) === '.') {
149                            for (var key in utils.Listener) {
150                                if (utils.Listener.hasOwnProperty(key)) {
151                                    if (key.split('.').indexOf(_event.split('.')[1]) > -1) {
152                                        el.removeEventListener(key.split('.')[0], utils.Listener[key]);
153                                        el.setAttribute('lg-event-uid', el.getAttribute('lg-event-uid').replace('&' + _id[i], ''));
154                                        delete utils.Listener[key];
155                                    }
156                                }
157                            }
158                        } else {
159                            el.removeEventListener(_event.split('.')[0], utils.Listener[_event]);
160                            el.setAttribute('lg-event-uid', el.getAttribute('lg-event-uid').replace('&' + _id[i], ''));
161                            delete utils.Listener[_event];
162                        }
163                    }
164                }
165            }
166        },
167
168        param: function param(obj) {
169            return Object.keys(obj).map(function (k) {
170                return encodeURIComponent(k) + '=' + encodeURIComponent(obj[k]);
171            }).join('&');
172        }
173    };
174
175    exports.default = utils;
176});
177
178},{}],2:[function(require,module,exports){
179(function (global, factory) {
180    if (typeof define === "function" && define.amd) {
181        define(['./lg-utils'], factory);
182    } else if (typeof exports !== "undefined") {
183        factory(require('./lg-utils'));
184    } else {
185        var mod = {
186            exports: {}
187        };
188        factory(global.lgUtils);
189        global.lightgallery = mod.exports;
190    }
191})(this, function (_lgUtils) {
192    'use strict';
193
194    var _lgUtils2 = _interopRequireDefault(_lgUtils);
195
196    function _interopRequireDefault(obj) {
197        return obj && obj.__esModule ? obj : {
198            default: obj
199        };
200    }
201
202    var _extends = Object.assign || function (target) {
203        for (var i = 1; i < arguments.length; i++) {
204            var source = arguments[i];
205
206            for (var key in source) {
207                if (Object.prototype.hasOwnProperty.call(source, key)) {
208                    target[key] = source[key];
209                }
210            }
211        }
212
213        return target;
214    };
215
216    /** Polyfill the CustomEvent() constructor functionality in Internet Explorer 9 and higher */
217    (function () {
218
219        if (typeof window.CustomEvent === 'function') {
220            return false;
vendor: 17,081 bytes, lines 221-758
221        }
222
223        function CustomEvent(event, params) {
224            params = params || {
225                bubbles: false,
226                cancelable: false,
227                detail: undefined
228            };
229            var evt = document.createEvent('CustomEvent');
230            evt.initCustomEvent(event, params.bubbles, params.cancelable, params.detail);
231            return evt;
232        }
233
234        CustomEvent.prototype = window.Event.prototype;
235
236        window.CustomEvent = CustomEvent;
237    })();
238
239    window.utils = _lgUtils2.default;
240    window.lgData = {
241        uid: 0
242    };
243
244    window.lgModules = {};
245    var defaults = {
246
247        mode: 'lg-slide',
248
249        // Ex : 'ease'
250        cssEasing: 'ease',
251
252        //'for jquery animation'
253        easing: 'linear',
254        speed: 600,
255        height: '100%',
256        width: '100%',
257        addClass: '',
258        startClass: 'lg-start-zoom',
259        backdropDuration: 150,
260        hideBarsDelay: 6000,
261
262        useLeft: false,
263
264        closable: true,
265        loop: true,
266        escKey: true,
267        keyPress: true,
268        controls: true,
269        slideEndAnimatoin: true,
270        hideControlOnEnd: false,
271        mousewheel: false,
272
273        getCaptionFromTitleOrAlt: true,
274
275        // .lg-item || '.lg-sub-html'
276        appendSubHtmlTo: '.lg-sub-html',
277
278        subHtmlSelectorRelative: false,
279
280        /**
281         * @desc number of preload slides
282         * will exicute only after the current slide is fully loaded.
283         *
284         * @ex you clicked on 4th image and if preload = 1 then 3rd slide and 5th
285         * slide will be loaded in the background after the 4th slide is fully loaded..
286         * if preload is 2 then 2nd 3rd 5th 6th slides will be preloaded.. ... ...
287         *
288         */
289        preload: 1,
290        showAfterLoad: true,
291        selector: '',
292        selectWithin: '',
293        nextHtml: '',
294        prevHtml: '',
295
296        // 0, 1
297        index: false,
298
299        iframeMaxWidth: '100%',
300
301        download: true,
302        counter: true,
303        appendCounterTo: '.lg-toolbar',
304
305        swipeThreshold: 50,
306        enableSwipe: true,
307        enableDrag: true,
308
309        dynamic: false,
310        dynamicEl: [],
311        galleryId: 1
312    };
313
314    function Plugin(element, options) {
315
316        // Current lightGallery element
317        this.el = element;
318
319        // lightGallery settings
320        this.s = _extends({}, defaults, options);
321
322        // When using dynamic mode, ensure dynamicEl is an array
323        if (this.s.dynamic && this.s.dynamicEl !== 'undefined' && this.s.dynamicEl.constructor === Array && !this.s.dynamicEl.length) {
324            throw 'When using dynamic mode, you must also define dynamicEl as an Array.';
325        }
326
327        // lightGallery modules
328        this.modules = {};
329
330        // false when lightgallery complete first slide;
331        this.lGalleryOn = false;
332
333        this.lgBusy = false;
334
335        // Timeout function for hiding controls;
336        this.hideBartimeout = false;
337
338        // To determine browser supports for touch events;
339        this.isTouch = 'ontouchstart' in document.documentElement;
340
341        // Disable hideControlOnEnd if sildeEndAnimation is true
342        if (this.s.slideEndAnimatoin) {
343            this.s.hideControlOnEnd = false;
344        }
345
346        this.items = [];
347
348        // Gallery items
349        if (this.s.dynamic) {
350            this.items = this.s.dynamicEl;
351        } else {
352            if (this.s.selector === 'this') {
353                this.items.push(this.el);
354            } else if (this.s.selector !== '') {
355                if (this.s.selectWithin) {
356                    this.items = document.querySelector(this.s.selectWithin).querySelectorAll(this.s.selector);
357                } else {
358                    this.items = this.el.querySelectorAll(this.s.selector);
359                }
360            } else {
361                this.items = this.el.children;
362            }
363        }
364
365        // .lg-item
366
367        this.___slide = '';
368
369        // .lg-outer
370        this.outer = '';
371
372        this.init();
373
374        return this;
375    }
376
377    Plugin.prototype.init = function () {
378
379        var _this = this;
380
381        // s.preload should not be more than $item.length
382        if (_this.s.preload > _this.items.length) {
383            _this.s.preload = _this.items.length;
384        }
385
386        // if dynamic option is enabled execute immediately
387        var _hash = window.location.hash;
388        if (_hash.indexOf('lg=' + this.s.galleryId) > 0) {
389
390            _this.index = parseInt(_hash.split('&slide=')[1], 10);
391
392            _lgUtils2.default.addClass(document.body, 'lg-from-hash');
393            if (!_lgUtils2.default.hasClass(document.body, 'lg-on')) {
394                _lgUtils2.default.addClass(document.body, 'lg-on');
395                setTimeout(function () {
396                    _this.build(_this.index);
397                });
398            }
399        }
400
401        if (_this.s.dynamic) {
402
403            _lgUtils2.default.trigger(this.el, 'onBeforeOpen');
404
405            _this.index = _this.s.index || 0;
406
407            // prevent accidental double execution
408            if (!_lgUtils2.default.hasClass(document.body, 'lg-on')) {
409                _lgUtils2.default.addClass(document.body, 'lg-on');
410                setTimeout(function () {
411                    _this.build(_this.index);
412                });
413            }
414        } else {
415
416            for (var i = 0; i < _this.items.length; i++) {
417
418                /*jshint loopfunc: true */
419                (function (index) {
420
421                    // Using different namespace for click because click event should not unbind if selector is same object('this')
422                    _lgUtils2.default.on(_this.items[index], 'click.lgcustom', function (e) {
423
424                        e.preventDefault();
425
426                        _lgUtils2.default.trigger(_this.el, 'onBeforeOpen');
427
428                        _this.index = _this.s.index || index;
429
430                        if (!_lgUtils2.default.hasClass(document.body, 'lg-on')) {
431                            _this.build(_this.index);
432                            _lgUtils2.default.addClass(document.body, 'lg-on');
433                        }
434                    });
435                })(i);
436            }
437        }
438    };
439
440    Plugin.prototype.build = function (index) {
441
442        var _this = this;
443
444        _this.structure();
445
446        for (var key in window.lgModules) {
447            _this.modules[key] = new window.lgModules[key](_this.el);
448        }
449
450        // initiate slide function
451        _this.slide(index, false, false);
452
453        if (_this.s.keyPress) {
454            _this.keyPress();
455        }
456
457        if (_this.items.length > 1) {
458
459            _this.arrow();
460
461            setTimeout(function () {
462                _this.enableDrag();
463                _this.enableSwipe();
464            }, 50);
465
466            if (_this.s.mousewheel) {
467                _this.mousewheel();
468            }
469        }
470
471        _this.counter();
472
473        _this.closeGallery();
474
475        _lgUtils2.default.trigger(_this.el, 'onAfterOpen');
476
477        // Hide controllers if mouse doesn't move for some period
478        _lgUtils2.default.on(_this.outer, 'mousemove.lg click.lg touchstart.lg', function () {
479
480            _lgUtils2.default.removeClass(_this.outer, 'lg-hide-items');
481
482            clearTimeout(_this.hideBartimeout);
483
484            // Timeout will be cleared on each slide movement also
485            _this.hideBartimeout = setTimeout(function () {
486                _lgUtils2.default.addClass(_this.outer, 'lg-hide-items');
487            }, _this.s.hideBarsDelay);
488        });
489    };
490
491    Plugin.prototype.structure = function () {
492        var list = '';
493        var controls = '';
494        var i = 0;
495        var subHtmlCont = '';
496        var template;
497        var _this = this;
498
499        document.body.insertAdjacentHTML('beforeend', '<div class="lg-backdrop"></div>');
500        _lgUtils2.default.setVendor(document.querySelector('.lg-backdrop'), 'TransitionDuration', this.s.backdropDuration + 'ms');
501
502        // Create gallery items
503        for (i = 0; i < this.items.length; i++) {
504            list += '<div class="lg-item"></div>';
505        }
506
507        // Create controlls
508        if (this.s.controls && this.items.length > 1) {
509            controls = '<div class="lg-actions">' + '<div class="lg-prev lg-icon">' + this.s.prevHtml + '</div>' + '<div class="lg-next lg-icon">' + this.s.nextHtml + '</div>' + '</div>';
510        }
511
512        if (this.s.appendSubHtmlTo === '.lg-sub-html') {
513            subHtmlCont = '<div class="lg-sub-html"></div>';
514        }
515
516        template = '<div class="lg-outer ' + this.s.addClass + ' ' + this.s.startClass + '">' + '<div class="lg" style="width:' + this.s.width + '; height:' + this.s.height + '">' + '<div class="lg-inner">' + list + '</div>' + '<div class="lg-toolbar group">' + '<span class="lg-close lg-icon"></span>' + '</div>' + controls + subHtmlCont + '</div>' + '</div>';
517
518        document.body.insertAdjacentHTML('beforeend', template);
519        this.outer = document.querySelector('.lg-outer');
520        this.___slide = this.outer.querySelectorAll('.lg-item');
521
522        if (this.s.useLeft) {
523            _lgUtils2.default.addClass(this.outer, 'lg-use-left');
524
525            // Set mode lg-slide if use left is true;
526            this.s.mode = 'lg-slide';
527        } else {
528            _lgUtils2.default.addClass(this.outer, 'lg-use-css3');
529        }
530
531        // For fixed height gallery
532        _this.setTop();
533        _lgUtils2.default.on(window, 'resize.lg orientationchange.lg', function () {
534            setTimeout(function () {
535                _this.setTop();
536            }, 100);
537        });
538
539        // add class lg-current to remove initial transition
540        _lgUtils2.default.addClass(this.___slide[this.index], 'lg-current');
541
542        // add Class for css support and transition mode
543        if (this.doCss()) {
544            _lgUtils2.default.addClass(this.outer, 'lg-css3');
545        } else {
546            _lgUtils2.default.addClass(this.outer, 'lg-css');
547
548            // Set speed 0 because no animation will happen if browser doesn't support css3
549            this.s.speed = 0;
550        }
551
552        _lgUtils2.default.addClass(this.outer, this.s.mode);
553
554        if (this.s.enableDrag && this.items.length > 1) {
555            _lgUtils2.default.addClass(this.outer, 'lg-grab');
556        }
557
558        if (this.s.showAfterLoad) {
559            _lgUtils2.default.addClass(this.outer, 'lg-show-after-load');
560        }
561
562        if (this.doCss()) {
563            var inner = this.outer.querySelector('.lg-inner');
564            _lgUtils2.default.setVendor(inner, 'TransitionTimingFunction', this.s.cssEasing);
565            _lgUtils2.default.setVendor(inner, 'TransitionDuration', this.s.speed + 'ms');
566        }
567
568        setTimeout(function () {
569            _lgUtils2.default.addClass(document.querySelector('.lg-backdrop'), 'in');
570        });
571
572        setTimeout(function () {
573            _lgUtils2.default.addClass(_this.outer, 'lg-visible');
574        }, this.s.backdropDuration);
575
576        if (this.s.download) {
577            this.outer.querySelector('.lg-toolbar').insertAdjacentHTML('beforeend', '<a id="lg-download" target="_blank" download class="lg-download lg-icon"></a>');
578        }
579
580        // Store the current scroll top value to scroll back after closing the gallery..
581        this.prevScrollTop = document.documentElement.scrollTop || document.body.scrollTop;
582    };
583
584    // For fixed height gallery
585    Plugin.prototype.setTop = function () {
586        if (this.s.height !== '100%') {
587            var wH = window.innerHeight;
588            var top = (wH - parseInt(this.s.height, 10)) / 2;
589            var lGallery = this.outer.querySelector('.lg');
590            if (wH >= parseInt(this.s.height, 10)) {
591                lGallery.style.top = top + 'px';
592            } else {
593                lGallery.style.top = '0px';
594            }
595        }
596    };
597
598    // Find css3 support
599    Plugin.prototype.doCss = function () {
600        // check for css animation support
601        var support = function support() {
602            var transition = ['transition', 'MozTransition', 'WebkitTransition', 'OTransition', 'msTransition', 'KhtmlTransition'];
603            var root = document.documentElement;
604            var i = 0;
605            for (i = 0; i < transition.length; i++) {
606                if (transition[i] in root.style) {
607                    return true;
608                }
609            }
610        };
611
612        if (support()) {
613            return true;
614        }
615
616        return false;
617    };
618
619    /**
620     *  @desc Check the given src is video
621     *  @param {String} src
622     *  @return {Object} video type
623     *  Ex:{ youtube  :  ["//www.youtube.com/watch?v=c0asJgSyxcY", "c0asJgSyxcY"] }
624     */
625    Plugin.prototype.isVideo = function (src, index) {
626
627        if (!src) {
628            throw new Error("Make sure that slide " + index + " has an image/video src");
629        }
630
631        var html;
632        if (this.s.dynamic) {
633            html = this.s.dynamicEl[index].html;
634        } else {
635            html = this.items[index].getAttribute('data-html');
636        }
637
638        if (!src && html) {
639            return {
640                html5: true
641            };
642        }
643
644        var youtube = src.match(/\/\/(?:www\.)?youtu(?:\.be|be\.com)\/(?:watch\?v=|embed\/)?([a-z0-9\-\_\%]+)/i);
645        var vimeo = src.match(/\/\/(?:www\.)?vimeo.com\/([0-9a-z\-_]+)/i);
646        var dailymotion = src.match(/\/\/(?:www\.)?dai.ly\/([0-9a-z\-_]+)/i);
647        var vk = src.match(/\/\/(?:www\.)?(?:vk\.com|vkontakte\.ru)\/(?:video_ext\.php\?)(.*)/i);
648
649        if (youtube) {
650            return {
651                youtube: youtube
652            };
653        } else if (vimeo) {
654            return {
655                vimeo: vimeo
656            };
657        } else if (dailymotion) {
658            return {
659                dailymotion: dailymotion
660            };
661        } else if (vk) {
662            return {
663                vk: vk
664            };
665        }
666    };
667
668    /**
669     *  @desc Create image counter
670     *  Ex: 1/10
671     */
672    Plugin.prototype.counter = function () {
673        if (this.s.counter) {
674            this.outer.querySelector(this.s.appendCounterTo).insertAdjacentHTML('beforeend', '<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>');
675        }
676    };
677
678    /**
679     *  @desc add sub-html into the slide
680     *  @param {Number} index - index of the slide
681     */
682    Plugin.prototype.addHtml = function (index) {
683        var subHtml = null;
684        var currentEle;
685        if (this.s.dynamic) {
686            subHtml = this.s.dynamicEl[index].subHtml;
687        } else {
688            currentEle = this.items[index];
689            subHtml = currentEle.getAttribute('data-sub-html');
690            if (this.s.getCaptionFromTitleOrAlt && !subHtml) {
691                subHtml = currentEle.getAttribute('title');
692                if (subHtml && currentEle.querySelector('img')) {
693                    subHtml = currentEle.querySelector('img').getAttribute('alt');
694                }
695            }
696        }
697
698        if (typeof subHtml !== 'undefined' && subHtml !== null) {
699
700            // get first letter of subhtml
701            // if first letter starts with . or # get the html form the jQuery object
702            var fL = subHtml.substring(0, 1);
703            if (fL === '.' || fL === '#') {
704                if (this.s.subHtmlSelectorRelative && !this.s.dynamic) {
705                    subHtml = currentEle.querySelector(subHtml).innerHTML;
706                } else {
707                    subHtml = document.querySelector(subHtml).innerHTML;
708                }
709            }
710        } else {
711            subHtml = '';
712        }
713
714        if (this.s.appendSubHtmlTo === '.lg-sub-html') {
715            this.outer.querySelector(this.s.appendSubHtmlTo).innerHTML = subHtml;
716        } else {
717            this.___slide[index].insertAdjacentHTML('beforeend', subHtml);
718        }
719
720        // Add lg-empty-html class if title doesn't exist
721        if (typeof subHtml !== 'undefined' && subHtml !== null) {
722            if (subHtml === '') {
723                _lgUtils2.default.addClass(this.outer.querySelector(this.s.appendSubHtmlTo), 'lg-empty-html');
724            } else {
725                _lgUtils2.default.removeClass(this.outer.querySelector(this.s.appendSubHtmlTo), 'lg-empty-html');
726            }
727        }
728
729        _lgUtils2.default.trigger(this.el, 'onAfterAppendSubHtml', {
730            index: index
731        });
732    };
733
734    /**
735     *  @desc Preload slides
736     *  @param {Number} index - index of the slide
737     */
738    Plugin.prototype.preload = function (index) {
739        var i = 1;
740        var j = 1;
741        for (i = 1; i <= this.s.preload; i++) {
742            if (i >= this.items.length - index) {
743                break;
744            }
745
746            this.loadContent(index + i, false, 0);
747        }
748
749        for (j = 1; j <= this.s.preload; j++) {
750            if (index - j < 0) {
751                break;
752            }
753
754            this.loadContent(index - j, false, 0);
755        }
756    };
757
758    /**
759     *  @desc Load slide content into slide.
760     *  @param {Number} index - index of the slide.
761     *  @param {Boolean} rec - if true call loadcontent() function again.
762     *  @param {Boolean} delay - delay for adding complete class. it is 0 except first time.
763     */
764    Plugin.prototype.loadContent = function (index, rec, delay) {
765
766        var _this = this;
767        var _hasPoster = false;
768        var _img;
769        var _src;
770        var _poster;
771        var _srcset;
772        var _sizes;
773        var _html;
774        var getResponsiveSrc = function getResponsiveSrc(srcItms) {
775            var rsWidth = [];
776            var rsSrc = [];
777            for (var i = 0; i < srcItms.length; i++) {
778                var __src = srcItms[i].split(' ');
779
780                // Manage empty space
781                if (__src[0] === '') {
782                    __src.splice(0, 1);
783                }
784
785                rsSrc.push(__src[0]);
786                rsWidth.push(__src[1]);
787            }
788
789            var wWidth = window.innerWidth;
790            for (var j = 0; j < rsWidth.length; j++) {
791                if (parseInt(rsWidth[j], 10) > wWidth) {
792                    _src = rsSrc[j];
793                    break;
794                }
795            }
796        };
797
798        if (_this.s.dynamic) {
799
800            if (_this.s.dynamicEl[index].poster) {
801                _hasPoster = true;
802                _poster = _this.s.dynamicEl[index].poster;
803            }
804
805            _html = _this.s.dynamicEl[index].html;
806            _src = _this.s.dynamicEl[index].src;
807
808            if (_this.s.dynamicEl[index].responsive) {
809                var srcDyItms = _this.s.dynamicEl[index].responsive.split(',');
810                getResponsiveSrc(srcDyItms);
811            }
812
813            _srcset = _this.s.dynamicEl[index].srcset;
814            _sizes = _this.s.dynamicEl[index].sizes;
815        } else {
816
817            if (_this.items[index].getAttribute('data-poster')) {
818                _hasPoster = true;
819                _poster = _this.items[index].getAttribute('data-poster');
820            }
821
822            _html = _this.items[index].getAttribute('data-html');
823            _src = _this.items[index].getAttribute('href') || _this.items[index].getAttribute('data-src');
824
825            if (_this.items[index].getAttribute('data-responsive')) {
826                var srcItms = _this.items[index].getAttribute('data-responsive').split(',');
827                getResponsiveSrc(srcItms);
828            }
829
830            _srcset = _this.items[index].getAttribute('data-srcset');
831            _sizes = _this.items[index].getAttribute('data-sizes');
832        }
833
834        //if (_src || _srcset || _sizes || _poster) {
835
836        var iframe = false;
837        if (_this.s.dynamic) {
838            if (_this.s.dynamicEl[index].iframe) {
839                iframe = true;
840            }
841        } else {
842            if (_this.items[index].getAttribute('data-iframe') === 'true') {
843                iframe = true;
844            }
845        }
846
847        var _isVideo = _this.isVideo(_src, index);
848        if (!_lgUtils2.default.hasClass(_this.___slide[index], 'lg-loaded')) {
849            if (iframe) {
850                _this.___slide[index].insertAdjacentHTML('afterbegin', '<div class="lg-video-cont" style="max-width:' + _this.s.iframeMaxWidth + '"><div class="lg-video"><iframe class="lg-object" frameborder="0" src="' + _src + '"  allowfullscreen="true"></iframe></div></div>');
851            } else if (_hasPoster) {
852                var videoClass = '';
853                if (_isVideo && _isVideo.youtube) {
854                    videoClass = 'lg-has-youtube';
855                } else if (_isVideo && _isVideo.vimeo) {
856                    videoClass = 'lg-has-vimeo';
857                } else {
858                    videoClass = 'lg-has-html5';
859                }
860
861                _this.___slide[index].insertAdjacentHTML('beforeend', '<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>');
862            } else if (_isVideo) {
863                _this.___slide[index].insertAdjacentHTML('beforeend', '<div class="lg-video-cont "><div class="lg-video"></div></div>');
864                _lgUtils2.default.trigger(_this.el, 'hasVideo', {
865                    index: index,
866                    src: _src,
867                    html: _html
868                });
869            } else {
870                _this.___slide[index].insertAdjacentHTML('beforeend', '<div class="lg-img-wrap"><img class="lg-object lg-image" src="' + _src + '" /></div>');
871            }
872
873            _lgUtils2.default.trigger(_this.el, 'onAferAppendSlide', {
874                index: index
875            });
876
877            _img = _this.___slide[index].querySelector('.lg-object');
878            if (_sizes) {
879                _img.setAttribute('sizes', _sizes);
880            }
881
882            if (_srcset) {
883                _img.setAttribute('srcset', _srcset);
884                try {
885                    picturefill({
886                        elements: [_img[0]]
887                    });
888                } catch (e) {
889                    console.error('Make sure you have included Picturefill version 2');
vendor: 14,074 bytes, lines 889-1250
889
890                }
891            }
892
893            if (this.s.appendSubHtmlTo !== '.lg-sub-html') {
894                _this.addHtml(index);
895            }
896
897            _lgUtils2.default.addClass(_this.___slide[index], 'lg-loaded');
898        }
899
900        _lgUtils2.default.on(_this.___slide[index].querySelector('.lg-object'), 'load.lg error.lg', function () {
901
902            // For first time add some delay for displaying the start animation.
903            var _speed = 0;
904
905            // Do not change the delay value because it is required for zoom plugin.
906            // If gallery opened from direct url (hash) speed value should be 0
907            if (delay && !_lgUtils2.default.hasClass(document.body, 'lg-from-hash')) {
908                _speed = delay;
909            }
910
911            setTimeout(function () {
912                _lgUtils2.default.addClass(_this.___slide[index], 'lg-complete');
913
914                _lgUtils2.default.trigger(_this.el, 'onSlideItemLoad', {
915                    index: index,
916                    delay: delay || 0
917                });
918            }, _speed);
919        });
920
921        // @todo check load state for html5 videos
922        if (_isVideo && _isVideo.html5 && !_hasPoster) {
923            _lgUtils2.default.addClass(_this.___slide[index], 'lg-complete');
924        }
925
926        if (rec === true) {
927            if (!_lgUtils2.default.hasClass(_this.___slide[index], 'lg-complete')) {
928                _lgUtils2.default.on(_this.___slide[index].querySelector('.lg-object'), 'load.lg error.lg', function () {
929                    _this.preload(index);
930                });
931            } else {
932                _this.preload(index);
933            }
934        }
935
936        //}
937    };
938
939    /**
940    *   @desc slide function for lightgallery
941        ** Slide() gets call on start
942        ** ** Set lg.on true once slide() function gets called.
943        ** Call loadContent() on slide() function inside setTimeout
944        ** ** On first slide we do not want any animation like slide of fade
945        ** ** So on first slide( if lg.on if false that is first slide) loadContent() should start loading immediately
946        ** ** Else loadContent() should wait for the transition to complete.
947        ** ** So set timeout s.speed + 50
948    <=> ** loadContent() will load slide content in to the particular slide
949        ** ** It has recursion (rec) parameter. if rec === true loadContent() will call preload() function.
950        ** ** preload will execute only when the previous slide is fully loaded (images iframe)
951        ** ** avoid simultaneous image load
952    <=> ** Preload() will check for s.preload value and call loadContent() again accoring to preload value
953        ** loadContent()  <====> Preload();
954    
955    *   @param {Number} index - index of the slide
956    *   @param {Boolean} fromTouch - true if slide function called via touch event or mouse drag
957    *   @param {Boolean} fromThumb - true if slide function called via thumbnail click
958    */
959    Plugin.prototype.slide = function (index, fromTouch, fromThumb) {
960
961        var _prevIndex = 0;
962        for (var i = 0; i < this.___slide.length; i++) {
963            if (_lgUtils2.default.hasClass(this.___slide[i], 'lg-current')) {
964                _prevIndex = i;
965                break;
966            }
967        }
968
969        var _this = this;
970
971        // Prevent if multiple call
972        // Required for hsh plugin
973        if (_this.lGalleryOn && _prevIndex === index) {
974            return;
975        }
976
977        var _length = this.___slide.length;
978        var _time = _this.lGalleryOn ? this.s.speed : 0;
979        var _next = false;
980        var _prev = false;
981
982        if (!_this.lgBusy) {
983
984            if (this.s.download) {
985                var _src;
986                if (_this.s.dynamic) {
987                    _src = _this.s.dynamicEl[index].downloadUrl !== false && (_this.s.dynamicEl[index].downloadUrl || _this.s.dynamicEl[index].src);
988                } else {
989                    _src = _this.items[index].getAttribute('data-download-url') !== 'false' && (_this.items[index].getAttribute('data-download-url') || _this.items[index].getAttribute('href') || _this.items[index].getAttribute('data-src'));
990                }
991
992                if (_src) {
993                    document.getElementById('lg-download').setAttribute('href', _src);
994                    _lgUtils2.default.removeClass(_this.outer, 'lg-hide-download');
995                } else {
996                    _lgUtils2.default.addClass(_this.outer, 'lg-hide-download');
997                }
998            }
999
1000            _lgUtils2.default.trigger(_this.el, 'onBeforeSlide', {
1001                prevIndex: _prevIndex,
1002                index: index,
1003                fromTouch: fromTouch,
1004                fromThumb: fromThumb
1005            });
1006
1007            _this.lgBusy = true;
1008
1009            clearTimeout(_this.hideBartimeout);
1010
1011            // Add title if this.s.appendSubHtmlTo === lg-sub-html
1012            if (this.s.appendSubHtmlTo === '.lg-sub-html') {
1013
1014                // wait for slide animation to complete
1015                setTimeout(function () {
1016                    _this.addHtml(index);
1017                }, _time);
1018            }
1019
1020            this.arrowDisable(index);
1021
1022            if (!fromTouch) {
1023
1024                // remove all transitions
1025                _lgUtils2.default.addClass(_this.outer, 'lg-no-trans');
1026
1027                for (var j = 0; j < this.___slide.length; j++) {
1028                    _lgUtils2.default.removeClass(this.___slide[j], 'lg-prev-slide');
1029                    _lgUtils2.default.removeClass(this.___slide[j], 'lg-next-slide');
1030                }
1031
1032                if (index < _prevIndex) {
1033                    _prev = true;
1034                    if (index === 0 && _prevIndex === _length - 1 && !fromThumb) {
1035                        _prev = false;
1036                        _next = true;
1037                    }
1038                } else if (index > _prevIndex) {
1039                    _next = true;
1040                    if (index === _length - 1 && _prevIndex === 0 && !fromThumb) {
1041                        _prev = true;
1042                        _next = false;
1043                    }
1044                }
1045
1046                if (_prev) {
1047
1048                    //prevslide
1049                    _lgUtils2.default.addClass(this.___slide[index], 'lg-prev-slide');
1050                    _lgUtils2.default.addClass(this.___slide[_prevIndex], 'lg-next-slide');
1051                } else if (_next) {
1052
1053                    // next slide
1054                    _lgUtils2.default.addClass(this.___slide[index], 'lg-next-slide');
1055                    _lgUtils2.default.addClass(this.___slide[_prevIndex], 'lg-prev-slide');
1056                }
1057
1058                // give 50 ms for browser to add/remove class
1059                setTimeout(function () {
1060                    _lgUtils2.default.removeClass(_this.outer.querySelector('.lg-current'), 'lg-current');
1061
1062                    //_this.$slide.eq(_prevIndex).removeClass('lg-current');
1063                    _lgUtils2.default.addClass(_this.___slide[index], 'lg-current');
1064
1065                    // reset all transitions
1066                    _lgUtils2.default.removeClass(_this.outer, 'lg-no-trans');
1067                }, 50);
1068            } else {
1069
1070                var touchPrev = index - 1;
1071                var touchNext = index + 1;
1072
1073                if (index === 0 && _prevIndex === _length - 1) {
1074
1075                    // next slide
1076                    touchNext = 0;
1077                    touchPrev = _length - 1;
1078                } else if (index === _length - 1 && _prevIndex === 0) {
1079
1080                    // prev slide
1081                    touchNext = 0;
1082                    touchPrev = _length - 1;
1083                }
1084
1085                _lgUtils2.default.removeClass(_this.outer.querySelector('.lg-prev-slide'), 'lg-prev-slide');
1086                _lgUtils2.default.removeClass(_this.outer.querySelector('.lg-current'), 'lg-current');
1087                _lgUtils2.default.removeClass(_this.outer.querySelector('.lg-next-slide'), 'lg-next-slide');
1088                _lgUtils2.default.addClass(_this.___slide[touchPrev], 'lg-prev-slide');
1089                _lgUtils2.default.addClass(_this.___slide[touchNext], 'lg-next-slide');
1090                _lgUtils2.default.addClass(_this.___slide[index], 'lg-current');
1091            }
1092
1093            if (_this.lGalleryOn) {
1094                setTimeout(function () {
1095                    _this.loadContent(index, true, 0);
1096                }, this.s.speed + 50);
1097
1098                setTimeout(function () {
1099                    _this.lgBusy = false;
1100                    _lgUtils2.default.trigger(_this.el, 'onAfterSlide', {
1101                        prevIndex: _prevIndex,
1102                        index: index,
1103                        fromTouch: fromTouch,
1104                        fromThumb: fromThumb
1105                    });
1106                }, this.s.speed);
1107            } else {
1108                _this.loadContent(index, true, _this.s.backdropDuration);
1109
1110                _this.lgBusy = false;
1111                _lgUtils2.default.trigger(_this.el, 'onAfterSlide', {
1112                    prevIndex: _prevIndex,
1113                    index: index,
1114                    fromTouch: fromTouch,
1115                    fromThumb: fromThumb
1116                });
1117            }
1118
1119            _this.lGalleryOn = true;
1120
1121            if (this.s.counter) {
1122                if (document.getElementById('lg-counter-current')) {
1123                    document.getElementById('lg-counter-current').innerHTML = index + 1;
1124                }
1125            }
1126        }
1127    };
1128
1129    /**
1130     *  @desc Go to next slide
1131     *  @param {Boolean} fromTouch - true if slide function called via touch event
1132     */
1133    Plugin.prototype.goToNextSlide = function (fromTouch) {
1134        var _this = this;
1135        if (!_this.lgBusy) {
1136            if (_this.index + 1 < _this.___slide.length) {
1137                _this.index++;
1138                _lgUtils2.default.trigger(_this.el, 'onBeforeNextSlide', {
1139                    index: _this.index
1140                });
1141                _this.slide(_this.index, fromTouch, false);
1142            } else {
1143                if (_this.s.loop) {
1144                    _this.index = 0;
1145                    _lgUtils2.default.trigger(_this.el, 'onBeforeNextSlide', {
1146                        index: _this.index
1147                    });
1148                    _this.slide(_this.index, fromTouch, false);
1149                } else if (_this.s.slideEndAnimatoin) {
1150                    _lgUtils2.default.addClass(_this.outer, 'lg-right-end');
1151                    setTimeout(function () {
1152                        _lgUtils2.default.removeClass(_this.outer, 'lg-right-end');
1153                    }, 400);
1154                }
1155            }
1156        }
1157    };
1158
1159    /**
1160     *  @desc Go to previous slide
1161     *  @param {Boolean} fromTouch - true if slide function called via touch event
1162     */
1163    Plugin.prototype.goToPrevSlide = function (fromTouch) {
1164        var _this = this;
1165        if (!_this.lgBusy) {
1166            if (_this.index > 0) {
1167                _this.index--;
1168                _lgUtils2.default.trigger(_this.el, 'onBeforePrevSlide', {
1169                    index: _this.index,
1170                    fromTouch: fromTouch
1171                });
1172                _this.slide(_this.index, fromTouch, false);
1173            } else {
1174                if (_this.s.loop) {
1175                    _this.index = _this.items.length - 1;
1176                    _lgUtils2.default.trigger(_this.el, 'onBeforePrevSlide', {
1177                        index: _this.index,
1178                        fromTouch: fromTouch
1179                    });
1180                    _this.slide(_this.index, fromTouch, false);
1181                } else if (_this.s.slideEndAnimatoin) {
1182                    _lgUtils2.default.addClass(_this.outer, 'lg-left-end');
1183                    setTimeout(function () {
1184                        _lgUtils2.default.removeClass(_this.outer, 'lg-left-end');
1185                    }, 400);
1186                }
1187            }
1188        }
1189    };
1190
1191    Plugin.prototype.keyPress = function () {
1192        var _this = this;
1193        if (this.items.length > 1) {
1194            _lgUtils2.default.on(window, 'keyup.lg', function (e) {
1195                if (_this.items.length > 1) {
1196                    if (e.keyCode === 37) {
1197                        e.preventDefault();
1198                        _this.goToPrevSlide();
1199                    }
1200
1201                    if (e.keyCode === 39) {
1202                        e.preventDefault();
1203                        _this.goToNextSlide();
1204                    }
1205                }
1206            });
1207        }
1208
1209        _lgUtils2.default.on(window, 'keydown.lg', function (e) {
1210            if (_this.s.escKey === true && e.keyCode === 27) {
1211                e.preventDefault();
1212                if (!_lgUtils2.default.hasClass(_this.outer, 'lg-thumb-open')) {
1213                    _this.destroy();
1214                } else {
1215                    _lgUtils2.default.removeClass(_this.outer, 'lg-thumb-open');
1216                }
1217            }
1218        });
1219    };
1220
1221    Plugin.prototype.arrow = function () {
1222        var _this = this;
1223        _lgUtils2.default.on(this.outer.querySelector('.lg-prev'), 'click.lg', function () {
1224            _this.goToPrevSlide();
1225        });
1226
1227        _lgUtils2.default.on(this.outer.querySelector('.lg-next'), 'click.lg', function () {
1228            _this.goToNextSlide();
1229        });
1230    };
1231
1232    Plugin.prototype.arrowDisable = function (index) {
1233
1234        // Disable arrows if s.hideControlOnEnd is true
1235        if (!this.s.loop && this.s.hideControlOnEnd) {
1236            var next = this.outer.querySelector('.lg-next');
1237            var prev = this.outer.querySelector('.lg-prev');
1238            if (index + 1 < this.___slide.length) {
1239                next.removeAttribute('disabled');
1240                _lgUtils2.default.removeClass(next, 'disabled');
1241            } else {
1242                next.setAttribute('disabled', 'disabled');
1243                _lgUtils2.default.addClass(next, 'disabled');
1244            }
1245
1246            if (index > 0) {
1247                prev.removeAttribute('disabled');
1248                _lgUtils2.default.removeClass(prev, 'disabled');
1249            } else {
1250                
1250next.setAttribute('disabled', 'disabled');
1251                _lgUtils2.default.addClass(next
vendor: 11,401 bytes, lines 1251-1546
1251, 'disabled');
1252            }
1253        }
1254    };
1255
1256    Plugin.prototype.setTranslate = function (el, xValue, yValue) {
1257        // jQuery supports Automatic CSS prefixing since jQuery 1.8.0
1258        if (this.s.useLeft) {
1259            el.style.left = xValue;
1260        } else {
1261            _lgUtils2.default.setVendor(el, 'Transform', 'translate3d(' + xValue + 'px, ' + yValue + 'px, 0px)');
1262        }
1263    };
1264
1265    Plugin.prototype.touchMove = function (startCoords, endCoords) {
1266
1267        var distance = endCoords - startCoords;
1268
1269        if (Math.abs(distance) > 15) {
1270            // reset opacity and transition duration
1271            _lgUtils2.default.addClass(this.outer, 'lg-dragging');
1272
1273            // move current slide
1274            this.setTranslate(this.___slide[this.index], distance, 0);
1275
1276            // move next and prev slide with current slide
1277            this.setTranslate(document.querySelector('.lg-prev-slide'), -this.___slide[this.index].clientWidth + distance, 0);
1278            this.setTranslate(document.querySelector('.lg-next-slide'), this.___slide[this.index].clientWidth + distance, 0);
1279        }
1280    };
1281
1282    Plugin.prototype.touchEnd = function (distance) {
1283        var _this = this;
1284
1285        // keep slide animation for any mode while dragg/swipe
1286        if (_this.s.mode !== 'lg-slide') {
1287            _lgUtils2.default.addClass(_this.outer, 'lg-slide');
1288        }
1289
1290        for (var i = 0; i < this.___slide.length; i++) {
1291            if (!_lgUtils2.default.hasClass(this.___slide[i], 'lg-current') && !_lgUtils2.default.hasClass(this.___slide[i], 'lg-prev-slide') && !_lgUtils2.default.hasClass(this.___slide[i], 'lg-next-slide')) {
1292                this.___slide[i].style.opacity = '0';
1293            }
1294        }
1295
1296        // set transition duration
1297        setTimeout(function () {
1298            _lgUtils2.default.removeClass(_this.outer, 'lg-dragging');
1299            if (distance < 0 && Math.abs(distance) > _this.s.swipeThreshold) {
1300                _this.goToNextSlide(true);
1301            } else if (distance > 0 && Math.abs(distance) > _this.s.swipeThreshold) {
1302                _this.goToPrevSlide(true);
1303            } else if (Math.abs(distance) < 5) {
1304
1305                // Trigger click if distance is less than 5 pix
1306                _lgUtils2.default.trigger(_this.el, 'onSlideClick');
1307            }
1308
1309            for (var i = 0; i < _this.___slide.length; i++) {
1310                _this.___slide[i].removeAttribute('style');
1311            }
1312        });
1313
1314        // remove slide class once drag/swipe is completed if mode is not slide
1315        setTimeout(function () {
1316            if (!_lgUtils2.default.hasClass(_this.outer, 'lg-dragging') && _this.s.mode !== 'lg-slide') {
1317                _lgUtils2.default.removeClass(_this.outer, 'lg-slide');
1318            }
1319        }, _this.s.speed + 100);
1320    };
1321
1322    Plugin.prototype.enableSwipe = function () {
1323        var _this = this;
1324        var startCoords = 0;
1325        var endCoords = 0;
1326        var isMoved = false;
1327
1328        if (_this.s.enableSwipe && _this.isTouch && _this.doCss()) {
1329
1330            for (var i = 0; i < _this.___slide.length; i++) {
1331                /*jshint loopfunc: true */
1332                _lgUtils2.default.on(_this.___slide[i], 'touchstart.lg', function (e) {
1333                    if (!_lgUtils2.default.hasClass(_this.outer, 'lg-zoomed') && !_this.lgBusy) {
1334                        e.preventDefault();
1335                        _this.manageSwipeClass();
1336                        startCoords = e.targetTouches[0].pageX;
1337                    }
1338                });
1339            }
1340
1341            for (var j = 0; j < _this.___slide.length; j++) {
1342                /*jshint loopfunc: true */
1343                _lgUtils2.default.on(_this.___slide[j], 'touchmove.lg', function (e) {
1344                    if (!_lgUtils2.default.hasClass(_this.outer, 'lg-zoomed')) {
1345                        e.preventDefault();
1346                        endCoords = e.targetTouches[0].pageX;
1347                        _this.touchMove(startCoords, endCoords);
1348                        isMoved = true;
1349                    }
1350                });
1351            }
1352
1353            for (var k = 0; k < _this.___slide.length; k++) {
1354                /*jshint loopfunc: true */
1355                _lgUtils2.default.on(_this.___slide[k], 'touchend.lg', function () {
1356                    if (!_lgUtils2.default.hasClass(_this.outer, 'lg-zoomed')) {
1357                        if (isMoved) {
1358                            isMoved = false;
1359                            _this.touchEnd(endCoords - startCoords);
1360                        } else {
1361                            _lgUtils2.default.trigger(_this.el, 'onSlideClick');
1362                        }
1363                    }
1364                });
1365            }
1366        }
1367    };
1368
1369    Plugin.prototype.enableDrag = function () {
1370        var _this = this;
1371        var startCoords = 0;
1372        var endCoords = 0;
1373        var isDraging = false;
1374        var isMoved = false;
1375        if (_this.s.enableDrag && !_this.isTouch && _this.doCss()) {
1376            for (var i = 0; i < _this.___slide.length; i++) {
1377                /*jshint loopfunc: true */
1378                _lgUtils2.default.on(_this.___slide[i], 'mousedown.lg', function (e) {
1379                    // execute only on .lg-object
1380                    if (!_lgUtils2.default.hasClass(_this.outer, 'lg-zoomed')) {
1381                        if (_lgUtils2.default.hasClass(e.target, 'lg-object') || _lgUtils2.default.hasClass(e.target, 'lg-video-play')) {
1382                            e.preventDefault();
1383
1384                            if (!_this.lgBusy) {
1385                                _this.manageSwipeClass();
1386                                startCoords = e.pageX;
1387                                isDraging = true;
1388
1389                                // ** Fix for webkit cursor issue https://code.google.com/p/chromium/issues/detail?id=26723
1390                                _this.outer.scrollLeft += 1;
1391                                _this.outer.scrollLeft -= 1;
1392
1393                                // *
1394
1395                                _lgUtils2.default.removeClass(_this.outer, 'lg-grab');
1396                                _lgUtils2.default.addClass(_this.outer, 'lg-grabbing');
1397
1398                                _lgUtils2.default.trigger(_this.el, 'onDragstart');
1399                            }
1400                        }
1401                    }
1402                });
1403            }
1404
1405            _lgUtils2.default.on(window, 'mousemove.lg', function (e) {
1406                if (isDraging) {
1407                    isMoved = true;
1408                    endCoords = e.pageX;
1409                    _this.touchMove(startCoords, endCoords);
1410                    _lgUtils2.default.trigger(_this.el, 'onDragmove');
1411                }
1412            });
1413
1414            _lgUtils2.default.on(window, 'mouseup.lg', function (e) {
1415                if (isMoved) {
1416                    isMoved = false;
1417                    _this.touchEnd(endCoords - startCoords);
1418                    _lgUtils2.default.trigger(_this.el, 'onDragend');
1419                } else if (_lgUtils2.default.hasClass(e.target, 'lg-object') || _lgUtils2.default.hasClass(e.target, 'lg-video-play')) {
1420                    _lgUtils2.default.trigger(_this.el, 'onSlideClick');
1421                }
1422
1423                // Prevent execution on click
1424                if (isDraging) {
1425                    isDraging = false;
1426                    _lgUtils2.default.removeClass(_this.outer, 'lg-grabbing');
1427                    _lgUtils2.default.addClass(_this.outer, 'lg-grab');
1428                }
1429            });
1430        }
1431    };
1432
1433    Plugin.prototype.manageSwipeClass = function () {
1434        var touchNext = this.index + 1;
1435        var touchPrev = this.index - 1;
1436        var length = this.___slide.length;
1437        if (this.s.loop) {
1438            if (this.index === 0) {
1439                touchPrev = length - 1;
1440            } else if (this.index === length - 1) {
1441                touchNext = 0;
1442            }
1443        }
1444
1445        for (var i = 0; i < this.___slide.length; i++) {
1446            _lgUtils2.default.removeClass(this.___slide[i], 'lg-next-slide');
1447            _lgUtils2.default.removeClass(this.___slide[i], 'lg-prev-slide');
1448        }
1449
1450        if (touchPrev > -1) {
1451            _lgUtils2.default.addClass(this.___slide[touchPrev], 'lg-prev-slide');
1452        }
1453
1454        _lgUtils2.default.addClass(this.___slide[touchNext], 'lg-next-slide');
1455    };
1456
1457    Plugin.prototype.mousewheel = function () {
1458        var _this = this;
1459        _lgUtils2.default.on(_this.outer, 'mousewheel.lg', function (e) {
1460
1461            if (!e.deltaY) {
1462                return;
1463            }
1464
1465            if (e.deltaY > 0) {
1466                _this.goToPrevSlide();
1467            } else {
1468                _this.goToNextSlide();
1469            }
1470
1471            e.preventDefault();
1472        });
1473    };
1474
1475    Plugin.prototype.closeGallery = function () {
1476
1477        var _this = this;
1478        var mousedown = false;
1479        _lgUtils2.default.on(this.outer.querySelector('.lg-close'), 'click.lg', function () {
1480            _this.destroy();
1481        });
1482
1483        if (_this.s.closable) {
1484
1485            // If you drag the slide and release outside gallery gets close on chrome
1486            // for preventing this check mousedown and mouseup happened on .lg-item or lg-outer
1487            _lgUtils2.default.on(_this.outer, 'mousedown.lg', function (e) {
1488
1489                if (_lgUtils2.default.hasClass(e.target, 'lg-outer') || _lgUtils2.default.hasClass(e.target, 'lg-item') || _lgUtils2.default.hasClass(e.target, 'lg-img-wrap')) {
1490                    mousedown = true;
1491                } else {
1492                    mousedown = false;
1493                }
1494            });
1495
1496            _lgUtils2.default.on(_this.outer, 'mouseup.lg', function (e) {
1497
1498                if (_lgUtils2.default.hasClass(e.target, 'lg-outer') || _lgUtils2.default.hasClass(e.target, 'lg-item') || _lgUtils2.default.hasClass(e.target, 'lg-img-wrap') && mousedown) {
1499                    if (!_lgUtils2.default.hasClass(_this.outer, 'lg-dragging')) {
1500                        _this.destroy();
1501                    }
1502                }
1503            });
1504        }
1505    };
1506
1507    Plugin.prototype.destroy = function (d) {
1508
1509        var _this = this;
1510
1511        if (!d) {
1512            _lgUtils2.default.trigger(_this.el, 'onBeforeClose');
1513        }
1514
1515        document.body.scrollTop = _this.prevScrollTop;
1516        document.documentElement.scrollTop = _this.prevScrollTop;
1517
1518        /**
1519         * if d is false or undefined destroy will only close the gallery
1520         * plugins instance remains with the element
1521         *
1522         * if d is true destroy will completely remove the plugin
1523         */
1524
1525        if (d) {
1526            if (!_this.s.dynamic) {
1527                // only when not using dynamic mode is $items a jquery collection
1528
1529                for (var i = 0; i < this.items.length; i++) {
1530                    _lgUtils2.default.off(this.items[i], '.lg');
1531                    _lgUtils2.default.off(this.items[i], '.lgcustom');
1532                }
1533            }
1534
1535            var lguid = _this.el.getAttribute('lg-uid');
1536            delete window.lgData[lguid];
1537            _this.el.removeAttribute('lg-uid');
1538        }
1539
1540        // Unbind all events added by lightGallery
1541        _lgUtils2.default.off(this.el, '.lgtm');
1542
1543        // Distroy all lightGallery modules
1544        for (var key in window.lgModules) {
1545            if (_this.modules[key]) {
1546                _this.modules[key].destroy(
1546);
1547            }
1548        }
1549
1550        this.lGalleryOn = false;
1551
1552        clearTimeout(_this.hideBartimeout);
1553        this.hideBartimeout = false;
1554        _lgUtils2.default.off(window, '.lg');
1555        _lgUtils2.default.removeClass(document.body, 'lg-on');
1556        _lgUtils2.default.removeClass(document.body, 'lg-from-hash');
1557
1558        if (_this.outer) {
1559            _lgUtils2.default.removeClass(_this.outer, 'lg-visible');
1560        }
1561
1562        _lgUtils2.default.removeClass(document.querySelector('.lg-backdrop'), 'in');
1563        setTimeout(function () {
1564            try {
1565                if (_this.outer) {
1566                    _this.outer.parentNode.removeChild(_this.outer);
1567                }
1568
1569                if (document.querySelector('.lg-backdrop')) {
1570                    document.querySelector('.lg-backdrop').parentNode.removeChild(document.querySelector('.lg-backdrop'));
1571                }
1572
1573                if (!d) {
1574                    _lgUtils2.default.trigger(_this.el, 'onCloseAfter');
1575                }
1576            } catch (err) {}
1577        }, _this.s.backdropDuration + 50);
1578    };
1579
1580    window.lightGallery = function (el, options) {
1581        if (!el) {
1582            return;
1583        }
1584
1585        try {
1586            if (!el.getAttribute('lg-uid')) {
1587                var uid = 'lg' + window.lgData.uid++;
1588                window.lgData[uid] = new Plugin(el, options);
1589                el.setAttribute('lg-uid', uid);
1590            } else {
1591                try {
1592                    window.lgData[el.getAttribute('lg-uid')].init();
1593                } catch (err) {
1594                    console.error('lightGallery has not initiated properly');
1595                }
1596            }
1597        } catch (err) {
1598            console.error('lightGallery has not initiated properly');
1599        }
1600    };
1601});
1602
1603},{"./lg-utils":1}]},{},[2])(2)
1604});

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.