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