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