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