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