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