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