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