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