PluginProbe ʕ •ᴥ•ʔ
Responsive Lightbox & Gallery / 2.7.7
Responsive Lightbox & Gallery v2.7.7
2.7.8 trunk 1.0.0 1.0.1 1.0.1.1 1.0.2 1.0.3 1.0.4 1.1.0 1.1.1 1.1.2 1.2.0 1.2.1 1.2.2 1.2.3 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 1.4.0 1.4.0.1 1.4.1 1.4.11 1.4.12 1.4.13 1.4.14 1.4.2 1.4.3 1.4.4 1.4.5 1.4.6 1.4.7 1.4.8 1.4.9 1.5.0 1.5.1 1.5.2 1.5.3 1.5.4 1.5.5 1.5.6 1.5.7 1.6.0 1.6.1 1.6.10 1.6.11 1.6.12 1.6.2 1.6.3 1.6.4 1.6.5 1.6.6 1.6.7 1.6.8 1.6.9 1.7.0 1.7.1 1.7.2 2.0 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 2.1 2.2.0 2.2.1 2.2.2 2.2.3 2.2.3.1 2.3.0 2.3.1 2.3.2 2.3.3 2.3.4 2.3.5 2.4.0 2.4.1 2.4.2 2.4.3 2.4.4 2.4.5 2.4.6 2.4.7 2.4.8 2.4.9 2.5.0 2.5.1 2.5.2 2.5.3 2.5.4 2.5.5 2.6.0 2.6.1 2.7.0 2.7.1 2.7.2 2.7.3 2.7.4 2.7.5 2.7.6 2.7.7
responsive-lightbox / assets / glightbox / glightbox.js
responsive-lightbox / assets / glightbox Last commit date
glightbox.css 6 months ago glightbox.js 6 months ago glightbox.min.css 6 months ago glightbox.min.js 6 months ago
glightbox.js
3562 lines
1 (function (global, factory) {
2 typeof exports === 'object' && typeof module !== 'undefined'
3 ? (module.exports = factory())
4 : typeof define === 'function' && define.amd
5 ? define(factory)
6 : ((global = global || self), (global.GLightbox = factory()));
7 })(this, function () {
8 'use strict';
9
10 function _classCallCheck(a, n) {
11 if (!(a instanceof n)) throw new TypeError('Cannot call a class as a function');
12 }
13 function _defineProperties(e, r) {
14 for (var t = 0; t < r.length; t++) {
15 var o = r[t];
16 ((o.enumerable = o.enumerable || !1),
17 (o.configurable = !0),
18 'value' in o && (o.writable = !0),
19 Object.defineProperty(e, _toPropertyKey(o.key), o));
20 }
21 }
22 function _createClass(e, r, t) {
23 return (
24 r && _defineProperties(e.prototype, r),
25 t && _defineProperties(e, t),
26 Object.defineProperty(e, 'prototype', {
27 writable: !1,
28 }),
29 e
30 );
31 }
32 function _toPrimitive(t, r) {
33 if ('object' != typeof t || !t) return t;
34 var e = t[Symbol.toPrimitive];
35 if (void 0 !== e) {
36 var i = e.call(t, r || 'default');
37 if ('object' != typeof i) return i;
38 throw new TypeError('@@toPrimitive must return a primitive value.');
39 }
40 return ('string' === r ? String : Number)(t);
41 }
42 function _toPropertyKey(t) {
43 var i = _toPrimitive(t, 'string');
44 return 'symbol' == typeof i ? i : i + '';
45 }
46 function _typeof(o) {
47 '@babel/helpers - typeof';
48
49 return (
50 (_typeof =
51 'function' == typeof Symbol && 'symbol' == typeof Symbol.iterator
52 ? function (o) {
53 return typeof o;
54 }
55 : function (o) {
56 return o &&
57 'function' == typeof Symbol &&
58 o.constructor === Symbol &&
59 o !== Symbol.prototype
60 ? 'symbol'
61 : typeof o;
62 }),
63 _typeof(o)
64 );
65 }
66
67 var uid = Date.now();
68 function extend() {
69 var extended = {};
70 var deep = true;
71 var i = 0;
72 var length = arguments.length;
73 if (Object.prototype.toString.call(arguments[0]) === '[object Boolean]') {
74 deep = arguments[0];
75 i++;
76 }
77 var merge = function merge(obj) {
78 for (var prop in obj) {
79 if (Object.prototype.hasOwnProperty.call(obj, prop)) {
80 if (deep && Object.prototype.toString.call(obj[prop]) === '[object Object]') {
81 extended[prop] = extend(true, extended[prop], obj[prop]);
82 } else {
83 extended[prop] = obj[prop];
84 }
85 }
86 }
87 };
88 for (; i < length; i++) {
89 var obj = arguments[i];
90 merge(obj);
91 }
92 return extended;
93 }
94 function each(collection, callback) {
95 if (isNode(collection) || collection === window || collection === document) {
96 collection = [collection];
97 }
98 if (!isArrayLike(collection) && !isObject(collection)) {
99 collection = [collection];
100 }
101 if (size(collection) == 0) {
102 return;
103 }
104 if (isArrayLike(collection) && !isObject(collection)) {
105 var l = collection.length,
106 i = 0;
107 for (; i < l; i++) {
108 if (callback.call(collection[i], collection[i], i, collection) === false) {
109 break;
110 }
111 }
112 } else if (isObject(collection)) {
113 for (var key in collection) {
114 if (has(collection, key)) {
115 if (
116 callback.call(collection[key], collection[key], key, collection) === false
117 ) {
118 break;
119 }
120 }
121 }
122 }
123 }
124 function getNodeEvents(node) {
125 var name = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
126 var fn = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
127 var cache = (node[uid] = node[uid] || []);
128 var data = {
129 all: cache,
130 evt: null,
131 found: null,
132 };
133 if (name && fn && size(cache) > 0) {
134 each(cache, function (cl, i) {
135 if (cl.eventName == name && cl.fn.toString() == fn.toString()) {
136 data.found = true;
137 data.evt = i;
138 return false;
139 }
140 });
141 }
142 return data;
143 }
144 function addEvent(eventName) {
145 var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
146 onElement = _ref.onElement,
147 withCallback = _ref.withCallback,
148 _ref$avoidDuplicate = _ref.avoidDuplicate,
149 avoidDuplicate = _ref$avoidDuplicate === void 0 ? true : _ref$avoidDuplicate,
150 _ref$once = _ref.once,
151 once = _ref$once === void 0 ? false : _ref$once,
152 _ref$useCapture = _ref.useCapture,
153 useCapture = _ref$useCapture === void 0 ? false : _ref$useCapture;
154 var thisArg = arguments.length > 2 ? arguments[2] : undefined;
155 var element = onElement || [];
156 if (isString(element)) {
157 element = document.querySelectorAll(element);
158 }
159 function handler(event) {
160 if (isFunction(withCallback)) {
161 withCallback.call(thisArg, event, this);
162 }
163 if (once) {
164 handler.destroy();
165 }
166 }
167 handler.destroy = function () {
168 each(element, function (el) {
169 var events = getNodeEvents(el, eventName, handler);
170 if (events.found) {
171 events.all.splice(events.evt, 1);
172 }
173 if (el.removeEventListener) {
174 el.removeEventListener(eventName, handler, useCapture);
175 }
176 });
177 };
178 each(element, function (el) {
179 var events = getNodeEvents(el, eventName, handler);
180 if ((el.addEventListener && avoidDuplicate && !events.found) || !avoidDuplicate) {
181 el.addEventListener(eventName, handler, useCapture);
182 events.all.push({
183 eventName: eventName,
184 fn: handler,
185 });
186 }
187 });
188 return handler;
189 }
190 function addClass(node, name) {
191 each(name.split(' '), function (cl) {
192 return node.classList.add(cl);
193 });
194 }
195 function removeClass(node, name) {
196 each(name.split(' '), function (cl) {
197 return node.classList.remove(cl);
198 });
199 }
200 function hasClass(node, name) {
201 return node.classList.contains(name);
202 }
203 function closest(elem, selector) {
204 while (elem !== document.body) {
205 elem = elem.parentElement;
206 if (!elem) {
207 return false;
208 }
209 var matches =
210 typeof elem.matches == 'function'
211 ? elem.matches(selector)
212 : elem.msMatchesSelector(selector);
213 if (matches) {
214 return elem;
215 }
216 }
217 }
218 function animateElement(element) {
219 var animation = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
220 var callback = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
221 if (!element || animation === '') {
222 return false;
223 }
224 if (animation === 'none') {
225 if (isFunction(callback)) {
226 callback();
227 }
228 return false;
229 }
230 var animationEnd = whichAnimationEvent();
231 var animationNames = animation.split(' ');
232 each(animationNames, function (name) {
233 addClass(element, 'g' + name);
234 });
235 addEvent(animationEnd, {
236 onElement: element,
237 avoidDuplicate: false,
238 once: true,
239 withCallback: function withCallback(event, target) {
240 each(animationNames, function (name) {
241 removeClass(target, 'g' + name);
242 });
243 if (isFunction(callback)) {
244 callback();
245 }
246 },
247 });
248 }
249 function cssTransform(node) {
250 var translate = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
251 if (translate === '') {
252 node.style.webkitTransform = '';
253 node.style.MozTransform = '';
254 node.style.msTransform = '';
255 node.style.OTransform = '';
256 node.style.transform = '';
257 return false;
258 }
259 node.style.webkitTransform = translate;
260 node.style.MozTransform = translate;
261 node.style.msTransform = translate;
262 node.style.OTransform = translate;
263 node.style.transform = translate;
264 }
265 function show(element) {
266 element.style.display = 'block';
267 }
268 function hide(element) {
269 element.style.display = 'none';
270 }
271 function createHTML(htmlStr) {
272 var frag = document.createDocumentFragment(),
273 temp = document.createElement('div');
274 temp.innerHTML = htmlStr;
275 while (temp.firstChild) {
276 frag.appendChild(temp.firstChild);
277 }
278 return frag;
279 }
280 function windowSize() {
281 return {
282 width:
283 window.innerWidth ||
284 document.documentElement.clientWidth ||
285 document.body.clientWidth,
286 height:
287 window.innerHeight ||
288 document.documentElement.clientHeight ||
289 document.body.clientHeight,
290 };
291 }
292 function whichAnimationEvent() {
293 var t,
294 el = document.createElement('fakeelement');
295 var animations = {
296 animation: 'animationend',
297 OAnimation: 'oAnimationEnd',
298 MozAnimation: 'animationend',
299 WebkitAnimation: 'webkitAnimationEnd',
300 };
301 for (t in animations) {
302 if (el.style[t] !== undefined) {
303 return animations[t];
304 }
305 }
306 }
307 function whichTransitionEvent() {
308 var t,
309 el = document.createElement('fakeelement');
310 var transitions = {
311 transition: 'transitionend',
312 OTransition: 'oTransitionEnd',
313 MozTransition: 'transitionend',
314 WebkitTransition: 'webkitTransitionEnd',
315 };
316 for (t in transitions) {
317 if (el.style[t] !== undefined) {
318 return transitions[t];
319 }
320 }
321 }
322 function createIframe(config) {
323 var url = config.url,
324 allow = config.allow,
325 callback = config.callback,
326 appendTo = config.appendTo;
327 var iframe = document.createElement('iframe');
328 iframe.className = 'vimeo-video gvideo';
329 iframe.src = url;
330 iframe.style.width = '100%';
331 iframe.style.height = '100%';
332 if (allow) {
333 iframe.setAttribute('allow', allow);
334 }
335 iframe.onload = function () {
336 iframe.onload = null;
337 addClass(iframe, 'node-ready');
338 if (isFunction(callback)) {
339 callback();
340 }
341 };
342 if (appendTo) {
343 appendTo.appendChild(iframe);
344 }
345 return iframe;
346 }
347 function waitUntil(check, onComplete, delay, timeout) {
348 if (check()) {
349 onComplete();
350 return;
351 }
352 if (!delay) {
353 delay = 100;
354 }
355 var timeoutPointer;
356 var intervalPointer = setInterval(function () {
357 if (!check()) {
358 return;
359 }
360 clearInterval(intervalPointer);
361 if (timeoutPointer) {
362 clearTimeout(timeoutPointer);
363 }
364 onComplete();
365 }, delay);
366 if (timeout) {
367 timeoutPointer = setTimeout(function () {
368 clearInterval(intervalPointer);
369 }, timeout);
370 }
371 }
372 function injectAssets(url, waitFor, callback) {
373 if (isNil(url)) {
374 console.error('Inject assets error');
375 return;
376 }
377 if (isFunction(waitFor)) {
378 callback = waitFor;
379 waitFor = false;
380 }
381 if (isString(waitFor) && waitFor in window) {
382 if (isFunction(callback)) {
383 callback();
384 }
385 return;
386 }
387 var found;
388 if (url.indexOf('.css') !== -1) {
389 found = document.querySelectorAll('link[href="' + url + '"]');
390 if (found && found.length > 0) {
391 if (isFunction(callback)) {
392 callback();
393 }
394 return;
395 }
396 var head = document.getElementsByTagName('head')[0];
397 var headStyles = head.querySelectorAll('link[rel="stylesheet"]');
398 var link = document.createElement('link');
399 link.rel = 'stylesheet';
400 link.type = 'text/css';
401 link.href = url;
402 link.media = 'all';
403 if (headStyles) {
404 head.insertBefore(link, headStyles[0]);
405 } else {
406 head.appendChild(link);
407 }
408 if (isFunction(callback)) {
409 callback();
410 }
411 return;
412 }
413 found = document.querySelectorAll('script[src="' + url + '"]');
414 if (found && found.length > 0) {
415 if (isFunction(callback)) {
416 if (isString(waitFor)) {
417 waitUntil(
418 function () {
419 return typeof window[waitFor] !== 'undefined';
420 },
421 function () {
422 callback();
423 }
424 );
425 return false;
426 }
427 callback();
428 }
429 return;
430 }
431 var script = document.createElement('script');
432 script.type = 'text/javascript';
433 script.src = url;
434 script.onload = function () {
435 if (isFunction(callback)) {
436 if (isString(waitFor)) {
437 waitUntil(
438 function () {
439 return typeof window[waitFor] !== 'undefined';
440 },
441 function () {
442 callback();
443 }
444 );
445 return false;
446 }
447 callback();
448 }
449 };
450 document.body.appendChild(script);
451 }
452 function isMobile() {
453 return (
454 'navigator' in window &&
455 window.navigator.userAgent.match(
456 /(iPad)|(iPhone)|(iPod)|(Android)|(PlayBook)|(BB10)|(BlackBerry)|(Opera Mini)|(IEMobile)|(webOS)|(MeeGo)/i
457 )
458 );
459 }
460 function isTouch() {
461 return (
462 isMobile() !== null ||
463 document.createTouch !== undefined ||
464 'ontouchstart' in window ||
465 'onmsgesturechange' in window ||
466 navigator.msMaxTouchPoints
467 );
468 }
469 function isFunction(f) {
470 return typeof f === 'function';
471 }
472 function isString(s) {
473 return typeof s === 'string';
474 }
475 function isNode(el) {
476 return !!(el && el.nodeType && el.nodeType == 1);
477 }
478 function isArray(ar) {
479 return Array.isArray(ar);
480 }
481 function isArrayLike(ar) {
482 return ar && ar.length && isFinite(ar.length);
483 }
484 function isObject(o) {
485 var type = _typeof(o);
486 return type === 'object' && o != null && !isFunction(o) && !isArray(o);
487 }
488 function isNil(o) {
489 return o == null;
490 }
491 function has(obj, key) {
492 return obj !== null && hasOwnProperty.call(obj, key);
493 }
494 function size(o) {
495 if (isObject(o)) {
496 if (o.keys) {
497 return o.keys().length;
498 }
499 var l = 0;
500 for (var k in o) {
501 if (has(o, k)) {
502 l++;
503 }
504 }
505 return l;
506 } else {
507 return o.length;
508 }
509 }
510 function isNumber(n) {
511 return !isNaN(parseFloat(n)) && isFinite(n);
512 }
513
514 function getNextFocusElement() {
515 var current = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : -1;
516 var btns = document.querySelectorAll('.gbtn[data-taborder]:not(.disabled)');
517 if (!btns.length) {
518 return false;
519 }
520 if (btns.length == 1) {
521 return btns[0];
522 }
523 if (typeof current == 'string') {
524 current = parseInt(current);
525 }
526 var orders = [];
527 each(btns, function (btn) {
528 orders.push(btn.getAttribute('data-taborder'));
529 });
530 var highestOrder = Math.max.apply(
531 Math,
532 orders.map(function (order) {
533 return parseInt(order);
534 })
535 );
536 var newIndex = current < 0 ? 1 : current + 1;
537 if (newIndex > highestOrder) {
538 newIndex = '1';
539 }
540 var nextOrders = orders.filter(function (el) {
541 return el >= parseInt(newIndex);
542 });
543 var nextFocus = nextOrders.sort()[0];
544 return document.querySelector('.gbtn[data-taborder="'.concat(nextFocus, '"]'));
545 }
546 function keyboardNavigation(instance) {
547 if (instance.events.hasOwnProperty('keyboard')) {
548 return false;
549 }
550 instance.events['keyboard'] = addEvent('keydown', {
551 onElement: window,
552 withCallback: function withCallback(event, target) {
553 event = event || window.event;
554 var key = event.keyCode;
555 if (key == 9) {
556 var focusedButton = document.querySelector('.gbtn.focused');
557 if (!focusedButton) {
558 var activeElement =
559 document.activeElement && document.activeElement.nodeName
560 ? document.activeElement.nodeName.toLocaleLowerCase()
561 : false;
562 if (
563 activeElement == 'input' ||
564 activeElement == 'textarea' ||
565 activeElement == 'button'
566 ) {
567 return;
568 }
569 }
570 event.preventDefault();
571 var btns = document.querySelectorAll('.gbtn[data-taborder]');
572 if (!btns || btns.length <= 0) {
573 return;
574 }
575 if (!focusedButton) {
576 var first = getNextFocusElement();
577 if (first) {
578 first.focus();
579 addClass(first, 'focused');
580 }
581 return;
582 }
583 var currentFocusOrder = focusedButton.getAttribute('data-taborder');
584 var nextFocus = getNextFocusElement(currentFocusOrder);
585 removeClass(focusedButton, 'focused');
586 if (nextFocus) {
587 nextFocus.focus();
588 addClass(nextFocus, 'focused');
589 }
590 }
591 if (key == 39) {
592 instance.nextSlide();
593 }
594 if (key == 37) {
595 instance.prevSlide();
596 }
597 if (key == 27) {
598 instance.close();
599 }
600 },
601 });
602 }
603
604 var ZoomImages = (function () {
605 function ZoomImages(el, slide) {
606 var _this = this;
607 var onclose = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
608 _classCallCheck(this, ZoomImages);
609 this.img = el;
610 this.slide = slide;
611 this.onclose = onclose;
612 if (this.img.setZoomEvents) {
613 return false;
614 }
615 this.active = false;
616 this.zoomedIn = false;
617 this.dragging = false;
618 this.currentX = null;
619 this.currentY = null;
620 this.initialX = null;
621 this.initialY = null;
622 this.xOffset = 0;
623 this.yOffset = 0;
624 this.img.addEventListener(
625 'mousedown',
626 function (e) {
627 return _this.dragStart(e);
628 },
629 false
630 );
631 this.img.addEventListener(
632 'mouseup',
633 function (e) {
634 return _this.dragEnd(e);
635 },
636 false
637 );
638 this.img.addEventListener(
639 'mousemove',
640 function (e) {
641 return _this.drag(e);
642 },
643 false
644 );
645 this.img.addEventListener(
646 'click',
647 function (e) {
648 if (_this.slide.classList.contains('dragging-nav')) {
649 _this.zoomOut();
650 return false;
651 }
652 if (!_this.zoomedIn) {
653 return _this.zoomIn();
654 }
655 if (_this.zoomedIn && !_this.dragging) {
656 _this.zoomOut();
657 }
658 },
659 false
660 );
661 this.img.setZoomEvents = true;
662 }
663 return _createClass(ZoomImages, [
664 {
665 key: 'zoomIn',
666 value: function zoomIn() {
667 var winWidth = this.widowWidth();
668 if (this.zoomedIn || winWidth <= 768) {
669 return;
670 }
671 var img = this.img;
672 img.setAttribute('data-style', img.getAttribute('style'));
673 img.style.maxWidth = img.naturalWidth + 'px';
674 img.style.maxHeight = img.naturalHeight + 'px';
675 if (img.naturalWidth > winWidth) {
676 var centerX = winWidth / 2 - img.naturalWidth / 2;
677 this.setTranslate(this.img.parentNode, centerX, 0);
678 }
679 this.slide.classList.add('zoomed');
680 this.zoomedIn = true;
681 },
682 },
683 {
684 key: 'zoomOut',
685 value: function zoomOut() {
686 this.img.parentNode.setAttribute('style', '');
687 this.img.setAttribute('style', this.img.getAttribute('data-style'));
688 this.slide.classList.remove('zoomed');
689 this.zoomedIn = false;
690 this.currentX = null;
691 this.currentY = null;
692 this.initialX = null;
693 this.initialY = null;
694 this.xOffset = 0;
695 this.yOffset = 0;
696 if (this.onclose && typeof this.onclose == 'function') {
697 this.onclose();
698 }
699 },
700 },
701 {
702 key: 'dragStart',
703 value: function dragStart(e) {
704 e.preventDefault();
705 if (!this.zoomedIn) {
706 this.active = false;
707 return;
708 }
709 if (e.type === 'touchstart') {
710 this.initialX = e.touches[0].clientX - this.xOffset;
711 this.initialY = e.touches[0].clientY - this.yOffset;
712 } else {
713 this.initialX = e.clientX - this.xOffset;
714 this.initialY = e.clientY - this.yOffset;
715 }
716 if (e.target === this.img) {
717 this.active = true;
718 this.img.classList.add('dragging');
719 }
720 },
721 },
722 {
723 key: 'dragEnd',
724 value: function dragEnd(e) {
725 var _this2 = this;
726 e.preventDefault();
727 this.initialX = this.currentX;
728 this.initialY = this.currentY;
729 this.active = false;
730 setTimeout(function () {
731 _this2.dragging = false;
732 _this2.img.isDragging = false;
733 _this2.img.classList.remove('dragging');
734 }, 100);
735 },
736 },
737 {
738 key: 'drag',
739 value: function drag(e) {
740 if (this.active) {
741 e.preventDefault();
742 if (e.type === 'touchmove') {
743 this.currentX = e.touches[0].clientX - this.initialX;
744 this.currentY = e.touches[0].clientY - this.initialY;
745 } else {
746 this.currentX = e.clientX - this.initialX;
747 this.currentY = e.clientY - this.initialY;
748 }
749 this.xOffset = this.currentX;
750 this.yOffset = this.currentY;
751 this.img.isDragging = true;
752 this.dragging = true;
753 this.setTranslate(this.img, this.currentX, this.currentY);
754 }
755 },
756 },
757 {
758 key: 'onMove',
759 value: function onMove(e) {
760 if (!this.zoomedIn) {
761 return;
762 }
763 var xOffset = e.clientX - this.img.naturalWidth / 2;
764 var yOffset = e.clientY - this.img.naturalHeight / 2;
765 this.setTranslate(this.img, xOffset, yOffset);
766 },
767 },
768 {
769 key: 'setTranslate',
770 value: function setTranslate(node, xPos, yPos) {
771 node.style.transform = 'translate3d(' + xPos + 'px, ' + yPos + 'px, 0)';
772 },
773 },
774 {
775 key: 'widowWidth',
776 value: function widowWidth() {
777 return (
778 window.innerWidth ||
779 document.documentElement.clientWidth ||
780 document.body.clientWidth
781 );
782 },
783 },
784 ]);
785 })();
786
787 var DragSlides = (function () {
788 function DragSlides() {
789 var _this = this;
790 var config = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
791 _classCallCheck(this, DragSlides);
792 var dragEl = config.dragEl,
793 _config$toleranceX = config.toleranceX,
794 toleranceX = _config$toleranceX === void 0 ? 40 : _config$toleranceX,
795 _config$toleranceY = config.toleranceY,
796 toleranceY = _config$toleranceY === void 0 ? 65 : _config$toleranceY,
797 _config$slide = config.slide,
798 slide = _config$slide === void 0 ? null : _config$slide,
799 _config$instance = config.instance,
800 instance = _config$instance === void 0 ? null : _config$instance;
801 this.el = dragEl;
802 this.active = false;
803 this.dragging = false;
804 this.currentX = null;
805 this.currentY = null;
806 this.initialX = null;
807 this.initialY = null;
808 this.xOffset = 0;
809 this.yOffset = 0;
810 this.direction = null;
811 this.lastDirection = null;
812 this.toleranceX = toleranceX;
813 this.toleranceY = toleranceY;
814 this.toleranceReached = false;
815 this.dragContainer = this.el;
816 this.slide = slide;
817 this.instance = instance;
818 this.el.addEventListener(
819 'mousedown',
820 function (e) {
821 return _this.dragStart(e);
822 },
823 false
824 );
825 this.el.addEventListener(
826 'mouseup',
827 function (e) {
828 return _this.dragEnd(e);
829 },
830 false
831 );
832 this.el.addEventListener(
833 'mousemove',
834 function (e) {
835 return _this.drag(e);
836 },
837 false
838 );
839 }
840 return _createClass(DragSlides, [
841 {
842 key: 'dragStart',
843 value: function dragStart(e) {
844 if (this.slide.classList.contains('zoomed')) {
845 this.active = false;
846 return;
847 }
848 if (e.type === 'touchstart') {
849 this.initialX = e.touches[0].clientX - this.xOffset;
850 this.initialY = e.touches[0].clientY - this.yOffset;
851 } else {
852 this.initialX = e.clientX - this.xOffset;
853 this.initialY = e.clientY - this.yOffset;
854 }
855 var clicked = e.target.nodeName.toLowerCase();
856 var exludeClicks = ['input', 'select', 'textarea', 'button', 'a'];
857 if (
858 e.target.classList.contains('nodrag') ||
859 closest(e.target, '.nodrag') ||
860 exludeClicks.indexOf(clicked) !== -1
861 ) {
862 this.active = false;
863 return;
864 }
865 e.preventDefault();
866 if (
867 e.target === this.el ||
868 (clicked !== 'img' && closest(e.target, '.gslide-inline'))
869 ) {
870 this.active = true;
871 this.el.classList.add('dragging');
872 this.dragContainer = closest(e.target, '.ginner-container');
873 }
874 },
875 },
876 {
877 key: 'dragEnd',
878 value: function dragEnd(e) {
879 var _this2 = this;
880 e && e.preventDefault();
881 this.initialX = 0;
882 this.initialY = 0;
883 this.currentX = null;
884 this.currentY = null;
885 this.initialX = null;
886 this.initialY = null;
887 this.xOffset = 0;
888 this.yOffset = 0;
889 this.active = false;
890 if (this.doSlideChange) {
891 this.instance.preventOutsideClick = true;
892 this.doSlideChange == 'right' && this.instance.prevSlide();
893 this.doSlideChange == 'left' && this.instance.nextSlide();
894 }
895 if (this.doSlideClose) {
896 this.instance.close();
897 }
898 if (!this.toleranceReached) {
899 this.setTranslate(this.dragContainer, 0, 0, true);
900 }
901 setTimeout(function () {
902 _this2.instance.preventOutsideClick = false;
903 _this2.toleranceReached = false;
904 _this2.lastDirection = null;
905 _this2.dragging = false;
906 _this2.el.isDragging = false;
907 _this2.el.classList.remove('dragging');
908 _this2.slide.classList.remove('dragging-nav');
909 _this2.dragContainer.style.transform = '';
910 _this2.dragContainer.style.transition = '';
911 }, 100);
912 },
913 },
914 {
915 key: 'drag',
916 value: function drag(e) {
917 if (this.active) {
918 e.preventDefault();
919 this.slide.classList.add('dragging-nav');
920 if (e.type === 'touchmove') {
921 this.currentX = e.touches[0].clientX - this.initialX;
922 this.currentY = e.touches[0].clientY - this.initialY;
923 } else {
924 this.currentX = e.clientX - this.initialX;
925 this.currentY = e.clientY - this.initialY;
926 }
927 this.xOffset = this.currentX;
928 this.yOffset = this.currentY;
929 this.el.isDragging = true;
930 this.dragging = true;
931 this.doSlideChange = false;
932 this.doSlideClose = false;
933 var currentXInt = Math.abs(this.currentX);
934 var currentYInt = Math.abs(this.currentY);
935 if (
936 currentXInt > 0 &&
937 currentXInt >= Math.abs(this.currentY) &&
938 (!this.lastDirection || this.lastDirection == 'x')
939 ) {
940 this.yOffset = 0;
941 this.lastDirection = 'x';
942 this.setTranslate(this.dragContainer, this.currentX, 0);
943 var doChange = this.shouldChange();
944 if (!this.instance.settings.dragAutoSnap && doChange) {
945 this.doSlideChange = doChange;
946 }
947 if (this.instance.settings.dragAutoSnap && doChange) {
948 this.instance.preventOutsideClick = true;
949 this.toleranceReached = true;
950 this.active = false;
951 this.instance.preventOutsideClick = true;
952 this.dragEnd(null);
953 doChange == 'right' && this.instance.prevSlide();
954 doChange == 'left' && this.instance.nextSlide();
955 return;
956 }
957 }
958 if (
959 this.toleranceY > 0 &&
960 currentYInt > 0 &&
961 currentYInt >= currentXInt &&
962 (!this.lastDirection || this.lastDirection == 'y')
963 ) {
964 this.xOffset = 0;
965 this.lastDirection = 'y';
966 this.setTranslate(this.dragContainer, 0, this.currentY);
967 var doClose = this.shouldClose();
968 if (!this.instance.settings.dragAutoSnap && doClose) {
969 this.doSlideClose = true;
970 }
971 if (this.instance.settings.dragAutoSnap && doClose) {
972 this.instance.close();
973 }
974 return;
975 }
976 }
977 },
978 },
979 {
980 key: 'shouldChange',
981 value: function shouldChange() {
982 var doChange = false;
983 var currentXInt = Math.abs(this.currentX);
984 if (currentXInt >= this.toleranceX) {
985 var dragDir = this.currentX > 0 ? 'right' : 'left';
986 if (
987 (dragDir == 'left' && this.slide !== this.slide.parentNode.lastChild) ||
988 (dragDir == 'right' && this.slide !== this.slide.parentNode.firstChild)
989 ) {
990 doChange = dragDir;
991 }
992 }
993 return doChange;
994 },
995 },
996 {
997 key: 'shouldClose',
998 value: function shouldClose() {
999 var doClose = false;
1000 var currentYInt = Math.abs(this.currentY);
1001 if (currentYInt >= this.toleranceY) {
1002 doClose = true;
1003 }
1004 return doClose;
1005 },
1006 },
1007 {
1008 key: 'setTranslate',
1009 value: function setTranslate(node, xPos, yPos) {
1010 var animated =
1011 arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
1012 if (animated) {
1013 node.style.transition = 'all .2s ease';
1014 } else {
1015 node.style.transition = '';
1016 }
1017 node.style.transform = 'translate3d('
1018 .concat(xPos, 'px, ')
1019 .concat(yPos, 'px, 0)');
1020 },
1021 },
1022 ]);
1023 })();
1024
1025 function slideImage(slide, data, index, callback) {
1026 var slideMedia = slide.querySelector('.gslide-media');
1027 var img = new Image();
1028 var titleID = 'gSlideTitle_' + index;
1029 var textID = 'gSlideDesc_' + index;
1030 img.addEventListener(
1031 'load',
1032 function () {
1033 if (isFunction(callback)) {
1034 callback();
1035 }
1036 },
1037 false
1038 );
1039 img.src = data.href;
1040 if (data.sizes != '' && data.srcset != '') {
1041 img.sizes = data.sizes;
1042 img.srcset = data.srcset;
1043 }
1044 img.alt = '';
1045 if (!isNil(data.alt) && data.alt !== '') {
1046 img.alt = data.alt;
1047 }
1048 if (data.title !== '') {
1049 img.setAttribute('aria-labelledby', titleID);
1050 }
1051 if (data.description !== '') {
1052 img.setAttribute('aria-describedby', textID);
1053 }
1054 if (data.hasOwnProperty('_hasCustomWidth') && data._hasCustomWidth) {
1055 img.style.width = data.width;
1056 }
1057 if (data.hasOwnProperty('_hasCustomHeight') && data._hasCustomHeight) {
1058 img.style.height = data.height;
1059 }
1060 slideMedia.insertBefore(img, slideMedia.firstChild);
1061 return;
1062 }
1063
1064 function slideVideo(slide, data, index, callback) {
1065 var _this = this;
1066 var slideContainer = slide.querySelector('.ginner-container');
1067 var videoID = 'gvideo' + index;
1068 var slideMedia = slide.querySelector('.gslide-media');
1069 var videoPlayers = this.getAllPlayers();
1070 addClass(slideContainer, 'gvideo-container');
1071 slideMedia.insertBefore(
1072 createHTML('<div class="gvideo-wrapper"></div>'),
1073 slideMedia.firstChild
1074 );
1075 var videoWrapper = slide.querySelector('.gvideo-wrapper');
1076 injectAssets(this.settings.plyr.css, 'Plyr');
1077 var url = data.href;
1078 var provider = data === null || data === void 0 ? void 0 : data.videoProvider;
1079 var customPlaceholder = false;
1080 slideMedia.style.maxWidth = data.width;
1081 injectAssets(this.settings.plyr.js, 'Plyr', function () {
1082 if (!provider && url.match(/vimeo\.com\/([0-9]*)/)) {
1083 provider = 'vimeo';
1084 }
1085 if (
1086 !provider &&
1087 (url.match(/(youtube\.com|youtube-nocookie\.com)\/watch\?v=([a-zA-Z0-9\-_]+)/) ||
1088 url.match(/youtu\.be\/([a-zA-Z0-9\-_]+)/) ||
1089 url.match(/(youtube\.com|youtube-nocookie\.com)\/embed\/([a-zA-Z0-9\-_]+)/) ||
1090 url.match(/(youtube\.com|youtube-nocookie\.com)\/shorts\/([a-zA-Z0-9\-_]+)/))
1091 ) {
1092 provider = 'youtube';
1093 }
1094 if (provider === 'local' || !provider) {
1095 provider = 'local';
1096 var html = '<video id="' + videoID + '" ';
1097 html += 'style="background:#000; max-width: '.concat(data.width, ';" ');
1098 html += 'preload="metadata" ';
1099 html += 'x-webkit-airplay="allow" ';
1100 html += 'playsinline ';
1101 html += 'controls ';
1102 html += 'class="gvideo-local">';
1103 html += '<source src="'.concat(url, '">');
1104 html += '</video>';
1105 customPlaceholder = createHTML(html);
1106 }
1107 var placeholder = customPlaceholder
1108 ? customPlaceholder
1109 : createHTML(
1110 '<div id="'
1111 .concat(videoID, '" data-plyr-provider="')
1112 .concat(provider, '" data-plyr-embed-id="')
1113 .concat(url, '"></div>')
1114 );
1115 addClass(videoWrapper, ''.concat(provider, '-video gvideo'));
1116 videoWrapper.appendChild(placeholder);
1117 videoWrapper.setAttribute('data-id', videoID);
1118 videoWrapper.setAttribute('data-index', index);
1119 var playerConfig = has(_this.settings.plyr, 'config') ? _this.settings.plyr.config : {};
1120 var player = new Plyr('#' + videoID, playerConfig);
1121 player.on('ready', function (event) {
1122 videoPlayers[videoID] = event.detail.plyr;
1123 if (isFunction(callback)) {
1124 callback();
1125 }
1126 });
1127 waitUntil(
1128 function () {
1129 return (
1130 slide.querySelector('iframe') &&
1131 slide.querySelector('iframe').dataset.ready == 'true'
1132 );
1133 },
1134 function () {
1135 _this.resize(slide);
1136 }
1137 );
1138 player.on('enterfullscreen', handleMediaFullScreen);
1139 player.on('exitfullscreen', handleMediaFullScreen);
1140 });
1141 }
1142 function handleMediaFullScreen(event) {
1143 var media = closest(event.target, '.gslide-media');
1144 if (event.type === 'enterfullscreen') {
1145 addClass(media, 'fullscreen');
1146 }
1147 if (event.type === 'exitfullscreen') {
1148 removeClass(media, 'fullscreen');
1149 }
1150 }
1151
1152 function slideInline(slide, data, index, callback) {
1153 var _this = this;
1154 var slideMedia = slide.querySelector('.gslide-media');
1155 var hash = has(data, 'href') && data.href ? data.href.split('#').pop().trim() : false;
1156 var content = has(data, 'content') && data.content ? data.content : false;
1157 var innerContent;
1158 if (content) {
1159 if (isString(content)) {
1160 innerContent = createHTML(
1161 '<div class="ginlined-content">'.concat(content, '</div>')
1162 );
1163 }
1164 if (isNode(content)) {
1165 if (content.style.display == 'none') {
1166 content.style.display = 'block';
1167 }
1168 var container = document.createElement('div');
1169 container.className = 'ginlined-content';
1170 container.appendChild(content);
1171 innerContent = container;
1172 }
1173 }
1174 if (hash) {
1175 var div = document.getElementById(hash);
1176 if (!div) {
1177 return false;
1178 }
1179 var cloned = div.cloneNode(true);
1180 cloned.style.height = data.height;
1181 cloned.style.maxWidth = data.width;
1182 addClass(cloned, 'ginlined-content');
1183 innerContent = cloned;
1184 }
1185 if (!innerContent) {
1186 console.error('Unable to append inline slide content', data);
1187 return false;
1188 }
1189 slideMedia.style.height = data.height;
1190 slideMedia.style.width = data.width;
1191 slideMedia.appendChild(innerContent);
1192 this.events['inlineclose' + hash] = addEvent('click', {
1193 onElement: slideMedia.querySelectorAll('.gtrigger-close'),
1194 withCallback: function withCallback(e) {
1195 e.preventDefault();
1196 _this.close();
1197 },
1198 });
1199 if (isFunction(callback)) {
1200 callback();
1201 }
1202 return;
1203 }
1204
1205 function slideIframe(slide, data, index, callback) {
1206 var slideMedia = slide.querySelector('.gslide-media');
1207 var iframe = createIframe({
1208 url: data.href,
1209 callback: callback,
1210 });
1211 slideMedia.parentNode.style.maxWidth = data.width;
1212 slideMedia.parentNode.style.height = data.height;
1213 slideMedia.appendChild(iframe);
1214 return;
1215 }
1216
1217 var SlideConfigParser = (function () {
1218 function SlideConfigParser() {
1219 var slideParamas =
1220 arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1221 _classCallCheck(this, SlideConfigParser);
1222 this.defaults = {
1223 href: '',
1224 sizes: '',
1225 srcset: '',
1226 title: '',
1227 type: '',
1228 videoProvider: '',
1229 description: '',
1230 alt: '',
1231 descPosition: 'bottom',
1232 effect: '',
1233 width: '',
1234 height: '',
1235 content: false,
1236 zoomable: true,
1237 draggable: true,
1238 };
1239 if (isObject(slideParamas)) {
1240 this.defaults = extend(this.defaults, slideParamas);
1241 }
1242 }
1243 return _createClass(SlideConfigParser, [
1244 {
1245 key: 'sourceType',
1246 value: function sourceType(url) {
1247 var origin = url;
1248 url = url.toLowerCase();
1249 if (url.match(/\.(jpeg|jpg|jpe|gif|png|apn|webp|avif|svg)/) !== null) {
1250 return 'image';
1251 }
1252 if (
1253 url.match(
1254 /(youtube\.com|youtube-nocookie\.com)\/watch\?v=([a-zA-Z0-9\-_]+)/
1255 ) ||
1256 url.match(/youtu\.be\/([a-zA-Z0-9\-_]+)/) ||
1257 url.match(
1258 /(youtube\.com|youtube-nocookie\.com)\/embed\/([a-zA-Z0-9\-_]+)/
1259 ) ||
1260 url.match(/(youtube\.com|youtube-nocookie\.com)\/shorts\/([a-zA-Z0-9\-_]+)/)
1261 ) {
1262 return 'video';
1263 }
1264 if (url.match(/vimeo\.com\/([0-9]*)/)) {
1265 return 'video';
1266 }
1267 if (url.match(/\.(mp4|ogg|webm|mov)/) !== null) {
1268 return 'video';
1269 }
1270 if (url.match(/\.(mp3|wav|wma|aac|ogg)/) !== null) {
1271 return 'audio';
1272 }
1273 if (url.indexOf('#') > -1) {
1274 var hash = origin.split('#').pop();
1275 if (hash.trim() !== '') {
1276 return 'inline';
1277 }
1278 }
1279 if (url.indexOf('goajax=true') > -1) {
1280 return 'ajax';
1281 }
1282 return 'external';
1283 },
1284 },
1285 {
1286 key: 'parseConfig',
1287 value: function parseConfig(element, settings) {
1288 var _this = this;
1289 var data = extend(
1290 {
1291 descPosition: settings.descPosition,
1292 },
1293 this.defaults
1294 );
1295 if (isObject(element) && !isNode(element)) {
1296 if (!has(element, 'type')) {
1297 if (has(element, 'content') && element.content) {
1298 element.type = 'inline';
1299 } else if (has(element, 'href')) {
1300 element.type = this.sourceType(element.href);
1301 }
1302 }
1303 var objectData = extend(data, element);
1304 this.setSize(objectData, settings);
1305 return objectData;
1306 }
1307 var url = '';
1308 var config = element.getAttribute('data-glightbox');
1309 var nodeType = element.nodeName.toLowerCase();
1310 if (nodeType === 'a') {
1311 url = element.href;
1312 }
1313 if (nodeType === 'img') {
1314 url = element.src;
1315 data.alt = element.alt;
1316 }
1317 data.href = url;
1318 each(data, function (val, key) {
1319 if (has(settings, key) && key !== 'width') {
1320 data[key] = settings[key];
1321 }
1322 var nodeData = element.dataset[key];
1323 if (!isNil(nodeData)) {
1324 data[key] = _this.sanitizeValue(nodeData);
1325 }
1326 });
1327 if (data.content) {
1328 data.type = 'inline';
1329 }
1330 if (!data.type && url) {
1331 data.type = this.sourceType(url);
1332 }
1333 if (!isNil(config)) {
1334 var cleanKeys = [];
1335 each(data, function (v, k) {
1336 cleanKeys.push(';\\s?' + k);
1337 });
1338 cleanKeys = cleanKeys.join('\\s?:|');
1339 if (config.trim() !== '') {
1340 each(data, function (val, key) {
1341 var str = config;
1342 var match = 's?' + key + 's?:s?(.*?)(' + cleanKeys + 's?:|$)';
1343 var regex = new RegExp(match);
1344 var matches = str.match(regex);
1345 if (matches && matches.length && matches[1]) {
1346 var value = matches[1].trim().replace(/;\s*$/, '');
1347 data[key] = _this.sanitizeValue(value);
1348 }
1349 });
1350 }
1351 } else {
1352 if (!data.title && nodeType == 'a') {
1353 var title = element.title;
1354 if (!isNil(title) && title !== '') {
1355 data.title = title;
1356 }
1357 }
1358 if (!data.title && nodeType == 'img') {
1359 var alt = element.alt;
1360 if (!isNil(alt) && alt !== '') {
1361 data.title = alt;
1362 }
1363 }
1364 }
1365 if (data.description && data.description.substring(0, 1) === '.') {
1366 var description;
1367 try {
1368 description = document.querySelector(data.description).innerHTML;
1369 } catch (error) {
1370 if (!(error instanceof DOMException)) {
1371 throw error;
1372 }
1373 }
1374 if (description) {
1375 data.description = description;
1376 }
1377 }
1378 if (!data.description) {
1379 var nodeDesc = element.querySelector('.glightbox-desc');
1380 if (nodeDesc) {
1381 data.description = nodeDesc.innerHTML;
1382 }
1383 }
1384 this.setSize(data, settings, element);
1385 this.slideConfig = data;
1386 return data;
1387 },
1388 },
1389 {
1390 key: 'setSize',
1391 value: function setSize(data, settings) {
1392 var element =
1393 arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
1394 var defaultWith =
1395 data.type == 'video'
1396 ? this.checkSize(settings.videosWidth)
1397 : this.checkSize(settings.width);
1398 var defaultHeight = this.checkSize(settings.height);
1399 data.width =
1400 has(data, 'width') && data.width !== ''
1401 ? this.checkSize(data.width)
1402 : defaultWith;
1403 data.height =
1404 has(data, 'height') && data.height !== ''
1405 ? this.checkSize(data.height)
1406 : defaultHeight;
1407 if (element && data.type == 'image') {
1408 data._hasCustomWidth = element.dataset.width ? true : false;
1409 data._hasCustomHeight = element.dataset.height ? true : false;
1410 }
1411 return data;
1412 },
1413 },
1414 {
1415 key: 'checkSize',
1416 value: function checkSize(size) {
1417 return isNumber(size) ? ''.concat(size, 'px') : size;
1418 },
1419 },
1420 {
1421 key: 'sanitizeValue',
1422 value: function sanitizeValue(val) {
1423 if (val !== 'true' && val !== 'false') {
1424 return val;
1425 }
1426 return val === 'true';
1427 },
1428 },
1429 ]);
1430 })();
1431
1432 var Slide = (function () {
1433 function Slide(el, instance, index) {
1434 _classCallCheck(this, Slide);
1435 this.element = el;
1436 this.instance = instance;
1437 this.index = index;
1438 }
1439 return _createClass(Slide, [
1440 {
1441 key: 'setContent',
1442 value: function setContent() {
1443 var _this = this;
1444 var slide =
1445 arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
1446 var callback =
1447 arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
1448 if (hasClass(slide, 'loaded')) {
1449 return false;
1450 }
1451 var settings = this.instance.settings;
1452 var slideConfig = this.slideConfig;
1453 var isMobileDevice = isMobile();
1454 if (isFunction(settings.beforeSlideLoad)) {
1455 settings.beforeSlideLoad({
1456 index: this.index,
1457 slide: slide,
1458 player: false,
1459 });
1460 }
1461 var type = slideConfig.type;
1462 var position = slideConfig.descPosition;
1463 var slideMedia = slide.querySelector('.gslide-media');
1464 var slideTitle = slide.querySelector('.gslide-title');
1465 var slideText = slide.querySelector('.gslide-desc');
1466 var slideDesc = slide.querySelector('.gdesc-inner');
1467 var finalCallback = callback;
1468 var titleID = 'gSlideTitle_' + this.index;
1469 var textID = 'gSlideDesc_' + this.index;
1470 if (isFunction(settings.afterSlideLoad)) {
1471 finalCallback = function finalCallback() {
1472 if (isFunction(callback)) {
1473 callback();
1474 }
1475 settings.afterSlideLoad({
1476 index: _this.index,
1477 slide: slide,
1478 player: _this.instance.getSlidePlayerInstance(_this.index),
1479 });
1480 };
1481 }
1482 if (slideConfig.title == '' && slideConfig.description == '') {
1483 if (slideDesc) {
1484 slideDesc.parentNode.parentNode.removeChild(slideDesc.parentNode);
1485 }
1486 } else {
1487 if (slideTitle && slideConfig.title !== '') {
1488 slideTitle.id = titleID;
1489 slideTitle.innerHTML = slideConfig.title;
1490 } else {
1491 slideTitle.parentNode.removeChild(slideTitle);
1492 }
1493 if (slideText && slideConfig.description !== '') {
1494 slideText.id = textID;
1495 if (isMobileDevice && settings.moreLength > 0) {
1496 slideConfig.smallDescription = this.slideShortDesc(
1497 slideConfig.description,
1498 settings.moreLength,
1499 settings.moreText
1500 );
1501 slideText.innerHTML = slideConfig.smallDescription;
1502 this.descriptionEvents(slideText, slideConfig);
1503 } else {
1504 slideText.innerHTML = slideConfig.description;
1505 }
1506 } else {
1507 slideText.parentNode.removeChild(slideText);
1508 }
1509 addClass(slideMedia.parentNode, 'desc-'.concat(position));
1510 addClass(slideDesc.parentNode, 'description-'.concat(position));
1511 }
1512 addClass(slideMedia, 'gslide-'.concat(type));
1513 addClass(slide, 'loaded');
1514 if (type === 'video') {
1515 slideVideo.apply(this.instance, [
1516 slide,
1517 slideConfig,
1518 this.index,
1519 finalCallback,
1520 ]);
1521 return;
1522 }
1523 if (type === 'external') {
1524 slideIframe.apply(this, [slide, slideConfig, this.index, finalCallback]);
1525 return;
1526 }
1527 if (type === 'inline') {
1528 slideInline.apply(this.instance, [
1529 slide,
1530 slideConfig,
1531 this.index,
1532 finalCallback,
1533 ]);
1534 if (slideConfig.draggable) {
1535 new DragSlides({
1536 dragEl: slide.querySelector('.gslide-inline'),
1537 toleranceX: settings.dragToleranceX,
1538 toleranceY: settings.dragToleranceY,
1539 slide: slide,
1540 instance: this.instance,
1541 });
1542 }
1543 return;
1544 }
1545 if (type === 'image') {
1546 slideImage(slide, slideConfig, this.index, function () {
1547 var img = slide.querySelector('img');
1548 if (slideConfig.draggable) {
1549 new DragSlides({
1550 dragEl: img,
1551 toleranceX: settings.dragToleranceX,
1552 toleranceY: settings.dragToleranceY,
1553 slide: slide,
1554 instance: _this.instance,
1555 });
1556 }
1557 if (slideConfig.zoomable && img.naturalWidth > img.offsetWidth) {
1558 addClass(img, 'zoomable');
1559 new ZoomImages(img, slide, function () {
1560 _this.instance.resize();
1561 });
1562 }
1563 if (isFunction(finalCallback)) {
1564 finalCallback();
1565 }
1566 });
1567 return;
1568 }
1569 if (isFunction(finalCallback)) {
1570 finalCallback();
1571 }
1572 },
1573 },
1574 {
1575 key: 'slideShortDesc',
1576 value: function slideShortDesc(string) {
1577 var n = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 50;
1578 var wordBoundary =
1579 arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
1580 var div = document.createElement('div');
1581 div.innerHTML = string;
1582 var cleanedString = div.innerText;
1583 var useWordBoundary = wordBoundary;
1584 string = cleanedString.trim();
1585 if (string.length <= n) {
1586 return string;
1587 }
1588 var subString = string.substr(0, n - 1);
1589 if (!useWordBoundary) {
1590 return subString;
1591 }
1592 div = null;
1593 return subString + '... <a href="#" class="desc-more">' + wordBoundary + '</a>';
1594 },
1595 },
1596 {
1597 key: 'descriptionEvents',
1598 value: function descriptionEvents(desc, data) {
1599 var _this2 = this;
1600 var moreLink = desc.querySelector('.desc-more');
1601 if (!moreLink) {
1602 return false;
1603 }
1604 addEvent('click', {
1605 onElement: moreLink,
1606 withCallback: function withCallback(event, target) {
1607 event.preventDefault();
1608 var body = document.body;
1609 var desc = closest(target, '.gslide-desc');
1610 if (!desc) {
1611 return false;
1612 }
1613 desc.innerHTML = data.description;
1614 addClass(body, 'gdesc-open');
1615 var shortEvent = addEvent('click', {
1616 onElement: [body, closest(desc, '.gslide-description')],
1617 withCallback: function withCallback(event, target) {
1618 if (event.target.nodeName.toLowerCase() !== 'a') {
1619 removeClass(body, 'gdesc-open');
1620 addClass(body, 'gdesc-closed');
1621 desc.innerHTML = data.smallDescription;
1622 _this2.descriptionEvents(desc, data);
1623 setTimeout(function () {
1624 removeClass(body, 'gdesc-closed');
1625 }, 400);
1626 shortEvent.destroy();
1627 }
1628 },
1629 });
1630 },
1631 });
1632 },
1633 },
1634 {
1635 key: 'create',
1636 value: function create() {
1637 return createHTML(this.instance.settings.slideHTML);
1638 },
1639 },
1640 {
1641 key: 'getConfig',
1642 value: function getConfig() {
1643 if (!isNode(this.element) && !this.element.hasOwnProperty('draggable')) {
1644 this.element.draggable = this.instance.settings.draggable;
1645 }
1646 var parser = new SlideConfigParser(this.instance.settings.slideExtraAttributes);
1647 this.slideConfig = parser.parseConfig(this.element, this.instance.settings);
1648 return this.slideConfig;
1649 },
1650 },
1651 ]);
1652 })();
1653
1654 function getLen(v) {
1655 return Math.sqrt(v.x * v.x + v.y * v.y);
1656 }
1657 function dot(v1, v2) {
1658 return v1.x * v2.x + v1.y * v2.y;
1659 }
1660 function getAngle(v1, v2) {
1661 var mr = getLen(v1) * getLen(v2);
1662 if (mr === 0) {
1663 return 0;
1664 }
1665 var r = dot(v1, v2) / mr;
1666 if (r > 1) {
1667 r = 1;
1668 }
1669 return Math.acos(r);
1670 }
1671 function cross(v1, v2) {
1672 return v1.x * v2.y - v2.x * v1.y;
1673 }
1674 function getRotateAngle(v1, v2) {
1675 var angle = getAngle(v1, v2);
1676 if (cross(v1, v2) > 0) {
1677 angle *= -1;
1678 }
1679 return (angle * 180) / Math.PI;
1680 }
1681 var EventsHandlerAdmin = (function () {
1682 function EventsHandlerAdmin(el) {
1683 _classCallCheck(this, EventsHandlerAdmin);
1684 this.handlers = [];
1685 this.el = el;
1686 }
1687 return _createClass(EventsHandlerAdmin, [
1688 {
1689 key: 'add',
1690 value: function add(handler) {
1691 this.handlers.push(handler);
1692 },
1693 },
1694 {
1695 key: 'del',
1696 value: function del(handler) {
1697 if (!handler) {
1698 this.handlers = [];
1699 }
1700 for (var i = this.handlers.length; i >= 0; i--) {
1701 if (this.handlers[i] === handler) {
1702 this.handlers.splice(i, 1);
1703 }
1704 }
1705 },
1706 },
1707 {
1708 key: 'dispatch',
1709 value: function dispatch() {
1710 for (var i = 0, len = this.handlers.length; i < len; i++) {
1711 var handler = this.handlers[i];
1712 if (typeof handler === 'function') {
1713 handler.apply(this.el, arguments);
1714 }
1715 }
1716 },
1717 },
1718 ]);
1719 })();
1720 function wrapFunc(el, handler) {
1721 var EventshandlerAdmin = new EventsHandlerAdmin(el);
1722 EventshandlerAdmin.add(handler);
1723 return EventshandlerAdmin;
1724 }
1725 var TouchEvents = (function () {
1726 function TouchEvents(el, option) {
1727 _classCallCheck(this, TouchEvents);
1728 this.element = typeof el == 'string' ? document.querySelector(el) : el;
1729 this.start = this.start.bind(this);
1730 this.move = this.move.bind(this);
1731 this.end = this.end.bind(this);
1732 this.cancel = this.cancel.bind(this);
1733 this.element.addEventListener('touchstart', this.start, false);
1734 this.element.addEventListener('touchmove', this.move, false);
1735 this.element.addEventListener('touchend', this.end, false);
1736 this.element.addEventListener('touchcancel', this.cancel, false);
1737 this.preV = {
1738 x: null,
1739 y: null,
1740 };
1741 this.pinchStartLen = null;
1742 this.zoom = 1;
1743 this.isDoubleTap = false;
1744 var noop = function noop() {};
1745 this.rotate = wrapFunc(this.element, option.rotate || noop);
1746 this.touchStart = wrapFunc(this.element, option.touchStart || noop);
1747 this.multipointStart = wrapFunc(this.element, option.multipointStart || noop);
1748 this.multipointEnd = wrapFunc(this.element, option.multipointEnd || noop);
1749 this.pinch = wrapFunc(this.element, option.pinch || noop);
1750 this.swipe = wrapFunc(this.element, option.swipe || noop);
1751 this.tap = wrapFunc(this.element, option.tap || noop);
1752 this.doubleTap = wrapFunc(this.element, option.doubleTap || noop);
1753 this.longTap = wrapFunc(this.element, option.longTap || noop);
1754 this.singleTap = wrapFunc(this.element, option.singleTap || noop);
1755 this.pressMove = wrapFunc(this.element, option.pressMove || noop);
1756 this.twoFingerPressMove = wrapFunc(this.element, option.twoFingerPressMove || noop);
1757 this.touchMove = wrapFunc(this.element, option.touchMove || noop);
1758 this.touchEnd = wrapFunc(this.element, option.touchEnd || noop);
1759 this.touchCancel = wrapFunc(this.element, option.touchCancel || noop);
1760 this.translateContainer = this.element;
1761 this._cancelAllHandler = this.cancelAll.bind(this);
1762 window.addEventListener('scroll', this._cancelAllHandler);
1763 this.delta = null;
1764 this.last = null;
1765 this.now = null;
1766 this.tapTimeout = null;
1767 this.singleTapTimeout = null;
1768 this.longTapTimeout = null;
1769 this.swipeTimeout = null;
1770 this.x1 = this.x2 = this.y1 = this.y2 = null;
1771 this.preTapPosition = {
1772 x: null,
1773 y: null,
1774 };
1775 }
1776 return _createClass(TouchEvents, [
1777 {
1778 key: 'start',
1779 value: function start(evt) {
1780 if (!evt.touches) {
1781 return;
1782 }
1783 var ignoreDragFor = ['a', 'button', 'input'];
1784 if (
1785 evt.target &&
1786 evt.target.nodeName &&
1787 ignoreDragFor.indexOf(evt.target.nodeName.toLowerCase()) >= 0
1788 ) {
1789 console.log(
1790 'ignore drag for this touched element',
1791 evt.target.nodeName.toLowerCase()
1792 );
1793 return;
1794 }
1795 this.now = Date.now();
1796 this.x1 = evt.touches[0].pageX;
1797 this.y1 = evt.touches[0].pageY;
1798 this.delta = this.now - (this.last || this.now);
1799 this.touchStart.dispatch(evt, this.element);
1800 if (this.preTapPosition.x !== null) {
1801 this.isDoubleTap =
1802 this.delta > 0 &&
1803 this.delta <= 250 &&
1804 Math.abs(this.preTapPosition.x - this.x1) < 30 &&
1805 Math.abs(this.preTapPosition.y - this.y1) < 30;
1806 if (this.isDoubleTap) {
1807 clearTimeout(this.singleTapTimeout);
1808 }
1809 }
1810 this.preTapPosition.x = this.x1;
1811 this.preTapPosition.y = this.y1;
1812 this.last = this.now;
1813 var preV = this.preV,
1814 len = evt.touches.length;
1815 if (len > 1) {
1816 this._cancelLongTap();
1817 this._cancelSingleTap();
1818 var v = {
1819 x: evt.touches[1].pageX - this.x1,
1820 y: evt.touches[1].pageY - this.y1,
1821 };
1822 preV.x = v.x;
1823 preV.y = v.y;
1824 this.pinchStartLen = getLen(preV);
1825 this.multipointStart.dispatch(evt, this.element);
1826 }
1827 this._preventTap = false;
1828 this.longTapTimeout = setTimeout(
1829 function () {
1830 this.longTap.dispatch(evt, this.element);
1831 this._preventTap = true;
1832 }.bind(this),
1833 750
1834 );
1835 },
1836 },
1837 {
1838 key: 'move',
1839 value: function move(evt) {
1840 if (!evt.touches) {
1841 return;
1842 }
1843 var preV = this.preV,
1844 len = evt.touches.length,
1845 currentX = evt.touches[0].pageX,
1846 currentY = evt.touches[0].pageY;
1847 this.isDoubleTap = false;
1848 if (len > 1) {
1849 var sCurrentX = evt.touches[1].pageX,
1850 sCurrentY = evt.touches[1].pageY;
1851 var v = {
1852 x: evt.touches[1].pageX - currentX,
1853 y: evt.touches[1].pageY - currentY,
1854 };
1855 if (preV.x !== null) {
1856 if (this.pinchStartLen > 0) {
1857 evt.zoom = getLen(v) / this.pinchStartLen;
1858 this.pinch.dispatch(evt, this.element);
1859 }
1860 evt.angle = getRotateAngle(v, preV);
1861 this.rotate.dispatch(evt, this.element);
1862 }
1863 preV.x = v.x;
1864 preV.y = v.y;
1865 if (this.x2 !== null && this.sx2 !== null) {
1866 evt.deltaX = (currentX - this.x2 + sCurrentX - this.sx2) / 2;
1867 evt.deltaY = (currentY - this.y2 + sCurrentY - this.sy2) / 2;
1868 } else {
1869 evt.deltaX = 0;
1870 evt.deltaY = 0;
1871 }
1872 this.twoFingerPressMove.dispatch(evt, this.element);
1873 this.sx2 = sCurrentX;
1874 this.sy2 = sCurrentY;
1875 } else {
1876 if (this.x2 !== null) {
1877 evt.deltaX = currentX - this.x2;
1878 evt.deltaY = currentY - this.y2;
1879 var movedX = Math.abs(this.x1 - this.x2),
1880 movedY = Math.abs(this.y1 - this.y2);
1881 if (movedX > 10 || movedY > 10) {
1882 this._preventTap = true;
1883 }
1884 } else {
1885 evt.deltaX = 0;
1886 evt.deltaY = 0;
1887 }
1888 this.pressMove.dispatch(evt, this.element);
1889 }
1890 this.touchMove.dispatch(evt, this.element);
1891 this._cancelLongTap();
1892 this.x2 = currentX;
1893 this.y2 = currentY;
1894 if (len > 1) {
1895 evt.preventDefault();
1896 }
1897 },
1898 },
1899 {
1900 key: 'end',
1901 value: function end(evt) {
1902 if (!evt.changedTouches) {
1903 return;
1904 }
1905 this._cancelLongTap();
1906 var self = this;
1907 if (evt.touches.length < 2) {
1908 this.multipointEnd.dispatch(evt, this.element);
1909 this.sx2 = this.sy2 = null;
1910 }
1911 if (
1912 (this.x2 && Math.abs(this.x1 - this.x2) > 30) ||
1913 (this.y2 && Math.abs(this.y1 - this.y2) > 30)
1914 ) {
1915 evt.direction = this._swipeDirection(this.x1, this.x2, this.y1, this.y2);
1916 this.swipeTimeout = setTimeout(function () {
1917 self.swipe.dispatch(evt, self.element);
1918 }, 0);
1919 } else {
1920 this.tapTimeout = setTimeout(function () {
1921 if (!self._preventTap) {
1922 self.tap.dispatch(evt, self.element);
1923 }
1924 if (self.isDoubleTap) {
1925 self.doubleTap.dispatch(evt, self.element);
1926 self.isDoubleTap = false;
1927 }
1928 }, 0);
1929 if (!self.isDoubleTap) {
1930 self.singleTapTimeout = setTimeout(function () {
1931 self.singleTap.dispatch(evt, self.element);
1932 }, 250);
1933 }
1934 }
1935 this.touchEnd.dispatch(evt, this.element);
1936 this.preV.x = 0;
1937 this.preV.y = 0;
1938 this.zoom = 1;
1939 this.pinchStartLen = null;
1940 this.x1 = this.x2 = this.y1 = this.y2 = null;
1941 },
1942 },
1943 {
1944 key: 'cancelAll',
1945 value: function cancelAll() {
1946 this._preventTap = true;
1947 clearTimeout(this.singleTapTimeout);
1948 clearTimeout(this.tapTimeout);
1949 clearTimeout(this.longTapTimeout);
1950 clearTimeout(this.swipeTimeout);
1951 },
1952 },
1953 {
1954 key: 'cancel',
1955 value: function cancel(evt) {
1956 this.cancelAll();
1957 this.touchCancel.dispatch(evt, this.element);
1958 },
1959 },
1960 {
1961 key: '_cancelLongTap',
1962 value: function _cancelLongTap() {
1963 clearTimeout(this.longTapTimeout);
1964 },
1965 },
1966 {
1967 key: '_cancelSingleTap',
1968 value: function _cancelSingleTap() {
1969 clearTimeout(this.singleTapTimeout);
1970 },
1971 },
1972 {
1973 key: '_swipeDirection',
1974 value: function _swipeDirection(x1, x2, y1, y2) {
1975 return Math.abs(x1 - x2) >= Math.abs(y1 - y2)
1976 ? x1 - x2 > 0
1977 ? 'Left'
1978 : 'Right'
1979 : y1 - y2 > 0
1980 ? 'Up'
1981 : 'Down';
1982 },
1983 },
1984 {
1985 key: 'on',
1986 value: function on(evt, handler) {
1987 if (this[evt]) {
1988 this[evt].add(handler);
1989 }
1990 },
1991 },
1992 {
1993 key: 'off',
1994 value: function off(evt, handler) {
1995 if (this[evt]) {
1996 this[evt].del(handler);
1997 }
1998 },
1999 },
2000 {
2001 key: 'destroy',
2002 value: function destroy() {
2003 if (this.singleTapTimeout) {
2004 clearTimeout(this.singleTapTimeout);
2005 }
2006 if (this.tapTimeout) {
2007 clearTimeout(this.tapTimeout);
2008 }
2009 if (this.longTapTimeout) {
2010 clearTimeout(this.longTapTimeout);
2011 }
2012 if (this.swipeTimeout) {
2013 clearTimeout(this.swipeTimeout);
2014 }
2015 this.element.removeEventListener('touchstart', this.start);
2016 this.element.removeEventListener('touchmove', this.move);
2017 this.element.removeEventListener('touchend', this.end);
2018 this.element.removeEventListener('touchcancel', this.cancel);
2019 this.rotate.del();
2020 this.touchStart.del();
2021 this.multipointStart.del();
2022 this.multipointEnd.del();
2023 this.pinch.del();
2024 this.swipe.del();
2025 this.tap.del();
2026 this.doubleTap.del();
2027 this.longTap.del();
2028 this.singleTap.del();
2029 this.pressMove.del();
2030 this.twoFingerPressMove.del();
2031 this.touchMove.del();
2032 this.touchEnd.del();
2033 this.touchCancel.del();
2034 this.preV =
2035 this.pinchStartLen =
2036 this.zoom =
2037 this.isDoubleTap =
2038 this.delta =
2039 this.last =
2040 this.now =
2041 this.tapTimeout =
2042 this.singleTapTimeout =
2043 this.longTapTimeout =
2044 this.swipeTimeout =
2045 this.x1 =
2046 this.x2 =
2047 this.y1 =
2048 this.y2 =
2049 this.preTapPosition =
2050 this.rotate =
2051 this.touchStart =
2052 this.multipointStart =
2053 this.multipointEnd =
2054 this.pinch =
2055 this.swipe =
2056 this.tap =
2057 this.doubleTap =
2058 this.longTap =
2059 this.singleTap =
2060 this.pressMove =
2061 this.touchMove =
2062 this.touchEnd =
2063 this.touchCancel =
2064 this.twoFingerPressMove =
2065 null;
2066 window.removeEventListener('scroll', this._cancelAllHandler);
2067 return null;
2068 },
2069 },
2070 ]);
2071 })();
2072
2073 function resetSlideMove(slide) {
2074 var transitionEnd = whichTransitionEvent();
2075 var windowWidth =
2076 window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth;
2077 var media = hasClass(slide, 'gslide-media') ? slide : slide.querySelector('.gslide-media');
2078 var container = closest(media, '.ginner-container');
2079 var desc = slide.querySelector('.gslide-description');
2080 if (windowWidth > 769) {
2081 media = container;
2082 }
2083 addClass(media, 'greset');
2084 cssTransform(media, 'translate3d(0, 0, 0)');
2085 addEvent(transitionEnd, {
2086 onElement: media,
2087 once: true,
2088 withCallback: function withCallback(event, target) {
2089 removeClass(media, 'greset');
2090 },
2091 });
2092 media.style.opacity = '';
2093 if (desc) {
2094 desc.style.opacity = '';
2095 }
2096 }
2097 function touchNavigation(instance) {
2098 if (instance.events.hasOwnProperty('touch')) {
2099 return false;
2100 }
2101 var winSize = windowSize();
2102 var winWidth = winSize.width;
2103 var winHeight = winSize.height;
2104 var process = false;
2105 var currentSlide = null;
2106 var media = null;
2107 var mediaImage = null;
2108 var doingMove = false;
2109 var initScale = 1;
2110 var maxScale = 4.5;
2111 var currentScale = 1;
2112 var doingZoom = false;
2113 var imageZoomed = false;
2114 var zoomedPosX = null;
2115 var zoomedPosY = null;
2116 var lastZoomedPosX = null;
2117 var lastZoomedPosY = null;
2118 var hDistance;
2119 var vDistance;
2120 var hDistancePercent = 0;
2121 var vDistancePercent = 0;
2122 var vSwipe = false;
2123 var hSwipe = false;
2124 var startCoords = {};
2125 var endCoords = {};
2126 var xDown = 0;
2127 var yDown = 0;
2128 var isInlined;
2129 var sliderWrapper = document.getElementById('glightbox-slider');
2130 var overlay = document.querySelector('.goverlay');
2131 var touchInstance = new TouchEvents(sliderWrapper, {
2132 touchStart: function touchStart(e) {
2133 process = true;
2134 if (
2135 hasClass(e.targetTouches[0].target, 'ginner-container') ||
2136 closest(e.targetTouches[0].target, '.gslide-desc') ||
2137 e.targetTouches[0].target.nodeName.toLowerCase() == 'a'
2138 ) {
2139 process = false;
2140 }
2141 if (
2142 closest(e.targetTouches[0].target, '.gslide-inline') &&
2143 !hasClass(e.targetTouches[0].target.parentNode, 'gslide-inline')
2144 ) {
2145 process = false;
2146 }
2147 if (process) {
2148 endCoords = e.targetTouches[0];
2149 startCoords.pageX = e.targetTouches[0].pageX;
2150 startCoords.pageY = e.targetTouches[0].pageY;
2151 xDown = e.targetTouches[0].clientX;
2152 yDown = e.targetTouches[0].clientY;
2153 currentSlide = instance.activeSlide;
2154 media = currentSlide.querySelector('.gslide-media');
2155 isInlined = currentSlide.querySelector('.gslide-inline');
2156 mediaImage = null;
2157 if (hasClass(media, 'gslide-image')) {
2158 mediaImage = media.querySelector('img');
2159 }
2160 var windowWidth =
2161 window.innerWidth ||
2162 document.documentElement.clientWidth ||
2163 document.body.clientWidth;
2164 if (windowWidth > 769) {
2165 media = currentSlide.querySelector('.ginner-container');
2166 }
2167 removeClass(overlay, 'greset');
2168 if (e.pageX > 20 && e.pageX < window.innerWidth - 20) {
2169 return;
2170 }
2171 e.preventDefault();
2172 }
2173 },
2174 touchMove: function touchMove(e) {
2175 if (!process) {
2176 return;
2177 }
2178 endCoords = e.targetTouches[0];
2179 if (doingZoom || imageZoomed) {
2180 return;
2181 }
2182 if (isInlined && isInlined.offsetHeight > winHeight) {
2183 var moved = startCoords.pageX - endCoords.pageX;
2184 if (Math.abs(moved) <= 13) {
2185 return false;
2186 }
2187 }
2188 doingMove = true;
2189 var xUp = e.targetTouches[0].clientX;
2190 var yUp = e.targetTouches[0].clientY;
2191 var xDiff = xDown - xUp;
2192 var yDiff = yDown - yUp;
2193 if (Math.abs(xDiff) > Math.abs(yDiff)) {
2194 vSwipe = false;
2195 hSwipe = true;
2196 } else {
2197 hSwipe = false;
2198 vSwipe = true;
2199 }
2200 hDistance = endCoords.pageX - startCoords.pageX;
2201 hDistancePercent = (hDistance * 100) / winWidth;
2202 vDistance = endCoords.pageY - startCoords.pageY;
2203 vDistancePercent = (vDistance * 100) / winHeight;
2204 var opacity;
2205 if (vSwipe && mediaImage) {
2206 opacity = 1 - Math.abs(vDistance) / winHeight;
2207 overlay.style.opacity = opacity;
2208 if (instance.settings.touchFollowAxis) {
2209 hDistancePercent = 0;
2210 }
2211 }
2212 if (hSwipe) {
2213 opacity = 1 - Math.abs(hDistance) / winWidth;
2214 media.style.opacity = opacity;
2215 if (instance.settings.touchFollowAxis) {
2216 vDistancePercent = 0;
2217 }
2218 }
2219 if (!mediaImage) {
2220 return cssTransform(media, 'translate3d('.concat(hDistancePercent, '%, 0, 0)'));
2221 }
2222 cssTransform(
2223 media,
2224 'translate3d('.concat(hDistancePercent, '%, ').concat(vDistancePercent, '%, 0)')
2225 );
2226 },
2227 touchEnd: function touchEnd() {
2228 if (!process) {
2229 return;
2230 }
2231 doingMove = false;
2232 if (imageZoomed || doingZoom) {
2233 lastZoomedPosX = zoomedPosX;
2234 lastZoomedPosY = zoomedPosY;
2235 return;
2236 }
2237 var v = Math.abs(parseInt(vDistancePercent));
2238 var h = Math.abs(parseInt(hDistancePercent));
2239 if (v > 29 && mediaImage) {
2240 instance.close();
2241 return;
2242 }
2243 if (v < 29 && h < 25) {
2244 addClass(overlay, 'greset');
2245 overlay.style.opacity = 1;
2246 return resetSlideMove(media);
2247 }
2248 },
2249 multipointEnd: function multipointEnd() {
2250 setTimeout(function () {
2251 doingZoom = false;
2252 }, 50);
2253 },
2254 multipointStart: function multipointStart() {
2255 doingZoom = true;
2256 initScale = currentScale ? currentScale : 1;
2257 },
2258 pinch: function pinch(evt) {
2259 if (!mediaImage || doingMove) {
2260 return false;
2261 }
2262 doingZoom = true;
2263 mediaImage.scaleX = mediaImage.scaleY = initScale * evt.zoom;
2264 var scale = initScale * evt.zoom;
2265 imageZoomed = true;
2266 if (scale <= 1) {
2267 imageZoomed = false;
2268 scale = 1;
2269 lastZoomedPosY = null;
2270 lastZoomedPosX = null;
2271 zoomedPosX = null;
2272 zoomedPosY = null;
2273 mediaImage.setAttribute('style', '');
2274 return;
2275 }
2276 if (scale > maxScale) {
2277 scale = maxScale;
2278 }
2279 mediaImage.style.transform = 'scale3d('.concat(scale, ', ').concat(scale, ', 1)');
2280 currentScale = scale;
2281 },
2282 pressMove: function pressMove(e) {
2283 if (imageZoomed && !doingZoom) {
2284 var mhDistance = endCoords.pageX - startCoords.pageX;
2285 var mvDistance = endCoords.pageY - startCoords.pageY;
2286 if (lastZoomedPosX) {
2287 mhDistance = mhDistance + lastZoomedPosX;
2288 }
2289 if (lastZoomedPosY) {
2290 mvDistance = mvDistance + lastZoomedPosY;
2291 }
2292 zoomedPosX = mhDistance;
2293 zoomedPosY = mvDistance;
2294 var style = 'translate3d('
2295 .concat(mhDistance, 'px, ')
2296 .concat(mvDistance, 'px, 0)');
2297 if (currentScale) {
2298 style += ' scale3d('
2299 .concat(currentScale, ', ')
2300 .concat(currentScale, ', 1)');
2301 }
2302 cssTransform(mediaImage, style);
2303 }
2304 },
2305 swipe: function swipe(evt) {
2306 if (imageZoomed) {
2307 return;
2308 }
2309 if (doingZoom) {
2310 doingZoom = false;
2311 return;
2312 }
2313 if (evt.direction == 'Left') {
2314 if (instance.index == instance.elements.length - 1) {
2315 return resetSlideMove(media);
2316 }
2317 instance.nextSlide();
2318 }
2319 if (evt.direction == 'Right') {
2320 if (instance.index == 0) {
2321 return resetSlideMove(media);
2322 }
2323 instance.prevSlide();
2324 }
2325 },
2326 });
2327 instance.events['touch'] = touchInstance;
2328 }
2329
2330 var _version = '3.3.1';
2331 var isMobile$1 = isMobile();
2332 var isTouch$1 = isTouch();
2333 var html = document.getElementsByTagName('html')[0];
2334 var defaults = {
2335 selector: '.glightbox',
2336 elements: null,
2337 skin: 'clean',
2338 theme: 'clean',
2339 closeButton: true,
2340 startAt: null,
2341 autoplayVideos: true,
2342 autofocusVideos: true,
2343 descPosition: 'bottom',
2344 width: '900px',
2345 height: '506px',
2346 videosWidth: '960px',
2347 beforeSlideChange: null,
2348 afterSlideChange: null,
2349 beforeSlideLoad: null,
2350 afterSlideLoad: null,
2351 slideInserted: null,
2352 slideRemoved: null,
2353 slideExtraAttributes: null,
2354 onOpen: null,
2355 onClose: null,
2356 loop: false,
2357 zoomable: true,
2358 draggable: true,
2359 dragAutoSnap: false,
2360 dragToleranceX: 40,
2361 dragToleranceY: 65,
2362 preload: true,
2363 oneSlidePerOpen: false,
2364 touchNavigation: true,
2365 touchFollowAxis: true,
2366 keyboardNavigation: true,
2367 closeOnOutsideClick: true,
2368 plugins: false,
2369 plyr: {
2370 css: 'https://cdn.plyr.io/3.6.12/plyr.css',
2371 js: 'https://cdn.plyr.io/3.6.12/plyr.js',
2372 config: {
2373 ratio: '16:9',
2374 fullscreen: {
2375 enabled: true,
2376 iosNative: true,
2377 },
2378 youtube: {
2379 noCookie: true,
2380 rel: 0,
2381 showinfo: 0,
2382 iv_load_policy: 3,
2383 },
2384 vimeo: {
2385 byline: false,
2386 portrait: false,
2387 title: false,
2388 transparent: false,
2389 },
2390 },
2391 },
2392 openEffect: 'zoom',
2393 closeEffect: 'zoom',
2394 slideEffect: 'slide',
2395 moreText: 'See more',
2396 moreLength: 60,
2397 cssEfects: {
2398 fade: {
2399 in: 'fadeIn',
2400 out: 'fadeOut',
2401 },
2402 zoom: {
2403 in: 'zoomIn',
2404 out: 'zoomOut',
2405 },
2406 slide: {
2407 in: 'slideInRight',
2408 out: 'slideOutLeft',
2409 },
2410 slideBack: {
2411 in: 'slideInLeft',
2412 out: 'slideOutRight',
2413 },
2414 none: {
2415 in: 'none',
2416 out: 'none',
2417 },
2418 },
2419 svg: {
2420 close: '<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 512 512" xml:space="preserve"><g><g><path d="M505.943,6.058c-8.077-8.077-21.172-8.077-29.249,0L6.058,476.693c-8.077,8.077-8.077,21.172,0,29.249C10.096,509.982,15.39,512,20.683,512c5.293,0,10.586-2.019,14.625-6.059L505.943,35.306C514.019,27.23,514.019,14.135,505.943,6.058z"/></g></g><g><g><path d="M505.942,476.694L35.306,6.059c-8.076-8.077-21.172-8.077-29.248,0c-8.077,8.076-8.077,21.171,0,29.248l470.636,470.636c4.038,4.039,9.332,6.058,14.625,6.058c5.293,0,10.587-2.019,14.624-6.057C514.018,497.866,514.018,484.771,505.942,476.694z"/></g></g></svg>',
2421 next: '<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 477.175 477.175" xml:space="preserve"> <g><path d="M360.731,229.075l-225.1-225.1c-5.3-5.3-13.8-5.3-19.1,0s-5.3,13.8,0,19.1l215.5,215.5l-215.5,215.5c-5.3,5.3-5.3,13.8,0,19.1c2.6,2.6,6.1,4,9.5,4c3.4,0,6.9-1.3,9.5-4l225.1-225.1C365.931,242.875,365.931,234.275,360.731,229.075z"/></g></svg>',
2422 prev: '<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 477.175 477.175" xml:space="preserve"><g><path d="M145.188,238.575l215.5-215.5c5.3-5.3,5.3-13.8,0-19.1s-13.8-5.3-19.1,0l-225.1,225.1c-5.3,5.3-5.3,13.8,0,19.1l225.1,225c2.6,2.6,6.1,4,9.5,4s6.9-1.3,9.5-4c5.3-5.3,5.3-13.8,0-19.1L145.188,238.575z"/></g></svg>',
2423 },
2424 };
2425 defaults.slideHTML =
2426 '<div class="gslide">\n <div class="gslide-inner-content">\n <div class="ginner-container">\n <div class="gslide-media">\n </div>\n <div class="gslide-description">\n <div class="gdesc-inner">\n <h4 class="gslide-title"></h4>\n <div class="gslide-desc"></div>\n </div>\n </div>\n </div>\n </div>\n</div>';
2427 defaults.lightboxHTML =
2428 '<div id="glightbox-body" class="glightbox-container" tabindex="-1" role="dialog" aria-hidden="false">\n <div class="gloader visible"></div>\n <div class="goverlay"></div>\n <div class="gcontainer">\n <div id="glightbox-slider" class="gslider"></div>\n <button class="gclose gbtn" aria-label="Close" data-taborder="3">{closeSVG}</button>\n <button class="gprev gbtn" aria-label="Previous" data-taborder="2">{prevSVG}</button>\n <button class="gnext gbtn" aria-label="Next" data-taborder="1">{nextSVG}</button>\n</div>\n</div>';
2429 var GlightboxInit = (function () {
2430 function GlightboxInit() {
2431 var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
2432 _classCallCheck(this, GlightboxInit);
2433 this.customOptions = options;
2434 this.settings = extend(defaults, options);
2435 this.effectsClasses = this.getAnimationClasses();
2436 this.videoPlayers = {};
2437 this.apiEvents = [];
2438 this.fullElementsList = false;
2439 }
2440 return _createClass(GlightboxInit, [
2441 {
2442 key: 'init',
2443 value: function init() {
2444 var _this = this;
2445 var selector = this.getSelector();
2446 if (selector) {
2447 this.baseEvents = addEvent('click', {
2448 onElement: selector,
2449 withCallback: function withCallback(e, target) {
2450 e.preventDefault();
2451 _this.open(target);
2452 },
2453 });
2454 }
2455 this.elements = this.getElements();
2456 },
2457 },
2458 {
2459 key: 'open',
2460 value: function open() {
2461 var element =
2462 arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
2463 var startAt =
2464 arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
2465 if (this.elements.length === 0) {
2466 return false;
2467 }
2468 this.activeSlide = null;
2469 this.prevActiveSlideIndex = null;
2470 this.prevActiveSlide = null;
2471 var index = isNumber(startAt) ? startAt : this.settings.startAt;
2472 if (isNode(element)) {
2473 var gallery = element.getAttribute('data-gallery');
2474 if (gallery) {
2475 this.fullElementsList = this.elements;
2476 this.elements = this.getGalleryElements(this.elements, gallery);
2477 }
2478 if (isNil(index)) {
2479 index = this.getElementIndex(element);
2480 if (index < 0) {
2481 index = 0;
2482 }
2483 }
2484 }
2485 if (!isNumber(index)) {
2486 index = 0;
2487 }
2488 this.build();
2489 animateElement(
2490 this.overlay,
2491 this.settings.openEffect === 'none'
2492 ? 'none'
2493 : this.settings.cssEfects.fade['in']
2494 );
2495 var body = document.body;
2496 var scrollBar = window.innerWidth - document.documentElement.clientWidth;
2497 if (scrollBar > 0) {
2498 var styleSheet = document.createElement('style');
2499 styleSheet.type = 'text/css';
2500 styleSheet.className = 'gcss-styles';
2501 styleSheet.innerText = '.gscrollbar-fixer {margin-right: '.concat(
2502 scrollBar,
2503 'px}'
2504 );
2505 document.head.appendChild(styleSheet);
2506 addClass(body, 'gscrollbar-fixer');
2507 }
2508 addClass(body, 'glightbox-open');
2509 addClass(html, 'glightbox-open');
2510 if (isMobile$1) {
2511 addClass(document.body, 'glightbox-mobile');
2512 this.settings.slideEffect = 'slide';
2513 }
2514 this.showSlide(index, true);
2515 if (this.elements.length === 1) {
2516 addClass(this.prevButton, 'glightbox-button-hidden');
2517 addClass(this.nextButton, 'glightbox-button-hidden');
2518 } else {
2519 removeClass(this.prevButton, 'glightbox-button-hidden');
2520 removeClass(this.nextButton, 'glightbox-button-hidden');
2521 }
2522 this.lightboxOpen = true;
2523 this.trigger('open');
2524 if (isFunction(this.settings.onOpen)) {
2525 this.settings.onOpen();
2526 }
2527 if (isTouch$1 && this.settings.touchNavigation) {
2528 touchNavigation(this);
2529 }
2530 if (this.settings.keyboardNavigation) {
2531 keyboardNavigation(this);
2532 }
2533 },
2534 },
2535 {
2536 key: 'openAt',
2537 value: function openAt() {
2538 var index =
2539 arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
2540 this.open(null, index);
2541 },
2542 },
2543 {
2544 key: 'showSlide',
2545 value: function showSlide() {
2546 var _this2 = this;
2547 var index =
2548 arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
2549 var first =
2550 arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
2551 show(this.loader);
2552 this.index = parseInt(index);
2553 var current = this.slidesContainer.querySelector('.current');
2554 if (current) {
2555 removeClass(current, 'current');
2556 }
2557 this.slideAnimateOut();
2558 var slideNode = this.slidesContainer.querySelectorAll('.gslide')[index];
2559 if (hasClass(slideNode, 'loaded')) {
2560 this.slideAnimateIn(slideNode, first);
2561 hide(this.loader);
2562 } else {
2563 show(this.loader);
2564 var slide = this.elements[index];
2565 var slideData = {
2566 index: this.index,
2567 slide: slideNode,
2568 slideNode: slideNode,
2569 slideConfig: slide.slideConfig,
2570 slideIndex: this.index,
2571 trigger: slide.node,
2572 player: null,
2573 };
2574 this.trigger('slide_before_load', slideData);
2575 slide.instance.setContent(slideNode, function () {
2576 hide(_this2.loader);
2577 _this2.resize();
2578 _this2.slideAnimateIn(slideNode, first);
2579 _this2.trigger('slide_after_load', slideData);
2580 });
2581 }
2582 this.slideDescription = slideNode.querySelector('.gslide-description');
2583 this.slideDescriptionContained =
2584 this.slideDescription &&
2585 hasClass(this.slideDescription.parentNode, 'gslide-media');
2586 if (this.settings.preload) {
2587 this.preloadSlide(index + 1);
2588 this.preloadSlide(index - 1);
2589 }
2590 this.updateNavigationClasses();
2591 this.activeSlide = slideNode;
2592 },
2593 },
2594 {
2595 key: 'preloadSlide',
2596 value: function preloadSlide(index) {
2597 var _this3 = this;
2598 if (index < 0 || index > this.elements.length - 1) {
2599 return false;
2600 }
2601 if (isNil(this.elements[index])) {
2602 return false;
2603 }
2604 var slideNode = this.slidesContainer.querySelectorAll('.gslide')[index];
2605 if (hasClass(slideNode, 'loaded')) {
2606 return false;
2607 }
2608 var slide = this.elements[index];
2609 var type = slide.type;
2610 var slideData = {
2611 index: index,
2612 slide: slideNode,
2613 slideNode: slideNode,
2614 slideConfig: slide.slideConfig,
2615 slideIndex: index,
2616 trigger: slide.node,
2617 player: null,
2618 };
2619 this.trigger('slide_before_load', slideData);
2620 if (type === 'video' || type === 'external') {
2621 setTimeout(function () {
2622 slide.instance.setContent(slideNode, function () {
2623 _this3.trigger('slide_after_load', slideData);
2624 });
2625 }, 200);
2626 } else {
2627 slide.instance.setContent(slideNode, function () {
2628 _this3.trigger('slide_after_load', slideData);
2629 });
2630 }
2631 },
2632 },
2633 {
2634 key: 'prevSlide',
2635 value: function prevSlide() {
2636 this.goToSlide(this.index - 1);
2637 },
2638 },
2639 {
2640 key: 'nextSlide',
2641 value: function nextSlide() {
2642 this.goToSlide(this.index + 1);
2643 },
2644 },
2645 {
2646 key: 'goToSlide',
2647 value: function goToSlide() {
2648 var index =
2649 arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
2650 this.prevActiveSlide = this.activeSlide;
2651 this.prevActiveSlideIndex = this.index;
2652 if (!this.loop() && (index < 0 || index > this.elements.length - 1)) {
2653 return false;
2654 }
2655 if (index < 0) {
2656 index = this.elements.length - 1;
2657 } else if (index >= this.elements.length) {
2658 index = 0;
2659 }
2660 this.showSlide(index);
2661 },
2662 },
2663 {
2664 key: 'insertSlide',
2665 value: function insertSlide() {
2666 var config =
2667 arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
2668 var index =
2669 arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : -1;
2670 if (index < 0) {
2671 index = this.elements.length;
2672 }
2673 var slide = new Slide(config, this, index);
2674 var data = slide.getConfig();
2675 var slideInfo = extend({}, data);
2676 var newSlide = slide.create();
2677 var totalSlides = this.elements.length - 1;
2678 slideInfo.index = index;
2679 slideInfo.node = false;
2680 slideInfo.instance = slide;
2681 slideInfo.slideConfig = data;
2682 this.elements.splice(index, 0, slideInfo);
2683 var addedSlideNode = null;
2684 var addedSlidePlayer = null;
2685 if (this.slidesContainer) {
2686 if (index > totalSlides) {
2687 this.slidesContainer.appendChild(newSlide);
2688 } else {
2689 var existingSlide =
2690 this.slidesContainer.querySelectorAll('.gslide')[index];
2691 this.slidesContainer.insertBefore(newSlide, existingSlide);
2692 }
2693 if (
2694 (this.settings.preload && this.index == 0 && index == 0) ||
2695 this.index - 1 == index ||
2696 this.index + 1 == index
2697 ) {
2698 this.preloadSlide(index);
2699 }
2700 if (this.index === 0 && index === 0) {
2701 this.index = 1;
2702 }
2703 this.updateNavigationClasses();
2704 addedSlideNode = this.slidesContainer.querySelectorAll('.gslide')[index];
2705 addedSlidePlayer = this.getSlidePlayerInstance(index);
2706 slideInfo.slideNode = addedSlideNode;
2707 }
2708 this.trigger('slide_inserted', {
2709 index: index,
2710 slide: addedSlideNode,
2711 slideNode: addedSlideNode,
2712 slideConfig: data,
2713 slideIndex: index,
2714 trigger: null,
2715 player: addedSlidePlayer,
2716 });
2717 if (isFunction(this.settings.slideInserted)) {
2718 this.settings.slideInserted({
2719 index: index,
2720 slide: addedSlideNode,
2721 player: addedSlidePlayer,
2722 });
2723 }
2724 },
2725 },
2726 {
2727 key: 'removeSlide',
2728 value: function removeSlide() {
2729 var index =
2730 arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : -1;
2731 if (index < 0 || index > this.elements.length - 1) {
2732 return false;
2733 }
2734 var slide =
2735 this.slidesContainer &&
2736 this.slidesContainer.querySelectorAll('.gslide')[index];
2737 if (slide) {
2738 if (this.getActiveSlideIndex() == index) {
2739 if (index == this.elements.length - 1) {
2740 this.prevSlide();
2741 } else {
2742 this.nextSlide();
2743 }
2744 }
2745 slide.parentNode.removeChild(slide);
2746 }
2747 this.elements.splice(index, 1);
2748 this.trigger('slide_removed', index);
2749 if (isFunction(this.settings.slideRemoved)) {
2750 this.settings.slideRemoved(index);
2751 }
2752 },
2753 },
2754 {
2755 key: 'slideAnimateIn',
2756 value: function slideAnimateIn(slide, first) {
2757 var _this4 = this;
2758 var slideMedia = slide.querySelector('.gslide-media');
2759 var slideDesc = slide.querySelector('.gslide-description');
2760 var prevData = {
2761 index: this.prevActiveSlideIndex,
2762 slide: this.prevActiveSlide,
2763 slideNode: this.prevActiveSlide,
2764 slideIndex: this.prevActiveSlide,
2765 slideConfig: isNil(this.prevActiveSlideIndex)
2766 ? null
2767 : this.elements[this.prevActiveSlideIndex].slideConfig,
2768 trigger: isNil(this.prevActiveSlideIndex)
2769 ? null
2770 : this.elements[this.prevActiveSlideIndex].node,
2771 player: this.getSlidePlayerInstance(this.prevActiveSlideIndex),
2772 };
2773 var nextData = {
2774 index: this.index,
2775 slide: this.activeSlide,
2776 slideNode: this.activeSlide,
2777 slideConfig: this.elements[this.index].slideConfig,
2778 slideIndex: this.index,
2779 trigger: this.elements[this.index].node,
2780 player: this.getSlidePlayerInstance(this.index),
2781 };
2782 if (slideMedia.offsetWidth > 0 && slideDesc) {
2783 hide(slideDesc);
2784 slideDesc.style.display = '';
2785 }
2786 removeClass(slide, this.effectsClasses);
2787 if (first) {
2788 animateElement(
2789 slide,
2790 this.settings.cssEfects[this.settings.openEffect]['in'],
2791 function () {
2792 if (_this4.settings.autoplayVideos) {
2793 _this4.slidePlayerPlay(slide);
2794 }
2795 _this4.trigger('slide_changed', {
2796 prev: prevData,
2797 current: nextData,
2798 });
2799 if (isFunction(_this4.settings.afterSlideChange)) {
2800 _this4.settings.afterSlideChange.apply(_this4, [
2801 prevData,
2802 nextData,
2803 ]);
2804 }
2805 }
2806 );
2807 } else {
2808 var effectName = this.settings.slideEffect;
2809 var animIn =
2810 effectName !== 'none'
2811 ? this.settings.cssEfects[effectName]['in']
2812 : effectName;
2813 if (this.prevActiveSlideIndex > this.index) {
2814 if (this.settings.slideEffect == 'slide') {
2815 animIn = this.settings.cssEfects.slideBack['in'];
2816 }
2817 }
2818 animateElement(slide, animIn, function () {
2819 if (_this4.settings.autoplayVideos) {
2820 _this4.slidePlayerPlay(slide);
2821 }
2822 _this4.trigger('slide_changed', {
2823 prev: prevData,
2824 current: nextData,
2825 });
2826 if (isFunction(_this4.settings.afterSlideChange)) {
2827 _this4.settings.afterSlideChange.apply(_this4, [
2828 prevData,
2829 nextData,
2830 ]);
2831 }
2832 });
2833 }
2834 setTimeout(function () {
2835 _this4.resize(slide);
2836 }, 100);
2837 addClass(slide, 'current');
2838 },
2839 },
2840 {
2841 key: 'slideAnimateOut',
2842 value: function slideAnimateOut() {
2843 if (!this.prevActiveSlide) {
2844 return false;
2845 }
2846 var prevSlide = this.prevActiveSlide;
2847 removeClass(prevSlide, this.effectsClasses);
2848 addClass(prevSlide, 'prev');
2849 var animation = this.settings.slideEffect;
2850 var animOut =
2851 animation !== 'none' ? this.settings.cssEfects[animation].out : animation;
2852 this.slidePlayerPause(prevSlide);
2853 this.trigger('slide_before_change', {
2854 prev: {
2855 index: this.prevActiveSlideIndex,
2856 slide: this.prevActiveSlide,
2857 slideNode: this.prevActiveSlide,
2858 slideIndex: this.prevActiveSlideIndex,
2859 slideConfig: isNil(this.prevActiveSlideIndex)
2860 ? null
2861 : this.elements[this.prevActiveSlideIndex].slideConfig,
2862 trigger: isNil(this.prevActiveSlideIndex)
2863 ? null
2864 : this.elements[this.prevActiveSlideIndex].node,
2865 player: this.getSlidePlayerInstance(this.prevActiveSlideIndex),
2866 },
2867 current: {
2868 index: this.index,
2869 slide: this.activeSlide,
2870 slideNode: this.activeSlide,
2871 slideIndex: this.index,
2872 slideConfig: this.elements[this.index].slideConfig,
2873 trigger: this.elements[this.index].node,
2874 player: this.getSlidePlayerInstance(this.index),
2875 },
2876 });
2877 if (isFunction(this.settings.beforeSlideChange)) {
2878 this.settings.beforeSlideChange.apply(this, [
2879 {
2880 index: this.prevActiveSlideIndex,
2881 slide: this.prevActiveSlide,
2882 player: this.getSlidePlayerInstance(this.prevActiveSlideIndex),
2883 },
2884 {
2885 index: this.index,
2886 slide: this.activeSlide,
2887 player: this.getSlidePlayerInstance(this.index),
2888 },
2889 ]);
2890 }
2891 if (
2892 this.prevActiveSlideIndex > this.index &&
2893 this.settings.slideEffect == 'slide'
2894 ) {
2895 animOut = this.settings.cssEfects.slideBack.out;
2896 }
2897 animateElement(prevSlide, animOut, function () {
2898 var container = prevSlide.querySelector('.ginner-container');
2899 var media = prevSlide.querySelector('.gslide-media');
2900 var desc = prevSlide.querySelector('.gslide-description');
2901 container.style.transform = '';
2902 media.style.transform = '';
2903 removeClass(media, 'greset');
2904 media.style.opacity = '';
2905 if (desc) {
2906 desc.style.opacity = '';
2907 }
2908 removeClass(prevSlide, 'prev');
2909 });
2910 },
2911 },
2912 {
2913 key: 'getAllPlayers',
2914 value: function getAllPlayers() {
2915 return this.videoPlayers;
2916 },
2917 },
2918 {
2919 key: 'getSlidePlayerInstance',
2920 value: function getSlidePlayerInstance(index) {
2921 var id = 'gvideo' + index;
2922 var videoPlayers = this.getAllPlayers();
2923 if (has(videoPlayers, id) && videoPlayers[id]) {
2924 return videoPlayers[id];
2925 }
2926 return false;
2927 },
2928 },
2929 {
2930 key: 'stopSlideVideo',
2931 value: function stopSlideVideo(slide) {
2932 if (isNode(slide)) {
2933 var node = slide.querySelector('.gvideo-wrapper');
2934 if (node) {
2935 slide = node.getAttribute('data-index');
2936 }
2937 }
2938 console.log('stopSlideVideo is deprecated, use slidePlayerPause');
2939 var player = this.getSlidePlayerInstance(slide);
2940 if (player && player.playing) {
2941 player.pause();
2942 }
2943 },
2944 },
2945 {
2946 key: 'slidePlayerPause',
2947 value: function slidePlayerPause(slide) {
2948 if (isNode(slide)) {
2949 var node = slide.querySelector('.gvideo-wrapper');
2950 if (node) {
2951 slide = node.getAttribute('data-index');
2952 }
2953 }
2954 var player = this.getSlidePlayerInstance(slide);
2955 if (player && player.playing) {
2956 player.pause();
2957 }
2958 },
2959 },
2960 {
2961 key: 'playSlideVideo',
2962 value: function playSlideVideo(slide) {
2963 if (isNode(slide)) {
2964 var node = slide.querySelector('.gvideo-wrapper');
2965 if (node) {
2966 slide = node.getAttribute('data-index');
2967 }
2968 }
2969 console.log('playSlideVideo is deprecated, use slidePlayerPlay');
2970 var player = this.getSlidePlayerInstance(slide);
2971 if (player && !player.playing) {
2972 player.play();
2973 }
2974 },
2975 },
2976 {
2977 key: 'slidePlayerPlay',
2978 value: function slidePlayerPlay(slide) {
2979 var _this$settings$plyr$c;
2980 if (
2981 isMobile$1 &&
2982 !(
2983 (_this$settings$plyr$c = this.settings.plyr.config) !== null &&
2984 _this$settings$plyr$c !== void 0 &&
2985 _this$settings$plyr$c.muted
2986 )
2987 ) {
2988 return;
2989 }
2990 if (isNode(slide)) {
2991 var node = slide.querySelector('.gvideo-wrapper');
2992 if (node) {
2993 slide = node.getAttribute('data-index');
2994 }
2995 }
2996 var player = this.getSlidePlayerInstance(slide);
2997 if (player && !player.playing) {
2998 player.play();
2999 if (this.settings.autofocusVideos) {
3000 player.elements.container.focus();
3001 }
3002 }
3003 },
3004 },
3005 {
3006 key: 'setElements',
3007 value: function setElements(elements) {
3008 var _this5 = this;
3009 this.settings.elements = false;
3010 var newElements = [];
3011 if (elements && elements.length) {
3012 each(elements, function (el, i) {
3013 var slide = new Slide(el, _this5, i);
3014 var data = slide.getConfig();
3015 var slideInfo = extend({}, data);
3016 slideInfo.slideConfig = data;
3017 slideInfo.instance = slide;
3018 slideInfo.index = i;
3019 newElements.push(slideInfo);
3020 });
3021 }
3022 this.elements = newElements;
3023 if (this.lightboxOpen) {
3024 this.slidesContainer.innerHTML = '';
3025 if (this.elements.length) {
3026 each(this.elements, function () {
3027 var slide = createHTML(_this5.settings.slideHTML);
3028 _this5.slidesContainer.appendChild(slide);
3029 });
3030 this.showSlide(0, true);
3031 }
3032 }
3033 },
3034 },
3035 {
3036 key: 'getElementIndex',
3037 value: function getElementIndex(node) {
3038 var index = false;
3039 each(this.elements, function (el, i) {
3040 if (has(el, 'node') && el.node == node) {
3041 index = i;
3042 return true;
3043 }
3044 });
3045 return index;
3046 },
3047 },
3048 {
3049 key: 'getElements',
3050 value: function getElements() {
3051 var _this6 = this;
3052 var list = [];
3053 this.elements = this.elements ? this.elements : [];
3054 if (
3055 !isNil(this.settings.elements) &&
3056 isArray(this.settings.elements) &&
3057 this.settings.elements.length
3058 ) {
3059 each(this.settings.elements, function (el, i) {
3060 var slide = new Slide(el, _this6, i);
3061 var elData = slide.getConfig();
3062 var slideInfo = extend({}, elData);
3063 slideInfo.node = false;
3064 slideInfo.index = i;
3065 slideInfo.instance = slide;
3066 slideInfo.slideConfig = elData;
3067 list.push(slideInfo);
3068 });
3069 }
3070 var nodes = false;
3071 var selector = this.getSelector();
3072 if (selector) {
3073 nodes = document.querySelectorAll(this.getSelector());
3074 }
3075 if (!nodes) {
3076 return list;
3077 }
3078 each(nodes, function (el, i) {
3079 var slide = new Slide(el, _this6, i);
3080 var elData = slide.getConfig();
3081 var slideInfo = extend({}, elData);
3082 slideInfo.node = el;
3083 slideInfo.index = i;
3084 slideInfo.instance = slide;
3085 slideInfo.slideConfig = elData;
3086 slideInfo.gallery = el.getAttribute('data-gallery');
3087 list.push(slideInfo);
3088 });
3089 return list;
3090 },
3091 },
3092 {
3093 key: 'getGalleryElements',
3094 value: function getGalleryElements(list, gallery) {
3095 return list.filter(function (el) {
3096 return el.gallery == gallery;
3097 });
3098 },
3099 },
3100 {
3101 key: 'getSelector',
3102 value: function getSelector() {
3103 if (this.settings.elements) {
3104 return false;
3105 }
3106 if (
3107 this.settings.selector &&
3108 this.settings.selector.substring(0, 5) == 'data-'
3109 ) {
3110 return '*['.concat(this.settings.selector, ']');
3111 }
3112 return this.settings.selector;
3113 },
3114 },
3115 {
3116 key: 'getActiveSlide',
3117 value: function getActiveSlide() {
3118 return this.slidesContainer.querySelectorAll('.gslide')[this.index];
3119 },
3120 },
3121 {
3122 key: 'getActiveSlideIndex',
3123 value: function getActiveSlideIndex() {
3124 return this.index;
3125 },
3126 },
3127 {
3128 key: 'getAnimationClasses',
3129 value: function getAnimationClasses() {
3130 var effects = [];
3131 for (var key in this.settings.cssEfects) {
3132 if (this.settings.cssEfects.hasOwnProperty(key)) {
3133 var effect = this.settings.cssEfects[key];
3134 effects.push('g'.concat(effect['in']));
3135 effects.push('g'.concat(effect.out));
3136 }
3137 }
3138 return effects.join(' ');
3139 },
3140 },
3141 {
3142 key: 'build',
3143 value: function build() {
3144 var _this7 = this;
3145 if (this.built) {
3146 return false;
3147 }
3148 var children = document.body.childNodes;
3149 var bodyChildElms = [];
3150 each(children, function (el) {
3151 if (
3152 el.parentNode == document.body &&
3153 el.nodeName.charAt(0) !== '#' &&
3154 el.hasAttribute &&
3155 !el.hasAttribute('aria-hidden')
3156 ) {
3157 bodyChildElms.push(el);
3158 el.setAttribute('aria-hidden', 'true');
3159 }
3160 });
3161 var nextSVG = has(this.settings.svg, 'next') ? this.settings.svg.next : '';
3162 var prevSVG = has(this.settings.svg, 'prev') ? this.settings.svg.prev : '';
3163 var closeSVG = has(this.settings.svg, 'close') ? this.settings.svg.close : '';
3164 var lightboxHTML = this.settings.lightboxHTML;
3165 lightboxHTML = lightboxHTML.replace(/{nextSVG}/g, nextSVG);
3166 lightboxHTML = lightboxHTML.replace(/{prevSVG}/g, prevSVG);
3167 lightboxHTML = lightboxHTML.replace(/{closeSVG}/g, closeSVG);
3168 lightboxHTML = createHTML(lightboxHTML);
3169 document.body.appendChild(lightboxHTML);
3170 var modal = document.getElementById('glightbox-body');
3171 this.modal = modal;
3172 var closeButton = modal.querySelector('.gclose');
3173 this.prevButton = modal.querySelector('.gprev');
3174 this.nextButton = modal.querySelector('.gnext');
3175 this.overlay = modal.querySelector('.goverlay');
3176 this.loader = modal.querySelector('.gloader');
3177 this.slidesContainer = document.getElementById('glightbox-slider');
3178 this.bodyHiddenChildElms = bodyChildElms;
3179 this.events = {};
3180 addClass(this.modal, 'glightbox-' + this.settings.skin);
3181 if (this.settings.closeButton && closeButton) {
3182 this.events['close'] = addEvent('click', {
3183 onElement: closeButton,
3184 withCallback: function withCallback(e, target) {
3185 e.preventDefault();
3186 _this7.close();
3187 },
3188 });
3189 }
3190 if (closeButton && !this.settings.closeButton) {
3191 closeButton.parentNode.removeChild(closeButton);
3192 }
3193 if (this.nextButton) {
3194 this.events['next'] = addEvent('click', {
3195 onElement: this.nextButton,
3196 withCallback: function withCallback(e, target) {
3197 e.preventDefault();
3198 _this7.nextSlide();
3199 },
3200 });
3201 }
3202 if (this.prevButton) {
3203 this.events['prev'] = addEvent('click', {
3204 onElement: this.prevButton,
3205 withCallback: function withCallback(e, target) {
3206 e.preventDefault();
3207 _this7.prevSlide();
3208 },
3209 });
3210 }
3211 if (this.settings.closeOnOutsideClick) {
3212 this.events['outClose'] = addEvent('click', {
3213 onElement: modal,
3214 withCallback: function withCallback(e, target) {
3215 if (
3216 !_this7.preventOutsideClick &&
3217 !hasClass(document.body, 'glightbox-mobile') &&
3218 !closest(e.target, '.ginner-container')
3219 ) {
3220 if (
3221 !closest(e.target, '.gbtn') &&
3222 !hasClass(e.target, 'gnext') &&
3223 !hasClass(e.target, 'gprev')
3224 ) {
3225 _this7.close();
3226 }
3227 }
3228 },
3229 });
3230 }
3231 each(this.elements, function (slide, i) {
3232 _this7.slidesContainer.appendChild(slide.instance.create());
3233 slide.slideNode = _this7.slidesContainer.querySelectorAll('.gslide')[i];
3234 });
3235 if (isTouch$1) {
3236 addClass(document.body, 'glightbox-touch');
3237 }
3238 this.events['resize'] = addEvent('resize', {
3239 onElement: window,
3240 withCallback: function withCallback() {
3241 _this7.resize();
3242 },
3243 });
3244 this.built = true;
3245 },
3246 },
3247 {
3248 key: 'resize',
3249 value: function resize() {
3250 var slide =
3251 arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
3252 slide = !slide ? this.activeSlide : slide;
3253 if (!slide || hasClass(slide, 'zoomed')) {
3254 return;
3255 }
3256 var winSize = windowSize();
3257 var video = slide.querySelector('.gvideo-wrapper');
3258 var image = slide.querySelector('.gslide-image');
3259 var description = this.slideDescription;
3260 var winWidth = winSize.width;
3261 var winHeight = winSize.height;
3262 if (winWidth <= 768) {
3263 addClass(document.body, 'glightbox-mobile');
3264 } else {
3265 removeClass(document.body, 'glightbox-mobile');
3266 }
3267 if (!video && !image) {
3268 return;
3269 }
3270 var descriptionResize = false;
3271 if (
3272 description &&
3273 (hasClass(description, 'description-bottom') ||
3274 hasClass(description, 'description-top')) &&
3275 !hasClass(description, 'gabsolute')
3276 ) {
3277 descriptionResize = true;
3278 }
3279 if (image) {
3280 if (winWidth <= 768) {
3281 var imgNode = image.querySelector('img');
3282 } else if (descriptionResize) {
3283 var _this$elements$this$i;
3284 var descHeight = description.offsetHeight;
3285 var _imgNode = image.querySelector('img');
3286 var slideTriggerNode =
3287 (_this$elements$this$i = this.elements[this.index]) === null ||
3288 _this$elements$this$i === void 0
3289 ? void 0
3290 : _this$elements$this$i.node;
3291 var maxHeightValue = '100vh';
3292 if (slideTriggerNode) {
3293 var _slideTriggerNode$get;
3294 maxHeightValue =
3295 (_slideTriggerNode$get =
3296 slideTriggerNode.getAttribute('data-height')) !== null &&
3297 _slideTriggerNode$get !== void 0
3298 ? _slideTriggerNode$get
3299 : maxHeightValue;
3300 }
3301 _imgNode.setAttribute(
3302 'style',
3303 'max-height: calc('
3304 .concat(maxHeightValue, ' - ')
3305 .concat(descHeight, 'px)')
3306 );
3307 description.setAttribute(
3308 'style',
3309 'max-width: '.concat(_imgNode.offsetWidth, 'px;')
3310 );
3311 }
3312 }
3313 if (video) {
3314 var ratio = has(this.settings.plyr.config, 'ratio')
3315 ? this.settings.plyr.config.ratio
3316 : '';
3317 if (!ratio) {
3318 var containerWidth = video.clientWidth;
3319 var containerHeight = video.clientHeight;
3320 var divisor = containerWidth / containerHeight;
3321 ratio = ''
3322 .concat(containerWidth / divisor, ':')
3323 .concat(containerHeight / divisor);
3324 }
3325 var videoRatio = ratio.split(':');
3326 var videoWidth = this.settings.videosWidth;
3327 var maxWidth = this.settings.videosWidth;
3328 if (isNumber(videoWidth) || videoWidth.indexOf('px') !== -1) {
3329 maxWidth = parseInt(videoWidth);
3330 } else {
3331 if (videoWidth.indexOf('vw') !== -1) {
3332 maxWidth = (winWidth * parseInt(videoWidth)) / 100;
3333 } else if (videoWidth.indexOf('vh') !== -1) {
3334 maxWidth = (winHeight * parseInt(videoWidth)) / 100;
3335 } else if (videoWidth.indexOf('%') !== -1) {
3336 maxWidth = (winWidth * parseInt(videoWidth)) / 100;
3337 } else {
3338 maxWidth = parseInt(video.clientWidth);
3339 }
3340 }
3341 var maxHeight =
3342 maxWidth / (parseInt(videoRatio[0]) / parseInt(videoRatio[1]));
3343 maxHeight = Math.floor(maxHeight);
3344 if (descriptionResize) {
3345 winHeight = winHeight - description.offsetHeight;
3346 }
3347 if (
3348 maxWidth > winWidth ||
3349 maxHeight > winHeight ||
3350 (winHeight < maxHeight && winWidth > maxWidth)
3351 ) {
3352 var vwidth = video.offsetWidth;
3353 var vheight = video.offsetHeight;
3354 var _ratio = winHeight / vheight;
3355 var vsize = {
3356 width: vwidth * _ratio,
3357 height: vheight * _ratio,
3358 };
3359 video.parentNode.setAttribute(
3360 'style',
3361 'max-width: '.concat(vsize.width, 'px')
3362 );
3363 if (descriptionResize) {
3364 description.setAttribute(
3365 'style',
3366 'max-width: '.concat(vsize.width, 'px;')
3367 );
3368 }
3369 } else {
3370 video.parentNode.style.maxWidth = ''.concat(videoWidth);
3371 if (descriptionResize) {
3372 description.setAttribute(
3373 'style',
3374 'max-width: '.concat(videoWidth, ';')
3375 );
3376 }
3377 }
3378 }
3379 },
3380 },
3381 {
3382 key: 'reload',
3383 value: function reload() {
3384 this.init();
3385 },
3386 },
3387 {
3388 key: 'updateNavigationClasses',
3389 value: function updateNavigationClasses() {
3390 var loop = this.loop();
3391 removeClass(this.nextButton, 'disabled');
3392 removeClass(this.prevButton, 'disabled');
3393 if (this.index == 0 && this.elements.length - 1 == 0) {
3394 addClass(this.prevButton, 'disabled');
3395 addClass(this.nextButton, 'disabled');
3396 } else if (this.index === 0 && !loop) {
3397 addClass(this.prevButton, 'disabled');
3398 } else if (this.index === this.elements.length - 1 && !loop) {
3399 addClass(this.nextButton, 'disabled');
3400 }
3401 },
3402 },
3403 {
3404 key: 'loop',
3405 value: function loop() {
3406 var loop = has(this.settings, 'loopAtEnd') ? this.settings.loopAtEnd : null;
3407 loop = has(this.settings, 'loop') ? this.settings.loop : loop;
3408 return loop;
3409 },
3410 },
3411 {
3412 key: 'close',
3413 value: function close() {
3414 var _this8 = this;
3415 if (!this.lightboxOpen) {
3416 if (this.events) {
3417 for (var key in this.events) {
3418 if (this.events.hasOwnProperty(key)) {
3419 this.events[key].destroy();
3420 }
3421 }
3422 this.events = null;
3423 }
3424 return false;
3425 }
3426 if (this.closing) {
3427 return false;
3428 }
3429 this.closing = true;
3430 this.slidePlayerPause(this.activeSlide);
3431 if (this.fullElementsList) {
3432 this.elements = this.fullElementsList;
3433 }
3434 if (this.bodyHiddenChildElms.length) {
3435 each(this.bodyHiddenChildElms, function (el) {
3436 el.removeAttribute('aria-hidden');
3437 });
3438 }
3439 addClass(this.modal, 'glightbox-closing');
3440 animateElement(
3441 this.overlay,
3442 this.settings.openEffect == 'none'
3443 ? 'none'
3444 : this.settings.cssEfects.fade.out
3445 );
3446 animateElement(
3447 this.activeSlide,
3448 this.settings.cssEfects[this.settings.closeEffect].out,
3449 function () {
3450 _this8.activeSlide = null;
3451 _this8.prevActiveSlideIndex = null;
3452 _this8.prevActiveSlide = null;
3453 _this8.built = false;
3454 if (_this8.events) {
3455 for (var _key in _this8.events) {
3456 if (_this8.events.hasOwnProperty(_key)) {
3457 _this8.events[_key].destroy();
3458 }
3459 }
3460 _this8.events = null;
3461 }
3462 var body = document.body;
3463 removeClass(html, 'glightbox-open');
3464 removeClass(
3465 body,
3466 'glightbox-open touching gdesc-open glightbox-touch glightbox-mobile gscrollbar-fixer'
3467 );
3468 _this8.modal.parentNode.removeChild(_this8.modal);
3469 _this8.trigger('close');
3470 if (isFunction(_this8.settings.onClose)) {
3471 _this8.settings.onClose();
3472 }
3473 var styles = document.querySelector('.gcss-styles');
3474 if (styles) {
3475 styles.parentNode.removeChild(styles);
3476 }
3477 _this8.lightboxOpen = false;
3478 _this8.closing = null;
3479 }
3480 );
3481 },
3482 },
3483 {
3484 key: 'destroy',
3485 value: function destroy() {
3486 this.close();
3487 this.clearAllEvents();
3488 if (this.baseEvents) {
3489 this.baseEvents.destroy();
3490 }
3491 },
3492 },
3493 {
3494 key: 'on',
3495 value: function on(evt, callback) {
3496 var once =
3497 arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
3498 if (!evt || !isFunction(callback)) {
3499 throw new TypeError('Event name and callback must be defined');
3500 }
3501 this.apiEvents.push({
3502 evt: evt,
3503 once: once,
3504 callback: callback,
3505 });
3506 },
3507 },
3508 {
3509 key: 'once',
3510 value: function once(evt, callback) {
3511 this.on(evt, callback, true);
3512 },
3513 },
3514 {
3515 key: 'trigger',
3516 value: function trigger(eventName) {
3517 var _this9 = this;
3518 var data =
3519 arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
3520 var onceTriggered = [];
3521 each(this.apiEvents, function (event, i) {
3522 var evt = event.evt,
3523 once = event.once,
3524 callback = event.callback;
3525 if (evt == eventName) {
3526 callback(data);
3527 if (once) {
3528 onceTriggered.push(i);
3529 }
3530 }
3531 });
3532 if (onceTriggered.length) {
3533 each(onceTriggered, function (i) {
3534 return _this9.apiEvents.splice(i, 1);
3535 });
3536 }
3537 },
3538 },
3539 {
3540 key: 'clearAllEvents',
3541 value: function clearAllEvents() {
3542 this.apiEvents.splice(0, this.apiEvents.length);
3543 },
3544 },
3545 {
3546 key: 'version',
3547 value: function version() {
3548 return _version;
3549 },
3550 },
3551 ]);
3552 })();
3553 function glightbox() {
3554 var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
3555 var instance = new GlightboxInit(options);
3556 instance.init();
3557 return instance;
3558 }
3559
3560 return glightbox;
3561 });
3562