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