vendor: 5,921 bytes, lines 1-202
1// http://paulirish.com/2011/requestanimationframe-for-smart-animating/ 2// http://my.opera.com/emoller/blog/2011/12/20/requestanimationframe-for-smart-er-animating 3// requestAnimationFrame polyfill by Erik Möller. fixes from Paul Irish and Tino Zijdel 4// MIT license 5 6(function () { 7 var lastTime = 0; 8 var vendors = ['ms', 'moz', 'webkit', 'o']; 9 for (var x = 0; x < vendors.length && !window.requestAnimationFrame; ++x) { 10 window.requestAnimationFrame = window[vendors[x] + 'RequestAnimationFrame']; 11 window.cancelAnimationFrame = window[vendors[x] + 'CancelAnimationFrame'] || 12 window[vendors[x] + 'CancelRequestAnimationFrame']; 13 } 14 15 if (!window.requestAnimationFrame) 16 window.requestAnimationFrame = function (callback, element) { 17 var currTime = new Date().getTime(); 18 var timeToCall = Math.max(0, 16 - (currTime - lastTime)); 19 var id = window.setTimeout(function () { 20 callback(currTime + timeToCall); 21 }, 22 timeToCall); 23 lastTime = currTime + timeToCall; 24 return id; 25 }; 26 27 if (!window.cancelAnimationFrame) 28 window.cancelAnimationFrame = function (id) { 29 clearTimeout(id); 30 }; 31}()); 32 33(function (root) { 34 35 // Store setTimeout reference so promise-polyfill will be unaffected by 36 // other code modifying setTimeout (like sinon.useFakeTimers()) 37 var setTimeoutFunc = setTimeout; 38 39 function noop() {} 40 41 // Polyfill for Function.prototype.bind 42 function bind(fn, thisArg) { 43 return function () { 44 fn.apply(thisArg, arguments); 45 }; 46 } 47 48 function Promise(fn) { 49 if (typeof this !== 'object') throw new TypeError('Promises must be constructed via new'); 50 if (typeof fn !== 'function') throw new TypeError('not a function'); 51 this._state = 0; 52 this._handled = false; 53 this._value = undefined; 54 this._deferreds = []; 55 56 doResolve(fn, this); 57 } 58 59 function handle(self, deferred) { 60 while (self._state === 3) { 61 self = self._value; 62 } 63 if (self._state === 0) { 64 self._deferreds.push(deferred); 65 return; 66 } 67 self._handled = true; 68 Promise._immediateFn(function () { 69 var cb = self._state === 1 ? deferred.onFulfilled : deferred.onRejected; 70 if (cb === null) { 71 (self._state === 1 ? resolve : reject)(deferred.promise, self._value); 72 return; 73 } 74 var ret; 75 try { 76 ret = cb(self._value); 77 } catch (e) { 78 reject(deferred.promise, e); 79 return; 80 } 81 resolve(deferred.promise, ret); 82 }); 83 } 84 85 function resolve(self, newValue) { 86 try { 87 // Promise Resolution Procedure: https://github.com/promises-aplus/promises-spec#the-promise-resolution-procedure 88 if (newValue === self) throw new TypeError('A promise cannot be resolved with itself.'); 89 if (newValue && (typeof newValue === 'object' || typeof newValue === 'function')) { 90 var then = newValue.then; 91 if (newValue instanceof Promise) { 92 self._state = 3; 93 self._value = newValue; 94 finale(self); 95 return; 96 } else if (typeof then === 'function') { 97 doResolve(bind(then, newValue), self); 98 return; 99 } 100 } 101 self._state = 1; 102 self._value = newValue; 103 finale(self); 104 } catch (e) { 105 reject(self, e); 106 } 107 } 108 109 function reject(self, newValue) { 110 self._state = 2; 111 self._value = newValue; 112 finale(self); 113 } 114 115 function finale(self) { 116 if (self._state === 2 && self._deferreds.length === 0) { 117 Promise._immediateFn(function () { 118 if (!self._handled) { 119 Promise._unhandledRejectionFn(self._value); 120 } 121 }); 122 } 123 124 for (var i = 0, len = self._deferreds.length; i < len; i++) { 125 handle(self, self._deferreds[i]); 126 } 127 self._deferreds = null; 128 } 129 130 function Handler(onFulfilled, onRejected, promise) { 131 this.onFulfilled = typeof onFulfilled === 'function' ? onFulfilled : null; 132 this.onRejected = typeof onRejected === 'function' ? onRejected : null; 133 this.promise = promise; 134 } 135 136 /** 137 * Take a potentially misbehaving resolver function and make sure 138 * onFulfilled and onRejected are only called once. 139 * 140 * Makes no guarantees about asynchrony. 141 */ 142 function doResolve(fn, self) { 143 var done = false; 144 try { 145 fn(function (value) { 146 if (done) return; 147 done = true; 148 resolve(self, value); 149 }, function (reason) { 150 if (done) return; 151 done = true; 152 reject(self, reason); 153 }); 154 } catch (ex) { 155 if (done) return; 156 done = true; 157 reject(self, ex); 158 } 159 } 160 161 Promise.prototype['catch'] = function (onRejected) { 162 return this.then(null, onRejected); 163 }; 164 165 Promise.prototype.then = function (onFulfilled, onRejected) { 166 var prom = new(this.constructor)(noop); 167 168 handle(this, new Handler(onFulfilled, onRejected, prom)); 169 return prom; 170 }; 171 172 Promise.all = function (arr) { 173 var args = Array.prototype.slice.call(arr); 174 175 return new Promise(function (resolve, reject) { 176 if (args.length === 0) return resolve([]); 177 var remaining = args.length; 178 179 function res(i, val) { 180 try { 181 if (val && (typeof val === 'object' || typeof val === 'function')) { 182 var then = val.then; 183 if (typeof then === 'function') { 184 then.call(val, function (val) { 185 res(i, val); 186 }, reject); 187 return; 188 } 189 } 190 args[i] = val; 191 if (--remaining === 0) { 192 resolve(args); 193 } 194 } catch (ex) { 195 reject(ex); 196 } 197 } 198 199 for (var i = 0; i < args.length; i++) { 200 res(i, args[i]); 201 } 202 });
203 }; 204 205 Promise.resolve = function (value) { 206 if (value && typeof value === 'object' && value.constructor === Promise) { 207 return value; 208 } 209 210 return new Promise(function (resolve) { 211 resolve(value); 212 }); 213 }; 214 215 Promise.reject = function (value) { 216 return new Promise(function (resolve, reject) { 217 reject(value); 218 }); 219 }; 220 221 Promise.race = function (values) { 222 return new Promise(function (resolve, reject) { 223 for (var i = 0, len = values.length; i < len; i++) { 224 values[i].then(resolve, reject); 225 } 226 }); 227 }; 228 229 // Use polyfill for setImmediate for performance gains 230 Promise._immediateFn = (typeof setImmediate === 'function' && function (fn) { 231 setImmediate(fn); 232 }) || 233 function (fn) { 234 setTimeoutFunc(fn, 0); 235 }; 236 237 Promise._unhandledRejectionFn = function _unhandledRejectionFn(err) { 238 if (typeof console !== 'undefined' && console) { 239 console.warn('Possible Unhandled Promise Rejection:', err); // eslint-disable-line no-console 240 } 241 }; 242 243 /** 244 * Set the immediate function to execute callbacks 245 * @param fn {function} Function to execute 246 * @deprecated 247 */ 248 Promise._setImmediateFn = function _setImmediateFn(fn) { 249 Promise._immediateFn = fn; 250 }; 251 252 /** 253 * Change the function to execute on unhandled rejection 254 * @param {function} fn Function to execute on unhandled rejection 255 * @deprecated 256 */ 257 Promise._setUnhandledRejectionFn = function _setUnhandledRejectionFn(fn) { 258 Promise._unhandledRejectionFn = fn; 259 }; 260 261 if (typeof module !== 'undefined' && module.exports) { 262 module.exports = Promise; 263 } else if (!root.Promise) { 264 root.Promise = Promise; 265 } 266 267})(this); 268 269 270 271 272 273 274 275 276 277 278/*! @source http://purl.eligrey.com/github/classList.js/blob/master/classList.js*/ 279; 280if ("document" in self && !("classList" in document.createElement("_"))) { 281 (function (j) { 282 "use strict"; 283 if (!("Element" in j)) { 284 return 285 } 286 var a = "classList", 287 f = "prototype", 288 m = j.Element[f], 289 b = Object, 290 k = String[f].trim || function () { 291 return this.replace(/^\s+|\s+$/g, "") 292 }, 293 c = Array[f].indexOf || function (q) { 294 var p = 0, 295 o = this.length; 296 for (; p < o; p++) { 297 if (p in this && this[p] === q) { 298 return p 299 } 300 } 301 return -1 302 }, 303 n = function (o, p) { 304 this.name = o; 305 this.code = DOMException[o]; 306 this.message = p 307 }, 308 g = function (p, o) { 309 if (o === "") { 310 throw new n("SYNTAX_ERR", "An invalid or illegal string was specified") 311 } 312 if (/\s/.test(o)) { 313 throw new n("INVALID_CHARACTER_ERR", "String contains an invalid character") 314 } 315 return c.call(p, o) 316 }, 317 d = function (s) { 318 var r = k.call(s.getAttribute("class") || ""), 319 q = r ? r.split(/\s+/) : [], 320 p = 0, 321 o = q.length; 322 for (; p < o; p++) { 323 this.push(q[p]) 324 } 325 this._updateClassName = function () { 326 s.setAttribute("class", this.toString()) 327 } 328 }, 329 e = d[f] = [], 330 i = function () { 331 return new d(this) 332 }; 333 n[f] = Error[f]; 334 e.item = function (o) { 335 return this[o] || null 336 }; 337 e.contains = function (o) { 338 o += ""; 339 return g(this, o) !== -1 340 }; 341 e.add = function () { 342 var s = arguments, 343 r = 0, 344 p = s.length, 345 q, o = false; 346 do { 347 q = s[r] + ""; 348 if (g(this, q) === -1) { 349 this.push(q); 350 o = true 351 } 352 } while (++r < p); 353 if (o) { 354 this._updateClassName() 355 } 356 }; 357 e.remove = function () { 358 var t = arguments, 359 s = 0, 360 p = t.length, 361 r, o = false; 362 do { 363 r = t[s] + ""; 364 var q = g(this, r); 365 if (q !== -1) { 366 this.splice(q, 1); 367 o = true 368 } 369 } while (++s < p); 370 if (o) { 371 this._updateClassName() 372 } 373 }; 374 e.toggle = function (p, q) { 375 p += ""; 376 var o = this.contains(p), 377 r = o ? q !== true && "remove" : q !== false && "add"; 378 if (r) { 379 this[r](p) 380 } 381 return !o 382 }; 383 e.toString = function () { 384 return this.join(" ") 385 }; 386 if (b.defineProperty) { 387 var l = { 388 get: i, 389 enumerable: true, 390 configurable: true 391 };
392 try { 393 b.defineProperty(m, a, l) 394 } catch (h) { 395 if (h.number === -2146823252) { 396 l.enumerable = false; 397 b.defineProperty(m, a, l) 398 } 399 } 400 } else { 401 if (b[f].__defineGetter__) { 402 m.__defineGetter__(a, i) 403 } 404 } 405 }(self)) 406}; 407 408 409 410 411 412/** 413 * Input Placeholder Polyfill 414 * MIT Licensed 415 * Created by Christopher Rolfe 416 */ 417if (!('placeholder' in document.createElement("input"))) { 418 419 // Get all the inputs 420 var inputs = document.getElementsByTagName('input'); 421 422 // Loop over them 423 for (var i = 0; i < inputs.length; i++) { 424 // If they don't have a preset value 425 if (!inputs[i].value) { 426 // The set the placeholder 427 inputs[i].value = inputs[i].getAttribute('placeholder'); 428 } 429 430 // Attach event listeners for click and blur 431 // Click so that we can clear the placeholder if we need to 432 // Blur to re-add it if needed 433 if (inputs[i].addEventListener) { 434 inputs[i].addEventListener('click', hidePlaceholderOnFocus, false); 435 inputs[i].addEventListener('blur', unfocusOnAnElement, false); 436 } else if (inputs[i].attachEvent) { 437 inputs[i].attachEvent('onclick', hidePlaceholderOnFocus); 438 inputs[i].attachEvent('onblur', unfocusOnAnElement); 439 } 440 } 441 442 /** 443 * When the input value is the same as the placeholder clear it 444 */ 445 function hidePlaceholderOnFocus(event) { 446 target = (event.currentTarget) ? event.currentTarget : event.srcElement; 447 448 if (target.value == target.getAttribute('placeholder')) { 449 target.value = ''; 450 } 451 } 452 453 /** 454 * When the input has an empty value put the placeholder back in 455 */ 456 function unfocusOnAnElement(event) { 457 target = (event.currentTarget) ? event.currentTarget : event.srcElement; 458 459 if (target.value == '') { 460 target.value = target.getAttribute('placeholder'); 461 } 462 } 463} 464 465(function polyfillRequestFullscreen() { 466 if (!Element.prototype.requestFullscreen) { 467 if (Element.prototype.webkitRequestFullscreen) { 468 Element.prototype.requestFullscreen = Element.prototype.webkitRequestFullScreen; 469 } else if (Element.prototype.mozRequestFullScreen) { 470 Element.prototype.requestFullscreen = Element.prototype.mozRequestFullScreen; 471 } 472 } 473})(); 474 475(function polyfillExitFullscreen() { 476 if (!Document.prototype.exitFullscreen) { 477 if (Document.prototype.webkitExitFullscreen) { 478 Document.prototype.exitFullscreen = Document.prototype.webkitExitFullscreen; 479 } else if (Document.prototype.mozExitFullScreen) { 480 Document.prototype.exitFullscreen = Document.prototype.mozExitFullScreen; 481 } 482 } 483})(); 484 485(function polyfillClosest() { 486 if (!Element.prototype.matches) 487 Element.prototype.matches = Element.prototype.msMatchesSelector || 488 Element.prototype.webkitMatchesSelector; 489 490 if (!Element.prototype.closest) { 491 Element.prototype.closest = function (s) { 492 var el = this; 493 if (!document.documentElement.contains(el)) return null; 494 do { 495 if (el.matches(s)) return el; 496 el = el.parentElement || el.parentNode; 497 } while (el !== null && el.nodeType === 1); 498 return null; 499 }; 500 } 501})(); 502var lightboxApp; 503(function () { 504 document.addEventListener('DOMContentLoaded', function () { 505 var appOptions = new Templates.Components.LightboxApplicationOptions(); 506 var app = new Templates.Components.LightboxApplication(appOptions); 507 app.init(); 508 lightboxApp = app; 509 }); 510})(); 511var Templates; 512(function (Templates) { 513 var Components; 514 (function (Components) { 515 var LightboxWindow = (function () { 516 function LightboxWindow() { 517 this.translations = {}; 518 this._mode = 'DetailView'; 519 this._images = []; 520 this._currentIndex = 0; 521 } 522 Object.defineProperty(LightboxWindow.prototype, "element", { 523 get: function () { 524 return this._element; 525 }, 526 enumerable: false, 527 configurable: true 528 }); 529 Object.defineProperty(LightboxWindow.prototype, "mode", { 530 get: function () { 531 return this._mode; 532 }, 533 enumerable: false, 534 configurable: true 535 }); 536 Object.defineProperty(LightboxWindow.prototype, "images", { 537 get: function () { 538 return this._images; 539 }, 540 enumerable: false, 541 configurable: true 542 }); 543 LightboxWindow.prototype.init = function () { 544 var _this = this; 545 this.bindFunctions(); 546 if (window.StandardTemplateTranslations) { 547 var translations = window.StandardTemplateTranslations; 548 var map = {}; 549 for (var i = 0, length_1 = translations.length; i < length_1; i++) { 550 var translation = translations[i]; 551 map[translation.key] = translation.value; 552 } 553 this.translations = map; 554 } 555 var overlayElement = document.createElement('div'); 556 overlayElement.className = 'ac-lightbox-overlay'; 557 var lightboxElement = document.createElement('div'); 558 lightboxElement.className = 'ac-lightbox'; 559 overlayElement.appendChild(lightboxElement); 560 var headerElement = document.createElement('div'); 561 headerElement.className = 'ac-lightbox-header'; 562 lightboxElement.appendChild(headerElement); 563 var fullScreenToggleElement = document.createElement('button'); 564 fullScreenToggleElement.className = 'ac-lightbox-button ac-lightbox-button--fullscreen'; 565 fullScreenToggleElement.type = 'button'; 566 fullScreenToggleElement.addEventListener('click', function () { 567 if (_this._isFullscreen) { 568 fullScreenToggleElement.classList.remove('ac-lightbox-button--fullscreen-open'); 569 } 570 else { 571 fullScreenToggleElement.classList.add('ac-lightbox-button--fullscreen-open'); 572 } 573 _this.toggleFullscreen(); 574 }); 575 headerElement.appendChild(fullScreenToggleElement); 576 var fullScreenToggleTextElement = document.createElement('span'); 577 fullScreenToggleTextElement.textContent = this.translate('Templates.Components.Lightbox.Fullscreen') || 'Fullscreen'; 578 fullScreenToggleTextElement.className = 'ac-visually-hidden'; 579 fullScreenToggleElement.appendChild(fullScreenToggleTextElement); 580 var lightboxIndexTextElement = document.createElement('div'); 581 lightboxIndexTextElement.className = 'ac-lightbox-index-indicator'; 582 lightboxIndexTextElement.textContent = '0 / 0'; 583 headerElement.appendChild(lightboxIndexTextElement); 584 this._indexTextElement = lightboxIndexTextElement; 585 var lightboxIndexTextLabelElement = document.createElement('span'); 586 lightboxIndexTextLabelElement.className = 'ac-visually-hidden'; 587 lightboxIndexTextLabelElement.textContent = "".concat(this.translate('Templates.Components.Lightbox.Image'), " "); 588 this._indexTextElement.appendChild(lightboxIndexTextLabelElement); 589 var lightboxModeButtonElement = document.createElement('button'); 590 lightboxModeButtonElement.className = 'ac-lightbox-button ac-lightbox-button--mode'; 591 lightboxModeButtonElement.type = 'button'; 592 lightboxModeButtonElement.addEventListener('click', function (event) { 593 _this.toggleView(); 594 }); 595 headerElement.appendChild(lightboxModeButtonElement); 596 this._modeButtonElement = lightboxModeButtonElement; 597 var lightboxModeButtonTextElement = document.createElement('span'); 598 lightboxModeButtonTextElement.className = 'ac-lightbox-button-text'; 599 lightboxModeButtonTextElement.textContent = (this.mode === 'DetailVie
599w') ? this.translate('Templates.Components.Lightbox.ListView') : this.translate('Templates.Components.Lightbox.DetailView'); 600 lightboxModeButtonElement.appendChild(lightboxModeButtonTextElement); 601 this._modeButtonTextElement = lightboxModeButtonTextElement; 602 var closeButtonElement = document.createElement('button'); 603 closeButtonElement.className = 'ac-lightbox-button ac-lightbox-button--close'; 604 closeButtonElement.type = 'button'; 605 closeButtonElement.addEventListener('click', function (event) { 606 _this.close(); 607 }); 608 headerElement.appendChild(closeButtonElement); 609 this._closeButtonElement = closeButtonElement; 610 var closeButtonTextElement = document.createElement('span'); 611 closeButtonTextElement.className = 'ac-lightbox-button-text'; 612 closeButtonTextElement.textContent = this.translate('Templates.Components.Lightbox.Close'); 613 closeButtonElement.appendChild(closeButtonTextElement); 614 var bodyElement = document.createElement('div'); 615 bodyElement.className = 'ac-lightbox-body'; 616 lightboxElement.appendChild(bodyElement); 617 this._bodyElement = bodyElement; 618 var footerElement = document.createElement('div'); 619 footerElement.className = 'ac-lightbox-footer'; 620 lightboxElement.appendChild(footerElement); 621 var previousImageButtonElement = document.createElement('button'); 622 previousImageButtonElement.className = 'ac-lightbox-button ac-lightbox-button--previous'; 623 previousImageButtonElement.type = 'button'; 624 previousImageButtonElement.addEventListener('click', function (event) { 625 _this.showPreviousImage(); 626 }); 627 footerElement.appendChild(previousImageButtonElement); 628 this._previousImageButtonElement = previousImageButtonElement; 629 var previousImageButtonTextElement = document.createElement('span'); 630 previousImageButtonTextElement.className = 'ac-lightbox-button-text'; 631 previousImageButtonTextElement.textContent = this.translate('Templates.Components.Lightbox.PreviousImage'); 632 previousImageButtonElement.appendChild(previousImageButtonTextElement); 633 var nextImageButtonElement = document.createElement('button'); 634 nextImageButtonElement.className = 'ac-lightbox-button ac-lightbox-button--next'; 635 nextImageButtonElement.type = 'button'; 636 nextImageButtonElement.addEventListener('click', function (event) { 637 _this.showNextImage(); 638 }); 639 footerElement.appendChild(nextImageButtonElement); 640 this._nextImageButtonElement = nextImageButtonElement; 641 var nextImageButtonTextElement = document.createElement('span'); 642 nextImageButtonTextElement.className = 'ac-lightbox-button-text'; 643 nextImageButtonTextElement.textContent = this.translate('Templates.Components.Lightbox.NextImage'); 644 nextImageButtonElement.appendChild(nextImageButtonTextElement); 645 this._element = overlayElement; 646 document.addEventListener('keydown', function (event) { 647 var keyCode = event.which || event.keyCode; 648 if (event.keyCode === 9) { 649 if (_this.isOpen()) { 650 var focusableElements = overlayElement.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])'); 651 var firstFocusableElement = focusableElements[0]; 652 var lastFocusableElement = focusableElements[focusableElements.length - 1]; 653 var targetElement = event.target; 654 if (!targetElement.closest('.ac-lightbox-overlay')) { 655 event.preventDefault(); 656 } 657 else { 658 if (event.target === lastFocusableElement && !event.shiftKey) { 659 event.preventDefault(); 660 firstFocusableElement.focus(); 661 } 662 else if (event.target === firstFocusableElement && event.shiftKey) { 663 event.preventDefault(); 664 lastFocusableElement.focus(); 665 } 666 } 667 } 668 } 669 }); 670 document.addEventListener('keyup', function (event) { 671 var keyCode = event.which || event.keyCode; 672 if (keyCode === 27) { 673 _this.close(); 674 } 675 }); 676 document.addEventListener('fullscreenchange', function (event) { 677 var notFullscreen = !document.fullscreen && !document.fullscreenEnabled && !document.webkitFullscreenElement && !document.mozFullscreenElement; 678 if (notFullscreen) { 679 _this.exitFullscreen(); 680 } 681 }); 682 this.addSwipeGestures(); 683 }; 684 LightboxWindow.prototype.translate = function (key) { 685 return this.translations[key]; 686 }; 687 LightboxWindow.prototype.clear = function () { 688 this._images = []; 689 this._currentIndex = 0; 690 }; 691 LightboxWindow.prototype.addImage = function (image) { 692 this._images.push(image); 693 }; 694 LightboxWindow.prototype.open = function (startIndex, initiator) { 695 this._currentIndex = startIndex; 696 this._currentInitiator = initiator;
697 this.showDetailView(); 698 this.element.className = 'ac-lightbox-overlay ac-lightbox-overlay--open'; 699 }; 700 LightboxWindow.prototype.close = function () { 701 if (this._currentInitiator) { 702 this._currentInitiator.focus(); 703 } 704 this._currentInitiator = null; 705 this.element.className = 'ac-lightbox-overlay'; 706 this.exitFullscreen(); 707 }; 708 LightboxWindow.prototype.bindFunctions = function () { 709 this.toggleFullscreen = this.toggleFullscreen.bind(this); 710 }; 711 LightboxWindow.prototype.toggleView = function () { 712 if (this.mode === 'DetailView') { 713 this.showListView(); 714 } 715 else { 716 this.showDetailView(); 717 } 718 }; 719 LightboxWindow.prototype.showDetailView = function () { 720 var _this = this; 721 this._mode = 'DetailView'; 722 this._indexTextElement.textContent = "".concat(this._currentIndex + 1, " ").concat(this.translate('Templates.Components.Lightbox.Of'), " ").concat(this.images.length); 723 this._modeButtonElement.classList.remove('detail-view'); 724 this._modeButtonTextElement.textContent = this.translate('Templates.Components.Lightbox.ListView'); 725 this._nextImageButtonElement.hidden = false; 726 this._nextImageButtonElement.disabled = !this.hasNextImage(); 727 this._previousImageButtonElement.hidden = false; 728 this._previousImageButtonElement.disabled = !this.hasPreviousImage(); 729 setTimeout(function () { 730 if (!_this.hasNextImage()) { 731 if (!_this.hasPreviousImage()) { 732 _this._closeButtonElement.focus(); 733 } 734 else { 735 _this._previousImageButtonElement.focus(); 736 } 737 } 738 else if (!_this.hasPreviousImage()) { 739 if (!_this.hasNextImage()) { 740 _this._closeButtonElement.focus(); 741 } 742 else { 743 _this._nextImageButtonElement.focus(); 744 } 745 } 746 }, 100); 747 this.clearBodyContent(); 748 if (this.images.length > 0) { 749 var currentImage = this.images[this._currentIndex]; 750 var imageElement = document.createElement('img'); 751 imageElement.className = 'ac-lightbox-image'; 752 imageElement.src = currentImage.imageUrl; 753 imageElement.alt = currentImage.alttext; 754 this._bodyElement.appendChild(imageElement); 755 if (currentImage.description) { 756 var descriptionElement = document.createElement('div'); 757 descriptionElement.className = 'ac-lightbox-image-description'; 758 descriptionElement.innerHTML = currentImage.description; 759 this._bodyElement.appendChild(descriptionElement); 760 } 761 } 762 }; 763 LightboxWindow.prototype.isOpen = function () { 764 return this.element.classList.contains('ac-lightbox-overlay--open'); 765 }; 766 LightboxWindow.prototype.hasPreviousImage = function () { 767 return this._currentIndex > 0; 768 }; 769 LightboxWindow.prototype.hasNextImage = function () { 770 return this._currentIndex < this.images.length - 1; 771 }; 772 LightboxWindow.prototype.showPreviousImage = function () { 773 if (this.hasPreviousImage()) { 774 this._currentIndex--;
775 this.showDetailView(); 776 } 777 }; 778 LightboxWindow.prototype.showNextImage = function () { 779 if (this.hasNextImage()) { 780 this._currentIndex++; 781 this.showDetailView(); 782 } 783 }; 784 LightboxWindow.prototype.showListView = function () { 785 var _this = this; 786 this._mode = 'ListView'; 787 this._modeButtonElement.classList.add('detail-view'); 788 this._modeButtonTextElement.textContent = this.translate('Templates.Components.Lightbox.DetailView'); 789 this._nextImageButtonElement.hidden = true; 790 this._previousImageButtonElement.hidden = true; 791 setTimeout(function () { _this._closeButtonElement.focus(); }, 100); 792 this.clearBodyContent(); 793 if (this.images.length > 0) { 794 var ulElement = document.createElement('ul'); 795 ulElement.className = 'ac-lightbox-thumbnail-list'; 796 var _loop_1 = function (j, length_2) { 797 var image = this_1.images[j]; 798 var liElement = document.createElement('li'); 799 liElement.className = 'ac-lightbox-thumbnail'; 800 ulElement.appendChild(liElement); 801 var anchorElement = document.createElement('a'); 802 anchorElement.className = 'ac-lightbox-thumbnail-anchor'; 803 anchorElement.href = '#'; 804 anchorElement.addEventListener('click', function (event) { 805 event.preventDefault(); 806 _this._currentIndex = j; 807 _this.toggleView(); 808 setTimeout(function () { 809 if (!_this.hasNextImage()) { 810 if (!_this.hasPreviousImage()) { 811 _this._closeButtonElement.focus(); 812 } 813 else { 814 _this._previousImageButtonElement.focus(); 815 } 816 } 817 else if (!_this.hasPreviousImage()) { 818 if (!_this.hasNextImage()) { 819 _this._closeButtonElement.focus(); 820 } 821 else { 822 _this._nextImageButtonElement.focus(); 823 } 824 } 825 else { 826 _this._nextImageButtonElement.focus(); 827 } 828 }, 100); 829 }); 830 liElement.appendChild(anchorElement); 831 var imageElement = document.createElement('img'); 832 imageElement.className = 'ac-lightbox-thumbnail-image'; 833 imageElement.src = image.thumbnailUrl; 834 imageElement.alt = image.alttext; 835 anchorElement.appendChild(imageElement); 836 }; 837 var this_1 = this; 838 for (var j = 0, length_2 = this.images.length; j < length_2; j++) { 839 _loop_1(j, length_2); 840 } 841 this._bodyElement.appendChild(ulElement); 842 } 843 }; 844 LightboxWindow.prototype.clearBodyContent = function () { 845 while (this._bodyElement.firstChild) { 846 this._bodyElement.removeChild(this._bodyElement.firstChild); 847 } 848 }; 849 LightboxWindow.prototype.requestFullscreen = function () { 850 if (this._isFullscreen) { 851 return; 852 } 853 if (this.supportsFullscreen()) { 854 this._element.requestFullscreen(); 855 } 856 this._isFullscreen = true; 857 this._element.classList.add('ac-lightbox-overlay--fullscreen'); 858 }; 859 LightboxWindow.prototype.exitFullscreen = function () { 860 if (!this._isFullscreen) { 861 return; 862 } 863 if (this.supportsFullscreen()) { 864 document.exitFullscreen(); 865 } 866 this._isFullscreen = false; 867 this._element.classList.remove('ac-lightbox-overlay--fullscreen'); 868 }; 869 LightboxWindow.prototype.toggleFullscreen = function () { 870 if (this._isFullscreen) { 871 this.exitFullscreen(); 872 } 873 else { 874 this.requestFullscreen(); 875 } 876 }; 877 LightboxWindow.prototype.supportsFullscreen = function () { 878 return (!!document.body.requestFullscreen && !!document.exitFullscreen); 879 }; 880 LightboxWindow.prototype.addSwipeGestures = function () { 881 this._element.addEventListener('mousedown', lock.bind(this)); 882 this._element.addEventListener('touchstart', lock.bind(this)); 883 this._element.addEventListener('mouseup', move.bind(this)); 884 this._element.addEventListener('touchend', move.bind(this)); 885 var x0 = null; 886 function lock(event) { 887 x0 = unify(event).clientX; 888 } 889 function move(event) {
890 if (this._mode !== 'DetailView') { 891 return; 892 } 893 if (x0 || x0 === 0) { 894 var dx = unify(event).clientX - x0; 895 var movingToTheLeft = dx < 0; 896 var movingToTheRight = dx > 0; 897 if (movingToTheLeft) { 898 this.showNextImage(); 899 } 900 else if (movingToTheRight) { 901 this.showPreviousImage(); 902 } 903 x0 = null; 904 } 905 } 906 function unify(event) { 907 return event.changedTouches ? event.changedTouches[0] : event; 908 } 909 }; 910 return LightboxWindow; 911 }()); 912 Components.LightboxWindow = LightboxWindow; 913 var LightboxImage = (function () { 914 function LightboxImage() { 915 } 916 return LightboxImage; 917 }()); 918 Components.LightboxImage = LightboxImage; 919 var LightboxApplicationOptions = (function () { 920 function LightboxApplicationOptions() { 921 this.anchorSelector = '.js-lightbox-image-anchor'; 922 this.imageSelector = '.js-lightbox-image'; 923 this.collectionSelector = '.js-lightbox-image-collection'; 924 this.imageUrlDataAttributteName = 'data-lightbox-image-url'; 925 this.thumbnailUrlDataAttributteName = 'data-lightbox-thumbnail-url'; 926 this.descriptionDataAttributteName = 'data-lightbox-image-description'; 927 this.alttextDataAttributteName = 'data-lightbox-image-alttext'; 928 } 929 return LightboxApplicationOptions; 930 }()); 931 Components.LightboxApplicationOptions = LightboxApplicationOptions; 932 var LightboxApplication = (function () { 933 function LightboxApplication(options) { 934 var _this = this; 935 this.clickHandler = function (e) { 936 e.preventDefault(); 937 var anchorElements = document.body.querySelectorAll(_this.options.anchorSelector); 938 var anchorElement = event.currentTarget; 939 _this.window.clear(); 940 var _imageElements = []; 941 var _imageElement = anchorElement.querySelector(_this.options.imageSelector); 942 if (_imageElement) { 943 var imageCollectionElement = anchorElement.closest(_this.options.collectionSelector); 944 if (imageCollectionElement) { 945 var imageElements = imageCollectionElement.querySelectorAll(_this.options.imageSelector); 946 if (imageElements) { 947 for (var j = 0, length_3 = imageElements.length; j < length_3; j++) { 948 var imageElement = imageElements[j]; 949 var imageUrl = imageElement.getAttribute(_this.options.imageUrlDataAttributteName); 950 var thumbnailUrl = imageElement.getAttribute(_this.options.thumbnailUrlDataAttributteName); 951 var description = imageElement.getAttribute(_this.options.descriptionDataAttributteName); 952 var alttext = imageElement.getAttribute(_this.options.alttextDataAttributteName); 953 if (imageUrl && thumbnailUrl) { 954 var image = new LightboxImage(); 955 image.imageUrl = imageUrl; 956 image.thumbnailUrl = thumbnailUrl; 957 image.description = description; 958 image.alttext = alttext; 959 _this.window.addImage(image); 960 _imageElements.push(imageElement); 961 } 962 } 963 } 964 } 965 else { 966 for (var j = 0, length_4 = anchorElements.length; j < length_4; j++) { 967 var ab = anchorElements[j]; 968 if (!ab.closest(_this.options.collectionSelector)) { 969 var imageElement = ab.querySelector(_this.options.imageSelector); 970 if (imageElement) { 971 var imageUrl = imageElement.getAttribute(_this.options.imageUrlDataAttributteName); 972 var thumbnailUrl = imageElement.getAttribute(_this.options.thumbnailUrlDataAttributteName); 973 var description = imageElement.getAttribute(_this.options.descriptionDataAttributteName); 974 var alttext = imageElement.getAttribute(_this.options.alttextDataAttributteName); 975 if (imageUrl && thumbnailUrl) { 976 var image = new LightboxImage(); 977 image.imageUrl = imageUrl; 978 image.thumbnailUrl = thumbnailUrl; 979 image.description = description; 980 image.alttext = alttext; 981 _this.window.addImage(image); 982 _imageElements.push(imageElement); 983 } 984 } 985 } 986 } 987 } 988 var imageIndex = ([].slice.call(_imageElements)).indexOf(_imageElement); 989 _this.window.open(imageIndex, anchorElement); 990 } 991 }; 992 this._options = options; 993 this._window = new Components.LightboxWindow(); 994 } 995 Object.defineProperty(LightboxApplication.prototype, "options", { 996 get: function () { 997 return this._options; 998 }, 999 enumerable: false, 1000 configurable: true 1001 }); 1002 Object.defineProperty(LightboxApplication.prototype, "window", { 1003 get: function () { 1004 return this._window; 1005 }, 1006 enumerable: false, 1007 configurable: true 1008 }); 1009 LightboxApplication.prototype.init = function () { 1010 var _this = this; 1011 this.window.init(); 1012 document.body.appendChild(this.window.element); 1013 this.bindAnchors();
1014 if (window.eventBus) { 1015 window.eventBus.addEventListener('init-lightbox', function (event) { 1016 _this.bindAnchors(); 1017 }); 1018 window.eventBus.addEventListener('show-container', function (event) { 1019 _this.bindAnchors(); 1020 }); 1021 } 1022 }; 1023 ; 1024 LightboxApplication.prototype.bindAnchors = function () { 1025 var anchorElements = document.body.querySelectorAll(this.options.anchorSelector); 1026 if (anchorElements) { 1027 for (var i = 0, length_5 = anchorElements.length; i < length_5; i++) { 1028 var anchorElement = anchorElements[i]; 1029 anchorElement.removeEventListener('click', this.clickHandler); 1030 anchorElement.addEventListener('click', this.clickHandler); 1031 } 1032 } 1033 }; 1034 return LightboxApplication; 1035 }()); 1036 Components.LightboxApplication = LightboxApplication; 1037 })(Components = Templates.Components || (Templates.Components = {})); 1038})(Templates || (Templates = {}));
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.