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