slick.js 44 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668
  1. /*
  2. _ _ _ _
  3. ___| (_) ___| | __ (_)___
  4. / __| | |/ __| |/ / | / __|
  5. \__ \ | | (__| < _ | \__ \
  6. |___/_|_|\___|_|\_(_)/ |___/
  7. |__/
  8. Author: Ken Wheeler
  9. Website: http://kenwheeler.github.io
  10. Docs: http://kenwheeler.github.io/slick
  11. Repo: http://github.com/kenwheeler/slick
  12. Issues: http://github.com/kenwheeler/slick/issues
  13. */
  14. /* global window, document, define, jQuery, setInterval, clearInterval */
  15. (function(factory) {
  16. 'use strict';
  17. if (typeof define === 'function' && define.amd) {
  18. define(['jquery'], factory);
  19. } else {
  20. factory(jQuery);
  21. }
  22. }(function($) {
  23. 'use strict';
  24. var Slick = window.Slick || {};
  25. Slick = (function() {
  26. var instanceUid = 0;
  27. function Slick(element, settings) {
  28. var _ = this,
  29. responsiveSettings, breakpoint;
  30. _.defaults = {
  31. accessibility: true,
  32. arrows: true,
  33. autoplay: false,
  34. autoplaySpeed: 3000,
  35. centerMode: false,
  36. centerPadding: '50px',
  37. cssEase: 'ease',
  38. customPaging: function(slider, i) {
  39. return '<button type="button">' + (i + 1) + '</button>';
  40. },
  41. dots: false,
  42. draggable: true,
  43. easing: 'linear',
  44. fade: false,
  45. infinite: true,
  46. lazyLoad: 'ondemand',
  47. onBeforeChange: null,
  48. onAfterChange: null,
  49. onInit: null,
  50. onReInit: null,
  51. pauseOnHover: true,
  52. responsive: null,
  53. slide: 'div',
  54. slidesToShow: 1,
  55. slidesToScroll: 1,
  56. speed: 300,
  57. swipe: true,
  58. touchMove: true,
  59. touchThreshold: 5,
  60. vertical: false
  61. };
  62. _.initials = {
  63. animating: false,
  64. autoPlayTimer: null,
  65. currentSlide: 0,
  66. currentLeft: null,
  67. direction: 1,
  68. $dots: null,
  69. listWidth: null,
  70. listHeight: null,
  71. loadIndex: 0,
  72. $nextArrow: null,
  73. $prevArrow: null,
  74. slideCount: null,
  75. slideWidth: null,
  76. $slideTrack: null,
  77. $slides: null,
  78. sliding: false,
  79. slideOffset: 0,
  80. swipeLeft: null,
  81. $list: null,
  82. touchObject: {},
  83. transformsEnabled: false
  84. };
  85. $.extend(_, _.initials);
  86. _.activeBreakpoint = null;
  87. _.animType = null;
  88. _.animProp = null;
  89. _.breakpoints = [];
  90. _.breakpointSettings = [];
  91. _.cssTransitions = false;
  92. _.paused = false;
  93. _.positionProp = null;
  94. _.$slider = $(element);
  95. _.$slidesCache = null;
  96. _.transformType = null;
  97. _.transitionType = null;
  98. _.windowWidth = 0;
  99. _.windowTimer = null;
  100. _.options = $.extend({}, _.defaults, settings);
  101. _.originalSettings = _.options;
  102. responsiveSettings = _.options.responsive || null;
  103. if (responsiveSettings && responsiveSettings.length > -1) {
  104. for (breakpoint in responsiveSettings) {
  105. if (responsiveSettings.hasOwnProperty(breakpoint)) {
  106. _.breakpoints.push(responsiveSettings[
  107. breakpoint].breakpoint);
  108. _.breakpointSettings[responsiveSettings[
  109. breakpoint].breakpoint] =
  110. responsiveSettings[breakpoint].settings;
  111. }
  112. }
  113. _.breakpoints.sort(function(a, b) {
  114. return b - a;
  115. });
  116. }
  117. _.autoPlay = $.proxy(_.autoPlay, _);
  118. _.autoPlayClear = $.proxy(_.autoPlayClear, _);
  119. _.changeSlide = $.proxy(_.changeSlide, _);
  120. _.setPosition = $.proxy(_.setPosition, _);
  121. _.swipeHandler = $.proxy(_.swipeHandler, _);
  122. _.dragHandler = $.proxy(_.dragHandler, _);
  123. _.keyHandler = $.proxy(_.keyHandler, _);
  124. _.autoPlayIterator = $.proxy(_.autoPlayIterator, _);
  125. _.instanceUid = instanceUid++;
  126. _.init();
  127. }
  128. return Slick;
  129. }());
  130. Slick.prototype.addSlide = function(markup, index, addBefore) {
  131. var _ = this;
  132. if (typeof(index) === 'boolean') {
  133. addBefore = index;
  134. index = null;
  135. } else if (index < 0 || (index >= _.slideCount)) {
  136. return false;
  137. }
  138. _.unload();
  139. if (typeof(index) === 'number') {
  140. if (index === 0 && _.$slides.length === 0) {
  141. $(markup).appendTo(_.$slideTrack);
  142. } else if (addBefore) {
  143. $(markup).insertBefore(_.$slides.eq(index));
  144. } else {
  145. $(markup).insertAfter(_.$slides.eq(index));
  146. }
  147. } else {
  148. if (addBefore === true) {
  149. $(markup).prependTo(_.$slideTrack);
  150. } else {
  151. $(markup).appendTo(_.$slideTrack);
  152. }
  153. }
  154. _.$slides = _.$slideTrack.children(this.options.slide);
  155. _.$slideTrack.children(this.options.slide).remove();
  156. _.$slideTrack.append(_.$slides);
  157. _.$slidesCache = _.$slides;
  158. _.reinit();
  159. };
  160. Slick.prototype.animateSlide = function(targetLeft,
  161. callback) {
  162. var animProps = {}, _ = this;
  163. if (_.transformsEnabled === false) {
  164. if (_.options.vertical === false) {
  165. _.$slideTrack.animate({
  166. left: targetLeft
  167. }, _.options.speed, _.options.easing, callback);
  168. } else {
  169. _.$slideTrack.animate({
  170. top: targetLeft
  171. }, _.options.speed, _.options.easing, callback);
  172. }
  173. } else {
  174. if (_.cssTransitions === false) {
  175. $({
  176. animStart: _.currentLeft
  177. }).animate({
  178. animStart: targetLeft
  179. }, {
  180. duration: _.options.speed,
  181. easing: _.options.easing,
  182. step: function(now) {
  183. if (_.options.vertical === false) {
  184. animProps[_.animType] = 'translate(' +
  185. now + 'px, 0px)';
  186. _.$slideTrack.css(animProps);
  187. } else {
  188. animProps[_.animType] = 'translate(0px,' +
  189. now + 'px,0px)';
  190. _.$slideTrack.css(animProps);
  191. }
  192. },
  193. complete: function() {
  194. if (callback) {
  195. callback.call();
  196. }
  197. }
  198. });
  199. } else {
  200. _.applyTransition();
  201. if (_.options.vertical === false) {
  202. animProps[_.animType] = 'translate3d(' + targetLeft + 'px, 0px, 0px)';
  203. } else {
  204. animProps[_.animType] = 'translate3d(0px,' + targetLeft + 'px, 0px)';
  205. }
  206. _.$slideTrack.css(animProps);
  207. if (callback) {
  208. setTimeout(function() {
  209. _.disableTransition();
  210. callback.call();
  211. }, _.options.speed);
  212. }
  213. }
  214. }
  215. };
  216. Slick.prototype.applyTransition = function(slide) {
  217. var _ = this,
  218. transition = {};
  219. if (_.options.fade === false) {
  220. transition[_.transitionType] = _.transformType + ' ' + _.options.speed + 'ms ' + _.options.cssEase;
  221. } else {
  222. transition[_.transitionType] = 'opacity ' + _.options.speed + 'ms ' + _.options.cssEase;
  223. }
  224. if (_.options.fade === false) {
  225. _.$slideTrack.css(transition);
  226. } else {
  227. _.$slides.eq(slide).css(transition);
  228. }
  229. };
  230. Slick.prototype.autoPlay = function() {
  231. var _ = this;
  232. if (_.autoPlayTimer) {
  233. clearInterval(_.autoPlayTimer);
  234. }
  235. if (_.slideCount > _.options.slidesToShow && _.paused !== true) {
  236. _.autoPlayTimer = setInterval(_.autoPlayIterator,
  237. _.options.autoplaySpeed);
  238. }
  239. };
  240. Slick.prototype.autoPlayClear = function() {
  241. var _ = this;
  242. if (_.autoPlayTimer) {
  243. clearInterval(_.autoPlayTimer);
  244. }
  245. };
  246. Slick.prototype.autoPlayIterator = function() {
  247. var _ = this;
  248. if (_.options.infinite === false) {
  249. if (_.direction === 1) {
  250. if ((_.currentSlide + 1) === _.slideCount -
  251. 1) {
  252. _.direction = 0;
  253. }
  254. _.slideHandler(_.currentSlide + _.options
  255. .slidesToScroll);
  256. } else {
  257. if ((_.currentSlide - 1 === 0)) {
  258. _.direction = 1;
  259. }
  260. _.slideHandler(_.currentSlide - _.options
  261. .slidesToScroll);
  262. }
  263. } else {
  264. _.slideHandler(_.currentSlide + _.options.slidesToScroll);
  265. }
  266. };
  267. Slick.prototype.buildArrows = function() {
  268. var _ = this;
  269. if (_.options.arrows === true && _.slideCount > _.options.slidesToShow) {
  270. _.$prevArrow = $(
  271. '<button type="button" class="slick-prev">Previous</button>').appendTo(
  272. _.$slider);
  273. _.$nextArrow = $(
  274. '<button type="button" class="slick-next">Next</button>').appendTo(
  275. _.$slider);
  276. if (_.options.infinite !== true) {
  277. _.$prevArrow.addClass('slick-disabled');
  278. }
  279. }
  280. };
  281. Slick.prototype.buildDots = function() {
  282. var _ = this,
  283. i, dotString;
  284. if (_.options.dots === true && _.slideCount > _.options.slidesToShow) {
  285. dotString = '<ul class="slick-dots">';
  286. for (i = 0; i <= _.getDotCount(); i += 1) {
  287. dotString += '<li>' + _.options.customPaging.call(this, _, i) + '</li>';
  288. }
  289. dotString += '</ul>';
  290. _.$dots = $(dotString).appendTo(
  291. _.$slider);
  292. _.$dots.find('li').first().addClass(
  293. 'slick-active');
  294. }
  295. };
  296. Slick.prototype.buildOut = function() {
  297. var _ = this;
  298. _.$slides = _.$slider.children(_.options.slide +
  299. ':not(.slick-cloned)').addClass(
  300. 'slick-slide');
  301. _.slideCount = _.$slides.length;
  302. _.$slidesCache = _.$slides;
  303. _.$slider.addClass('slick-slider');
  304. _.$slideTrack = (_.slideCount === 0) ?
  305. $('<div class="slick-track"/>').appendTo(_.$slider) :
  306. _.$slides.wrapAll('<div class="slick-track"/>').parent();
  307. _.$list = _.$slideTrack.wrap(
  308. '<div class="slick-list"/>').parent();
  309. _.$slideTrack.css('opacity', 0);
  310. if (_.options.centerMode === true) {
  311. _.options.infinite = true;
  312. _.options.slidesToScroll = 1;
  313. if (_.options.slidesToShow % 2 === 0) {
  314. _.options.slidesToShow = 3;
  315. }
  316. }
  317. $('img[data-lazy]', _.$slider).not('[src]').addClass('slick-loading');
  318. _.setupInfinite();
  319. _.buildArrows();
  320. _.buildDots();
  321. if (_.options.accessibility === true) {
  322. _.$list.prop('tabIndex', 0);
  323. }
  324. _.setSlideClasses(0);
  325. if (_.options.draggable === true) {
  326. _.$list.addClass('draggable');
  327. }
  328. };
  329. Slick.prototype.checkResponsive = function() {
  330. var _ = this,
  331. breakpoint, targetBreakpoint;
  332. if (_.originalSettings.responsive && _.originalSettings
  333. .responsive.length > -1 && _.originalSettings.responsive !== null) {
  334. targetBreakpoint = null;
  335. for (breakpoint in _.breakpoints) {
  336. if (_.breakpoints.hasOwnProperty(breakpoint)) {
  337. if ($(window).width() < _.breakpoints[
  338. breakpoint]) {
  339. targetBreakpoint = _.breakpoints[
  340. breakpoint];
  341. }
  342. }
  343. }
  344. if (targetBreakpoint !== null) {
  345. if (_.activeBreakpoint !== null) {
  346. if (targetBreakpoint !== _.activeBreakpoint) {
  347. _.activeBreakpoint =
  348. targetBreakpoint;
  349. _.options = $.extend({}, _.defaults,
  350. _.breakpointSettings[
  351. targetBreakpoint]);
  352. _.refresh();
  353. }
  354. } else {
  355. _.activeBreakpoint = targetBreakpoint;
  356. _.options = $.extend({}, _.defaults,
  357. _.breakpointSettings[
  358. targetBreakpoint]);
  359. _.refresh();
  360. }
  361. } else {
  362. if (_.activeBreakpoint !== null) {
  363. _.activeBreakpoint = null;
  364. _.options = $.extend({}, _.defaults,
  365. _.originalSettings);
  366. _.refresh();
  367. }
  368. }
  369. }
  370. };
  371. Slick.prototype.changeSlide = function(event) {
  372. var _ = this;
  373. switch (event.data.message) {
  374. case 'previous':
  375. _.slideHandler(_.currentSlide - _.options
  376. .slidesToScroll);
  377. break;
  378. case 'next':
  379. _.slideHandler(_.currentSlide + _.options
  380. .slidesToScroll);
  381. break;
  382. case 'index':
  383. _.slideHandler($(event.target).parent().index() * _.options.slidesToScroll);
  384. break;
  385. default:
  386. return false;
  387. }
  388. };
  389. Slick.prototype.destroy = function() {
  390. var _ = this;
  391. _.autoPlayClear();
  392. _.touchObject = {};
  393. $('.slick-cloned', _.$slider).remove();
  394. if (_.$dots) {
  395. _.$dots.remove();
  396. }
  397. if (_.$prevArrow) {
  398. _.$prevArrow.remove();
  399. _.$nextArrow.remove();
  400. }
  401. _.$slides.unwrap().unwrap();
  402. _.$slides.removeClass(
  403. 'slick-slide slick-active slick-visible').removeAttr('style');
  404. _.$slider.removeClass('slick-slider');
  405. _.$slider.removeClass('slick-initialized');
  406. _.$list.off('.slick');
  407. $(window).off('.slick-' + _.instanceUid);
  408. };
  409. Slick.prototype.disableTransition = function(slide) {
  410. var _ = this,
  411. transition = {};
  412. transition[_.transitionType] = "";
  413. if (_.options.fade === false) {
  414. _.$slideTrack.css(transition);
  415. } else {
  416. _.$slides.eq(slide).css(transition);
  417. }
  418. };
  419. Slick.prototype.fadeSlide = function(slideIndex, callback) {
  420. var _ = this;
  421. if (_.cssTransitions === false) {
  422. _.$slides.eq(slideIndex).css({
  423. zIndex: 1000
  424. });
  425. _.$slides.eq(slideIndex).animate({
  426. opacity: 1
  427. }, _.options.speed, _.options.easing, callback);
  428. } else {
  429. _.applyTransition(slideIndex);
  430. _.$slides.eq(slideIndex).css({
  431. opacity: 1,
  432. zIndex: 1000
  433. });
  434. if (callback) {
  435. setTimeout(function() {
  436. _.disableTransition(slideIndex);
  437. callback.call();
  438. }, _.options.speed);
  439. }
  440. }
  441. };
  442. Slick.prototype.filterSlides = function(filter) {
  443. var _ = this;
  444. if (filter !== null) {
  445. _.unload();
  446. _.$slideTrack.children(this.options.slide).remove();
  447. _.$slidesCache.filter(filter).appendTo(_.$slideTrack);
  448. _.reinit();
  449. }
  450. };
  451. Slick.prototype.getDotCount = function() {
  452. var _ = this,
  453. breaker = 0,
  454. dotCounter = 0,
  455. dotCount = 0,
  456. dotLimit;
  457. dotLimit = _.options.infinite === true ? _.slideCount + _.options.slidesToShow - _.options.slidesToScroll : _.slideCount;
  458. while (breaker < dotLimit) {
  459. dotCount++;
  460. dotCounter += _.options.slidesToScroll;
  461. breaker = dotCounter + _.options.slidesToShow;
  462. }
  463. return dotCount;
  464. };
  465. Slick.prototype.getLeft = function(slideIndex) {
  466. var _ = this,
  467. targetLeft;
  468. _.slideOffset = 0;
  469. if (_.options.infinite === true) {
  470. if (_.slideCount > _.options.slidesToShow) {
  471. _.slideOffset = (_.slideWidth * _.options.slidesToShow) * -1;
  472. }
  473. if (_.slideCount % _.options.slidesToScroll !== 0) {
  474. if (slideIndex + _.options.slidesToScroll > _.slideCount && _.slideCount > _.options.slidesToShow) {
  475. _.slideOffset = ((_.slideCount % _.options.slidesToShow) * _.slideWidth) * -1;
  476. }
  477. }
  478. } else {
  479. if (_.slideCount % _.options.slidesToShow !== 0) {
  480. if (slideIndex + _.options.slidesToScroll > _.slideCount && _.slideCount > _.options.slidesToShow) {
  481. _.slideOffset = ((_.slideCount % _.options.slidesToShow) * _.slideWidth);
  482. }
  483. }
  484. }
  485. if (_.options.centerMode === true) {
  486. _.slideOffset += _.slideWidth * Math.floor(_.options.slidesToShow / 2) - _.slideWidth;
  487. }
  488. if (_.options.vertical === false) {
  489. targetLeft = ((slideIndex * _.slideWidth) * -1) + _.slideOffset;
  490. } else {
  491. _.listHeight = _.$list.height();
  492. if (_.options.infinite === true) {
  493. targetLeft = ((slideIndex * _.listHeight) * -1) - _.listHeight;
  494. } else {
  495. targetLeft = ((slideIndex * _.listHeight) * -1);
  496. }
  497. }
  498. return targetLeft;
  499. };
  500. Slick.prototype.init = function() {
  501. var _ = this;
  502. if (!$(_.$slider).hasClass('slick-initialized')) {
  503. $(_.$slider).addClass('slick-initialized');
  504. _.buildOut();
  505. _.setProps();
  506. _.startLoad();
  507. _.loadSlider();
  508. _.initializeEvents();
  509. _.checkResponsive();
  510. }
  511. if (_.options.onInit !== null) {
  512. _.options.onInit.call(this, _);
  513. }
  514. };
  515. Slick.prototype.initArrowEvents = function() {
  516. var _ = this;
  517. if (_.options.arrows === true && _.slideCount > _.options.slidesToShow) {
  518. _.$prevArrow.on('click.slick', {
  519. message: 'previous'
  520. }, _.changeSlide);
  521. _.$nextArrow.on('click.slick', {
  522. message: 'next'
  523. }, _.changeSlide);
  524. }
  525. };
  526. Slick.prototype.initDotEvents = function() {
  527. var _ = this;
  528. if (_.options.dots === true && _.slideCount > _.options.slidesToShow) {
  529. $('li', _.$dots).on('click.slick', {
  530. message: 'index'
  531. }, _.changeSlide);
  532. }
  533. };
  534. Slick.prototype.initializeEvents = function() {
  535. var _ = this;
  536. _.initArrowEvents();
  537. _.initDotEvents();
  538. _.$list.on('touchstart.slick mousedown.slick', {
  539. action: 'start'
  540. }, _.swipeHandler);
  541. _.$list.on('touchmove.slick mousemove.slick', {
  542. action: 'move'
  543. }, _.swipeHandler);
  544. _.$list.on('touchend.slick mouseup.slick', {
  545. action: 'end'
  546. }, _.swipeHandler);
  547. _.$list.on('touchcancel.slick mouseleave.slick', {
  548. action: 'end'
  549. }, _.swipeHandler);
  550. if (_.options.pauseOnHover === true && _.options.autoplay === true) {
  551. _.$list.on('mouseenter.slick', _.autoPlayClear);
  552. _.$list.on('mouseleave.slick', _.autoPlay);
  553. }
  554. _.$list.on('keydown.slick', _.keyHandler);
  555. $(window).on('orientationchange.slick.slick-' + _.instanceUid, function() {
  556. _.checkResponsive();
  557. _.setPosition();
  558. });
  559. $(window).on('resize.slick.slick-' + _.instanceUid, function() {
  560. if ($(window).width !== _.windowWidth) {
  561. clearTimeout(_.windowDelay);
  562. _.windowDelay = window.setTimeout(function() {
  563. _.windowWidth = $(window).width();
  564. _.checkResponsive();
  565. _.setPosition();
  566. }, 50);
  567. }
  568. });
  569. $(window).on('load.slick.slick-' + _.instanceUid, _.setPosition);
  570. };
  571. Slick.prototype.initUI = function() {
  572. var _ = this;
  573. if (_.options.arrows === true && _.slideCount > _.options.slidesToShow) {
  574. _.$prevArrow.show();
  575. _.$nextArrow.show();
  576. }
  577. if (_.options.dots === true && _.slideCount > _.options.slidesToShow) {
  578. _.$dots.show();
  579. }
  580. if (_.options.autoplay === true) {
  581. _.autoPlay();
  582. }
  583. };
  584. Slick.prototype.keyHandler = function(event) {
  585. var _ = this;
  586. if (event.keyCode === 37) {
  587. _.changeSlide({
  588. data: {
  589. message: 'previous'
  590. }
  591. });
  592. } else if (event.keyCode === 39) {
  593. _.changeSlide({
  594. data: {
  595. message: 'next'
  596. }
  597. });
  598. }
  599. };
  600. Slick.prototype.lazyLoad = function() {
  601. var _ = this,
  602. loadRange, cloneRange, rangeStart, rangeEnd;
  603. if (_.options.centerMode === true) {
  604. rangeStart = _.options.slidesToShow + _.currentSlide - 1;
  605. rangeEnd = rangeStart + _.options.slidesToShow + 2;
  606. } else {
  607. rangeStart = _.options.infinite ? _.options.slidesToShow + _.currentSlide : _.currentSlide;
  608. rangeEnd = rangeStart + _.options.slidesToShow;
  609. }
  610. loadRange = _.$slider.find('.slick-slide').slice(rangeStart, rangeEnd);
  611. $('img[data-lazy]', loadRange).not('[src]').each(function() {
  612. $(this).attr('src', $(this).attr('data-lazy')).removeClass('slick-loading');
  613. });
  614. if (_.currentSlide >= _.slideCount - _.options.slidesToShow) {
  615. cloneRange = _.$slider.find('.slick-cloned').slice(0, _.options.slidesToShow);
  616. $('img[data-lazy]', cloneRange).not('[src]').each(function() {
  617. $(this).attr('src', $(this).attr('data-lazy')).removeClass('slick-loading');
  618. });
  619. } else if (_.currentSlide === 0) {
  620. cloneRange = _.$slider.find('.slick-cloned').slice(_.options.slidesToShow * -1);
  621. $('img[data-lazy]', cloneRange).not('[src]').each(function() {
  622. $(this).attr('src', $(this).attr('data-lazy')).removeClass('slick-loading');
  623. });
  624. }
  625. };
  626. Slick.prototype.loadSlider = function() {
  627. var _ = this;
  628. _.setPosition();
  629. _.$slideTrack.css({
  630. opacity: 1
  631. });
  632. _.$slider.removeClass('slick-loading');
  633. _.initUI();
  634. if (_.options.lazyLoad === 'progressive') {
  635. _.progressiveLazyLoad();
  636. }
  637. };
  638. Slick.prototype.postSlide = function(index) {
  639. var _ = this;
  640. if (_.options.onAfterChange !== null && index !== _.currentSlide) {
  641. _.options.onAfterChange.call(this, _, index);
  642. }
  643. _.animating = false;
  644. _.setPosition();
  645. _.swipeLeft = null;
  646. if (_.options.autoplay === true && _.paused === false) {
  647. _.autoPlay();
  648. }
  649. _.setSlideClasses(_.currentSlide);
  650. };
  651. Slick.prototype.progressiveLazyLoad = function() {
  652. var _ = this,
  653. imgCount, targetImage;
  654. imgCount = $('img[data-lazy]').not('[src]').length;
  655. if (imgCount > 0) {
  656. targetImage = $($('img[data-lazy]', _.$slider).not('[src]').get(0));
  657. targetImage.attr('src', targetImage.attr('data-lazy')).removeClass('slick-loading').load(function() {
  658. _.progressiveLazyLoad();
  659. });
  660. }
  661. };
  662. Slick.prototype.refresh = function() {
  663. var _ = this;
  664. _.destroy();
  665. $.extend(_, _.initials);
  666. _.init();
  667. };
  668. Slick.prototype.reinit = function() {
  669. var _ = this;
  670. _.$slides = $(_.options.slide +
  671. ':not(.slick-cloned)', _.$slideTrack).addClass(
  672. 'slick-slide');
  673. _.slideCount = _.$slides.length;
  674. if (_.currentSlide >= _.slideCount && _.currentSlide !== 0) {
  675. _.currentSlide = _.currentSlide - _.options.slidesToScroll;
  676. }
  677. _.setProps();
  678. _.setupInfinite();
  679. _.buildArrows();
  680. _.updateArrows();
  681. _.initArrowEvents();
  682. _.buildDots();
  683. _.updateDots();
  684. _.initDotEvents();
  685. _.setSlideClasses(0);
  686. _.setPosition();
  687. if (_.options.onReInit !== null) {
  688. _.options.onReInit.call(this, _);
  689. }
  690. };
  691. Slick.prototype.removeSlide = function(index, removeBefore) {
  692. var _ = this;
  693. if (typeof(index) === 'boolean') {
  694. removeBefore = index;
  695. index = removeBefore === true ? 0 : _.slideCount - 1;
  696. } else {
  697. index = removeBefore === true ? --index : index;
  698. }
  699. if (_.slideCount < 1 || index < 0 || index > _.slideCount - 1) {
  700. return false;
  701. }
  702. _.unload();
  703. _.$slideTrack.children(this.options.slide).eq(index).remove();
  704. _.$slides = _.$slideTrack.children(this.options.slide);
  705. _.$slideTrack.children(this.options.slide).remove();
  706. _.$slideTrack.append(_.$slides);
  707. _.$slidesCache = _.$slides;
  708. _.reinit();
  709. };
  710. Slick.prototype.setCSS = function(position) {
  711. var _ = this,
  712. positionProps = {}, x, y;
  713. x = _.positionProp == 'left' ? position + 'px' : '0px';
  714. y = _.positionProp == 'top' ? position + 'px' : '0px';
  715. positionProps[_.positionProp] = position;
  716. if (_.transformsEnabled === false) {
  717. _.$slideTrack.css(positionProps);
  718. } else {
  719. positionProps = {};
  720. if (_.cssTransitions === false) {
  721. positionProps[_.animType] = 'translate(' + x + ', ' + y + ')';
  722. _.$slideTrack.css(positionProps);
  723. } else {
  724. positionProps[_.animType] = 'translate3d(' + x + ', ' + y + ', 0px)';
  725. _.$slideTrack.css(positionProps);
  726. }
  727. }
  728. };
  729. Slick.prototype.setDimensions = function() {
  730. var _ = this;
  731. if (_.options.centerMode === true) {
  732. _.$list.find('.slick-slide').width(_.slideWidth);
  733. } else {
  734. _.$list.find('.slick-slide').width(_.slideWidth);
  735. }
  736. if (_.options.vertical === false) {
  737. _.$slideTrack.width(Math.ceil((_.slideWidth * _
  738. .$slider.find('.slick-slide').length)));
  739. if (_.options.centerMode === true) {
  740. _.$list.css({
  741. padding: ('0px ' + _.options.centerPadding)
  742. });
  743. }
  744. } else {
  745. _.$list.height(_.$slides.first().outerHeight());
  746. _.$slideTrack.height(Math.ceil((_.listHeight * _
  747. .$slider.find('.slick-slide').length)));
  748. if (_.options.centerMode === true) {
  749. _.$list.css({
  750. padding: (_.options.centerPadding + ' 0px')
  751. });
  752. }
  753. }
  754. };
  755. Slick.prototype.setFade = function() {
  756. var _ = this,
  757. targetLeft;
  758. _.$slides.each(function(index, element) {
  759. targetLeft = (_.slideWidth * index) * -1;
  760. $(element).css({
  761. position: 'relative',
  762. left: targetLeft,
  763. top: 0,
  764. zIndex: 800,
  765. opacity: 0
  766. });
  767. });
  768. _.$slides.eq(_.currentSlide).css({
  769. zIndex: 900,
  770. opacity: 1
  771. });
  772. };
  773. Slick.prototype.setPosition = function() {
  774. var _ = this;
  775. _.setValues();
  776. _.setDimensions();
  777. if (_.options.fade === false) {
  778. _.setCSS(_.getLeft(_.currentSlide));
  779. } else {
  780. _.setFade();
  781. }
  782. };
  783. Slick.prototype.setProps = function() {
  784. var _ = this;
  785. _.positionProp = _.options.vertical === true ? 'top' : 'left';
  786. if (_.positionProp === 'top') {
  787. _.$slider.addClass('slick-vertical');
  788. } else {
  789. _.$slider.removeClass('slick-vertical');
  790. }
  791. if (document.body.style.WebkitTransition !== undefined ||
  792. document.body.style.MozTransition !== undefined ||
  793. document.body.style.msTransition !== undefined) {
  794. _.cssTransitions = true;
  795. }
  796. if (document.body.style.MozTransform !== undefined) {
  797. _.animType = 'MozTransform';
  798. _.transformType = "-moz-transform";
  799. _.transitionType = 'MozTransition';
  800. }
  801. if (document.body.style.webkitTransform !== undefined) {
  802. _.animType = 'webkitTransform';
  803. _.transformType = "-webkit-transform";
  804. _.transitionType = 'webkitTransition';
  805. }
  806. if (document.body.style.msTransform !== undefined) {
  807. _.animType = 'transform';
  808. _.transformType = "transform";
  809. _.transitionType = 'transition';
  810. }
  811. _.transformsEnabled = (_.animType !== null);
  812. };
  813. Slick.prototype.setValues = function() {
  814. var _ = this;
  815. _.listWidth = _.$list.width();
  816. _.listHeight = _.$list.height();
  817. _.slideWidth = Math.ceil(_.listWidth / _.options
  818. .slidesToShow);
  819. };
  820. Slick.prototype.setSlideClasses = function(index) {
  821. var _ = this,
  822. centerOffset, allSlides, indexOffset;
  823. _.$slider.find('.slick-slide').removeClass('slick-active').removeClass('slick-center');
  824. allSlides = _.$slider.find('.slick-slide');
  825. if (_.options.centerMode === true) {
  826. centerOffset = Math.floor(_.options.slidesToShow / 2);
  827. if (index >= centerOffset && index <= (_.slideCount - 1) - centerOffset) {
  828. _.$slides.slice(index - centerOffset, index + centerOffset + 1).addClass('slick-active');
  829. } else {
  830. indexOffset = _.options.slidesToShow + index;
  831. allSlides.slice(indexOffset - centerOffset + 1, indexOffset + centerOffset + 2).addClass('slick-active');
  832. }
  833. if (index === 0) {
  834. allSlides.eq(allSlides.length - 1 - _.options.slidesToShow).addClass('slick-center');
  835. } else if (index === _.slideCount - 1) {
  836. allSlides.eq(_.options.slidesToShow).addClass('slick-center');
  837. }
  838. _.$slides.eq(index).addClass('slick-center');
  839. } else {
  840. if (index > 0 && index < (_.slideCount - _.options.slidesToShow)) {
  841. _.$slides.slice(index, index + _.options.slidesToShow).addClass('slick-active');
  842. } else {
  843. indexOffset = _.options.slidesToShow + index;
  844. allSlides.slice(indexOffset, indexOffset + _.options.slidesToShow).addClass('slick-active');
  845. }
  846. }
  847. if (_.options.lazyLoad === 'ondemand') {
  848. _.lazyLoad();
  849. }
  850. };
  851. Slick.prototype.setupInfinite = function() {
  852. var _ = this,
  853. i, slideIndex, infiniteCount;
  854. if (_.options.fade === true || _.options.vertical === true) {
  855. _.options.slidesToShow = 1;
  856. _.options.slidesToScroll = 1;
  857. _.options.centerMode = false;
  858. }
  859. if (_.options.infinite === true && _.options.fade === false) {
  860. slideIndex = null;
  861. if (_.slideCount > _.options.slidesToShow) {
  862. if (_.options.centerMode === true) {
  863. infiniteCount = _.options.slidesToShow + 1;
  864. } else {
  865. infiniteCount = _.options.slidesToShow;
  866. }
  867. for (i = _.slideCount; i > (_.slideCount -
  868. infiniteCount); i -= 1) {
  869. slideIndex = i - 1;
  870. $(_.$slides[slideIndex]).clone().attr('id', '').prependTo(
  871. _.$slideTrack).addClass('slick-cloned');
  872. }
  873. for (i = 0; i < infiniteCount; i += 1) {
  874. slideIndex = i;
  875. $(_.$slides[slideIndex]).clone().attr('id', '').appendTo(
  876. _.$slideTrack).addClass('slick-cloned');
  877. }
  878. _.$slideTrack.find('.slick-cloned').find('[id]').each(function() {
  879. $(this).attr('id', '');
  880. });
  881. }
  882. }
  883. };
  884. Slick.prototype.slideHandler = function(index) {
  885. var targetSlide, animSlide, slideLeft, unevenOffset, targetLeft = null,
  886. _ = this;
  887. if (_.animating === true) {
  888. return false;
  889. }
  890. targetSlide = index;
  891. targetLeft = _.getLeft(targetSlide);
  892. slideLeft = _.getLeft(_.currentSlide);
  893. unevenOffset = _.slideCount % _.options.slidesToScroll !== 0 ? _.options.slidesToScroll : 0;
  894. if (_.options.infinite === false && (index < 0 || index > (_.slideCount - _.options.slidesToShow + unevenOffset))) {
  895. targetSlide = _.currentSlide;
  896. _.animateSlide(slideLeft, function() {
  897. _.postSlide(targetSlide);
  898. });
  899. return false;
  900. }
  901. if (_.options.autoplay === true) {
  902. clearInterval(_.autoPlayTimer);
  903. }
  904. _.currentLeft = _.swipeLeft === null ? slideLeft : _.swipeLeft;
  905. if (targetSlide < 0) {
  906. if (_.slideCount % _.options.slidesToScroll !== 0) {
  907. animSlide = _.slideCount - (_.slideCount % _.options.slidesToScroll);
  908. } else {
  909. animSlide = _.slideCount - _.options.slidesToScroll;
  910. }
  911. } else if (targetSlide > (_.slideCount - 1)) {
  912. animSlide = 0;
  913. } else {
  914. animSlide = targetSlide;
  915. }
  916. _.animating = true;
  917. if (_.options.onBeforeChange !== null && index !== _.currentSlide) {
  918. _.options.onBeforeChange.call(this, _, _.currentSlide);
  919. }
  920. _.currentSlide = animSlide;
  921. _.updateDots();
  922. _.updateArrows();
  923. if (_.options.fade === true) {
  924. _.fadeSlide(animSlide, function() {
  925. _.postSlide(animSlide);
  926. });
  927. return false;
  928. }
  929. _.animateSlide(targetLeft, function() {
  930. _.postSlide(animSlide);
  931. });
  932. };
  933. Slick.prototype.startLoad = function() {
  934. var _ = this;
  935. if (_.options.arrows === true && _.slideCount > _.options.slidesToShow) {
  936. _.$prevArrow.hide();
  937. _.$nextArrow.hide();
  938. }
  939. if (_.options.dots === true && _.slideCount > _.options.slidesToShow) {
  940. _.$dots.hide();
  941. }
  942. _.$slider.addClass('slick-loading');
  943. };
  944. Slick.prototype.swipeDirection = function() {
  945. var xDist, yDist, r, swipeAngle, _ = this;
  946. xDist = _.touchObject.startX - _.touchObject.curX;
  947. yDist = _.touchObject.startY - _.touchObject.curY;
  948. r = Math.atan2(yDist, xDist);
  949. swipeAngle = Math.round(r * 180 / Math.PI);
  950. if (swipeAngle < 0) {
  951. swipeAngle = 360 - Math.abs(swipeAngle);
  952. }
  953. if ((swipeAngle <= 45) && (swipeAngle >= 0)) {
  954. return 'left';
  955. }
  956. if ((swipeAngle <= 360) && (swipeAngle >= 315)) {
  957. return 'left';
  958. }
  959. if ((swipeAngle >= 135) && (swipeAngle <= 225)) {
  960. return 'right';
  961. }
  962. return 'vertical';
  963. };
  964. Slick.prototype.swipeEnd = function(event) {
  965. var _ = this;
  966. _.$list.removeClass('dragging');
  967. if (_.touchObject.curX === undefined) {
  968. return false;
  969. }
  970. if (_.touchObject.swipeLength >= _.touchObject.minSwipe) {
  971. $(event.target).on('click.slick', function(event) {
  972. event.stopImmediatePropagation();
  973. event.stopPropagation();
  974. event.preventDefault();
  975. $(event.target).off('click.slick');
  976. });
  977. switch (_.swipeDirection()) {
  978. case 'left':
  979. _.slideHandler(_.currentSlide + _.options.slidesToScroll);
  980. _.touchObject = {};
  981. break;
  982. case 'right':
  983. _.slideHandler(_.currentSlide - _.options.slidesToScroll);
  984. _.touchObject = {};
  985. break;
  986. }
  987. } else {
  988. if(_.touchObject.startX !== _.touchObject.curX) {
  989. _.slideHandler(_.currentSlide);
  990. _.touchObject = {};
  991. }
  992. }
  993. };
  994. Slick.prototype.swipeHandler = function(event) {
  995. var _ = this;
  996. if ('ontouchend' in document && _.options.swipe === false) {
  997. return false;
  998. } else if (_.options.draggable === false && !event.originalEvent.touches) {
  999. return false;
  1000. }
  1001. _.touchObject.fingerCount = event.originalEvent && event.originalEvent.touches !== undefined ?
  1002. event.originalEvent.touches.length : 1;
  1003. _.touchObject.minSwipe = _.listWidth / _.options
  1004. .touchThreshold;
  1005. switch (event.data.action) {
  1006. case 'start':
  1007. _.swipeStart(event);
  1008. break;
  1009. case 'move':
  1010. _.swipeMove(event);
  1011. break;
  1012. case 'end':
  1013. _.swipeEnd(event);
  1014. break;
  1015. }
  1016. };
  1017. Slick.prototype.swipeMove = function(event) {
  1018. var _ = this,
  1019. curLeft, swipeDirection, positionOffset, touches;
  1020. touches = event.originalEvent !== undefined ? event.originalEvent.touches : null;
  1021. curLeft = _.getLeft(_.currentSlide);
  1022. if (!_.$list.hasClass('dragging') || touches && touches.length !== 1) {
  1023. return false;
  1024. }
  1025. _.touchObject.curX = touches !== undefined ? touches[0].pageX : event.clientX;
  1026. _.touchObject.curY = touches !== undefined ? touches[0].pageY : event.clientY;
  1027. _.touchObject.swipeLength = Math.round(Math.sqrt(
  1028. Math.pow(_.touchObject.curX - _.touchObject.startX, 2)));
  1029. swipeDirection = _.swipeDirection();
  1030. if (swipeDirection === 'vertical') {
  1031. return false;
  1032. }
  1033. if (event.originalEvent !== undefined) {
  1034. event.preventDefault();
  1035. }
  1036. positionOffset = _.touchObject.curX > _.touchObject.startX ? 1 : -1;
  1037. if (_.options.vertical === false) {
  1038. _.swipeLeft = curLeft + _.touchObject.swipeLength * positionOffset;
  1039. } else {
  1040. _.swipeLeft = curLeft + (_.touchObject
  1041. .swipeLength * (_.listHeight / _.listWidth)) * positionOffset;
  1042. }
  1043. if (_.options.fade === true || _.options.touchMove === false) {
  1044. return false;
  1045. }
  1046. if (_.animating === true) {
  1047. _.swipeLeft = null;
  1048. return false;
  1049. }
  1050. _.setCSS(_.swipeLeft);
  1051. };
  1052. Slick.prototype.swipeStart = function(event) {
  1053. var _ = this,
  1054. touches;
  1055. if (_.touchObject.fingerCount !== 1 || _.slideCount <= _.options.slidesToShow) {
  1056. _.touchObject = {};
  1057. return false;
  1058. }
  1059. if (event.originalEvent !== undefined && event.originalEvent.touches !== undefined) {
  1060. touches = event.originalEvent.touches[0];
  1061. }
  1062. _.touchObject.startX = _.touchObject.curX = touches !== undefined ? touches.pageX : event.clientX;
  1063. _.touchObject.startY = _.touchObject.curY = touches !== undefined ? touches.pageY : event.clientY;
  1064. _.$list.addClass('dragging');
  1065. };
  1066. Slick.prototype.unfilterSlides = function() {
  1067. var _ = this;
  1068. if (_.$slidesCache !== null) {
  1069. _.unload();
  1070. _.$slideTrack.children(this.options.slide).remove();
  1071. _.$slidesCache.appendTo(_.$slideTrack);
  1072. _.reinit();
  1073. }
  1074. };
  1075. Slick.prototype.unload = function() {
  1076. var _ = this;
  1077. $('.slick-cloned', _.$slider).remove();
  1078. if (_.$dots) {
  1079. _.$dots.remove();
  1080. }
  1081. if (_.$prevArrow) {
  1082. _.$prevArrow.remove();
  1083. _.$nextArrow.remove();
  1084. }
  1085. _.$slides.removeClass(
  1086. 'slick-slide slick-active slick-visible').removeAttr('style');
  1087. };
  1088. Slick.prototype.updateArrows = function() {
  1089. var _ = this;
  1090. if (_.options.arrows === true && _.options.infinite !==
  1091. true && _.slideCount > _.options.slidesToShow) {
  1092. _.$prevArrow.removeClass('slick-disabled');
  1093. _.$nextArrow.removeClass('slick-disabled');
  1094. if (_.currentSlide === 0) {
  1095. _.$prevArrow.addClass('slick-disabled');
  1096. _.$nextArrow.removeClass('slick-disabled');
  1097. } else if (_.currentSlide >= _.slideCount - _.options.slidesToShow) {
  1098. _.$nextArrow.addClass('slick-disabled');
  1099. _.$prevArrow.removeClass('slick-disabled');
  1100. }
  1101. }
  1102. };
  1103. Slick.prototype.updateDots = function() {
  1104. var _ = this;
  1105. if (_.$dots !== null) {
  1106. _.$dots.find('li').removeClass('slick-active');
  1107. _.$dots.find('li').eq(_.currentSlide / _.options.slidesToScroll).addClass(
  1108. 'slick-active');
  1109. }
  1110. };
  1111. $.fn.slick = function(options) {
  1112. var _ = this;
  1113. return _.each(function(index, element) {
  1114. element.slick = new Slick(element, options);
  1115. });
  1116. };
  1117. $.fn.slickAdd = function(slide, slideIndex, addBefore) {
  1118. var _ = this;
  1119. return _.each(function(index, element) {
  1120. element.slick.addSlide(slide, slideIndex, addBefore);
  1121. });
  1122. };
  1123. $.fn.slickFilter = function(filter) {
  1124. var _ = this;
  1125. return _.each(function(index, element) {
  1126. element.slick.filterSlides(filter);
  1127. });
  1128. };
  1129. $.fn.slickGoTo = function(slide) {
  1130. var _ = this;
  1131. return _.each(function(index, element) {
  1132. element.slick.slideHandler(slide);
  1133. });
  1134. };
  1135. $.fn.slickNext = function() {
  1136. var _ = this;
  1137. return _.each(function(index, element) {
  1138. element.slick.changeSlide({
  1139. data: {
  1140. message: 'next'
  1141. }
  1142. });
  1143. });
  1144. };
  1145. $.fn.slickPause = function() {
  1146. var _ = this;
  1147. return _.each(function(index, element) {
  1148. element.slick.autoPlayClear();
  1149. element.slick.paused = true;
  1150. });
  1151. };
  1152. $.fn.slickPlay = function() {
  1153. var _ = this;
  1154. return _.each(function(index, element) {
  1155. element.slick.paused = false;
  1156. element.slick.autoPlay();
  1157. });
  1158. };
  1159. $.fn.slickPrev = function() {
  1160. var _ = this;
  1161. return _.each(function(index, element) {
  1162. element.slick.changeSlide({
  1163. data: {
  1164. message: 'previous'
  1165. }
  1166. });
  1167. });
  1168. };
  1169. $.fn.slickRemove = function(slideIndex, removeBefore) {
  1170. var _ = this;
  1171. return _.each(function(index, element) {
  1172. element.slick.removeSlide(slideIndex, removeBefore);
  1173. });
  1174. };
  1175. $.fn.slickSetOption = function(option, value, refresh) {
  1176. var _ = this;
  1177. return _.each(function(index, element) {
  1178. element.slick.options[option] = value;
  1179. if (refresh === true) {
  1180. element.slick.unload();
  1181. element.slick.reinit();
  1182. }
  1183. });
  1184. };
  1185. $.fn.slickUnfilter = function() {
  1186. var _ = this;
  1187. return _.each(function(index, element) {
  1188. element.slick.unfilterSlides();
  1189. });
  1190. };
  1191. $.fn.unslick = function() {
  1192. var _ = this;
  1193. return _.each(function(index, element) {
  1194. element.slick.destroy();
  1195. });
  1196. };
  1197. }));