(function(factory) {
'use strict';
if (typeof define === 'function' && define.amd) {
define(['jquery'], factory);
} else {
factory(jquery);
}
} (function($) {
'use strict';
var slick = window.slick || {};
slick = (function() {
var instanceuid = 0;
function slick(element, settings) {
var _ = this,
responsivesettings, breakpoint;
_.defaults = {
accessibility: true,
arrows: true,
autoplay: false,
autoplayspeed: 3000,
centermode: false,
centerpadding: '50px',
cssease: 'ease',
custompaging: function(slider, i) {
return '';
},
dots: false,
draggable: true,
easing: 'linear',
fade: false,
infinite: true,
lazyload: 'ondemand',
onbeforechange: null,
onafterchange: null,
oninit: null,
onreinit: null,
pauseonhover: true,
responsive: null,
slide: 'div',
slidestoshow: 1,
slidestoscroll: 1,
speed: 300,
swipe: true,
touchmove: true,
touchthreshold: 5,
vertical: false
};
_.initials = {
animating: false,
autoplaytimer: null,
currentslide: 0,
currentleft: null,
direction: 1,
$dots: null,
listwidth: null,
listheight: null,
loadindex: 0,
$nextarrow: null,
$prevarrow: null,
slidecount: null,
slidewidth: null,
$slidetrack: null,
$slides: null,
sliding: false,
slideoffset: 0,
swipeleft: null,
$list: null,
touchobject: {},
transformsenabled: false
};
$.extend(_, _.initials);
_.activebreakpoint = null;
_.animtype = null;
_.animprop = null;
_.breakpoints = [];
_.breakpointsettings = [];
_.csstransitions = false;
_.paused = false;
_.positionprop = null;
_.$slider = $(element);
_.$slidescache = null;
_.transformtype = null;
_.transitiontype = null;
_.windowwidth = 0;
_.windowtimer = null;
_.options = $.extend({},
_.defaults, settings);
_.originalsettings = _.options;
responsivesettings = _.options.responsive || null;
if (responsivesettings && responsivesettings.length > -1) {
for (breakpoint in responsivesettings) {
if (responsivesettings.hasownproperty(breakpoint)) {
_.breakpoints.push(responsivesettings[breakpoint].breakpoint);
_.breakpointsettings[responsivesettings[breakpoint].breakpoint] = responsivesettings[breakpoint].settings;
}
}
_.breakpoints.sort(function(a, b) {
return b - a;
});
}
_.autoplay = $.proxy(_.autoplay, _);
_.autoplayclear = $.proxy(_.autoplayclear, _);
_.changeslide = $.proxy(_.changeslide, _);
_.setposition = $.proxy(_.setposition, _);
_.swipehandler = $.proxy(_.swipehandler, _);
_.draghandler = $.proxy(_.draghandler, _);
_.keyhandler = $.proxy(_.keyhandler, _);
_.autoplayiterator = $.proxy(_.autoplayiterator, _);
_.instanceuid = instanceuid++;
_.init();
}
return slick;
} ());
slick.prototype.addslide = function(markup, index, addbefore) {
var _ = this;
if (typeof(index) === 'boolean') {
addbefore = index;
index = null;
} else if (index < 0 || (index >= _.slidecount)) {
return false;
}
_.unload();
if (typeof(index) === 'number') {
if (index === 0 && _.$slides.length === 0) {
$(markup).appendto(_.$slidetrack);
} else if (addbefore) {
$(markup).insertbefore(_.$slides.eq(index));
} else {
$(markup).insertafter(_.$slides.eq(index));
}
} else {
if (addbefore === true) {
$(markup).prependto(_.$slidetrack);
} else {
$(markup).appendto(_.$slidetrack);
}
}
_.$slides = _.$slidetrack.children(this.options.slide);
_.$slidetrack.children(this.options.slide).remove();
_.$slidetrack.append(_.$slides);
_.$slidescache = _.$slides;
_.reinit();
};
slick.prototype.animateslide = function(targetleft, callback) {
var animprops = {},
_ = this;
if (_.transformsenabled === false) {
if (_.options.vertical === false) {
_.$slidetrack.animate({
left: targetleft
},
_.options.speed, _.options.easing, callback);
} else {
_.$slidetrack.animate({
top: targetleft
},
_.options.speed, _.options.easing, callback);
}
} else {
if (_.csstransitions === false) {
$({
animstart: _.currentleft
}).animate({
animstart: targetleft
},
{
duration: _.options.speed,
easing: _.options.easing,
step: function(now) {
if (_.options.vertical === false) {
animprops[_.animtype] = 'translate(' + now + 'px, 0px)';
_.$slidetrack.css(animprops);
} else {
animprops[_.animtype] = 'translate(0px,' + now + 'px)';
_.$slidetrack.css(animprops);
}
},
complete: function() {
if (callback) {
callback.call();
}
}
});
} else {
_.applytransition();
if (_.options.vertical === false) {
animprops[_.animtype] = 'translate3d(' + targetleft + 'px, 0px, 0px)';
} else {
animprops[_.animtype] = 'translate3d(0px,' + targetleft + 'px, 0px)';
}
_.$slidetrack.css(animprops);
if (callback) {
settimeout(function() {
_.disabletransition();
callback.call();
},
_.options.speed);
}
}
}
};
slick.prototype.applytransition = function(slide) {
var _ = this,
transition = {};
if (_.options.fade === false) {
transition[_.transitiontype] = _.transformtype + ' ' + _.options.speed + 'ms ' + _.options.cssease;
} else {
transition[_.transitiontype] = 'opacity ' + _.options.speed + 'ms ' + _.options.cssease;
}
if (_.options.fade === false) {
_.$slidetrack.css(transition);
} else {
_.$slides.eq(slide).css(transition);
}
};
slick.prototype.autoplay = function() {
var _ = this;
if (_.autoplaytimer) {
clearinterval(_.autoplaytimer);
}
if (_.slidecount > _.options.slidestoshow && _.paused !== true) {
_.autoplaytimer = setinterval(_.autoplayiterator, _.options.autoplayspeed);
}
};
slick.prototype.autoplayclear = function() {
var _ = this;
if (_.autoplaytimer) {
clearinterval(_.autoplaytimer);
}
};
slick.prototype.autoplayiterator = function() {
var _ = this;
if (_.options.infinite === false) {
if (_.direction === 1) {
if ((_.currentslide + 1) === _.slidecount - 1) {
_.direction = 0;
}
_.slidehandler(_.currentslide + _.options.slidestoscroll);
} else {
if ((_.currentslide - 1 === 0)) {
_.direction = 1;
}
_.slidehandler(_.currentslide - _.options.slidestoscroll);
}
} else {
_.slidehandler(_.currentslide + _.options.slidestoscroll);
}
};
slick.prototype.buildarrows = function() {
var _ = this;
if (_.options.arrows === true && _.slidecount > _.options.slidestoshow) {
_.$prevarrow = $('').appendto(_.$slider);
_.$nextarrow = $('').appendto(_.$slider);
if (_.options.infinite !== true) {
_.$prevarrow.addclass('slick-disabled');
}
}
};
slick.prototype.builddots = function() {
var _ = this,
i, dotstring;
if (_.options.dots === true && _.slidecount > _.options.slidestoshow) {
dotstring = '
';
for (i = 0; i <= _.getdotcount(); i += 1) {
dotstring += '- ' + _.options.custompaging.call(this, _, i) + '
';
}
dotstring += '
';
_.$dots = $(dotstring).appendto(_.$slider);
_.$dots.find('li').first().addclass('slick-active');
}
};
slick.prototype.buildout = function() {
var _ = this;
_.$slides = _.$slider.children(_.options.slide + ':not(.slick-cloned)').addclass('slick-slide');
_.slidecount = _.$slides.length;
_.$slidescache = _.$slides;
_.$slider.addclass('slick-slider');
_.$slidetrack = (_.slidecount === 0) ? $('').appendto(_.$slider) : _.$slides.wrapall('').parent();
_.$list = _.$slidetrack.wrap('').parent();
_.$slidetrack.css('opacity', 0);
if (_.options.centermode === true) {
_.options.infinite = true;
_.options.slidestoscroll = 1;
if (_.options.slidestoshow % 2 === 0) {
_.options.slidestoshow = 3;
}
}
$('img[data-lazy]', _.$slider).not('[src]').addclass('slick-loading');
_.setupinfinite();
_.buildarrows();
_.builddots();
if (_.options.accessibility === true) {
_.$list.prop('tabindex', 0);
}
_.setslideclasses(0);
if (_.options.draggable === true) {
_.$list.addclass('draggable');
}
};
slick.prototype.checkresponsive = function() {
var _ = this,
breakpoint, targetbreakpoint;
if (_.originalsettings.responsive && _.originalsettings.responsive.length > -1 && _.originalsettings.responsive !== null) {
targetbreakpoint = null;
for (breakpoint in _.breakpoints) {
if (_.breakpoints.hasownproperty(breakpoint)) {
if ($(window).width() < _.breakpoints[breakpoint]) {
targetbreakpoint = _.breakpoints[breakpoint];
}
}
}
if (targetbreakpoint !== null) {
if (_.activebreakpoint !== null) {
if (targetbreakpoint !== _.activebreakpoint) {
_.activebreakpoint = targetbreakpoint;
_.options = $.extend({},
_.defaults, _.breakpointsettings[targetbreakpoint]);
_.refresh();
}
} else {
_.activebreakpoint = targetbreakpoint;
_.options = $.extend({},
_.defaults, _.breakpointsettings[targetbreakpoint]);
_.refresh();
}
} else {
if (_.activebreakpoint !== null) {
_.activebreakpoint = null;
_.options = $.extend({},
_.defaults, _.originalsettings);
_.refresh();
}
}
}
};
slick.prototype.changeslide = function(event) {
var _ = this;
switch (event.data.message) {
case 'previous':
_.slidehandler(_.currentslide - _.options.slidestoscroll);
break;
case 'next':
_.slidehandler(_.currentslide + _.options.slidestoscroll);
break;
case 'index':
_.slidehandler($(event.target).parent().index() * _.options.slidestoscroll);
break;
default:
return false;
}
};
slick.prototype.destroy = function() {
var _ = this;
_.autoplayclear();
_.touchobject = {};
$('.slick-cloned', _.$slider).remove();
if (_.$dots) {
_.$dots.remove();
}
if (_.$prevarrow) {
_.$prevarrow.remove();
_.$nextarrow.remove();
}
_.$slides.unwrap().unwrap();
_.$slides.removeclass('slick-slide slick-active slick-visible').removeattr('style');
_.$slider.removeclass('slick-slider');
_.$slider.removeclass('slick-initialized');
_.$list.off('.slick');
$(window).off('.slick-' + _.instanceuid);
};
slick.prototype.disabletransition = function(slide) {
var _ = this,
transition = {};
transition[_.transitiontype] = "";
if (_.options.fade === false) {
_.$slidetrack.css(transition);
} else {
_.$slides.eq(slide).css(transition);
}
};
slick.prototype.fadeslide = function(slideindex, callback) {
var _ = this;
if (_.csstransitions === false) {
_.$slides.eq(slideindex).css({
zindex: 1000
});
_.$slides.eq(slideindex).animate({
opacity: 1
},
_.options.speed, _.options.easing, callback);
} else {
_.applytransition(slideindex);
_.$slides.eq(slideindex).css({
opacity: 1,
zindex: 1000
});
if (callback) {
settimeout(function() {
_.disabletransition(slideindex);
callback.call();
},
_.options.speed);
}
}
};
slick.prototype.filterslides = function(filter) {
var _ = this;
if (filter !== null) {
_.unload();
_.$slidetrack.children(this.options.slide).remove();
_.$slidescache.filter(filter).appendto(_.$slidetrack);
_.reinit();
}
};
slick.prototype.getcurrent = function() {
var _ = this;
return _.currentslide;
};
slick.prototype.getdotcount = function() {
var _ = this,
breaker = 0,
dotcounter = 0,
dotcount = 0,
dotlimit;
dotlimit = _.options.infinite === true ? _.slidecount + _.options.slidestoshow - _.options.slidestoscroll: _.slidecount;
while (breaker < dotlimit) {
dotcount++;
dotcounter += _.options.slidestoscroll;
breaker = dotcounter + _.options.slidestoshow;
}
return dotcount;
};
slick.prototype.getleft = function(slideindex) {
var _ = this,
targetleft;
_.slideoffset = 0;
if (_.options.infinite === true) {
if (_.slidecount > _.options.slidestoshow) {
_.slideoffset = (_.slidewidth * _.options.slidestoshow) * -1;
}
if (_.slidecount % _.options.slidestoscroll !== 0) {
if (slideindex + _.options.slidestoscroll > _.slidecount && _.slidecount > _.options.slidestoshow) {
_.slideoffset = ((_.slidecount % _.options.slidestoshow) * _.slidewidth) * -1;
}
}
} else {
if (_.slidecount % _.options.slidestoshow !== 0) {
if (slideindex + _.options.slidestoscroll > _.slidecount && _.slidecount > _.options.slidestoshow) {
_.slideoffset = ((_.slidecount % _.options.slidestoshow) * _.slidewidth);
}
}
}
if (_.options.centermode === true) {
_.slideoffset += _.slidewidth * math.floor(_.options.slidestoshow / 2) - _.slidewidth;
}
if (_.options.vertical === false) {
targetleft = ((slideindex * _.slidewidth) * -1) + _.slideoffset;
} else {
_.listheight = _.$list.height();
if (_.options.infinite === true) {
targetleft = ((slideindex * _.listheight) * -1) - _.listheight;
} else {
targetleft = ((slideindex * _.listheight) * -1);
}
}
return targetleft;
};
slick.prototype.init = function() {
var _ = this;
if (!$(_.$slider).hasclass('slick-initialized')) {
$(_.$slider).addclass('slick-initialized');
_.buildout();
_.setprops();
_.startload();
_.loadslider();
_.initializeevents();
_.checkresponsive();
}
if (_.options.oninit !== null) {
_.options.oninit.call(this, _);
}
};
slick.prototype.initarrowevents = function() {
var _ = this;
if (_.options.arrows === true && _.slidecount > _.options.slidestoshow) {
_.$prevarrow.on('click.slick', {
message: 'previous'
},
_.changeslide);
_.$nextarrow.on('click.slick', {
message: 'next'
},
_.changeslide);
}
};
slick.prototype.initdotevents = function() {
var _ = this;
if (_.options.dots === true && _.slidecount > _.options.slidestoshow) {
$('li', _.$dots).on('click.slick', {
message: 'index'
},
_.changeslide);
}
};
slick.prototype.initializeevents = function() {
var _ = this;
_.initarrowevents();
_.initdotevents();
_.$list.on('touchstart.slick mousedown.slick', {
action: 'start'
},
_.swipehandler);
_.$list.on('touchmove.slick mousemove.slick', {
action: 'move'
},
_.swipehandler);
_.$list.on('touchend.slick mouseup.slick', {
action: 'end'
},
_.swipehandler);
_.$list.on('touchcancel.slick mouseleave.slick', {
action: 'end'
},
_.swipehandler);
if (_.options.pauseonhover === true && _.options.autoplay === true) {
_.$list.on('mouseenter.slick', _.autoplayclear);
_.$list.on('mouseleave.slick', _.autoplay);
}
if (_.options.accessibility === true) {
_.$list.on('keydown.slick', _.keyhandler);
}
$(window).on('orientationchange.slick.slick-' + _.instanceuid,
function() {
_.checkresponsive();
_.setposition();
});
$(window).on('resize.slick.slick-' + _.instanceuid,
function() {
if ($(window).width !== _.windowwidth) {
cleartimeout(_.windowdelay);
_.windowdelay = window.settimeout(function() {
_.windowwidth = $(window).width();
_.checkresponsive();
_.setposition();
},
50);
}
});
$(window).on('load.slick.slick-' + _.instanceuid, _.setposition);
};
slick.prototype.initui = function() {
var _ = this;
if (_.options.arrows === true && _.slidecount > _.options.slidestoshow) {
_.$prevarrow.show();
_.$nextarrow.show();
}
if (_.options.dots === true && _.slidecount > _.options.slidestoshow) {
_.$dots.show();
}
if (_.options.autoplay === true) {
_.autoplay();
}
};
slick.prototype.keyhandler = function(event) {
var _ = this;
if (event.keycode === 37) {
_.changeslide({
data: {
message: 'previous'
}
});
} else if (event.keycode === 39) {
_.changeslide({
data: {
message: 'next'
}
});
}
};
slick.prototype.lazyload = function() {
var _ = this,
loadrange, clonerange, rangestart, rangeend;
if (_.options.centermode === true) {
rangestart = _.options.slidestoshow + _.currentslide - 1;
rangeend = rangestart + _.options.slidestoshow + 2;
} else {
rangestart = _.options.infinite ? _.options.slidestoshow + _.currentslide: _.currentslide;
rangeend = rangestart + _.options.slidestoshow;
}
loadrange = _.$slider.find('.slick-slide').slice(rangestart, rangeend);
$('img[data-lazy]', loadrange).not('[src]').each(function() {
$(this).css({
opacity: 0
}).attr('src', $(this).attr('data-lazy')).removeclass('slick-loading').load(function() {
$(this).animate({
opacity: 1
},
200);
});
});
if (_.currentslide >= _.slidecount - _.options.slidestoshow) {
clonerange = _.$slider.find('.slick-cloned').slice(0, _.options.slidestoshow);
$('img[data-lazy]', clonerange).not('[src]').each(function() {
$(this).css({
opacity: 0
}).attr('src', $(this).attr('data-lazy')).removeclass('slick-loading').load(function() {
$(this).animate({
opacity: 1
},
200);
});
});
} else if (_.currentslide === 0) {
clonerange = _.$slider.find('.slick-cloned').slice(_.options.slidestoshow * -1);
$('img[data-lazy]', clonerange).not('[src]').each(function() {
$(this).css({
opacity: 0
}).attr('src', $(this).attr('data-lazy')).removeclass('slick-loading').load(function() {
$(this).animate({
opacity: 1
},
200);
});
});
}
};
slick.prototype.loadslider = function() {
var _ = this;
_.setposition();
_.$slidetrack.css({
opacity: 1
});
_.$slider.removeclass('slick-loading');
_.initui();
if (_.options.lazyload === 'progressive') {
_.progressivelazyload();
}
};
slick.prototype.postslide = function(index) {
var _ = this;
if (_.options.onafterchange !== null) {
_.options.onafterchange.call(this, _, index);
}
_.animating = false;
_.setposition();
_.swipeleft = null;
if (_.options.autoplay === true && _.paused === false) {
_.autoplay();
}
_.setslideclasses(_.currentslide);
};
slick.prototype.progressivelazyload = function() {
var _ = this,
imgcount, targetimage;
imgcount = $('img[data-lazy]').not('[src]').length;
if (imgcount > 0) {
targetimage = $($('img[data-lazy]', _.$slider).not('[src]').get(0));
targetimage.attr('src', targetimage.attr('data-lazy')).removeclass('slick-loading').load(function() {
_.progressivelazyload();
});
}
};
slick.prototype.refresh = function() {
var _ = this;
_.destroy();
$.extend(_, _.initials);
_.init();
};
slick.prototype.reinit = function() {
var _ = this;
_.$slides = $(_.options.slide + ':not(.slick-cloned)', _.$slidetrack).addclass('slick-slide');
_.slidecount = _.$slides.length;
if (_.currentslide >= _.slidecount && _.currentslide !== 0) {
_.currentslide = _.currentslide - _.options.slidestoscroll;
}
_.setprops();
_.setupinfinite();
_.buildarrows();
_.updatearrows();
_.initarrowevents();
_.builddots();
_.updatedots();
_.initdotevents();
_.setslideclasses(0);
_.setposition();
if (_.options.onreinit !== null) {
_.options.onreinit.call(this, _);
}
};
slick.prototype.removeslide = function(index, removebefore) {
var _ = this;
if (typeof(index) === 'boolean') {
removebefore = index;
index = removebefore === true ? 0 : _.slidecount - 1;
} else {
index = removebefore === true ? --index: index;
}
if (_.slidecount < 1 || index < 0 || index > _.slidecount - 1) {
return false;
}
_.unload();
_.$slidetrack.children(this.options.slide).eq(index).remove();
_.$slides = _.$slidetrack.children(this.options.slide);
_.$slidetrack.children(this.options.slide).remove();
_.$slidetrack.append(_.$slides);
_.$slidescache = _.$slides;
_.reinit();
};
slick.prototype.setcss = function(position) {
var _ = this,
positionprops = {},
x, y;
x = _.positionprop == 'left' ? position + 'px': '0px';
y = _.positionprop == 'top' ? position + 'px': '0px';
positionprops[_.positionprop] = position;
if (_.transformsenabled === false) {
_.$slidetrack.css(positionprops);
} else {
positionprops = {};
if (_.csstransitions === false) {
positionprops[_.animtype] = 'translate(' + x + ', ' + y + ')';
_.$slidetrack.css(positionprops);
} else {
positionprops[_.animtype] = 'translate3d(' + x + ', ' + y + ', 0px)';
_.$slidetrack.css(positionprops);
}
}
};
slick.prototype.setdimensions = function() {
var _ = this;
if (_.options.centermode === true) {
_.$slidetrack.children('.slick-slide').width(_.slidewidth);
} else {
_.$slidetrack.children('.slick-slide').width(_.slidewidth);
}
if (_.options.vertical === false) {
_.$slidetrack.width(math.ceil((_.slidewidth * _.$slidetrack.children('.slick-slide').length)));
if (_.options.centermode === true) {
_.$list.css({
padding: ('0px ' + _.options.centerpadding)
});
}
} else {
_.$list.height(_.$slides.first().outerheight());
_.$slidetrack.height(math.ceil((_.listheight * _.$slidetrack.children('.slick-slide').length)));
if (_.options.centermode === true) {
_.$list.css({
padding: (_.options.centerpadding + ' 0px')
});
}
}
};
slick.prototype.setfade = function() {
var _ = this,
targetleft;
_.$slides.each(function(index, element) {
targetleft = (_.slidewidth * index) * -1;
$(element).css({
position: 'relative',
left: targetleft,
top: 0,
zindex: 800,
opacity: 0
});
});
_.$slides.eq(_.currentslide).css({
zindex: 900,
opacity: 1
});
};
slick.prototype.setposition = function() {
var _ = this;
_.setvalues();
_.setdimensions();
if (_.options.fade === false) {
_.setcss(_.getleft(_.currentslide));
} else {
_.setfade();
}
};
slick.prototype.setprops = function() {
var _ = this;
_.positionprop = _.options.vertical === true ? 'top': 'left';
if (_.positionprop === 'top') {
_.$slider.addclass('slick-vertical');
} else {
_.$slider.removeclass('slick-vertical');
}
if (document.body.style.webkittransition !== undefined || document.body.style.moztransition !== undefined || document.body.style.mstransition !== undefined) {
_.csstransitions = true;
}
if (document.body.style.moztransform !== undefined) {
_.animtype = 'moztransform';
_.transformtype = "-moz-transform";
_.transitiontype = 'moztransition';
}
if (document.body.style.webkittransform !== undefined) {
_.animtype = 'webkittransform';
_.transformtype = "-webkit-transform";
_.transitiontype = 'webkittransition';
}
if (document.body.style.mstransform !== undefined) {
_.animtype = 'transform';
_.transformtype = "transform";
_.transitiontype = 'transition';
}
_.transformsenabled = (_.animtype !== null);
};
slick.prototype.setvalues = function() {
var _ = this;
_.listwidth = _.$list.width();
_.listheight = _.$list.height();
_.slidewidth = math.ceil(_.listwidth / _.options.slidestoshow);
};
slick.prototype.setslideclasses = function(index) {
var _ = this,
centeroffset, allslides, indexoffset;
_.$slider.find('.slick-slide').removeclass('slick-active').removeclass('slick-center');
allslides = _.$slider.find('.slick-slide');
if (_.options.centermode === true) {
centeroffset = math.floor(_.options.slidestoshow / 2);
if (index >= centeroffset && index <= (_.slidecount - 1) - centeroffset) {
_.$slides.slice(index - centeroffset, index + centeroffset + 1).addclass('slick-active');
} else {
indexoffset = _.options.slidestoshow + index;
allslides.slice(indexoffset - centeroffset + 1, indexoffset + centeroffset + 2).addclass('slick-active');
}
if (index === 0) {
allslides.eq(allslides.length - 1 - _.options.slidestoshow).addclass('slick-center');
} else if (index === _.slidecount - 1) {
allslides.eq(_.options.slidestoshow).addclass('slick-center');
}
_.$slides.eq(index).addclass('slick-center');
} else {
if (index > 0 && index < (_.slidecount - _.options.slidestoshow)) {
_.$slides.slice(index, index + _.options.slidestoshow).addclass('slick-active');
} else {
indexoffset = _.options.slidestoshow + index;
allslides.slice(indexoffset, indexoffset + _.options.slidestoshow).addclass('slick-active');
}
}
if (_.options.lazyload === 'ondemand') {
_.lazyload();
}
};
slick.prototype.setupinfinite = function() {
var _ = this,
i, slideindex, infinitecount;
if (_.options.fade === true || _.options.vertical === true) {
_.options.slidestoshow = 1;
_.options.slidestoscroll = 1;
_.options.centermode = false;
}
if (_.options.infinite === true && _.options.fade === false) {
slideindex = null;
if (_.slidecount > _.options.slidestoshow) {
if (_.options.centermode === true) {
infinitecount = _.options.slidestoshow + 1;
} else {
infinitecount = _.options.slidestoshow;
}
for (i = _.slidecount; i > (_.slidecount - infinitecount); i -= 1) {
slideindex = i - 1;
$(_.$slides[slideindex]).clone().attr('id', '').prependto(_.$slidetrack).addclass('slick-cloned');
}
for (i = 0; i < infinitecount; i += 1) {
slideindex = i;
$(_.$slides[slideindex]).clone().attr('id', '').appendto(_.$slidetrack).addclass('slick-cloned');
}
_.$slidetrack.find('.slick-cloned').find('[id]').each(function() {
$(this).attr('id', '');
});
}
}
};
slick.prototype.slidehandler = function(index) {
var targetslide, animslide, slideleft, unevenoffset, targetleft = null,
_ = this;
if (_.animating === true) {
return false;
}
targetslide = index;
targetleft = _.getleft(targetslide);
slideleft = _.getleft(_.currentslide);
unevenoffset = _.slidecount % _.options.slidestoscroll !== 0 ? _.options.slidestoscroll: 0;
_.currentleft = _.swipeleft === null ? slideleft: _.swipeleft;
if (_.options.infinite === false && (index < 0 || index > (_.slidecount - _.options.slidestoshow + unevenoffset))) {
targetslide = _.currentslide;
_.animateslide(slideleft,
function() {
_.postslide(targetslide);
});
return false;
}
if (_.options.autoplay === true) {
clearinterval(_.autoplaytimer);
}
if (targetslide < 0) {
if (_.slidecount % _.options.slidestoscroll !== 0) {
animslide = _.slidecount - (_.slidecount % _.options.slidestoscroll);
} else {
animslide = _.slidecount - _.options.slidestoscroll;
}
} else if (targetslide > (_.slidecount - 1)) {
animslide = 0;
} else {
animslide = targetslide;
}
_.animating = true;
if (_.options.onbeforechange !== null && index !== _.currentslide) {
_.options.onbeforechange.call(this, _, _.currentslide, animslide);
}
_.currentslide = animslide;
_.updatedots();
_.updatearrows();
if (_.options.fade === true) {
_.fadeslide(animslide,
function() {
_.postslide(animslide);
});
return false;
}
_.animateslide(targetleft,
function() {
_.postslide(animslide);
});
};
slick.prototype.startload = function() {
var _ = this;
if (_.options.arrows === true && _.slidecount > _.options.slidestoshow) {
_.$prevarrow.hide();
_.$nextarrow.hide();
}
if (_.options.dots === true && _.slidecount > _.options.slidestoshow) {
_.$dots.hide();
}
_.$slider.addclass('slick-loading');
};
slick.prototype.swipedirection = function() {
var xdist, ydist, r, swipeangle, _ = this;
xdist = _.touchobject.startx - _.touchobject.curx;
ydist = _.touchobject.starty - _.touchobject.cury;
r = math.atan2(ydist, xdist);
swipeangle = math.round(r * 180 / math.pi);
if (swipeangle < 0) {
swipeangle = 360 - math.abs(swipeangle);
}
if ((swipeangle <= 45) && (swipeangle >= 0)) {
return 'left';
}
if ((swipeangle <= 360) && (swipeangle >= 315)) {
return 'left';
}
if ((swipeangle >= 135) && (swipeangle <= 225)) {
return 'right';
}
return 'vertical';
};
slick.prototype.swipeend = function(event) {
var _ = this;
_.$list.removeclass('dragging');
if (_.touchobject.curx === undefined) {
return false;
}
if (_.touchobject.swipelength >= _.touchobject.minswipe) {
$(event.target).on('click.slick',
function(event) {
event.stopimmediatepropagation();
event.stoppropagation();
event.preventdefault();
$(event.target).off('click.slick');
});
switch (_.swipedirection()) {
case 'left':
_.slidehandler(_.currentslide + _.options.slidestoscroll);
_.touchobject = {};
break;
case 'right':
_.slidehandler(_.currentslide - _.options.slidestoscroll);
_.touchobject = {};
break;
}
} else {
if (_.touchobject.startx !== _.touchobject.curx) {
_.slidehandler(_.currentslide);
_.touchobject = {};
}
}
};
slick.prototype.swipehandler = function(event) {
var _ = this;
if ('ontouchend' in document && _.options.swipe === false) {
return false;
} else if (_.options.draggable === false && !event.originalevent.touches) {
return false;
}
_.touchobject.fingercount = event.originalevent && event.originalevent.touches !== undefined ? event.originalevent.touches.length: 1;
_.touchobject.minswipe = _.listwidth / _.options.touchthreshold;
switch (event.data.action) {
case 'start':
_.swipestart(event);
break;
case 'move':
_.swipemove(event);
break;
case 'end':
_.swipeend(event);
break;
}
};
slick.prototype.swipemove = function(event) {
var _ = this,
curleft, swipedirection, positionoffset, touches;
touches = event.originalevent !== undefined ? event.originalevent.touches: null;
curleft = _.getleft(_.currentslide);
if (!_.$list.hasclass('dragging') || touches && touches.length !== 1) {
return false;
}
_.touchobject.curx = touches !== undefined ? touches[0].pagex: event.clientx;
_.touchobject.cury = touches !== undefined ? touches[0].pagey: event.clienty;
_.touchobject.swipelength = math.round(math.sqrt(math.pow(_.touchobject.curx - _.touchobject.startx, 2)));
swipedirection = _.swipedirection();
if (swipedirection === 'vertical') {
return;
}
if (event.originalevent !== undefined && _.touchobject.swipelength > 4) {
event.preventdefault();
}
positionoffset = _.touchobject.curx > _.touchobject.startx ? 1 : -1;
if (_.options.vertical === false) {
_.swipeleft = curleft + _.touchobject.swipelength * positionoffset;
} else {
_.swipeleft = curleft + (_.touchobject.swipelength * (_.listheight / _.listwidth)) * positionoffset;
}
if (_.options.fade === true || _.options.touchmove === false) {
return false;
}
if (_.animating === true) {
_.swipeleft = null;
return false;
}
_.setcss(_.swipeleft);
};
slick.prototype.swipestart = function(event) {
var _ = this,
touches;
if (_.touchobject.fingercount !== 1 || _.slidecount <= _.options.slidestoshow) {
_.touchobject = {};
return false;
}
if (event.originalevent !== undefined && event.originalevent.touches !== undefined) {
touches = event.originalevent.touches[0];
}
_.touchobject.startx = _.touchobject.curx = touches !== undefined ? touches.pagex: event.clientx;
_.touchobject.starty = _.touchobject.cury = touches !== undefined ? touches.pagey: event.clienty;
_.$list.addclass('dragging');
};
slick.prototype.unfilterslides = function() {
var _ = this;
if (_.$slidescache !== null) {
_.unload();
_.$slidetrack.children(this.options.slide).remove();
_.$slidescache.appendto(_.$slidetrack);
_.reinit();
}
};
slick.prototype.unload = function() {
var _ = this;
$('.slick-cloned', _.$slider).remove();
if (_.$dots) {
_.$dots.remove();
}
if (_.$prevarrow) {
_.$prevarrow.remove();
_.$nextarrow.remove();
}
_.$slides.removeclass('slick-slide slick-active slick-visible').removeattr('style');
};
slick.prototype.updatearrows = function() {
var _ = this;
if (_.options.arrows === true && _.options.infinite !== true && _.slidecount > _.options.slidestoshow) {
_.$prevarrow.removeclass('slick-disabled');
_.$nextarrow.removeclass('slick-disabled');
if (_.currentslide === 0) {
_.$prevarrow.addclass('slick-disabled');
_.$nextarrow.removeclass('slick-disabled');
} else if (_.currentslide >= _.slidecount - _.options.slidestoshow) {
_.$nextarrow.addclass('slick-disabled');
_.$prevarrow.removeclass('slick-disabled');
}
}
};
slick.prototype.updatedots = function() {
var _ = this;
if (_.$dots !== null) {
_.$dots.find('li').removeclass('slick-active');
_.$dots.find('li').eq(_.currentslide / _.options.slidestoscroll).addclass('slick-active');
}
};
$.fn.slick = function(options) {
var _ = this;
return _.each(function(index, element) {
element.slick = new slick(element, options);
});
};
$.fn.slickadd = function(slide, slideindex, addbefore) {
var _ = this;
return _.each(function(index, element) {
element.slick.addslide(slide, slideindex, addbefore);
});
};
$.fn.slickcurrentslide = function() {
var _ = this;
return _.get(0).slick.getcurrent();
};
$.fn.slickfilter = function(filter) {
var _ = this;
return _.each(function(index, element) {
element.slick.filterslides(filter);
});
};
$.fn.slickgoto = function(slide) {
var _ = this;
return _.each(function(index, element) {
element.slick.slidehandler(slide);
});
};
$.fn.slicknext = function() {
var _ = this;
return _.each(function(index, element) {
element.slick.changeslide({
data: {
message: 'next'
}
});
});
};
$.fn.slickpause = function() {
var _ = this;
return _.each(function(index, element) {
element.slick.autoplayclear();
element.slick.paused = true;
});
};
$.fn.slickplay = function() {
var _ = this;
return _.each(function(index, element) {
element.slick.paused = false;
element.slick.autoplay();
});
};
$.fn.slickprev = function() {
var _ = this;
return _.each(function(index, element) {
element.slick.changeslide({
data: {
message: 'previous'
}
});
});
};
$.fn.slickremove = function(slideindex, removebefore) {
var _ = this;
return _.each(function(index, element) {
element.slick.removeslide(slideindex, removebefore);
});
};
$.fn.slicksetoption = function(option, value, refresh) {
var _ = this;
return _.each(function(index, element) {
element.slick.options[option] = value;
if (refresh === true) {
element.slick.unload();
element.slick.reinit();
}
});
};
$.fn.slickunfilter = function() {
var _ = this;
return _.each(function(index, element) {
element.slick.unfilterslides();
});
};
$.fn.unslick = function() {
var _ = this;
return _.each(function(index, element) {
element.slick.destroy();
});
};
}));