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