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