slick.js 86 KB

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