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