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