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