You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

2892 lines
82 KiB

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