PageSourceSearch

https://sib.org.bz/wp-content/plugins/teampress/js/glightbox.min.js?ver=1.0

js sib.org.bz collected 2026-09-24 22:12:29 UTC 70,807 bytes, 1,962 lines download raw bytes

1(function (global, factory) {
2    if (typeof define === "function" && define.amd) {
3        define('GLightbox', ['module'], factory);
4    } else if (typeof exports !== "undefined") {
5        factory(module);
6    } else {
7        var mod = {
8            exports: {}
9        };
10        factory(mod);
11        global.GLightbox = mod.exports;
12    }
13})(this, function (module) {
14    'use strict';
15
16    function _classCallCheck(instance, Constructor) {
17        if (!(instance instanceof Constructor)) {
18            throw new TypeError("Cannot call a class as a function");
19        }
20    }
21
22    var _createClass = function () {
23        function defineProperties(target, props) {
24            for (var i = 0; i < props.length; i++) {
25                var descriptor = props[i];
26                descriptor.enumerable = descriptor.enumerable || false;
27                descriptor.configurable = true;
28                if ("value" in descriptor) descriptor.writable = true;
29                Object.defineProperty(target, descriptor.key, descriptor);
30            }
31        }
32
33        return function (Constructor, protoProps, staticProps) {
34            if (protoProps) defineProperties(Constructor.prototype, protoProps);
35            if (staticProps) defineProperties(Constructor, staticProps);
36            return Constructor;
37        };
38    }();
39
40    var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) {
41        return typeof obj;
42    } : function (obj) {
43        return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
44    };
45
46    /**
47     * GLightbox v1.0.8
48     * Awesome pure javascript lightbox
49     * made by mcstudios.com.mx
50     */
51
52    var isMobile = navigator.userAgent.match(/(iPad)|(iPhone)|(iPod)|(Android)|(PlayBook)|(BB10)|(BlackBerry)|(Opera Mini)|(IEMobile)|(webOS)|(MeeGo)/i);
53    var isTouch = isMobile !== null || document.createTouch !== undefined || 'ontouchstart' in window || 'onmsgesturechange' in window || navigator.msMaxTouchPoints;
54    var html = document.getElementsByTagName('html')[0];
55    var body = document.body;
56    var transitionEnd = whichTransitionEvent();
57    var animationEnd = whichAnimationEvent();
58    var uid = Date.now();
59
60    var YTTemp = [];
61    var videoPlayers = {};
62
63    // Default settings
64    var defaults = {
65        selector: 'glightbox',
66        skin: 'clean',
67        closeButton: true,
68        startAt: 0,
69        autoplayVideos: true,
70        descPosition: 'bottom',
71        width: 900,
72        height: 506,
73        videosWidth: 960,
74        videosHeight: 540,
75        beforeSlideChange: null,
76        afterSlideChange: null,
77        beforeSlideLoad: null,
78        afterSlideLoad: null,
79        onOpen: null,
80        onClose: null,
81        loopAtEnd: false,
82        touchNavigation: true,
83        keyboardNavigation: true,
84        closeOnOutsideClick: true,
85        jwplayer: {
86            api: null,
87            licenseKey: null,
88            params: {
89                width: '100%',
90                aspectratio: '16:9',
91                stretching: 'uniform'
92            }
93        },
94        vimeo: {
95            api: 'https://player.vimeo.com/api/player.js',
96            params: {
97                api: 1,
98                title: 0,
99                byline: 0,
100                portrait: 0
101            }
102        },
103        youtube: {
104            api: 'https://www.youtube.com/iframe_api',
105            params: {
106                enablejsapi: 1,
107                showinfo: 0
108            }
109        },
110        openEffect: 'zoomIn', // fade, zoom, none
111        closeEffect: 'zoomOut', // fade, zoom, none
112        slideEffect: 'slide', // fade, slide, zoom, none
113        moreText: 'See more',
114        moreLength: 60,
115        slideHtml: '',
116        lightboxHtml: '',
117        cssEfects: {
118            fade: { in: 'fadeIn', out: 'fadeOut' },
119            zoom: { in: 'zoomIn', out: 'zoomOut' },
120            slide: { in: 'slideInRight', out: 'slideOutLeft' },
121            slide_back: { in: 'slideInLeft', out: 'slideOutRight' }
122        }
123    };
124
125    /* jshint multistr: true */
126    // You can pass your own slide structure
127    // just make sure that add the same classes so they are populated
128    // title class = gslide-title
129    // desc class = gslide-desc
130    // prev arrow class = gnext
131    // next arrow id = gprev
132    // close id = gclose
133    var lightboxSlideHtml = '<div class="gslide">\
134         <div class="gslide-inner-content">\
135            <div class="ginner-container">\
136               <div class="gslide-media">\
137               </div>\
138               <div class="gslide-description">\
139                  <h4 class="gslide-title"></h4>\
140                  <div class="gslide-desc"></div>\
141               </div>\
142            </div>\
143         </div>\
144       </div>';
145    defaults.slideHtml = lightboxSlideHtml;
146
147    var lightboxHtml = '<div id="glightbox-body" class="glightbox-container">\
148            <div class="gloader visible"></div>\
149            <div class="goverlay"></div>\
150            <div class="gcontainer">\
151               <div id="glightbox-slider" class="gslider"></div>\
152               <a class="gnext"></a>\
153               <a class="gprev"></a>\
154               <a class="gclose"></a>\
155            </div>\
156   </div>';
157    defaults.lightboxHtml = lightboxHtml;
158
159    /**
160     * Merge two or more objects
161     */
162    function extend() {
163        var extended = {};
164        var deep = false;
165        var i = 0;
166        var length = arguments.length;
167        if (Object.prototype.toString.call(arguments[0]) === '[object Boolean]') {
168            deep = arguments[0];
169            i++;
170        }
171        var merge = function merge(obj) {
172            for (var prop in obj) {
173                if (Object.prototype.hasOwnProperty.call(obj, prop)) {
174                    if (deep && Object.prototype.toString.call(obj[prop]) === '[object Object]') {
175                        extended[prop] = extend(true, extended[prop], obj[prop]);
176                    } else {
177                        extended[prop] = obj[prop];
178                    }
179                }
180            }
181        };
182        for (; i < length; i++) {
183            var obj = arguments[i];
184            merge(obj);
185        }
186        return extended;
187    }
188
189    var utils = {
190        isFunction: function isFunction(f) {
191            return typeof f === 'function';
192        },
193        isString: function isString(s) {
194            return typeof s === 'string';
195        },
196        isNode: function isNode(el) {
197            return !!(el && el.nodeType && el.nodeType == 1);
198        },
199        isArray: function isArray(ar) {
200            return Array.isArray(ar);
201        },
202        isArrayLike: function isArrayLike(ar) {
203            return ar && ar.length && isFinite(ar.length);
204        },
205        isObject: function isObject(o) {
206            var type = typeof o === 'undefined' ? 'undefined' : _typeof(o);
207            return type === 'object' && o != null && !utils.isFunction(o) && !utils.isArray(o);
208        },
209        isNil: function isNil(o) {
210            return o == null;
211        },
212        has: function has(obj, key) {
213            return obj !== null && hasOwnProperty.call(obj, key);
214        },
215        size: function size(o) {
216            if (utils.isObject(o)) {
217                if (o.keys) {
218                    return o.keys().length;
219                }
220                var l = 0;
221                for (var k in o) {
222                    if (utils.has(o, k)) {
223                        l++;
224                    }
225                }
226                return l;
227            } else {
228                return o.length;
229            }
230        },
231        isNumber: function isNumber(n) {
232            return !isNaN(parseFloat(n)) && isFinite(n);
233        }
234    };
235
236    /**
237     * Each
238     *
239     * @param {mixed} node lisy, array, object
240     * @param {function} callback
241     */
242    function each(collection, callback) {
243        if (utils.isNode(collection) || collection === window || collection === document) {
244            collection = [collection];
245        }
246        if (!utils.isArrayLike(collection) && !utils.isObject(collection)) {
247            collection = [collection];
248        }
249        if (utils.size(collection) == 0) {
250            return;
251        }
252
253        if (utils.isArrayLike(collection) && !utils.isObject(collection)) {
254            var l = collection.length,
255                i = 0;
256            for (; i < l; i++) {
257                if (callback.call(collection[i], collection[i], i, collection) === false) {
258                    break;
259                }
260            }
261        } else if (utils.isObject(collection)) {
262            for (var key in collection) {
263                if (utils.has(collection, key)) {
264                    if (callback.call(collection[key], collection[key], key, collection) === false) {
265                        break;
266                    }
267                }
268            }
269        }
270    }
271
272    /**
273     * Get nde events
274     * return node events and optionally
275     * check if the node has already a specific event
276     * to avoid duplicated callbacks
277     *
278     * @param {node} node
279     * @param {string} name event name
280     * @param {object} fn callback
281     * @returns {object}
282     */
283    function getNodeEvents(node) {
284        var name = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
285        var fn = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
286
287        var cache = node[uid] = node[uid] || [];
288        var data = { all: cache, evt: null, found: null };
289        if (name && fn && utils.size(cache) > 0) {
290            each(cache, function (cl, i) {
291                if (cl.eventName == name && cl.fn.toString() == fn.toString()) {
292                    data.found = true;
293                    data.evt = i;
294                    return false;
295                }
296            });
297        }
298        return data;
299    }
300
301    /**
302     * Add Event
303     * Add an event listener
304     *
305     * @param {string} eventName
306     * @param {object} detials
307     */
308    function addEvent(eventName) {
309        var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
310            onElement = _ref.onElement,
311            withCallback = _ref.withCallback,
312            _ref$avoidDuplicate = _ref.avoidDuplicate,
313            avoidDuplicate = _ref$avoidDuplicate === undefined ? true : _ref$avoidDuplicate,
314            _ref$once = _ref.once,
315            once = _ref$once === undefined ? false : _ref$once,
316            _ref$useCapture = _ref.useCapture,
317            useCapture = _ref$useCapture === undefined ? false : _ref$useCapture;
318
319        var thisArg = arguments[2];
320
321        var element = onElement || [];
322        if (utils.isString(element)) {
323            element = document.querySelectorAll(element);
324        }
325        function handler(event) {
326            if (utils.isFunction(withCallback)) {
327                withCallback.call(thisArg, event, this);
328            }
329            if (once) {
330                handler.destroy();
331            }
332        }
333        handler.destroy = function () {
334            each(element, function (el) {
335                var events = getNodeEvents(el, eventName, handler);
336                if (events.found) {
337                    events.all.splice(events.evt, 1);
338                }
339                if (el.removeEventListener) el.removeEventListener(eventName, handler, useCapture);
340            });
341        };
342        each(element, function (el) {
343            var events = getNodeEvents(el, eventName, handler);
344            if (el.addEventListener && avoidDuplicate && !events.found || !avoidDuplicate) {
345                el.addEventListener(eventName, handler, useCapture);
346                events.all.push({ eventName: eventName, fn: handler });
347            }
348        });
349        return handler;
350    }
351
352    /**
353     * Add element class
354     *
355     * @param {node} element
356     * @param {string} class name
357     */
358    function addClass(node, name) {
359        if (hasClass(node, name)) {
360            return;
361        }
362        if (node.classList) {
363            node.classList.add(name);
364        } else {
365            node.className += " " + name;
366        }
367    }
368
369    /**
370     * Remove element class
371     *
372     * @param {node} element
373     * @param {string} class name
374     */
375    function removeClass(node, name) {
376        var c = name.split(' ');
377        if (c.length > 1) {
378            each(c, function (cl) {
379                removeClass(node, cl);
380            });
381            return;
382        }
383        if (node.classList) {
384            node.classList.remove(name);
385        } else {
386            node.className = node.className.replace(name, "");
387        }
388    }
389
390    /**
391     * Has class
392     *
393     * @param {node} element
394     * @param {string} class name
395     */
396    function hasClass(node, name) {
397        return node.classList ? node.classList.contains(name) : new RegExp("(^| )" + name + "( |$)", "gi").test(node.className);
398    }
399
400    /**
401     * Determine animation events
402     */
403    function whichAnimationEvent() {
404        var t = void 0,
405            el = document.createElement("fakeelement");
406        var animations = {
407            animation: "animationend",
408            OAnimation: "oAnimationEnd",
409            MozAnimation: "animationend",
410            WebkitAnimation: "webkitAnimationEnd"
411        };
412        for (t in animations) {
413            if (el.style[t] !== undefined) {
414                return animations[t];
415            }
416        }
417    }
418
419    /**
420     * Determine transition events
421     */
422    function whichTransitionEvent() {
423        var t = void 0,
424            el = document.createElement("fakeelement");
425
426        var transitions = {
427            transition: "transitionend",
428            OTransition: "oTransitionEnd",
429            MozTransition: "transitionend",
430            WebkitTransition: "webkitTransitionEnd"
431        };
432
433        for (t in transitions) {
434            if (el.style[t] !== undefined) {
435                return transitions[t];
436            }
437        }
438    }
439
440    /**
441     * CSS Animations
442     *
443     * @param {node} element
444     * @param {string} animation name
445     * @param {function} callback
446     */
447    function animateElement(element) {
448        var animation = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
449        var callback = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
450
451        if (!element || animation === '') {
452            return false;
453        }
454        if (animation == 'none') {
455            if (utils.isFunction(callback)) callback();
456            return false;
457        }
458        var animationNames = animation.split(' ');
459        each(animationNames, function (name) {
460            addClass(element, 'g' + name);
461        });
462        addEvent(animationEnd, {
463            onElement: element,
464            avoidDuplicate: false,
465            once: true,
466            withCallback: function withCallback(event, target) {
467                each(animationNames, function (name) {
468                    removeClass(target, 'g' + name);
469                });
470                if (utils.isFunction(callback)) callback();
471            }
472        });
473    }
474
475    /**
476     * Create a document fragment
477     *
478     * @param {string} html code
479     */
480    function createHTML(htmlStr) {
481        var frag = document.createDocumentFragment(),
482            temp = document.createElement('div');
483        temp.innerHTML = htmlStr;
484        while (temp.firstChild) {
485            frag.appendChild(temp.firstChild);
486        }
487        return frag;
488    }
489
490    /**
491     * Get the closestElement
492     *
493     * @param {node} element
494     * @param {string} class name
495     */
496    function getClosest(elem, selector) {
497        while (elem !== document.body) {
498            elem = elem.parentElement;
499            var matches = typeof elem.matches == 'function' ? elem.matches(selector) : elem.msMatchesSelector(selector);
500
501            if (matches) return elem;
502        }
503    }
504
505    /**
506     * Show element
507     *
508     * @param {node} element
509     */
510    function show(element) {
511        element.style.display = 'block';
512    }
513
514    /**
515     * Hide element
516     */
517    function hide(element) {
518        element.style.display = 'none';
519    }
520
521    /**
522     * Get slide data
523     *
524     * @param {node} element
525     */
526    var getSlideData = function getSlideData() {
527        var element = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
528        var settings = arguments[1];
529
530        var data = {
531            href: '',
532            title: '',
533            description: '',
534            descPosition: 'bottom',
535            effect: '',
536            node: element
537        };
538
539        if (utils.isObject(element) && !utils.isNode(element)) {
540            return extend(data, element);
541        }
542
543        var url = '';
544        var config = element.getAttribute('data-glightbox');
545        var type = element.nodeName.toLowerCase();
546        if (type === 'div') url = jQuery(element).attr('href');
547        if (type === 'img') url = element.src;
548
549        data.href = url;
550
551        each(data, function (val, key) {
552            if (utils.has(settings, key)) {
553                data[key] = settings[key];
554            }
555            var nodeData = element.dataset[key];
556            if (!utils.isNil(nodeData)) {
557                data[key] = nodeData;
558            }
559        });
560
561        var sourceType = getSourceType(url);
562        data = extend(data, sourceType);
563
564        if (!utils.isNil(config)) {
565            var cleanKeys = [];
566            each(data, function (v, k) {
567                cleanKeys.push(';\\s?' + k);
568            });
569            cleanKeys = cleanKeys.join('\\s?:|');
570            if (config.trim() !== '') {
571                each(data, function (val, key) {
572                    var str = config;
573                    var match = '\s?' + key + '\s?:\s?(.*?)(' + cleanKeys + '\s?:|$)';
574                    var regex = new RegExp(match);
575                    var matches = str.match(regex);
576
577                    if (matches && matches.length && matches[1]) {
578                        var value = matches[1].trim().replace(/;\s*$/, '');
579                        data[key] = value;
580                    }
581                });
582            }
583        } else {
584            if (type == 'div') {
585                var title = element.title;
586                if (!utils.isNil(title) && title !== '') data.title = title;
587            }
588            if (type == 'img') {
589                var alt = element.alt;
590                if (!utils.isNil(alt) && alt !== '') data.title = alt;
591            }
592            var desc = element.getAttribute('data-description');
593            if (!utils.isNil(desc) && desc !== '') data.description = desc;
594        }
595        var nodeDesc = element.querySelector('.glightbox-desc');
596        if (nodeDesc) {
597            data.description = nodeDesc.innerHTML;
598        }
599
600        data.sourcetype = data.hasOwnProperty('type') ? data.type : data.sourcetype;
601        data.type = data.sourcetype;
602
603        var defaultWith = data.sourcetype == 'video' ? settings.videosWidth : settings.width;
604        var defaultHeight = data.sourcetype == 'video' ? settings.videosHeight : settings.height;
605
606        data.width = utils.has(data, 'width') ? data.width : defaultWith;
607        data.height = utils.has(data, 'height') ? data.height : defaultHeight;
608
609        return data;
610    };
611
612    /**
613     * Set slide content
614     *
615     * @param {node} slide
616     * @param {object} data
617     * @param {function} callback
618     */
619    var setSlideContent = function setSlideContent() {
620        var slide = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
621
622        var _this = this;
623
624        var data = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
625        var callback = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
626
627        if (hasClass(slide, 'loaded')) {
628            return false;
629        }
630
631        if (utils.isFunction(this.settings.beforeSlideLoad)) {
632            this.settings.beforeSlideLoad(slide, data);
633        }
634
635        var type = data.type;
636        var position = data.descPosition;
637        var slideMedia = slide.querySelector('.gslide-media');
638        var slideTitle = slide.querySelector('.gslide-title');
639        var slideText = slide.querySelector('.gslide-desc');
640        var slideDesc = slide.querySelector('.gslide-description');
641        var finalCallback = callback;
642
643        if (utils.isFunction(this.settings.afterSlideLoad)) {
644            finalCallback = function finalCallback() {
645                if (utils.isFunction(callback)) {
646                    callback();
647                }
648                _this.settings.afterSlideLoad(slide, data);
649            };
650        }
651
652        if (data.title == '' && data.description == '') {
653            if (slideDesc) {
654                slideDesc.parentNode.removeChild(slideDesc);
655            }
656        } else {
657            if (slideTitle && data.title !== '') {
658                slideTitle.innerHTML = data.title;
659            } else {
660                slideTitle.parentNode.removeChild(slideTitle);
661            }
662            if (slideText && data.description !== '') {
663                if (isMobile && this.settings.moreLength > 0) {
664                    data.smallDescription = slideShortDesc(data.description, this.settings.moreLength, this.settings.moreText);
665                    slideText.innerHTML = data.smallDescription;
666                    slideDescriptionEvents.apply(this, [slideText, data]);
667                } else {
668                    slideText.innerHTML = data.description;
669                }
670            } else {
671                slideText.parentNode.removeChild(slideText);
672            }
673            addClass(slideMedia.parentNode, 'desc-' + position);
674            addClass(slideDesc, 'description-' + position);
675        }
676
677        addClass(slideMedia, 'gslide-' + type);
678        addClass(slide, 'loaded');
679
680        if (type === 'video') {
681            setSlideVideo.apply(this, [slide, data, finalCallback]);
682            return;
683        }
684
685        if (type === 'external') {
686            var iframe = createIframe(data.href, data.width, data.height, finalCallback);
687            slideMedia.appendChild(iframe);
688            return;
689        }
690
691        if (type === 'inline') {
692            setInlineContent.apply(this, [slide, data, finalCallback]);
693            return;
694        }
695
696        if (type === 'image') {
697            var img = new Image();
698            img.addEventListener('load', function () {
699                if (utils.isFunction(finalCallback)) {
700                    finalCallback();
701                }
702            }, false);
703            img.src = data.href;
704            /*-Disable image by exthemes-*/
705			//slideMedia.appendChild(img);
706            return;
707        }
708
709        if (utils.isFunction(finalCallback)) finalCallback();
710    };
711
712    /**
713     * Set slide video
714     *
715     * @param {node} slide
716     * @param {object} data
717     * @param {function} callback
718     */
719    function setSlideVideo(slide, data, callback) {
720        var _this2 = this;
721
722        var source = data.source;
723        var video_id = 'gvideo' + data.index;
724        var slideMedia = slide.querySelector('.gslide-media');
725
726        var url = data.href;
727        var protocol = location.protocol.replace(':', '');
728
729        if (protocol == 'file') {
730            protocol = 'http';
731        }
732
733        // Set vimeo videos
734        if (source == 'vimeo') {
735            var vimeo_id = /vimeo.*\/(\d+)/i.exec(url);
736            var params = parseUrlParams(this.settings.vimeo.params);
737            var video_url = protocol + '://player.vimeo.com/video/' + vimeo_id[1] + '?' + params;
738
739            injectVideoApi(this.settings.vimeo.api);
740
741            var finalCallback = function finalCallback() {
742                waitUntil(function () {
743                    return typeof Vimeo !== 'undefined';
744                }, function () {
745                    var player = new Vimeo.Player(iframe);
746                    videoPlayers[video_id] = player;
747
748                    if (utils.isFunction(callback)) {
749                        callback();
750                    }
751                });
752            };
753
754            var iframe = createIframe(video_url, data.width, data.height, finalCallback, slideMedia);
755            iframe.id = video_id;
756            iframe.className = 'vimeo-video gvideo';
757
758            if (this.settings.autoplayVideos && !isMobile) {
759                iframe.className += ' wait-autoplay';
760            }
761        }
762
763        // Set youtube videos
764        if (source == 'youtube') {
765            var youtube_params = extend(this.settings.youtube.params, {
766                playerapiid: video_id
767            });
768            var yparams = parseUrlParams(youtube_params);
769            var youtube_id = getYoutubeID(url);
770            var _video_url = protocol + '://www.youtube.com/embed/' + youtube_id + '?' + yparams;
771
772            injectVideoApi(this.settings.youtube.api);
773
774            var _finalCallback = function _finalCallback() {
775                if (!utils.isNil(YT) && YT.loaded) {
776                    var player = new YT.Player(_iframe);
777                    videoPlayers[video_id] = player;
778                } else {
779                    YTTemp.push(_iframe);
780                }
781                if (utils.isFunction(callback)) {
782                    callback();
783                }
784            };
785
786            var _iframe = createIframe(_video_url, data.width, data.height, _finalCallback, slideMedia);
787            _iframe.id = video_id;
788            _iframe.className = 'youtube-video gvideo';
789
790            if (this.settings.autoplayVideos && !isMobile) {
791                _iframe.className += ' wait-autoplay';
792            }
793        }
794
795        if (source == 'local') {
796            var _html = '<video id="' + video_id + '" ';
797            _html += 'style="background:#000; width: ' + data.width + 'px; height: ' + data.height + 'px;" ';
798            _html += 'preload="metadata" ';
799            _html += 'x-webkit-airplay="allow" ';
800            _html += 'webkit-playsinline="" ';
801            _html += 'controls ';
802            _html += 'class="gvideo">';
803
804            var format = url.toLowerCase().split('.').pop();
805            var sources = { 'mp4': '', 'ogg': '', 'webm': '' };
806            sources[format] = url;
807
808            for (var key in sources) {
809                if (sources.hasOwnProperty(key)) {
810                    var videoFile = sources[key];
811                    if (data.hasOwnProperty(key)) {
812                        videoFile = data[key];
813                    }
814                    if (videoFile !== '') {
815                        _html += '<source src="' + videoFile + '" type="video/' + key + '">';
816                    }
817                }
818            }
819
820            _html += '</video>';
821
822            var video = createHTML(_html);
823            slideMedia.appendChild(video);
824
825            var vnode = document.getElementById(video_id);
826            if (this.settings.jwplayer !== null && this.settings.jwplayer.api !== null) {
827                var jwplayerConfig = this.settings.jwplayer;
828                var jwplayerApi = this.settings.jwplayer.api;
829
830                if (!jwplayerApi) {
831                    console.warn('Missing jwplayer api file');
832                    if (utils.isFunction(callback)) callback();
833                    return false;
834                }
835
836                injectVideoApi(jwplayerApi, function () {
837                    var jwconfig = extend(_this2.settings.jwplayer.params, {
838                        width: data.width + 'px',
839                        height: data.height + 'px',
840                        file: url
841                    });
842
843                    jwplayer.key = _this2.settings.jwplayer.licenseKey;
844
845                    var player = jwplayer(video_id);
846
847                    player.setup(jwconfig);
848
849                    videoPlayers[video_id] = player;
850                    player.on('ready', function () {
851                        vnode = slideMedia.querySelector('.jw-video');
852                        addClass(vnode, 'gvideo');
853                        vnode.id = video_id;
854                        if (utils.isFunction(callback)) callback();
855                    });
856                });
857            } else {
858                addClass(vnode, 'html5-video');
859                videoPlayers[video_id] = vnode;
860                if (utils.isFunction(callback)) callback();
861            }
862        }
863    }
864
865    /**
866     * Create an iframe element
867     *
868     * @param {string} url
869     * @param {numeric} width
870     * @param {numeric} height
871     * @param {function} callback
872     */
873    function createIframe(url, width, height, callback, appendTo) {
874        var iframe = document.createElement('iframe');
875        var winWidth = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth;
876        iframe.className = 'vimeo-video gvideo';
877        iframe.src = url;
878        if (isMobile && winWidth < 767) {
879            iframe.style.height = '';
880        } else {
881            iframe.style.height = height + 'px';
882        }
883        iframe.style.width = width + 'px';
884        iframe.setAttribute('allowFullScreen', '');
885        iframe.onload = function () {
886            addClass(iframe, 'iframe-ready');
887            if (utils.isFunction(callback)) {
888                callback();
889            }
890        };
891
892        if (appendTo) {
893            appendTo.appendChild(iframe);
894        }
895        return iframe;
896    }
897
898    /**
899     * Get youtube ID
900     *
901     * @param {string} url
902     * @returns {string} video id
903     */
904    function getYoutubeID(url) {
905        var videoID = '';
906        url = url.replace(/(>|<)/gi, '').split(/(vi\/|v=|\/v\/|youtu\.be\/|\/embed\/)/);
907        if (url[2] !== undefined) {
908            videoID = url[2].split(/[^0-9a-z_\-]/i);
909            videoID = videoID[0];
910        } else {
911            videoID = url;
912        }
913        return videoID;
914    }
915
916    /**
917     * Inject videos api
918     * used for youtube, vimeo and jwplayer
919     *
920     * @param {string} url
921     * @param {function} callback
922     */
923    function injectVideoApi(url, callback) {
924        if (utils.isNil(url)) {
925            console.error('Inject videos api error');
926            return;
927        }
928        var found = document.querySelectorAll('script[src="' + url + '"]');
929        if (utils.isNil(found) || found.length == 0) {
930            var script = document.createElement('script');
931            script.type = 'text/javascript';
932            script.src = url;
933            script.onload = function () {
934                if (utils.isFunction(callback)) callback();
935            };
936            document.body.appendChild(script);
937            return false;
938        }
939        if (utils.isFunction(callback)) callback();
940    }
941
942    /**
943     * Handle youtube Api
944     * This is a simple fix, when the video
945     * is ready sometimes the youtube api is still
946     * loading so we can not autoplay or pause
947     * we need to listen onYouTubeIframeAPIReady and
948     * register the videos if required
949     */
950    function youtubeApiHandle() {
951        for (var i = 0; i < YTTemp.length; i++) {
952            var iframe = YTTemp[i];
953            var player = new YT.Player(iframe);
954            videoPlayers[iframe.id] = player;
955        }
956    }
957    if (typeof window.onYouTubeIframeAPIReady !== 'undefined') {
958        window.onYouTubeIframeAPIReady = function () {
959            window.onYouTubeIframeAPIReady();
960            youtubeApiHandle();
961        };
962    } else {
963        window.onYouTubeIframeAPIReady = youtubeApiHandle;
964    }
965
966    /**
967     * Wait until
968     * wait until all the validations
969     * are passed
970     *
971     * @param {function} check
972     * @param {function} onComplete
973     * @param {numeric} delay
974     * @param {numeric} timeout
975     */
976    function waitUntil(check, onComplete, delay, timeout) {
977        if (check()) {
978            onComplete();
979            return;
980        }
981
982        if (!delay) delay = 100;
983
984        var timeoutPointer;
985        var intervalPointer = setInterval(function () {
986            if (!check()) return;
987            clearInterval(intervalPointer);
988            if (timeoutPointer) clearTimeout(timeoutPointer);
989            onComplete();
990        }, delay);
991        if (timeout) timeoutPointer = setTimeout(function () {
992            clearInterval(intervalPointer);
993        }, timeout);
994    }
995
996    /**
997     * Parse url params
998     * convert an object in to a
999     * url query string parameters
1000     *
1001     * @param {object} params
1002     */
1003    function parseUrlParams(params) {
1004        var qs = '';
1005        var i = 0;
1006        each(params, function (val, key) {
1007            if (i > 0) {
1008                qs += '&amp;';
1009            }
1010            qs += key + '=' + val;
1011            i += 1;
1012        });
1013        return qs;
1014    }
1015
1016    /**
1017     * Set slide inline content
1018     * we'll extend this to make http
1019     * requests using the fetch api
1020     * but for now we keep it simple
1021     *
1022     * @param {node} slide
1023     * @param {object} data
1024     * @param {function} callback
1025     */
1026    function setInlineContent(slide, data, callback) {
1027        var slideMedia = slide.querySelector('.gslide-media');
1028        var div = document.getElementById(data.inlined.replace('#', ''));
1029        if (div) {
1030            var cloned = div.cloneNode(true);
1031            cloned.style.height = data.height + 'px';
1032            cloned.style.maxWidth = data.width + 'px';
1033            addClass(cloned, 'ginlined-content');
1034            slideMedia.appendChild(cloned);
1035
1036            if (utils.isFunction(callback)) {
1037                callback();
1038            }
1039            return;
1040        }
1041    }
1042
1043    /**
1044     * Get source type
1045     * gte the source type of a url
1046     *
1047     * @param {string} url
1048     */
1049    var getSourceType = function getSourceType(url) {
1050        var origin = url;
1051        url = url.toLowerCase();
1052        var data = {};
1053        if (url.match(/\.(jpeg|jpg|gif|png)$/) !== null) {
1054            data.sourcetype = 'image';
1055            return data;
1056        }
1057        if (url.match(/(youtube\.com|youtube-nocookie\.com)\/watch\?v=([a-zA-Z0-9\-_]+)/) || url.match(/youtu\.be\/([a-zA-Z0-9\-_]+)/)) {
1058            data.sourcetype = 'video';
1059            data.source = 'youtube';
1060            return data;
1061        }
1062        if (url.match(/vimeo\.com\/([0-9]*)/)) {
1063            data.sourcetype = 'video';
1064            data.source = 'vimeo';
1065            return data;
1066        }
1067        if (url.match(/\.(mp4|ogg|webm)$/) !== null) {
1068            data.sourcetype = 'video';
1069            data.source = 'local';
1070            return data;
1071        }
1072
1073        // Check if inline content
1074        if (url.indexOf("#") > -1) {
1075            var hash = origin.split('#').pop();
1076            if (hash.trim() !== '') {
1077                data.sourcetype = 'inline';
1078                data.source = url;
1079                data.inlined = '#' + hash;
1080                return data;
1081            }
1082        }
1083        // Ajax
1084        if (url.includes("gajax=true")) {
1085            data.sourcetype = 'ajax';
1086            data.source = url;
1087        }
1088
1089        // Any other url
1090        data.sourcetype = 'external';
1091        data.source = url;
1092        return data;
1093    };
1094
1095    /**
1096     * Desktop keyboard navigation
1097     */
1098    function keyboardNavigation() {
1099        var _this3 = this;
1100
1101        if (this.events.hasOwnProperty('keyboard')) {
1102            return false;
1103        }
1104        this.events['keyboard'] = addEvent('keydown', {
1105            onElement: window,
1106            withCallback: function withCallback(event, target) {
1107                event = event || window.event;
1108                var key = event.keyCode;
1109                if (key == 39) _this3.nextSlide();
1110                if (key == 37) _this3.prevSlide();
1111                if (key == 27) _this3.close();
1112            }
1113        });
1114    }
1115
1116    /**
1117     * Touch navigation
1118     */
1119    function touchNavigation() {
1120        var _this4 = this;
1121
1122        if (this.events.hasOwnProperty('touchStart')) {
1123            return false;
1124        }
1125        var index = void 0,
1126            hDistance = void 0,
1127            vDistance = void 0,
1128            hDistanceLast = void 0,
1129            vDistanceLast = void 0,
1130            hDistancePercent = void 0,
1131            vSwipe = false,
1132            hSwipe = false,
1133            hSwipMinDistance = 0,
1134            vSwipMinDistance = 0,
1135            doingPinch = false,
1136            pinchBigger = false,
1137            startCoords = {},
1138            endCoords = {},
1139            slider = this.slidesContainer,
1140            activeSlide = null,
1141            xDown = 0,
1142            yDown = 0,
1143            activeSlideImage = null,
1144            activeSlideMedia = null,
1145            activeSlideDesc = null;
1146
1147        var winWidth = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth;
1148        var winHeight = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight;
1149        this.events['doctouchmove'] = addEvent('touchmove', {
1150            onElement: document,
1151            withCallback: function withCallback(e, target) {
1152                if (hasClass(body, 'gdesc-open')) {
1153                    e.preventDefault();
1154                    return false;
1155                }
1156            }
1157        });
1158
1159        this.events['touchStart'] = addEvent('touchstart', {
1160            onElement: body,
1161            withCallback: function withCallback(e, target) {
1162                if (hasClass(body, 'gdesc-open')) {
1163                    return;
1164                }
1165                addClass(body, 'touching');
1166                activeSlide = _this4.getActiveSlide();
1167                activeSlideImage = activeSlide.querySelector('.gslide-image');
1168                activeSlideMedia = activeSlide.querySelector('.gslide-media');
1169                activeSlideDesc = activeSlide.querySelector('.gslide-description');
1170
1171                index = _this4.index;
1172                endCoords = e.targetTouches[0];
1173                startCoords.pageX = e.targetTouches[0].pageX;
1174                startCoords.pageY = e.targetTouches[0].pageY;
1175                xDown = e.targetTouches[0].clientX;
1176                yDown = e.targetTouches[0].clientY;
1177            }
1178        });
1179
1180        this.events['gestureStart'] = addEvent('gesturestart', {
1181            onElement: body,
1182            withCallback: function withCallback(e, target) {
1183                if (activeSlideImage) {
1184                    e.preventDefault();
1185                    doingPinch = true;
1186                }
1187            }
1188        });
1189
1190        this.events['gestureChange'] = addEvent('gesturechange', {
1191            onElement: body,
1192            withCallback: function withCallback(e, target) {
1193                e.preventDefault();
1194                slideCSSTransform(activeSlideImage, 'scale(' + e.scale + ')');
1195            }
1196        });
1197
1198        this.events['gesturEend'] = addEvent('gestureend', {
1199            onElement: body,
1200            withCallback: function withCallback(e, target) {
1201                doingPinch = false;
1202                if (e.scale < 1) {
1203                    pinchBigger = false;
1204                    slideCSSTransform(activeSlideImage, 'scale(1)');
1205                } else {
1206                    pinchBigger = true;
1207                }
1208            }
1209        });
1210
1211        this.events['touchMove'] = addEvent('touchmove', {
1212            onElement: body,
1213            withCallback: function withCallback(e, target) {
1214                if (!hasClass(body, 'touching')) {
1215                    return;
1216                }
1217                if (hasClass(body, 'gdesc-open') || doingPinch || pinchBigger) {
1218                    return;
1219                }
1220                e.preventDefault();
1221                endCoords = e.targetTouches[0];
1222                var slideHeight = activeSlide.querySelector('.gslide-inner-content').offsetHeight;
1223                var slideWidth = activeSlide.querySelector('.gslide-inner-content').offsetWidth;
1224
1225                var xUp = e.targetTouches[0].clientX;
1226                var yUp = e.targetTouches[0].clientY;
1227                var xDiff = xDown - xUp;
1228                var yDiff = yDown - yUp;
1229
1230                if (Math.abs(xDiff) > Math.abs(yDiff)) {
1231                    /*most significant*/
1232                    vSwipe = false;
1233                    hSwipe = true;
1234                } else {
1235                    hSwipe = false;
1236                    vSwipe = true;
1237                }
1238
1239                if (vSwipe) {
1240                    vDistanceLast = vDistance;
1241                    vDistance = endCoords.pageY - startCoords.pageY;
1242                    if (Math.abs(vDistance) >= vSwipMinDistance || vSwipe) {
1243                        var opacity = 0.75 - Math.abs(vDistance) / slideHeight;
1244                        activeSlideMedia.style.opacity = opacity;
1245                        if (activeSlideDesc) {
1246                            activeSlideDesc.style.opacity = opacity;
1247                        }
1248                        slideCSSTransform(activeSlideMedia, 'translate3d(0, ' + vDistance + 'px, 0)');
1249                    }
1250                    return;
1251                }
1252
1253                hDistanceLast = hDistance;
1254                hDistance = endCoords.pageX - startCoords.pageX;
1255                hDistancePercent = hDistance * 100 / winWidth;
1256
1257                if (hSwipe) {
1258                    if (_this4.index + 1 == _this4.elements.length && hDistance < -60) {
1259                        resetSlideMove(activeSlide);
1260                        return false;
1261                    }
1262                    if (_this4.index - 1 < 0 && hDistance > 60) {
1263                        resetSlideMove(activeSlide);
1264                        return false;
1265                    }
1266
1267                    var _opacity = 0.75 - Math.abs(hDistance) / slideWidth;
1268                    activeSlideMedia.style.opacity = _opacity;
1269                    if (activeSlideDesc) {
1270                        activeSlideDesc.style.opacity = _opacity;
1271                    }
1272                    slideCSSTransform(activeSlideMedia, 'translate3d(' + hDistancePercent + '%, 0, 0)');
1273                }
1274            }
1275        });
1276
1277        this.events['touchEnd'] = addEvent('touchend', {
1278            onElement: body,
1279            withCallback: function withCallback(e, target) {
1280                vDistance = endCoords.pageY - startCoords.pageY;
1281                hDistance = endCoords.pageX - startCoords.pageX;
1282                hDistancePercent = hDistance * 100 / winWidth;
1283
1284                removeClass(body, 'touching');
1285
1286                var slideHeight = activeSlide.querySelector('.gslide-inner-content').offsetHeight;
1287                var slideWidth = activeSlide.querySelector('.gslide-inner-content').offsetWidth;
1288
1289                // Swipe to top/bottom to close
1290                if (vSwipe) {
1291                    var onEnd = slideHeight / 2;
1292                    vSwipe = false;
1293                    if (Math.abs(vDistance) >= onEnd) {
1294                        _this4.close();
1295                        return;
1296                    }
1297                    resetSlideMove(activeSlide);
1298                    return;
1299                }
1300
1301                if (hSwipe) {
1302                    hSwipe = false;
1303                    var where = 'prev';
1304                    var asideExist = true;
1305                    if (hDistance < 0) {
1306                        where = 'next';
1307                        hDistance = Math.abs(hDistance);
1308                    }
1309                    if (where == 'prev' && _this4.index - 1 < 0) {
1310                        asideExist = false;
1311                    }
1312                    if (where == 'next' && _this4.index + 1 >= _this4.elements.length) {
1313                        asideExist = false;
1314                    }
1315                    if (asideExist && hDistance >= slideWidth / 2 - 90) {
1316                        if (where == 'next') {
1317                            _this4.nextSlide();
1318                        } else {
1319                            _this4.prevSlide();
1320                        }
1321                        return;
1322                    }
1323                    resetSlideMove(activeSlide);
1324                }
1325            }
1326        });
1327    }
1328
1329    function slideCSSTransform(slide) {
1330        var translate = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
1331
1332        if (translate == '') {
1333            slide.style.webkitTransform = '';
1334            slide.style.MozTransform = '';
1335            slide.style.msTransform = '';
1336            slide.style.OTransform = '';
1337            slide.style.transform = '';
1338            return false;
1339        }
1340        slide.style.webkitTransform = translate;
1341        slide.style.MozTransform = translate;
1342        slide.style.msTransform = translate;
1343        slide.style.OTransform = translate;
1344        slide.style.transform = translate;
1345    }
1346
1347    function resetSlideMove(slide) {
1348        var media = slide.querySelector('.gslide-media');
1349        var desc = slide.querySelector('.gslide-description');
1350
1351        addClass(media, 'greset');
1352        slideCSSTransform(media, 'translate3d(0, 0, 0)');
1353        var animation = addEvent(transitionEnd, {
1354            onElement: media,
1355            once: true,
1356            withCallback: function withCallback(event, target) {
1357                removeClass(media, 'greset');
1358            }
1359        });
1360
1361        media.style.opacity = '';
1362        if (desc) {
1363            desc.style.opacity = '';
1364        }
1365    }
1366
1367    function slideShortDesc(string) {
1368        var n = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 50;
1369        var wordBoundary = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
1370
1371        var useWordBoundary = wordBoundary;
1372        string = string.trim();
1373        if (string.length <= n) {
1374            return string;
1375        }
1376        var subString = string.substr(0, n - 1);
1377        if (!useWordBoundary) {
1378            return subString;
1379        }
1380        return subString + '... <a href="#" class="desc-more">' + wordBoundary + '</a>';
1381    }
1382
1383    function slideDescriptionEvents(desc, data) {
1384        var moreLink = desc.querySelector('.desc-more');
1385        if (!moreLink) {
1386            return false;
1387        }
1388
1389        addEvent('click', {
1390            onElement: moreLink,
1391            withCallback: function withCallback(event, target) {
1392                event.preventDefault();
1393                var desc = getClosest(target, '.gslide-desc');
1394                if (!desc) {
1395                    return false;
1396                }
1397
1398                desc.innerHTML = data.description;
1399                addClass(body, 'gdesc-open');
1400
1401                var shortEvent = addEvent('click', {
1402                    onElement: [body, getClosest(desc, '.gslide-description')],
1403                    withCallback: function withCallback(event, target) {
1404                        if (event.target.nodeName.toLowerCase() !== 'div') {
1405                            removeClass(body, 'gdesc-open');
1406                            addClass(body, 'gdesc-closed');
1407                            desc.innerHTML = data.smallDescription;
1408                            slideDescriptionEvents(desc, data);
1409
1410                            setTimeout(function () {
1411                                removeClass(body, 'gdesc-closed');
1412                            }, 400);
1413                            shortEvent.destroy();
1414                        }
1415                    }
1416                });
1417            }
1418        });
1419    }
1420
1421    /**
1422     * GLightbox Class
1423     * Class and public methods
1424     */
1425
1426    var GlightboxInit = function () {
1427        function GlightboxInit(options) {
1428            _classCallCheck(this, GlightboxInit);
1429
1430            this.settings = extend(defaults, options || {});
1431            this.effectsClasses = this.getAnimationClasses();
1432        }
1433
1434        _createClass(GlightboxInit, [{
1435            key: 'init',
1436            value: function init() {
1437                var _this5 = this;
1438
1439                this.baseEvents = addEvent('click', {
1440                    onElement: '.' + this.settings.selector,
1441                    withCallback: function withCallback(e, target) {
1442                        e.preventDefault();
1443                        _this5.open(target);
1444                    }
1445                });
1446            }
1447        }, {
1448            key: 'open',
1449            value: function open() {
1450                var element = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
1451
1452                this.elements = this.getElements(element);
1453                if (this.elements.length == 0) return false;
1454
1455                this.activeSlide = null;
1456                this.prevActiveSlideIndex = null;
1457                this.prevActiveSlide = null;
1458                var index = this.settings.startAt;
1459                if (element) {
1460                    // if element passed, get the index
1461                    index = this.elements.indexOf(element);
1462                    if (index < 0) {
1463                        index = 0;
1464                    }
1465                }
1466
1467                this.build();
1468                animateElement(this.overlay, this.settings.openEffect == 'none' ? 'none' : this.settings.cssEfects.fade.in);
1469
1470                var bodyWidth = body.offsetWidth;
1471                body.style.width = bodyWidth + 'px';
1472
1473                addClass(body, 'glightbox-open');
1474                addClass(html, 'glightbox-open');
1475                if (isMobile) {
1476                    addClass(html, 'glightbox-mobile');
1477                    this.settings.slideEffect = 'slide';
1478                }
1479
1480                this.showSlide(index, true);
1481
1482                if (this.elements.length == 1) {
1483                    hide(this.prevButton);
1484                    hide(this.nextButton);
1485                } else {
1486                    show(this.prevButton);
1487                    show(this.nextButton);
1488                }
1489                this.lightboxOpen = true;
1490
1491                if (utils.isFunction(this.settings.onOpen)) {
1492                    this.settings.onOpen();
1493                }
1494
1495                if (isMobile && isTouch && this.settings.touchNavigation) {
1496                    touchNavigation.apply(this);
1497                    return false;
1498                }
1499                if (this.settings.keyboardNavigation) {
1500                    keyboardNavigation.apply(this);
1501                }
1502            }
1503        }, {
1504            key: 'showSlide',
1505            value: function showSlide() {
1506                var _this6 = this;
1507
1508                var index = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
1509                var first = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
1510
1511                show(this.loader);
1512                this.index = index;
1513
1514                var current = this.slidesContainer.querySelector('.current');
1515                if (current) {
1516                    removeClass(current, 'current');
1517                }
1518
1519                // hide prev slide
1520                this.slideAnimateOut();
1521
1522                var slide = this.slidesContainer.querySelectorAll('.gslide')[index];
1523                show(this.slidesContainer);
1524
1525                // Check if slide's content is alreay loaded
1526                if (hasClass(slide, 'loaded')) {
1527                    this.slideAnimateIn(slide, first);
1528                    hide(this.loader);
1529                } else {
1530                    // If not loaded add the slide content
1531                    show(this.loader);
1532                    // console.log("a", this.settings);
1533                    var slide_data = getSlideData(this.elements[index], this.settings);
1534                    // console.log(slide_data);
1535                    slide_data.index = index;
1536                    setSlideContent.apply(this, [slide, slide_data, function () {
1537                        hide(_this6.loader);
1538                        _this6.slideAnimateIn(slide, first);
1539                    }]);
1540                }
1541
1542                // Preload subsequent slides
1543                this.preloadSlide(index + 1);
1544                this.preloadSlide(index - 1);
1545
1546                // Handle navigation arrows
1547                removeClass(this.nextButton, 'disabled');
1548                removeClass(this.prevButton, 'disabled');
1549                if (index === 0) {
1550                    addClass(this.prevButton, 'disabled');
1551                } else if (index === this.elements.length - 1 && this.settings.loopAtEnd !== true) {
1552                    addClass(this.nextButton, 'disabled');
1553                }
1554                this.activeSlide = slide;
1555            }
1556        }, {
1557            key: 'preloadSlide',
1558            value: function preloadSlide(index) {
1559                var _this7 = this;
1560
1561                // Verify slide index, it can not be lower than 0
1562                // and it can not be greater than the total elements
1563                if (index < 0 || index > this.elements.length) return false;
1564
1565                if (utils.isNil(this.elements[index])) return false;
1566
1567                var slide = this.slidesContainer.querySelectorAll('.gslide')[index];
1568                if (hasClass(slide, 'loaded')) {
1569                    return false;
1570                }
1571
1572                var slide_data = getSlideData(this.elements[index], this.settings);
1573                slide_data.index = index;
1574                var type = slide_data.sourcetype;
1575                if (type == 'video' || type == 'external') {
1576                    setTimeout(function () {
1577                        setSlideContent.apply(_this7, [slide, slide_data]);
1578                    }, 200);
1579                } else {
1580                    setSlideContent.apply(this, [slide, slide_data]);
1581                }
1582            }
1583        }, {
1584            key: 'prevSlide',
1585            value: function prevSlide() {
1586                var prev = this.index - 1;
1587                if (prev < 0) {
1588                    return false;
1589                }
1590                this.goToSlide(prev);
1591            }
1592        }, {
1593            key: 'nextSlide',
1594            value: function nextSlide() {
1595                var next = this.index + 1;
1596                if (next > this.elements.length) return false;
1597
1598                this.goToSlide(next);
1599            }
1600        }, {
1601            key: 'goToSlide',
1602            value: function goToSlide() {
1603                var index = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
1604
1605                if (index > -1) {
1606                    this.prevActiveSlide = this.activeSlide;
1607                    this.prevActiveSlideIndex = this.index;
1608
1609                    if (index < this.elements.length) {
1610                        this.showSlide(index);
1611                    } else {
1612                        if (this.settings.loopAtEnd === true) {
1613                            index = 0;
1614                            this.showSlide(index);
1615                        }
1616                    }
1617                }
1618            }
1619        }, {
1620            key: 'slideAnimateIn',
1621            value: function slideAnimateIn(slide, first) {
1622                var _this8 = this;
1623
1624                var slideMedia = slide.querySelector('.gslide-media');
1625                var slideDesc = slide.querySelector('.gslide-description');
1626                var prevData = {
1627                    index: this.prevActiveSlideIndex,
1628                    slide: this.prevActiveSlide
1629                };
1630                var nextData = {
1631                    index: this.index,
1632                    slide: this.activeSlide
1633                };
1634                if (slideMedia.offsetWidth > 0 && slideDesc) {
1635                    hide(slideDesc);
1636                    slide.querySelector('.ginner-container').style.maxWidth = slideMedia.offsetWidth + 'px';
1637                    slideDesc.style.display = '';
1638                }
1639                removeClass(slide, this.effectsClasses);
1640                if (first) {
1641                    animateElement(slide, this.settings.openEffect, function () {
1642                        if (!isMobile && _this8.settings.autoplayVideos) {
1643                            _this8.playSlideVideo(slide);
1644                        }
1645                        if (utils.isFunction(_this8.settings.afterSlideChange)) {
1646                            _this8.settings.afterSlideChange.apply(_this8, [prevData, nextData]);
1647                        }
1648                    });
1649                } else {
1650                    var effect_name = this.settings.slideEffect;
1651                    var animIn = effect_name !== 'none' ? this.settings.cssEfects[effect_name].in : effect_name;
1652                    if (this.prevActiveSlideIndex > this.index) {
1653                        if (this.settings.slideEffect == 'slide') {
1654                            animIn = this.settings.cssEfects.slide_back.in;
1655                        }
1656                    }
1657                    animateElement(slide, animIn, function () {
1658                        if (!isMobile && _this8.settings.autoplayVideos) {
1659                            _this8.playSlideVideo(slide);
1660                        }
1661                        if (utils.isFunction(_this8.settings.afterSlideChange)) {
1662                            _this8.settings.afterSlideChange.apply(_this8, [prevData, nextData]);
1663                        }
1664                    });
1665                }
1666                addClass(slide, 'current');
1667            }
1668        }, {
1669            key: 'slideAnimateOut',
1670            value: function slideAnimateOut() {
1671                if (!this.prevActiveSlide) {
1672                    return false;
1673                }
1674
1675                var prevSlide = this.prevActiveSlide;
1676                removeClass(prevSlide, this.effectsClasses);
1677                addClass(prevSlide, 'prev');
1678
1679                var animation = this.settings.slideEffect;
1680                var animOut = animation !== 'none' ? this.settings.cssEfects[animation].out : animation;
1681
1682                this.stopSlideVideo(prevSlide);
1683                if (utils.isFunction(this.settings.beforeSlideChange)) {
1684                    this.settings.beforeSlideChange.apply(this, [{
1685                        index: this.prevActiveSlideIndex,
1686                        slide: this.prevActiveSlide
1687                    }, {
1688                        index: this.index,
1689                        slide: this.activeSlide
1690                    }]);
1691                }
1692                if (this.prevActiveSlideIndex > this.index && this.settings.slideEffect == 'slide') {
1693                    // going back
1694                    animOut = this.settings.cssEfects.slide_back.out;
1695                }
1696                animateElement(prevSlide, animOut, function () {
1697                    var media = prevSlide.querySelector('.gslide-media');
1698                    var desc = prevSlide.querySelector('.gslide-description');
1699
1700                    media.style.transform = '';
1701                    removeClass(media, 'greset');
1702                    media.style.opacity = '';
1703                    if (desc) {
1704                        desc.style.opacity = '';
1705                    }
1706                    removeClass(prevSlide, 'prev');
1707                });
1708            }
1709        }, {
1710            key: 'stopSlideVideo',
1711            value: function stopSlideVideo(slide) {
1712                if (utils.isNumber(slide)) {
1713                    slide = this.slidesContainer.querySelectorAll('.gslide')[slide];
1714                }
1715
1716                var slideVideo = slide ? slide.querySelector('.gvideo') : null;
1717                if (!slideVideo) {
1718                    return false;
1719                }
1720
1721                var videoID = slideVideo.id;
1722                if (videoPlayers && videoPlayers.hasOwnProperty(videoID)) {
1723                    var player = videoPlayers[videoID];
1724                    if (hasClass(slideVideo, 'vimeo-video')) {
1725                        player.pause();
1726                    }
1727                    if (hasClass(slideVideo, 'youtube-video')) {
1728                        player.pauseVideo();
1729                    }
1730                    if (hasClass(slideVideo, 'jw-video')) {
1731                        player.pause(true);
1732                    }
1733                    if (hasClass(slideVideo, 'html5-video')) {
1734                        player.pause();
1735                    }
1736                }
1737            }
1738        }, {
1739            key: 'playSlideVideo',
1740            value: function playSlideVideo(slide) {
1741                if (utils.isNumber(slide)) {
1742                    slide = this.slidesContainer.querySelectorAll('.gslide')[slide];
1743                }
1744                var slideVideo = slide.querySelector('.gvideo');
1745                if (!slideVideo) {
1746                    return false;
1747                }
1748
1749                var videoID = slideVideo.id;
1750                if (videoPlayers && videoPlayers.hasOwnProperty(videoID)) {
1751                    var player = videoPlayers[videoID];
1752                    if (hasClass(slideVideo, 'vimeo-video')) {
1753                        player.play();
1754                    }
1755                    if (hasClass(slideVideo, 'youtube-video')) {
1756                        player.playVideo();
1757                    }
1758                    if (hasClass(slideVideo, 'jw-video')) {
1759                        player.play();
1760                    }
1761                    if (hasClass(slideVideo, 'html5-video')) {
1762                        player.play();
1763                    }
1764                    setTimeout(function () {
1765                        removeClass(slideVideo, 'wait-autoplay');
1766                    }, 300);
1767                    return false;
1768             
1768   }
1769            }
1770        }, {
1771            key: 'setElements',
1772            value: function setElements(elements) {
1773                this.settings.elements = elements;
1774            }
1775        }, {
1776            key: 'getElements',
1777            value: function getElements() {
1778                var element = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
1779
1780                this.elements = [];
1781
1782                if (!utils.isNil(this.settings.elements) && utils.isArray(this.settings.elements)) {
1783                    return this.settings.elements;
1784                }
1785
1786                var nodes = false;
1787                if (element !== null) {
1788                    var gallery = element.getAttribute('data-gallery');
1789                    if (gallery && gallery !== '') {
1790                        nodes = document.querySelectorAll('[data-gallery="' + gallery + '"]');
1791                    }
1792                }
1793                if (nodes == false) {
1794                    nodes = document.querySelectorAll('.' + this.settings.selector);
1795                }
1796                nodes = Array.prototype.slice.call(nodes);
1797                return nodes;
1798            }
1799        }, {
1800            key: 'getActiveSlide',
1801            value: function getActiveSlide() {
1802                return this.slidesContainer.querySelectorAll('.gslide')[this.index];
1803            }
1804        }, {
1805            key: 'getActiveSlideIndex',
1806            value: function getActiveSlideIndex() {
1807                return this.index;
1808            }
1809        }, {
1810            key: 'getAnimationClasses',
1811            value: function getAnimationClasses() {
1812                var effects = [];
1813                for (var key in this.settings.cssEfects) {
1814                    if (this.settings.cssEfects.hasOwnProperty(key)) {
1815                        var effect = this.settings.cssEfects[key];
1816                        effects.push('g' + effect.in);
1817                        effects.push('g' + effect.out);
1818                    }
1819                }
1820                return effects.join(' ');
1821            }
1822        }, {
1823            key: 'build',
1824            value: function build() {
1825                var _this9 = this;
1826
1827                if (this.built) {
1828                    return false;
1829                }
1830
1831                var lightbox_html = createHTML(this.settings.lightboxHtml);
1832                document.body.appendChild(lightbox_html);
1833
1834                var modal = document.getElementById('glightbox-body');
1835                this.modal = modal;
1836                var closeButton = modal.querySelector('.gclose');
1837                this.prevButton = modal.querySelector('.gprev');
1838                this.nextButton = modal.querySelector('.gnext');
1839                this.overlay = modal.querySelector('.goverlay');
1840                this.loader = modal.querySelector('.gloader');
1841                this.slidesContainer = document.getElementById('glightbox-slider');
1842                this.events = {};
1843
1844                addClass(this.modal, 'glightbox-' + this.settings.skin);
1845
1846                if (this.settings.closeButton && closeButton) {
1847                    this.events['close'] = addEvent('click', {
1848                        onElement: closeButton,
1849                        withCallback: function withCallback(e, target) {
1850                            e.preventDefault();
1851                            _this9.close();
1852                        }
1853                    });
1854                }
1855                if (closeButton && !this.settings.closeButton) {
1856                    closeButton.parentNode.removeChild(closeButton);
1857                }
1858
1859                if (this.nextButton) {
1860                    this.events['next'] = addEvent('click', {
1861                        onElement: this.nextButton,
1862                        withCallback: function withCallback(e, target) {
1863                            e.preventDefault();
1864                            _this9.nextSlide();
1865                        }
1866                    });
1867                }
1868
1869                if (this.prevButton) {
1870                    this.events['prev'] = addEvent('click', {
1871                        onElement: this.prevButton,
1872                        withCallback: function withCallback(e, target) {
1873                            e.preventDefault();
1874                            _this9.prevSlide();
1875                        }
1876                    });
1877                }
1878                if (this.settings.closeOnOutsideClick) {
1879                    this.events['outClose'] = addEvent('click', {
1880                        onElement: modal,
1881                        withCallback: function withCallback(e, target) {
1882                            if (!getClosest(e.target, '.ginner-container')) {
1883                                if (!hasClass(e.target, 'gnext') && !hasClass(e.target, 'gprev')) {
1884                                    _this9.close();
1885                                }
1886                            }
1887                        }
1888                    });
1889                }
1890                each(this.elements, function () {
1891                    var slide = createHTML(_this9.settings.slideHtml);
1892                    _this9.slidesContainer.appendChild(slide);
1893                });
1894                if (isTouch) {
1895                    addClass(html, 'glightbox-touch');
1896                }
1897
1898                this.built = true;
1899            }
1900        }, {
1901            key: 'reload',
1902            value: function reload() {
1903                this.init();
1904            }
1905        }, {
1906            key: 'close',
1907            value: function close() {
1908                var _this10 = this;
1909
1910                if (this.closing) {
1911                    return false;
1912                }
1913                this.closing = true;
1914                this.stopSlideVideo(this.activeSlide);
1915                addClass(this.modal, 'glightbox-closing');
1916                animateElement(this.overlay, this.settings.openEffect == 'none' ? 'none' : this.settings.cssEfects.fade.out);
1917                animateElement(this.activeSlide, this.settings.closeEffect, function () {
1918                    _this10.activeSlide = null;
1919                    _this10.prevActiveSlideIndex = null;
1920                    _this10.prevActiveSlide = null;
1921                    _this10.built = false;
1922
1923                    if (_this10.events) {
1924                        for (var key in _this10.events) {
1925                            if (_this10.events.hasOwnProperty(key)) {
1926                                _this10.events[key].destroy();
1927                            }
1928                        }
1929                    }
1930
1931                    removeClass(body, 'glightbox-open');
1932                    removeClass(html, 'glightbox-open');
1933                    removeClass(body, 'touching');
1934                    removeClass(body, 'gdesc-open');
1935                    body.style.width = '';
1936                    _this10.modal.parentNode.removeChild(_this10.modal);
1937                    if (utils.isFunction(_this10.settings.onClose)) {
1938                        _this10.settings.onClose();
1939                    }
1940                    _this10.closing = null;
1941                });
1942            }
1943        }, {
1944            key: 'destroy',
1945            value: function destroy() {
1946                this.close();
1947                this.baseEvents.destroy();
1948            }
1949        }]);
1950
1951        return GlightboxInit;
1952    }();
1953
1954    module.exports = function () {
1955        var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1956
1957        var instance = new GlightboxInit(options);
1958        instance.init();
1959
1960        return instance;
1961    };
1962});

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.