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