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