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