Advertisement
contatowellington

Untitled

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