1/*! lightgallery - v1.7.0 - 2020-05-03 2* http://sachinchoolur.github.io/lightGallery/ 3* Copyright (c) 2020 Sachin N; Licensed GPLv3 */ 4/*! lightgallery - v1.7.0 - 2020-05-03 5* http://sachinchoolur.github.io/lightGallery/ 6* Copyright (c) 2020 Sachin N; Licensed GPLv3 */ 7(function (root, factory) { 8 if (typeof define === 'function' && define.amd) { 9 // AMD. Register as an anonymous module unless amdModuleId is set 10 define(['jquery'], function (a0) { 11 return (factory(a0)); 12 }); 13 } else if (typeof module === 'object' && module.exports) { 14 // Node. Does not work with strict CommonJS, but 15 // only CommonJS-like environments that support module.exports, 16 // like Node. 17 module.exports = factory(require('jquery')); 18 } else { 19 factory(root["jQuery"]); 20 } 21}(this, function ($) { 22 23(function() { 24 'use strict'; 25 26 var defaults = { 27 28 mode: 'lg-slide', 29 30 // Ex : 'ease' 31 cssEasing: 'ease', 32 33 //'for jquery animation' 34 easing: 'linear', 35 speed: 600, 36 height: '100%', 37 width: '100%', 38 addClass: '', 39 startClass: 'lg-start-zoom', 40 backdropDuration: 150, 41 hideBarsDelay: 6000, 42 43 useLeft: false, 44 45 // aria-labelledby attribute fot gallery 46 ariaLabelledby: '', 47 48 //aria-describedby attribute for gallery 49 ariaDescribedby: '', 50 51 closable: true, 52 loop: true, 53 escKey: true, 54 keyPress: true, 55 controls: true, 56 slideEndAnimatoin: true, 57 hideControlOnEnd: false, 58 mousewheel: true, 59 60 getCaptionFromTitleOrAlt: true, 61 62 // .lg-item || '.lg-sub-html' 63 appendSubHtmlTo: '.lg-sub-html', 64 65 subHtmlSelectorRelative: false, 66 67 /** 68 * @desc number of preload slides 69 * will exicute only after the current slide is fully loaded. 70 * 71 * @ex you clicked on 4th image and if preload = 1 then 3rd slide and 5th 72 * slide will be loaded in the background after the 4th slide is fully loaded.. 73 * if preload is 2 then 2nd 3rd 5th 6th slides will be preloaded.. ... ... 74 * 75 */ 76 preload: 1, 77 showAfterLoad: true, 78 selector: '', 79 selectWithin: '', 80 nextHtml: '', 81 prevHtml: '', 82 83 // 0, 1 84 index: false, 85 86 iframeMaxWidth: '100%', 87 88 download: true, 89 counter: true, 90 appendCounterTo: '.lg-toolbar', 91 92 swipeThreshold: 50, 93 enableSwipe: true, 94 enableDrag: true, 95 96 dynamic: false, 97 dynamicEl: [], 98 galleryId: 1 99 }; 100 101 function Plugin(element, options) { 102 103 // Current lightGallery element 104 this.el = element; 105 106 // Current jquery element 107 this.$el = $(element); 108 109 // lightGallery settings 110 this.s = $.extend({}, defaults, options); 111 112 // When using dynamic mode, ensure dynamicEl is an array 113 if (this.s.dynamic && this.s.dynamicEl !== 'undefined' && this.s.dynamicEl.constructor === Array && !this.s.dynamicEl.length) { 114 throw ('When using dynamic mode, you must also define dynamicEl as an Array.'); 115 } 116 117 // lightGallery modules 118 this.modules = {}; 119 120 // false when lightgallery complete first slide; 121 this.lGalleryOn = false; 122 123 this.lgBusy = false; 124 125 // Timeout function for hiding controls; 126 this.hideBartimeout = false; 127 128 // To determine browser supports for touch events; 129 this.isTouch = ('ontouchstart' in document.documentElement); 130 131 // Disable hideControlOnEnd if sildeEndAnimation is true 132 if (this.s.slideEndAnimatoin) { 133 this.s.hideControlOnEnd = false; 134 } 135 136 // Gallery items 137 if (this.s.dynamic) { 138 this.$items = this.s.dynamicEl; 139 } else { 140 if (this.s.selector === 'this') { 141 this.$items = this.$el; 142 } else if (this.s.selector !== '') { 143 if (this.s.selectWithin) { 144 this.$items = $(this.s.selectWithin).find(this.s.selector); 145 } else { 146 this.$items = this.$el.find($(this.s.selector)); 147 } 148 } else { 149 this.$items = this.$el.children(); 150 } 151 } 152 153 // .lg-item 154 this.$slide = ''; 155 156 // .lg-outer 157 this.$outer = ''; 158 159 this.init(); 160 161 return this; 162 } 163 164 Plugin.prototype.init = function() { 165 166 var _this = this; 167 168 // s.preload should not be more than $item.length 169 if (_this.s.preload > _this.$items.length) { 170 _this.s.preload = _this.$items.length; 171 } 172 173 // if dynamic option is enabled execute immediately 174 var _hash = window.location.hash; 175 if (_hash.indexOf('lg=' + this.s.galleryId) > 0) { 176 177 _this.index = parseInt(_hash.split('&slide=')[1], 10); 178 179 $('body').addClass('lg-from-hash'); 180 if (!$('body').hasClass('lg-on')) { 181 setTimeout(function() { 182 _this.build(_this.index); 183 }); 184 185 $('body').addClass('lg-on'); 186 } 187 } 188 189 if (_this.s.dynamic) { 190 191 _this.$el.trigger('onBeforeOpen.lg'); 192 193 _this.index = _this.s.index || 0; 194 195 // prevent accidental double execution 196 if (!$('body').hasClass('lg-on')) { 197 setTimeout(function() { 198 _this.build(_this.index); 199 $('body').addClass('lg-on'); 200 }); 201 } 202 } else { 203 204 // Using different namespace for click because click event should not unbind if selector is same object('this') 205 _this.$items.on('click.lgcustom', function(event) { 206 207 // For IE8 208 try { 209 event.preventDefault(); 210 event.preventDefault(); 211 } catch (er) { 212 event.returnValue = false;
213 } 214 215 _this.$el.trigger('onBeforeOpen.lg'); 216 217 _this.index = _this.s.index || _this.$items.index(this); 218 219 // prevent accidental double execution 220 if (!$('body').hasClass('lg-on')) { 221 _this.build(_this.index); 222 $('body').addClass('lg-on'); 223 } 224 }); 225 } 226 227 }; 228 229 Plugin.prototype.build = function(index) { 230 231 var _this = this; 232 233 _this.structure(); 234 235 // module constructor 236 $.each($.fn.lightGallery.modules, function(key) { 237 _this.modules[key] = new $.fn.lightGallery.modules[key](_this.el); 238 }); 239 240 // initiate slide function 241 _this.slide(index, false, false, false); 242 243 if (_this.s.keyPress) { 244 _this.keyPress(); 245 } 246 247 if (_this.$items.length > 1) { 248 249 _this.arrow(); 250 251 setTimeout(function() { 252 _this.enableDrag(); 253 _this.enableSwipe(); 254 }, 50); 255 256 if (_this.s.mousewheel) { 257 _this.mousewheel(); 258 } 259 } else { 260 _this.$slide.on('click.lg', function() { 261 _this.$el.trigger('onSlideClick.lg'); 262 }); 263 } 264 265 _this.counter(); 266 267 _this.closeGallery(); 268 269 _this.$el.trigger('onAfterOpen.lg'); 270 271 // Hide controllers if mouse doesn't move for some period 272 _this.$outer.on('mousemove.lg click.lg touchstart.lg', function() { 273 274 _this.$outer.removeClass('lg-hide-items'); 275 276 clearTimeout(_this.hideBartimeout); 277 278 // Timeout will be cleared on each slide movement also 279 _this.hideBartimeout = setTimeout(function() { 280 _this.$outer.addClass('lg-hide-items'); 281 }, _this.s.hideBarsDelay); 282 283 }); 284 285 _this.$outer.trigger('mousemove.lg'); 286 287 }; 288 289 Plugin.prototype.structure = function() { 290 var list = ''; 291 var controls = ''; 292 var i = 0; 293 var subHtmlCont = ''; 294 var template; 295 var _this = this; 296 297 $('body').append('<div class="lg-backdrop"></div>'); 298 $('.lg-backdrop').css('transition-duration', this.s.backdropDuration + 'ms'); 299 300 // Create gallery items 301 for (i = 0; i < this.$items.length; i++) { 302 list += '<div class="lg-item"></div>'; 303 } 304 305 // Create controlls 306 if (this.s.controls && this.$items.length > 1) { 307 controls = '<div class="lg-actions">' + 308 '<button aria-label="Previous slide" class="lg-prev lg-icon">' + this.s.prevHtml + '</button>' + 309 '<button aria-label="Next slide" class="lg-next lg-icon">' + this.s.nextHtml + '</button>' + 310 '</div>'; 311 } 312 313 if (this.s.appendSubHtmlTo === '.lg-sub-html') { 314 subHtmlCont = '<div role="status" aria-live="polite" class="lg-sub-html"></div>'; 315 } 316 317 var ariaLabelledby = this.s.ariaLabelledby ? 318 'aria-labelledby="' + this.s.ariaLabelledby + '"' : ''; 319 var ariaDescribedby = this.s.ariaDescribedby ? 320 'aria-describedby="' + this.s.ariaDescribedby + '"' : ''; 321 322 template = '<div tabindex="-1" aria-modal="true" ' + ariaLabelledby + ' ' + ariaDescribedby + ' role="dialog" class="lg-outer ' + this.s.addClass + ' ' + this.s.startClass + '">' + 323 '<div class="lg" style="width:' + this.s.width + '; height:' + this.s.height + '">' + 324 '<div class="lg-inner">' + list + '</div>' + 325 '<div class="lg-toolbar lg-group">' + 326 '<button aria-label="Close gallery" class="lg-close lg-icon"></button>' + 327 '</div>' + 328 controls + 329 subHtmlCont + 330 '</div>' + 331 '</div>'; 332 333 $('body').append(template); 334 this.$outer = $('.lg-outer'); 335 this.$outer.focus(); 336 this.$slide = this.$outer.find('.lg-item'); 337 338 if (this.s.useLeft) { 339 this.$outer.addClass('lg-use-left'); 340 341 // Set mode lg-slide if use left is true; 342 this.s.mode = 'lg-slide'; 343 } else { 344 this.$outer.addClass('lg-use-css3'); 345 } 346 347 // For fixed height gallery 348 _this.setTop(); 349 $(window).on('resize.lg orientationchange.lg', function() { 350 setTimeout(function() { 351 _this.setTop(); 352 }, 100); 353 }); 354 355 // add class lg-current to remove initial transition 356 this.$slide.eq(this.index).addClass('lg-current'); 357
358 // add Class for css support and transition mode 359 if (this.doCss()) { 360 this.$outer.addClass('lg-css3'); 361 } else { 362 this.$outer.addClass('lg-css'); 363 364 // Set speed 0 because no animation will happen if browser doesn't support css3 365 this.s.speed = 0; 366 } 367 368 this.$outer.addClass(this.s.mode); 369 370 if (this.s.enableDrag && this.$items.length > 1) { 371 this.$outer.addClass('lg-grab'); 372 } 373 374 if (this.s.showAfterLoad) { 375 this.$outer.addClass('lg-show-after-load'); 376 } 377 378 if (this.doCss()) { 379 var $inner = this.$outer.find('.lg-inner'); 380 $inner.css('transition-timing-function', this.s.cssEasing); 381 $inner.css('transition-duration', this.s.speed + 'ms'); 382 } 383 384 setTimeout(function() { 385 $('.lg-backdrop').addClass('in'); 386 }); 387 388 setTimeout(function() { 389 _this.$outer.addClass('lg-visible'); 390 }, this.s.backdropDuration); 391 392 if (this.s.download) { 393 this.$outer.find('.lg-toolbar').append('<a id="lg-download" aria-label="Download" target="_blank" download class="lg-download lg-icon"></a>'); 394 } 395 396 // Store the current scroll top value to scroll back after closing the gallery.. 397 this.prevScrollTop = $(window).scrollTop(); 398 399 }; 400 401 // For fixed height gallery 402 Plugin.prototype.setTop = function() { 403 if (this.s.height !== '100%') { 404 var wH = $(window).height(); 405 var top = (wH - parseInt(this.s.height, 10)) / 2; 406 var $lGallery = this.$outer.find('.lg'); 407 if (wH >= parseInt(this.s.height, 10)) { 408 $lGallery.css('top', top + 'px'); 409 } else { 410 $lGallery.css('top', '0px'); 411 } 412 } 413 }; 414 415 // Find css3 support 416 Plugin.prototype.doCss = function() { 417 // check for css animation support 418 var support = function() { 419 var transition = ['transition', 'MozTransition', 'WebkitTransition', 'OTransition', 'msTransition', 'KhtmlTransition']; 420 var root = document.documentElement; 421 var i = 0; 422 for (i = 0; i < transition.length; i++) { 423 if (transition[i] in root.style) { 424 return true; 425 } 426 } 427 }; 428 429 if (support()) { 430 return true; 431 } 432 433 return false; 434 }; 435 436 /** 437 * @desc Check the given src is video 438 * @param {String} src 439 * @return {Object} video type 440 * Ex:{ youtube : ["//www.youtube.com/watch?v=c0asJgSyxcY", "c0asJgSyxcY"] } 441 */ 442 Plugin.prototype.isVideo = function(src, index) { 443 444 var html; 445 if (this.s.dynamic) { 446 html = this.s.dynamicEl[index].html; 447 } else { 448 html = this.$items.eq(index).attr('data-html'); 449 } 450 451 if (!src) { 452 if (html) { 453 return { 454 html5: true 455 }; 456 } else { 457 console.error('lightGallery :- data-src is not provided on slide item ' + (index + 1) + '. Please make sure the selector property is properly configured. More info - http://sachinchoolur.github.io/lightGallery/demos/html-markup.html'); 458 return false; 459 } 460 } 461 462 var youtube = src.match(/\/\/(?:www\.)?youtu(?:\.be|be\.com|be-nocookie\.com)\/(?:watch\?v=|embed\/)?([a-z0-9\-\_\%]+)/i); 463 var vimeo = src.match(/\/\/(?:www\.)?vimeo.com\/([0-9a-z\-_]+)/i); 464 var dailymotion = src.match(/\/\/(?:www\.)?dai.ly\/([0-9a-z\-_]+)/i); 465 var vk = src.match(/\/\/(?:www\.)?(?:vk\.com|vkontakte\.ru)\/(?:video_ext\.php\?)(.*)/i); 466 467 if (youtube) { 468 return { 469 youtube: youtube 470 }; 471 } else if (vimeo) { 472 return { 473 vimeo: vimeo 474 }; 475 } else if (dailymotion) { 476 return { 477 dailymotion: dailymotion 478 }; 479 } else if (vk) { 480 return { 481 vk: vk 482 }; 483 } 484 }; 485 486 /** 487 * @desc Create image counter 488 * Ex: 1/10 489 */ 490 Plugin.prototype.counter = function() { 491 if (this.s.counter) { 492 $(this.s.appendCounterTo).append('<div id="lg-counter" role="status" aria-l
492ive="polite"><span id="lg-counter-current">' + (parseInt(this.index, 10) + 1) + '</span> / <span id="lg-counter-all">' + this.$items.length + '</span></div>'); 493 } 494 }; 495 496 /** 497 * @desc add sub-html into the slide 498 * @param {Number} index - index of the slide 499 */ 500 Plugin.prototype.addHtml = function(index) { 501 var subHtml = null; 502 var subHtmlUrl; 503 var $currentEle; 504 if (this.s.dynamic) { 505 if (this.s.dynamicEl[index].subHtmlUrl) { 506 subHtmlUrl = this.s.dynamicEl[index].subHtmlUrl; 507 } else { 508 subHtml = this.s.dynamicEl[index].subHtml; 509 } 510 } else { 511 $currentEle = this.$items.eq(index); 512 if ($currentEle.attr('data-sub-html-url')) { 513 subHtmlUrl = $currentEle.attr('data-sub-html-url'); 514 } else { 515 subHtml = $currentEle.attr('data-sub-html'); 516 if (this.s.getCaptionFromTitleOrAlt && !subHtml) { 517 subHtml = $currentEle.attr('title') || $currentEle.find('img').first().attr('alt'); 518 } 519 } 520 } 521 522 if (!subHtmlUrl) { 523 if (typeof subHtml !== 'undefined' && subHtml !== null) { 524 525 // get first letter of subhtml 526 // if first letter starts with . or # get the html form the jQuery object 527 var fL = subHtml.substring(0, 1); 528 if (fL === '.' || fL === '#') { 529 if (this.s.subHtmlSelectorRelative && !this.s.dynamic) { 530 subHtml = $currentEle.find(subHtml).html(); 531 } else { 532 subHtml = $(subHtml).html(); 533 } 534 } 535 } else { 536 subHtml = ''; 537 } 538 } 539 540 if (this.s.appendSubHtmlTo === '.lg-sub-html') { 541 542 if (subHtmlUrl) { 543 this.$outer.find(this.s.appendSubHtmlTo).load(subHtmlUrl); 544 } else { 545 this.$outer.find(this.s.appendSubHtmlTo).html(subHtml); 546 } 547 548 } else { 549 550 if (subHtmlUrl) { 551 this.$slide.eq(index).load(subHtmlUrl); 552 } else { 553 this.$slide.eq(index).append(subHtml); 554 } 555 } 556 557 // Add lg-empty-html class if title doesn't exist 558 if (typeof subHtml !== 'undefined' && subHtml !== null) { 559 if (subHtml === '') { 560 this.$outer.find(this.s.appendSubHtmlTo).addClass('lg-empty-html'); 561 } else { 562 this.$outer.find(this.s.appendSubHtmlTo).removeClass('lg-empty-html'); 563 } 564 } 565 566 this.$el.trigger('onAfterAppendSubHtml.lg', [index]); 567 }; 568 569 /** 570 * @desc Preload slides 571 * @param {Number} index - index of the slide 572 */ 573 Plugin.prototype.preload = function(index) { 574 var i = 1; 575 var j = 1; 576 for (i = 1; i <= this.s.preload; i++) { 577 if (i >= this.$items.length - index) { 578 break; 579 } 580 581 this.loadContent(index + i, false, 0); 582 } 583 584 for (j = 1; j <= this.s.preload; j++) { 585 if (index - j < 0) { 586 break; 587 } 588 589 this.loadContent(index - j, false, 0); 590 } 591 }; 592 593 /** 594 * @desc Load slide content into slide. 595 * @param {Number} index - index of the slide. 596 * @param {Boolean} rec - if true call loadcontent() function again. 597 * @param {Boolean} delay - delay for adding complete class. it is 0 except first time. 598 */ 599 Plugin.prototype.loadContent = function(index, rec, delay) { 600 601 var _this = this; 602 var _hasPoster = false; 603 var _$img; 604 var _src; 605 var _poster; 606 var _srcset; 607 var _sizes; 608 var _html; 609 var _alt; 610 var getResponsiveSrc = function(srcItms) { 611 var rsWidth = []; 612 var rsSrc = []; 613 for (var i = 0; i < srcItms.length; i++) { 614 var __src = srcItms[i].split(' '); 615 616 // Manage empty space 617 if (__src[0] === '') { 618 __src.splice(0, 1); 619 } 620 621 rsSrc.push(__src[0]); 622 rsWidth.push(__src[1]); 623 } 624 625 var wWidth = $(window).width(); 626 for (var j = 0; j < rsWidth.length; j++) { 627 if (parseInt(rsWidth[j], 10) >
627 wWidth) { 628 _src = rsSrc[j]; 629 break; 630 } 631 } 632 }; 633 634 if (_this.s.dynamic) { 635 636 if (_this.s.dynamicEl[index].poster) { 637 _hasPoster = true; 638 _poster = _this.s.dynamicEl[index].poster; 639 } 640 641 _html = _this.s.dynamicEl[index].html; 642 _src = _this.s.dynamicEl[index].src; 643 _alt = _this.s.dynamicEl[index].alt; 644 645 if (_this.s.dynamicEl[index].responsive) { 646 var srcDyItms = _this.s.dynamicEl[index].responsive.split(','); 647 getResponsiveSrc(srcDyItms); 648 } 649 650 _srcset = _this.s.dynamicEl[index].srcset; 651 _sizes = _this.s.dynamicEl[index].sizes; 652 653 } else { 654 var $currentEle = _this.$items.eq(index); 655 if ($currentEle.attr('data-poster')) { 656 _hasPoster = true; 657 _poster = $currentEle.attr('data-poster'); 658 } 659 660 _html = $currentEle.attr('data-html'); 661 _src = $currentEle.attr('href') || $currentEle.attr('data-src'); 662 _alt = $currentEle.attr('title') || $currentEle.find('img').first().attr('alt'); 663 664 if ($currentEle.attr('data-responsive')) { 665 var srcItms = $currentEle.attr('data-responsive').split(','); 666 getResponsiveSrc(srcItms); 667 } 668 669 _srcset = $currentEle.attr('data-srcset'); 670 _sizes = $currentEle.attr('data-sizes'); 671 672 } 673 674 //if (_src || _srcset || _sizes || _poster) { 675 676 var iframe = false; 677 if (_this.s.dynamic) { 678 if (_this.s.dynamicEl[index].iframe) { 679 iframe = true; 680 } 681 } else { 682 if (_this.$items.eq(index).attr('data-iframe') === 'true') { 683 iframe = true; 684 } 685 } 686 687 var _isVideo = _this.isVideo(_src, index); 688 if (!_this.$slide.eq(index).hasClass('lg-loaded')) { 689 if (iframe) { 690 _this.$slide.eq(index).prepend('<div class="lg-video-cont lg-has-iframe" style="max-width:' + _this.s.iframeMaxWidth + '"><div class="lg-video"><iframe class="lg-object" frameborder="0" src="' + _src + '" allowfullscreen="true"></iframe></div></div>'); 691 } else if (_hasPoster) { 692 var videoClass = ''; 693 if (_isVideo && _isVideo.youtube) { 694 videoClass = 'lg-has-youtube'; 695 } else if (_isVideo && _isVideo.vimeo) { 696 videoClass = 'lg-has-vimeo'; 697 } else { 698 videoClass = 'lg-has-html5'; 699 } 700 701 _this.$slide.eq(index).prepend('<div class="lg-video-cont ' + videoClass + ' "><div class="lg-video"><span class="lg-video-play"></span><img class="lg-object lg-has-poster" src="' + _poster + '" /></div></div>'); 702 703 } else if (_isVideo) { 704 _this.$slide.eq(index).prepend('<div class="lg-video-cont "><div class="lg-video"></div></div>'); 705 _this.$el.trigger('hasVideo.lg', [index, _src, _html]); 706 } else { 707 _alt = _alt ? 'alt="' + _alt + '"' : ''; 708 _this.$slide.eq(index).prepend('<div class="lg-img-wrap"><img class="lg-object lg-image" ' + _alt + ' src="' + _src + '" /></div>'); 709 } 710 711 _this.$el.trigger('onAferAppendSlide.lg', [index]); 712 713 _$img = _this.$slide.eq(index).find('.lg-object'); 714 if (_sizes) { 715 _$img.attr('sizes', _sizes); 716 } 717 718 if (_srcset) { 719 _$img.attr('srcset', _srcset); 720 try { 721 picturefill({ 722 elements: [_$img[0]] 723 }); 724 } catch (e) { 725 console.warn('lightGallery :- If you want srcset to be supported for older browser please include picturefil version 2 javascript library in your document.'); 726 } 727 } 728 729 if (this.s.appendSubHtmlTo !== '.lg-sub-html') { 730 _this.addHtml(index); 731 } 732 733 _this.$slide.eq(index).addClass('lg-loaded'); 734 } 735 736 _this.$slide.eq(index).find('.lg-object').on('load.lg error.lg', function() { 737 738 // For first time add some delay for displaying the start animation. 739 var _speed = 0; 740
741 // Do not change the delay value because it is required for zoom plugin. 742 // If gallery opened from direct url (hash) speed value should be 0 743 if (delay && !$('body').hasClass('lg-from-hash')) { 744 _speed = delay; 745 } 746 747 setTimeout(function() { 748 _this.$slide.eq(index).addClass('lg-complete'); 749 _this.$el.trigger('onSlideItemLoad.lg', [index, delay || 0]); 750 }, _speed); 751 752 }); 753 754 // @todo check load state for html5 videos 755 if (_isVideo && _isVideo.html5 && !_hasPoster) { 756 _this.$slide.eq(index).addClass('lg-complete'); 757 } 758 759 if (rec === true) { 760 if (!_this.$slide.eq(index).hasClass('lg-complete')) { 761 _this.$slide.eq(index).find('.lg-object').on('load.lg error.lg', function() { 762 _this.preload(index); 763 }); 764 } else { 765 _this.preload(index); 766 } 767 } 768 769 //} 770 }; 771 772 /** 773 * @desc slide function for lightgallery 774 ** Slide() gets call on start 775 ** ** Set lg.on true once slide() function gets called. 776 ** Call loadContent() on slide() function inside setTimeout 777 ** ** On first slide we do not want any animation like slide of fade 778 ** ** So on first slide( if lg.on if false that is first slide) loadContent() should start loading immediately 779 ** ** Else loadContent() should wait for the transition to complete. 780 ** ** So set timeout s.speed + 50 781 <=> ** loadContent() will load slide content in to the particular slide 782 ** ** It has recursion (rec) parameter. if rec === true loadContent() will call preload() function. 783 ** ** preload will execute only when the previous slide is fully loaded (images iframe) 784 ** ** avoid simultaneous image load 785 <=> ** Preload() will check for s.preload value and call loadContent() again accoring to preload value 786 ** loadContent() <====> Preload(); 787 788 * @param {Number} index - index of the slide 789 * @param {Boolean} fromTouch - true if slide function called via touch event or mouse drag 790 * @param {Boolean} fromThumb - true if slide function called via thumbnail click 791 * @param {String} direction - Direction of the slide(next/prev) 792 */ 793 Plugin.prototype.slide = function(index, fromTouch, fromThumb, direction) { 794 795 var _prevIndex = this.$outer.find('.lg-current').index(); 796 var _this = this; 797 798 // Prevent if multiple call 799 // Required for hsh plugin 800 if (_this.lGalleryOn && (_prevIndex === index)) { 801 return; 802 } 803 804 var _length = this.$slide.length; 805 var _time = _this.lGalleryOn ? this.s.speed : 0; 806 807 if (!_this.lgBusy) { 808 809 if (this.s.download) { 810 var _src; 811 if (_this.s.dynamic) { 812 _src = _this.s.dynamicEl[index].downloadUrl !== false && (_this.s.dynamicEl[index].downloadUrl || _this.s.dynamicEl[index].src); 813 } else { 814 _src = _this.$items.eq(index).attr('data-download-url') !== 'false' && (_this.$items.eq(index).attr('data-download-url') || _this.$items.eq(index).attr('href') || _this.$items.eq(index).attr('data-src')); 815 816 } 817 818 if (_src) { 819 $('#lg-download').attr('href', _src); 820 _this.$outer.removeClass('lg-hide-download'); 821 } else { 822 _this.$outer.addClass('lg-hide-download'); 823 } 824 } 825 826 this.$el.trigger('onBeforeSlide.lg', [_prevIndex, index, fromTouch, fromThumb]); 827 828 _this.lgBusy = true; 829 830 clearTimeout(_this.hideBartimeout); 831 832 // Add title if this.s.appendSubHtmlTo === lg-sub-html 833 if (this.s.appendSubHtmlTo === '.lg-sub-html') { 834 835 // wait for slide animation to complete 836 setTimeout(function() { 837 _this.addHtml(index); 838 }, _time); 839 } 840 841 this.arrowDisable(index); 842 843 if (!direction) { 844 if (index < _prevIndex) { 845 direction = 'prev'; 846 } else if (index > _prevIndex) {
847 direction = 'next'; 848 } 849 } 850 851 if (!fromTouch) { 852 853 // remove all transitions 854 _this.$outer.addClass('lg-no-trans'); 855 856 this.$slide.removeClass('lg-prev-slide lg-next-slide'); 857 858 if (direction === 'prev') { 859 860 //prevslide 861 this.$slide.eq(index).addClass('lg-prev-slide'); 862 this.$slide.eq(_prevIndex).addClass('lg-next-slide'); 863 } else { 864 865 // next slide 866 this.$slide.eq(index).addClass('lg-next-slide'); 867 this.$slide.eq(_prevIndex).addClass('lg-prev-slide'); 868 } 869 870 // give 50 ms for browser to add/remove class 871 setTimeout(function() { 872 _this.$slide.removeClass('lg-current'); 873 874 //_this.$slide.eq(_prevIndex).removeClass('lg-current'); 875 _this.$slide.eq(index).addClass('lg-current'); 876 877 // reset all transitions 878 _this.$outer.removeClass('lg-no-trans'); 879 }, 50); 880 } else { 881 882 this.$slide.removeClass('lg-prev-slide lg-current lg-next-slide'); 883 var touchPrev; 884 var touchNext; 885 if (_length > 2) { 886 touchPrev = index - 1; 887 touchNext = index + 1; 888 889 if ((index === 0) && (_prevIndex === _length - 1)) { 890 891 // next slide 892 touchNext = 0; 893 touchPrev = _length - 1; 894 } else if ((index === _length - 1) && (_prevIndex === 0)) { 895 896 // prev slide 897 touchNext = 0; 898 touchPrev = _length - 1; 899 } 900 901 } else { 902 touchPrev = 0; 903 touchNext = 1; 904 } 905 906 if (direction === 'prev') { 907 _this.$slide.eq(touchNext).addClass('lg-next-slide'); 908 } else { 909 _this.$slide.eq(touchPrev).addClass('lg-prev-slide'); 910 } 911 912 _this.$slide.eq(index).addClass('lg-current'); 913 } 914 915 if (_this.lGalleryOn) { 916 setTimeout(function() { 917 _this.loadContent(index, true, 0); 918 }, this.s.speed + 50); 919 920 setTimeout(function() { 921 _this.lgBusy = false; 922 _this.$el.trigger('onAfterSlide.lg', [_prevIndex, index, fromTouch, fromThumb]); 923 }, this.s.speed); 924 925 } else { 926 _this.loadContent(index, true, _this.s.backdropDuration); 927 928 _this.lgBusy = false; 929 _this.$el.trigger('onAfterSlide.lg', [_prevIndex, index, fromTouch, fromThumb]); 930 } 931 932 _this.lGalleryOn = true; 933 934 if (this.s.counter) { 935 $('#lg-counter-current').text(index + 1); 936 } 937 938 } 939 _this.index = index; 940 941 }; 942 943 /** 944 * @desc Go to next slide 945 * @param {Boolean} fromTouch - true if slide function called via touch event 946 */ 947 Plugin.prototype.goToNextSlide = function(fromTouch) { 948 var _this = this; 949 var _loop = _this.s.loop; 950 if (fromTouch && _this.$slide.length < 3) { 951 _loop = false; 952 } 953 954 if (!_this.lgBusy) { 955 if ((_this.index + 1) < _this.$slide.length) { 956 _this.index++; 957 _this.$el.trigger('onBeforeNextSlide.lg', [_this.index]); 958 _this.slide(_this.index, fromTouch, false, 'next'); 959 } else { 960 if (_loop) { 961 _this.index = 0; 962 _this.$el.trigger('onBeforeNextSlide.lg', [_this.index]); 963 _this.slide(_this.index, fromTouch, false, 'next'); 964 } else if (_this.s.slideEndAnimatoin && !fromTouch) { 965 _this.$outer.addClass('lg-right-end'); 966 setTimeout(function() { 967 _this.$outer.removeClass('lg-right-end'); 968 }, 400); 969 } 970 } 971 } 972 }; 973 974 /** 975 * @desc Go to previous slide 976 * @param {Boolean} fromTouch - true if slide function called via touch event 977 */ 978 Plugin.prototype.goToPrevSlide = function(fromTouch) { 979 var _this = this; 980 var _loop = _this.s.loop; 981 if (fromTouch && _this.$slide.length < 3) { 982 _loop = false;
983 } 984 985 if (!_this.lgBusy) { 986 if (_this.index > 0) { 987 _this.index--; 988 _this.$el.trigger('onBeforePrevSlide.lg', [_this.index, fromTouch]); 989 _this.slide(_this.index, fromTouch, false, 'prev'); 990 } else { 991 if (_loop) { 992 _this.index = _this.$items.length - 1; 993 _this.$el.trigger('onBeforePrevSlide.lg', [_this.index, fromTouch]); 994 _this.slide(_this.index, fromTouch, false, 'prev'); 995 } else if (_this.s.slideEndAnimatoin && !fromTouch) { 996 _this.$outer.addClass('lg-left-end'); 997 setTimeout(function() { 998 _this.$outer.removeClass('lg-left-end'); 999 }, 400); 1000 } 1001 } 1002 } 1003 }; 1004 1005 Plugin.prototype.keyPress = function() { 1006 var _this = this; 1007 if (this.$items.length > 1) { 1008 $(window).on('keyup.lg', function(e) { 1009 if (_this.$items.length > 1) { 1010 if (e.keyCode === 37) { 1011 e.preventDefault(); 1012 _this.goToPrevSlide(); 1013 } 1014 1015 if (e.keyCode === 39) { 1016 e.preventDefault(); 1017 _this.goToNextSlide(); 1018 } 1019 } 1020 }); 1021 } 1022 1023 $(window).on('keydown.lg', function(e) { 1024 if (_this.s.escKey === true && e.keyCode === 27) { 1025 e.preventDefault(); 1026 if (!_this.$outer.hasClass('lg-thumb-open')) { 1027 _this.destroy(); 1028 } else { 1029 _this.$outer.removeClass('lg-thumb-open'); 1030 } 1031 } 1032 }); 1033 }; 1034 1035 Plugin.prototype.arrow = function() { 1036 var _this = this; 1037 this.$outer.find('.lg-prev').on('click.lg', function() { 1038 _this.goToPrevSlide(); 1039 }); 1040 1041 this.$outer.find('.lg-next').on('click.lg', function() { 1042 _this.goToNextSlide(); 1043 }); 1044 }; 1045 1046 Plugin.prototype.arrowDisable = function(index) { 1047 1048 // Disable arrows if s.hideControlOnEnd is true 1049 if (!this.s.loop && this.s.hideControlOnEnd) { 1050 if ((index + 1) < this.$slide.length) { 1051 this.$outer.find('.lg-next').removeAttr('disabled').removeClass('disabled'); 1052 } else { 1053 this.$outer.find('.lg-next').attr('disabled', 'disabled').addClass('disabled'); 1054 } 1055 1056 if (index > 0) { 1057 this.$outer.find('.lg-prev').removeAttr('disabled').removeClass('disabled'); 1058 } else { 1059 this.$outer.find('.lg-prev').attr('disabled', 'disabled').addClass('disabled'); 1060 } 1061 } 1062 }; 1063 1064 Plugin.prototype.setTranslate = function($el, xValue, yValue) { 1065 // jQuery supports Automatic CSS prefixing since jQuery 1.8.0 1066 if (this.s.useLeft) { 1067 $el.css('left', xValue); 1068 } else { 1069 $el.css({ 1070 transform: 'translate3d(' + (xValue) + 'px, ' + yValue + 'px, 0px)' 1071 }); 1072 } 1073 }; 1074 1075 Plugin.prototype.touchMove = function(startCoords, endCoords) { 1076 1077 var distance = endCoords - startCoords; 1078 1079 if (Math.abs(distance) > 15) { 1080 // reset opacity and transition duration 1081 this.$outer.addClass('lg-dragging'); 1082 1083 // move current slide 1084 this.setTranslate(this.$slide.eq(this.index), distance, 0); 1085 1086 // move next and prev slide with current slide 1087 this.setTranslate($('.lg-prev-slide'), -this.$slide.eq(this.index).width() + distance, 0); 1088 this.setTranslate($('.lg-next-slide'), this.$slide.eq(this.index).width() + distance, 0); 1089 } 1090 }; 1091 1092 Plugin.prototype.touchEnd = function(distance) { 1093 var _this = this; 1094 1095 // keep slide animation for any mode while dragg/swipe 1096 if (_this.s.mode !== 'lg-slide') { 1097 _this.$outer.addClass('lg-slide'); 1098 } 1099 1100 this.$slide.not('.lg-current, .lg-prev-slide, .lg-next-slide').css('opacity', '0'); 1101 1102 // set transition duration 1103 setTimeout(function() { 1104 _this.$outer.removeClass('lg-dragging'); 1105 if ((distance < 0) && (Math.abs(distance) > _this.s.swipeThreshold)) { 1106 _this.goToNextSlide(true); 1107 } else if ((distance > 0) && (Math.abs(distance) > _this.s.swipeThreshold)) { 1108 _this.goToPrevSlide(true); 1109 } else if (Math.abs(distance) < 5) { 1110 1111 // Trigger click if distance is less than 5 pix 1112 _this.$el.trigger('onSlideClick.lg'); 1113 } 1114 1115 _this.$slide.removeAttr('style'); 1116 }); 1117 1118 // remove slide class once drag/swipe is completed if mode is not slide 1119 setTimeout(function() { 1120 if (!_this.$outer.hasClass('lg-dragging') && _this.s.mode !== 'lg-slide') { 1121 _this.$outer.removeClass('lg-slide'); 1122 } 1123 }, _this.s.speed + 100); 1124 1125 }; 1126 1127 Plugin.prototype.enableSwipe = function() { 1128 var _this = this; 1129 var startCoords = 0; 1130 var endCoords = 0; 1131 var isMoved = false;
1132 1133 if (_this.s.enableSwipe && _this.doCss()) { 1134 1135 _this.$slide.on('touchstart.lg', function(e) { 1136 if (!_this.$outer.hasClass('lg-zoomed') && !_this.lgBusy) { 1137 e.preventDefault(); 1138 _this.manageSwipeClass(); 1139 startCoords = e.originalEvent.targetTouches[0].pageX; 1140 } 1141 }); 1142 1143 _this.$slide.on('touchmove.lg', function(e) { 1144 if (!_this.$outer.hasClass('lg-zoomed')) { 1145 e.preventDefault(); 1146 endCoords = e.originalEvent.targetTouches[0].pageX; 1147 _this.touchMove(startCoords, endCoords); 1148 isMoved = true; 1149 } 1150 }); 1151 1152 _this.$slide.on('touchend.lg', function() { 1153 if (!_this.$outer.hasClass('lg-zoomed')) { 1154 if (isMoved) { 1155 isMoved = false; 1156 _this.touchEnd(endCoords - startCoords); 1157 } else { 1158 _this.$el.trigger('onSlideClick.lg'); 1159 } 1160 } 1161 }); 1162 } 1163 1164 }; 1165 1166 Plugin.prototype.enableDrag = function() { 1167 var _this = this; 1168 var startCoords = 0; 1169 var endCoords = 0; 1170 var isDraging = false; 1171 var isMoved = false; 1172 if (_this.s.enableDrag && _this.doCss()) { 1173 _this.$slide.on('mousedown.lg', function(e) { 1174 if (!_this.$outer.hasClass('lg-zoomed') && !_this.lgBusy && !$(e.target).text().trim()) { 1175 e.preventDefault(); 1176 _this.manageSwipeClass(); 1177 startCoords = e.pageX; 1178 isDraging = true; 1179 1180 // ** Fix for webkit cursor issue https://code.google.com/p/chromium/issues/detail?id=26723 1181 _this.$outer.scrollLeft += 1; 1182 _this.$outer.scrollLeft -= 1; 1183 1184 // * 1185 1186 _this.$outer.removeClass('lg-grab').addClass('lg-grabbing'); 1187 1188 _this.$el.trigger('onDragstart.lg'); 1189 } 1190 }); 1191 1192 $(window).on('mousemove.lg', function(e) { 1193 if (isDraging) { 1194 isMoved = true; 1195 endCoords = e.pageX; 1196 _this.touchMove(startCoords, endCoords); 1197 _this.$el.trigger('onDragmove.lg'); 1198 } 1199 }); 1200 1201 $(window).on('mouseup.lg', function(e) { 1202 if (isMoved) { 1203 isMoved = false; 1204 _this.touchEnd(endCoords - startCoords); 1205 _this.$el.trigger('onDragend.lg'); 1206 } else if ($(e.target).hasClass('lg-object') || $(e.target).hasClass('lg-video-play')) { 1207 _this.$el.trigger('onSlideClick.lg'); 1208 } 1209 1210 // Prevent execution on click 1211 if (isDraging) { 1212 isDraging = false; 1213 _this.$outer.removeClass('lg-grabbing').addClass('lg-grab'); 1214 } 1215 }); 1216 1217 } 1218 }; 1219 1220 Plugin.prototype.manageSwipeClass = function() { 1221 var _touchNext = this.index + 1; 1222 var _touchPrev = this.index - 1; 1223 if (this.s.loop && this.$slide.length > 2) { 1224 if (this.index === 0) { 1225 _touchPrev = this.$slide.length - 1; 1226 } else if (this.index === this.$slide.length - 1) { 1227 _touchNext = 0; 1228 } 1229 } 1230 1231 this.$slide.removeClass('lg-next-slide lg-prev-slide'); 1232 if (_touchPrev > -1) { 1233 this.$slide.eq(_touchPrev).addClass('lg-prev-slide'); 1234 } 1235 1236 this.$slide.eq(_touchNext).addClass('lg-next-slide'); 1237 }; 1238 1239 Plugin.prototype.mousewheel = function() { 1240 var _this = this; 1241 _this.$outer.on('mousewheel.lg', function(e) { 1242 1243 if (!e.deltaY) { 1244 return; 1245 } 1246 1247 if (e.deltaY > 0) { 1248 _this.goToPrevSlide(); 1249 } else { 1250 _this.goToNextSlide(); 1251 } 1252 1253 e.preventDefault(); 1254 }); 1255 1256 }; 1257 1258 Plugin.prototype.closeGallery = function() { 1259 1260 var _this = this; 1261 var mousedown = false;
1262 this.$outer.find('.lg-close').on('click.lg', function() { 1263 _this.destroy(); 1264 }); 1265 1266 if (_this.s.closable) { 1267 1268 // If you drag the slide and release outside gallery gets close on chrome 1269 // for preventing this check mousedown and mouseup happened on .lg-item or lg-outer 1270 _this.$outer.on('mousedown.lg', function(e) { 1271 1272 if ($(e.target).is('.lg-outer') || $(e.target).is('.lg-item ') || $(e.target).is('.lg-img-wrap')) { 1273 mousedown = true; 1274 } else { 1275 mousedown = false; 1276 } 1277 1278 }); 1279 1280 _this.$outer.on('mousemove.lg', function() { 1281 mousedown = false; 1282 }); 1283 1284 _this.$outer.on('mouseup.lg', function(e) { 1285 1286 if ($(e.target).is('.lg-outer') || $(e.target).is('.lg-item ') || $(e.target).is('.lg-img-wrap') && mousedown) { 1287 if (!_this.$outer.hasClass('lg-dragging')) { 1288 _this.destroy(); 1289 } 1290 } 1291 1292 }); 1293 1294 } 1295 1296 }; 1297 1298 Plugin.prototype.destroy = function(d) { 1299 1300 var _this = this; 1301 1302 if (!d) { 1303 _this.$el.trigger('onBeforeClose.lg'); 1304 $(window).scrollTop(_this.prevScrollTop); 1305 } 1306 1307 1308 /** 1309 * if d is false or undefined destroy will only close the gallery 1310 * plugins instance remains with the element 1311 * 1312 * if d is true destroy will completely remove the plugin 1313 */ 1314 1315 if (d) { 1316 if (!_this.s.dynamic) { 1317 // only when not using dynamic mode is $items a jquery collection 1318 this.$items.off('click.lg click.lgcustom'); 1319 } 1320 1321 $.removeData(_this.el, 'lightGallery'); 1322 } 1323 1324 // Unbind all events added by lightGallery 1325 this.$el.off('.lg.tm'); 1326 1327 // destroy all lightGallery modules 1328 $.each($.fn.lightGallery.modules, function(key) { 1329 if (_this.modules[key]) { 1330 _this.modules[key].destroy(); 1331 } 1332 }); 1333 1334 this.lGalleryOn = false; 1335 1336 clearTimeout(_this.hideBartimeout); 1337 this.hideBartimeout = false; 1338 $(window).off('.lg'); 1339 $('body').removeClass('lg-on lg-from-hash'); 1340 1341 if (_this.$outer) { 1342 _this.$outer.removeClass('lg-visible'); 1343 } 1344 1345 $('.lg-backdrop').removeClass('in'); 1346 1347 setTimeout(function() { 1348 if (_this.$outer) { 1349 _this.$outer.remove(); 1350 } 1351 1352 $('.lg-backdrop').remove(); 1353 1354 if (!d) { 1355 _this.$el.trigger('onCloseAfter.lg'); 1356 } 1357 _this.$el.focus(); 1358 1359 }, _this.s.backdropDuration + 50); 1360 }; 1361 1362 $.fn.lightGallery = function(options) { 1363 return this.each(function() { 1364 if (!$.data(this, 'lightGallery')) { 1365 $.data(this, 'lightGallery', new Plugin(this, options)); 1366 } else { 1367 try { 1368 $(this).data('lightGallery').init(); 1369 } catch (err) { 1370 console.error('lightGallery has not initiated properly'); 1371 } 1372 } 1373 }); 1374 }; 1375 1376 $.fn.lightGallery.modules = {}; 1377 1378})(); 1379 1380 1381})); 1382 1383/*! lg-autoplay - v1.2.0 - 2020-05-03 1384* http://sachinchoolur.github.io/lightGallery 1385* Copyright (c) 2020 Sachin N; Licensed GPLv3 */ 1386 1387(function (root, factory) { 1388 if (typeof define === 'function' && define.amd) { 1389 // AMD. Register as an anonymous module unless amdModuleId is set 1390 define(['jquery'], function (a0) { 1391 return (factory(a0)); 1392 }); 1393 } else if (typeof module === 'object' && module.exports) { 1394 // Node. Does not work with strict CommonJS, but 1395 // only CommonJS-like environments that support module.exports, 1396 // like Node. 1397 module.exports = factory(require('jquery')); 1398 } else { 1399 factory(root["jQuery"]); 1400 } 1401}(this, function ($) { 1402 1403 1404(function() { 1405 1406 'use strict'; 1407 1408 var defaults = { 1409 autoplay: false, 1410 pause: 5000, 1411 progressBar: true, 1412 fourceAutoplay: false, 1413 autoplayControls: true, 1414 appendAutoplayControlsTo: '.lg-toolbar' 1415 }; 1416 1417 /** 1418 * Creates the autoplay plugin. 1419 * @param {object} element - lightGallery element 1420 */ 1421 var Autoplay = function(element) { 1422 1423 this.core = $(element).data('lightGallery'); 1424 1425 this.$el = $(element); 1426 1427 // Execute only if items are above 1 1428 if (this.core.$items.length < 2) { 1429 return false;
vendor: 4,684 bytes, lines 1430-1571
1430 } 1431 1432 this.core.s = $.extend({}, defaults, this.core.s); 1433 this.interval = false; 1434 1435 // Identify if slide happened from autoplay 1436 this.fromAuto = true; 1437 1438 // Identify if autoplay canceled from touch/drag 1439 this.canceledOnTouch = false; 1440 1441 // save fourceautoplay value 1442 this.fourceAutoplayTemp = this.core.s.fourceAutoplay; 1443 1444 // do not allow progress bar if browser does not support css3 transitions 1445 if (!this.core.doCss()) { 1446 this.core.s.progressBar = false; 1447 } 1448 1449 this.init(); 1450 1451 return this; 1452 }; 1453 1454 Autoplay.prototype.init = function() { 1455 var _this = this; 1456 1457 // append autoplay controls 1458 if (_this.core.s.autoplayControls) { 1459 _this.controls(); 1460 } 1461 1462 // Create progress bar 1463 if (_this.core.s.progressBar) { 1464 _this.core.$outer.find('.lg').append('<div class="lg-progress-bar"><div class="lg-progress"></div></div>'); 1465 } 1466 1467 // set progress 1468 _this.progress(); 1469 1470 // Start autoplay 1471 if (_this.core.s.autoplay) { 1472 _this.$el.one('onSlideItemLoad.lg.tm', function() { 1473 _this.startlAuto(); 1474 }); 1475 } 1476 1477 // cancel interval on touchstart and dragstart 1478 _this.$el.on('onDragstart.lg.tm touchstart.lg.tm', function() { 1479 if (_this.interval) { 1480 _this.cancelAuto(); 1481 _this.canceledOnTouch = true; 1482 } 1483 }); 1484 1485 // restore autoplay if autoplay canceled from touchstart / dragstart 1486 _this.$el.on('onDragend.lg.tm touchend.lg.tm onSlideClick.lg.tm', function() { 1487 if (!_this.interval && _this.canceledOnTouch) { 1488 _this.startlAuto(); 1489 _this.canceledOnTouch = false; 1490 } 1491 }); 1492 1493 }; 1494 1495 Autoplay.prototype.progress = function() { 1496 1497 var _this = this; 1498 var _$progressBar; 1499 var _$progress; 1500 1501 _this.$el.on('onBeforeSlide.lg.tm', function() { 1502 1503 // start progress bar animation 1504 if (_this.core.s.progressBar && _this.fromAuto) { 1505 _$progressBar = _this.core.$outer.find('.lg-progress-bar'); 1506 _$progress = _this.core.$outer.find('.lg-progress'); 1507 if (_this.interval) { 1508 _$progress.removeAttr('style'); 1509 _$progressBar.removeClass('lg-start'); 1510 setTimeout(function() { 1511 _$progress.css('transition', 'width ' + (_this.core.s.speed + _this.core.s.pause) + 'ms ease 0s'); 1512 _$progressBar.addClass('lg-start'); 1513 }, 20); 1514 } 1515 } 1516 1517 // Remove setinterval if slide is triggered manually and fourceautoplay is false 1518 if (!_this.fromAuto && !_this.core.s.fourceAutoplay) { 1519 _this.cancelAuto(); 1520 } 1521 1522 _this.fromAuto = false; 1523 1524 }); 1525 }; 1526 1527 // Manage autoplay via play/stop buttons 1528 Autoplay.prototype.controls = function() { 1529 var _this = this; 1530 var _html = '<button aria-label="Toggle autoplay" class="lg-autoplay-button lg-icon"></button>'; 1531 1532 // Append autoplay controls 1533 $(this.core.s.appendAutoplayControlsTo).append(_html); 1534 1535 _this.core.$outer.find('.lg-autoplay-button').on('click.lg', function() { 1536 if ($(_this.core.$outer).hasClass('lg-show-autoplay')) { 1537 _this.cancelAuto(); 1538 _this.core.s.fourceAutoplay = false; 1539 } else { 1540 if (!_this.interval) { 1541 _this.startlAuto(); 1542 _this.core.s.fourceAutoplay = _this.fourceAutoplayTemp; 1543 } 1544 } 1545 }); 1546 }; 1547 1548 // Autostart gallery 1549 Autoplay.prototype.startlAuto = function() { 1550 var _this = this; 1551 1552 _this.core.$outer.find('.lg-progress').css('transition', 'width ' + (_this.core.s.speed + _this.core.s.pause) + 'ms ease 0s'); 1553 _this.core.$outer.addClass('lg-show-autoplay'); 1554 _this.core.$outer.find('.lg-progress-bar').addClass('lg-start'); 1555 1556 _this.interval = setInterval(function() { 1557 if (_this.core.index + 1 < _this.core.$items.length) { 1558 _this.core.index++; 1559 } else { 1560 _this.core.index = 0; 1561 } 1562 1563 _this.fromAuto = true; 1564 _this.core.slide(_this.core.index, false, false, 'next'); 1565 }, _this.core.s.speed + _this.core.s.pause); 1566 }; 1567 1568 // cancel Autostart 1569 Autoplay.prototype.cancelAuto = function() { 1570 clearInterval(this.interval); 1571 this.interval = false;
1572 this.core.$outer.find('.lg-progress').removeAttr('style'); 1573 this.core.$outer.removeClass('lg-show-autoplay'); 1574 this.core.$outer.find('.lg-progress-bar').removeClass('lg-start'); 1575 }; 1576 1577 Autoplay.prototype.destroy = function() { 1578 1579 this.cancelAuto(); 1580 this.core.$outer.find('.lg-progress-bar').remove(); 1581 }; 1582 1583 $.fn.lightGallery.modules.autoplay = Autoplay; 1584 1585})(); 1586 1587 1588})); 1589 1590/*! lg-fullscreen - v1.2.0 - 2020-05-03 1591* http://sachinchoolur.github.io/lightGallery 1592* Copyright (c) 2020 Sachin N; Licensed GPLv3 */ 1593 1594(function (root, factory) { 1595 if (typeof define === 'function' && define.amd) { 1596 // AMD. Register as an anonymous module unless amdModuleId is set 1597 define(['jquery'], function (a0) { 1598 return (factory(a0)); 1599 }); 1600 } else if (typeof module === 'object' && module.exports) { 1601 // Node. Does not work with strict CommonJS, but 1602 // only CommonJS-like environments that support module.exports, 1603 // like Node. 1604 module.exports = factory(require('jquery')); 1605 } else { 1606 factory(root["jQuery"]); 1607 } 1608}(this, function ($) { 1609 1610(function() { 1611 1612 'use strict'; 1613 1614 var defaults = { 1615 fullScreen: true 1616 }; 1617 1618 function isFullScreen() { 1619 return ( 1620 document.fullscreenElement || 1621 document.mozFullScreenElement || 1622 document.webkitFullscreenElement || 1623 document.msFullscreenElement 1624 ); 1625 } 1626 1627 var Fullscreen = function(element) { 1628 1629 // get lightGallery core plugin data 1630 this.core = $(element).data('lightGallery'); 1631 1632 this.$el = $(element); 1633 1634 // extend module defalut settings with lightGallery core settings 1635 this.core.s = $.extend({}, defaults, this.core.s); 1636 1637 this.init(); 1638 1639 return this; 1640 }; 1641 1642 Fullscreen.prototype.init = function() { 1643 var fullScreen = ''; 1644 if (this.core.s.fullScreen) { 1645 1646 // check for fullscreen browser support 1647 if (!document.fullscreenEnabled && !document.webkitFullscreenEnabled && 1648 !document.mozFullScreenEnabled && !document.msFullscreenEnabled) { 1649 return; 1650 } else { 1651 fullScreen = '<button aria-label="Toggle fullscreen" class="lg-fullscreen lg-icon"></button>'; 1652 this.core.$outer.find('.lg-toolbar').append(fullScreen); 1653 this.fullScreen(); 1654 } 1655 } 1656 }; 1657 1658 Fullscreen.prototype.requestFullscreen = function() { 1659 var el = document.documentElement; 1660 if (el.requestFullscreen) { 1661 el.requestFullscreen(); 1662 } else if (el.msRequestFullscreen) { 1663 el.msRequestFullscreen(); 1664 } else if (el.mozRequestFullScreen) { 1665 el.mozRequestFullScreen(); 1666 } else if (el.webkitRequestFullscreen) { 1667 el.webkitRequestFullscreen(); 1668 } 1669 }; 1670 1671 Fullscreen.prototype.exitFullscreen = function() { 1672 if (document.exitFullscreen) { 1673 document.exitFullscreen(); 1674 } else if (document.msExitFullscreen) { 1675 document.msExitFullscreen(); 1676 } else if (document.mozCancelFullScreen) { 1677 document.mozCancelFullScreen(); 1678 } else if (document.webkitExitFullscreen) { 1679 document.webkitExitFullscreen(); 1680 } 1681 }; 1682 1683 // https://developer.mozilla.org/en-US/docs/Web/Guide/API/DOM/Using_full_screen_mode 1684 Fullscreen.prototype.fullScreen = function() { 1685 var _this = this; 1686 1687 $(document).on('fullscreenchange.lg webkitfullscreenchange.lg mozfullscreenchange.lg MSFullscreenChange.lg', function() { 1688 _this.core.$outer.toggleClass('lg-fullscreen-on'); 1689 }); 1690 1691 this.core.$outer.find('.lg-fullscreen').on('click.lg', function() { 1692 if (isFullScreen()) { 1693 _this.exitFullscreen(); 1694 } else { 1695 _this.requestFullscreen(); 1696 } 1697 }); 1698 1699 }; 1700 1701 Fullscreen.prototype.destroy = function() { 1702 1703 // exit from fullscreen if activated 1704 if(isFullScreen()) { 1705 this.exitFullscreen(); 1706 } 1707 1708 $(document).off('fullscreenchange.lg webkitfullscreenchange.lg mozfullscreenchange.lg MSFullscreenChange.lg'); 1709 }; 1710 1711 $.fn.lightGallery.modules.fullscreen = Fullscreen; 1712 1713})(); 1714 1715})); 1716 1717/*! lg-pager - v1.0.2 - 2017-01-22 1718* http://sachinchoolur.github.io/lightGallery 1719* Copyright (c) 2017 Sachin N; Licensed GPLv3 */ 1720 1721(function (root, factory) { 1722 if (typeof define === 'function' && define.amd) { 1723 // AMD. Register as an anonymous module unless amdModuleId is set 1724 define(['jquery'], function (a0) { 1725 return (factory(a0)); 1726 }); 1727 } else if (typeof exports === 'object') { 1728 // Node. Does not work with strict CommonJS, but 1729 // only CommonJS-like environments that support module.exports, 1730 // like Node. 1731 module.exports = factory(require('jquery')); 1732 } else { 1733 factory(jQuery); 1734 } 1735}(this, function ($) { 1736 1737(function() { 1738 1739 'use strict'; 1740 1741 var defaults = { 1742 pager: false 1743 }; 1744 1745 var Pager = function(element) { 1746 1747 this.core = $(element).data('lightGallery'); 1748 1749 this.$el = $(element); 1750 this.core.s = $.extend({}, defaults, this.core.s); 1751 if (this.core.s.pager && this.core.$items.length > 1) { 1752 this.init(); 1753 } 1754 1755 return this; 1756 }; 1757 1758 Pager.prototype.init = function() { 1759 var _this = this; 1760 var pagerList = ''; 1761 var $pagerCont; 1762 var $pagerOuter; 1763 var timeout; 1764 1765 _this.core.$outer.find('.lg').append('<div class="lg-pager-outer"></div>'); 1766 1767 if (_this.core.s.dynamic) { 1768 for (var i = 0; i < _this.core.s.dynamicEl.length; i++) { 1769 pagerList += '<span class="lg-pager-cont"> <span class="lg-pager"></span><div class="lg-pager-thumb-cont"><span class="lg-caret"></span> <img src="' + _this.core.s.dynamicEl[i].thumb + '" /></div></span>'; 1770 } 1771 } else { 1772 _this.core.$items.each(function() { 1773 1774 if (!_this.core.s.exThumbImage) { 1775 pagerList += '<span class="lg-pager-cont"> <span class="lg-pager"></span><div class="lg-pager-thumb-cont"><span class="lg-caret"></span> <img src="' + $(this).find('img').attr('src') + '" /></div></span>'; 1776 } else { 1777 pagerList += '<span class="lg-pager-cont"> <span class="lg-pager"></span><div class="lg-pager-thumb-cont"><span class="lg-caret"></span> <img src="' + $(this).attr(_this.core.s.exThumbImage) + '" /></div></span>'; 1778 } 1779 1780 }); 1781 } 1782 1783 $pagerOuter = _this.core.$outer.find('.lg-pager-outer'); 1784
vendor: 17,833 bytes, lines 1785-2335
1785 $pagerOuter.html(pagerList); 1786 1787 $pagerCont = _this.core.$outer.find('.lg-pager-cont'); 1788 $pagerCont.on('click.lg touchend.lg', function() { 1789 var _$this = $(this); 1790 _this.core.index = _$this.index(); 1791 _this.core.slide(_this.core.index, false, true, false); 1792 }); 1793 1794 $pagerOuter.on('mouseover.lg', function() { 1795 clearTimeout(timeout); 1796 $pagerOuter.addClass('lg-pager-hover'); 1797 }); 1798 1799 $pagerOuter.on('mouseout.lg', function() { 1800 timeout = setTimeout(function() { 1801 $pagerOuter.removeClass('lg-pager-hover'); 1802 }); 1803 }); 1804 1805 _this.core.$el.on('onBeforeSlide.lg.tm', function(e, prevIndex, index) { 1806 $pagerCont.removeClass('lg-pager-active'); 1807 $pagerCont.eq(index).addClass('lg-pager-active'); 1808 }); 1809 1810 }; 1811 1812 Pager.prototype.destroy = function() { 1813 1814 }; 1815 1816 $.fn.lightGallery.modules.pager = Pager; 1817 1818})(); 1819 1820 1821})); 1822 1823/*! lg-thumbnail - v1.2.0 - 2020-05-03 1824* http://sachinchoolur.github.io/lightGallery 1825* Copyright (c) 2020 Sachin N; Licensed GPLv3 */ 1826 1827(function (root, factory) { 1828 if (typeof define === 'function' && define.amd) { 1829 // AMD. Register as an anonymous module unless amdModuleId is set 1830 define(['jquery'], function (a0) { 1831 return (factory(a0)); 1832 }); 1833 } else if (typeof module === 'object' && module.exports) { 1834 // Node. Does not work with strict CommonJS, but 1835 // only CommonJS-like environments that support module.exports, 1836 // like Node. 1837 module.exports = factory(require('jquery')); 1838 } else { 1839 factory(root["jQuery"]); 1840 } 1841}(this, function ($) { 1842 1843(function() { 1844 1845 'use strict'; 1846 1847 var defaults = { 1848 thumbnail: true, 1849 1850 animateThumb: true, 1851 currentPagerPosition: 'middle', 1852 1853 thumbWidth: 100, 1854 thumbHeight: '80px', 1855 thumbContHeight: 100, 1856 thumbMargin: 5, 1857 1858 exThumbImage: false, 1859 showThumbByDefault: true, 1860 toogleThumb: true, 1861 pullCaptionUp: true, 1862 1863 enableThumbDrag: true, 1864 enableThumbSwipe: true, 1865 swipeThreshold: 50, 1866 1867 loadYoutubeThumbnail: true, 1868 youtubeThumbSize: 1, 1869 1870 loadVimeoThumbnail: true, 1871 vimeoThumbSize: 'thumbnail_small', 1872 1873 loadDailymotionThumbnail: true 1874 }; 1875 1876 var Thumbnail = function(element) { 1877 1878 // get lightGallery core plugin data 1879 this.core = $(element).data('lightGallery'); 1880 1881 // extend module default settings with lightGallery core settings 1882 this.core.s = $.extend({}, defaults, this.core.s); 1883 1884 this.$el = $(element); 1885 this.$thumbOuter = null; 1886 this.thumbOuterWidth = 0; 1887 this.thumbTotalWidth = (this.core.$items.length * (this.core.s.thumbWidth + this.core.s.thumbMargin)); 1888 this.thumbIndex = this.core.index; 1889 1890 if (this.core.s.animateThumb) { 1891 this.core.s.thumbHeight = '100%'; 1892 } 1893 1894 // Thumbnail animation value 1895 this.left = 0; 1896 1897 this.init(); 1898 1899 return this; 1900 }; 1901 1902 Thumbnail.prototype.init = function() { 1903 var _this = this; 1904 if (this.core.s.thumbnail && this.core.$items.length > 1) { 1905 if (this.core.s.showThumbByDefault) { 1906 setTimeout(function(){ 1907 _this.core.$outer.addClass('lg-thumb-open'); 1908 }, 700); 1909 } 1910 1911 if (this.core.s.pullCaptionUp) { 1912 this.core.$outer.addClass('lg-pull-caption-up'); 1913 } 1914 1915 this.build(); 1916 if (this.core.s.animateThumb && this.core.doCss()) { 1917 if (this.core.s.enableThumbDrag) { 1918 this.enableThumbDrag(); 1919 } 1920 1921 if (this.core.s.enableThumbSwipe) { 1922 this.enableThumbSwipe(); 1923 } 1924 1925 this.thumbClickable = false; 1926 } else { 1927 this.thumbClickable = true; 1928 } 1929 1930 this.toogle(); 1931 this.thumbkeyPress(); 1932 } 1933 }; 1934 1935 Thumbnail.prototype.build = function() { 1936 var _this = this; 1937 var thumbList = ''; 1938 var vimeoErrorThumbSize = ''; 1939 var $thumb; 1940 var html = '<div class="lg-thumb-outer">' + 1941 '<div class="lg-thumb lg-group">' + 1942 '</div>' + 1943 '</div>'; 1944 1945 switch (this.core.s.vimeoThumbSize) { 1946 case 'thumbnail_large': 1947 vimeoErrorThumbSize = '640'; 1948 break; 1949 case 'thumbnail_medium': 1950 vimeoErrorThumbSize = '200x150'; 1951 break; 1952 case 'thumbnail_small': 1953 vimeoErrorThumbSize = '100x75'; 1954 } 1955 1956 _this.core.$outer.addClass('lg-has-thumb'); 1957 1958 _this.core.$outer.find('.lg').append(html); 1959 1960 _this.$thumbOuter = _this.core.$outer.find('.lg-thumb-outer'); 1961 _this.thumbOuterWidth = _this.$thumbOuter.width(); 1962 1963 if (_this.core.s.animateThumb) { 1964 _this.core.$outer.find('.lg-thumb').css({ 1965 width: _this.thumbTotalWidth + 'px', 1966 position: 'relative' 1967 }); 1968 } 1969 1970 if (this.core.s.animateThumb) { 1971 _this.$thumbOuter.css('height', _this.core.s.thumbContHeight + 'px'); 1972 } 1973 1974 function getThumb(src, thumb, index) { 1975 var isVideo = _this.core.isVideo(src, index) || {}; 1976 var thumbImg; 1977 var vimeoId = ''; 1978 1979 if (isVideo.youtube || isVideo.vimeo || isVideo.dailymotion) { 1980 if (isVideo.youtube) { 1981 if (_this.core.s.loadYoutubeThumbnail) { 1982 thumbImg = '//img.youtube.com/vi/' + isVideo.youtube[1] + '/' + _this.core.s.youtubeThumbSize + '.jpg'; 1983 } else { 1984 thumbImg = thumb; 1985 } 1986 } else if (isVideo.vimeo) { 1987 if (_this.core.s.loadVimeoThumbnail) { 1988 thumbImg = '//i.vimeocdn.com/video/error_' + vimeoErrorThumbSize + '.jpg'; 1989 vimeoId = isVideo.vimeo[1]; 1990 } else { 1991 thumbImg = thumb; 1992 } 1993 } else if (isVideo.dailymotion) { 1994 if (_this.core.s.loadDailymotionThumbnail) { 1995 thumbImg = '//www.dailymotion.com/thumbnail/video/' + isVideo.dailymotion[1]; 1996 } else { 1997 thumbImg = thumb; 1998 } 1999 } 2000 } else { 2001 thumbImg = thumb; 2002 } 2003 2004 thumbList += '<div data-vimeo-id="' + vimeoId + '" class="lg-thumb-item" style="width:' + _this.core.s.thumbWidth + 'px; height: ' + _this.core.s.thumbHeight + '; margin-right: ' + _this.core.s.thumbMargin + 'px"><img src="' + thumbImg + '" /></div>'; 2005 vimeoId = ''; 2006 } 2007 2008 if (_this.core.s.dynamic) { 2009 for (var i = 0; i < _this.core.s.dynamicEl.length; i++) { 2010 getThumb(_this.core.s.dynamicEl[i].src, _this.core.s.dynamicEl[i].thumb, i); 2011 } 2012 } else { 2013 _this.core.$items.each(function(i) { 2014 2015 if (!_this.core.s.exThumbImage) { 2016 getThumb($(this).attr('href') || $(this).attr('data-src'), $(this).find('img').attr('src'), i); 2017 } else { 2018 getThumb($(this).attr('href') || $(this).attr('data-src'), $(this).attr(_this.core.s.exThumbImage), i); 2019 } 2020 2021 }); 2022 } 2023 2024 _this.core.$outer.find('.lg-thumb').html(thumbList); 2025 2026 $thumb = _this.core.$outer.find('.lg-thumb-item'); 2027 2028 // Load vimeo thumbnails 2029 $thumb.each(function() { 2030 var $this = $(this); 2031 var vimeoVideoId = $this.attr('data-vimeo-id'); 2032 2033 if (vimeoVideoId) { 2034 $.getJSON('//www.vimeo.com/api/v2/video/' + vimeoVideoId + '.json?callback=?', { 2035 format: 'json' 2036 }, function(data) { 2037 $this.find('img').attr('src', data[0][_this.core.s.vimeoThumbSize]); 2038 }); 2039 } 2040 }); 2041 2042 // manage active class for thumbnail 2043 $thumb.eq(_this.core.index).addClass('active'); 2044 _this.core.$el.on('onBeforeSlide.lg.tm', function() { 2045 $thumb.removeClass('active'); 2046 $thumb.eq(_this.core.index).addClass('active'); 2047 }); 2048 2049 $thumb.on('click.lg touchend.lg', function() { 2050 var _$this = $(this); 2051 setTimeout(function() { 2052 2053 // In IE9 and bellow touch does not support 2054 // Go to slide if browser does not support css transitions 2055 if ((_this.thumbClickable && !_this.core.lgBusy) || !_this.core.doCss()) { 2056 _this.core.index = _$this.index(); 2057 _this.core.slide(_this.core.index, false, true, false); 2058 } 2059 }, 50); 2060 }); 2061 2062 _this.core.$el.on('onBeforeSlide.lg.tm', function() { 2063 _this.animateThumb(_this.core.index); 2064 }); 2065 2066 $(window).on('resize.lg.thumb orientationchange.lg.thumb', function() { 2067 setTimeout(function() { 2068 _this.animateThumb(_this.core.index); 2069 _this.thumbOuterWidth = _this.$thumbOuter.width(); 2070 }, 200); 2071 }); 2072 2073 }; 2074 2075 Thumbnail.prototype.setTranslate = function(value) { 2076 // jQuery supports Automatic CSS prefixing since jQuery 1.8.0 2077 this.core.$outer.find('.lg-thumb').css({ 2078 transform: 'translate3d(-' + (value) + 'px, 0px, 0px)' 2079 }); 2080 }; 2081 2082 Thumbnail.prototype.animateThumb = function(index) { 2083 var $thumb = this.core.$outer.find('.lg-thumb'); 2084 if (this.core.s.animateThumb) { 2085 var position; 2086 switch (this.core.s.currentPagerPosition) { 2087 case 'left': 2088 position = 0; 2089 break; 2090 case 'middle': 2091 position = (this.thumbOuterWidth / 2) - (this.core.s.thumbWidth / 2); 2092 break; 2093 case 'right': 2094 position = this.thumbOuterWidth - this.core.s.thumbWidth; 2095 } 2096 this.left = ((this.core.s.thumbWidth + this.core.s.thumbMargin) * index - 1) - position; 2097 if (this.left > (this.thumbTotalWidth - this.thumbOuterWidth)) { 2098 this.left = this.thumbTotalWidth - this.thumbOuterWidth; 2099 } 2100 2101 if (this.left < 0) { 2102 this.left = 0; 2103 } 2104 2105 if (this.core.lGalleryOn) { 2106 if (!$thumb.hasClass('on')) { 2107 this.core.$outer.find('.lg-thumb').css('transition-duration', this.core.s.speed + 'ms'); 2108 } 2109 2110 if (!this.core.doCss()) { 2111 $thumb.animate({ 2112 left: -this.left + 'px' 2113 }, this.core.s.speed); 2114 } 2115 } else { 2116 if (!this.core.doCss()) { 2117 $thumb.css('left', -this.left + 'px'); 2118 } 2119 } 2120 2121 this.setTranslate(this.left); 2122 2123 } 2124 }; 2125 2126 // Enable thumbnail dragging and swiping 2127 Thumbnail.prototype.enableThumbDrag = function() { 2128 2129 var _this = this; 2130 var startCoords = 0; 2131 var endCoords = 0; 2132 var isDraging = false; 2133 var isMoved = false; 2134 var tempLeft = 0; 2135 2136 _this.$thumbOuter.addClass('lg-grab'); 2137 2138 _this.core.$outer.find('.lg-thumb').on('mousedown.lg.thumb', function(e) { 2139 if (_this.thumbTotalWidth > _this.thumbOuterWidth) { 2140 // execute only on .lg-object 2141 e.preventDefault(); 2142 startCoords = e.pageX; 2143 isDraging = true; 2144 2145 // ** Fix for webkit cursor issue https://code.google.com/p/chromium/issues/detail?id=26723 2146 _this.core.$outer.scrollLeft += 1; 2147 _this.core.$outer.scrollLeft -= 1; 2148 2149 // * 2150 _this.thumbClickable = false; 2151 _this.$thumbOuter.removeClass('lg-grab').addClass('lg-grabbing'); 2152 } 2153 }); 2154 2155 $(window).on('mousemove.lg.thumb', function(e) { 2156 if (isDraging) { 2157 tempLeft = _this.left; 2158 isMoved = true; 2159 endCoords = e.pageX; 2160 2161 _this.$thumbOuter.addClass('lg-dragging'); 2162 2163 tempLeft = tempLeft - (endCoords - startCoords); 2164 2165 if (tempLeft > (_this.thumbTotalWidth - _this.thumbOuterWidth)) { 2166 tempLeft = _this.thumbTotalWidth - _this.thumbOuterWidth; 2167 } 2168 2169 if (tempLeft < 0) { 2170 tempLeft = 0; 2171 } 2172 2173 // move current slide 2174 _this.setTranslate(tempLeft); 2175 2176 } 2177 }); 2178 2179 $(window).on('mouseup.lg.thumb', function() { 2180 if (isMoved) { 2181 isMoved = false; 2182 _this.$thumbOuter.removeClass('lg-dragging'); 2183 2184 _this.left = tempLeft; 2185 2186 if (Math.abs(endCoords - startCoords) < _this.core.s.swipeThreshold) { 2187 _this.thumbClickable = true; 2188 } 2189 2190 } else { 2191 _this.thumbClickable = true; 2192 } 2193 2194 if (isDraging) { 2195 isDraging = false; 2196 _this.$thumbOuter.removeClass('lg-grabbing').addClass('lg-grab'); 2197 } 2198 }); 2199 2200 }; 2201 2202 Thumbnail.prototype.enableThumbSwipe = function() { 2203 var _this = this; 2204 var startCoords = 0; 2205 var endCoords = 0; 2206 var isMoved = false; 2207 var tempLeft = 0; 2208 2209 _this.core.$outer.find('.lg-thumb').on('touchstart.lg', function(e) { 2210 if (_this.thumbTotalWidth > _this.thumbOuterWidth) { 2211 e.preventDefault(); 2212 startCoords = e.originalEvent.targetTouches[0].pageX; 2213 _this.thumbClickable = false; 2214 } 2215 }); 2216 2217 _this.core.$outer.find('.lg-thumb').on('touchmove.lg', function(e) { 2218 if (_this.thumbTotalWidth > _this.thumbOuterWidth) { 2219 e.preventDefault(); 2220 endCoords = e.originalEvent.targetTouches[0].pageX; 2221 isMoved = true; 2222 2223 _this.$thumbOuter.addClass('lg-dragging'); 2224 2225 tempLeft = _this.left; 2226 2227 tempLeft = tempLeft - (endCoords - startCoords); 2228 2229 if (tempLeft > (_this.thumbTotalWidth - _this.thumbOuterWidth)) { 2230 tempLeft = _this.thumbTotalWidth - _this.thumbOuterWidth; 2231 } 2232 2233 if (tempLeft < 0) { 2234 tempLeft = 0; 2235 } 2236 2237 // move current slide 2238 _this.setTranslate(tempLeft); 2239 2240 } 2241 }); 2242 2243 _this.core.$outer.find('.lg-thumb').on('touchend.lg', function() { 2244 if (_this.thumbTotalWidth > _this.thumbOuterWidth) { 2245 2246 if (isMoved) { 2247 isMoved = false; 2248 _this.$thumbOuter.removeClass('lg-dragging'); 2249 if (Math.abs(endCoords - startCoords) < _this.core.s.swipeThreshold) { 2250 _this.thumbClickable = true; 2251 } 2252 2253 _this.left = tempLeft; 2254 } else { 2255 _this.thumbClickable = true; 2256 } 2257 } else { 2258 _this.thumbClickable = true; 2259 } 2260 }); 2261 2262 }; 2263 2264 Thumbnail.prototype.toogle = function() { 2265 var _this = this; 2266 if (_this.core.s.toogleThumb) { 2267 _this.core.$outer.addClass('lg-can-toggle'); 2268 _this.$thumbOuter.append('<button aria-label="Toggle thumbnails" class="lg-toogle-thumb lg-icon"></button>'); 2269 _this.core.$outer.find('.lg-toogle-thumb').on('click.lg', function() { 2270 _this.core.$outer.toggleClass('lg-thumb-open'); 2271 }); 2272 } 2273 }; 2274 2275 Thumbnail.prototype.thumbkeyPress = function() { 2276 var _this = this; 2277 $(window).on('keydown.lg.thumb', function(e) { 2278 if (e.keyCode === 38) { 2279 e.preventDefault(); 2280 _this.core.$outer.addClass('lg-thumb-open'); 2281 } else if (e.keyCode === 40) { 2282 e.preventDefault(); 2283 _this.core.$outer.removeClass('lg-thumb-open'); 2284 } 2285 }); 2286 }; 2287 2288 Thumbnail.prototype.destroy = function() { 2289 if (this.core.s.thumbnail && this.core.$items.length > 1) { 2290 $(window).off('resize.lg.thumb orientationchange.lg.thumb keydown.lg.thumb'); 2291 this.$thumbOuter.remove(); 2292 this.core.$outer.removeClass('lg-has-thumb'); 2293 } 2294 }; 2295 2296 $.fn.lightGallery.modules.Thumbnail = Thumbnail; 2297 2298})(); 2299 2300})); 2301 2302/*! lg-video - v1.3.0 - 2020-05-03 2303* http://sachinchoolur.github.io/lightGallery 2304* Copyright (c) 2020 Sachin N; Licensed GPLv3 */ 2305 2306(function (root, factory) { 2307 if (typeof define === 'function' && define.amd) { 2308 // AMD. Register as an anonymous module unless amdModuleId is set 2309 define(['jquery'], function (a0) { 2310 return (factory(a0)); 2311 }); 2312 } else if (typeof module === 'object' && module.exports) { 2313 // Node. Does not work with strict CommonJS, but 2314 // only CommonJS-like environments that support module.exports, 2315 // like Node. 2316 module.exports = factory(require('jquery')); 2317 } else { 2318 factory(root["jQuery"]); 2319 } 2320}(this, function ($) { 2321 2322(function() { 2323 2324 'use strict'; 2325 2326 var defaults = { 2327 videoMaxWidth: '855px', 2328 2329 autoplayFirstVideo: true, 2330 2331 youtubePlayerParams: false, 2332 vimeoPlayerParams: false, 2333 dailymotionPlayerParams: false, 2334 vkPlayerParams: false, 2335
vendor: 13,776 bytes, lines 2336-2681
2336 videojs: false, 2337 videojsOptions: {} 2338 }; 2339 2340 var Video = function(element) { 2341 2342 this.core = $(element).data('lightGallery'); 2343 2344 this.$el = $(element); 2345 this.core.s = $.extend({}, defaults, this.core.s); 2346 this.videoLoaded = false; 2347 2348 this.init(); 2349 2350 return this; 2351 }; 2352 2353 Video.prototype.init = function() { 2354 var _this = this; 2355 2356 // Event triggered when video url found without poster 2357 _this.core.$el.on('hasVideo.lg.tm', onHasVideo.bind(this)); 2358 2359 // Set max width for video 2360 _this.core.$el.on('onAferAppendSlide.lg.tm', onAferAppendSlide.bind(this)); 2361 2362 if (_this.core.doCss() && (_this.core.$items.length > 1) && (_this.core.s.enableSwipe || _this.core.s.enableDrag)) { 2363 _this.core.$el.on('onSlideClick.lg.tm', function() { 2364 var $el = _this.core.$slide.eq(_this.core.index); 2365 _this.loadVideoOnclick($el); 2366 }); 2367 } else { 2368 2369 // For IE 9 and bellow 2370 _this.core.$slide.on('click.lg', function() { 2371 _this.loadVideoOnclick($(this)); 2372 }); 2373 } 2374 2375 _this.core.$el.on('onBeforeSlide.lg.tm', onBeforeSlide.bind(this)); 2376 2377 _this.core.$el.on('onAfterSlide.lg.tm', function(event, prevIndex) { 2378 _this.core.$slide.eq(prevIndex).removeClass('lg-video-playing'); 2379 }); 2380 2381 if (_this.core.s.autoplayFirstVideo) { 2382 _this.core.$el.on('onAferAppendSlide.lg.tm', function (e, index) { 2383 if (!_this.core.lGalleryOn) { 2384 var $el = _this.core.$slide.eq(index); 2385 setTimeout(function () { 2386 _this.loadVideoOnclick($el); 2387 }, 100); 2388 } 2389 }); 2390 } 2391 }; 2392 2393 Video.prototype.loadVideo = function(src, addClass, noPoster, index, html) { 2394 var _this = this; 2395 var video = ''; 2396 var autoplay = 1; 2397 var a = ''; 2398 var isVideo = this.core.isVideo(src, index) || {}; 2399 var videoTitle; 2400 2401 if (_this.core.s.dynamic) { 2402 videoTitle = _this.core.s.dynamicEl[_this.core.index].title; 2403 } else { 2404 videoTitle = _this.core.$items.eq(_this.core.index).attr('title') || _this.core.$items.eq(_this.core.index).find('img').first().attr('alt'); 2405 } 2406 2407 videoTitle = videoTitle ? 'title="' + videoTitle + '"' : ''; 2408 2409 // Enable autoplay based on setting for first video if poster doesn't exist 2410 if (noPoster) { 2411 if (this.videoLoaded) { 2412 autoplay = 0; 2413 } else { 2414 autoplay = this.core.s.autoplayFirstVideo ? 1 : 0; 2415 } 2416 } 2417 2418 if (isVideo.youtube) { 2419 2420 a = '?wmode=opaque&autoplay=' + autoplay + '&enablejsapi=1'; 2421 if (this.core.s.youtubePlayerParams) { 2422 a = a + '&' + $.param(this.core.s.youtubePlayerParams); 2423 } 2424 2425 video = '<iframe class="lg-video-object lg-youtube ' + addClass + '" ' + videoTitle + ' width="560" height="315" src="//www.youtube.com/embed/' + isVideo.youtube[1] + a + '" frameborder="0" allowfullscreen></iframe>'; 2426 2427 } else if (isVideo.vimeo) { 2428 2429 a = '?autoplay=' + autoplay + '&api=1'; 2430 if (this.core.s.vimeoPlayerParams) { 2431 a = a + '&' + $.param(this.core.s.vimeoPlayerParams); 2432 } 2433 2434 video = '<iframe class="lg-video-object lg-vimeo ' + addClass + '" ' + videoTitle + ' width="560" height="315" src="//player.vimeo.com/video/' + isVideo.vimeo[1] + a + '" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>'; 2435 2436 } else if (isVideo.dailymotion) { 2437 2438 a = '?wmode=opaque&autoplay=' + autoplay + '&api=postMessage'; 2439 if (this.core.s.dailymotionPlayerParams) { 2440 a = a + '&' + $.param(this.core.s.dailymotionPlayerParams); 2441 } 2442 2443 video = '<iframe class="lg-video-object lg-dailymotion ' + addClass + '" ' + videoTitle + ' width="560" height="315" src="//www.dailymotion.com/embed/video/' + isVideo.dailymotion[1] + a + '" frameborder="0" allowfullscreen></iframe>'; 2444 2445 } else if (isVideo.html5) { 2446 var fL = html.substring(0, 1); 2447 if (fL === '.' || fL === '#') { 2448 html = $(html).html(); 2449 } 2450 2451 video = html; 2452 2453 } else if (isVideo.vk) { 2454 2455 a = '&autoplay=' + autoplay; 2456 if (this.core.s.vkPlayerParams) { 2457 a = a + '&' + $.param(this.core.s.vkPlayerParams); 2458 } 2459 2460 video = '<iframe class="lg-video-object lg-vk ' + addClass + '" ' + videoTitle + ' width="560" height="315" src="//vk.com/video_ext.php?' + isVideo.vk[1] + a + '" frameborder="0" allowfullscreen></iframe>'; 2461 2462 } 2463 2464 return video; 2465 }; 2466 2467 Video.prototype.loadVideoOnclick = function($el){ 2468 2469 var _this = this; 2470 // check slide has poster 2471 if ($el.find('.lg-object').hasClass('lg-has-poster') && $el.find('.lg-object').is(':visible')) { 2472 2473 // check already video element present 2474 if (!$el.hasClass('lg-has-video')) { 2475 2476 $el.addClass('lg-video-playing lg-has-video'); 2477 2478 var _src; 2479 var _html; 2480 var _loadVideo = function(_src, _html) { 2481 2482 $el.find('.lg-video').append(_this.loadVideo(_src, '', false, _this.core.index, _html)); 2483 2484 if (_html) { 2485 if (_this.core.s.videojs) { 2486 try { 2487 videojs(_this.core.$slide.eq(_this.core.index).find('.lg-html5').get(0), _this.core.s.videojsOptions, function() { 2488 this.play(); 2489 }); 2490 } catch (e) { 2491 console.error('Make sure you have included videojs'); 2492 } 2493 } else { 2494 _this.core.$slide.eq(_this.core.index).find('.lg-html5').get(0).play(); 2495 } 2496 } 2497 2498 }; 2499 2500 if (_this.core.s.dynamic) { 2501 2502 _src = _this.core.s.dynamicEl[_this.core.index].src; 2503 _html = _this.core.s.dynamicEl[_this.core.index].html; 2504 2505 _loadVideo(_src, _html); 2506 2507 } else { 2508 2509 _src = _this.core.$items.eq(_this.core.index).attr('href') || _this.core.$items.eq(_this.core.index).attr('data-src'); 2510 _html = _this.core.$items.eq(_this.core.index).attr('data-html'); 2511 2512 _loadVideo(_src, _html); 2513 2514 } 2515 2516 var $tempImg = $el.find('.lg-object'); 2517 $el.find('.lg-video').append($tempImg); 2518 2519 // @todo loading icon for html5 videos also 2520 // for showing the loading indicator while loading video 2521 if (!$el.find('.lg-video-object').hasClass('lg-html5')) { 2522 $el.removeClass('lg-complete'); 2523 $el.find('.lg-video-object').on('load.lg error.lg', function() { 2524 $el.addClass('lg-complete'); 2525 }); 2526 } 2527 2528 } else { 2529 2530 var youtubePlayer = $el.find('.lg-youtube').get(0); 2531 var vimeoPlayer = $el.find('.lg-vimeo').get(0); 2532 var dailymotionPlayer = $el.find('.lg-dailymotion').get(0); 2533 var html5Player = $el.find('.lg-html5').get(0); 2534 if (youtubePlayer) { 2535 youtubePlayer.contentWindow.postMessage('{"event":"command","func":"playVideo","args":""}', '*'); 2536 } else if (vimeoPlayer) { 2537 try { 2538 $f(vimeoPlayer).api('play'); 2539 } catch (e) { 2540 console.error('Make sure you have included froogaloop2 js'); 2541 } 2542 } else if (dailymotionPlayer) { 2543 dailymotionPlayer.contentWindow.postMessage('play', '*'); 2544 2545 } else if (html5Player) { 2546 if (_this.core.s.videojs) { 2547 try { 2548 videojs(html5Player).play(); 2549 } catch (e) { 2550 console.error('Make sure you have included videojs'); 2551 } 2552 } else { 2553 html5Player.play(); 2554 } 2555 } 2556 2557 $el.addClass('lg-video-playing'); 2558 2559 } 2560 } 2561 }; 2562 2563 Video.prototype.destroy = function() { 2564 this.videoLoaded = false; 2565 }; 2566 2567 function onHasVideo(event, index, src, html) { 2568 /*jshint validthis:true */ 2569 var _this = this; 2570 _this.core.$slide.eq(index).find('.lg-video').append(_this.loadVideo(src, 'lg-object', true, index, html)); 2571 if (html) { 2572 if (_this.core.s.videojs) { 2573 try { 2574 videojs(_this.core.$slide.eq(index).find('.lg-html5').get(0), _this.core.s.videojsOptions, function() { 2575 if (!_this.videoLoaded && _this.core.s.autoplayFirstVideo) { 2576 this.play(); 2577 } 2578 }); 2579 } catch (e) { 2580 console.error('Make sure you have included videojs'); 2581 } 2582 } else { 2583 if(!_this.videoLoaded && _this.core.s.autoplayFirstVideo) { 2584 _this.core.$slide.eq(index).find('.lg-html5').get(0).play(); 2585 } 2586 } 2587 } 2588 } 2589 2590 function onAferAppendSlide(event, index) { 2591 /*jshint validthis:true */ 2592 var $videoCont = this.core.$slide.eq(index).find('.lg-video-cont'); 2593 if (!$videoCont.hasClass('lg-has-iframe')) { 2594 $videoCont.css('max-width', this.core.s.videoMaxWidth); 2595 this.videoLoaded = true; 2596 } 2597 } 2598 2599 function onBeforeSlide(event, prevIndex, index) { 2600 /*jshint validthis:true */ 2601 var _this = this; 2602 2603 var $videoSlide = _this.core.$slide.eq(prevIndex); 2604 var youtubePlayer = $videoSlide.find('.lg-youtube').get(0); 2605 var vimeoPlayer = $videoSlide.find('.lg-vimeo').get(0); 2606 var dailymotionPlayer = $videoSlide.find('.lg-dailymotion').get(0); 2607 var vkPlayer = $videoSlide.find('.lg-vk').get(0); 2608 var html5Player = $videoSlide.find('.lg-html5').get(0); 2609 if (youtubePlayer) { 2610 youtubePlayer.contentWindow.postMessage('{"event":"command","func":"pauseVideo","args":""}', '*'); 2611 } else if (vimeoPlayer) { 2612 try { 2613 $f(vimeoPlayer).api('pause'); 2614 } catch (e) { 2615 console.error('Make sure you have included froogaloop2 js'); 2616 } 2617 } else if (dailymotionPlayer) { 2618 dailymotionPlayer.contentWindow.postMessage('pause', '*'); 2619 2620 } else if (html5Player) { 2621 if (_this.core.s.videojs) { 2622 try { 2623 videojs(html5Player).pause(); 2624 } catch (e) { 2625 console.error('Make sure you have included videojs'); 2626 } 2627 } else { 2628 html5Player.pause(); 2629 } 2630 } if (vkPlayer) { 2631 $(vkPlayer).attr('src', $(vkPlayer).attr('src').replace('&autoplay', '&noplay')); 2632 } 2633 2634 var _src; 2635 if (_this.core.s.dynamic) { 2636 _src = _this.core.s.dynamicEl[index].src; 2637 } else { 2638 _src = _this.core.$items.eq(index).attr('href') || _this.core.$items.eq(index).attr('data-src'); 2639 2640 } 2641 2642 var _isVideo = _this.core.isVideo(_src, index) || {}; 2643 if (_isVideo.youtube || _isVideo.vimeo || _isVideo.dailymotion || _isVideo.vk) { 2644 _this.core.$outer.addClass('lg-hide-download'); 2645 } 2646 2647 } 2648 2649 $.fn.lightGallery.modules.video = Video; 2650 2651 })(); 2652 2653 2654})); 2655 2656/*! lg-zoom - v1.2.0 - 2020-05-03 2657* http://sachinchoolur.github.io/lightGallery 2658* Copyright (c) 2020 Sachin N; Licensed GPLv3 */ 2659 2660(function (root, factory) { 2661 if (typeof define === 'function' && define.amd) { 2662 // AMD. Register as an anonymous module unless amdModuleId is set 2663 define(['jquery'], function (a0) { 2664 return (factory(a0)); 2665 }); 2666 } else if (typeof module === 'object' && module.exports) { 2667 // Node. Does not work with strict CommonJS, but 2668 // only CommonJS-like environments that support module.exports, 2669 // like Node. 2670 module.exports = factory(require('jquery')); 2671 } else { 2672 factory(root["jQuery"]); 2673 } 2674}(this, function ($) { 2675 2676(function() { 2677 2678 'use strict'; 2679 2680 var getUseLeft = function() { 2681 var useLeft = false;
vendor: 10,633 bytes, lines 2682-2997
2682 var isChrome = navigator.userAgent.match(/Chrom(e|ium)\/([0-9]+)\./); 2683 if (isChrome && parseInt(isChrome[2], 10) < 54) { 2684 useLeft = true; 2685 } 2686 2687 return useLeft; 2688 }; 2689 2690 var defaults = { 2691 scale: 1, 2692 zoom: true, 2693 actualSize: true, 2694 enableZoomAfter: 300, 2695 useLeftForZoom: getUseLeft() 2696 }; 2697 2698 var Zoom = function(element) { 2699 2700 this.core = $(element).data('lightGallery'); 2701 2702 this.core.s = $.extend({}, defaults, this.core.s); 2703 2704 if (this.core.s.zoom && this.core.doCss()) { 2705 this.init(); 2706 2707 // Store the zoomable timeout value just to clear it while closing 2708 this.zoomabletimeout = false; 2709 2710 // Set the initial value center 2711 this.pageX = $(window).width() / 2; 2712 this.pageY = ($(window).height() / 2) + $(window).scrollTop(); 2713 } 2714 2715 return this; 2716 }; 2717 2718 Zoom.prototype.init = function() { 2719 2720 var _this = this; 2721 var zoomIcons = '<button aria-label="Zoom in" id="lg-zoom-in" class="lg-icon"></button><button aria-label="Zoom out" id="lg-zoom-out" class="lg-icon"></button>'; 2722 2723 if (_this.core.s.actualSize) { 2724 zoomIcons += '<button aria-label="Actual size" id="lg-actual-size" class="lg-icon"></button>'; 2725 } 2726 2727 if (_this.core.s.useLeftForZoom) { 2728 _this.core.$outer.addClass('lg-use-left-for-zoom'); 2729 } else { 2730 _this.core.$outer.addClass('lg-use-transition-for-zoom'); 2731 } 2732 2733 this.core.$outer.find('.lg-toolbar').append(zoomIcons); 2734 2735 // Add zoomable class 2736 _this.core.$el.on('onSlideItemLoad.lg.tm.zoom', function(event, index, delay) { 2737 2738 // delay will be 0 except first time 2739 var _speed = _this.core.s.enableZoomAfter + delay; 2740 2741 // set _speed value 0 if gallery opened from direct url and if it is first slide 2742 if ($('body').hasClass('lg-from-hash') && delay) { 2743 2744 // will execute only once 2745 _speed = 0; 2746 } else { 2747 2748 // Remove lg-from-hash to enable starting animation. 2749 $('body').removeClass('lg-from-hash'); 2750 } 2751 2752 _this.zoomabletimeout = setTimeout(function() { 2753 _this.core.$slide.eq(index).addClass('lg-zoomable'); 2754 }, _speed + 30); 2755 }); 2756 2757 var scale = 1; 2758 /** 2759 * @desc Image zoom 2760 * Translate the wrap and scale the image to get better user experience 2761 * 2762 * @param {String} scaleVal - Zoom decrement/increment value 2763 */ 2764 var zoom = function(scaleVal) { 2765 2766 var $image = _this.core.$outer.find('.lg-current .lg-image'); 2767 var _x; 2768 var _y; 2769 2770 // Find offset manually to avoid issue after zoom 2771 var offsetX = ($(window).width() - $image.prop('offsetWidth')) / 2; 2772 var offsetY = (($(window).height() - $image.prop('offsetHeight')) / 2) + $(window).scrollTop(); 2773 2774 _x = _this.pageX - offsetX; 2775 _y = _this.pageY - offsetY; 2776 2777 var x = (scaleVal - 1) * (_x); 2778 var y = (scaleVal - 1) * (_y); 2779 2780 $image.css('transform', 'scale3d(' + scaleVal + ', ' + scaleVal + ', 1)').attr('data-scale', scaleVal); 2781 2782 if (_this.core.s.useLeftForZoom) { 2783 $image.parent().css({ 2784 left: -x + 'px', 2785 top: -y + 'px' 2786 }).attr('data-x', x).attr('data-y', y); 2787 } else { 2788 $image.parent().css('transform', 'translate3d(-' + x + 'px, -' + y + 'px, 0)').attr('data-x', x).attr('data-y', y); 2789 } 2790 }; 2791 2792 var callScale = function() { 2793 if (scale > 1) { 2794 _this.core.$outer.addClass('lg-zoomed'); 2795 } else { 2796 _this.resetZoom(); 2797 } 2798 2799 if (scale < 1) { 2800 scale = 1; 2801 } 2802 2803 zoom(scale); 2804 }; 2805 2806 var actualSize = function(event, $image, index, fromIcon) { 2807 var w = $image.prop('offsetWidth'); 2808 var nw; 2809 if (_this.core.s.dynamic) { 2810 nw = _this.core.s.dynamicEl[index].width || $image[0].naturalWidth || w; 2811 } else { 2812 nw = _this.core.$items.eq(index).attr('data-width') || $image[0].naturalWidth || w; 2813 } 2814 2815 var _scale; 2816 2817 if (_this.core.$outer.hasClass('lg-zoomed')) { 2818 scale = 1; 2819 } else { 2820 if (nw > w) { 2821 _scale = nw / w; 2822 scale = _scale || 2; 2823 } 2824 } 2825 2826 if (fromIcon) { 2827 _this.pageX = $(window).width() / 2; 2828 _this.pageY = ($(window).height() / 2) + $(window).scrollTop(); 2829 } else { 2830 _this.pageX = event.pageX || event.originalEvent.targetTouches[0].pageX; 2831 _this.pageY = event.pageY || event.originalEvent.targetTouches[0].pageY; 2832 } 2833 2834 callScale(); 2835 setTimeout(function() { 2836 _this.core.$outer.removeClass('lg-grabbing').addClass('lg-grab'); 2837 }, 10); 2838 }; 2839 2840 var tapped = false; 2841 2842 // event triggered after appending slide content 2843 _this.core.$el.on('onAferAppendSlide.lg.tm.zoom', function(event, index) { 2844 2845 // Get the current element 2846 var $image = _this.core.$slide.eq(index).find('.lg-image'); 2847 2848 $image.on('dblclick', function(event) { 2849 actualSize(event, $image, index); 2850 }); 2851 2852 $image.on('touchstart', function(event) { 2853 if (!tapped) { 2854 tapped = setTimeout(function() { 2855 tapped = null; 2856 }, 300); 2857 } else { 2858 clearTimeout(tapped); 2859 tapped = null; 2860 actualSize(event, $image, index); 2861 } 2862 2863 event.preventDefault(); 2864 }); 2865 2866 }); 2867 2868 // Update zoom on resize and orientationchange 2869 $(window).on('resize.lg.zoom scroll.lg.zoom orientationchange.lg.zoom', function() { 2870 _this.pageX = $(window).width() / 2; 2871 _this.pageY = ($(window).height() / 2) + $(window).scrollTop(); 2872 zoom(scale); 2873 }); 2874 2875 $('#lg-zoom-out').on('click.lg', function() { 2876 if (_this.core.$outer.find('.lg-current .lg-image').length) { 2877 scale -= _this.core.s.scale; 2878 callScale(); 2879 } 2880 }); 2881 2882 $('#lg-zoom-in').on('click.lg', function() { 2883 if (_this.core.$outer.find('.lg-current .lg-image').length) { 2884 scale += _this.core.s.scale; 2885 callScale(); 2886 } 2887 }); 2888 2889 $('#lg-actual-size').on('click.lg', function(event) { 2890 actualSize(event, _this.core.$slide.eq(_this.core.index).find('.lg-image'), _this.core.index, true); 2891 }); 2892 2893 // Reset zoom on slide change 2894 _this.core.$el.on('onBeforeSlide.lg.tm', function() { 2895 scale = 1; 2896 _this.resetZoom(); 2897 }); 2898 2899 // Drag option after zoom 2900 _this.zoomDrag(); 2901 2902 _this.zoomSwipe(); 2903 2904 }; 2905 2906 // Reset zoom effect 2907 Zoom.prototype.resetZoom = function() { 2908 this.core.$outer.removeClass('lg-zoomed'); 2909 this.core.$slide.find('.lg-img-wrap').removeAttr('style data-x data-y'); 2910 this.core.$slide.find('.lg-image').removeAttr('style data-scale'); 2911 2912 // Reset pagx pagy values to center 2913 this.pageX = $(window).width() / 2; 2914 this.pageY = ($(window).height() / 2) + $(window).scrollTop(); 2915 }; 2916 2917 Zoom.prototype.zoomSwipe = function() { 2918 var _this = this; 2919 var startCoords = {}; 2920 var endCoords = {}; 2921 var isMoved = false; 2922 2923 // Allow x direction drag 2924 var allowX = false; 2925 2926 // Allow Y direction drag 2927 var allowY = false; 2928 2929 _this.core.$slide.on('touchstart.lg', function(e) { 2930 2931 if (_this.core.$outer.hasClass('lg-zoomed')) { 2932 var $image = _this.core.$slide.eq(_this.core.index).find('.lg-object'); 2933 2934 allowY = $image.prop('offsetHeight') * $image.attr('data-scale') > _this.core.$outer.find('.lg').height(); 2935 allowX = $image.prop('offsetWidth') * $image.attr('data-scale') > _this.core.$outer.find('.lg').width(); 2936 if ((allowX || allowY)) { 2937 e.preventDefault(); 2938 startCoords = { 2939 x: e.originalEvent.targetTouches[0].pageX, 2940 y: e.originalEvent.targetTouches[0].pageY 2941 }; 2942 } 2943 } 2944 2945 }); 2946 2947 _this.core.$slide.on('touchmove.lg', function(e) { 2948 2949 if (_this.core.$outer.hasClass('lg-zoomed')) { 2950 2951 var _$el = _this.core.$slide.eq(_this.core.index).find('.lg-img-wrap'); 2952 var distanceX; 2953 var distanceY; 2954 2955 e.preventDefault(); 2956 isMoved = true; 2957 2958 endCoords = { 2959 x: e.originalEvent.targetTouches[0].pageX, 2960 y: e.originalEvent.targetTouches[0].pageY 2961 }; 2962 2963 // reset opacity and transition duration 2964 _this.core.$outer.addClass('lg-zoom-dragging'); 2965 2966 if (allowY) { 2967 distanceY = (-Math.abs(_$el.attr('data-y'))) + (endCoords.y - startCoords.y); 2968 } else { 2969 distanceY = -Math.abs(_$el.attr('data-y')); 2970 } 2971 2972 if (allowX) { 2973 distanceX = (-Math.abs(_$el.attr('data-x'))) + (endCoords.x - startCoords.x); 2974 } else { 2975 distanceX = -Math.abs(_$el.attr('data-x')); 2976 } 2977 2978 if ((Math.abs(endCoords.x - startCoords.x) > 15) || (Math.abs(endCoords.y - startCoords.y) > 15)) { 2979 2980 if (_this.core.s.useLeftForZoom) { 2981 _$el.css({ 2982 left: distanceX + 'px', 2983 top: distanceY + 'px' 2984 }); 2985 } else { 2986 _$el.css('transform', 'translate3d(' + distanceX + 'px, ' + distanceY + 'px, 0)'); 2987 } 2988 } 2989 2990 } 2991 2992 }); 2993 2994 _this.core.$slide.on('touchend.lg', function() { 2995 if (_this.core.$outer.hasClass('lg-zoomed')) { 2996 if (isMoved) { 2997 isMoved = false;
2998 _this.core.$outer.removeClass('lg-zoom-dragging'); 2999 _this.touchendZoom(startCoords, endCoords, allowX, allowY); 3000 3001 } 3002 } 3003 }); 3004 3005 }; 3006 3007 Zoom.prototype.zoomDrag = function() { 3008 3009 var _this = this; 3010 var startCoords = {}; 3011 var endCoords = {}; 3012 var isDraging = false; 3013 var isMoved = false; 3014 3015 // Allow x direction drag 3016 var allowX = false; 3017 3018 // Allow Y direction drag 3019 var allowY = false; 3020 3021 _this.core.$slide.on('mousedown.lg.zoom', function(e) { 3022 3023 // execute only on .lg-object 3024 var $image = _this.core.$slide.eq(_this.core.index).find('.lg-object'); 3025 3026 allowY = $image.prop('offsetHeight') * $image.attr('data-scale') > _this.core.$outer.find('.lg').height(); 3027 allowX = $image.prop('offsetWidth') * $image.attr('data-scale') > _this.core.$outer.find('.lg').width(); 3028 3029 if (_this.core.$outer.hasClass('lg-zoomed')) { 3030 if ($(e.target).hasClass('lg-object') && (allowX || allowY)) { 3031 e.preventDefault(); 3032 startCoords = { 3033 x: e.pageX, 3034 y: e.pageY 3035 }; 3036 3037 isDraging = true; 3038 3039 // ** Fix for webkit cursor issue https://code.google.com/p/chromium/issues/detail?id=26723 3040 _this.core.$outer.scrollLeft += 1; 3041 _this.core.$outer.scrollLeft -= 1; 3042 3043 _this.core.$outer.removeClass('lg-grab').addClass('lg-grabbing'); 3044 } 3045 } 3046 }); 3047 3048 $(window).on('mousemove.lg.zoom', function(e) { 3049 if (isDraging) { 3050 var _$el = _this.core.$slide.eq(_this.core.index).find('.lg-img-wrap'); 3051 var distanceX; 3052 var distanceY; 3053 3054 isMoved = true; 3055 endCoords = { 3056 x: e.pageX, 3057 y: e.pageY 3058 }; 3059 3060 // reset opacity and transition duration 3061 _this.core.$outer.addClass('lg-zoom-dragging'); 3062 3063 if (allowY) { 3064 distanceY = (-Math.abs(_$el.attr('data-y'))) + (endCoords.y - startCoords.y); 3065 } else { 3066 distanceY = -Math.abs(_$el.attr('data-y')); 3067 } 3068 3069 if (allowX) { 3070 distanceX = (-Math.abs(_$el.attr('data-x'))) + (endCoords.x - startCoords.x); 3071 } else { 3072 distanceX = -Math.abs(_$el.attr('data-x')); 3073 } 3074 3075 if (_this.core.s.useLeftForZoom) { 3076 _$el.css({ 3077 left: distanceX + 'px', 3078 top: distanceY + 'px' 3079 }); 3080 } else { 3081 _$el.css('transform', 'translate3d(' + distanceX + 'px, ' + distanceY + 'px, 0)'); 3082 } 3083 } 3084 }); 3085 3086 $(window).on('mouseup.lg.zoom', function(e) { 3087 3088 if (isDraging) { 3089 isDraging = false; 3090 _this.core.$outer.removeClass('lg-zoom-dragging'); 3091 3092 // Fix for chrome mouse move on click 3093 if (isMoved && ((startCoords.x !== endCoords.x) || (startCoords.y !== endCoords.y))) { 3094 endCoords = { 3095 x: e.pageX, 3096 y: e.pageY 3097 }; 3098 _this.touchendZoom(startCoords, endCoords, allowX, allowY); 3099 3100 } 3101 3102 isMoved = false; 3103 } 3104 3105 _this.core.$outer.removeClass('lg-grabbing').addClass('lg-grab'); 3106 3107 }); 3108 }; 3109 3110 Zoom.prototype.touchendZoom = function(startCoords, endCoords, allowX, allowY) { 3111 3112 var _this = this; 3113 var _$el = _this.core.$slide.eq(_this.core.index).find('.lg-img-wrap'); 3114 var $image = _this.core.$slide.eq(_this.core.index).find('.lg-object'); 3115 var distanceX = (-Math.abs(_$el.attr('data-x'))) + (endCoords.x - startCoords.x); 3116 var distanceY = (-Math.abs(_$el.attr('data-y'))) + (endCoords.y - startCoords.y); 3117 var minY = (_this.core.$outer.find('.lg').height() - $image.prop('offsetHeight')) / 2; 3118 var maxY = Math.abs(($image.prop('offsetHeight') * Math.abs($image.attr('data-scale'))) - _this.core.$outer.find('.lg').height() + minY); 3119 var minX = (_this.core.$outer.find('.lg').width() - $image.prop('offsetWidth')) / 2; 3120 var maxX = Math.abs(($image.prop('offsetWidth') * Math.abs($image.attr('data-scale'))) - _this.core.$outer.find('.lg').width() + minX); 3121 3122 if ((Math.abs(endCoords.x - startCoords.x) > 15) || (Math.abs(endCoords.y - startCoords.y) > 15)) { 3123 if (allowY) { 3124 if (distanceY <= -maxY) { 3125 distanceY = -maxY; 3126 } else if (distanceY >= -minY) { 3127 distanceY = -minY; 3128 } 3129 } 3130 3131 if (allowX) { 3132 if (distanceX <= -maxX) { 3133 distanceX = -maxX; 3134 } else if (distanceX >= -minX) { 3135 distanceX = -minX; 3136 } 3137 } 3138 3139 if (allowY) { 3140 _$el.attr('data-y', Math.abs(distanceY)); 3141 } else { 3142 distanceY = -Math.abs(_$el.attr('data-y')); 3143 } 3144 3145 if (allowX) { 3146 _$el.attr('data-x', Math.abs(distanceX)); 3147 } else { 3148 distanceX = -Math.abs(_$el.attr('data-x')); 3149 } 3150 3151 if (_this.core.s.useLeftForZoom) { 3152 _$el.css({ 3153 left: distanceX + 'px', 3154 top: distanceY + 'px' 3155 }); 3156 } else { 3157 _$el.css('transform', 'translate3d(' + distanceX + 'px, ' + distanceY + 'px, 0)'); 3158 } 3159 3160 } 3161 }; 3162 3163 Zoom.prototype.destroy = function() { 3164 3165 var _this = this; 3166 3167 // Unbind all events added by lightGallery zoom plugin 3168 _this.core.$el.off('.lg.zoom'); 3169 $(window).off('.lg.zoom'); 3170 _this.core.$slide.off('.lg.zoom'); 3171 _this.core.$el.off('.lg.tm.zoom'); 3172 _this.resetZoom(); 3173 clearTimeout(_this.zoomabletimeout); 3174 _this.zoomabletimeout = false;
vendor: 6,328 bytes, lines 3175-3362
3175 }; 3176 3177 $.fn.lightGallery.modules.zoom = Zoom; 3178 3179})(); 3180 3181 3182})); 3183 3184/*! lg-hash - v1.0.4 - 2017-12-20 3185* http://sachinchoolur.github.io/lightGallery 3186* Copyright (c) 2017 Sachin N; Licensed GPLv3 */ 3187 3188(function (root, factory) { 3189 if (typeof define === 'function' && define.amd) { 3190 // AMD. Register as an anonymous module unless amdModuleId is set 3191 define(['jquery'], function (a0) { 3192 return (factory(a0)); 3193 }); 3194 } else if (typeof exports === 'object') { 3195 // Node. Does not work with strict CommonJS, but 3196 // only CommonJS-like environments that support module.exports, 3197 // like Node. 3198 module.exports = factory(require('jquery')); 3199 } else { 3200 factory(jQuery); 3201 } 3202}(this, function ($) { 3203 3204(function() { 3205 3206 'use strict'; 3207 3208 var defaults = { 3209 hash: true 3210 }; 3211 3212 var Hash = function(element) { 3213 3214 this.core = $(element).data('lightGallery'); 3215 3216 this.core.s = $.extend({}, defaults, this.core.s); 3217 3218 if (this.core.s.hash) { 3219 this.oldHash = window.location.hash; 3220 this.init(); 3221 } 3222 3223 return this; 3224 }; 3225 3226 Hash.prototype.init = function() { 3227 var _this = this; 3228 var _hash; 3229 3230 // Change hash value on after each slide transition 3231 _this.core.$el.on('onAfterSlide.lg.tm', function(event, prevIndex, index) { 3232 if (history.replaceState) { 3233 history.replaceState(null, null, window.location.pathname + window.location.search + '#lg=' + _this.core.s.galleryId + '&slide=' + index); 3234 } else { 3235 window.location.hash = 'lg=' + _this.core.s.galleryId + '&slide=' + index; 3236 } 3237 }); 3238 3239 // Listen hash change and change the slide according to slide value 3240 $(window).on('hashchange.lg.hash', function() { 3241 _hash = window.location.hash; 3242 var _idx = parseInt(_hash.split('&slide=')[1], 10); 3243 3244 // it galleryId doesn't exist in the url close the gallery 3245 if ((_hash.indexOf('lg=' + _this.core.s.galleryId) > -1)) { 3246 _this.core.slide(_idx, false, false); 3247 } else if (_this.core.lGalleryOn) { 3248 _this.core.destroy(); 3249 } 3250 3251 }); 3252 }; 3253 3254 Hash.prototype.destroy = function() { 3255 3256 if (!this.core.s.hash) { 3257 return; 3258 } 3259 3260 // Reset to old hash value 3261 if (this.oldHash && this.oldHash.indexOf('lg=' + this.core.s.galleryId) < 0) { 3262 if (history.replaceState) { 3263 history.replaceState(null, null, this.oldHash); 3264 } else { 3265 window.location.hash = this.oldHash; 3266 } 3267 } else { 3268 if (history.replaceState) { 3269 history.replaceState(null, document.title, window.location.pathname + window.location.search); 3270 } else { 3271 window.location.hash = ''; 3272 } 3273 } 3274 3275 this.core.$el.off('.lg.hash'); 3276 3277 }; 3278 3279 $.fn.lightGallery.modules.hash = Hash; 3280 3281})(); 3282 3283 3284})); 3285 3286/*! lg-share - v1.1.0 - 2020-05-03 3287* http://sachinchoolur.github.io/lightGallery 3288* Copyright (c) 2020 Sachin N; Licensed GPLv3 */ 3289 3290(function (root, factory) { 3291 if (typeof define === 'function' && define.amd) { 3292 // AMD. Register as an anonymous module unless amdModuleId is set 3293 define(['jquery'], function (a0) { 3294 return (factory(a0)); 3295 }); 3296 } else if (typeof module === 'object' && module.exports) { 3297 // Node. Does not work with strict CommonJS, but 3298 // only CommonJS-like environments that support module.exports, 3299 // like Node. 3300 module.exports = factory(require('jquery')); 3301 } else { 3302 factory(root["jQuery"]); 3303 } 3304}(this, function ($) { 3305 3306(function() { 3307 3308 'use strict'; 3309 3310 var defaults = { 3311 share: true, 3312 facebook: true, 3313 facebookDropdownText: 'Facebook', 3314 twitter: true, 3315 twitterDropdownText: 'Twitter', 3316 googlePlus: true, 3317 googlePlusDropdownText: 'GooglePlus', 3318 pinterest: true, 3319 pinterestDropdownText: 'Pinterest' 3320 }; 3321 3322 var Share = function(element) { 3323 3324 this.core = $(element).data('lightGallery'); 3325 3326 this.core.s = $.extend({}, defaults, this.core.s); 3327 if (this.core.s.share) { 3328 this.init(); 3329 } 3330 3331 return this; 3332 }; 3333 3334 Share.prototype.init = function() { 3335 var _this = this; 3336 3337 var shareHtml = '<button aria-label="Share" id="lg-share" class="lg-icon" aria-haspopup="true" aria-expanded="false">' + 3338 '<ul class="lg-dropdown" style="position: absolute;">'; 3339 shareHtml += _this.core.s.facebook ? '<li><a id="lg-share-facebook" target="_blank"><span class="lg-icon"></span><span class="lg-dropdown-text">' + this.core.s.facebookDropdownText + '</span></a></li>' : ''; 3340 shareHtml += _this.core.s.twitter ? '<li><a id="lg-share-twitter" target="_blank"><span class="lg-icon"></span><span class="lg-dropdown-text">' + this.core.s.twitterDropdownText + '</span></a></li>' : ''; 3341 shareHtml += _this.core.s.googlePlus ? '<li><a id="lg-share-googleplus" target="_blank"><span class="lg-icon"></span><span class="lg-dropdown-text">' + this.core.s.googlePlusDropdownText + '</span></a></li>' : ''; 3342 shareHtml += _this.core.s.pinterest ? '<li><a id="lg-share-pinterest" target="_blank"><span class="lg-icon"></span><span class="lg-dropdown-text">' + this.core.s.pinterestDropdownText + '</span></a></li>' : ''; 3343 shareHtml += '</ul></button>'; 3344 3345 this.core.$outer.find('.lg-toolbar').append(shareHtml); 3346 this.core.$outer.find('.lg').append('<div id="lg-dropdown-overlay"></div>'); 3347 $('#lg-share').on('click.lg', function(){ 3348 _this.core.$outer.toggleClass('lg-dropdown-active'); 3349 var ariaExpanded = $('#lg-share').attr('aria-expanded'); 3350 $('#lg-share').attr('aria-expanded', ariaExpanded === 'true' ? false: true); 3351 }); 3352 3353 $('#lg-dropdown-overlay').on('click.lg', function(){ 3354 _this.core.$outer.removeClass('lg-dropdown-active'); 3355 $('#lg-share').attr('aria-expanded', false); 3356 }); 3357 3358 _this.core.$el.on('onAfterSlide.lg.tm', function(event, prevIndex, index) { 3359 3360 setTimeout(function() { 3361 3362 $('#lg-share-facebook').attr('href', 'https://www.facebook.com/sharer/sharer.php?u=' + (encodeURIComponent(_this.get
vendor: 1,425 bytes, lines 3362-3396
3362SahreProps(index, 'facebookShareUrl') || window.location.href))); 3363 3364 $('#lg-share-twitter').attr('href', 'https://twitter.com/intent/tweet?text=' + _this.getSahreProps(index, 'tweetText') + '&url=' + (encodeURIComponent(_this.getSahreProps(index, 'twitterShareUrl') || window.location.href))); 3365 3366 $('#lg-share-googleplus').attr('href', 'https://plus.google.com/share?url=' + (encodeURIComponent(_this.getSahreProps(index, 'googleplusShareUrl') || window.location.href))); 3367 3368 $('#lg-share-pinterest').attr('href', 'http://www.pinterest.com/pin/create/button/?url=' + (encodeURIComponent(_this.getSahreProps(index, 'pinterestShareUrl') || window.location.href)) + '&media=' + encodeURIComponent(_this.getSahreProps(index, 'src')) + '&description=' + _this.getSahreProps(index, 'pinterestText')); 3369 3370 }, 100); 3371 }); 3372 }; 3373 3374 Share.prototype.getSahreProps = function(index, prop){ 3375 var shareProp = ''; 3376 if(this.core.s.dynamic) { 3377 shareProp = this.core.s.dynamicEl[index][prop]; 3378 } else { 3379 var _href = this.core.$items.eq(index).attr('href'); 3380 var _prop = this.core.$items.eq(index).data(prop); 3381 shareProp = prop === 'src' ? _href || _prop : _prop; 3382 } 3383 return shareProp; 3384 }; 3385 3386 Share.prototype.destroy = function() { 3387 3388 }; 3389 3390 $.fn.lightGallery.modules.share = Share; 3391 3392})(); 3393 3394 3395 3396}));
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.