PageSourceSearch

https://scad.gov.ae/o/scad-theme/js/lightgallery.js

js scad.gov.ae collected 2026-10-02 07:16:18 UTC 76,361 bytes, 1,624 lines download raw bytes

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

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.