1/* 2 _ _ _ _ 3 ___| (_) ___| | __ (_)___ 4/ __| | |/ __| |/ / | / __| 5\__ \ | | (__| < _ | \__ \ 6|___/_|_|\___|_|\_(_)/ |___/ 7 |__/ 8 9 Version: 1.4.0 10 Author: Ken Wheeler 11 Website: http://kenwheeler.github.io 12 Docs: http://kenwheeler.github.io/slick 13 Repo: http://github.com/kenwheeler/slick 14 Issues: http://github.com/kenwheeler/slick/issues 15 16 */ 17 18/* global window, document, define, jQuery, setInterval, clearInterval */ 19 20(function(factory) { 21 'use strict'; 22 if (typeof define === 'function' && define.amd) { 23 define(['jquery'], factory); 24 } else if (typeof exports !== 'undefined') { 25 module.exports = factory(require('jquery')); 26 } else { 27 factory(jQuery); 28 } 29 30}(function($) { 31 'use strict'; 32 var Slick = window.Slick || {}; 33 34 Slick = (function() { 35 36 var instanceUid = 0; 37 38 function Slick(element, settings) { 39 40 var _ = this, 41 dataSettings, responsiveSettings, breakpoint; 42 43 _.defaults = { 44 accessibility: true, 45 adaptiveHeight: false, 46 appendArrows: $(element), 47 appendDots: $(element), 48 arrows: true, 49 asNavFor: null, 50 prevArrow: '<button type="button" data-role="none" class="slick-prev">Previous</button>', 51 nextArrow: '<button type="button" data-role="none" class="slick-next">Next</button>', 52 autoplay: false, 53 autoplaySpeed: 3000, 54 centerMode: false, 55 centerPadding: '50px', 56 cssEase: 'ease', 57 customPaging: function(slider, i) { 58 return '<button type="button" data-role="none">' + (i + 1) + '</button>'; 59 }, 60 dots: false, 61 dotsClass: 'slick-dots', 62 draggable: true, 63 easing: 'linear', 64 edgeFriction: 0.35, 65 fade: false, 66 focusOnSelect: false, 67 infinite: true, 68 initialSlide: 0, 69 lazyLoad: 'ondemand', 70 mobileFirst: false, 71 pauseOnHover: true, 72 pauseOnDotsHover: false, 73 respondTo: 'window', 74 responsive: null, 75 rtl: false, 76 slide: '', 77 slidesToShow: 1, 78 slidesToScroll: 1, 79 speed: 500, 80 swipe: true, 81 swipeToSlide: false, 82 touchMove: true, 83 touchThreshold: 5, 84 useCSS: true, 85 variableWidth: false, 86 vertical: false, 87 waitForAnimate: true 88 }; 89 90 _.initials = { 91 animating: false, 92 dragging: false, 93 autoPlayTimer: null, 94 currentDirection: 0, 95 currentLeft: null, 96 currentSlide: 0, 97 direction: 1, 98 $dots: null, 99 listWidth: null, 100 listHeight: null, 101 loadIndex: 0, 102 $nextArrow: null, 103 $prevArrow: null, 104 slideCount: null, 105 slideWidth: null, 106 $slideTrack: null, 107 $slides: null, 108 sliding: false, 109 slideOffset: 0, 110 swipeLeft: null, 111 $list: null, 112 touchObject: {}, 113 transformsEnabled: false 114 }; 115 116 $.extend(_, _.initials); 117 118 _.activeBreakpoint = null; 119 _.animType = null; 120 _.animProp = null; 121 _.breakpoints = []; 122 _.breakpointSettings = []; 123 _.cssTransitions = false; 124 _.hidden = "hidden"; 125 _.paused = false; 126 _.positionProp = null; 127 _.respondTo = null; 128 _.shouldClick = true; 129 _.$slider = $(element); 130 _.$slidesCache = null; 131 _.transformType = null; 132 _.transitionType = null; 133 _.visibilityChange = "visibilitychange"; 134 _.windowWidth = 0; 135 _.windowTimer = null; 136 137 dataSettings = $(element).data('slick') || {}; 138
139 _.options = $.extend({}, _.defaults, dataSettings, settings); 140 141 _.currentSlide = _.options.initialSlide; 142 143 _.originalSettings = _.options; 144 responsiveSettings = _.options.responsive || null; 145 146 if (responsiveSettings && responsiveSettings.length > -1) { 147 _.respondTo = _.options.respondTo || "window"; 148 for (breakpoint in responsiveSettings) { 149 if (responsiveSettings.hasOwnProperty(breakpoint)) { 150 _.breakpoints.push(responsiveSettings[ 151 breakpoint].breakpoint); 152 _.breakpointSettings[responsiveSettings[ 153 breakpoint].breakpoint] = 154 responsiveSettings[breakpoint].settings; 155 } 156 } 157 _.breakpoints.sort(function(a, b) { 158 if(_.options.mobileFirst === true) { 159 return a - b; 160 } else { 161 return b - a; 162 } 163 }); 164 } 165 166 if (typeof document.mozHidden !== "undefined") { 167 _.hidden = "mozHidden"; 168 _.visibilityChange = "mozvisibilitychange"; 169 } else if (typeof document.msHidden !== "undefined") { 170 _.hidden = "msHidden"; 171 _.visibilityChange = "msvisibilitychange"; 172 } else if (typeof document.webkitHidden !== "undefined") { 173 _.hidden = "webkitHidden"; 174 _.visibilityChange = "webkitvisibilitychange"; 175 } 176 177 _.autoPlay = $.proxy(_.autoPlay, _); 178 _.autoPlayClear = $.proxy(_.autoPlayClear, _); 179 _.changeSlide = $.proxy(_.changeSlide, _); 180 _.clickHandler = $.proxy(_.clickHandler, _); 181 _.selectHandler = $.proxy(_.selectHandler, _); 182 _.setPosition = $.proxy(_.setPosition, _); 183 _.swipeHandler = $.proxy(_.swipeHandler, _); 184 _.dragHandler = $.proxy(_.dragHandler, _); 185 _.keyHandler = $.proxy(_.keyHandler, _); 186 _.autoPlayIterator = $.proxy(_.autoPlayIterator, _); 187 188 _.instanceUid = instanceUid++; 189 190 // A simple way to check for HTML strings 191 // Strict HTML recognition (must start with <) 192 // Extracted from jQuery v1.11 source 193 _.htmlExpr = /^(?:\s*(<[\w\W]+>)[^>]*)$/; 194 195 _.init(); 196 197 _.checkResponsive(); 198 199 } 200 201 return Slick; 202 203 }()); 204 205 Slick.prototype.addSlide = Slick.prototype.slickAdd = function(markup, index, addBefore) { 206 207 var _ = this; 208 209 if (typeof(index) === 'boolean') { 210 addBefore = index; 211 index = null; 212 } else if (index < 0 || (index >= _.slideCount)) { 213 return false; 214 } 215 216 _.unload(); 217 218 if (typeof(index) === 'number') { 219 if (index === 0 && _.$slides.length === 0) { 220 $(markup).appendTo(_.$slideTrack); 221 } else if (addBefore) { 222 $(markup).insertBefore(_.$slides.eq(index)); 223 } else { 224 $(markup).insertAfter(_.$slides.eq(index)); 225 } 226 } else { 227 if (addBefore === true) { 228 $(markup).prependTo(_.$slideTrack); 229 } else { 230 $(markup).appendTo(_.$slideTrack); 231 } 232 } 233 234 _.$slides = _.$slideTrack.children(this.options.slide); 235 236 _.$slideTrack.children(this.options.slide).detach(); 237 238 _.$slideTrack.append(_.$slides); 239 240 _.$slides.each(function(index, element) { 241 $(element).attr("data-slick-index",index); 242 }); 243 244 _.$slidesCache = _.$slides; 245 246 _.reinit(); 247 248 }; 249 250 Slick.prototype.animateHeight = function(){ 251 var _ = this; 252 if(_.options.slidesToShow === 1 && _.options.adaptiveHeight === true && _.options.vertical === false) { 253 var targetHeight = _.$slides.eq(_.currentSlide).outerHeight(true); 254 _.$list.animate({height: targetHeight},_.options.speed); 255 } 256 }; 257 258 Slick.prototype.animateSlide = function(targetLeft, callback) { 259 260 var animProps = {}, _ = this; 261 262 _.animateHeight(); 263 264 if (_.options.rtl === true && _.options.vertical === false) { 265 targetLeft = -targetLeft; 266 } 267 if (_.transformsEnabled === false) { 268 if (_.options.vertical === false) { 269 _.$slideTrack.animate({ 270 left: targetLeft 271 }, _.options.speed, _.options.easing, callback); 272 } else { 273 _.$slideTrack.animate({ 274 top: targetLeft 275 }, _.options.speed, _.options.easing, callback); 276 } 277 278 } else { 279 280 if (_.cssTransitions === false) { 281 if (_.options.rtl === true) { 282 _.currentLeft = -(_.currentLeft); 283 } 284 $({ 285 animStart: _.currentLeft 286 }).animate({ 287 animStart: targetLeft 288 }, { 289 duration: _.options.speed, 290 easing: _.options.easing, 291 step: function(now) { 292 now = Math.ceil(now); 293 if (_.options.vertical === false) { 294 animProps[_.animType] = 'translate(' + 295 now + 'px, 0px)'; 296 _.$slideTrack.css(animProps); 297 } else { 298 animProps[_.animType] = 'translate(0px,' + 299 now + 'px)'; 300 _.$slideTrack.css(animProps); 301 } 302 }, 303 complete: function() { 304 if (callback) { 305 callback.call(); 306 } 307 } 308 }); 309 310 } else { 311 312 _.applyTransition();
313 targetLeft = Math.ceil(targetLeft); 314 315 if (_.options.vertical === false) { 316 animProps[_.animType] = 'translate3d(' + targetLeft + 'px, 0px, 0px)'; 317 } else { 318 animProps[_.animType] = 'translate3d(0px,' + targetLeft + 'px, 0px)'; 319 } 320 _.$slideTrack.css(animProps); 321 322 if (callback) { 323 setTimeout(function() { 324 325 _.disableTransition(); 326 327 callback.call(); 328 }, _.options.speed); 329 } 330 331 } 332 333 } 334 335 }; 336 337 Slick.prototype.asNavFor = function(index) { 338 var _ = this, asNavFor = _.options.asNavFor !== null ? $(_.options.asNavFor).slick('getSlick') : null; 339 if(asNavFor !== null) asNavFor.slideHandler(index, true); 340 }; 341 342 Slick.prototype.applyTransition = function(slide) { 343 344 var _ = this, 345 transition = {}; 346 347 if (_.options.fade === false) { 348 transition[_.transitionType] = _.transformType + ' ' + _.options.speed + 'ms ' + _.options.cssEase; 349 } else { 350 transition[_.transitionType] = 'opacity ' + _.options.speed + 'ms ' + _.options.cssEase; 351 } 352 353 if (_.options.fade === false) { 354 _.$slideTrack.css(transition); 355 } else { 356 _.$slides.eq(slide).css(transition); 357 } 358 359 }; 360 361 Slick.prototype.autoPlay = function() { 362 363 var _ = this; 364 365 if (_.autoPlayTimer) { 366 clearInterval(_.autoPlayTimer); 367 } 368 369 if (_.slideCount > _.options.slidesToShow && _.paused !== true) { 370 _.autoPlayTimer = setInterval(_.autoPlayIterator, 371 _.options.autoplaySpeed); 372 } 373 374 }; 375 376 Slick.prototype.autoPlayClear = function() { 377 378 var _ = this; 379 if (_.autoPlayTimer) { 380 clearInterval(_.autoPlayTimer); 381 } 382 383 }; 384 385 Slick.prototype.autoPlayIterator = function() { 386 387 var _ = this; 388 389 if (_.options.infinite === false) { 390 391 if (_.direction === 1) { 392 393 if ((_.currentSlide + 1) === _.slideCount - 394 1) { 395 _.direction = 0; 396 } 397 398 _.slideHandler(_.currentSlide + _.options.slidesToScroll); 399 400 } else { 401 402 if ((_.currentSlide - 1 === 0)) { 403 404 _.direction = 1; 405 406 } 407 408 _.slideHandler(_.currentSlide - _.options.slidesToScroll); 409 410 } 411 412 } else { 413 414 _.slideHandler(_.currentSlide + _.options.slidesToScroll); 415 416 } 417 418 }; 419 420 Slick.prototype.buildArrows = function() { 421 422 var _ = this; 423 424 if (_.options.arrows === true && _.slideCount > _.options.slidesToShow) { 425 426 _.$prevArrow = $(_.options.prevArrow); 427 _.$nextArrow = $(_.options.nextArrow); 428 429 if (_.htmlExpr.test(_.options.prevArrow)) { 430 _.$prevArrow.appendTo(_.options.appendArrows); 431 } 432 433 if (_.htmlExpr.test(_.options.nextArrow)) { 434 _.$nextArrow.appendTo(_.options.appendArrows); 435 } 436 437 if (_.options.infinite !== true) { 438 _.$prevArrow.addClass('slick-disabled'); 439 } 440 441 } 442 443 }; 444 445 Slick.prototype.buildDots = function() { 446 447 var _ = this, 448 i, dotString; 449 450 if (_.options.dots === true && _.slideCount > _.options.slidesToShow) { 451 452 dotString = '<ul class="' + _.options.dotsClass + '">'; 453 454 for (i = 0; i <= _.getDotCount(); i += 1) { 455 dotString += '<li>' + _.options.customPaging.call(this, _, i) + '</li>'; 456 } 457 458 dotString += '</ul>'; 459 460 _.$dots = $(dotString).appendTo( 461 _.options.appendDots); 462 463 _.$dots.find('li').first().addClass( 464 'slick-active'); 465 466 } 467 468 }; 469 470 Slick.prototype.buildOut = function() { 471 472 var _ = this; 473 474 _.$slides = _.$slider.children(_.options.slide + 475 ':not(.slick-cloned)').addClass( 476 'slick-slide'); 477 _.slideCount = _.$slides.length; 478 479 _.$slides.each(function(index, element) { 480 $(element).attr("data-slick-index",index); 481 }); 482 483 _.$slidesCache = _.$slides; 484 485 _.$slider.addClass('slick-slider'); 486 487 _.$slideTrack = (_.slideCount === 0) ? 488 $('<div class="slick-track"/>').appendTo(_.$slider) : 489 _.$slides.wrapAll('<div class="slick-track"/>').parent(); 490 491 _.$list = _.$slideTrack.wrap( 492 '<div class="slick-list"/>').parent(); 493 _.$slideTrack.css('opacity', 0); 494 495 if (_.options.centerMode === true) {
496 _.options.slidesToScroll = 1; 497 } 498 499 $('img[data-lazy]', _.$slider).not('[src]').addClass('slick-loading'); 500 501 _.setupInfinite(); 502 503 _.buildArrows(); 504 505 _.buildDots(); 506 507 _.updateDots(); 508 509 if (_.options.accessibility === true) { 510 _.$list.prop('tabIndex', 0); 511 } 512 513 _.setSlideClasses(typeof this.currentSlide === 'number' ? this.currentSlide : 0); 514 515 if (_.options.draggable === true) { 516 _.$list.addClass('draggable'); 517 } 518 519 }; 520 521 Slick.prototype.checkResponsive = function() { 522 523 var _ = this, 524 breakpoint, targetBreakpoint, respondToWidth; 525 var sliderWidth = _.$slider.width(); 526 var windowWidth = window.innerWidth || $(window).width(); 527 if (_.respondTo === "window") { 528 respondToWidth = windowWidth; 529 } else if (_.respondTo === "slider") { 530 respondToWidth = sliderWidth; 531 } else if (_.respondTo === "min") { 532 respondToWidth = Math.min(windowWidth, sliderWidth); 533 } 534 535 if (_.originalSettings.responsive && _.originalSettings 536 .responsive.length > -1 && _.originalSettings.responsive !== null) { 537 538 targetBreakpoint = null; 539 540 for (breakpoint in _.breakpoints) { 541 if (_.breakpoints.hasOwnProperty(breakpoint)) { 542 if (_.originalSettings.mobileFirst === false) { 543 if (respondToWidth < _.breakpoints[breakpoint]) { 544 targetBreakpoint = _.breakpoints[breakpoint]; 545 } 546 } else { 547 if (respondToWidth > _.breakpoints[breakpoint]) { 548 targetBreakpoint = _.breakpoints[breakpoint]; 549 } 550 } 551 } 552 } 553 554 if (targetBreakpoint !== null) { 555 if (_.activeBreakpoint !== null) { 556 if (targetBreakpoint !== _.activeBreakpoint) { 557 _.activeBreakpoint = 558 targetBreakpoint; 559 if(_.breakpointSettings[targetBreakpoint] === "unslick") { 560 _.unslick(); 561 } else { 562 _.options = $.extend({}, _.originalSettings, 563 _.breakpointSettings[ 564 targetBreakpoint]); 565 _.refresh(); 566 } 567 } 568 } else { 569 _.activeBreakpoint = targetBreakpoint; 570 if(_.breakpointSettings[targetBreakpoint] === "unslick") { 571 _.unslick(); 572 } else { 573 _.options = $.extend({}, _.originalSettings, 574 _.breakpointSettings[ 575 targetBreakpoint]); 576 _.refresh(); 577 } 578 } 579 } else { 580 if (_.activeBreakpoint !== null) { 581 _.activeBreakpoint = null; 582 _.options = _.originalSettings; 583 _.refresh(); 584 } 585 } 586 587 } 588 589 }; 590 591 Slick.prototype.changeSlide = function(event, dontAnimate) { 592 593 var _ = this, 594 $target = $(event.target), 595 indexOffset, slideOffset, unevenOffset; 596 597 // If target is a link, prevent default action. 598 $target.is('a') && event.preventDefault(); 599 600 unevenOffset = (_.slideCount % _.options.slidesToScroll !== 0); 601 indexOffset = unevenOffset ? 0 : (_.slideCount - _.currentSlide) % _.options.slidesToScroll; 602 603 switch (event.data.message) { 604 605 case 'previous': 606 slideOffset = indexOffset === 0 ? _.options.slidesToScroll : _.options.slidesToShow - indexOffset; 607 if (_.slideCount > _.options.slidesToShow) { 608 _.slideHandler(_.currentSlide - slideOffset, false, dontAnimate); 609 } 610 break; 611 612 case 'next': 613 slideOffset = indexOffset === 0 ? _.options.slidesToScroll : indexOffset; 614 if (_.slideCount > _.options.slidesToShow) { 615 _.slideHandler(_.currentSlide + slideOffset, false, dontAnimate); 616 } 617 break; 618 619 case 'index': 620 var index = event.data.index === 0 ? 0 : 621 event.data.index || $(event.target).parent().index() * _.options.slidesToScroll; 622 623 _.slideHandler(_.checkNavigable(index), false, dontAnimate); 624 break; 625 626 default: 627 return; 628 } 629 630 }; 631 632 Slick.prototype.checkNavigable = function(index) { 633 634 var _ = this, navigables, prevNavigable; 635 636 navigables = _.getNavigableIndexes(); 637 prevNavigable = 0; 638 if(index > navigables[navigables.length -1]){ 639 index = navigables[navigables.length -1]; 640 } else { 641 for(var n in navigables) { 642 if(index < navigables[n]) { 643 index = prevNavigable; 644 break; 645 } 646 prevNavigable = navigables[n]; 647 } 648 } 649 650 return index; 651 }; 652 653 Slick.prototype.clickHandler = function(event) { 654 655 var _ = this; 656 657 if(_.shouldClick === false) { 658 event.stopImmediatePropagation(); 659 event.stopPropagation(); 660 event.preventDefault(); 661 } 662 663 }; 664 665 Slick.prototype.destroy = function() { 666 667 var _ = this; 668 669 _.autoPlayClear(); 670 671 _.touchObject = {}; 672 673 $('.slick-cloned', _.$slider).remove(); 674 if (_.$dots) { 675 _.$dots.remove(); 676 } 677 if (_.$prevArrow && (typeof _.options.prevArrow !== 'object')) { 678 _.$prevArrow.remove(); 679 } 680 if (_.$nextArrow && (typeof _.options.nextArrow !== 'object')) { 681 _.$nextArrow.remove(); 682 } 683 684 _.$slides.removeClass( 685 'slick-slide slick-active slick-center slick-visible') 686 .removeAttr('data-slick-index') 687 .css({ 688 position: '', 689 left: '', 690 top: '', 691 zIndex: '', 692 opacity: '', 693 width: '' 694 }); 695 696 _.$slider.removeClass('slick-slider'); 697 _.$slider.removeClass('slick-initialized'); 698 699 _.$list.off('.slick'); 700 $(window).off('.slick-' + _.instanceUid); 701 $(document).off('.slick-' + _.instanceUid); 702 703 _.$slider.html(_.$slides); 704 705 }; 706 707 Slick.prototype.disableTransition = function(slide) { 708 709 var _ = this, 710 transition = {}; 711 712 transition[_.transitionType] = ""; 713 714 if (_.options.fade === false) { 715 _.$slideTrack.css(transition); 716 } else { 717 _.$slides.eq(slide).css(transition); 718 } 719 720 }; 721 722 Slick.prototype.fadeSlide = function(slideIndex, callback) { 723 724 var _ = this; 725 726 if (_.cssTransitions === false) { 727 728 _.$slides.eq(slideIndex).css({ 729 zIndex: 1000 730 }); 731 732 _.$slides.eq(slideIndex).animate({ 733 opacity: 1 734 }, _.options.speed, _.options.easing, callback); 735 736 } else { 737 738 _.applyTransition(slideIndex); 739 740 _.$slides.eq(slideIndex).css({ 741 opacity: 1, 742 zIndex: 1000 743 }); 744 745 if (callback) { 746 setTimeout(function() { 747 748 _.disableTransition(slideIndex); 749 750 callback.call(); 751 }, _.options.speed); 752 } 753 754 } 755 756 }; 757
758 Slick.prototype.filterSlides = Slick.prototype.slickFilter = function(filter) { 759 760 var _ = this; 761 762 if (filter !== null) { 763 764 _.unload(); 765 766 _.$slideTrack.children(this.options.slide).detach(); 767 768 _.$slidesCache.filter(filter).appendTo(_.$slideTrack); 769 770 _.reinit(); 771 772 } 773 774 }; 775 776 Slick.prototype.getCurrent = Slick.prototype.slickCurrentSlide = function() { 777 778 var _ = this; 779 return _.currentSlide; 780 781 }; 782 783 Slick.prototype.getDotCount = function() { 784 785 var _ = this; 786 787 var breakPoint = 0; 788 var counter = 0; 789 var pagerQty = 0; 790 791 if(_.options.infinite === true) { 792 pagerQty = Math.ceil(_.slideCount / _.options.slidesToScroll); 793 } else if (_.options.centerMode === true) { 794 pagerQty = _.slideCount; 795 } else { 796 while (breakPoint < _.slideCount){ 797 ++pagerQty; 798 breakPoint = counter + _.options.slidesToShow; 799 counter += _.options.slidesToScroll <= _.options.slidesToShow ? _.options.slidesToScroll : _.options.slidesToShow; 800 } 801 } 802 803 return pagerQty - 1; 804 805 }; 806 807 Slick.prototype.getLeft = function(slideIndex) { 808 809 var _ = this, 810 targetLeft, 811 verticalHeight, 812 verticalOffset = 0, 813 targetSlide; 814 815 _.slideOffset = 0; 816 verticalHeight = _.$slides.first().outerHeight(); 817 818 if (_.options.infinite === true) { 819 if (_.slideCount > _.options.slidesToShow) { 820 _.slideOffset = (_.slideWidth * _.options.slidesToShow) * -1; 821 verticalOffset = (verticalHeight * _.options.slidesToShow) * -1; 822 } 823 if (_.slideCount % _.options.slidesToScroll !== 0) { 824 if (slideIndex + _.options.slidesToScroll > _.slideCount && _.slideCount > _.options.slidesToShow) { 825 if(slideIndex > _.slideCount) { 826 _.slideOffset = ((_.options.slidesToShow - (sl
826ideIndex - _.slideCount)) * _.slideWidth) * -1; 827 verticalOffset = ((_.options.slidesToShow - (slideIndex - _.slideCount)) * verticalHeight) * -1; 828 } else { 829 _.slideOffset = ((_.slideCount % _.options.slidesToScroll) * _.slideWidth) * -1; 830 verticalOffset = ((_.slideCount % _.options.slidesToScroll) * verticalHeight) * -1; 831 } 832 } 833 } 834 } else { 835 if(slideIndex + _.options.slidesToShow > _.slideCount) { 836 _.slideOffset = ((slideIndex + _.options.slidesToShow) - _.slideCount) * _.slideWidth; 837 verticalOffset = ((slideIndex + _.options.slidesToShow) - _.slideCount) * verticalHeight; 838 } 839 } 840 841 if (_.slideCount <= _.options.slidesToShow){ 842 _.slideOffset = 0; 843 verticalOffset = 0; 844 } 845 846 if (_.options.centerMode === true && _.options.infinite === true) { 847 _.slideOffset += _.slideWidth * Math.floor(_.options.slidesToShow / 2) - _.slideWidth; 848 } else if (_.options.centerMode === true) { 849 _.slideOffset = 0; 850 _.slideOffset += _.slideWidth * Math.floor(_.options.slidesToShow / 2); 851 } 852 853 if (_.options.vertical === false) { 854 targetLeft = ((slideIndex * _.slideWidth) * -1) + _.slideOffset; 855 } else { 856 targetLeft = ((slideIndex * verticalHeight) * -1) + verticalOffset; 857 } 858 859 if (_.options.variableWidth === true) { 860
861 if (_.slideCount <= _.options.slidesToShow || _.options.infinite === false) { 862 targetSlide = _.$slideTrack.children('.slick-slide').eq(slideIndex); 863 } else { 864 targetSlide = _.$slideTrack.children('.slick-slide').eq(slideIndex + _.options.slidesToShow); 865 } 866 867 targetLeft = targetSlide[0] ? targetSlide[0].offsetLeft * -1 : 0; 868 869 if (_.options.centerMode === true) { 870 if(_.options.infinite === false) { 871 targetSlide = _.$slideTrack.children('.slick-slide').eq(slideIndex); 872 } else { 873 targetSlide = _.$slideTrack.children('.slick-slide').eq(slideIndex + _.options.slidesToShow + 1); 874 } 875 targetLeft = targetSlide[0] ? targetSlide[0].offsetLeft * -1 : 0; 876 targetLeft += (_.$list.width() - targetSlide.outerWidth()) / 2; 877 } 878 } 879 880 return targetLeft; 881 882 }; 883 884 Slick.prototype.getOption = Slick.prototype.slickGetOption = function(option) { 885 886 var _ = this; 887 888 return _.options[option]; 889 890 }; 891 892 Slick.prototype.getNavigableIndexes = function() { 893 894 var _ = this; 895 896 var breakPoint = 0; 897 var counter = 0; 898 var indexes = []; 899 var max = _.options.infinite === false ? _.slideCount - _.options.slidesToShow + 1 : _.slideCount; 900 if (_.options.centerMode === true) max = _.slideCount; 901 902 while (breakPoint < max){ 903 indexes.push(breakPoint); 904 breakPoint = counter + _.options.slidesToScroll; 905 counter += _.options.slidesToScroll <= _.options.slidesToShow ? _.options.slidesToScroll : _.options.slidesToShow; 906 } 907 908 return indexes; 909 910 }; 911 912 Slick.prototype.getSlick = function() { 913 914 return this; 915 916 }; 917 918 Slick.prototype.getSlideCount = function() { 919 920 var _ = this, slidesTraversed, swipedSlide, centerOffset; 921 922 centerOffset = _.options.centerMode === true ? _.slideWidth * Math.floor(_.options.slidesToShow / 2) : 0; 923 924 if(_.options.swipeToSlide === true) { 925 _.$slideTrack.find('.slick-slide').each(function(index, slide){ 926 if (slide.offsetLeft - centerOffset + ($(slide).outerWidth() / 2) > (_.swipeLeft * -1)) { 927 swipedSlide = slide; 928 return false; 929 } 930 }); 931 932 slidesTraversed = Math.abs($(swipedSlide).attr('data-slick-index') - _.currentSlide) || 1; 933 934 return slidesTraversed; 935 936 } else { 937 return _.options.slidesToScroll; 938 } 939 940 }; 941 942 Slick.prototype.goTo = Slick.prototype.slickGoTo = function(slide, dontAnimate) { 943 944 var _ = this; 945 946 _.changeSlide({ 947 data: { 948 message: 'index', 949 index: parseInt(slide) 950 } 951 }, dontAnimate); 952 953 }; 954 955 Slick.prototype.init = function() { 956 957 var _ = this; 958 959 if (!$(_.$slider).hasClass('slick-initialized')) { 960 961 $(_.$slider).addClass('slick-initialized'); 962 _.buildOut(); 963 _.setProps(); 964 _.startLoad(); 965 _.loadSlider(); 966 _.initializeEvents(); 967 _.updateArrows(); 968 _.updateDots(); 969 } 970 971 _.$slider.trigger("init", [ _ ]); 972 973 }; 974 975 Slick.prototype.initArrowEvents = function() { 976 977 var _ = this; 978 979 if (_.options.arrows === true && _.slideCount > _.options.slidesToShow) { 980 _.$prevArrow.on('click.slick', { 981 message: 'previous' 982 }, _.changeSlide); 983 _.$nextArrow.on('click.slick', { 984 message: 'next' 985 }, _.changeSlide); 986 } 987 988 }; 989 990 Slick.prototype.initDotEvents = function() { 991 992 var _ = this; 993 994 if (_.options.dots === true && _.slideCount > _.options.slidesToShow) { 995 $('li', _.$dots).on('click.slick', { 996 message: 'index' 997 }, _.changeSlide); 998 } 999 1000 if (_.options.dots === true && _.options.pauseOnDotsHover === true && _.options.autoplay === true) { 1001 $('li', _.$dots) 1002 .on('mouseenter.slick', function(){ 1003 _.paused = true; 1004 _.autoPlayClear(); 1005 })
1006 .on('mouseleave.slick', function(){ 1007 _.paused = false; 1008 _.autoPlay(); 1009 }); 1010 } 1011 1012 }; 1013 1014 Slick.prototype.initializeEvents = function() { 1015 1016 var _ = this; 1017 1018 _.initArrowEvents(); 1019 1020 _.initDotEvents(); 1021 1022 _.$list.on('touchstart.slick mousedown.slick', { 1023 action: 'start' 1024 }, _.swipeHandler); 1025 _.$list.on('touchmove.slick mousemove.slick', { 1026 action: 'move' 1027 }, _.swipeHandler); 1028 _.$list.on('touchend.slick mouseup.slick', { 1029 action: 'end' 1030 }, _.swipeHandler); 1031 _.$list.on('touchcancel.slick mouseleave.slick', { 1032 action: 'end' 1033 }, _.swipeHandler); 1034 1035 _.$list.on('click.slick', _.clickHandler); 1036 1037 if (_.options.autoplay === true) { 1038 1039 $(document).on(_.visibilityChange, function(){ 1040 _.visibility(); 1041 }); 1042 1043 if( _.options.pauseOnHover === true ) { 1044 1045 _.$list.on('mouseenter.slick', function(){ 1046 _.paused = true; 1047 _.autoPlayClear(); 1048 }); 1049 _.$list.on('mouseleave.slick', function(){ 1050 _.paused = false; 1051 _.autoPlay(); 1052 }); 1053 1054 } 1055 1056 } 1057 1058 if(_.options.accessibility === true) { 1059 _.$list.on('keydown.slick', _.keyHandler); 1060 } 1061 1062 if(_.options.focusOnSelect === true) { 1063 $(_.options.slide, _.$slideTrack).on('click.slick', _.selectHandler); 1064 } 1065 1066 $(window).on('orientationchange.slick.slick-' + _.instanceUid, function() { 1067 _.checkResponsive(); 1068 _.setPosition(); 1069 }); 1070 1071 $(window).on('resize.slick.slick-' + _.instanceUid, function() { 1072 if ($(window).width() !== _.windowWidth) { 1073 clearTimeout(_.windowDelay); 1074 _.windowDelay = window.setTimeout(function() { 1075 _.windowWidth = $(window).width(); 1076 _.checkResponsive(); 1077 _.setPosition(); 1078 }, 50); 1079 } 1080 }); 1081 1082 $('*[draggable!=true]', _.$slideTrack).on('dragstart', function(e){ e.preventDefault(); }); 1083 1084 $(window).on('load.slick.slick-' + _.instanceUid, _.setPosition); 1085 $(document).on('ready.slick.slick-' + _.instanceUid, _.setPosition); 1086 1087 }; 1088 1089 Slick.prototype.initUI = function() { 1090 1091 var _ = this; 1092 1093 if (_.options.arrows === true && _.slideCount > _.options.slidesToShow) { 1094 1095 _.$prevArrow.show(); 1096 _.$nextArrow.show(); 1097 1098 } 1099 1100 if (_.options.dots === true && _.slideCount > _.options.slidesToShow) { 1101 1102 _.$dots.show(); 1103 1104 } 1105 1106 if (_.options.autoplay === true) { 1107 1108 _.autoPlay(); 1109 1110 } 1111 1112 }; 1113 1114 Slick.prototype.keyHandler = function(event) { 1115 1116 var _ = this; 1117 1118 if (event.keyCode === 37 && _.options.accessibility === true) { 1119 _.changeSlide({ 1120 data: { 1121 message: 'previous' 1122 } 1123 }); 1124 } else if (event.keyCode === 39 && _.options.accessibility === true) { 1125 _.changeSlide({ 1126 data: { 1127 message: 'next' 1128 } 1129 }); 1130 } 1131 1132 }; 1133 1134 Slick.prototype.lazyLoad = function() { 1135 1136 var _ = this, 1137 loadRange, cloneRange, rangeStart, rangeEnd; 1138 1139 function loadImages(imagesScope) { 1140 $('img[data-lazy]', imagesScope).each(function() { 1141 var image = $(this), 1142 imageSource = $(this).attr('data-lazy'); 1143 1144 image 1145 .load(function() { image.animate({ opacity: 1 }, 200); }) 1146 .css({ opacity: 0 }) 1147 .attr('src', imageSource) 1148 .removeAttr('data-lazy') 1149 .removeClass('slick-loading'); 1150 }); 1151 } 1152 1153 if (_.options.centerMode === true) { 1154 if (_.options.infinite === true) { 1155 rangeStart = _.currentSlide + (_.options.slidesToShow/2 + 1); 1156 rangeEnd = rangeStart + _.options.slidesToShow + 2; 1157 } else { 1158 rangeStart = Math.max(0, _.currentSlide - (_.options.slidesToShow/2 + 1)); 1159 rangeEnd = 2 + (_.options.slidesToShow/2 + 1) + _.currentSlide; 1160 } 1161 } else {
1162 rangeStart = _.options.infinite ? _.options.slidesToShow + _.currentSlide : _.currentSlide; 1163 rangeEnd = rangeStart + _.options.slidesToShow; 1164 if (_.options.fade === true ) { 1165 if(rangeStart > 0) rangeStart--; 1166 if(rangeEnd <= _.slideCount) rangeEnd++; 1167 } 1168 } 1169 1170 loadRange = _.$slider.find('.slick-slide').slice(rangeStart, rangeEnd); 1171 loadImages(loadRange); 1172 1173 if (_.slideCount <= _.options.slidesToShow){ 1174 cloneRange = _.$slider.find('.slick-slide'); 1175 loadImages(cloneRange); 1176 }else 1177 if (_.currentSlide >= _.slideCount - _.options.slidesToShow) { 1178 cloneRange = _.$slider.find('.slick-cloned').slice(0, _.options.slidesToShow); 1179 loadImages(cloneRange); 1180 } else if (_.currentSlide === 0) { 1181 cloneRange = _.$slider.find('.slick-cloned').slice(_.options.slidesToShow * -1); 1182 loadImages(cloneRange); 1183 } 1184 1185 }; 1186 1187 Slick.prototype.loadSlider = function() { 1188 1189 var _ = this; 1190 1191 _.setPosition(); 1192 1193 _.$slideTrack.css({ 1194 opacity: 1 1195 }); 1196 1197 _.$slider.removeClass('slick-loading'); 1198 1199 _.initUI(); 1200 1201 if (_.options.lazyLoad === 'progressive') { 1202 _.progressiveLazyLoad(); 1203 } 1204 1205 }; 1206 1207 Slick.prototype.next = Slick.prototype.slickNext = function() { 1208 1209 var _ = this; 1210 1211 _.changeSlide({ 1212 data: { 1213 message: 'next' 1214 } 1215 }); 1216 1217 }; 1218 1219 Slick.prototype.pause = Slick.prototype.slickPause = function() { 1220 1221 var _ = this; 1222 1223 _.autoPlayClear(); 1224 _.paused = true; 1225 1226 }; 1227 1228 Slick.prototype.play = Slick.prototype.slickPlay = function() { 1229 1230 var _ = this; 1231 1232 _.paused = false; 1233 _.autoPlay(); 1234 1235 }; 1236 1237 Slick.prototype.postSlide = function(index) { 1238 1239 var _ = this; 1240 1241 _.$slider.trigger("afterChange", [ _, index]); 1242 1243 _.animating = false; 1244 1245 _.setPosition(); 1246 1247 _.swipeLeft = null; 1248 1249 if (_.options.autoplay === true && _.paused === false) { 1250 _.autoPlay(); 1251 } 1252 1253 }; 1254 1255 Slick.prototype.prev = Slick.prototype.slickPrev = function() { 1256 1257 var _ = this; 1258 1259 _.changeSlide({ 1260 data: { 1261 message: 'previous' 1262 } 1263 }); 1264 1265 }; 1266 1267 Slick.prototype.progressiveLazyLoad = function() { 1268 1269 var _ = this, 1270 imgCount, targetImage; 1271 1272 imgCount = $('img[data-lazy]', _.$slider).length; 1273 1274 if (imgCount > 0) { 1275 targetImage = $('img[data-lazy]', _.$slider).first(); 1276 targetImage.attr('src', targetImage.attr('data-lazy')).removeClass('slick-loading').load(function() { 1277 targetImage.removeAttr('data-lazy'); 1278 _.progressiveLazyLoad(); 1279 }) 1280 .error(function () { 1281 targetImage.removeAttr('data-lazy'); 1282 _.progressiveLazyLoad(); 1283 }); 1284 } 1285 1286 }; 1287 1288 Slick.prototype.refresh = function() { 1289 1290 var _ = this, 1291 currentSlide = _.currentSlide; 1292 1293 _.destroy(); 1294 1295 $.extend(_, _.initials); 1296 1297 _.init(); 1298 1299 _.changeSlide({ 1300 data: { 1301 message: 'index', 1302 index: currentSlide 1303 } 1304 }, true); 1305 1306 }; 1307 1308 Slick.prototype.reinit = function() { 1309 1310 var _ = this; 1311 1312 _.$slides = _.$slideTrack.children(_.options.slide).addClass( 1313 'slick-slide'); 1314 1315 _.slideCount = _.$slides.length; 1316 1317 if (_.currentSlide >= _.slideCount && _.currentSlide !== 0) { 1318 _.currentSlide = _.currentSlide - _.options.slidesToScroll; 1319 } 1320 1321 if (_.slideCount <= _.options.slidesToShow) { 1322 _.currentSlide = 0; 1323 } 1324 1325 _.setProps(); 1326 1327 _.setupInfinite(); 1328 1329 _.buildArrows(); 1330 1331 _.updateArrows(); 1332 1333 _.initArrowEvents(); 1334 1335 _.buildDots(); 1336 1337 _.updateDots(); 1338 1339 _.initDotEvents(); 1340 1341 if(_.options.focusOnSelect === true) { 1342 $(_.options.slide, _.$slideTrack).on('click.slick', _.selectHandler); 1343 } 1344 1345 _.setSlideClasses(0); 1346 1347 _.setPosition(); 1348 1349 _.$slider.trigger("reInit", [ _ ]); 1350 1351 }; 1352 1353 Slick.prototype.removeSlide = Slick.prototype.slickRemove = function(index, removeBefore, removeAll) { 1354 1355 var _ = this; 1356 1357 if (typeof(index) === 'boolean') { 1358 removeBefore = index; 1359 index = removeBefore === true ? 0 : _.slideCount - 1; 1360 } else { 1361 index = removeBefore === true ? --index : index; 1362 } 1363 1364 if (_.slideCount < 1 || index < 0 || index > _.slideCount - 1) { 1365 return false;
1366 } 1367 1368 _.unload(); 1369 1370 if(removeAll === true) { 1371 _.$slideTrack.children().remove(); 1372 } else { 1373 _.$slideTrack.children(this.options.slide).eq(index).remove(); 1374 } 1375 1376 _.$slides = _.$slideTrack.children(this.options.slide); 1377 1378 _.$slideTrack.children(this.options.slide).detach(); 1379 1380 _.$slideTrack.append(_.$slides); 1381 1382 _.$slidesCache = _.$slides; 1383 1384 _.reinit(); 1385 1386 }; 1387 1388 Slick.prototype.setCSS = function(position) { 1389 1390 var _ = this, 1391 positionProps = {}, x, y; 1392 1393 if (_.options.rtl === true) { 1394 position = -position; 1395 } 1396 x = _.positionProp == 'left' ? Math.ceil(position) + 'px' : '0px'; 1397 y = _.positionProp == 'top' ? Math.ceil(position) + 'px' : '0px'; 1398 1399 positionProps[_.positionProp] = position; 1400 1401 if (_.transformsEnabled === false) { 1402 _.$slideTrack.css(positionProps); 1403 } else { 1404 positionProps = {}; 1405 if (_.cssTransitions === false) { 1406 positionProps[_.animType] = 'translate(' + x + ', ' + y + ')'; 1407 _.$slideTrack.css(positionProps); 1408 } else { 1409 positionProps[_.animType] = 'translate3d(' + x + ', ' + y + ', 0px)'; 1410 _.$slideTrack.css(positionProps); 1411 } 1412 } 1413 1414 }; 1415 1416 Slick.prototype.setDimensions = function() { 1417 1418 var _ = this; 1419 1420 if (_.options.vertical === false) { 1421 if (_.options.centerMode === true) { 1422 _.$list.css({ 1423 padding: ('0px ' + _.options.centerPadding) 1424 }); 1425 } 1426 } else { 1427 _.$list.height(_.$slides.first().outerHeight(true) * _.options.slidesToShow); 1428 if (_.options.centerMode === true) { 1429 _.$list.css({ 1430 padding: (_.options.centerPadding + ' 0px') 1431 }); 1432 } 1433 } 1434 1435 _.listWidth = _.$list.width(); 1436 _.listHeight = _.$list.height(); 1437 1438 1439 if(_.options.vertical === false && _.options.variableWidth === false) { 1440 _.slideWidth = Math.ceil(_.listWidth / _.options.slidesToShow); 1441 _.$slideTrack.width(Math.ceil((_.slideWidth * _.$slideTrack.children('.slick-slide').length))); 1442 1443 } else if (_.options.variableWidth === true) { 1444 var trackWidth = 0; 1445 _.slideWidth = Math.ceil(_.listWidth / _.options.slidesToShow); 1446 _.$slideTrack.children('.slick-slide').each(function(){ 1447 trackWidth += _.listWidth; 1448 }); 1449 _.$slideTrack.width(Math.ceil(trackWidth) + 1); 1450 } else { 1451 _.slideWidth = Math.ceil(_.listWidth); 1452 _.$slideTrack.height(Math.ceil((_.$slides.first().outerHeight(true) * _.$slideTrack.children('.slick-slide').length))); 1453 } 1454 1455 var offset = _.$slides.first().outerWidth(true) - _.$slides.first().width(); 1456 if (_.options.variableWidth === false) _.$slideTrack.children('.slick-slide').width(_.slideWidth - offset); 1457 1458 }; 1459 1460 Slick.prototype.setFade = function() { 1461 1462 var _ = this, 1463 targetLeft; 1464 1465 _.$slides.each(function(index, element) { 1466 targetLeft = (_.slideWidth * index) * -1; 1467 if (_.options.rtl === true) { 1468 $(element).css({ 1469 position: 'relative', 1470 right: targetLeft, 1471 top: 0, 1472 zIndex: 800, 1473 opacity: 0 1474 }); 1475 } else { 1476 $(element).css({ 1477 position: 'relative', 1478 left: targetLeft, 1479 top: 0, 1480 zIndex: 800, 1481 opacity: 0 1482 }); 1483 } 1484 }); 1485 1486 _.$slides.eq(_.currentSlide).css({ 1487 zIndex: 900, 1488 opacity: 1 1489 }); 1490 1491 }; 1492 1493 Slick.prototype.setHeight = function() { 1494 1495 var _ = this; 1496 1497 if(_.options.slidesToShow === 1 && _.options.adaptiveHeight === true && _.options.vertical === false) { 1498 var targetHeight = _.$slides.eq(_.currentSlide).outerHeight(true); 1499 _.$list.css('height', targetHeight); 1500 } 1501 1502 }; 1503 1504 Slick.prototype.setOption = Slick.prototype.slickSetOption = function(option, value, refresh) { 1505 1506 var _ = this;
1507 _.options[option] = value; 1508 1509 if (refresh === true) { 1510 _.unload(); 1511 _.reinit(); 1512 } 1513 1514 }; 1515 1516 Slick.prototype.setPosition = function() { 1517 1518 var _ = this; 1519 1520 _.setDimensions(); 1521 1522 _.setHeight(); 1523 1524 if (_.options.fade === false) { 1525 _.setCSS(_.getLeft(_.currentSlide)); 1526 } else { 1527 _.setFade(); 1528 } 1529 1530 _.$slider.trigger("setPosition", [ _ ]); 1531 1532 }; 1533 1534 Slick.prototype.setProps = function() { 1535 1536 var _ = this, 1537 bodyStyle = document.body.style; 1538 1539 _.positionProp = _.options.vertical === true ? 'top' : 'left'; 1540 1541 if (_.positionProp === 'top') { 1542 _.$slider.addClass('slick-vertical'); 1543 } else { 1544 _.$slider.removeClass('slick-vertical'); 1545 } 1546 1547 if (bodyStyle.WebkitTransition !== undefined || 1548 bodyStyle.MozTransition !== undefined || 1549 bodyStyle.msTransition !== undefined) { 1550 if(_.options.useCSS === true) { 1551 _.cssTransitions = true; 1552 } 1553 } 1554 1555 if (bodyStyle.OTransform !== undefined) { 1556 _.animType = 'OTransform'; 1557 _.transformType = "-o-transform"; 1558 _.transitionType = 'OTransition'; 1559 if (bodyStyle.perspectiveProperty === undefined && bodyStyle.webkitPerspective === undefined) _.animType = false;
1560 } 1561 if (bodyStyle.MozTransform !== undefined) { 1562 _.animType = 'MozTransform'; 1563 _.transformType = "-moz-transform"; 1564 _.transitionType = 'MozTransition'; 1565 if (bodyStyle.perspectiveProperty === undefined && bodyStyle.MozPerspective === undefined) _.animType = false; 1566 } 1567 if (bodyStyle.webkitTransform !== undefined) { 1568 _.animType = 'webkitTransform'; 1569 _.transformType = "-webkit-transform"; 1570 _.transitionType = 'webkitTransition'; 1571 if (bodyStyle.perspectiveProperty === undefined && bodyStyle.webkitPerspective === undefined) _.animType = false; 1572 } 1573 if (bodyStyle.msTransform !== undefined) { 1574 _.animType = 'msTransform'; 1575 _.transformType = "-ms-transform"; 1576 _.transitionType = 'msTransition'; 1577 if (bodyStyle.msTransform === undefined) _.animType = false; 1578 } 1579 if (bodyStyle.transform !== undefined && _.animType !== false) { 1580 _.animType = 'transform'; 1581 _.transformType = "transform"; 1582 _.transitionType = 'transition'; 1583 } 1584 _.transformsEnabled = (_.animType !== null && _.animType !== false); 1585 1586 }; 1587 1588 1589 Slick.prototype.setSlideClasses = function(index) { 1590 1591 var _ = this, 1592 centerOffset, allSlides, indexOffset, remainder; 1593 1594 _.$slider.find('.slick-slide').removeClass('slick-active').removeClass('slick-center'); 1595 allSlides = _.$slider.find('.slick-slide'); 1596 1597 if (_.options.centerMode === true) { 1598 1599 centerOffset = Math.floor(_.options.slidesToShow / 2); 1600 1601 if(_.options.infinite === true) { 1602 1603 if (index >= centerOffset && index <= (_.slideCount - 1) - centerOffset) { 1604 _.$slides.slice(index - centerOffset, index + centerOffset + 1).addClass('slick-active'); 1605 } else { 1606 indexOffset = _.options.slidesToShow + index; 1607 allSlides.slice(indexOffset - centerOffset + 1, indexOffset + centerOffset + 2).addClass('slick-active'); 1608 } 1609 1610 if (index === 0) { 1611 allSlides.eq(allSlides.length - 1 - _.options.slidesToShow).addClass('slick-center'); 1612 } else if (index === _.slideCount - 1) { 1613 allSlides.eq(_.options.slidesToShow).addClass('slick-center'); 1614 } 1615 1616 } 1617 1618 _.$slides.eq(index).addClass('slick-center'); 1619 1620 } else { 1621 1622 if (index >= 0 && index <= (_.slideCount - _.options.slidesToShow)) { 1623 _.$slides.slice(index, index + _.options.slidesToShow).addClass('slick-active'); 1624 } else if ( allSlides.length <= _.options.slidesToShow ) { 1625 allSlides.addClass('slick-active'); 1626 } else { 1627 remainder = _.slideCount%_.options.slidesToShow; 1628 indexOffset = _.options.infinite === true ? _.options.slidesToShow + index : index; 1629 if(_.options.slidesToShow == _.options.slidesToScroll && (_.slideCount - index) < _.options.slidesToShow) { 1630 allSlides.slice(indexOffset-(_.options.slidesToShow-remainder), indexOffset + remainder).addClass('slick-active'); 1631 } else { 1632 allSlides.slice(indexOffset, indexOffset + _.options.slidesToShow).addClass('slick-active'); 1633 } 1634 } 1635 1636 } 1637 1638 if (_.options.lazyLoad === 'ondemand') { 1639 _.lazyLoad(); 1640 } 1641 1642 }; 1643 1644 Slick.prototype.setupInfinite = function() { 1645 1646 var _ = this, 1647 i, slideIndex, infiniteCount; 1648 1649 if (_.options.fade === true) { 1650 _.options.centerMode = false; 1651 } 1652 1653 if (_.options.infinite === true && _.options.fade === false) { 1654 1655 slideIndex = null; 1656 1657 if (_.slideCount > _.options.slidesToShow) { 1658 1659 if (_.options.centerMode === true) { 1660 infiniteCount = _.options.slidesToShow + 1; 1661 } else { 1662 infiniteCount = _.options.slidesToShow; 1663 } 1664 1665 for (i = _.slideCount; i > (_.slideCount - 1666 infiniteCount); i -= 1) { 1667 slideIndex = i - 1; 1668 $(_.$slides[slideIndex]).clone(true).attr('id', '') 1669 .attr('data-slick-index', slideIndex-_.slideCount) 1670 .prependTo(_.$slideTrack).addClass('slick-cloned'); 1671 } 1672 for (i = 0; i < infiniteCount; i += 1) { 1673 slideIndex = i; 1674 $(_.$slides[slideIndex]).clone(true).attr('id', '') 1675 .attr('data-slick-index', slideIndex+_.slideCount) 1676 .appendTo(_.$slideTrack).addClass('slick-cloned'); 1677 } 1678 _.$slideTrack.find('.slick-cloned').find('[id]').each(function() { 1679 $(this).attr('id', ''); 1680 }); 1681 1682 } 1683 1684 } 1685 1686 }; 1687 1688 Slick.prototype.selectHandler = function(event) { 1689 1690 var _ = this; 1691 var index = parseInt($(event.target).parents('.slick-slide').attr("data-slick-index")); 1692 if(!index) index = 0; 1693 1694 if(_.slideCount <= _.options.slidesToShow){ 1695 _.$slider.find('.slick-slide').removeClass('slick-active'); 1696 _.$slides.eq(index).addClass('slick-active'); 1697 if(_.options.centerMode === true) { 1698 _.$slider.find('.slick-slide').removeClass('slick-center'); 1699 _.$slides.eq(index).addClass('slick-center'); 1700 } 1701 _.asNavFor(index); 1702 return; 1703 } 1704 _.slideHandler(index); 1705 1706 }; 1707 1708 Slick.prototype.slideHandler = function(index,sync,dontAnimate) { 1709 1710 var targetSlide, animSlide, oldSlide, slideLeft, targetLeft = null, 1711 _ = this; 1712 1713 sync = sync || false; 1714 1715 if (_.animating === true && _.options.waitForAnimate === true) { 1716 return; 1717 } 1718 1719 if (_.options.fade === true && _.currentSlide === index) { 1720 return; 1721 } 1722 1723 if (_.slideCount <= _.options.slidesToShow) { 1724 return; 1725 } 1726 1727 if (sync === false) { 1728 _.asNavFor(index); 1729 } 1730 1731 targetSlide = index; 1732 targetLeft = _.getLeft(targetSlide); 1733 slideLeft = _.getLeft(_.currentSlide); 1734 1735 _.currentLeft = _.swipeLeft === null ? slideLeft : _.swipeLeft; 1736 1737 if (_.options.infinite === false && _.options.centerMode === false && (index < 0 || index > _.getDotCount() * _.options.slidesToScroll)) { 1738 if(_.options.fade === false) { 1739 targetSlide = _.currentSlide; 1740 if(dontAnimate!==true) { 1741 _.animateSlide(slideLeft, function() { 1742 _.postSlide(targetSlide); 1743 }); 1744 } else { 1745 _.postSlide(targetSlide); 1746 } 1747 } 1748 return; 1749 } else if (_.options.infinite === false && _.options.centerMode === true && (index < 0 || index > (_.slideCount - _.options.slidesToScroll))) { 1750 if(_.options.fade === false) { 1751 targetSlide = _.currentSlide; 1752 if(dontAnimate!==true) { 1753 _.animateSlide(slideLeft, function() { 1754 _.postSlide(targetSlide); 1755 }); 1756 } else { 1757 _.postSlide(targetSlide); 1758 } 1759 } 1760 return; 1761 } 1762 1763 if (_.options.autoplay === true) { 1764 clearInterval(_.autoPlayTimer); 1765 } 1766
1767 if (targetSlide < 0) { 1768 if (_.slideCount % _.options.slidesToScroll !== 0) { 1769 animSlide = _.slideCount - (_.slideCount % _.options.slidesToScroll); 1770 } else { 1771 animSlide = _.slideCount + targetSlide; 1772 } 1773 } else if (targetSlide >= _.slideCount) { 1774 if (_.slideCount % _.options.slidesToScroll !== 0) { 1775 animSlide = 0; 1776 } else { 1777 animSlide = targetSlide - _.slideCount; 1778 } 1779 } else { 1780 animSlide = targetSlide; 1781 } 1782 1783 _.animating = true; 1784 1785 _.$slider.trigger("beforeChange", [ _ , _.currentSlide, animSlide]); 1786 1787 oldSlide = _.currentSlide; 1788 _.currentSlide = animSlide; 1789 1790 _.setSlideClasses(_.currentSlide); 1791 1792 _.updateDots(); 1793 _.updateArrows(); 1794 1795 if (_.options.fade === true) { 1796 if(dontAnimate!==true) { 1797 _.fadeSlide(animSlide, function() { 1798 _.postSlide(animSlide); 1799 }); 1800 } else { 1801 _.postSlide(animSlide); 1802 } 1803 _.animateHeight(); 1804 return; 1805 } 1806 1807 if(dontAnimate!==true) { 1808 _.animateSlide(targetLeft, function() { 1809 _.postSlide(animSlide); 1810 }); 1811 } else { 1812 _.postSlide(animSlide); 1813 } 1814 1815 }; 1816 1817 Slick.prototype.startLoad = function() { 1818 1819 var _ = this; 1820 1821 if (_.options.arrows === true && _.slideCount > _.options.slidesToShow) { 1822 1823 _.$prevArrow.hide(); 1824 _.$nextArrow.hide(); 1825 1826 } 1827 1828 if (_.options.dots === true && _.slideCount > _.options.slidesToShow) { 1829 1830 _.$dots.hide(); 1831 1832 } 1833 1834 _.$slider.addClass('slick-loading'); 1835 1836 }; 1837 1838 Slick.prototype.swipeDirection = function() { 1839 1840 var xDist, yDist, r, swipeAngle, _ = this; 1841 1842 xDist = _.touchObject.startX - _.touchObject.curX; 1843 yDist = _.touchObject.startY - _.touchObject.curY; 1844 r = Math.atan2(yDist, xDist); 1845 1846 swipeAngle = Math.round(r * 180 / Math.PI); 1847 if (swipeAngle < 0) { 1848 swipeAngle = 360 - Math.abs(swipeAngle); 1849 } 1850 1851 if ((swipeAngle <= 45) && (swipeAngle >= 0)) { 1852 return (_.options.rtl === false ? 'left' : 'right'); 1853 } 1854 if ((swipeAngle <= 360) && (swipeAngle >= 315)) { 1855 return (_.options.rtl === false ? 'left' : 'right'); 1856 } 1857 if ((swipeAngle >= 135) && (swipeAngle <= 225)) { 1858 return (_.options.rtl === false ? 'right' : 'left'); 1859 } 1860 1861 return 'vertical'; 1862 1863 }; 1864 1865 Slick.prototype.swipeEnd = function(event) { 1866 1867 var _ = this, slideCount; 1868 1869 _.dragging = false; 1870 1871 _.shouldClick = (_.touchObject.swipeLength > 10) ? false : true; 1872 1873 if (_.touchObject.curX === undefined) { 1874 return false; 1875 } 1876 1877 if (_.touchObject.edgeHit === true) { 1878 _.$slider.trigger("edge", [ _, _.swipeDirection()]); 1879 } 1880 1881 if (_.touchObject.swipeLength >= _.touchObject.minSwipe) { 1882 1883 switch (_.swipeDirection()) { 1884 case 'left': 1885 slideCount = _.options.swipeToSlide ? _.checkNavigable(_.currentSlide + _.getSlideCount()) : _.currentSlide + _.getSlideCount(); 1886 _.slideHandler(slideCount); 1887 _.currentDirection = 0; 1888 _.touchObject = {}; 1889 _.$slider.trigger("swipe", [ _, "left"]); 1890 break; 1891 1892 case 'right': 1893 slideCount = _.options.swipeToSlide ? _.checkNavigable(_.currentSlide - _.getSlideCount()) : _.currentSlide - _.getSlideCount(); 1894 _.slideHandler(slideCount); 1895 _.currentDirection = 1; 1896 _.touchObject = {}; 1897 _.$slider.trigger("swipe", [ _, "right"]); 1898 break; 1899 } 1900 } else { 1901 if(_.touchObject.startX !== _.touchObject.curX) { 1902 _.slideHandler(_.currentSlide); 1903 _.touchObject = {}; 1904 } 1905 } 1906 1907 }; 1908 1909 Slick.prototype.swipeHandler = function(event) { 1910 1911 var _ = this; 1912 1913 if ((_.options.swipe === false) || ('ontouchend' in document && _.options.swipe === false)) { 1914 return; 1915 } else if (_.options.draggable === false && event.type.indexOf('mouse') !== -1) { 1916 return; 1917 } 1918 1919 _.touchObject.fingerCount = event.originalEvent && event.originalEvent.touches !== undefined ? 1920 event.originalEvent.touches.length : 1; 1921 1922 _.touchObject.minSwipe = _.listWidth / _.options 1923 .touchThreshold; 1924 1925 switch (event.data.action) { 1926 1927 case 'start': 1928 _.swipeStart(event); 1929 break; 1930 1931 case 'move': 1932 _.swipeMove(event); 1933 break; 1934 1935 case 'end': 1936 _.swipeEnd(event); 1937 break; 1938 1939 } 1940 1941 }; 1942 1943 Slick.prototype.swipeMove = function(event) { 1944 1945 var _ = this, 1946 edgeWasHit = false, 1947 curLeft, swipeDirection, swipeLength, positionOffset, touches; 1948 1949 touches = event.originalEvent !== undefined ? event.originalEvent.touches : null; 1950 1951 if (!_.dragging || touches && touches.length !== 1) { 1952 return false;
1953 } 1954 1955 curLeft = _.getLeft(_.currentSlide); 1956 1957 _.touchObject.curX = touches !== undefined ? touches[0].pageX : event.clientX; 1958 _.touchObject.curY = touches !== undefined ? touches[0].pageY : event.clientY; 1959 1960 _.touchObject.swipeLength = Math.round(Math.sqrt( 1961 Math.pow(_.touchObject.curX - _.touchObject.startX, 2))); 1962 1963 swipeDirection = _.swipeDirection(); 1964 1965 if (swipeDirection === 'vertical') { 1966 return; 1967 } 1968 1969 if (event.originalEvent !== undefined && _.touchObject.swipeLength > 4) { 1970 event.preventDefault(); 1971 } 1972 1973 positionOffset = (_.options.rtl === false ? 1 : -1) * (_.touchObject.curX > _.touchObject.startX ? 1 : -1); 1974 1975 swipeLength = _.touchObject.swipeLength; 1976 1977 _.touchObject.edgeHit = false; 1978 1979 if (_.options.infinite === false) { 1980 if ((_.currentSlide === 0 && swipeDirection === "right") || (_.currentSlide >= _.getDotCount() && swipeDirection === "left")) { 1981 swipeLength = _.touchObject.swipeLength * _.options.edgeFriction; 1982 _.touchObject.edgeHit = true; 1983 } 1984 } 1985 1986 if (_.options.vertical === false) { 1987 _.swipeLeft = curLeft + swipeLength * positionOffset; 1988 } else { 1989 _.swipeLeft = curLeft + (swipeLength * (_.$list.height() / _.listWidth)) * positionOffset; 1990 } 1991 1992 if (_.options.fade === true || _.options.touchMove === false) { 1993 return false; 1994 } 1995 1996 if (_.animating === true) { 1997 _.swipeLeft = null; 1998 return false; 1999 } 2000 2001 _.setCSS(_.swipeLeft); 2002 2003 }; 2004 2005 Slick.prototype.swipeStart = function(event) { 2006 2007 var _ = this, 2008 touches; 2009 2010 if (_.touchObject.fingerCount !== 1 || _.slideCount <= _.options.slidesToShow) { 2011 _.touchObject = {}; 2012 return false; 2013 } 2014 2015 if (event.originalEvent !== undefined && event.originalEvent.touches !== undefined) { 2016 touches = event.originalEvent.touches[0]; 2017 } 2018 2019 _.touchObject.startX = _.touchObject.curX = touches !== undefined ? touches.pageX : event.clientX; 2020 _.touchObject.startY = _.touchObject.curY = touches !== undefined ? touches.pageY : event.clientY; 2021 2022 _.dragging = true; 2023 2024 }; 2025 2026 Slick.prototype.unfilterSlides = Slick.prototype.slickUnfilter = function() { 2027 2028 var _ = this; 2029 2030 if (_.$slidesCache !== null) { 2031 2032 _.unload(); 2033 2034 _.$slideTrack.children(this.options.slide).detach(); 2035 2036 _.$slidesCache.appendTo(_.$slideTrack); 2037 2038 _.reinit(); 2039 2040 } 2041 2042 }; 2043 2044 Slick.prototype.unload = function() { 2045 2046 var _ = this; 2047 2048 $('.slick-cloned', _.$slider).remove(); 2049 if (_.$dots) { 2050 _.$dots.remove(); 2051 } 2052 if (_.$prevArrow && (typeof _.options.prevArrow !== 'object')) { 2053 _.$prevArrow.remove(); 2054 } 2055 if (_.$nextArrow && (typeof _.options.nextArrow !== 'object')) { 2056 _.$nextArrow.remove(); 2057 } 2058 _.$slides.removeClass( 2059 'slick-slide slick-active slick-visible').css('width', ''); 2060 2061 }; 2062 2063 Slick.prototype.unslick = function() { 2064 2065 var _ = this; 2066 _.destroy(); 2067 2068 }; 2069 2070 Slick.prototype.updateArrows = function() { 2071 2072 var _ = this, centerOffset; 2073 2074 centerOffset = Math.floor(_.options.slidesToShow / 2); 2075 2076 if (_.options.arrows === true && _.options.infinite !== 2077 true && _.slideCount > _.options.slidesToShow) { 2078 _.$prevArrow.removeClass('slick-disabled'); 2079 _.$nextArrow.removeClass('slick-disabled'); 2080 if (_.currentSlide === 0) { 2081 _.$prevArrow.addClass('slick-disabled'); 2082 _.$nextArrow.removeClass('slick-disabled'); 2083 } else if (_.currentSlide >= _.slideCount - _.options.slidesToShow && _.options.centerMode === false) { 2084 _.$nextArrow.addClass('slick-disabled'); 2085 _.$prevArrow.removeClass('slick-disabled'); 2086 } else if (_.currentSlide >= _.slideCount - 1 && _.options.centerMode === true) { 2087 _.$nextArrow.addClass('slick-disabled'); 2088 _.$prevArrow.removeClass('slick-disabled'); 2089 } 2090 } 2091 2092 }; 2093 2094 Slick.prototype.updateDots = function() { 2095 2096 var _ = this; 2097 2098 if (_.$dots !== null) { 2099 2100 _.$dots.find('li').removeClass('slick-active'); 2101 _.$dots.find('li').eq(Math.floor(_.currentSlide / _.options.slidesToScroll)).addClass('slick-active'); 2102 2103 } 2104 2105 }; 2106 2107 Slick.prototype.visibility = function() { 2108 2109 var _ = this; 2110 2111 if( document[ _.hidden ] ) { 2112 _.paused = true; 2113 _.autoPlayClear(); 2114 } else { 2115 _.paused = false;
2116 _.autoPlay(); 2117 } 2118 2119 }; 2120 2121 $.fn.slick = function() { 2122 var _ = this, opt = arguments[0], args = Array.prototype.slice.call(arguments,1), l = _.length, i = 0, ret; 2123 for(i; i < l; i++) { 2124 if (typeof opt == 'object' || typeof opt == 'undefined') 2125 _[i].slick = new Slick(_[i], opt); 2126 else 2127 ret = _[i].slick[opt].apply(_[i].slick, args); 2128 if (typeof ret != 'undefined') return ret; 2129 } 2130 return _; 2131 }; 2132 2133 $(function(){ 2134 $('[data-slick]').slick(); 2135 }); 2136 2137}));
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.