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