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