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