1/* 2 _ _ _ _ 3 ___| (_) ___| | __ (_)___ 4/ __| | |/ __| |/ / | / __| 5\__ \ | | (__| < _ | \__ \ 6|___/_|_|\___|_|\_(_)/ |___/ 7 |__/ 8 9 Version: 1.7.1 10 Author: Ken Wheeler 11 Website: http://kenwheeler.github.io 12 Docs: http://kenwheeler.github.io/slick 13 Repo: http://github.com/kenwheeler/slick 14 Issues: http://github.com/kenwheeler/slick/issues 15 16 */ 17/* global window, document, define, jQuery, setInterval, clearInterval */ 18;(function(factory) { 19 'use strict'; 20 if (typeof define === 'function' && define.amd) { 21 define(['jquery'], factory); 22 } else if (typeof exports !== 'undefined') { 23 module.exports = factory(require('jquery')); 24 } else { 25 factory(jQuery); 26 } 27 28}(function($) { 29 'use strict'; 30 var Slick = window.Slick || {}; 31 32 Slick = (function() { 33 34 var instanceUid = 0; 35 36 function Slick(element, settings) { 37 38 var _ = this, dataSettings; 39 40 _.defaults = { 41 accessibility: true, 42 adaptiveHeight: false, 43 appendArrows: $(element), 44 appendDots: $(element), 45 arrows: true, 46 asNavFor: null, 47 prevArrow: '<button class="slick-prev" aria-label="Previous" type="button">Previous</button>', 48 nextArrow: '<button class="slick-next" aria-label="Next" type="button">Next</button>', 49 autoplay: false, 50 autoplaySpeed: 3000, 51 centerMode: false, 52 centerPadding: '50px', 53 cssEase: 'ease', 54 customPaging: function(slider, i) { 55 return $('<button type="button" />').text(i + 1); 56 }, 57 dots: false, 58 dotsClass: 'slick-dots', 59 draggable: true, 60 easing: 'linear', 61 edgeFriction: 0.35, 62 fade: false, 63 focusOnSelect: false, 64 infinite: true, 65 initialSlide: 0, 66 lazyLoad: 'ondemand', 67 mobileFirst: false, 68 pauseOnHover: true, 69 pauseOnFocus: true, 70 pauseOnDotsHover: false, 71 respondTo: 'window', 72 responsive: null, 73 rows: 1, 74 rtl: false, 75 slide: '', 76 slidesPerRow: 1, 77 slidesToShow: 1, 78 slidesToScroll: 1, 79 speed: 500, 80 swipe: true, 81 swipeToSlide: false, 82 touchMove: true, 83 touchThreshold: 5, 84 useCSS: true, 85 useTransform: true, 86 variableWidth: false, 87 vertical: false, 88 verticalSwiping: false, 89 waitForAnimate: true, 90 zIndex: 1000 91 }; 92 93 _.initials = { 94 animating: false, 95 dragging: false, 96 autoPlayTimer: null, 97 currentDirection: 0, 98 currentLeft: null, 99 currentSlide: 0, 100 direction: 1, 101 $dots: null, 102 listWidth: null, 103 listHeight: null, 104 loadIndex: 0, 105 $nextArrow: null, 106 $prevArrow: null, 107 scrolling: false, 108 slideCount: null, 109 slideWidth: null, 110 $slideTrack: null, 111 $slides: null, 112 sliding: false, 113 slideOffset: 0, 114 swipeLeft: null, 115 swiping: false, 116 $list: null, 117 touchObject: {}, 118 transformsEnabled: false, 119 unslicked: false 120 }; 121 122 $.extend(_, _.initials); 123 124 _.activeBreakpoint = null; 125 _.animType = null; 126 _.animProp = null; 127 _.breakpoints = []; 128 _.breakpointSettings = []; 129 _.cssTransitions = false; 130 _.focussed = false; 131 _.interrupted = false;
vendor: 28,506 bytes, lines 132-1090
132 _.hidden = 'hidden'; 133 _.paused = true; 134 _.positionProp = null; 135 _.respondTo = null; 136 _.rowCount = 1; 137 _.shouldClick = true; 138 _.$slider = $(element); 139 _.$slidesCache = null; 140 _.transformType = null; 141 _.transitionType = null; 142 _.visibilityChange = 'visibilitychange'; 143 _.windowWidth = 0; 144 _.windowTimer = null; 145 146 dataSettings = $(element).data('slick') || {}; 147 148 _.options = $.extend({}, _.defaults, settings, dataSettings); 149 150 _.currentSlide = _.options.initialSlide; 151 152 _.originalSettings = _.options; 153 154 if (typeof document.mozHidden !== 'undefined') { 155 _.hidden = 'mozHidden'; 156 _.visibilityChange = 'mozvisibilitychange'; 157 } else if (typeof document.webkitHidden !== 'undefined') { 158 _.hidden = 'webkitHidden'; 159 _.visibilityChange = 'webkitvisibilitychange'; 160 } 161 162 _.autoPlay = $.proxy(_.autoPlay, _); 163 _.autoPlayClear = $.proxy(_.autoPlayClear, _); 164 _.autoPlayIterator = $.proxy(_.autoPlayIterator, _); 165 _.changeSlide = $.proxy(_.changeSlide, _); 166 _.clickHandler = $.proxy(_.clickHandler, _); 167 _.selectHandler = $.proxy(_.selectHandler, _); 168 _.setPosition = $.proxy(_.setPosition, _); 169 _.swipeHandler = $.proxy(_.swipeHandler, _); 170 _.dragHandler = $.proxy(_.dragHandler, _); 171 _.keyHandler = $.proxy(_.keyHandler, _); 172 173 _.instanceUid = instanceUid++; 174 175 // A simple way to check for HTML strings 176 // Strict HTML recognition (must start with <) 177 // Extracted from jQuery v1.11 source 178 _.htmlExpr = /^(?:\s*(<[\w\W]+>)[^>]*)$/; 179 180 181 _.registerBreakpoints(); 182 _.init(true); 183 184 } 185 186 return Slick; 187 188 }()); 189 190 Slick.prototype.activateADA = function() { 191 var _ = this; 192 193 _.$slideTrack.find('.slick-active').attr({ 194 'aria-hidden': 'false' 195 }).find('a, input, button, select').attr({ 196 'tabindex': '0' 197 }); 198 199 }; 200 201 Slick.prototype.addSlide = Slick.prototype.slickAdd = function(markup, index, addBefore) { 202 203 var _ = this; 204 205 if (typeof(index) === 'boolean') { 206 addBefore = index; 207 index = null; 208 } else if (index < 0 || (index >= _.slideCount)) { 209 return false; 210 } 211 212 _.unload(); 213 214 if (typeof(index) === 'number') { 215 if (index === 0 && _.$slides.length === 0) { 216 $(markup).appendTo(_.$slideTrack); 217 } else if (addBefore) { 218 $(markup).insertBefore(_.$slides.eq(index)); 219 } else { 220 $(markup).insertAfter(_.$slides.eq(index)); 221 } 222 } else { 223 if (addBefore === true) { 224 $(markup).prependTo(_.$slideTrack); 225 } else { 226 $(markup).appendTo(_.$slideTrack); 227 } 228 } 229 230 _.$slides = _.$slideTrack.children(this.options.slide); 231 232 _.$slideTrack.children(this.options.slide).detach(); 233 234 _.$slideTrack.append(_.$slides); 235 236 _.$slides.each(function(index, element) { 237 $(element).attr('data-slick-index', index); 238 }); 239 240 _.$slidesCache = _.$slides; 241 242 _.reinit(); 243 244 }; 245 246 Slick.prototype.animateHeight = function() { 247 var _ = this; 248 if (_.options.slidesToShow === 1 && _.options.adaptiveHeight === true && _.options.vertical === false) { 249 var targetHeight = _.$slides.eq(_.currentSlide).outerHeight(true); 250 _.$list.animate({ 251 height: targetHeight 252 }, _.options.speed); 253 } 254 }; 255 256 Slick.prototype.animateSlide = function(targetLeft, callback) { 257 258 var animProps = {}, 259 _ = this; 260 261 _.animateHeight(); 262 263 if (_.options.rtl === true && _.options.vertical === false) { 264 targetLeft = -targetLeft; 265 } 266 if (_.transformsEnabled === false) { 267 if (_.options.vertical === false) { 268 _.$slideTrack.animate({ 269 left: targetLeft 270 }, _.options.speed, _.options.easing, callback); 271 } else { 272 _.$slideTrack.animate({ 273 top: targetLeft 274 }, _.options.speed, _.options.easing, callback); 275 } 276 277 } else { 278 279 if (_.cssTransitions === false) { 280 if (_.options.rtl === true) { 281 _.currentLeft = -(_.currentLeft); 282 } 283 $({ 284 animStart: _.currentLeft 285 }).animate({ 286 animStart: targetLeft 287 }, { 288 duration: _.options.speed, 289 easing: _.options.easing, 290 step: function(now) { 291 now = Math.ceil(now); 292 if (_.options.vertical === false) { 293 animProps[_.animType] = 'translate(' + 294 now + 'px, 0px)'; 295 _.$slideTrack.css(animProps); 296 } else { 297 animProps[_.animType] = 'translate(0px,' + 298 now + 'px)'; 299 _.$slideTrack.css(animProps); 300 } 301 }, 302 complete: function() { 303 if (callback) { 304 callback.call(); 305 } 306 } 307 }); 308 309 } else { 310 311 _.applyTransition(); 312 targetLeft = Math.ceil(targetLeft); 313 314 if (_.options.vertical === false) { 315 animProps[_.animType] = 'translate3d(' + targetLeft + 'px, 0px, 0px)'; 316 } else { 317 animProps[_.animType] = 'translate3d(0px,' + targetLeft + 'px, 0px)'; 318 } 319 _.$slideTrack.css(animProps); 320 321 if (callback) { 322 setTimeout(function() { 323 324 _.disableTransition(); 325 326 callback.call(); 327 }, _.options.speed); 328 } 329 330 } 331 332 } 333 334 }; 335 336 Slick.prototype.getNavTarget = function() { 337 338 var _ = this, 339 asNavFor = _.options.asNavFor; 340 341 if ( asNavFor && asNavFor !== null ) { 342 asNavFor = $(asNavFor).not(_.$slider); 343 } 344 345 return asNavFor; 346 347 }; 348 349 Slick.prototype.asNavFor = function(index) { 350 351 var _ = this, 352 asNavFor = _.getNavTarget(); 353 354 if ( asNavFor !== null && typeof asNavFor === 'object' ) { 355 asNavFor.each(function() { 356 var target = $(this).slick('getSlick'); 357 if(!target.unslicked) { 358 target.slideHandler(index, true); 359 } 360 }); 361 } 362 363 }; 364 365 Slick.prototype.applyTransition = function(slide) { 366 367 var _ = this, 368 transition = {}; 369 370 if (_.options.fade === false) { 371 transition[_.transitionType] = _.transformType + ' ' + _.options.speed + 'ms ' + _.options.cssEase; 372 } else { 373 transition[_.transitionType] = 'opacity ' + _.options.speed + 'ms ' + _.options.cssEase; 374 } 375 376 if (_.options.fade === false) { 377 _.$slideTrack.css(transition); 378 } else { 379 _.$slides.eq(slide).css(transition); 380 } 381 382 }; 383 384 Slick.prototype.autoPlay = function() { 385 386 var _ = this; 387 388 _.autoPlayClear(); 389 390 if ( _.slideCount > _.options.slidesToShow ) { 391 _.autoPlayTimer = setInterval( _.autoPlayIterator, _.options.autoplaySpeed ); 392 } 393 394 }; 395 396 Slick.prototype.autoPlayClear = function() { 397 398 var _ = this; 399 400 if (_.autoPlayTimer) { 401 clearInterval(_.autoPlayTimer); 402 } 403 404 }; 405 406 Slick.prototype.autoPlayIterator = function() { 407 408 var _ = this, 409 slideTo = _.currentSlide + _.options.slidesToScroll; 410 411 if ( !_.paused && !_.interrupted && !_.focussed ) { 412 413 if ( _.options.infinite === false ) { 414 415 if ( _.direction === 1 && ( _.currentSlide + 1 ) === ( _.slideCount - 1 )) { 416 _.direction = 0; 417 } 418 419 else if ( _.direction === 0 ) { 420 421 slideTo = _.currentSlide - _.options.slidesToScroll; 422 423 if ( _.currentSlide - 1 === 0 ) { 424 _.direction = 1; 425 } 426 427 } 428 429 } 430 431 _.slideHandler( slideTo ); 432 433 } 434 435 }; 436 437 Slick.prototype.buildArrows = function() { 438 439 var _ = this; 440 441 if (_.options.arrows === true ) { 442 443 _.$prevArrow = $(_.options.prevArrow).addClass('slick-arrow'); 444 _.$nextArrow = $(_.options.nextArrow).addClass('slick-arrow'); 445 446 if( _.slideCount > _.options.slidesToShow ) { 447 448 _.$prevArrow.removeClass('slick-hidden').removeAttr('aria-hidden tabindex'); 449 _.$nextArrow.removeClass('slick-hidden').removeAttr('aria-hidden tabindex'); 450 451 if (_.htmlExpr.test(_.options.prevArrow)) { 452 _.$prevArrow.prependTo(_.options.appendArrows); 453 } 454 455 if (_.htmlExpr.test(_.options.nextArrow)) { 456 _.$nextArrow.appendTo(_.options.appendArrows); 457 } 458 459 if (_.options.infinite !== true) { 460 _.$prevArrow 461 .addClass('slick-disabled') 462 .attr('aria-disabled', 'true'); 463 } 464 465 } else { 466 467 _.$prevArrow.add( _.$nextArrow ) 468 469 .addClass('slick-hidden') 470 .attr({ 471 'aria-disabled': 'true', 472 'tabindex': '-1' 473 }); 474 475 } 476 477 } 478 479 }; 480 481 Slick.prototype.buildDots = function() { 482 483 var _ = this, 484 i, dot; 485 486 if (_.options.dots === true) { 487 488 _.$slider.addClass('slick-dotted'); 489 490 dot = $('<ul />').addClass(_.options.dotsClass); 491 492 for (i = 0; i <= _.getDotCount(); i += 1) { 493 dot.append($('<li />').append(_.options.customPaging.call(this, _, i))); 494 } 495 496 _.$dots = dot.appendTo(_.options.appendDots); 497 498 _.$dots.find('li').first().addClass('slick-active'); 499 500 } 501 502 }; 503 504 Slick.prototype.buildOut = function() { 505 506 var _ = this; 507 508 _.$slides = 509 _.$slider 510 .children( _.options.slide + ':not(.slick-cloned)') 511 .addClass('slick-slide'); 512 513 _.slideCount = _.$slides.length; 514 515 _.$slides.each(function(index, element) { 516 $(element) 517 .attr('data-slick-index', index) 518 .data('originalStyling', $(element).attr('style') || ''); 519 }); 520 521 _.$slider.addClass('slick-slider'); 522 523 _.$slideTrack = (_.slideCount === 0) ? 524 $('<div class="slick-track"/>').appendTo(_.$slider) : 525 _.$slides.wrapAll('<div class="slick-track"/>').parent(); 526 527 _.$list = _.$slideTrack.wrap( 528 '<div class="slick-list"/>').parent(); 529 _.$slideTrack.css('opacity', 0); 530 531 if (_.options.centerMode === true || _.options.swipeToSlide === true) { 532 _.options.slidesToScroll = 1; 533 } 534 535 $('img[data-lazy]', _.$slider).not('[src]').addClass('slick-loading'); 536 537 _.setupInfinite(); 538 539 _.buildArrows(); 540 541 _.buildDots(); 542 543 _.updateDots(); 544 545 546 _.setSlideClasses(typeof _.currentSlide === 'number' ? _.currentSlide : 0); 547 548 if (_.options.draggable === true) { 549 _.$list.addClass('draggable'); 550 } 551 552 }; 553 554 Slick.prototype.buildRows = function() { 555 556 var _ = this, a, b, c, newSlides, numOfSlides, originalSlides,slidesPerSection; 557 558 newSlides = document.createDocumentFragment(); 559 originalSlides = _.$slider.children(); 560 561 if(_.options.rows > 1) { 562 563 slidesPerSection = _.options.slidesPerRow * _.options.rows; 564 numOfSlides = Math.ceil( 565 originalSlides.length / slidesPerSection 566 ); 567 568 for(a = 0; a < numOfSlides; a++){ 569 var slide = document.createElement('div'); 570 for(b = 0; b < _.options.rows; b++) { 571 var row = document.createElement('div'); 572 for(c = 0; c < _.options.slidesPerRow; c++) { 573 var target = (a * slidesPerSection + ((b * _.options.slidesPerRow) + c)); 574 if (originalSlides.get(target)) { 575 row.appendChild(originalSlides.get(target)); 576 } 577 } 578 slide.appendChild(row); 579 } 580 newSlides.appendChild(slide); 581 } 582 583 _.$slider.empty().append(newSlides); 584 _.$slider.children().children().children() 585 .css({ 586 'width':(100 / _.options.slidesPerRow) + '%', 587 'display': 'inline-block' 588 }); 589 590 } 591 592 }; 593 594 Slick.prototype.checkResponsive = function(initial, forceUpdate) { 595 596 var _ = this, 597 breakpoint, targetBreakpoint, respondToWidth, triggerBreakpoint = false; 598 var sliderWidth = _.$slider.width(); 599 var windowWidth = window.innerWidth || $(window).width(); 600 601 if (_.respondTo === 'window') { 602 respondToWidth = windowWidth; 603 } else if (_.respondTo === 'slider') { 604 respondToWidth = sliderWidth; 605 } else if (_.respondTo === 'min') { 606 respondToWidth = Math.min(windowWidth, sliderWidth); 607 } 608 609 if ( _.options.responsive && 610 _.options.responsive.length && 611 _.options.responsive !== null) { 612 613 targetBreakpoint = null; 614 615 for (breakpoint in _.breakpoints) { 616 if (_.breakpoints.hasOwnProperty(breakpoint)) { 617 if (_.originalSettings.mobileFirst === false) { 618 if (respondToWidth < _.breakpoints[breakpoint]) { 619 targetBreakpoint = _.breakpoints[breakpoint]; 620 } 621 } else { 622 if (respondToWidth > _.breakpoints[breakpoint]) { 623 targetBreakpoint = _.breakpoints[breakpoint]; 624 } 625 } 626 } 627 } 628 629 if (targetBreakpoint !== null) { 630 if (_.activeBreakpoint !== null) { 631 if (targetBreakpoint !== _.activeBreakpoint || forceUpdate) { 632 _.activeBreakpoint = 633 targetBreakpoint; 634 if (_.breakpointSettings[targetBreakpoint] === 'unslick') { 635 _.unslick(targetBreakpoint); 636 } else { 637 _.options = $.extend({}, _.originalSettings, 638 _.breakpointSettings[ 639 targetBreakpoint]); 640 if (initial === true) { 641 _.currentSlide = _.options.initialSlide; 642 } 643 _.refresh(initial); 644 } 645 triggerBreakpoint = targetBreakpoint; 646 } 647 } else { 648 _.activeBreakpoint = targetBreakpoint; 649 if (_.breakpointSettings[targetBreakpoint] === 'unslick') { 650 _.unslick(targetBreakpoint); 651 } else { 652 _.options = $.extend({}, _.originalSettings, 653 _.breakpointSettings[ 654 targetBreakpoint]); 655 if (initial === true) { 656 _.currentSlide = _.options.initialSlide; 657 } 658 _.refresh(initial); 659 } 660 triggerBreakpoint = targetBreakpoint; 661 } 662 } else { 663 if (_.activeBreakpoint !== null) { 664 _.activeBreakpoint = null; 665 _.options = _.originalSettings; 666 if (initial === true) { 667 _.currentSlide = _.options.initialSlide; 668 } 669 _.refresh(initial); 670 triggerBreakpoint = targetBreakpoint; 671 } 672 } 673 674 // only trigger breakpoints during an actual break. not on initialize. 675 if( !initial && triggerBreakpoint !== false ) { 676 _.$slider.trigger('breakpoint', [_, triggerBreakpoint]); 677 } 678 } 679 680 }; 681 682 Slick.prototype.changeSlide = function(event, dontAnimate) { 683 684 var _ = this, 685 $target = $(event.currentTarget), 686 indexOffset, slideOffset, unevenOffset; 687 688 // If target is a link, prevent default action. 689 if($target.is('a')) { 690 event.preventDefault(); 691 } 692 693 // If target is not the <li> element (ie: a child), find the <li>. 694 if(!$target.is('li')) { 695 $target = $target.closest('li'); 696 } 697 698 unevenOffset = (_.slideCount % _.options.slidesToScroll !== 0); 699 indexOffset = unevenOffset ? 0 : (_.slideCount - _.currentSlide) % _.options.slidesToScroll; 700 701 switch (event.data.message) { 702 703 case 'previous': 704 slideOffset = indexOffset === 0 ? _.options.slidesToScroll : _.options.slidesToShow - indexOffset; 705 if (_.slideCount > _.options.slidesToShow) { 706 _.slideHandler(_.currentSlide - slideOffset, false, dontAnimate); 707 } 708 break; 709 710 case 'next': 711 slideOffset = indexOffset === 0 ? _.options.slidesToScroll : indexOffset; 712 if (_.slideCount > _.options.slidesToShow) { 713 _.slideHandler(_.currentSlide + slideOffset, false, dontAnimate); 714 } 715 break; 716 717 case 'index': 718 var index = event.data.index === 0 ? 0 : 719 event.data.index || $target.index() * _.options.slidesToScroll; 720 721 _.slideHandler(_.checkNavigable(index), false, dontAnimate); 722 $target.children().trigger('focus'); 723 break; 724 725 default: 726 return; 727 } 728 729 }; 730 731 Slick.prototype.checkNavigable = function(index) { 732 733 var _ = this, 734 navigables, prevNavigable; 735 736 navigables = _.getNavigableIndexes(); 737 prevNavigable = 0; 738 if (index > navigables[navigables.length - 1]) { 739 index = navigables[navigables.length - 1]; 740 } else { 741 for (var n in navigables) { 742 if (index < navigables[n]) { 743 index = prevNavigable; 744 break; 745 } 746 prevNavigable = navigables[n]; 747 } 748 } 749 750 return index; 751 }; 752 753 Slick.prototype.cleanUpEvents = function() { 754 755 var _ = this; 756 757 if (_.options.dots && _.$dots !== null) { 758 759 $('li', _.$dots) 760 .off('click.slick', _.changeSlide) 761 .off('mouseenter.slick', $.proxy(_.interrupt, _, true)) 762 .off('mouseleave.slick', $.proxy(_.interrupt, _, false)); 763 764 if (_.options.accessibility === true) { 765 _.$dots.off('keydown.slick', _.keyHandler); 766 } 767 } 768 769 _.$slider.off('focus.slick blur.slick'); 770 771 if (_.options.arrows === true && _.slideCount > _.options.slidesToShow) { 772 _.$prevArrow && _.$prevArrow.off('click.slick', _.changeSlide); 773 _.$nextArrow && _.$nextArrow.off('click.slick', _.changeSlide); 774 775 if (_.options.accessibility === true) { 776 _.$prevArrow.off('keydown.slick', _.keyHandler); 777 _.$nextArrow.off('keydown.slick', _.keyHandler); 778 } 779 } 780 781 _.$list.off('touchstart.slick mousedown.slick', _.swipeHandler); 782 _.$list.off('touchmove.slick mousemove.slick', _.swipeHandler); 783 _.$list.off('touchend.slick mouseup.slick', _.swipeHandler); 784 _.$list.off('touchcancel.slick mouseleave.slick', _.swipeHandler); 785 786 _.$list.off('click.slick', _.clickHandler); 787 788 $(document).off(_.visibilityChange, _.visibility); 789 790 _.cleanUpSlideEvents(); 791 792 if (_.options.accessibility === true) { 793 _.$list.off('keydown.slick', _.keyHandler); 794 } 795 796 if (_.options.focusOnSelect === true) { 797 $(_.$slideTrack).children().off('click.slick', _.selectHandler); 798 } 799 800 $(window).off('orientationchange.slick.slick-' + _.instanceUid, _.orientationChange); 801 802 $(window).off('resize.slick.slick-' + _.instanceUid, _.resize); 803 804 $('[draggable!=true]', _.$slideTrack).off('dragstart', _.preventDefault); 805 806 $(window).off('load.slick.slick-' + _.instanceUid, _.setPosition); 807 808 }; 809 810 Slick.prototype.cleanUpSlideEvents = function() { 811 812 var _ = this; 813 814 _.$list.off('mouseenter.slick', $.proxy(_.interrupt, _, true)); 815 _.$list.off('mouseleave.slick', $.proxy(_.interrupt, _, false)); 816 817 }; 818 819 Slick.prototype.cleanUpRows = function() { 820 821 var _ = this, originalSlides; 822 823 if(_.options.rows > 1) { 824 originalSlides = _.$slides.children().children(); 825 originalSlides.removeAttr('style'); 826 _.$slider.empty().append(originalSlides); 827 } 828 829 }; 830 831 Slick.prototype.clickHandler = function(event) { 832 833 var _ = this; 834 835 if (_.shouldClick === false) { 836 event.stopImmediatePropagation(); 837 event.stopPropagation(); 838 event.preventDefault(); 839 } 840 841 }; 842 843 Slick.prototype.destroy = function(refresh) { 844 845 var _ = this; 846 847 _.autoPlayClear(); 848 849 _.touchObject = {}; 850 851 _.cleanUpEvents(); 852 853 $('.slick-cloned', _.$slider).detach(); 854 855 if (_.$dots) { 856 _.$dots.remove(); 857 } 858 859 if ( _.$prevArrow && _.$prevArrow.length ) { 860 861 _.$prevArrow 862 .removeClass('slick-disabled slick-arrow slick-hidden') 863 .removeAttr('aria-hidden aria-disabled tabindex') 864 .css('display',''); 865 866 if ( _.htmlExpr.test( _.options.prevArrow )) { 867 _.$prevArrow.remove(); 868 } 869 } 870 871 if ( _.$nextArrow && _.$nextArrow.length ) { 872 873 _.$nextArrow 874 .removeClass('slick-disabled slick-arrow slick-hidden') 875 .removeAttr('aria-hidden aria-disabled tabindex') 876 .css('display',''); 877 878 if ( _.htmlExpr.test( _.options.nextArrow )) { 879 _.$nextArrow.remove(); 880 } 881 } 882 883 884 if (_.$slides) { 885 886 _.$slides 887 .removeClass('slick-slide slick-active slick-center slick-visible slick-current') 888 .removeAttr('aria-hidden') 889 .removeAttr('data-slick-index') 890 .each(function(){ 891 $(this).attr('style', $(this).data('originalStyling')); 892 }); 893 894 _.$slideTrack.children(this.options.slide).detach(); 895 896 _.$slideTrack.detach(); 897 898 _.$list.detach(); 899 900 _.$slider.append(_.$slides); 901 } 902 903 _.cleanUpRows(); 904 905 _.$slider.removeClass('slick-slider'); 906 _.$slider.removeClass('slick-initialized'); 907 _.$slider.removeClass('slick-dotted'); 908 909 _.unslicked = true; 910 911 if(!refresh) { 912 _.$slider.trigger('destroy', [_]); 913 } 914 915 }; 916 917 Slick.prototype.disableTransition = function(slide) { 918 919 var _ = this, 920 transition = {}; 921 922 transition[_.transitionType] = ''; 923 924 if (_.options.fade === false) { 925 _.$slideTrack.css(transition); 926 } else { 927 _.$slides.eq(slide).css(transition); 928 } 929 930 }; 931 932 Slick.prototype.fadeSlide = function(slideIndex, callback) { 933 934 var _ = this; 935 936 if (_.cssTransitions === false) { 937 938 _.$slides.eq(slideIndex).css({ 939 zIndex: _.options.zIndex 940 }); 941 942 _.$slides.eq(slideIndex).animate({ 943 opacity: 1 944 }, _.options.speed, _.options.easing, callback); 945 946 } else { 947 948 _.applyTransition(slideIndex); 949 950 _.$slides.eq(slideIndex).css({ 951 opacity: 1, 952 zIndex: _.options.zIndex 953 }); 954 955 if (callback) { 956 setTimeout(function() { 957 958 _.disableTransition(slideIndex); 959 960 callback.call(); 961 }, _.options.speed); 962 } 963 964 } 965 966 }; 967 968 Slick.prototype.fadeSlideOut = function(slideIndex) { 969 970 var _ = this; 971 972 if (_.cssTransitions === false) { 973 974 _.$slides.eq(slideIndex).animate({ 975 opacity: 0, 976 zIndex: _.options.zIndex - 2 977 }, _.options.speed, _.options.easing); 978 979 } else { 980 981 _.applyTransition(slideIndex); 982 983 _.$slides.eq(slideIndex).css({ 984 opacity: 0, 985 zIndex: _.options.zIndex - 2 986 }); 987 988 } 989 990 }; 991 992 Slick.prototype.filterSlides = Slick.prototype.slickFilter = function(filter) { 993 994 var _ = this; 995 996 if (filter !== null) { 997 998 _.$slidesCache = _.$slides; 999 1000 _.unload(); 1001 1002 _.$slideTrack.children(this.options.slide).detach(); 1003 1004 _.$slidesCache.filter(filter).appendTo(_.$slideTrack); 1005 1006 _.reinit(); 1007 1008 } 1009 1010 }; 1011 1012 Slick.prototype.focusHandler = function() { 1013 1014 var _ = this; 1015 1016 _.$slider 1017 .off('focus.slick blur.slick') 1018 .on('focus.slick blur.slick', '*', function(event) { 1019 1020 event.stopImmediatePropagation(); 1021 var $sf = $(this); 1022 1023 setTimeout(function() { 1024 1025 if( _.options.pauseOnFocus ) { 1026 _.focussed = $sf.is(':focus'); 1027 _.autoPlay(); 1028 } 1029 1030 }, 0); 1031 1032 }); 1033 }; 1034 1035 Slick.prototype.getCurrent = Slick.prototype.slickCurrentSlide = function() { 1036 1037 var _ = this; 1038 return _.currentSlide; 1039 1040 }; 1041 1042 Slick.prototype.getDotCount = function() { 1043 1044 var _ = this; 1045 1046 var breakPoint = 0; 1047 var counter = 0; 1048 var pagerQty = 0; 1049 1050 if (_.options.infinite === true) { 1051 if (_.slideCount <= _.options.slidesToShow) { 1052 ++pagerQty; 1053 } else { 1054 while (breakPoint < _.slideCount) { 1055 ++pagerQty; 1056 breakPoint = counter + _.options.slidesToScroll; 1057 counter += _.options.slidesToScroll <= _.options.slidesToShow ? _.options.slidesToScroll : _.options.slidesToShow; 1058 } 1059 } 1060 } else if (_.options.centerMode === true) { 1061 pagerQty = _.slideCount; 1062 } else if(!_.options.asNavFor) { 1063 pagerQty = 1 + Math.ceil((_.slideCount - _.options.slidesToShow) / _.options.slidesToScroll); 1064 }else { 1065 while (breakPoint < _.slideCount) { 1066 ++pagerQty; 1067 breakPoint = counter + _.options.slidesToScroll; 1068 counter += _.options.slidesToScroll <= _.options.slidesToShow ? _.options.slidesToScroll : _.options.slidesToShow; 1069 } 1070 } 1071 1072 return pagerQty - 1; 1073 1074 }; 1075 1076 Slick.prototype.getLeft = function(slideIndex) { 1077 1078 var _ = this, 1079 targetLeft, 1080 verticalHeight, 1081 verticalOffset = 0, 1082 targetSlide; 1083 1084 _.slideOffset = 0; 1085 verticalHeight = _.$slides.first().outerHeight(true); 1086 1087 if (_.options.infinite === true) { 1088 if (_.slideCount > _.options.slidesToShow) { 1089 _.slideOffset = (_.slideWidth * _.options.slidesToShow) * -1; 1090 verticalOffset = (verticalHeight * _.options.slidesToShow) * -1
vendor: 7,472 bytes, lines 1090-1311
1090; 1091 } 1092 if (_.slideCount % _.options.slidesToScroll !== 0) { 1093 if (slideIndex + _.options.slidesToScroll > _.slideCount && _.slideCount > _.options.slidesToShow) { 1094 if (slideIndex > _.slideCount) { 1095 _.slideOffset = ((_.options.slidesToShow - (slideIndex - _.slideCount)) * _.slideWidth) * -1; 1096 verticalOffset = ((_.options.slidesToShow - (slideIndex - _.slideCount)) * verticalHeight) * -1; 1097 } else { 1098 _.slideOffset = ((_.slideCount % _.options.slidesToScroll) * _.slideWidth) * -1; 1099 verticalOffset = ((_.slideCount % _.options.slidesToScroll) * verticalHeight) * -1; 1100 } 1101 } 1102 } 1103 } else { 1104 if (slideIndex + _.options.slidesToShow > _.slideCount) { 1105 _.slideOffset = ((slideIndex + _.options.slidesToShow) - _.slideCount) * _.slideWidth; 1106 verticalOffset = ((slideIndex + _.options.slidesToShow) - _.slideCount) * verticalHeight; 1107 } 1108 } 1109 1110 if (_.slideCount <= _.options.slidesToShow) { 1111 _.slideOffset = 0; 1112 verticalOffset = 0; 1113 } 1114 1115 if (_.options.centerMode === true && _.slideCount <= _.options.slidesToShow) { 1116 _.slideOffset = ((_.slideWidth * Math.floor(_.options.slidesToShow)) / 2) - ((_.slideWidth * _.slideCount) / 2); 1117 } else if (_.options.centerMode === true && _.options.infinite === true) { 1118 _.slideOffset += _.slideWidth * Math.floor(_.options.slidesToShow / 2) - _.slideWidth; 1119 } else if (_.options.centerMode === true) { 1120 _.slideOffset = 0; 1121 _.slideOffset += _.slideWidth * Math.floor(_.options.slidesToShow / 2); 1122 } 1123 1124 if (_.options.vertical === false) { 1125 targetLeft = ((slideIndex * _.slideWidth) * -1) + _.slideOffset; 1126 } else { 1127 targetLeft = ((slideIndex * verticalHeight) * -1) + verticalOffset; 1128 } 1129 1130 if (_.options.variableWidth === true) { 1131 1132 if (_.slideCount <= _.options.slidesToShow || _.options.infinite === false) { 1133 targetSlide = _.$slideTrack.children('.slick-slide').eq(slideIndex); 1134 } else { 1135 targetSlide = _.$slideTrack.children('.slick-slide').eq(slideIndex + _.options.slidesToShow); 1136 } 1137 1138 if (_.options.rtl === true) { 1139 if (targetSlide[0]) { 1140 targetLeft = (_.$slideTrack.width() - targetSlide[0].offsetLeft - targetSlide.width()) * -1; 1141 } else { 1142 targetLeft = 0; 1143 } 1144 } else { 1145 targetLeft = targetSlide[0] ? targetSlide[0].offsetLeft * -1 : 0; 1146 } 1147 1148 if (_.options.centerMode === true) { 1149 if (_.slideCount <= _.options.slidesToShow || _.options.infinite === false) { 1150 targetSlide = _.$slideTrack.children('.slick-slide').eq(slideIndex); 1151 } else { 1152 targetSlide = _.$slideTrack.children('.slick-slide').eq(slideIndex + _.options.slidesToShow + 1); 1153 } 1154 1155 if (_.options.rtl === true) { 1156 if (targetSlide[0]) { 1157 targetLeft = (_.$slideTrack.width() - targetSlide[0].offsetLeft - targetSlide.width()) * -1; 1158 } else { 1159 targetLeft = 0; 1160 } 1161 } else { 1162 targetLeft = targetSlide[0] ? targetSlide[0].offsetLeft * -1 : 0; 1163 } 1164 1165 targetLeft += (_.$list.width() - targetSlide.outerWidth()) / 2; 1166 } 1167 } 1168 1169 return targetLeft; 1170 1171 }; 1172 1173 Slick.prototype.getOption = Slick.prototype.slickGetOption = function(option) { 1174 1175 var _ = this; 1176 1177 return _.options[option]; 1178 1179 }; 1180 1181 Slick.prototype.getNavigableIndexes = function() { 1182 1183 var _ = this, 1184 breakPoint = 0, 1185 counter = 0, 1186 indexes = [], 1187 max; 1188 1189 if (_.options.infinite === false) { 1190 max = _.slideCount; 1191 } else { 1192 breakPoint = _.options.slidesToScroll * -1; 1193 counter = _.options.slidesToScroll * -1; 1194 max = _.slideCount * 2; 1195 } 1196 1197 while (breakPoint < max) { 1198 indexes.push(breakPoint); 1199 breakPoint = counter + _.options.slidesToScroll; 1200 counter += _.options.slidesToScroll <= _.options.slidesToShow ? _.options.slidesToScroll : _.options.slidesToShow; 1201 } 1202 1203 return indexes; 1204 1205 }; 1206 1207 Slick.prototype.getSlick = function() { 1208 1209 return this; 1210 1211 }; 1212 1213 Slick.prototype.getSlideCount = function() { 1214 1215 var _ = this, 1216 slidesTraversed, swipedSlide, centerOffset; 1217 1218 centerOffset = _.options.centerMode === true ? _.slideWidth * Math.floor(_.options.slidesToShow / 2) : 0; 1219 1220 if (_.options.swipeToSlide === true) { 1221 _.$slideTrack.find('.slick-slide').each(function(index, slide) { 1222 if (slide.offsetLeft - centerOffset + ($(slide).outerWidth() / 2) > (_.swipeLeft * -1)) { 1223 swipedSlide = slide; 1224 return false; 1225 } 1226 }); 1227 1228 slidesTraversed = Math.abs($(swipedSlide).attr('data-slick-index') - _.currentSlide) || 1; 1229 1230 return slidesTraversed; 1231 1232 } else { 1233 return _.options.slidesToScroll; 1234 } 1235 1236 }; 1237 1238 Slick.prototype.goTo = Slick.prototype.slickGoTo = function(slide, dontAnimate) { 1239 1240 var _ = this; 1241 1242 _.changeSlide({ 1243 data: { 1244 message: 'index', 1245 index: parseInt(slide) 1246 } 1247 }, dontAnimate); 1248 1249 }; 1250 1251 Slick.prototype.init = function(creation) { 1252 1253 var _ = this; 1254 1255 if (!$(_.$slider).hasClass('slick-initialized')) { 1256 1257 $(_.$slider).addClass('slick-initialized'); 1258 1259 _.buildRows(); 1260 _.buildOut(); 1261 _.setProps(); 1262 _.startLoad(); 1263 _.loadSlider(); 1264 _.initializeEvents(); 1265 _.updateArrows(); 1266 _.updateDots(); 1267 _.checkResponsive(true); 1268 _.focusHandler(); 1269 1270 } 1271 1272 if (creation) { 1273 _.$slider.trigger('init', [_]); 1274 } 1275 1276 if (_.options.accessibility === true) { 1277 _.initADA(); 1278 } 1279 1280 if ( _.options.autoplay ) { 1281 1282 _.paused = false; 1283 _.autoPlay(); 1284 1285 } 1286 1287 }; 1288 1289 Slick.prototype.initADA = function() { 1290 var _ = this, 1291 numDotGroups = Math.ceil(_.slideCount / _.options.slidesToShow), 1292 tabControlIndexes = _.getNavigableIndexes().filter(function(val) { 1293 return (val >= 0) && (val < _.slideCount); 1294 }); 1295 1296 _.$slides.add(_.$slideTrack.find('.slick-cloned')).attr({ 1297 'aria-hidden': 'true', 1298 'tabindex': '-1' 1299 }).find('a, input, button, select').attr({ 1300 'tabindex': '-1' 1301 }); 1302 1303 if (_.$dots !== null) { 1304 _.$slides.not(_.$slideTrack.find('.slick-cloned')).each(function(i) { 1305 var slideControlIndex = tabControlIndexes.indexOf(i); 1306 1307 $(this).attr({ 1308 'role': 'tabpanel', 1309 'id': 'slick-slide' + _.instanceUid + i, 1310 'tabindex': -1 1311 });
vendor: 11,179 bytes, lines 1311-1690
1311 1312 1313 if (slideControlIndex !== -1) { 1314 $(this).attr({ 1315 'aria-describedby': 'slick-slide-control' + _.instanceUid + slideControlIndex 1316 }); 1317 } 1318 }); 1319 1320 _.$dots.attr('role', 'tablist').find('li').each(function(i) { 1321 var mappedSlideIndex = tabControlIndexes[i]; 1322 1323 $(this).attr({ 1324 'role': 'presentation' 1325 }); 1326 1327 $(this).find('button').first().attr({ 1328 'role': 'tab', 1329 'id': 'slick-slide-control' + _.instanceUid + i, 1330 'aria-controls': 'slick-slide' + _.instanceUid + mappedSlideIndex, 1331 'aria-label': (i + 1) + ' of ' + numDotGroups, 1332 'aria-selected': null, 1333 'tabindex': '-1' 1334 }); 1335 1336 }).eq(_.currentSlide).find('button').attr({ 1337 'aria-selected': 'true', 1338 'tabindex': '0' 1339 }).end(); 1340 } 1341 1342 for (var i=_.currentSlide, max=i+_.options.slidesToShow; i < max; i++) { 1343 _.$slides.eq(i).attr('tabindex', 0); 1344 } 1345 1346 _.activateADA(); 1347 1348 }; 1349 1350 Slick.prototype.initArrowEvents = function() { 1351 1352 var _ = this; 1353 1354 if (_.options.arrows === true && _.slideCount > _.options.slidesToShow) { 1355 _.$prevArrow 1356 .off('click.slick') 1357 .on('click.slick', { 1358 message: 'previous' 1359 }, _.changeSlide); 1360 _.$nextArrow 1361 .off('click.slick') 1362 .on('click.slick', { 1363 message: 'next' 1364 }, _.changeSlide); 1365 1366 if (_.options.accessibility === true) { 1367 _.$prevArrow.on('keydown.slick', _.keyHandler); 1368 _.$nextArrow.on('keydown.slick', _.keyHandler); 1369 } 1370 } 1371 1372 }; 1373 1374 Slick.prototype.initDotEvents = function() { 1375 1376 var _ = this; 1377 1378 if (_.options.dots === true) { 1379 $('li', _.$dots).on('click.slick', { 1380 message: 'index' 1381 }, _.changeSlide); 1382 1383 if (_.options.accessibility === true) { 1384 _.$dots.on('keydown.slick', _.keyHandler); 1385 } 1386 } 1387 1388 if ( _.options.dots === true && _.options.pauseOnDotsHover === true ) { 1389 1390 $('li', _.$dots) 1391 .on('mouseenter.slick', $.proxy(_.interrupt, _, true)) 1392 .on('mouseleave.slick', $.proxy(_.interrupt, _, false)); 1393 1394 } 1395 1396 }; 1397 1398 Slick.prototype.initSlideEvents = function() { 1399 1400 var _ = this; 1401 1402 if ( _.options.pauseOnHover ) { 1403 1404 _.$list.on('mouseenter.slick', $.proxy(_.interrupt, _, true)); 1405 _.$list.on('mouseleave.slick', $.proxy(_.interrupt, _, false)); 1406 1407 } 1408 1409 }; 1410 1411 Slick.prototype.initializeEvents = function() { 1412 1413 var _ = this; 1414 1415 _.initArrowEvents(); 1416 1417 _.initDotEvents(); 1418 _.initSlideEvents(); 1419 1420 _.$list.on('touchstart.slick mousedown.slick', { 1421 action: 'start' 1422 }, _.swipeHandler); 1423 _.$list.on('touchmove.slick mousemove.slick', { 1424 action: 'move' 1425 }, _.swipeHandler); 1426 _.$list.on('touchend.slick mouseup.slick', { 1427 action: 'end' 1428 }, _.swipeHandler); 1429 _.$list.on('touchcancel.slick mouseleave.slick', { 1430 action: 'end' 1431 }, _.swipeHandler); 1432 1433 _.$list.on('click.slick', _.clickHandler); 1434 1435 $(document).on(_.visibilityChange, $.proxy(_.visibility, _)); 1436 1437 if (_.options.accessibility === true) { 1438 _.$list.on('keydown.slick', _.keyHandler); 1439 } 1440 1441 if (_.options.focusOnSelect === true) { 1442 $(_.$slideTrack).children().on('click.slick', _.selectHandler); 1443 } 1444 1445 $(window).on('orientationchange.slick.slick-' + _.instanceUid, $.proxy(_.orientationChange, _)); 1446 1447 $(window).on('resize.slick.slick-' + _.instanceUid, $.proxy(_.resize, _)); 1448 1449 $('[draggable!=true]', _.$slideTrack).on('dragstart', _.preventDefault); 1450 1451 $(window).on('load.slick.slick-' + _.instanceUid, _.setPosition); 1452 $(_.setPosition); 1453 1454 }; 1455 1456 Slick.prototype.initUI = function() { 1457 1458 var _ = this; 1459 1460 if (_.options.arrows === true && _.slideCount > _.options.slidesToShow) { 1461 1462 _.$prevArrow.show(); 1463 _.$nextArrow.show(); 1464 1465 } 1466 1467 if (_.options.dots === true && _.slideCount > _.options.slidesToShow) { 1468 1469 _.$dots.show(); 1470 1471 } 1472 1473 }; 1474 1475 Slick.prototype.keyHandler = function(event) { 1476 1477 var _ = this; 1478 //Dont slide if the cursor is inside the form fields and arrow keys are pressed 1479 if(!event.target.tagName.match('TEXTAREA|INPUT|SELECT')) { 1480 if (event.keyCode === 37 && _.options.accessibility === true) { 1481 _.changeSlide({ 1482 data: { 1483 message: _.options.rtl === true ? 'next' : 'previous' 1484 } 1485 }); 1486 } else if (event.keyCode === 39 && _.options.accessibility === true) { 1487 _.changeSlide({ 1488 data: { 1489 message: _.options.rtl === true ? 'previous' : 'next' 1490 } 1491 }); 1492 } 1493 } 1494 1495 }; 1496 1497 Slick.prototype.lazyLoad = function() { 1498 1499 var _ = this, 1500 loadRange, cloneRange, rangeStart, rangeEnd; 1501 1502 function loadImages(imagesScope) { 1503 1504 $('img[data-lazy]', imagesScope).each(function() { 1505 1506 var image = $(this), 1507 imageSource = $(this).attr('data-lazy'), 1508 imageSrcSet = $(this).attr('data-srcset'), 1509 imageSizes = $(this).attr('data-sizes') || _.$slider.attr('data-sizes'), 1510 imageToLoad = document.createElement('img'); 1511 1512 imageToLoad.onload = function() { 1513 1514 image 1515 .animate({ opacity: 0 }, 100, function() { 1516 1517 if (imageSrcSet) { 1518 image 1519 .attr('srcset', imageSrcSet ); 1520 1521 if (imageSizes) { 1522 image 1523 .attr('sizes', imageSizes ); 1524 } 1525 } 1526 1527 image 1528 .attr('src', imageSource) 1529 .animate({ opacity: 1 }, 200, function() { 1530 image 1531 .removeAttr('data-lazy data-srcset data-sizes') 1532 .removeClass('slick-loading'); 1533 }); 1534 _.$slider.trigger('lazyLoaded', [_, image, imageSource]); 1535 }); 1536 1537 }; 1538 1539 imageToLoad.onerror = function() { 1540 1541 image 1542 .removeAttr( 'data-lazy' ) 1543 .removeClass( 'slick-loading' ) 1544 .addClass( 'slick-lazyload-error' ); 1545 1546 _.$slider.trigger('lazyLoadError', [ _, image, imageSource ]); 1547 1548 }; 1549 1550 imageToLoad.src = imageSource; 1551 1552 }); 1553 1554 } 1555 1556 if (_.options.centerMode === true) { 1557 if (_.options.infinite === true) { 1558 rangeStart = _.currentSlide + (_.options.slidesToShow / 2 + 1); 1559 rangeEnd = rangeStart + _.options.slidesToShow + 2; 1560 } else { 1561 rangeStart = Math.max(0, _.currentSlide - (_.options.slidesToShow / 2 + 1)); 1562 rangeEnd = 2 + (_.options.slidesToShow / 2 + 1) + _.currentSlide; 1563 } 1564 } else { 1565 rangeStart = _.options.infinite ? _.options.slidesToShow + _.currentSlide : _.currentSlide; 1566 rangeEnd = Math.ceil(rangeStart + _.options.slidesToShow); 1567 if (_.options.fade === true) { 1568 if (rangeStart > 0) rangeStart--; 1569 if (rangeEnd <= _.slideCount) rangeEnd++; 1570 } 1571 } 1572 1573 loadRange = _.$slider.find('.slick-slide').slice(rangeStart, rangeEnd); 1574 1575 if (_.options.lazyLoad === 'anticipated') { 1576 var prevSlide = rangeStart - 1, 1577 nextSlide = rangeEnd, 1578 $slides = _.$slider.find('.slick-slide'); 1579 1580 for (var i = 0; i < _.options.slidesToScroll; i++) { 1581 if (prevSlide < 0) prevSlide = _.slideCount - 1; 1582 loadRange = loadRange.add($slides.eq(prevSlide)); 1583 loadRange = loadRange.add($slides.eq(nextSlide)); 1584 prevSlide--; 1585 nextSlide++; 1586 } 1587 } 1588 1589 loadImages(loadRange); 1590 1591 if (_.slideCount <= _.options.slidesToShow) { 1592 cloneRange = _.$slider.find('.slick-slide'); 1593 loadImages(cloneRange); 1594 } else 1595 if (_.currentSlide >= _.slideCount - _.options.slidesToShow) { 1596 cloneRange = _.$slider.find('.slick-cloned').slice(0, _.options.slidesToShow); 1597 loadImages(cloneRange); 1598 } else if (_.currentSlide === 0) { 1599 cloneRange = _.$slider.find('.slick-cloned').slice(_.options.slidesToShow * -1); 1600 loadImages(cloneRange); 1601 } 1602 1603 }; 1604 1605 Slick.prototype.loadSlider = function() { 1606 1607 var _ = this; 1608 1609 _.setPosition(); 1610 1611 _.$slideTrack.css({ 1612 opacity: 1 1613 }); 1614 1615 _.$slider.removeClass('slick-loading'); 1616 1617 _.initUI(); 1618 1619 if (_.options.lazyLoad === 'progressive') { 1620 _.progressiveLazyLoad(); 1621 } 1622 1623 }; 1624 1625 Slick.prototype.next = Slick.prototype.slickNext = function() { 1626 1627 var _ = this; 1628 1629 _.changeSlide({ 1630 data: { 1631 message: 'next' 1632 } 1633 }); 1634 1635 }; 1636 1637 Slick.prototype.orientationChange = function() { 1638 1639 var _ = this; 1640 1641 _.checkResponsive(); 1642 _.setPosition(); 1643 1644 }; 1645 1646 Slick.prototype.pause = Slick.prototype.slickPause = function() { 1647 1648 var _ = this; 1649 1650 _.autoPlayClear(); 1651 _.paused = true; 1652 1653 }; 1654 1655 Slick.prototype.play = Slick.prototype.slickPlay = function() { 1656 1657 var _ = this; 1658 1659 _.autoPlay(); 1660 _.options.autoplay = true; 1661 _.paused = false; 1662 _.focussed = false; 1663 _.interrupted = false; 1664 1665 }; 1666 1667 Slick.prototype.postSlide = function(index) { 1668 1669 var _ = this; 1670 1671 if( !_.unslicked ) { 1672 1673 _.$slider.trigger('afterChange', [_, index]); 1674 1675 _.animating = false; 1676 1677 if (_.slideCount > _.options.slidesToShow) { 1678 _.setPosition(); 1679 } 1680 1681 _.swipeLeft = null; 1682 1683 if ( _.options.autoplay ) { 1684 _.autoPlay(); 1685 } 1686 1687 if (_.options.accessibility === true) { 1688 _.initADA(); 1689 // for non-autoplay: once active slide (group) has updated, set focus on first newly showing slide 1690 if (!_.options.autoplay
vendor: 16,834 bytes, lines 1690-2288
1690) { 1691 var $currentSlide = $(_.$slides.get(_.currentSlide)); 1692 $currentSlide.attr('tabindex', 0).focus(); 1693 } 1694 } 1695 1696 } 1697 1698 }; 1699 1700 Slick.prototype.prev = Slick.prototype.slickPrev = function() { 1701 1702 var _ = this; 1703 1704 _.changeSlide({ 1705 data: { 1706 message: 'previous' 1707 } 1708 }); 1709 1710 }; 1711 1712 Slick.prototype.preventDefault = function(event) { 1713 1714 event.preventDefault(); 1715 1716 }; 1717 1718 Slick.prototype.progressiveLazyLoad = function( tryCount ) { 1719 1720 tryCount = tryCount || 1; 1721 1722 var _ = this, 1723 $imgsToLoad = $( 'img[data-lazy]', _.$slider ), 1724 image, 1725 imageSource, 1726 imageSrcSet, 1727 imageSizes, 1728 imageToLoad; 1729 1730 if ( $imgsToLoad.length ) { 1731 1732 image = $imgsToLoad.first(); 1733 imageSource = image.attr('data-lazy'); 1734 imageSrcSet = image.attr('data-srcset'); 1735 imageSizes = image.attr('data-sizes') || _.$slider.attr('data-sizes'); 1736 imageToLoad = document.createElement('img'); 1737 1738 imageToLoad.onload = function() { 1739 1740 if (imageSrcSet) { 1741 image 1742 .attr('srcset', imageSrcSet ); 1743 1744 if (imageSizes) { 1745 image 1746 .attr('sizes', imageSizes ); 1747 } 1748 } 1749 1750 image 1751 .attr( 'src', imageSource ) 1752 .removeAttr('data-lazy data-srcset data-sizes') 1753 .removeClass('slick-loading'); 1754 1755 if ( _.options.adaptiveHeight === true ) { 1756 _.setPosition(); 1757 } 1758 1759 _.$slider.trigger('lazyLoaded', [ _, image, imageSource ]); 1760 _.progressiveLazyLoad(); 1761 1762 }; 1763 1764 imageToLoad.onerror = function() { 1765 1766 if ( tryCount < 3 ) { 1767 1768 /** 1769 * try to load the image 3 times, 1770 * leave a slight delay so we don't get 1771 * servers blocking the request. 1772 */ 1773 setTimeout( function() { 1774 _.progressiveLazyLoad( tryCount + 1 ); 1775 }, 500 ); 1776 1777 } else { 1778 1779 image 1780 .removeAttr( 'data-lazy' ) 1781 .removeClass( 'slick-loading' ) 1782 .addClass( 'slick-lazyload-error' ); 1783 1784 _.$slider.trigger('lazyLoadError', [ _, image, imageSource ]); 1785 1786 _.progressiveLazyLoad(); 1787 1788 } 1789 1790 }; 1791 1792 imageToLoad.src = imageSource; 1793 1794 } else { 1795 1796 _.$slider.trigger('allImagesLoaded', [ _ ]); 1797 1798 } 1799 1800 }; 1801 1802 Slick.prototype.refresh = function( initializing ) { 1803 1804 var _ = this, currentSlide, lastVisibleIndex; 1805 1806 lastVisibleIndex = _.slideCount - _.options.slidesToShow; 1807 1808 // in non-infinite sliders, we don't want to go past the 1809 // last visible index. 1810 if( !_.options.infinite && ( _.currentSlide > lastVisibleIndex )) { 1811 _.currentSlide = lastVisibleIndex; 1812 } 1813 1814 // if less slides than to show, go to start. 1815 if ( _.slideCount <= _.options.slidesToShow ) { 1816 _.currentSlide = 0; 1817 1818 } 1819 1820 currentSlide = _.currentSlide; 1821 1822 _.destroy(true); 1823 1824 $.extend(_, _.initials, { currentSlide: currentSlide }); 1825 1826 _.init(); 1827 1828 if( !initializing ) { 1829 1830 _.changeSlide({ 1831 data: { 1832 message: 'index', 1833 index: currentSlide 1834 } 1835 }, false); 1836 1837 } 1838 1839 }; 1840 1841 Slick.prototype.registerBreakpoints = function() { 1842 1843 var _ = this, breakpoint, currentBreakpoint, l, 1844 responsiveSettings = _.options.responsive || null; 1845 1846 if ( $.type(responsiveSettings) === 'array' && responsiveSettings.length ) { 1847 1848 _.respondTo = _.options.respondTo || 'window'; 1849 1850 for ( breakpoint in responsiveSettings ) { 1851 1852 l = _.breakpoints.length-1; 1853 1854 if (responsiveSettings.hasOwnProperty(breakpoint)) { 1855 currentBreakpoint = responsiveSettings[breakpoint].breakpoint; 1856 1857 // loop through the breakpoints and cut out any existing 1858 // ones with the same breakpoint number, we don't want dupes. 1859 while( l >= 0 ) { 1860 if( _.breakpoints[l] && _.breakpoints[l] === currentBreakpoint ) { 1861 _.breakpoints.splice(l,1); 1862 } 1863 l--; 1864 } 1865 1866 _.breakpoints.push(currentBreakpoint); 1867 _.breakpointSettings[currentBreakpoint] = responsiveSettings[breakpoint].settings; 1868 1869 } 1870 1871 } 1872 1873 _.breakpoints.sort(function(a, b) { 1874 return ( _.options.mobileFirst ) ? a-b : b-a; 1875 }); 1876 1877 } 1878 1879 }; 1880 1881 Slick.prototype.reinit = function() { 1882 1883 var _ = this; 1884 1885 _.$slides = 1886 _.$slideTrack 1887 .children(_.options.slide) 1888 .addClass('slick-slide'); 1889 1890 _.slideCount = _.$slides.length; 1891 1892 if (_.currentSlide >= _.slideCount && _.currentSlide !== 0) { 1893 _.currentSlide = _.currentSlide - _.options.slidesToScroll; 1894 } 1895 1896 if (_.slideCount <= _.options.slidesToShow) { 1897 _.currentSlide = 0; 1898 } 1899 1900 _.registerBreakpoints(); 1901 1902 _.setProps(); 1903 _.setupInfinite(); 1904 _.buildArrows(); 1905 _.updateArrows(); 1906 _.initArrowEvents(); 1907 _.buildDots(); 1908 _.updateDots(); 1909 _.initDotEvents(); 1910 _.cleanUpSlideEvents(); 1911 _.initSlideEvents(); 1912 1913 _.checkResponsive(false, true); 1914 1915 if (_.options.focusOnSelect === true) { 1916 $(_.$slideTrack).children().on('click.slick', _.selectHandler); 1917 } 1918 1919 _.setSlideClasses(typeof _.currentSlide === 'number' ? _.currentSlide : 0); 1920 1921 _.setPosition(); 1922 _.focusHandler(); 1923 1924 _.paused = !_.options.autoplay; 1925 _.autoPlay(); 1926 1927 _.$slider.trigger('reInit', [_]); 1928 1929 }; 1930 1931 Slick.prototype.resize = function() { 1932 1933 var _ = this; 1934 1935 if ($(window).width() !== _.windowWidth) { 1936 clearTimeout(_.windowDelay); 1937 _.windowDelay = window.setTimeout(function() { 1938 _.windowWidth = $(window).width(); 1939 _.checkResponsive(); 1940 if( !_.unslicked ) { _.setPosition(); } 1941 }, 50); 1942 } 1943 }; 1944 1945 Slick.prototype.removeSlide = Slick.prototype.slickRemove = function(index, removeBefore, removeAll) { 1946 1947 var _ = this; 1948 1949 if (typeof(index) === 'boolean') { 1950 removeBefore = index; 1951 index = removeBefore === true ? 0 : _.slideCount - 1; 1952 } else { 1953 index = removeBefore === true ? --index : index; 1954 } 1955 1956 if (_.slideCount < 1 || index < 0 || index > _.slideCount - 1) { 1957 return false; 1958 } 1959 1960 _.unload(); 1961 1962 if (removeAll === true) { 1963 _.$slideTrack.children().remove(); 1964 } else { 1965 _.$slideTrack.children(this.options.slide).eq(index).remove(); 1966 } 1967 1968 _.$slides = _.$slideTrack.children(this.options.slide); 1969 1970 _.$slideTrack.children(this.options.slide).detach(); 1971 1972 _.$slideTrack.append(_.$slides); 1973 1974 _.$slidesCache = _.$slides; 1975 1976 _.reinit(); 1977 1978 }; 1979 1980 Slick.prototype.setCSS = function(position) { 1981 1982 var _ = this, 1983 positionProps = {}, 1984 x, y; 1985 1986 if (_.options.rtl === true) { 1987 position = -position; 1988 } 1989 x = _.positionProp == 'left' ? Math.ceil(position) + 'px' : '0px'; 1990 y = _.positionProp == 'top' ? Math.ceil(position) + 'px' : '0px'; 1991 1992 positionProps[_.positionProp] = position; 1993 1994 if (_.transformsEnabled === false) { 1995 _.$slideTrack.css(positionProps); 1996 } else { 1997 positionProps = {}; 1998 if (_.cssTransitions === false) { 1999 positionProps[_.animType] = 'translate(' + x + ', ' + y + ')'; 2000 _.$slideTrack.css(positionProps); 2001 } else { 2002 positionProps[_.animType] = 'translate3d(' + x + ', ' + y + ', 0px)'; 2003 _.$slideTrack.css(positionProps); 2004 } 2005 } 2006 2007 }; 2008 2009 Slick.prototype.setDimensions = function() { 2010 2011 var _ = this; 2012 2013 if (_.options.vertical === false) { 2014 if (_.options.centerMode === true) { 2015 _.$list.css({ 2016 padding: ('0px ' + _.options.centerPadding) 2017 }); 2018 } 2019 } else { 2020 _.$list.height(_.$slides.first().outerHeight(true) * _.options.slidesToShow); 2021 if (_.options.centerMode === true) { 2022 _.$list.css({ 2023 padding: (_.options.centerPadding + ' 0px') 2024 }); 2025 } 2026 } 2027 2028 _.listWidth = _.$list.width(); 2029 _.listHeight = _.$list.height(); 2030 2031 2032 if (_.options.vertical === false && _.options.variableWidth === false) { 2033 _.slideWidth = Math.ceil(_.listWidth / _.options.slidesToShow); 2034 _.$slideTrack.width(Math.ceil((_.slideWidth * _.$slideTrack.children('.slick-slide').length))); 2035 2036 } else if (_.options.variableWidth === true) { 2037 _.$slideTrack.width(5000 * _.slideCount); 2038 } else { 2039 _.slideWidth = Math.ceil(_.listWidth); 2040 _.$slideTrack.height(Math.ceil((_.$slides.first().outerHeight(true) * _.$slideTrack.children('.slick-slide').length))); 2041 } 2042 2043 var offset = _.$slides.first().outerWidth(true) - _.$slides.first().width(); 2044 if (_.options.variableWidth === false) _.$slideTrack.children('.slick-slide').width(_.slideWidth - offset); 2045 2046 }; 2047 2048 Slick.prototype.setFade = function() { 2049 2050 var _ = this, 2051 targetLeft; 2052 2053 _.$slides.each(function(index, element) { 2054 targetLeft = (_.slideWidth * index) * -1; 2055 if (_.options.rtl === true) { 2056 $(element).css({ 2057 position: 'relative', 2058 right: targetLeft, 2059 top: 0, 2060 zIndex: _.options.zIndex - 2, 2061 opacity: 0 2062 }); 2063 } else { 2064 $(element).css({ 2065 position: 'relative', 2066 left: targetLeft, 2067 top: 0, 2068 zIndex: _.options.zIndex - 2, 2069 opacity: 0 2070 }); 2071 } 2072 }); 2073 2074 _.$slides.eq(_.currentSlide).css({ 2075 zIndex: _.options.zIndex - 1, 2076 opacity: 1 2077 }); 2078 2079 }; 2080 2081 Slick.prototype.setHeight = function() { 2082 2083 var _ = this; 2084 2085 if (_.options.slidesToShow === 1 && _.options.adaptiveHeight === true && _.options.vertical === false) { 2086 var targetHeight = _.$slides.eq(_.currentSlide).outerHeight(true); 2087 _.$list.css('height', targetHeight); 2088 } 2089 2090 }; 2091 2092 Slick.prototype.setOption = 2093 Slick.prototype.slickSetOption = function() { 2094 2095 /** 2096 * accepts arguments in format of: 2097 * 2098 * - for changing a single option's value: 2099 * .slick("setOption", option, value, refresh ) 2100 * 2101 * - for changing a set of responsive options: 2102 * .slick("setOption", 'responsive', [{}, ...], refresh ) 2103 * 2104 * - for updating multiple values at once (not responsive) 2105 * .slick("setOption", { 'option': value, ... }, refresh ) 2106 */ 2107 2108 var _ = this, l, item, option, value, refresh = false, type; 2109 2110 if( $.type( arguments[0] ) === 'object' ) { 2111 2112 option = arguments[0]; 2113 refresh = arguments[1]; 2114 type = 'multiple'; 2115 2116 } else if ( $.type( arguments[0] ) === 'string' ) { 2117 2118 option = arguments[0]; 2119 value = arguments[1]; 2120 refresh = arguments[2]; 2121 2122 if ( arguments[0] === 'responsive' && $.type( arguments[1] ) === 'array' ) { 2123 2124 type = 'responsive'; 2125 2126 } else if ( typeof arguments[1] !== 'undefined' ) { 2127 2128 type = 'single'; 2129 2130 } 2131 2132 } 2133 2134 if ( type === 'single' ) { 2135 2136 _.options[option] = value; 2137 2138 2139 } else if ( type === 'multiple' ) { 2140 2141 $.each( option , function( opt, val ) { 2142 2143 _.options[opt] = val; 2144 2145 }); 2146 2147 2148 } else if ( type === 'responsive' ) { 2149 2150 for ( item in value ) { 2151 2152 if( $.type( _.options.responsive ) !== 'array' ) { 2153 2154 _.options.responsive = [ value[item] ]; 2155 2156 } else { 2157 2158 l = _.options.responsive.length-1; 2159 2160 // loop through the responsive object and splice out duplicates. 2161 while( l >= 0 ) { 2162 2163 if( _.options.responsive[l].breakpoint === value[item].breakpoint ) { 2164 2165 _.options.responsive.splice(l,1); 2166 2167 } 2168 2169 l--; 2170 2171 } 2172 2173 _.options.responsive.push( value[item] ); 2174 2175 } 2176 2177 } 2178 2179 } 2180 2181 if ( refresh ) { 2182 2183 _.unload(); 2184 _.reinit(); 2185 2186 } 2187 2188 }; 2189 2190 Slick.prototype.setPosition = function() { 2191 2192 var _ = this; 2193 2194 _.setDimensions(); 2195 2196 _.setHeight(); 2197 2198 if (_.options.fade === false) { 2199 _.setCSS(_.getLeft(_.currentSlide)); 2200 } else { 2201 _.setFade(); 2202 } 2203 2204 _.$slider.trigger('setPosition', [_]); 2205 2206 }; 2207 2208 Slick.prototype.setProps = function() { 2209 2210 var _ = this, 2211 bodyStyle = document.body.style; 2212 2213 _.positionProp = _.options.vertical === true ? 'top' : 'left'; 2214 2215 if (_.positionProp === 'top') { 2216 _.$slider.addClass('slick-vertical'); 2217 } else { 2218 _.$slider.removeClass('slick-vertical'); 2219 } 2220 2221 if (bodyStyle.WebkitTransition !== undefined || 2222 bodyStyle.MozTransition !== undefined || 2223 bodyStyle.msTransition !== undefined) { 2224 if (_.options.useCSS === true) { 2225 _.cssTransitions = true; 2226 } 2227 } 2228 2229 if ( _.options.fade ) { 2230 if ( typeof _.options.zIndex === 'number' ) { 2231 if( _.options.zIndex < 3 ) { 2232 _.options.zIndex = 3; 2233 } 2234 } else { 2235 _.options.zIndex = _.defaults.zIndex; 2236 } 2237 } 2238 2239 if (bodyStyle.OTransform !== undefined) { 2240 _.animType = 'OTransform'; 2241 _.transformType = '-o-transform'; 2242 _.transitionType = 'OTransition'; 2243 if (bodyStyle.perspectiveProperty === undefined && bodyStyle.webkitPerspective === undefined) _.animType = false; 2244 } 2245 if (bodyStyle.MozTransform !== undefined) { 2246 _.animType = 'MozTransform'; 2247 _.transformType = '-moz-transform'; 2248 _.transitionType = 'MozTransition'; 2249 if (bodyStyle.perspectiveProperty === undefined && bodyStyle.MozPerspective === undefined) _.animType = false; 2250 } 2251 if (bodyStyle.webkitTransform !== undefined) { 2252 _.animType = 'webkitTransform'; 2253 _.transformType = '-webkit-transform'; 2254 _.transitionType = 'webkitTransition'; 2255 if (bodyStyle.perspectiveProperty === undefined && bodyStyle.webkitPerspective === undefined) _.animType = false; 2256 } 2257 if (bodyStyle.msTransform !== undefined) { 2258 _.animType = 'msTransform'; 2259 _.transformType = '-ms-transform'; 2260 _.transitionType = 'msTransition'; 2261 if (bodyStyle.msTransform === undefined) _.animType = false; 2262 } 2263 if (bodyStyle.transform !== undefined && _.animType !== false) { 2264 _.animType = 'transform'; 2265 _.transformType = 'transform'; 2266 _.transitionType = 'transition'; 2267 } 2268 _.transformsEnabled = _.options.useTransform && (_.animType !== null && _.animType !== false); 2269 }; 2270 2271 2272 Slick.prototype.setSlideClasses = function(index) { 2273 2274 var _ = this, 2275 centerOffset, allSlides, indexOffset, remainder; 2276 2277 allSlides = _.$slider 2278 .find('.slick-slide') 2279 .removeClass('slick-active slick-center slick-current') 2280 .attr('aria-hidden', 'true'); 2281 2282 _.$slides 2283 .eq(index) 2284 .addClass('slick-current'); 2285 2286 if (_.options.centerMode === true) { 2287 2288
vendor: 19,934 bytes, lines 2288-2992
2288centerOffset = Math.floor(_.options.slidesToShow / 2); 2289 2290 if (_.options.infinite === true) { 2291 2292 if (index >= centerOffset && index <= (_.slideCount - 1) - centerOffset) { 2293 2294 _.$slides 2295 .slice(index - centerOffset, index + centerOffset + 1) 2296 .addClass('slick-active') 2297 .attr('aria-hidden', 'false'); 2298 2299 } else { 2300 2301 indexOffset = _.options.slidesToShow + index; 2302 allSlides 2303 .slice(indexOffset - centerOffset + 1, indexOffset + centerOffset + 2) 2304 .addClass('slick-active') 2305 .attr('aria-hidden', 'false'); 2306 2307 } 2308 2309 if (index === 0) { 2310 2311 allSlides 2312 .eq(allSlides.length - 1 - _.options.slidesToShow) 2313 .addClass('slick-center'); 2314 2315 } else if (index === _.slideCount - 1) { 2316 2317 allSlides 2318 .eq(_.options.slidesToShow) 2319 .addClass('slick-center'); 2320 2321 } 2322 2323 } 2324 2325 _.$slides 2326 .eq(index) 2327 .addClass('slick-center'); 2328 2329 } else { 2330 2331 if (index >= 0 && index <= (_.slideCount - _.options.slidesToShow)) { 2332 2333 _.$slides 2334 .slice(index, index + _.options.slidesToShow) 2335 .addClass('slick-active') 2336 .attr('aria-hidden', 'false'); 2337 2338 } else if (allSlides.length <= _.options.slidesToShow) { 2339 2340 allSlides 2341 .addClass('slick-active') 2342 .attr('aria-hidden', 'false'); 2343 2344 } else { 2345 2346 remainder = _.slideCount % _.options.slidesToShow; 2347 indexOffset = _.options.infinite === true ? _.options.slidesToShow + index : index; 2348 2349 if (_.options.slidesToShow == _.options.slidesToScroll && (_.slideCount - index) < _.options.slidesToShow) { 2350 2351 allSlides 2352 .slice(indexOffset - (_.options.slidesToShow - remainder), indexOffset + remainder) 2353 .addClass('slick-active') 2354 .attr('aria-hidden', 'false'); 2355 2356 } else { 2357 2358 allSlides 2359 .slice(indexOffset, indexOffset + _.options.slidesToShow) 2360 .addClass('slick-active') 2361 .attr('aria-hidden', 'false'); 2362 2363 } 2364 2365 } 2366 2367 } 2368 2369 if (_.options.lazyLoad === 'ondemand' || _.options.lazyLoad === 'anticipated') { 2370 _.lazyLoad(); 2371 } 2372 }; 2373 2374 Slick.prototype.setupInfinite = function() { 2375 2376 var _ = this, 2377 i, slideIndex, infiniteCount; 2378 2379 if (_.options.fade === true) { 2380 _.options.centerMode = false; 2381 } 2382 2383 if (_.options.infinite === true && _.options.fade === false) { 2384 2385 slideIndex = null; 2386 2387 if (_.slideCount > _.options.slidesToShow) { 2388 2389 if (_.options.centerMode === true) { 2390 infiniteCount = _.options.slidesToShow + 1; 2391 } else { 2392 infiniteCount = _.options.slidesToShow; 2393 } 2394 2395 for (i = _.slideCount; i > (_.slideCount - 2396 infiniteCount); i -= 1) { 2397 slideIndex = i - 1; 2398 $(_.$slides[slideIndex]).clone(true).attr('id', '') 2399 .attr('data-slick-index', slideIndex - _.slideCount) 2400 .prependTo(_.$slideTrack).addClass('slick-cloned'); 2401 } 2402 for (i = 0; i < infiniteCount + _.slideCount; i += 1) { 2403 slideIndex = i; 2404 $(_.$slides[slideIndex]).clone(true).attr('id', '') 2405 .attr('data-slick-index', slideIndex + _.slideCount) 2406 .appendTo(_.$slideTrack).addClass('slick-cloned'); 2407 } 2408 _.$slideTrack.find('.slick-cloned').find('[id]').each(function() { 2409 $(this).attr('id', ''); 2410 }); 2411 2412 } 2413 2414 } 2415 2416 }; 2417 2418 Slick.prototype.interrupt = function( toggle ) { 2419 2420 var _ = this; 2421 2422 if( !toggle ) { 2423 _.autoPlay(); 2424 } 2425 _.interrupted = toggle; 2426 2427 }; 2428 2429 Slick.prototype.selectHandler = function(event) { 2430 2431 var _ = this; 2432 2433 var targetElement = 2434 $(event.target).is('.slick-slide') ? 2435 $(event.target) : 2436 $(event.target).parents('.slick-slide'); 2437 2438 var index = parseInt(targetElement.attr('data-slick-index')); 2439 2440 if (!index) index = 0; 2441 2442 if (_.slideCount <= _.options.slidesToShow) { 2443 2444 _.slideHandler(index, false, true); 2445 return; 2446 2447 } 2448 2449 _.slideHandler(index); 2450 2451 }; 2452 2453 Slick.prototype.slideHandler = function(index, sync, dontAnimate) { 2454 2455 var targetSlide, animSlide, oldSlide, slideLeft, targetLeft = null, 2456 _ = this, navTarget; 2457 2458 sync = sync || false; 2459 2460 if (_.animating === true && _.options.waitForAnimate === true) { 2461 return; 2462 } 2463 2464 if (_.options.fade === true && _.currentSlide === index) { 2465 return; 2466 } 2467 2468 if (sync === false) { 2469 _.asNavFor(index); 2470 } 2471 2472 targetSlide = index; 2473 targetLeft = _.getLeft(targetSlide); 2474 slideLeft = _.getLeft(_.currentSlide); 2475 2476 _.currentLeft = _.swipeLeft === null ? slideLeft : _.swipeLeft; 2477 2478 if (_.options.infinite === false && _.options.centerMode === false && (index < 0 || index > _.getDotCount() * _.options.slidesToScroll)) { 2479 if (_.options.fade === false) { 2480 targetSlide = _.currentSlide; 2481 if (dontAnimate !== true) { 2482 _.animateSlide(slideLeft, function() { 2483 _.postSlide(targetSlide); 2484 }); 2485 } else { 2486 _.postSlide(targetSlide); 2487 } 2488 } 2489 return; 2490 } else if (_.options.infinite === false && _.options.centerMode === true && (index < 0 || index > (_.slideCount - _.options.slidesToScroll))) { 2491 if (_.options.fade === false) { 2492 targetSlide = _.currentSlide; 2493 if (dontAnimate !== true) { 2494 _.animateSlide(slideLeft, function() { 2495 _.postSlide(targetSlide); 2496 }); 2497 } else { 2498 _.postSlide(targetSlide); 2499 } 2500 } 2501 return; 2502 } 2503 2504 if ( _.options.autoplay ) { 2505 clearInterval(_.autoPlayTimer); 2506 } 2507 2508 if (targetSlide < 0) { 2509 if (_.slideCount % _.options.slidesToScroll !== 0) { 2510 animSlide = _.slideCount - (_.slideCount % _.options.slidesToScroll); 2511 } else { 2512 animSlide = _.slideCount + targetSlide; 2513 } 2514 } else if (targetSlide >= _.slideCount) { 2515 if (_.slideCount % _.options.slidesToScroll !== 0) { 2516 animSlide = 0; 2517 } else { 2518 animSlide = targetSlide - _.slideCount; 2519 } 2520 } else { 2521 animSlide = targetSlide; 2522 } 2523 2524 _.animating = true; 2525 2526 _.$slider.trigger('beforeChange', [_, _.currentSlide, animSlide]); 2527 2528 oldSlide = _.currentSlide; 2529 _.currentSlide = animSlide; 2530 2531 _.setSlideClasses(_.currentSlide); 2532 2533 if ( _.options.asNavFor ) { 2534 2535 navTarget = _.getNavTarget(); 2536 navTarget = navTarget.slick('getSlick'); 2537 2538 if ( navTarget.slideCount <= navTarget.options.slidesToShow ) { 2539 navTarget.setSlideClasses(_.currentSlide); 2540 } 2541 2542 } 2543 2544 _.updateDots(); 2545 _.updateArrows(); 2546 2547 if (_.options.fade === true) { 2548 if (dontAnimate !== true) { 2549 2550 _.fadeSlideOut(oldSlide); 2551 2552 _.fadeSlide(animSlide, function() { 2553 _.postSlide(animSlide); 2554 }); 2555 2556 } else { 2557 _.postSlide(animSlide); 2558 } 2559 _.animateHeight(); 2560 return; 2561 } 2562 2563 if (dontAnimate !== true) { 2564 _.animateSlide(targetLeft, function() { 2565 _.postSlide(animSlide); 2566 }); 2567 } else { 2568 _.postSlide(animSlide); 2569 } 2570 2571 }; 2572 2573 Slick.prototype.startLoad = function() { 2574 2575 var _ = this; 2576 2577 if (_.options.arrows === true && _.slideCount > _.options.slidesToShow) { 2578 2579 _.$prevArrow.hide(); 2580 _.$nextArrow.hide(); 2581 2582 } 2583 2584 if (_.options.dots === true && _.slideCount > _.options.slidesToShow) { 2585 2586 _.$dots.hide(); 2587 2588 } 2589 2590 _.$slider.addClass('slick-loading'); 2591 2592 }; 2593 2594 Slick.prototype.swipeDirection = function() { 2595 2596 var xDist, yDist, r, swipeAngle, _ = this; 2597 2598 xDist = _.touchObject.startX - _.touchObject.curX; 2599 yDist = _.touchObject.startY - _.touchObject.curY; 2600 r = Math.atan2(yDist, xDist); 2601 2602 swipeAngle = Math.round(r * 180 / Math.PI); 2603 if (swipeAngle < 0) { 2604 swipeAngle = 360 - Math.abs(swipeAngle); 2605 } 2606 2607 if ((swipeAngle <= 45) && (swipeAngle >= 0)) { 2608 return (_.options.rtl === false ? 'left' : 'right'); 2609 } 2610 if ((swipeAngle <= 360) && (swipeAngle >= 315)) { 2611 return (_.options.rtl === false ? 'left' : 'right'); 2612 } 2613 if ((swipeAngle >= 135) && (swipeAngle <= 225)) { 2614 return (_.options.rtl === false ? 'right' : 'left'); 2615 } 2616 if (_.options.verticalSwiping === true) { 2617 if ((swipeAngle >= 35) && (swipeAngle <= 135)) { 2618 return 'down'; 2619 } else { 2620 return 'up'; 2621 } 2622 } 2623 2624 return 'vertical'; 2625 2626 }; 2627 2628 Slick.prototype.swipeEnd = function(event) { 2629 2630 var _ = this, 2631 slideCount, 2632 direction; 2633 2634 _.dragging = false; 2635 _.swiping = false; 2636 2637 if (_.scrolling) { 2638 _.scrolling = false; 2639 return false; 2640 } 2641 2642 _.interrupted = false; 2643 _.shouldClick = ( _.touchObject.swipeLength > 10 ) ? false : true; 2644 2645 if ( _.touchObject.curX === undefined ) { 2646 return false; 2647 } 2648 2649 if ( _.touchObject.edgeHit === true ) { 2650 _.$slider.trigger('edge', [_, _.swipeDirection() ]); 2651 } 2652 2653 if ( _.touchObject.swipeLength >= _.touchObject.minSwipe ) { 2654 2655 direction = _.swipeDirection(); 2656 2657 switch ( direction ) { 2658 2659 case 'left': 2660 case 'down': 2661 2662 slideCount = 2663 _.options.swipeToSlide ? 2664 _.checkNavigable( _.currentSlide + _.getSlideCount() ) : 2665 _.currentSlide + _.getSlideCount(); 2666 2667 _.currentDirection = 0; 2668 2669 break; 2670 2671 case 'right': 2672 case 'up': 2673 2674 slideCount = 2675 _.options.swipeToSlide ? 2676 _.checkNavigable( _.currentSlide - _.getSlideCount() ) : 2677 _.currentSlide - _.getSlideCount(); 2678 2679 _.currentDirection = 1; 2680 2681 break; 2682 2683 default: 2684 2685 2686 } 2687 2688 if( direction != 'vertical' ) { 2689 2690 _.slideHandler( slideCount ); 2691 _.touchObject = {}; 2692 _.$slider.trigger('swipe', [_, direction ]); 2693 2694 } 2695 2696 } else { 2697 2698 if ( _.touchObject.startX !== _.touchObject.curX ) { 2699 2700 _.slideHandler( _.currentSlide ); 2701 _.touchObject = {}; 2702 2703 } 2704 2705 } 2706 2707 }; 2708 2709 Slick.prototype.swipeHandler = function(event) { 2710 2711 var _ = this; 2712 2713 if ((_.options.swipe === false) || ('ontouchend' in document && _.options.swipe === false)) { 2714 return; 2715 } else if (_.options.draggable === false && event.type.indexOf('mouse') !== -1) { 2716 return; 2717 } 2718 2719 _.touchObject.fingerCount = event.originalEvent && event.originalEvent.touches !== undefined ? 2720 event.originalEvent.touches.length : 1; 2721 2722 _.touchObject.minSwipe = _.listWidth / _.options 2723 .touchThreshold; 2724 2725 if (_.options.verticalSwiping === true) { 2726 _.touchObject.minSwipe = _.listHeight / _.options 2727 .touchThreshold; 2728 } 2729 2730 switch (event.data.action) { 2731 2732 case 'start': 2733 _.swipeStart(event); 2734 break; 2735 2736 case 'move': 2737 _.swipeMove(event); 2738 break; 2739 2740 case 'end': 2741 _.swipeEnd(event); 2742 break; 2743 2744 } 2745 2746 }; 2747 2748 Slick.prototype.swipeMove = function(event) { 2749 2750 var _ = this, 2751 edgeWasHit = false, 2752 curLeft, swipeDirection, swipeLength, positionOffset, touches, verticalSwipeLength; 2753 2754 touches = event.originalEvent !== undefined ? event.originalEvent.touches : null; 2755 2756 if (!_.dragging || _.scrolling || touches && touches.length !== 1) { 2757 return false; 2758 } 2759 2760 curLeft = _.getLeft(_.currentSlide); 2761 2762 _.touchObject.curX = touches !== undefined ? touches[0].pageX : event.clientX; 2763 _.touchObject.curY = touches !== undefined ? touches[0].pageY : event.clientY; 2764 2765 _.touchObject.swipeLength = Math.round(Math.sqrt( 2766 Math.pow(_.touchObject.curX - _.touchObject.startX, 2))); 2767 2768 verticalSwipeLength = Math.round(Math.sqrt( 2769 Math.pow(_.touchObject.curY - _.touchObject.startY, 2))); 2770 2771 if (!_.options.verticalSwiping && !_.swiping && verticalSwipeLength > 4) { 2772 _.scrolling = true; 2773 return false; 2774 } 2775 2776 if (_.options.verticalSwiping === true) { 2777 _.touchObject.swipeLength = verticalSwipeLength; 2778 } 2779 2780 swipeDirection = _.swipeDirection(); 2781 2782 if (event.originalEvent !== undefined && _.touchObject.swipeLength > 4) { 2783 _.swiping = true; 2784 event.preventDefault(); 2785 } 2786 2787 positionOffset = (_.options.rtl === false ? 1 : -1) * (_.touchObject.curX > _.touchObject.startX ? 1 : -1); 2788 if (_.options.verticalSwiping === true) { 2789 positionOffset = _.touchObject.curY > _.touchObject.startY ? 1 : -1; 2790 } 2791 2792 2793 swipeLength = _.touchObject.swipeLength; 2794 2795 _.touchObject.edgeHit = false; 2796 2797 if (_.options.infinite === false) { 2798 if ((_.currentSlide === 0 && swipeDirection === 'right') || (_.currentSlide >= _.getDotCount() && swipeDirection === 'left')) { 2799 swipeLength = _.touchObject.swipeLength * _.options.edgeFriction; 2800 _.touchObject.edgeHit = true; 2801 } 2802 } 2803 2804 if (_.options.vertical === false) { 2805 _.swipeLeft = curLeft + swipeLength * positionOffset; 2806 } else { 2807 _.swipeLeft = curLeft + (swipeLength * (_.$list.height() / _.listWidth)) * positionOffset; 2808 } 2809 if (_.options.verticalSwiping === true) { 2810 _.swipeLeft = curLeft + swipeLength * positionOffset; 2811 } 2812 2813 if (_.options.fade === true || _.options.touchMove === false) { 2814 return false; 2815 } 2816 2817 if (_.animating === true) { 2818 _.swipeLeft = null; 2819 return false; 2820 } 2821 2822 _.setCSS(_.swipeLeft); 2823 2824 }; 2825 2826 Slick.prototype.swipeStart = function(event) { 2827 2828 var _ = this, 2829 touches; 2830 2831 _.interrupted = true; 2832 2833 if (_.touchObject.fingerCount !== 1 || _.slideCount <= _.options.slidesToShow) { 2834 _.touchObject = {}; 2835 return false; 2836 } 2837 2838 if (event.originalEvent !== undefined && event.originalEvent.touches !== undefined) { 2839 touches = event.originalEvent.touches[0]; 2840 } 2841 2842 _.touchObject.startX = _.touchObject.curX = touches !== undefined ? touches.pageX : event.clientX; 2843 _.touchObject.startY = _.touchObject.curY = touches !== undefined ? touches.pageY : event.clientY; 2844 2845 _.dragging = true; 2846 2847 }; 2848 2849 Slick.prototype.unfilterSlides = Slick.prototype.slickUnfilter = function() { 2850 2851 var _ = this; 2852 2853 if (_.$slidesCache !== null) { 2854 2855 _.unload(); 2856 2857 _.$slideTrack.children(this.options.slide).detach(); 2858 2859 _.$slidesCache.appendTo(_.$slideTrack); 2860 2861 _.reinit(); 2862 2863 } 2864 2865 }; 2866 2867 Slick.prototype.unload = function() { 2868 2869 var _ = this; 2870 2871 $('.slick-cloned', _.$slider).remove(); 2872 2873 if (_.$dots) { 2874 _.$dots.remove(); 2875 } 2876 2877 if (_.$prevArrow && _.htmlExpr.test(_.options.prevArrow)) { 2878 _.$prevArrow.remove(); 2879 } 2880 2881 if (_.$nextArrow && _.htmlExpr.test(_.options.nextArrow)) { 2882 _.$nextArrow.remove(); 2883 } 2884 2885 _.$slides 2886 .removeClass('slick-slide slick-active slick-visible slick-current') 2887 .attr('aria-hidden', 'true') 2888 .css('width', ''); 2889 2890 }; 2891 2892 Slick.prototype.unslick = function(fromBreakpoint) { 2893 2894 var _ = this; 2895 _.$slider.trigger('unslick', [_, fromBreakpoint]); 2896 _.destroy(); 2897 2898 }; 2899 2900 Slick.prototype.updateArrows = function() { 2901 2902 var _ = this, 2903 centerOffset; 2904 2905 centerOffset = Math.floor(_.options.slidesToShow / 2); 2906 2907 if ( _.options.arrows === true && 2908 _.slideCount > _.options.slidesToShow && 2909 !_.options.infinite ) { 2910 2911 _.$prevArrow.removeClass('slick-disabled').attr('aria-disabled', 'false'); 2912 _.$nextArrow.removeClass('slick-disabled').attr('aria-disabled', 'false'); 2913 2914 if (_.currentSlide === 0) { 2915 2916 _.$prevArrow.addClass('slick-disabled').attr('aria-disabled', 'true'); 2917 _.$nextArrow.removeClass('slick-disabled').attr('aria-disabled', 'false'); 2918 2919 } else if (_.currentSlide >= _.slideCount - _.options.slidesToShow && _.options.centerMode === false) { 2920 2921 _.$nextArrow.addClass('slick-disabled').attr('aria-disabled', 'true'); 2922 _.$prevArrow.removeClass('slick-disabled').attr('aria-disabled', 'false'); 2923 2924 } else if (_.currentSlide >= _.slideCount - 1 && _.options.centerMode === true) { 2925 2926 _.$nextArrow.addClass('slick-disabled').attr('aria-disabled', 'true'); 2927 _.$prevArrow.removeClass('slick-disabled').attr('aria-disabled', 'false'); 2928 2929 } 2930 2931 } 2932 2933 }; 2934 2935 Slick.prototype.updateDots = function() { 2936 2937 var _ = this; 2938 2939 if (_.$dots !== null) { 2940 2941 _.$dots 2942 .find('li') 2943 .removeClass('slick-active') 2944 .end(); 2945 2946 _.$dots 2947 .find('li') 2948 .eq(Math.floor(_.currentSlide / _.options.slidesToScroll)) 2949 .addClass('slick-active'); 2950 2951 } 2952 2953 }; 2954 2955 Slick.prototype.visibility = function() { 2956 2957 var _ = this; 2958 2959 if ( _.options.autoplay ) { 2960 2961 if ( document[_.hidden] ) { 2962 2963 _.interrupted = true; 2964 2965 } else { 2966 2967 _.interrupted = false; 2968 2969 } 2970 2971 } 2972 2973 }; 2974 2975 $.fn.slick = function() { 2976 var _ = this, 2977 opt = arguments[0], 2978 args = Array.prototype.slice.call(arguments, 1), 2979 l = _.length, 2980 i, 2981 ret; 2982 for (i = 0; i < l; i++) { 2983 if (typeof opt == 'object' || typeof opt == 'undefined') 2984 _[i].slick = new Slick(_[i], opt); 2985 else 2986 ret = _[i].slick[opt].apply(_[i].slick, args); 2987 if (typeof ret != 'undefined') return ret; 2988 } 2989 return _; 2990 }; 2991 2992}));
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.