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