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