IM12345_Web demo - 代码源于 商丘市12345项目

slick.js 45KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691
  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)';
  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.getCurrent = function() {
  452. var _ = this;
  453. return _.currentSlide;
  454. };
  455. Slick.prototype.getDotCount = function() {
  456. var _ = this,
  457. breaker = 0,
  458. dotCounter = 0,
  459. dotCount = 0,
  460. dotLimit;
  461. dotLimit = _.options.infinite === true ? _.slideCount + _.options.slidesToShow - _.options.slidesToScroll : _.slideCount;
  462. while (breaker < dotLimit) {
  463. dotCount++;
  464. dotCounter += _.options.slidesToScroll;
  465. breaker = dotCounter + _.options.slidesToShow;
  466. }
  467. return dotCount;
  468. };
  469. Slick.prototype.getLeft = function(slideIndex) {
  470. var _ = this,
  471. targetLeft;
  472. _.slideOffset = 0;
  473. if (_.options.infinite === true) {
  474. if (_.slideCount > _.options.slidesToShow) {
  475. _.slideOffset = (_.slideWidth * _.options.slidesToShow) * -1;
  476. }
  477. if (_.slideCount % _.options.slidesToScroll !== 0) {
  478. if (slideIndex + _.options.slidesToScroll > _.slideCount && _.slideCount > _.options.slidesToShow) {
  479. _.slideOffset = ((_.slideCount % _.options.slidesToShow) * _.slideWidth) * -1;
  480. }
  481. }
  482. } else {
  483. if (_.slideCount % _.options.slidesToShow !== 0) {
  484. if (slideIndex + _.options.slidesToScroll > _.slideCount && _.slideCount > _.options.slidesToShow) {
  485. _.slideOffset = ((_.slideCount % _.options.slidesToShow) * _.slideWidth);
  486. }
  487. }
  488. }
  489. if (_.options.centerMode === true) {
  490. _.slideOffset += _.slideWidth * Math.floor(_.options.slidesToShow / 2) - _.slideWidth;
  491. }
  492. if (_.options.vertical === false) {
  493. targetLeft = ((slideIndex * _.slideWidth) * -1) + _.slideOffset;
  494. } else {
  495. _.listHeight = _.$list.height();
  496. if (_.options.infinite === true) {
  497. targetLeft = ((slideIndex * _.listHeight) * -1) - _.listHeight;
  498. } else {
  499. targetLeft = ((slideIndex * _.listHeight) * -1);
  500. }
  501. }
  502. return targetLeft;
  503. };
  504. Slick.prototype.init = function() {
  505. var _ = this;
  506. if (!$(_.$slider).hasClass('slick-initialized')) {
  507. $(_.$slider).addClass('slick-initialized');
  508. _.buildOut();
  509. _.setProps();
  510. _.startLoad();
  511. _.loadSlider();
  512. _.initializeEvents();
  513. _.checkResponsive();
  514. }
  515. if (_.options.onInit !== null) {
  516. _.options.onInit.call(this, _);
  517. }
  518. };
  519. Slick.prototype.initArrowEvents = function() {
  520. var _ = this;
  521. if (_.options.arrows === true && _.slideCount > _.options.slidesToShow) {
  522. _.$prevArrow.on('click.slick', {
  523. message: 'previous'
  524. }, _.changeSlide);
  525. _.$nextArrow.on('click.slick', {
  526. message: 'next'
  527. }, _.changeSlide);
  528. }
  529. };
  530. Slick.prototype.initDotEvents = function() {
  531. var _ = this;
  532. if (_.options.dots === true && _.slideCount > _.options.slidesToShow) {
  533. $('li', _.$dots).on('click.slick', {
  534. message: 'index'
  535. }, _.changeSlide);
  536. }
  537. };
  538. Slick.prototype.initializeEvents = function() {
  539. var _ = this;
  540. _.initArrowEvents();
  541. _.initDotEvents();
  542. _.$list.on('touchstart.slick mousedown.slick', {
  543. action: 'start'
  544. }, _.swipeHandler);
  545. _.$list.on('touchmove.slick mousemove.slick', {
  546. action: 'move'
  547. }, _.swipeHandler);
  548. _.$list.on('touchend.slick mouseup.slick', {
  549. action: 'end'
  550. }, _.swipeHandler);
  551. _.$list.on('touchcancel.slick mouseleave.slick', {
  552. action: 'end'
  553. }, _.swipeHandler);
  554. if (_.options.pauseOnHover === true && _.options.autoplay === true) {
  555. _.$list.on('mouseenter.slick', _.autoPlayClear);
  556. _.$list.on('mouseleave.slick', _.autoPlay);
  557. }
  558. if(_.options.accessibility === true) {
  559. _.$list.on('keydown.slick', _.keyHandler);
  560. }
  561. $(window).on('orientationchange.slick.slick-' + _.instanceUid, function() {
  562. _.checkResponsive();
  563. _.setPosition();
  564. });
  565. $(window).on('resize.slick.slick-' + _.instanceUid, function() {
  566. if ($(window).width !== _.windowWidth) {
  567. clearTimeout(_.windowDelay);
  568. _.windowDelay = window.setTimeout(function() {
  569. _.windowWidth = $(window).width();
  570. _.checkResponsive();
  571. _.setPosition();
  572. }, 50);
  573. }
  574. });
  575. $(window).on('load.slick.slick-' + _.instanceUid, _.setPosition);
  576. };
  577. Slick.prototype.initUI = function() {
  578. var _ = this;
  579. if (_.options.arrows === true && _.slideCount > _.options.slidesToShow) {
  580. _.$prevArrow.show();
  581. _.$nextArrow.show();
  582. }
  583. if (_.options.dots === true && _.slideCount > _.options.slidesToShow) {
  584. _.$dots.show();
  585. }
  586. if (_.options.autoplay === true) {
  587. _.autoPlay();
  588. }
  589. };
  590. Slick.prototype.keyHandler = function(event) {
  591. var _ = this;
  592. if (event.keyCode === 37) {
  593. _.changeSlide({
  594. data: {
  595. message: 'previous'
  596. }
  597. });
  598. } else if (event.keyCode === 39) {
  599. _.changeSlide({
  600. data: {
  601. message: 'next'
  602. }
  603. });
  604. }
  605. };
  606. Slick.prototype.lazyLoad = function() {
  607. var _ = this,
  608. loadRange, cloneRange, rangeStart, rangeEnd;
  609. if (_.options.centerMode === true) {
  610. rangeStart = _.options.slidesToShow + _.currentSlide - 1;
  611. rangeEnd = rangeStart + _.options.slidesToShow + 2;
  612. } else {
  613. rangeStart = _.options.infinite ? _.options.slidesToShow + _.currentSlide : _.currentSlide;
  614. rangeEnd = rangeStart + _.options.slidesToShow;
  615. }
  616. loadRange = _.$slider.find('.slick-slide').slice(rangeStart, rangeEnd);
  617. $('img[data-lazy]', loadRange).not('[src]').each(function() {
  618. $(this).css({opacity: 0}).attr('src', $(this).attr('data-lazy')).removeClass('slick-loading').load(function(){
  619. $(this).animate({ opacity: 1 }, 200);
  620. });
  621. });
  622. if (_.currentSlide >= _.slideCount - _.options.slidesToShow) {
  623. cloneRange = _.$slider.find('.slick-cloned').slice(0, _.options.slidesToShow);
  624. $('img[data-lazy]', cloneRange).not('[src]').each(function() {
  625. $(this).css({opacity: 0}).attr('src', $(this).attr('data-lazy')).removeClass('slick-loading').load(function(){
  626. $(this).animate({ opacity: 1 }, 200);
  627. });
  628. });
  629. } else if (_.currentSlide === 0) {
  630. cloneRange = _.$slider.find('.slick-cloned').slice(_.options.slidesToShow * -1);
  631. $('img[data-lazy]', cloneRange).not('[src]').each(function() {
  632. $(this).css({opacity: 0}).attr('src', $(this).attr('data-lazy')).removeClass('slick-loading').load(function(){
  633. $(this).animate({ opacity: 1 }, 200);
  634. });
  635. });
  636. }
  637. };
  638. Slick.prototype.loadSlider = function() {
  639. var _ = this;
  640. _.setPosition();
  641. _.$slideTrack.css({
  642. opacity: 1
  643. });
  644. _.$slider.removeClass('slick-loading');
  645. _.initUI();
  646. if (_.options.lazyLoad === 'progressive') {
  647. _.progressiveLazyLoad();
  648. }
  649. };
  650. Slick.prototype.postSlide = function(index) {
  651. var _ = this;
  652. if (_.options.onAfterChange !== null) {
  653. _.options.onAfterChange.call(this, _, index);
  654. }
  655. _.animating = false;
  656. _.setPosition();
  657. _.swipeLeft = null;
  658. if (_.options.autoplay === true && _.paused === false) {
  659. _.autoPlay();
  660. }
  661. _.setSlideClasses(_.currentSlide);
  662. };
  663. Slick.prototype.progressiveLazyLoad = function() {
  664. var _ = this,
  665. imgCount, targetImage;
  666. imgCount = $('img[data-lazy]').not('[src]').length;
  667. if (imgCount > 0) {
  668. targetImage = $($('img[data-lazy]', _.$slider).not('[src]').get(0));
  669. targetImage.attr('src', targetImage.attr('data-lazy')).removeClass('slick-loading').load(function() {
  670. _.progressiveLazyLoad();
  671. });
  672. }
  673. };
  674. Slick.prototype.refresh = function() {
  675. var _ = this;
  676. _.destroy();
  677. $.extend(_, _.initials);
  678. _.init();
  679. };
  680. Slick.prototype.reinit = function() {
  681. var _ = this;
  682. _.$slides = $(_.options.slide +
  683. ':not(.slick-cloned)', _.$slideTrack).addClass(
  684. 'slick-slide');
  685. _.slideCount = _.$slides.length;
  686. if (_.currentSlide >= _.slideCount && _.currentSlide !== 0) {
  687. _.currentSlide = _.currentSlide - _.options.slidesToScroll;
  688. }
  689. _.setProps();
  690. _.setupInfinite();
  691. _.buildArrows();
  692. _.updateArrows();
  693. _.initArrowEvents();
  694. _.buildDots();
  695. _.updateDots();
  696. _.initDotEvents();
  697. _.setSlideClasses(0);
  698. _.setPosition();
  699. if (_.options.onReInit !== null) {
  700. _.options.onReInit.call(this, _);
  701. }
  702. };
  703. Slick.prototype.removeSlide = function(index, removeBefore) {
  704. var _ = this;
  705. if (typeof(index) === 'boolean') {
  706. removeBefore = index;
  707. index = removeBefore === true ? 0 : _.slideCount - 1;
  708. } else {
  709. index = removeBefore === true ? --index : index;
  710. }
  711. if (_.slideCount < 1 || index < 0 || index > _.slideCount - 1) {
  712. return false;
  713. }
  714. _.unload();
  715. _.$slideTrack.children(this.options.slide).eq(index).remove();
  716. _.$slides = _.$slideTrack.children(this.options.slide);
  717. _.$slideTrack.children(this.options.slide).remove();
  718. _.$slideTrack.append(_.$slides);
  719. _.$slidesCache = _.$slides;
  720. _.reinit();
  721. };
  722. Slick.prototype.setCSS = function(position) {
  723. var _ = this,
  724. positionProps = {}, x, y;
  725. x = _.positionProp == 'left' ? position + 'px' : '0px';
  726. y = _.positionProp == 'top' ? position + 'px' : '0px';
  727. positionProps[_.positionProp] = position;
  728. if (_.transformsEnabled === false) {
  729. _.$slideTrack.css(positionProps);
  730. } else {
  731. positionProps = {};
  732. if (_.cssTransitions === false) {
  733. positionProps[_.animType] = 'translate(' + x + ', ' + y + ')';
  734. _.$slideTrack.css(positionProps);
  735. } else {
  736. positionProps[_.animType] = 'translate3d(' + x + ', ' + y + ', 0px)';
  737. _.$slideTrack.css(positionProps);
  738. }
  739. }
  740. };
  741. Slick.prototype.setDimensions = function() {
  742. var _ = this;
  743. if (_.options.centerMode === true) {
  744. // _.$slideTrack.children('.slick-slide').width(_.slideWidth);
  745. _.$slideTrack.children('.slick-slide').width('252px');
  746. } else {
  747. // _.$slideTrack.children('.slick-slide').width(_.slideWidth);
  748. _.$slideTrack.children('.slick-slide').width('252px');
  749. }
  750. if (_.options.vertical === false) {
  751. _.$slideTrack.width(Math.ceil((_.slideWidth * _
  752. .$slideTrack.children('.slick-slide').length)));
  753. if (_.options.centerMode === true) {
  754. _.$list.css({
  755. padding: ('0px ' + _.options.centerPadding)
  756. });
  757. }
  758. } else {
  759. _.$list.height(_.$slides.first().outerHeight());
  760. _.$slideTrack.height(Math.ceil((_.listHeight * _
  761. .$slideTrack.children('.slick-slide').length)));
  762. if (_.options.centerMode === true) {
  763. _.$list.css({
  764. padding: (_.options.centerPadding + ' 0px')
  765. });
  766. }
  767. }
  768. };
  769. Slick.prototype.setFade = function() {
  770. var _ = this,
  771. targetLeft;
  772. _.$slides.each(function(index, element) {
  773. targetLeft = (_.slideWidth * index) * -1;
  774. $(element).css({
  775. position: 'relative',
  776. left: targetLeft,
  777. top: 0,
  778. zIndex: 800,
  779. opacity: 0
  780. });
  781. });
  782. _.$slides.eq(_.currentSlide).css({
  783. zIndex: 900,
  784. opacity: 1
  785. });
  786. };
  787. Slick.prototype.setPosition = function() {
  788. var _ = this;
  789. _.setValues();
  790. _.setDimensions();
  791. if (_.options.fade === false) {
  792. _.setCSS(_.getLeft(_.currentSlide));
  793. } else {
  794. _.setFade();
  795. }
  796. };
  797. Slick.prototype.setProps = function() {
  798. var _ = this;
  799. _.positionProp = _.options.vertical === true ? 'top' : 'left';
  800. if (_.positionProp === 'top') {
  801. _.$slider.addClass('slick-vertical');
  802. } else {
  803. _.$slider.removeClass('slick-vertical');
  804. }
  805. if (document.body.style.WebkitTransition !== undefined ||
  806. document.body.style.MozTransition !== undefined ||
  807. document.body.style.msTransition !== undefined) {
  808. _.cssTransitions = true;
  809. }
  810. if (document.body.style.MozTransform !== undefined) {
  811. _.animType = 'MozTransform';
  812. _.transformType = "-moz-transform";
  813. _.transitionType = 'MozTransition';
  814. }
  815. if (document.body.style.webkitTransform !== undefined) {
  816. _.animType = 'webkitTransform';
  817. _.transformType = "-webkit-transform";
  818. _.transitionType = 'webkitTransition';
  819. }
  820. if (document.body.style.msTransform !== undefined) {
  821. _.animType = 'transform';
  822. _.transformType = "transform";
  823. _.transitionType = 'transition';
  824. }
  825. _.transformsEnabled = (_.animType !== null);
  826. };
  827. Slick.prototype.setValues = function() {
  828. var _ = this;
  829. _.listWidth = _.$list.width();
  830. _.listHeight = _.$list.height();
  831. _.slideWidth = Math.ceil(_.listWidth / _.options
  832. .slidesToShow);
  833. };
  834. Slick.prototype.setSlideClasses = function(index) {
  835. var _ = this,
  836. centerOffset, allSlides, indexOffset;
  837. _.$slider.find('.slick-slide').removeClass('slick-active').removeClass('slick-center');
  838. allSlides = _.$slider.find('.slick-slide');
  839. if (_.options.centerMode === true) {
  840. centerOffset = Math.floor(_.options.slidesToShow / 2);
  841. if (index >= centerOffset && index <= (_.slideCount - 1) - centerOffset) {
  842. _.$slides.slice(index - centerOffset, index + centerOffset + 1).addClass('slick-active');
  843. } else {
  844. indexOffset = _.options.slidesToShow + index;
  845. allSlides.slice(indexOffset - centerOffset + 1, indexOffset + centerOffset + 2).addClass('slick-active');
  846. }
  847. if (index === 0) {
  848. allSlides.eq(allSlides.length - 1 - _.options.slidesToShow).addClass('slick-center');
  849. } else if (index === _.slideCount - 1) {
  850. allSlides.eq(_.options.slidesToShow).addClass('slick-center');
  851. }
  852. _.$slides.eq(index).addClass('slick-center');
  853. } else {
  854. if (index > 0 && index < (_.slideCount - _.options.slidesToShow)) {
  855. _.$slides.slice(index, index + _.options.slidesToShow).addClass('slick-active');
  856. } else {
  857. indexOffset = _.options.slidesToShow + index;
  858. allSlides.slice(indexOffset, indexOffset + _.options.slidesToShow).addClass('slick-active');
  859. }
  860. }
  861. if (_.options.lazyLoad === 'ondemand') {
  862. _.lazyLoad();
  863. }
  864. };
  865. Slick.prototype.setupInfinite = function() {
  866. var _ = this,
  867. i, slideIndex, infiniteCount;
  868. if (_.options.fade === true || _.options.vertical === true) {
  869. _.options.slidesToShow = 1;
  870. _.options.slidesToScroll = 1;
  871. _.options.centerMode = false;
  872. }
  873. if (_.options.infinite === true && _.options.fade === false) {
  874. slideIndex = null;
  875. if (_.slideCount > _.options.slidesToShow) {
  876. if (_.options.centerMode === true) {
  877. infiniteCount = _.options.slidesToShow + 1;
  878. } else {
  879. infiniteCount = _.options.slidesToShow;
  880. }
  881. for (i = _.slideCount; i > (_.slideCount -
  882. infiniteCount); i -= 1) {
  883. slideIndex = i - 1;
  884. $(_.$slides[slideIndex]).clone().attr('id', '').prependTo(
  885. _.$slideTrack).addClass('slick-cloned');
  886. }
  887. for (i = 0; i < infiniteCount; i += 1) {
  888. slideIndex = i;
  889. $(_.$slides[slideIndex]).clone().attr('id', '').appendTo(
  890. _.$slideTrack).addClass('slick-cloned');
  891. }
  892. _.$slideTrack.find('.slick-cloned').find('[id]').each(function() {
  893. $(this).attr('id', '');
  894. });
  895. }
  896. }
  897. };
  898. Slick.prototype.slideHandler = function(index) {
  899. var targetSlide, animSlide, slideLeft, unevenOffset, targetLeft = null,
  900. _ = this;
  901. if (_.animating === true) {
  902. return false;
  903. }
  904. targetSlide = index;
  905. targetLeft = _.getLeft(targetSlide);
  906. slideLeft = _.getLeft(_.currentSlide);
  907. unevenOffset = _.slideCount % _.options.slidesToScroll !== 0 ? _.options.slidesToScroll : 0;
  908. _.currentLeft = _.swipeLeft === null ? slideLeft : _.swipeLeft;
  909. if (_.options.infinite === false && (index < 0 || index > (_.slideCount - _.options.slidesToShow + unevenOffset))) {
  910. targetSlide = _.currentSlide;
  911. _.animateSlide(slideLeft, function() {
  912. _.postSlide(targetSlide);
  913. });
  914. return false;
  915. }
  916. if (_.options.autoplay === true) {
  917. clearInterval(_.autoPlayTimer);
  918. }
  919. if (targetSlide < 0) {
  920. if (_.slideCount % _.options.slidesToScroll !== 0) {
  921. animSlide = _.slideCount - (_.slideCount % _.options.slidesToScroll);
  922. } else {
  923. animSlide = _.slideCount - _.options.slidesToScroll;
  924. }
  925. } else if (targetSlide > (_.slideCount - 1)) {
  926. animSlide = 0;
  927. } else {
  928. animSlide = targetSlide;
  929. }
  930. _.animating = true;
  931. if (_.options.onBeforeChange !== null && index !== _.currentSlide) {
  932. _.options.onBeforeChange.call(this, _, _.currentSlide, animSlide);
  933. }
  934. _.currentSlide = animSlide;
  935. _.updateDots();
  936. _.updateArrows();
  937. if (_.options.fade === true) {
  938. _.fadeSlide(animSlide, function() {
  939. _.postSlide(animSlide);
  940. });
  941. return false;
  942. }
  943. _.animateSlide(targetLeft, function() {
  944. _.postSlide(animSlide);
  945. });
  946. };
  947. Slick.prototype.startLoad = function() {
  948. var _ = this;
  949. if (_.options.arrows === true && _.slideCount > _.options.slidesToShow) {
  950. _.$prevArrow.hide();
  951. _.$nextArrow.hide();
  952. }
  953. if (_.options.dots === true && _.slideCount > _.options.slidesToShow) {
  954. _.$dots.hide();
  955. }
  956. _.$slider.addClass('slick-loading');
  957. };
  958. Slick.prototype.swipeDirection = function() {
  959. var xDist, yDist, r, swipeAngle, _ = this;
  960. xDist = _.touchObject.startX - _.touchObject.curX;
  961. yDist = _.touchObject.startY - _.touchObject.curY;
  962. r = Math.atan2(yDist, xDist);
  963. swipeAngle = Math.round(r * 180 / Math.PI);
  964. if (swipeAngle < 0) {
  965. swipeAngle = 360 - Math.abs(swipeAngle);
  966. }
  967. if ((swipeAngle <= 45) && (swipeAngle >= 0)) {
  968. return 'left';
  969. }
  970. if ((swipeAngle <= 360) && (swipeAngle >= 315)) {
  971. return 'left';
  972. }
  973. if ((swipeAngle >= 135) && (swipeAngle <= 225)) {
  974. return 'right';
  975. }
  976. return 'vertical';
  977. };
  978. Slick.prototype.swipeEnd = function(event) {
  979. var _ = this;
  980. _.$list.removeClass('dragging');
  981. if (_.touchObject.curX === undefined) {
  982. return false;
  983. }
  984. if (_.touchObject.swipeLength >= _.touchObject.minSwipe) {
  985. $(event.target).on('click.slick', function(event) {
  986. event.stopImmediatePropagation();
  987. event.stopPropagation();
  988. event.preventDefault();
  989. $(event.target).off('click.slick');
  990. });
  991. switch (_.swipeDirection()) {
  992. case 'left':
  993. _.slideHandler(_.currentSlide + _.options.slidesToScroll);
  994. _.touchObject = {};
  995. break;
  996. case 'right':
  997. _.slideHandler(_.currentSlide - _.options.slidesToScroll);
  998. _.touchObject = {};
  999. break;
  1000. }
  1001. } else {
  1002. if(_.touchObject.startX !== _.touchObject.curX) {
  1003. _.slideHandler(_.currentSlide);
  1004. _.touchObject = {};
  1005. }
  1006. }
  1007. };
  1008. Slick.prototype.swipeHandler = function(event) {
  1009. var _ = this;
  1010. if ('ontouchend' in document && _.options.swipe === false) {
  1011. return false;
  1012. } else if (_.options.draggable === false && !event.originalEvent.touches) {
  1013. return false;
  1014. }
  1015. _.touchObject.fingerCount = event.originalEvent && event.originalEvent.touches !== undefined ?
  1016. event.originalEvent.touches.length : 1;
  1017. _.touchObject.minSwipe = _.listWidth / _.options
  1018. .touchThreshold;
  1019. switch (event.data.action) {
  1020. case 'start':
  1021. _.swipeStart(event);
  1022. break;
  1023. case 'move':
  1024. _.swipeMove(event);
  1025. break;
  1026. case 'end':
  1027. _.swipeEnd(event);
  1028. break;
  1029. }
  1030. };
  1031. Slick.prototype.swipeMove = function(event) {
  1032. var _ = this,
  1033. curLeft, swipeDirection, positionOffset, touches;
  1034. touches = event.originalEvent !== undefined ? event.originalEvent.touches : null;
  1035. curLeft = _.getLeft(_.currentSlide);
  1036. if (!_.$list.hasClass('dragging') || touches && touches.length !== 1) {
  1037. return false;
  1038. }
  1039. _.touchObject.curX = touches !== undefined ? touches[0].pageX : event.clientX;
  1040. _.touchObject.curY = touches !== undefined ? touches[0].pageY : event.clientY;
  1041. _.touchObject.swipeLength = Math.round(Math.sqrt(
  1042. Math.pow(_.touchObject.curX - _.touchObject.startX, 2)));
  1043. swipeDirection = _.swipeDirection();
  1044. if (swipeDirection === 'vertical') {
  1045. return;
  1046. }
  1047. if (event.originalEvent !== undefined && _.touchObject.swipeLength > 4) {
  1048. event.preventDefault();
  1049. }
  1050. positionOffset = _.touchObject.curX > _.touchObject.startX ? 1 : -1;
  1051. if (_.options.vertical === false) {
  1052. _.swipeLeft = curLeft + _.touchObject.swipeLength * positionOffset;
  1053. } else {
  1054. _.swipeLeft = curLeft + (_.touchObject
  1055. .swipeLength * (_.listHeight / _.listWidth)) * positionOffset;
  1056. }
  1057. if (_.options.fade === true || _.options.touchMove === false) {
  1058. return false;
  1059. }
  1060. if (_.animating === true) {
  1061. _.swipeLeft = null;
  1062. return false;
  1063. }
  1064. _.setCSS(_.swipeLeft);
  1065. };
  1066. Slick.prototype.swipeStart = function(event) {
  1067. var _ = this,
  1068. touches;
  1069. if (_.touchObject.fingerCount !== 1 || _.slideCount <= _.options.slidesToShow) {
  1070. _.touchObject = {};
  1071. return false;
  1072. }
  1073. if (event.originalEvent !== undefined && event.originalEvent.touches !== undefined) {
  1074. touches = event.originalEvent.touches[0];
  1075. }
  1076. _.touchObject.startX = _.touchObject.curX = touches !== undefined ? touches.pageX : event.clientX;
  1077. _.touchObject.startY = _.touchObject.curY = touches !== undefined ? touches.pageY : event.clientY;
  1078. _.$list.addClass('dragging');
  1079. };
  1080. Slick.prototype.unfilterSlides = function() {
  1081. var _ = this;
  1082. if (_.$slidesCache !== null) {
  1083. _.unload();
  1084. _.$slideTrack.children(this.options.slide).remove();
  1085. _.$slidesCache.appendTo(_.$slideTrack);
  1086. _.reinit();
  1087. }
  1088. };
  1089. Slick.prototype.unload = function() {
  1090. var _ = this;
  1091. $('.slick-cloned', _.$slider).remove();
  1092. if (_.$dots) {
  1093. _.$dots.remove();
  1094. }
  1095. if (_.$prevArrow) {
  1096. _.$prevArrow.remove();
  1097. _.$nextArrow.remove();
  1098. }
  1099. _.$slides.removeClass(
  1100. 'slick-slide slick-active slick-visible').removeAttr('style');
  1101. };
  1102. Slick.prototype.updateArrows = function() {
  1103. var _ = this;
  1104. if (_.options.arrows === true && _.options.infinite !==
  1105. true && _.slideCount > _.options.slidesToShow) {
  1106. _.$prevArrow.removeClass('slick-disabled');
  1107. _.$nextArrow.removeClass('slick-disabled');
  1108. if (_.currentSlide === 0) {
  1109. _.$prevArrow.addClass('slick-disabled');
  1110. _.$nextArrow.removeClass('slick-disabled');
  1111. } else if (_.currentSlide >= _.slideCount - _.options.slidesToShow) {
  1112. _.$nextArrow.addClass('slick-disabled');
  1113. _.$prevArrow.removeClass('slick-disabled');
  1114. }
  1115. }
  1116. };
  1117. Slick.prototype.updateDots = function() {
  1118. var _ = this;
  1119. if (_.$dots !== null) {
  1120. _.$dots.find('li').removeClass('slick-active');
  1121. _.$dots.find('li').eq(_.currentSlide / _.options.slidesToScroll).addClass(
  1122. 'slick-active');
  1123. }
  1124. };
  1125. $.fn.slick = function(options) {
  1126. var _ = this;
  1127. return _.each(function(index, element) {
  1128. element.slick = new Slick(element, options);
  1129. });
  1130. };
  1131. $.fn.slickAdd = function(slide, slideIndex, addBefore) {
  1132. var _ = this;
  1133. return _.each(function(index, element) {
  1134. element.slick.addSlide(slide, slideIndex, addBefore);
  1135. });
  1136. };
  1137. $.fn.slickCurrentSlide = function() {
  1138. var _ = this;
  1139. return _.get(0).slick.getCurrent();
  1140. };
  1141. $.fn.slickFilter = function(filter) {
  1142. var _ = this;
  1143. return _.each(function(index, element) {
  1144. element.slick.filterSlides(filter);
  1145. });
  1146. };
  1147. $.fn.slickGoTo = function(slide) {
  1148. var _ = this;
  1149. return _.each(function(index, element) {
  1150. element.slick.slideHandler(slide);
  1151. });
  1152. };
  1153. $.fn.slickNext = function() {
  1154. var _ = this;
  1155. return _.each(function(index, element) {
  1156. element.slick.changeSlide({
  1157. data: {
  1158. message: 'next'
  1159. }
  1160. });
  1161. });
  1162. };
  1163. $.fn.slickPause = function() {
  1164. var _ = this;
  1165. return _.each(function(index, element) {
  1166. element.slick.autoPlayClear();
  1167. element.slick.paused = true;
  1168. });
  1169. };
  1170. $.fn.slickPlay = function() {
  1171. var _ = this;
  1172. return _.each(function(index, element) {
  1173. element.slick.paused = false;
  1174. element.slick.autoPlay();
  1175. });
  1176. };
  1177. $.fn.slickPrev = function() {
  1178. var _ = this;
  1179. return _.each(function(index, element) {
  1180. element.slick.changeSlide({
  1181. data: {
  1182. message: 'previous'
  1183. }
  1184. });
  1185. });
  1186. };
  1187. $.fn.slickRemove = function(slideIndex, removeBefore) {
  1188. var _ = this;
  1189. return _.each(function(index, element) {
  1190. element.slick.removeSlide(slideIndex, removeBefore);
  1191. });
  1192. };
  1193. $.fn.slickSetOption = function(option, value, refresh) {
  1194. var _ = this;
  1195. return _.each(function(index, element) {
  1196. element.slick.options[option] = value;
  1197. if (refresh === true) {
  1198. element.slick.unload();
  1199. element.slick.reinit();
  1200. }
  1201. });
  1202. };
  1203. $.fn.slickUnfilter = function() {
  1204. var _ = this;
  1205. return _.each(function(index, element) {
  1206. element.slick.unfilterSlides();
  1207. });
  1208. };
  1209. $.fn.unslick = function() {
  1210. var _ = this;
  1211. return _.each(function(index, element) {
  1212. element.slick.destroy();
  1213. });
  1214. };
  1215. }));