/*! modernizr 3.1.0 (custom build) | mit * * http://modernizr.com/download/?-backgroundsize-bgsizecover-borderradius-boxshadow-cssanimations-csstransforms-csstransforms3d-csstransitions-touchevents !*/ !function(e,n,t){function s(e){var n=c.classname,t=modernizr._config.classprefix||"";if(s&&(n=n.baseval),modernizr._config.enablejsclass){var s=new regexp("(^|\\s)"+t+"no-js(\\s|$)");n=n.replace(s,"$1"+t+"js$2")}modernizr._config.enableclasses&&(n+=" "+t+e.join(" "+t),s?c.classname.baseval=n:c.classname=n)}function o(e,n){return typeof e===n}function r(){var e,n,t,s,r,i,a;for(var f in x){if(e=[],n=x[f],n.name&&(e.push(n.name.tolowercase()),n.options&&n.options.aliases&&n.options.aliases.length))for(t=0;tp;p++)if(v=e[p],h=j.style[v],u(v,"-")&&(v=l(v)),j.style[v]!==t){if(r||o(s,"undefined"))return a(),"pfx"==n?v:!0;try{j.style[v]=s}catch(y){}if(j.style[v]!=h)return a(),"pfx"==n?v:!0}return a(),!1}function h(e,n,t,s,r){var i=e.charat(0).touppercase()+e.slice(1),a=(e+" "+p.join(i+" ")+i).split(" ");return o(n,"string")||o(n,"undefined")?v(a,n,s,r):(a=(e+" "+e.join(i+" ")+i).split(" "),p(a,n,t))}function g(e,n,s){return h(e,t,t,n,s)}var y=[],x=[],b={_version:"3.1.0",_config:{classprefix:"",enableclasses:!0,enablejsclass:!0,useprefixes:!0},_q:[],on:function(e,n){var t=this;settimeout(function(){n(t[e])},0)},addtest:function(e,n,t){x.push({name:e,fn:n,options:t})},addasynctest:function(e){x.push({name:null,fn:e})}},modernizr=function(){};modernizr.prototype=b,modernizr=new modernizr;var c=n.documentelement,s="svg"===c.nodename.tolowercase(),w=b._config.useprefixes?" -webkit- -moz- -o- -ms- ".split(" "):[];b._prefixes=w;var _="css"in e&&"supports"in e.css,t="supportscss"in e;modernizr.addtest("supports",_||t);var z=b.teststyles=f;modernizr.addtest("touchevents",function(){var t;if("ontouchstart"in e||e.documenttouch&&n instanceof documenttouch)t=!0;else{var s=["@media (",w.join("touch-enabled),("),"heartz",")","{#modernizr{top:9px;position:absolute}}"].join("");z(s,function(e){t=9===e.offsettop})}return t});var k="moz o ms webkit",p=b._config.useprefixes?k.split(" "):[];b._cssomprefixes=p;var e=b._config.useprefixes?k.tolowercase().split(" "):[];b._domprefixes=e;var n={elem:i("modernizr")};modernizr._q.push(function(){delete n.elem});var j={style:n.elem.style};modernizr._q.unshift(function(){delete j.style}),b.testallprops=h,b.testallprops=g,modernizr.addtest("cssanimations",g("animationname","a",!0)),modernizr.addtest("backgroundsize",g("backgroundsize","100%",!0)),modernizr.addtest("csstransitions",g("transition","all",!0)),modernizr.addtest("csstransforms3d",function(){var e=!!g("perspective","1px",!0),n=modernizr._config.useprefixes;if(e&&(!n||"webkitperspective"in c.style)){var t;modernizr.supports?t="@supports (perspective: 1px)":(t="@media (transform-3d)",n&&(t+=",(-webkit-transform-3d)")),t+="{#modernizr{left:9px;position:absolute;height:5px;margin:0;padding:0;border:0}}",z(t,function(n){e=9===n.offsetleft&&5===n.offsetheight})}return e}),modernizr.addtest("bgsizecover",g("backgroundsize","cover")),modernizr.addtest("borderradius",g("borderradius","0px",!0)),modernizr.addtest("boxshadow",g("boxshadow","1px 1px",!0)),modernizr.addtest("csstransforms",function(){return-1===navigator.useragent.indexof("android 2.")&&g("transform","scale(1)",!0)}),r(),s(y),delete b.addtest,delete b.addasynctest;for(var a=0;a-1&&(g=!0),i)for(var a=i.split(/[,\n] ?/),b=a.length;b--;)if(document.url.indexof(a[b])>-1){d("mousewheel",v),g=!0;break}}function r(){if(document.body){var a=document.body,b=document.documentelement,c=window.innerheight,d=a.scrollheight;if(o=document.compatmode.indexof("css")>=0?b:a,n=a,q(),l=!0,top!=self)j=!0;else if(d>c&&(a.offsetheight<=c||b.offsetheight<=c)&&(o.style.height="auto",o.offsetheight<=c)){var e=document.createelement("div");e.style.clear="both",a.appendchild(e)}if(document.url.indexof("mail.google.com")>-1){var f=document.createelement("style");f.innerhtml=".iu { visibility: hidden }",(document.getelementsbytagname("head")[0]||b).appendchild(f)}m||(a.style.backgroundattachment="scroll"),g&&d("keydown",w)}}function u(c,e,f,g){if(g||(g=1e3),f(e,f),s.push({x:e,y:f,lastx:0>e?.99:-.99,lasty:0>f?.99:-.99,start:+new date}),!t){var h=function(){for(var i=+new date,j=0,k=0,l=0;l=b,p=o?1:n/b;d&&(p=h(p));var q=m.x*p-m.lastx>>0,r=m.y*p-m.lasty>>0;j+=q,k+=r,m.lastx+=q,m.lasty+=r,o&&(s.splice(l,1),l--)}if(e){var u=c.scrollleft;c.scrollleft+=j,j&&c.scrollleft===u&&(e=0)}if(f){var v=c.scrolltop;c.scrolltop+=k,k&&c.scrolltop===v&&(f=0)}e||f||(s=[]),s.length?settimeout(h,g/a+1):t=!1};settimeout(h,0),t=!0}}function v(a){l||r();var b=a.target,d=b(b);if(!d||a.defaultprevented||e(n,"embed")||e(b,"embed")&&/\.pdf/i.test(b.src))return!0;var e=a.wheeldeltax||0,f=a.wheeldeltay||0;e||f||(f=a.wheeldelta||0),math.abs(e)>1.2&&(e*=c/120),math.abs(f)>1.2&&(f*=c/120),u(d,-e,-f),a.preventdefault()}function w(a){var b=a.target,c=a.ctrlkey||a.altkey||a.metakey;if(/input|textarea|embed/i.test(b.nodename)||b.iscontenteditable||a.defaultprevented||c)return!0;if(e(b,"button")&&a.keycode===p.spacebar)return!0;var d,e=0,f=0,g=b(n),i=g.clientheight;switch(g==document.body&&(i=window.innerheight),a.keycode){case p.up:f=-h;break;case p.down:f=h;break;case p.spacebar:d=a.shiftkey?1:-1,f=.9*-d*i;break;case p.pageup:f=.9*-i;break;case p.pagedown:f=.9*i;break;case p.home:f=-g.scrolltop;break;case p.end:var j=g.scrollheight-g.scrolltop-i;f=j>0?j+10:0;break;case p.left:e=-h;break;case p.right:e=h;break;default:return!0}u(g,e,f),a.preventdefault()}function x(a){n=a.target}function a(a,b){for(var c=a.length;c--;)y[z(a[c])]=b;return b}function b(a){var b=[],c=o.scrollheight;do{var d=y[z(a)];if(d)return a(b,d);if(b.push(a),c===a.scrollheight){if(!j||o.clientheight+100?1:-1,b=b>0?1:-1,(k.x!==a||k.y!==b)&&(k.x=a,k.y=b,s=[])}function g(a){var b,c,d;return a*=e,1>a?b=a-(1-math.exp(-a)):(c=math.exp(-1),a-=1,d=1-math.exp(-a),b=c+d*(1-c)),b*f}function h(a){return a>=1?1:0>=a?0:(1==f&&(f/=g(1)),g(a))}var n,o,a=150,b=600,c=150,d=!0,e=5,f=1,g=!1,h=50,i="",j=!1,k={x:0,y:0},l=!1,m=!0,p={left:37,up:38,right:39,down:40,spacebar:32,pageup:33,pagedown:34,end:35,home:36},s=[],t=!1,y={};setinterval(function(){y={}},1e4);var z=function(){var a=0;return function(b){return b.uniqueid||(b.uniqueid=a++)}}();/chrome/.test(navigator.useragent.tolowercase())&&(c("mousedown",x),c("mousewheel",v),c("keydown",w),c("load",r))})}(jquery); */ /* _ _ _ _ ___| (_) ___| | __ (_)___ / __| | |/ __| |/ / | / __| \__ \ | | (__| < _ | \__ \ |___/_|_|\___|_|\_(_)/ |___/ |__/ version: 1.5.9 author: ken wheeler website: http://kenwheeler.github.io docs: http://kenwheeler.github.io/slick repo: http://github.com/kenwheeler/slick issues: http://github.com/kenwheeler/slick/issues */ /* global window, document, define, jquery, setinterval, clearinterval */ (function(factory) { 'use strict'; if (typeof define === 'function' && define.amd) { define(['jquery'], factory); } else if (typeof exports !== 'undefined') { module.exports = factory(require('jquery')); } else { factory(jquery); } }(function($) { 'use strict'; var slick = window.slick || {}; slick = (function() { var instanceuid = 0; function slick(element, settings) { var _ = this, datasettings; _.defaults = { accessibility: true, adaptiveheight: false, appendarrows: $(element), appenddots: $(element), arrows: true, asnavfor: null, prevarrow: '', nextarrow: '', autoplay: false, autoplayspeed: 3000, centermode: false, centerpadding: '50px', cssease: 'ease', custompaging: function(slider, i) { return $('').text(i + 1); }, dots: false, dotsclass: 'slick-dots', draggable: true, easing: 'linear', edgefriction: 0.35, fade: false, focusonselect: false, infinite: true, initialslide: 0, lazyload: 'ondemand', mobilefirst: false, pauseonhover: true, pauseonfocus: true, pauseondotshover: false, respondto: 'window', responsive: null, rows: 1, rtl: false, slide: '', slidesperrow: 1, slidestoshow: 1, slidestoscroll: 1, speed: 500, swipe: true, swipetoslide: false, touchmove: true, touchthreshold: 5, usecss: true, usetransform: true, variablewidth: false, vertical: false, verticalswiping: false, waitforanimate: true, zindex: 1000 }; _.initials = { animating: false, dragging: false, autoplaytimer: null, currentdirection: 0, currentleft: null, currentslide: 0, 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, unslicked: false }; $.extend(_, _.initials); _.activebreakpoint = null; _.animtype = null; _.animprop = null; _.breakpoints = []; _.breakpointsettings = []; _.csstransitions = false; _.focussed = false; _.interrupted = false; _.hidden = 'hidden'; _.paused = true; _.positionprop = null; _.respondto = null; _.rowcount = 1; _.shouldclick = true; _.$slider = $(element); _.$slidescache = null; _.transformtype = null; _.transitiontype = null; _.visibilitychange = 'visibilitychange'; _.windowwidth = 0; _.windowtimer = null; datasettings = $(element).data('slick') || {}; _.options = $.extend({}, _.defaults, settings, datasettings); _.currentslide = _.options.initialslide; _.originalsettings = _.options; if (typeof document.mozhidden !== 'undefined') { _.hidden = 'mozhidden'; _.visibilitychange = 'mozvisibilitychange'; } else if (typeof document.webkithidden !== 'undefined') { _.hidden = 'webkithidden'; _.visibilitychange = 'webkitvisibilitychange'; } _.autoplay = $.proxy(_.autoplay, _); _.autoplayclear = $.proxy(_.autoplayclear, _); _.autoplayiterator = $.proxy(_.autoplayiterator, _); _.changeslide = $.proxy(_.changeslide, _); _.clickhandler = $.proxy(_.clickhandler, _); _.selecthandler = $.proxy(_.selecthandler, _); _.setposition = $.proxy(_.setposition, _); _.swipehandler = $.proxy(_.swipehandler, _); _.draghandler = $.proxy(_.draghandler, _); _.keyhandler = $.proxy(_.keyhandler, _); _.instanceuid = instanceuid++; // a simple way to check for html strings // strict html recognition (must start with <) // extracted from jquery v1.11 source _.htmlexpr = /^(?:\s*(<[\w\w]+>)[^>]*)$/; _.registerbreakpoints(); _.init(true); } return slick; }()); slick.prototype.activateada = function() { var _ = this; _.$slidetrack.find('.slick-active').attr({ 'aria-hidden': 'false' }).find('a, input, button, select').attr({ 'tabindex': '0' }); }; slick.prototype.addslide = slick.prototype.slickadd = 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).detach(); _.$slidetrack.append(_.$slides); _.$slides.each(function(index, element) { $(element).attr('data-slick-index', index); }); _.$slidescache = _.$slides; _.reinit(); }; slick.prototype.animateheight = function() { var _ = this; if (_.options.slidestoshow === 1 && _.options.adaptiveheight === true && _.options.vertical === false) { var targetheight = _.$slides.eq(_.currentslide).outerheight(true); _.$list.animate({ height: targetheight }, _.options.speed); } }; slick.prototype.animateslide = function(targetleft, callback) { var animprops = {}, _ = this; _.animateheight(); if (_.options.rtl === true && _.options.vertical === false) { targetleft = -targetleft; } 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) { if (_.options.rtl === true) { _.currentleft = -(_.currentleft); } $({ animstart: _.currentleft }).animate({ animstart: targetleft }, { duration: _.options.speed, easing: _.options.easing, step: function(now) { now = math.ceil(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(); targetleft = math.ceil(targetleft); 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.getnavtarget = function() { var _ = this, asnavfor = _.options.asnavfor; if ( asnavfor && asnavfor !== null ) { asnavfor = $(asnavfor).not(_.$slider); } return asnavfor; }; slick.prototype.asnavfor = function(index) { var _ = this, asnavfor = _.getnavtarget(); if ( asnavfor !== null && typeof asnavfor === 'object' ) { asnavfor.each(function() { var target = $(this).slick('getslick'); if(!target.unslicked) { target.slidehandler(index, true); } }); } }; 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; _.autoplayclear(); if ( _.slidecount > _.options.slidestoshow ) { _.autoplaytimer = setinterval( _.autoplayiterator, _.options.autoplayspeed ); } }; slick.prototype.autoplayclear = function() { var _ = this; if (_.autoplaytimer) { clearinterval(_.autoplaytimer); } }; slick.prototype.autoplayiterator = function() { var _ = this, slideto = _.currentslide + _.options.slidestoscroll; if ( !_.paused && !_.interrupted && !_.focussed ) { if ( _.options.infinite === false ) { if ( _.direction === 1 && ( _.currentslide + 1 ) === ( _.slidecount - 1 )) { _.direction = 0; } else if ( _.direction === 0 ) { slideto = _.currentslide - _.options.slidestoscroll; if ( _.currentslide - 1 === 0 ) { _.direction = 1; } } } _.slidehandler( slideto ); } }; slick.prototype.buildarrows = function() { var _ = this; if (_.options.arrows === true ) { _.$prevarrow = $(_.options.prevarrow).addclass('slick-arrow'); _.$nextarrow = $(_.options.nextarrow).addclass('slick-arrow'); if( _.slidecount > _.options.slidestoshow ) { _.$prevarrow.removeclass('slick-hidden').removeattr('aria-hidden tabindex'); _.$nextarrow.removeclass('slick-hidden').removeattr('aria-hidden tabindex'); if (_.htmlexpr.test(_.options.prevarrow)) { _.$prevarrow.prependto(_.options.appendarrows); } if (_.htmlexpr.test(_.options.nextarrow)) { _.$nextarrow.appendto(_.options.appendarrows); } if (_.options.infinite !== true) { _.$prevarrow .addclass('slick-disabled') .attr('aria-disabled', 'true'); } } else { _.$prevarrow.add( _.$nextarrow ) .addclass('slick-hidden') .attr({ 'aria-disabled': 'true', 'tabindex': '-1' }); } } }; slick.prototype.builddots = function() { var _ = this, i, dot; if (_.options.dots === true && _.slidecount > _.options.slidestoshow) { _.$slider.addclass('slick-dotted'); dot = $('
    ').addclass(_.options.dotsclass); for (i = 0; i <= _.getdotcount(); i += 1) { dot.append($('
  • ').append(_.options.custompaging.call(this, _, i))); } _.$dots = dot.appendto(_.options.appenddots); _.$dots.find('li').first().addclass('slick-active').attr('aria-hidden', 'false'); } }; slick.prototype.buildout = function() { var _ = this; _.$slides = _.$slider .children( _.options.slide + ':not(.slick-cloned)') .addclass('slick-slide'); _.slidecount = _.$slides.length; _.$slides.each(function(index, element) { $(element) .attr('data-slick-index', index) .data('originalstyling', $(element).attr('style') || ''); }); _.$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.swipetoslide === true) { _.options.slidestoscroll = 1; } $('img[data-lazy]', _.$slider).not('[src]').addclass('slick-loading'); _.setupinfinite(); _.buildarrows(); _.builddots(); _.updatedots(); _.setslideclasses(typeof _.currentslide === 'number' ? _.currentslide : 0); if (_.options.draggable === true) { _.$list.addclass('draggable'); } }; slick.prototype.buildrows = function() { var _ = this, a, b, c, newslides, numofslides, originalslides,slidespersection; newslides = document.createdocumentfragment(); originalslides = _.$slider.children(); if(_.options.rows > 1) { slidespersection = _.options.slidesperrow * _.options.rows; numofslides = math.ceil( originalslides.length / slidespersection ); for(a = 0; a < numofslides; a++){ var slide = document.createelement('div'); for(b = 0; b < _.options.rows; b++) { var row = document.createelement('div'); for(c = 0; c < _.options.slidesperrow; c++) { var target = (a * slidespersection + ((b * _.options.slidesperrow) + c)); if (originalslides.get(target)) { row.appendchild(originalslides.get(target)); } } slide.appendchild(row); } newslides.appendchild(slide); } _.$slider.empty().append(newslides); _.$slider.children().children().children() .css({ 'width':(100 / _.options.slidesperrow) + '%', 'display': 'inline-block' }); } }; slick.prototype.checkresponsive = function(initial, forceupdate) { var _ = this, breakpoint, targetbreakpoint, respondtowidth, triggerbreakpoint = false; var sliderwidth = _.$slider.width(); var windowwidth = window.innerwidth || $(window).width(); if (_.respondto === 'window') { respondtowidth = windowwidth; } else if (_.respondto === 'slider') { respondtowidth = sliderwidth; } else if (_.respondto === 'min') { respondtowidth = math.min(windowwidth, sliderwidth); } if ( _.options.responsive && _.options.responsive.length && _.options.responsive !== null) { targetbreakpoint = null; for (breakpoint in _.breakpoints) { if (_.breakpoints.hasownproperty(breakpoint)) { if (_.originalsettings.mobilefirst === false) { if (respondtowidth < _.breakpoints[breakpoint]) { targetbreakpoint = _.breakpoints[breakpoint]; } } else { if (respondtowidth > _.breakpoints[breakpoint]) { targetbreakpoint = _.breakpoints[breakpoint]; } } } } if (targetbreakpoint !== null) { if (_.activebreakpoint !== null) { if (targetbreakpoint !== _.activebreakpoint || forceupdate) { _.activebreakpoint = targetbreakpoint; if (_.breakpointsettings[targetbreakpoint] === 'unslick') { _.unslick(targetbreakpoint); } else { _.options = $.extend({}, _.originalsettings, _.breakpointsettings[ targetbreakpoint]); if (initial === true) { _.currentslide = _.options.initialslide; } _.refresh(initial); } triggerbreakpoint = targetbreakpoint; } } else { _.activebreakpoint = targetbreakpoint; if (_.breakpointsettings[targetbreakpoint] === 'unslick') { _.unslick(targetbreakpoint); } else { _.options = $.extend({}, _.originalsettings, _.breakpointsettings[ targetbreakpoint]); if (initial === true) { _.currentslide = _.options.initialslide; } _.refresh(initial); } triggerbreakpoint = targetbreakpoint; } } else { if (_.activebreakpoint !== null) { _.activebreakpoint = null; _.options = _.originalsettings; if (initial === true) { _.currentslide = _.options.initialslide; } _.refresh(initial); triggerbreakpoint = targetbreakpoint; } } // only trigger breakpoints during an actual break. not on initialize. if( !initial && triggerbreakpoint !== false ) { _.$slider.trigger('breakpoint', [_, triggerbreakpoint]); } } }; slick.prototype.changeslide = function(event, dontanimate) { var _ = this, $target = $(event.currenttarget), indexoffset, slideoffset, unevenoffset; // if target is a link, prevent default action. if($target.is('a')) { event.preventdefault(); } // if target is not the
  • element (ie: a child), find the
  • . if(!$target.is('li')) { $target = $target.closest('li'); } unevenoffset = (_.slidecount % _.options.slidestoscroll !== 0); indexoffset = unevenoffset ? 0 : (_.slidecount - _.currentslide) % _.options.slidestoscroll; switch (event.data.message) { case 'previous': slideoffset = indexoffset === 0 ? _.options.slidestoscroll : _.options.slidestoshow - indexoffset; if (_.slidecount > _.options.slidestoshow) { _.slidehandler(_.currentslide - slideoffset, false, dontanimate); } break; case 'next': slideoffset = indexoffset === 0 ? _.options.slidestoscroll : indexoffset; if (_.slidecount > _.options.slidestoshow) { _.slidehandler(_.currentslide + slideoffset, false, dontanimate); } break; case 'index': var index = event.data.index === 0 ? 0 : event.data.index || $target.index() * _.options.slidestoscroll; _.slidehandler(_.checknavigable(index), false, dontanimate); $target.children().trigger('focus'); break; default: return; } }; slick.prototype.checknavigable = function(index) { var _ = this, navigables, prevnavigable; navigables = _.getnavigableindexes(); prevnavigable = 0; if (index > navigables[navigables.length - 1]) { index = navigables[navigables.length - 1]; } else { for (var n in navigables) { if (index < navigables[n]) { index = prevnavigable; break; } prevnavigable = navigables[n]; } } return index; }; slick.prototype.cleanupevents = function() { var _ = this; if (_.options.dots && _.$dots !== null) { $('li', _.$dots) .off('click.slick', _.changeslide) .off('mouseenter.slick', $.proxy(_.interrupt, _, true)) .off('mouseleave.slick', $.proxy(_.interrupt, _, false)); } _.$slider.off('focus.slick blur.slick'); if (_.options.arrows === true && _.slidecount > _.options.slidestoshow) { _.$prevarrow && _.$prevarrow.off('click.slick', _.changeslide); _.$nextarrow && _.$nextarrow.off('click.slick', _.changeslide); } _.$list.off('touchstart.slick mousedown.slick', _.swipehandler); _.$list.off('touchmove.slick mousemove.slick', _.swipehandler); _.$list.off('touchend.slick mouseup.slick', _.swipehandler); _.$list.off('touchcancel.slick mouseleave.slick', _.swipehandler); _.$list.off('click.slick', _.clickhandler); $(document).off(_.visibilitychange, _.visibility); _.cleanupslideevents(); if (_.options.accessibility === true) { _.$list.off('keydown.slick', _.keyhandler); } if (_.options.focusonselect === true) { $(_.$slidetrack).children().off('click.slick', _.selecthandler); } $(window).off('orientationchange.slick.slick-' + _.instanceuid, _.orientationchange); $(window).off('resize.slick.slick-' + _.instanceuid, _.resize); $('[draggable!=true]', _.$slidetrack).off('dragstart', _.preventdefault); $(window).off('load.slick.slick-' + _.instanceuid, _.setposition); $(document).off('ready.slick.slick-' + _.instanceuid, _.setposition); }; slick.prototype.cleanupslideevents = function() { var _ = this; _.$list.off('mouseenter.slick', $.proxy(_.interrupt, _, true)); _.$list.off('mouseleave.slick', $.proxy(_.interrupt, _, false)); }; slick.prototype.cleanuprows = function() { var _ = this, originalslides; if(_.options.rows > 1) { originalslides = _.$slides.children().children(); originalslides.removeattr('style'); _.$slider.empty().append(originalslides); } }; slick.prototype.clickhandler = function(event) { var _ = this; if (_.shouldclick === false) { event.stopimmediatepropagation(); event.stoppropagation(); event.preventdefault(); } }; slick.prototype.destroy = function(refresh) { var _ = this; _.autoplayclear(); _.touchobject = {}; _.cleanupevents(); $('.slick-cloned', _.$slider).detach(); if (_.$dots) { _.$dots.remove(); } if ( _.$prevarrow && _.$prevarrow.length ) { _.$prevarrow .removeclass('slick-disabled slick-arrow slick-hidden') .removeattr('aria-hidden aria-disabled tabindex') .css('display',''); if ( _.htmlexpr.test( _.options.prevarrow )) { _.$prevarrow.remove(); } } if ( _.$nextarrow && _.$nextarrow.length ) { _.$nextarrow .removeclass('slick-disabled slick-arrow slick-hidden') .removeattr('aria-hidden aria-disabled tabindex') .css('display',''); if ( _.htmlexpr.test( _.options.nextarrow )) { _.$nextarrow.remove(); } } if (_.$slides) { _.$slides .removeclass('slick-slide slick-active slick-center slick-visible slick-current') .removeattr('aria-hidden') .removeattr('data-slick-index') .each(function(){ $(this).attr('style', $(this).data('originalstyling')); }); _.$slidetrack.children(this.options.slide).detach(); _.$slidetrack.detach(); _.$list.detach(); _.$slider.append(_.$slides); } _.cleanuprows(); _.$slider.removeclass('slick-slider'); _.$slider.removeclass('slick-initialized'); _.$slider.removeclass('slick-dotted'); _.unslicked = true; if(!refresh) { _.$slider.trigger('destroy', [_]); } }; 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: _.options.zindex }); _.$slides.eq(slideindex).animate({ opacity: 1 }, _.options.speed, _.options.easing, callback); } else { _.applytransition(slideindex); _.$slides.eq(slideindex).css({ opacity: 1, zindex: _.options.zindex }); if (callback) { settimeout(function() { _.disabletransition(slideindex); callback.call(); }, _.options.speed); } } }; slick.prototype.fadeslideout = function(slideindex) { var _ = this; if (_.csstransitions === false) { _.$slides.eq(slideindex).animate({ opacity: 0, zindex: _.options.zindex - 2 }, _.options.speed, _.options.easing); } else { _.applytransition(slideindex); _.$slides.eq(slideindex).css({ opacity: 0, zindex: _.options.zindex - 2 }); } }; slick.prototype.filterslides = slick.prototype.slickfilter = function(filter) { var _ = this; if (filter !== null) { _.$slidescache = _.$slides; _.unload(); _.$slidetrack.children(this.options.slide).detach(); _.$slidescache.filter(filter).appendto(_.$slidetrack); _.reinit(); } }; slick.prototype.focushandler = function() { var _ = this; _.$slider .off('focus.slick blur.slick') .on('focus.slick blur.slick', '*:not(.slick-arrow)', function(event) { event.stopimmediatepropagation(); var $sf = $(this); settimeout(function() { if( _.options.pauseonfocus ) { _.focussed = $sf.is(':focus'); _.autoplay(); } }, 0); }); }; slick.prototype.getcurrent = slick.prototype.slickcurrentslide = function() { var _ = this; return _.currentslide; }; slick.prototype.getdotcount = function() { var _ = this; var breakpoint = 0; var counter = 0; var pagerqty = 0; if (_.options.infinite === true) { while (breakpoint < _.slidecount) { ++pagerqty; breakpoint = counter + _.options.slidestoscroll; counter += _.options.slidestoscroll <= _.options.slidestoshow ? _.options.slidestoscroll : _.options.slidestoshow; } } else if (_.options.centermode === true) { pagerqty = _.slidecount; } else { while (breakpoint < _.slidecount) { ++pagerqty; breakpoint = counter + _.options.slidestoscroll; counter += _.options.slidestoscroll <= _.options.slidestoshow ? _.options.slidestoscroll : _.options.slidestoshow; } } return pagerqty - 1; }; slick.prototype.getleft = function(slideindex) { var _ = this, targetleft, verticalheight, verticaloffset = 0, targetslide; _.slideoffset = 0; verticalheight = _.$slides.first().outerheight(true); if (_.options.infinite === true) { if (_.slidecount > _.options.slidestoshow) { _.slideoffset = (_.slidewidth * _.options.slidestoshow) * -1; verticaloffset = (verticalheight * _.options.slidestoshow) * -1; } if (_.slidecount % _.options.slidestoscroll !== 0) { if (slideindex + _.options.slidestoscroll > _.slidecount && _.slidecount > _.options.slidestoshow) { if (slideindex > _.slidecount) { _.slideoffset = ((_.options.slidestoshow - (slideindex - _.slidecount)) * _.slidewidth) * -1; verticaloffset = ((_.options.slidestoshow - (slideindex - _.slidecount)) * verticalheight) * -1; } else { _.slideoffset = ((_.slidecount % _.options.slidestoscroll) * _.slidewidth) * -1; verticaloffset = ((_.slidecount % _.options.slidestoscroll) * verticalheight) * -1; } } } } else { if (slideindex + _.options.slidestoshow > _.slidecount) { _.slideoffset = ((slideindex + _.options.slidestoshow) - _.slidecount) * _.slidewidth; verticaloffset = ((slideindex + _.options.slidestoshow) - _.slidecount) * verticalheight; } } if (_.slidecount <= _.options.slidestoshow) { _.slideoffset = 0; verticaloffset = 0; } if (_.options.centermode === true && _.options.infinite === true) { _.slideoffset += _.slidewidth * math.floor(_.options.slidestoshow / 2) - _.slidewidth; } else if (_.options.centermode === true) { _.slideoffset = 0; _.slideoffset += _.slidewidth * math.floor(_.options.slidestoshow / 2); } if (_.options.vertical === false) { targetleft = ((slideindex * _.slidewidth) * -1) + _.slideoffset; } else { targetleft = ((slideindex * verticalheight) * -1) + verticaloffset; } if (_.options.variablewidth === true) { if (_.slidecount <= _.options.slidestoshow || _.options.infinite === false) { targetslide = _.$slidetrack.children('.slick-slide').eq(slideindex); } else { targetslide = _.$slidetrack.children('.slick-slide').eq(slideindex + _.options.slidestoshow); } if (_.options.rtl === true) { if (targetslide[0]) { targetleft = (_.$slidetrack.width() - targetslide[0].offsetleft - targetslide.width()) * -1; } else { targetleft = 0; } } else { targetleft = targetslide[0] ? targetslide[0].offsetleft * -1 : 0; } if (_.options.centermode === true) { if (_.slidecount <= _.options.slidestoshow || _.options.infinite === false) { targetslide = _.$slidetrack.children('.slick-slide').eq(slideindex); } else { targetslide = _.$slidetrack.children('.slick-slide').eq(slideindex + _.options.slidestoshow + 1); } if (_.options.rtl === true) { if (targetslide[0]) { targetleft = (_.$slidetrack.width() - targetslide[0].offsetleft - targetslide.width()) * -1; } else { targetleft = 0; } } else { targetleft = targetslide[0] ? targetslide[0].offsetleft * -1 : 0; } targetleft += (_.$list.width() - targetslide.outerwidth()) / 2; } } return targetleft; }; slick.prototype.getoption = slick.prototype.slickgetoption = function(option) { var _ = this; return _.options[option]; }; slick.prototype.getnavigableindexes = function() { var _ = this, breakpoint = 0, counter = 0, indexes = [], max; if (_.options.infinite === false) { max = _.slidecount; } else { breakpoint = _.options.slidestoscroll * -1; counter = _.options.slidestoscroll * -1; max = _.slidecount * 2; } while (breakpoint < max) { indexes.push(breakpoint); breakpoint = counter + _.options.slidestoscroll; counter += _.options.slidestoscroll <= _.options.slidestoshow ? _.options.slidestoscroll : _.options.slidestoshow; } return indexes; }; slick.prototype.getslick = function() { return this; }; slick.prototype.getslidecount = function() { var _ = this, slidestraversed, swipedslide, centeroffset; centeroffset = _.options.centermode === true ? _.slidewidth * math.floor(_.options.slidestoshow / 2) : 0; if (_.options.swipetoslide === true) { _.$slidetrack.find('.slick-slide').each(function(index, slide) { if (slide.offsetleft - centeroffset + ($(slide).outerwidth() / 2) > (_.swipeleft * -1)) { swipedslide = slide; return false; } }); slidestraversed = math.abs($(swipedslide).attr('data-slick-index') - _.currentslide) || 1; return slidestraversed; } else { return _.options.slidestoscroll; } }; slick.prototype.goto = slick.prototype.slickgoto = function(slide, dontanimate) { var _ = this; _.changeslide({ data: { message: 'index', index: parseint(slide) } }, dontanimate); }; slick.prototype.init = function(creation) { var _ = this; if (!$(_.$slider).hasclass('slick-initialized')) { $(_.$slider).addclass('slick-initialized'); _.buildrows(); _.buildout(); _.setprops(); _.startload(); _.loadslider(); _.initializeevents(); _.updatearrows(); _.updatedots(); _.checkresponsive(true); _.focushandler(); } if (creation) { _.$slider.trigger('init', [_]); } if (_.options.accessibility === true) { _.initada(); } if ( _.options.autoplay ) { _.paused = false; _.autoplay(); } }; slick.prototype.initada = function() { var _ = this; _.$slides.add(_.$slidetrack.find('.slick-cloned')).attr({ 'aria-hidden': 'true', 'tabindex': '-1' }).find('a, input, button, select').attr({ 'tabindex': '-1' }); _.$slidetrack.attr('role', 'listbox'); _.$slides.not(_.$slidetrack.find('.slick-cloned')).each(function(i) { $(this).attr({ 'role': 'option', 'aria-describedby': 'slick-slide' + _.instanceuid + i + '' }); }); if (_.$dots !== null) { _.$dots.attr('role', 'tablist').find('li').each(function(i) { $(this).attr({ 'role': 'presentation', 'aria-selected': 'false', 'aria-controls': 'navigation' + _.instanceuid + i + '', 'id': 'slick-slide' + _.instanceuid + i + '' }); }) .first().attr('aria-selected', 'true').end() .find('button').attr('role', 'button').end() .closest('div').attr('role', 'toolbar'); } _.activateada(); }; slick.prototype.initarrowevents = function() { var _ = this; if (_.options.arrows === true && _.slidecount > _.options.slidestoshow) { _.$prevarrow .off('click.slick') .on('click.slick', { message: 'previous' }, _.changeslide); _.$nextarrow .off('click.slick') .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); } if ( _.options.dots === true && _.options.pauseondotshover === true ) { $('li', _.$dots) .on('mouseenter.slick', $.proxy(_.interrupt, _, true)) .on('mouseleave.slick', $.proxy(_.interrupt, _, false)); } }; slick.prototype.initslideevents = function() { var _ = this; if ( _.options.pauseonhover ) { _.$list.on('mouseenter.slick', $.proxy(_.interrupt, _, true)); _.$list.on('mouseleave.slick', $.proxy(_.interrupt, _, false)); } }; slick.prototype.initializeevents = function() { var _ = this; _.initarrowevents(); _.initdotevents(); _.initslideevents(); _.$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); _.$list.on('click.slick', _.clickhandler); $(document).on(_.visibilitychange, $.proxy(_.visibility, _)); if (_.options.accessibility === true) { _.$list.on('keydown.slick', _.keyhandler); } if (_.options.focusonselect === true) { $(_.$slidetrack).children().on('click.slick', _.selecthandler); } $(window).on('orientationchange.slick.slick-' + _.instanceuid, $.proxy(_.orientationchange, _)); $(window).on('resize.slick.slick-' + _.instanceuid, $.proxy(_.resize, _)); $('[draggable!=true]', _.$slidetrack).on('dragstart', _.preventdefault); $(window).on('load.slick.slick-' + _.instanceuid, _.setposition); $(document).on('ready.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(); } }; slick.prototype.keyhandler = function(event) { var _ = this; //dont slide if the cursor is inside the form fields and arrow keys are pressed if(!event.target.tagname.match('textarea|input|select')) { if (event.keycode === 37 && _.options.accessibility === true) { _.changeslide({ data: { message: _.options.rtl === true ? 'next' : 'previous' } }); } else if (event.keycode === 39 && _.options.accessibility === true) { _.changeslide({ data: { message: _.options.rtl === true ? 'previous' : 'next' } }); } } }; slick.prototype.lazyload = function() { var _ = this, loadrange, clonerange, rangestart, rangeend; function loadimages(imagesscope) { $('img[data-lazy]', imagesscope).each(function() { var image = $(this), imagesource = $(this).attr('data-lazy'), imagetoload = document.createelement('img'); imagetoload.onload = function() { image .animate({ opacity: 0 }, 100, function() { image .attr('src', imagesource) .animate({ opacity: 1 }, 200, function() { image .removeattr('data-lazy') .removeclass('slick-loading'); }); _.$slider.trigger('lazyloaded', [_, image, imagesource]); }); }; imagetoload.onerror = function() { image .removeattr( 'data-lazy' ) .removeclass( 'slick-loading' ) .addclass( 'slick-lazyload-error' ); _.$slider.trigger('lazyloaderror', [ _, image, imagesource ]); }; imagetoload.src = imagesource; }); } if (_.options.centermode === true) { if (_.options.infinite === true) { rangestart = _.currentslide + (_.options.slidestoshow / 2 + 1); rangeend = rangestart + _.options.slidestoshow + 2; } else { rangestart = math.max(0, _.currentslide - (_.options.slidestoshow / 2 + 1)); rangeend = 2 + (_.options.slidestoshow / 2 + 1) + _.currentslide; } } else { rangestart = _.options.infinite ? _.options.slidestoshow + _.currentslide : _.currentslide; rangeend = math.ceil(rangestart + _.options.slidestoshow); if (_.options.fade === true) { if (rangestart > 0) rangestart--; if (rangeend <= _.slidecount) rangeend++; } } loadrange = _.$slider.find('.slick-slide').slice(rangestart, rangeend); loadimages(loadrange); if (_.slidecount <= _.options.slidestoshow) { clonerange = _.$slider.find('.slick-slide'); loadimages(clonerange); } else if (_.currentslide >= _.slidecount - _.options.slidestoshow) { clonerange = _.$slider.find('.slick-cloned').slice(0, _.options.slidestoshow); loadimages(clonerange); } else if (_.currentslide === 0) { clonerange = _.$slider.find('.slick-cloned').slice(_.options.slidestoshow * -1); loadimages(clonerange); } }; slick.prototype.loadslider = function() { var _ = this; _.setposition(); _.$slidetrack.css({ opacity: 1 }); _.$slider.removeclass('slick-loading'); _.initui(); if (_.options.lazyload === 'progressive') { _.progressivelazyload(); } }; slick.prototype.next = slick.prototype.slicknext = function() { var _ = this; _.changeslide({ data: { message: 'next' } }); }; slick.prototype.orientationchange = function() { var _ = this; _.checkresponsive(); _.setposition(); }; slick.prototype.pause = slick.prototype.slickpause = function() { var _ = this; _.autoplayclear(); _.paused = true; }; slick.prototype.play = slick.prototype.slickplay = function() { var _ = this; _.autoplay(); _.options.autoplay = true; _.paused = false; _.focussed = false; _.interrupted = false; }; slick.prototype.postslide = function(index) { var _ = this; if( !_.unslicked ) { _.$slider.trigger('afterchange', [_, index]); _.animating = false; _.setposition(); _.swipeleft = null; if ( _.options.autoplay ) { _.autoplay(); } if (_.options.accessibility === true) { _.initada(); } } }; slick.prototype.prev = slick.prototype.slickprev = function() { var _ = this; _.changeslide({ data: { message: 'previous' } }); }; slick.prototype.preventdefault = function(event) { event.preventdefault(); }; slick.prototype.progressivelazyload = function( trycount ) { trycount = trycount || 1; var _ = this, $imgstoload = $( 'img[data-lazy]', _.$slider ), image, imagesource, imagetoload; if ( $imgstoload.length ) { image = $imgstoload.first(); imagesource = image.attr('data-lazy'); imagetoload = document.createelement('img'); imagetoload.onload = function() { image .attr( 'src', imagesource ) .removeattr('data-lazy') .removeclass('slick-loading'); if ( _.options.adaptiveheight === true ) { _.setposition(); } _.$slider.trigger('lazyloaded', [ _, image, imagesource ]); _.progressivelazyload(); }; imagetoload.onerror = function() { if ( trycount < 3 ) { /** * try to load the image 3 times, * leave a slight delay so we don't get * servers blocking the request. */ settimeout( function() { _.progressivelazyload( trycount + 1 ); }, 500 ); } else { image .removeattr( 'data-lazy' ) .removeclass( 'slick-loading' ) .addclass( 'slick-lazyload-error' ); _.$slider.trigger('lazyloaderror', [ _, image, imagesource ]); _.progressivelazyload(); } }; imagetoload.src = imagesource; } else { _.$slider.trigger('allimagesloaded', [ _ ]); } }; slick.prototype.refresh = function( initializing ) { var _ = this, currentslide, lastvisibleindex; lastvisibleindex = _.slidecount - _.options.slidestoshow; // in non-infinite sliders, we don't want to go past the // last visible index. if( !_.options.infinite && ( _.currentslide > lastvisibleindex )) { _.currentslide = lastvisibleindex; } // if less slides than to show, go to start. if ( _.slidecount <= _.options.slidestoshow ) { _.currentslide = 0; } currentslide = _.currentslide; _.destroy(true); $.extend(_, _.initials, { currentslide: currentslide }); _.init(); if( !initializing ) { _.changeslide({ data: { message: 'index', index: currentslide } }, false); } }; slick.prototype.registerbreakpoints = function() { var _ = this, breakpoint, currentbreakpoint, l, responsivesettings = _.options.responsive || null; if ( $.type(responsivesettings) === 'array' && responsivesettings.length ) { _.respondto = _.options.respondto || 'window'; for ( breakpoint in responsivesettings ) { l = _.breakpoints.length-1; currentbreakpoint = responsivesettings[breakpoint].breakpoint; if (responsivesettings.hasownproperty(breakpoint)) { // loop through the breakpoints and cut out any existing // ones with the same breakpoint number, we don't want dupes. while( l >= 0 ) { if( _.breakpoints[l] && _.breakpoints[l] === currentbreakpoint ) { _.breakpoints.splice(l,1); } l--; } _.breakpoints.push(currentbreakpoint); _.breakpointsettings[currentbreakpoint] = responsivesettings[breakpoint].settings; } } _.breakpoints.sort(function(a, b) { return ( _.options.mobilefirst ) ? a-b : b-a; }); } }; slick.prototype.reinit = function() { var _ = this; _.$slides = _.$slidetrack .children(_.options.slide) .addclass('slick-slide'); _.slidecount = _.$slides.length; if (_.currentslide >= _.slidecount && _.currentslide !== 0) { _.currentslide = _.currentslide - _.options.slidestoscroll; } if (_.slidecount <= _.options.slidestoshow) { _.currentslide = 0; } _.registerbreakpoints(); _.setprops(); _.setupinfinite(); _.buildarrows(); _.updatearrows(); _.initarrowevents(); _.builddots(); _.updatedots(); _.initdotevents(); _.cleanupslideevents(); _.initslideevents(); _.checkresponsive(false, true); if (_.options.focusonselect === true) { $(_.$slidetrack).children().on('click.slick', _.selecthandler); } _.setslideclasses(typeof _.currentslide === 'number' ? _.currentslide : 0); _.setposition(); _.focushandler(); _.paused = !_.options.autoplay; _.autoplay(); _.$slider.trigger('reinit', [_]); }; slick.prototype.resize = function() { var _ = this; if ($(window).width() !== _.windowwidth) { cleartimeout(_.windowdelay); _.windowdelay = window.settimeout(function() { _.windowwidth = $(window).width(); _.checkresponsive(); if( !_.unslicked ) { _.setposition(); } }, 50); } }; slick.prototype.removeslide = slick.prototype.slickremove = function(index, removebefore, removeall) { 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(); if (removeall === true) { _.$slidetrack.children().remove(); } else { _.$slidetrack.children(this.options.slide).eq(index).remove(); } _.$slides = _.$slidetrack.children(this.options.slide); _.$slidetrack.children(this.options.slide).detach(); _.$slidetrack.append(_.$slides); _.$slidescache = _.$slides; _.reinit(); }; slick.prototype.setcss = function(position) { var _ = this, positionprops = {}, x, y; if (_.options.rtl === true) { position = -position; } x = _.positionprop == 'left' ? math.ceil(position) + 'px' : '0px'; y = _.positionprop == 'top' ? math.ceil(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.vertical === false) { if (_.options.centermode === true) { _.$list.css({ padding: ('0px ' + _.options.centerpadding) }); } } else { _.$list.height(_.$slides.first().outerheight(true) * _.options.slidestoshow); if (_.options.centermode === true) { _.$list.css({ padding: (_.options.centerpadding + ' 0px') }); } } _.listwidth = _.$list.width(); _.listheight = _.$list.height(); if (_.options.vertical === false && _.options.variablewidth === false) { _.slidewidth = math.ceil(_.listwidth / _.options.slidestoshow); _.$slidetrack.width(math.ceil((_.slidewidth * _.$slidetrack.children('.slick-slide').length))); } else if (_.options.variablewidth === true) { _.$slidetrack.width(5000 * _.slidecount); } else { _.slidewidth = math.ceil(_.listwidth); _.$slidetrack.height(math.ceil((_.$slides.first().outerheight(true) * _.$slidetrack.children('.slick-slide').length))); } var offset = _.$slides.first().outerwidth(true) - _.$slides.first().width(); if (_.options.variablewidth === false) _.$slidetrack.children('.slick-slide').width(_.slidewidth - offset); }; slick.prototype.setfade = function() { var _ = this, targetleft; _.$slides.each(function(index, element) { targetleft = (_.slidewidth * index) * -1; if (_.options.rtl === true) { $(element).css({ position: 'relative', right: targetleft, top: 0, zindex: _.options.zindex - 2, opacity: 0 }); } else { $(element).css({ position: 'relative', left: targetleft, top: 0, zindex: _.options.zindex - 2, opacity: 0 }); } }); _.$slides.eq(_.currentslide).css({ zindex: _.options.zindex - 1, opacity: 1 }); }; slick.prototype.setheight = function() { var _ = this; if (_.options.slidestoshow === 1 && _.options.adaptiveheight === true && _.options.vertical === false) { var targetheight = _.$slides.eq(_.currentslide).outerheight(true); _.$list.css('height', targetheight); } }; slick.prototype.setoption = slick.prototype.slicksetoption = function() { /** * accepts arguments in format of: * * - for changing a single option's value: * .slick("setoption", option, value, refresh ) * * - for changing a set of responsive options: * .slick("setoption", 'responsive', [{}, ...], refresh ) * * - for updating multiple values at once (not responsive) * .slick("setoption", { 'option': value, ... }, refresh ) */ var _ = this, l, item, option, value, refresh = false, type; if( $.type( arguments[0] ) === 'object' ) { option = arguments[0]; refresh = arguments[1]; type = 'multiple'; } else if ( $.type( arguments[0] ) === 'string' ) { option = arguments[0]; value = arguments[1]; refresh = arguments[2]; if ( arguments[0] === 'responsive' && $.type( arguments[1] ) === 'array' ) { type = 'responsive'; } else if ( typeof arguments[1] !== 'undefined' ) { type = 'single'; } } if ( type === 'single' ) { _.options[option] = value; } else if ( type === 'multiple' ) { $.each( option , function( opt, val ) { _.options[opt] = val; }); } else if ( type === 'responsive' ) { for ( item in value ) { if( $.type( _.options.responsive ) !== 'array' ) { _.options.responsive = [ value[item] ]; } else { l = _.options.responsive.length-1; // loop through the responsive object and splice out duplicates. while( l >= 0 ) { if( _.options.responsive[l].breakpoint === value[item].breakpoint ) { _.options.responsive.splice(l,1); } l--; } _.options.responsive.push( value[item] ); } } } if ( refresh ) { _.unload(); _.reinit(); } }; slick.prototype.setposition = function() { var _ = this; _.setdimensions(); _.setheight(); if (_.options.fade === false) { _.setcss(_.getleft(_.currentslide)); } else { _.setfade(); } _.$slider.trigger('setposition', [_]); }; slick.prototype.setprops = function() { var _ = this, bodystyle = document.body.style; _.positionprop = _.options.vertical === true ? 'top' : 'left'; if (_.positionprop === 'top') { _.$slider.addclass('slick-vertical'); } else { _.$slider.removeclass('slick-vertical'); } if (bodystyle.webkittransition !== undefined || bodystyle.moztransition !== undefined || bodystyle.mstransition !== undefined) { if (_.options.usecss === true) { _.csstransitions = true; } } if ( _.options.fade ) { if ( typeof _.options.zindex === 'number' ) { if( _.options.zindex < 3 ) { _.options.zindex = 3; } } else { _.options.zindex = _.defaults.zindex; } } if (bodystyle.otransform !== undefined) { _.animtype = 'otransform'; _.transformtype = '-o-transform'; _.transitiontype = 'otransition'; if (bodystyle.perspectiveproperty === undefined && bodystyle.webkitperspective === undefined) _.animtype = false; } if (bodystyle.moztransform !== undefined) { _.animtype = 'moztransform'; _.transformtype = '-moz-transform'; _.transitiontype = 'moztransition'; if (bodystyle.perspectiveproperty === undefined && bodystyle.mozperspective === undefined) _.animtype = false; } if (bodystyle.webkittransform !== undefined) { _.animtype = 'webkittransform'; _.transformtype = '-webkit-transform'; _.transitiontype = 'webkittransition'; if (bodystyle.perspectiveproperty === undefined && bodystyle.webkitperspective === undefined) _.animtype = false; } if (bodystyle.mstransform !== undefined) { _.animtype = 'mstransform'; _.transformtype = '-ms-transform'; _.transitiontype = 'mstransition'; if (bodystyle.mstransform === undefined) _.animtype = false; } if (bodystyle.transform !== undefined && _.animtype !== false) { _.animtype = 'transform'; _.transformtype = 'transform'; _.transitiontype = 'transition'; } _.transformsenabled = _.options.usetransform && (_.animtype !== null && _.animtype !== false); }; slick.prototype.setslideclasses = function(index) { var _ = this, centeroffset, allslides, indexoffset, remainder; allslides = _.$slider .find('.slick-slide') .removeclass('slick-active slick-center slick-current') .attr('aria-hidden', 'true'); _.$slides .eq(index) .addclass('slick-current'); if (_.options.centermode === true) { centeroffset = math.floor(_.options.slidestoshow / 2); if (_.options.infinite === true) { if (index >= centeroffset && index <= (_.slidecount - 1) - centeroffset) { _.$slides .slice(index - centeroffset, index + centeroffset + 1) .addclass('slick-active') .attr('aria-hidden', 'false'); } else { indexoffset = _.options.slidestoshow + index; allslides .slice(indexoffset - centeroffset + 1, indexoffset + centeroffset + 2) .addclass('slick-active') .attr('aria-hidden', 'false'); } 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') .attr('aria-hidden', 'false'); } else if (allslides.length <= _.options.slidestoshow) { allslides .addclass('slick-active') .attr('aria-hidden', 'false'); } else { remainder = _.slidecount % _.options.slidestoshow; indexoffset = _.options.infinite === true ? _.options.slidestoshow + index : index; if (_.options.slidestoshow == _.options.slidestoscroll && (_.slidecount - index) < _.options.slidestoshow) { allslides .slice(indexoffset - (_.options.slidestoshow - remainder), indexoffset + remainder) .addclass('slick-active') .attr('aria-hidden', 'false'); } else { allslides .slice(indexoffset, indexoffset + _.options.slidestoshow) .addclass('slick-active') .attr('aria-hidden', 'false'); } } } if (_.options.lazyload === 'ondemand') { _.lazyload(); } }; slick.prototype.setupinfinite = function() { var _ = this, i, slideindex, infinitecount; if (_.options.fade === true) { _.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(true).attr('id', '') .attr('data-slick-index', slideindex - _.slidecount) .prependto(_.$slidetrack).addclass('slick-cloned'); } for (i = 0; i < infinitecount; i += 1) { slideindex = i; $(_.$slides[slideindex]).clone(true).attr('id', '') .attr('data-slick-index', slideindex + _.slidecount) .appendto(_.$slidetrack).addclass('slick-cloned'); } _.$slidetrack.find('.slick-cloned').find('[id]').each(function() { $(this).attr('id', ''); }); } } }; slick.prototype.interrupt = function( toggle ) { var _ = this; if( !toggle ) { _.autoplay(); } _.interrupted = toggle; }; slick.prototype.selecthandler = function(event) { var _ = this; var targetelement = $(event.target).is('.slick-slide') ? $(event.target) : $(event.target).parents('.slick-slide'); var index = parseint(targetelement.attr('data-slick-index')); if (!index) index = 0; if (_.slidecount <= _.options.slidestoshow) { _.setslideclasses(index); _.asnavfor(index); return; } _.slidehandler(index); }; slick.prototype.slidehandler = function(index, sync, dontanimate) { var targetslide, animslide, oldslide, slideleft, targetleft = null, _ = this, navtarget; sync = sync || false; if (_.animating === true && _.options.waitforanimate === true) { return; } if (_.options.fade === true && _.currentslide === index) { return; } if (_.slidecount <= _.options.slidestoshow) { return; } if (sync === false) { _.asnavfor(index); } targetslide = index; targetleft = _.getleft(targetslide); slideleft = _.getleft(_.currentslide); _.currentleft = _.swipeleft === null ? slideleft : _.swipeleft; if (_.options.infinite === false && _.options.centermode === false && (index < 0 || index > _.getdotcount() * _.options.slidestoscroll)) { if (_.options.fade === false) { targetslide = _.currentslide; if (dontanimate !== true) { _.animateslide(slideleft, function() { _.postslide(targetslide); }); } else { _.postslide(targetslide); } } return; } else if (_.options.infinite === false && _.options.centermode === true && (index < 0 || index > (_.slidecount - _.options.slidestoscroll))) { if (_.options.fade === false) { targetslide = _.currentslide; if (dontanimate !== true) { _.animateslide(slideleft, function() { _.postslide(targetslide); }); } else { _.postslide(targetslide); } } return; } if ( _.options.autoplay ) { clearinterval(_.autoplaytimer); } if (targetslide < 0) { if (_.slidecount % _.options.slidestoscroll !== 0) { animslide = _.slidecount - (_.slidecount % _.options.slidestoscroll); } else { animslide = _.slidecount + targetslide; } } else if (targetslide >= _.slidecount) { if (_.slidecount % _.options.slidestoscroll !== 0) { animslide = 0; } else { animslide = targetslide - _.slidecount; } } else { animslide = targetslide; } _.animating = true; _.$slider.trigger('beforechange', [_, _.currentslide, animslide]); oldslide = _.currentslide; _.currentslide = animslide; _.setslideclasses(_.currentslide); if ( _.options.asnavfor ) { navtarget = _.getnavtarget(); navtarget = navtarget.slick('getslick'); if ( navtarget.slidecount <= navtarget.options.slidestoshow ) { navtarget.setslideclasses(_.currentslide); } } _.updatedots(); _.updatearrows(); if (_.options.fade === true) { if (dontanimate !== true) { _.fadeslideout(oldslide); _.fadeslide(animslide, function() { _.postslide(animslide); }); } else { _.postslide(animslide); } _.animateheight(); return; } if (dontanimate !== true) { _.animateslide(targetleft, function() { _.postslide(animslide); }); } else { _.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 (_.options.rtl === false ? 'left' : 'right'); } if ((swipeangle <= 360) && (swipeangle >= 315)) { return (_.options.rtl === false ? 'left' : 'right'); } if ((swipeangle >= 135) && (swipeangle <= 225)) { return (_.options.rtl === false ? 'right' : 'left'); } if (_.options.verticalswiping === true) { if ((swipeangle >= 35) && (swipeangle <= 135)) { return 'down'; } else { return 'up'; } } return 'vertical'; }; slick.prototype.swipeend = function(event) { var _ = this, slidecount, direction; _.dragging = false; _.interrupted = false; _.shouldclick = ( _.touchobject.swipelength > 10 ) ? false : true; if ( _.touchobject.curx === undefined ) { return false; } if ( _.touchobject.edgehit === true ) { _.$slider.trigger('edge', [_, _.swipedirection() ]); } if ( _.touchobject.swipelength >= _.touchobject.minswipe ) { direction = _.swipedirection(); switch ( direction ) { case 'left': case 'down': slidecount = _.options.swipetoslide ? _.checknavigable( _.currentslide + _.getslidecount() ) : _.currentslide + _.getslidecount(); _.currentdirection = 0; break; case 'right': case 'up': slidecount = _.options.swipetoslide ? _.checknavigable( _.currentslide - _.getslidecount() ) : _.currentslide - _.getslidecount(); _.currentdirection = 1; break; default: } if( direction != 'vertical' ) { _.slidehandler( slidecount ); _.touchobject = {}; _.$slider.trigger('swipe', [_, direction ]); } } else { if ( _.touchobject.startx !== _.touchobject.curx ) { _.slidehandler( _.currentslide ); _.touchobject = {}; } } }; slick.prototype.swipehandler = function(event) { var _ = this; if ((_.options.swipe === false) || ('ontouchend' in document && _.options.swipe === false)) { return; } else if (_.options.draggable === false && event.type.indexof('mouse') !== -1) { return; } _.touchobject.fingercount = event.originalevent && event.originalevent.touches !== undefined ? event.originalevent.touches.length : 1; _.touchobject.minswipe = _.listwidth / _.options .touchthreshold; if (_.options.verticalswiping === true) { _.touchobject.minswipe = _.listheight / _.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, edgewashit = false, curleft, swipedirection, swipelength, positionoffset, touches; touches = event.originalevent !== undefined ? event.originalevent.touches : null; if (!_.dragging || touches && touches.length !== 1) { return false; } curleft = _.getleft(_.currentslide); _.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))); if (_.options.verticalswiping === true) { _.touchobject.swipelength = math.round(math.sqrt( math.pow(_.touchobject.cury - _.touchobject.starty, 2))); } swipedirection = _.swipedirection(); if (swipedirection === 'vertical') { return; } if (event.originalevent !== undefined && _.touchobject.swipelength > 4) { event.preventdefault(); } positionoffset = (_.options.rtl === false ? 1 : -1) * (_.touchobject.curx > _.touchobject.startx ? 1 : -1); if (_.options.verticalswiping === true) { positionoffset = _.touchobject.cury > _.touchobject.starty ? 1 : -1; } swipelength = _.touchobject.swipelength; _.touchobject.edgehit = false; if (_.options.infinite === false) { if ((_.currentslide === 0 && swipedirection === 'right') || (_.currentslide >= _.getdotcount() && swipedirection === 'left')) { swipelength = _.touchobject.swipelength * _.options.edgefriction; _.touchobject.edgehit = true; } } if (_.options.vertical === false) { _.swipeleft = curleft + swipelength * positionoffset; } else { _.swipeleft = curleft + (swipelength * (_.$list.height() / _.listwidth)) * positionoffset; } if (_.options.verticalswiping === true) { _.swipeleft = curleft + swipelength * 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; _.interrupted = true; 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; _.dragging = true; }; slick.prototype.unfilterslides = slick.prototype.slickunfilter = function() { var _ = this; if (_.$slidescache !== null) { _.unload(); _.$slidetrack.children(this.options.slide).detach(); _.$slidescache.appendto(_.$slidetrack); _.reinit(); } }; slick.prototype.unload = function() { var _ = this; $('.slick-cloned', _.$slider).remove(); if (_.$dots) { _.$dots.remove(); } if (_.$prevarrow && _.htmlexpr.test(_.options.prevarrow)) { _.$prevarrow.remove(); } if (_.$nextarrow && _.htmlexpr.test(_.options.nextarrow)) { _.$nextarrow.remove(); } _.$slides .removeclass('slick-slide slick-active slick-visible slick-current') .attr('aria-hidden', 'true') .css('width', ''); }; slick.prototype.unslick = function(frombreakpoint) { var _ = this; _.$slider.trigger('unslick', [_, frombreakpoint]); _.destroy(); }; slick.prototype.updatearrows = function() { var _ = this, centeroffset; centeroffset = math.floor(_.options.slidestoshow / 2); if ( _.options.arrows === true && _.slidecount > _.options.slidestoshow && !_.options.infinite ) { _.$prevarrow.removeclass('slick-disabled').attr('aria-disabled', 'false'); _.$nextarrow.removeclass('slick-disabled').attr('aria-disabled', 'false'); if (_.currentslide === 0) { _.$prevarrow.addclass('slick-disabled').attr('aria-disabled', 'true'); _.$nextarrow.removeclass('slick-disabled').attr('aria-disabled', 'false'); } else if (_.currentslide >= _.slidecount - _.options.slidestoshow && _.options.centermode === false) { _.$nextarrow.addclass('slick-disabled').attr('aria-disabled', 'true'); _.$prevarrow.removeclass('slick-disabled').attr('aria-disabled', 'false'); } else if (_.currentslide >= _.slidecount - 1 && _.options.centermode === true) { _.$nextarrow.addclass('slick-disabled').attr('aria-disabled', 'true'); _.$prevarrow.removeclass('slick-disabled').attr('aria-disabled', 'false'); } } }; slick.prototype.updatedots = function() { var _ = this; if (_.$dots !== null) { _.$dots .find('li') .removeclass('slick-active') .attr('aria-hidden', 'true'); _.$dots .find('li') .eq(math.floor(_.currentslide / _.options.slidestoscroll)) .addclass('slick-active') .attr('aria-hidden', 'false'); } }; slick.prototype.visibility = function() { var _ = this; if ( _.options.autoplay ) { if ( document[_.hidden] ) { _.interrupted = true; } else { _.interrupted = false; } } }; $.fn.slick = function() { var _ = this, opt = arguments[0], args = array.prototype.slice.call(arguments, 1), l = _.length, i, ret; for (i = 0; i < l; i++) { if (typeof opt == 'object' || typeof opt == 'undefined') _[i].slick = new slick(_[i], opt); else ret = _[i].slick[opt].apply(_[i].slick, args); if (typeof ret != 'undefined') return ret; } return _; }; })); /*slick end*/ /** * bxslider v4.1.2 - fully loaded, responsive content slider * http://bxslider.com * * copyright 2014, steven wanderski - http://stevenwanderski.com - http://bxcreative.com * written while drinking belgian ales and listening to jazz * * released under the mit license - http://opensource.org/licenses/mit */ ;(function($){ var plugin = {}; var defaults = { // general mode: 'horizontal', slideselector: '', infiniteloop: true, hidecontrolonend: false, speed: 500, easing: null, slidemargin: 0, startslide: 0, randomstart: false, captions: false, ticker: false, tickerhover: false, adaptiveheight: false, adaptiveheightspeed: 500, video: false, usecss: true, preloadimages: 'visible', responsive: true, slidezindex: 50, wrapperclass: 'bx-wrapper', // touch touchenabled: true, swipethreshold: 50, onetoonetouch: true, preventdefaultswipex: true, preventdefaultswipey: false, // pager pager: true, pagertype: 'full', pagershortseparator: ' / ', pagerselector: null, buildpager: null, pagercustom: null, // controls controls: true, nexttext: 'next', prevtext: 'prev', nextselector: null, prevselector: null, autocontrols: false, starttext: 'start', stoptext: 'stop', autocontrolscombine: false, autocontrolsselector: null, // auto auto: false, pause: 4000, autostart: true, autodirection: 'next', autohover: false, autodelay: 0, autoslideforonepage: false, // carousel minslides: 1, maxslides: 1, moveslides: 0, slidewidth: 0, // callbacks onsliderload: function() {}, onslidebefore: function() {}, onslideafter: function() {}, onslidenext: function() {}, onslideprev: function() {}, onsliderresize: function() {} } $.fn.bxslider = function(options){ if(this.length == 0) return this; // support mutltiple elements if(this.length > 1){ this.each(function(){$(this).bxslider(options)}); return this; } // create a namespace to be used throughout the plugin var slider = {}; // set a reference to our slider element var el = this; plugin.el = this; /** * makes slideshow responsive */ // first get the original window dimens (thanks alot ie) var windowwidth = $(window).width(); var windowheight = $(window).height(); /** * =================================================================================== * = private functions * =================================================================================== */ /** * initializes namespace settings to be used throughout plugin */ var init = function(){ // merge user-supplied options with the defaults slider.settings = $.extend({}, defaults, options); // parse slidewidth setting slider.settings.slidewidth = parseint(slider.settings.slidewidth); // store the original children slider.children = el.children(slider.settings.slideselector); // check if actual number of slides is less than minslides / maxslides if(slider.children.length < slider.settings.minslides) slider.settings.minslides = slider.children.length; if(slider.children.length < slider.settings.maxslides) slider.settings.maxslides = slider.children.length; // if random start, set the startslide setting to random number if(slider.settings.randomstart) slider.settings.startslide = math.floor(math.random() * slider.children.length); // store active slide information slider.active = { index: slider.settings.startslide } // store if the slider is in carousel mode (displaying / moving multiple slides) slider.carousel = slider.settings.minslides > 1 || slider.settings.maxslides > 1; // if carousel, force preloadimages = 'all' if(slider.carousel) slider.settings.preloadimages = 'all'; // calculate the min / max width thresholds based on min / max number of slides // used to setup and update carousel slides dimensions slider.minthreshold = (slider.settings.minslides * slider.settings.slidewidth) + ((slider.settings.minslides - 1) * slider.settings.slidemargin); slider.maxthreshold = (slider.settings.maxslides * slider.settings.slidewidth) + ((slider.settings.maxslides - 1) * slider.settings.slidemargin); // store the current state of the slider (if currently animating, working is true) slider.working = false; // initialize the controls object slider.controls = {}; // initialize an auto interval slider.interval = null; // determine which property to use for transitions slider.animprop = slider.settings.mode == 'vertical' ? 'top' : 'left'; // determine if hardware acceleration can be used slider.usingcss = slider.settings.usecss && slider.settings.mode != 'fade' && (function(){ // create our test div element var div = document.createelement('div'); // css transition properties var props = ['webkitperspective', 'mozperspective', 'operspective', 'msperspective']; // test for each property for(var i in props){ if(div.style[props[i]] !== undefined){ slider.cssprefix = props[i].replace('perspective', '').tolowercase(); slider.animprop = '-' + slider.cssprefix + '-transform'; return true; } } return false; }()); // if vertical mode always make maxslides and minslides equal if(slider.settings.mode == 'vertical') slider.settings.maxslides = slider.settings.minslides; // save original style data el.data("origstyle", el.attr("style")); el.children(slider.settings.slideselector).each(function() { $(this).data("origstyle", $(this).attr("style")); }); // perform all dom / css modifications setup(); } /** * performs all dom and css modifications */ var setup = function(){ // wrap el in a wrapper el.wrap('
    '); // store a namspace reference to .bx-viewport slider.viewport = el.parent(); // add a loading div to display while images are loading slider.loader = $('
    '); slider.viewport.prepend(slider.loader); // set el to a massive width, to hold any needed slides // also strip any margin and padding from el el.css({ width: slider.settings.mode == 'horizontal' ? (slider.children.length * 100 + 215) + '%' : 'auto', position: 'relative' }); // if using css, add the easing property if(slider.usingcss && slider.settings.easing){ el.css('-' + slider.cssprefix + '-transition-timing-function', slider.settings.easing); // if not using css and no easing value was supplied, use the default js animation easing (swing) }else if(!slider.settings.easing){ slider.settings.easing = 'swing'; } var slidesshowing = getnumberslidesshowing(); // make modifications to the viewport (.bx-viewport) slider.viewport.css({ width: '100%', overflow: 'hidden', position: 'relative' }); slider.viewport.parent().css({ maxwidth: getviewportmaxwidth() }); // make modification to the wrapper (.bx-wrapper) if(!slider.settings.pager) { slider.viewport.parent().css({ margin: '0 auto 0px' }); } // apply css to all slider children slider.children.css({ 'float': slider.settings.mode == 'horizontal' ? 'left' : 'none', liststyle: 'none', position: 'relative' }); // apply the calculated width after the float is applied to prevent scrollbar interference slider.children.css('width', getslidewidth()); // if slidemargin is supplied, add the css if(slider.settings.mode == 'horizontal' && slider.settings.slidemargin > 0) slider.children.css('marginright', slider.settings.slidemargin); if(slider.settings.mode == 'vertical' && slider.settings.slidemargin > 0) slider.children.css('marginbottom', slider.settings.slidemargin); // if "fade" mode, add positioning and z-index css if(slider.settings.mode == 'fade'){ slider.children.css({ position: 'absolute', zindex: 0, display: 'none' }); // prepare the z-index on the showing element slider.children.eq(slider.settings.startslide).css({zindex: slider.settings.slidezindex, display: 'block'}); } // create an element to contain all slider controls (pager, start / stop, etc) slider.controls.el = $('
    '); // if captions are requested, add them if(slider.settings.captions) appendcaptions(); // check if startslide is last slide slider.active.last = slider.settings.startslide == getpagerqty() - 1; // if video is true, set up the fitvids plugin if(slider.settings.video) el.fitvids(); // set the default preload selector (visible) var preloadselector = slider.children.eq(slider.settings.startslide); if (slider.settings.preloadimages == "all") preloadselector = slider.children; // only check for control addition if not in "ticker" mode if(!slider.settings.ticker){ // if pager is requested, add it if(slider.settings.pager) appendpager(); // if controls are requested, add them if(slider.settings.controls) appendcontrols(); // if auto is true, and auto controls are requested, add them if(slider.settings.auto && slider.settings.autocontrols) appendcontrolsauto(); // if any control option is requested, add the controls wrapper if(slider.settings.controls || slider.settings.autocontrols || slider.settings.pager) slider.viewport.after(slider.controls.el); // if ticker mode, do not allow a pager }else{ slider.settings.pager = false; } // preload all images, then perform final dom / css modifications that depend on images being loaded loadelements(preloadselector, start); } var loadelements = function(selector, callback){ var total = selector.find('img, iframe').length; if (total == 0){ callback(); return; } var count = 0; selector.find('img, iframe').each(function(){ $(this).one('load', function() { if(++count == total) callback(); }).each(function() { if(this.complete) $(this).load(); }); }); } /** * start the slider */ var start = function(){ // if infinite loop, prepare additional slides if(slider.settings.infiniteloop && slider.settings.mode != 'fade' && !slider.settings.ticker){ var slice = slider.settings.mode == 'vertical' ? slider.settings.minslides : slider.settings.maxslides; var sliceappend = slider.children.slice(0, slice).clone().addclass('bx-clone'); var sliceprepend = slider.children.slice(-slice).clone().addclass('bx-clone'); el.append(sliceappend).prepend(sliceprepend); } // remove the loading dom element slider.loader.remove(); // set the left / top position of "el" setslideposition(); // if "vertical" mode, always use adaptiveheight to prevent odd behavior if (slider.settings.mode == 'vertical') slider.settings.adaptiveheight = true; // set the viewport height slider.viewport.height(getviewportheight()); // make sure everything is positioned just right (same as a window resize) el.redrawslider(); // onsliderload callback slider.settings.onsliderload(slider.active.index); // slider has been fully initialized slider.initialized = true; // bind the resize call to the window if (slider.settings.responsive) $(window).bind('resize', resizewindow); // if auto is true and has more than 1 page, start the show if (slider.settings.auto && slider.settings.autostart && (getpagerqty() > 1 || slider.settings.autoslideforonepage)) initauto(); // if ticker is true, start the ticker if (slider.settings.ticker) initticker(); // if pager is requested, make the appropriate pager link active if (slider.settings.pager) updatepageractive(slider.settings.startslide); // check for any updates to the controls (like hidecontrolonend updates) if (slider.settings.controls) updatedirectioncontrols(); // if touchenabled is true, setup the touch events if (slider.settings.touchenabled && !slider.settings.ticker) inittouch(); } /** * returns the calculated height of the viewport, used to determine either adaptiveheight or the maxheight value */ var getviewportheight = function(){ var height = 0; // first determine which children (slides) should be used in our height calculation var children = $(); // if mode is not "vertical" and adaptiveheight is false, include all children if(slider.settings.mode != 'vertical' && !slider.settings.adaptiveheight){ children = slider.children; }else{ // if not carousel, return the single active child if(!slider.carousel){ children = slider.children.eq(slider.active.index); // if carousel, return a slice of children }else{ // get the individual slide index var currentindex = slider.settings.moveslides == 1 ? slider.active.index : slider.active.index * getmoveby(); // add the current slide to the children children = slider.children.eq(currentindex); // cycle through the remaining "showing" slides for (i = 1; i <= slider.settings.maxslides - 1; i++){ // if looped back to the start if(currentindex + i >= slider.children.length){ children = children.add(slider.children.eq(i - 1)); }else{ children = children.add(slider.children.eq(currentindex + i)); } } } } // if "vertical" mode, calculate the sum of the heights of the children if(slider.settings.mode == 'vertical'){ children.each(function(index) { height += $(this).outerheight(); }); // add user-supplied margins if(slider.settings.slidemargin > 0){ height += slider.settings.slidemargin * (slider.settings.minslides - 1); } // if not "vertical" mode, calculate the max height of the children }else{ height = math.max.apply(math, children.map(function(){ return $(this).outerheight(false); }).get()); } if(slider.viewport.css('box-sizing') == 'border-box'){ height += parsefloat(slider.viewport.css('padding-top')) + parsefloat(slider.viewport.css('padding-bottom')) + parsefloat(slider.viewport.css('border-top-width')) + parsefloat(slider.viewport.css('border-bottom-width')); }else if(slider.viewport.css('box-sizing') == 'padding-box'){ height += parsefloat(slider.viewport.css('padding-top')) + parsefloat(slider.viewport.css('padding-bottom')); } return height; } /** * returns the calculated width to be used for the outer wrapper / viewport */ var getviewportmaxwidth = function(){ var width = '100%'; if(slider.settings.slidewidth > 0){ if(slider.settings.mode == 'horizontal'){ width = (slider.settings.maxslides * slider.settings.slidewidth) + ((slider.settings.maxslides - 1) * slider.settings.slidemargin); }else{ width = slider.settings.slidewidth; } } return width; } /** * returns the calculated width to be applied to each slide */ var getslidewidth = function(){ // start with any user-supplied slide width var newelwidth = slider.settings.slidewidth; // get the current viewport width var wrapwidth = slider.viewport.width(); // if slide width was not supplied, or is larger than the viewport use the viewport width if(slider.settings.slidewidth == 0 || (slider.settings.slidewidth > wrapwidth && !slider.carousel) || slider.settings.mode == 'vertical'){ newelwidth = wrapwidth; // if carousel, use the thresholds to determine the width }else if(slider.settings.maxslides > 1 && slider.settings.mode == 'horizontal'){ if(wrapwidth > slider.maxthreshold){ // newelwidth = (wrapwidth - (slider.settings.slidemargin * (slider.settings.maxslides - 1))) / slider.settings.maxslides; }else if(wrapwidth < slider.minthreshold){ newelwidth = (wrapwidth - (slider.settings.slidemargin * (slider.settings.minslides - 1))) / slider.settings.minslides; } } return newelwidth; } /** * returns the number of slides currently visible in the viewport (includes partially visible slides) */ var getnumberslidesshowing = function(){ var slidesshowing = 1; if(slider.settings.mode == 'horizontal' && slider.settings.slidewidth > 0){ // if viewport is smaller than minthreshold, return minslides if(slider.viewport.width() < slider.minthreshold){ slidesshowing = slider.settings.minslides; // if viewport is larger than minthreshold, return maxslides }else if(slider.viewport.width() > slider.maxthreshold){ slidesshowing = slider.settings.maxslides; // if viewport is between min / max thresholds, divide viewport width by first child width }else{ var childwidth = slider.children.first().width() + slider.settings.slidemargin; slidesshowing = math.floor((slider.viewport.width() + slider.settings.slidemargin) / childwidth); } // if "vertical" mode, slides showing will always be minslides }else if(slider.settings.mode == 'vertical'){ slidesshowing = slider.settings.minslides; } return slidesshowing; } /** * returns the number of pages (one full viewport of slides is one "page") */ var getpagerqty = function(){ var pagerqty = 0; // if moveslides is specified by the user if(slider.settings.moveslides > 0){ if(slider.settings.infiniteloop){ pagerqty = math.ceil(slider.children.length / getmoveby()); }else{ // use a while loop to determine pages var breakpoint = 0; var counter = 0 // when breakpoint goes above children length, counter is the number of pages while (breakpoint < slider.children.length){ ++pagerqty; breakpoint = counter + getnumberslidesshowing(); counter += slider.settings.moveslides <= getnumberslidesshowing() ? slider.settings.moveslides : getnumberslidesshowing(); } } // if moveslides is 0 (auto) divide children length by sides showing, then round up }else{ pagerqty = math.ceil(slider.children.length / getnumberslidesshowing()); } return pagerqty; } /** * returns the number of indivual slides by which to shift the slider */ var getmoveby = function(){ // if moveslides was set by the user and moveslides is less than number of slides showing if(slider.settings.moveslides > 0 && slider.settings.moveslides <= getnumberslidesshowing()){ return slider.settings.moveslides; } // if moveslides is 0 (auto) return getnumberslidesshowing(); } /** * sets the slider's (el) left or top position */ var setslideposition = function(){ // if last slide, not infinite loop, and number of children is larger than specified maxslides if(slider.children.length > slider.settings.maxslides && slider.active.last && !slider.settings.infiniteloop){ if (slider.settings.mode == 'horizontal'){ // get the last child's position var lastchild = slider.children.last(); var position = lastchild.position(); // set the left position setpositionproperty(-(position.left - (slider.viewport.width() - lastchild.outerwidth())), 'reset', 0); }else if(slider.settings.mode == 'vertical'){ // get the last showing index's position var lastshowingindex = slider.children.length - slider.settings.minslides; var position = slider.children.eq(lastshowingindex).position(); // set the top position setpositionproperty(-position.top, 'reset', 0); } // if not last slide }else{ // get the position of the first showing slide var position = slider.children.eq(slider.active.index * getmoveby()).position(); // check for last slide if (slider.active.index == getpagerqty() - 1) slider.active.last = true; // set the repective position if (position != undefined){ if (slider.settings.mode == 'horizontal') setpositionproperty(-position.left, 'reset', 0); else if (slider.settings.mode == 'vertical') setpositionproperty(-position.top, 'reset', 0); } } } /** * sets the el's animating property position (which in turn will sometimes animate el). * if using css, sets the transform property. if not using css, sets the top / left property. * * @param value (int) * - the animating property's value * * @param type (string) 'slider', 'reset', 'ticker' * - the type of instance for which the function is being * * @param duration (int) * - the amount of time (in ms) the transition should occupy * * @param params (array) optional * - an optional parameter containing any variables that need to be passed in */ var setpositionproperty = function(value, type, duration, params){ // use css transform if(slider.usingcss){ // determine the translate3d value var propvalue = slider.settings.mode == 'vertical' ? 'translate3d(0, ' + value + 'px, 0)' : 'translate3d(' + value + 'px, 0, 0)'; // add the css transition-duration el.css('-' + slider.cssprefix + '-transition-duration', duration / 1000 + 's'); if(type == 'slide'){ // set the property value el.css(slider.animprop, propvalue); // bind a callback method - executes when css transition completes el.bind('transitionend webkittransitionend otransitionend mstransitionend', function(){ // unbind the callback el.unbind('transitionend webkittransitionend otransitionend mstransitionend'); updateafterslidetransition(); }); }else if(type == 'reset'){ el.css(slider.animprop, propvalue); }else if(type == 'ticker'){ // make the transition use 'linear' el.css('-' + slider.cssprefix + '-transition-timing-function', 'linear'); el.css(slider.animprop, propvalue); // bind a callback method - executes when css transition completes el.bind('transitionend webkittransitionend otransitionend mstransitionend', function(){ // unbind the callback el.unbind('transitionend webkittransitionend otransitionend mstransitionend'); // reset the position setpositionproperty(params['resetvalue'], 'reset', 0); // start the loop again tickerloop(); }); } // use js animate }else{ var animateobj = {}; animateobj[slider.animprop] = value; if(type == 'slide'){ el.animate(animateobj, duration, slider.settings.easing, function(){ updateafterslidetransition(); }); }else if(type == 'reset'){ el.css(slider.animprop, value) }else if(type == 'ticker'){ el.animate(animateobj, speed, 'linear', function(){ setpositionproperty(params['resetvalue'], 'reset', 0); // run the recursive loop after animation tickerloop(); }); } } } /** * populates the pager with proper amount of pages */ var populatepager = function(){ var pagerhtml = ''; var pagerqty = getpagerqty(); // loop through each pager item for(var i=0; i < pagerqty; i++){ var linkcontent = ''; // if a buildpager function is supplied, use it to get pager link value, else use index + 1 if(slider.settings.buildpager && $.isfunction(slider.settings.buildpager)){ linkcontent = slider.settings.buildpager(i); slider.pagerel.addclass('bx-custom-pager'); }else{ linkcontent = i + 1; slider.pagerel.addclass('bx-default-pager'); } // var linkcontent = slider.settings.buildpager && $.isfunction(slider.settings.buildpager) ? slider.settings.buildpager(i) : i + 1; // add the markup to the string pagerhtml += ''; }; // populate the pager element with pager links slider.pagerel.html(pagerhtml); } /** * appends the pager to the controls element */ var appendpager = function(){ if(!slider.settings.pagercustom){ // create the pager dom element slider.pagerel = $('
    '); // if a pager selector was supplied, populate it with the pager if(slider.settings.pagerselector){ $(slider.settings.pagerselector).html(slider.pagerel); // if no pager selector was supplied, add it after the wrapper }else{ slider.controls.el.addclass('bx-has-pager').append(slider.pagerel); } // populate the pager populatepager(); }else{ slider.pagerel = $(slider.settings.pagercustom); } // assign the pager click binding slider.pagerel.on('click', 'a', clickpagerbind); } /** * appends prev / next controls to the controls element */ var appendcontrols = function(){ slider.controls.next = $('' + slider.settings.nexttext + ''); slider.controls.prev = $('' + slider.settings.prevtext + ''); // bind click actions to the controls slider.controls.next.bind('click', clicknextbind); slider.controls.prev.bind('click', clickprevbind); // if nextslector was supplied, populate it if(slider.settings.nextselector){ $(slider.settings.nextselector).append(slider.controls.next); } // if prevslector was supplied, populate it if(slider.settings.prevselector){ $(slider.settings.prevselector).append(slider.controls.prev); } // if no custom selectors were supplied if(!slider.settings.nextselector && !slider.settings.prevselector){ // add the controls to the dom slider.controls.directionel = $('
    '); // add the control elements to the directionel slider.controls.directionel.append(slider.controls.prev).append(slider.controls.next); // slider.viewport.append(slider.controls.directionel); slider.controls.el.addclass('bx-has-controls-direction').append(slider.controls.directionel); } } /** * appends start / stop auto controls to the controls element */ var appendcontrolsauto = function(){ slider.controls.start = $(''); slider.controls.stop = $(''); // add the controls to the dom slider.controls.autoel = $('
    '); // bind click actions to the controls slider.controls.autoel.on('click', '.bx-start', clickstartbind); slider.controls.autoel.on('click', '.bx-stop', clickstopbind); // if autocontrolscombine, insert only the "start" control if(slider.settings.autocontrolscombine){ slider.controls.autoel.append(slider.controls.start); // if autocontrolscombine is false, insert both controls }else{ slider.controls.autoel.append(slider.controls.start).append(slider.controls.stop); } // if auto controls selector was supplied, populate it with the controls if(slider.settings.autocontrolsselector){ $(slider.settings.autocontrolsselector).html(slider.controls.autoel); // if auto controls selector was not supplied, add it after the wrapper }else{ slider.controls.el.addclass('bx-has-controls-auto').append(slider.controls.autoel); } // update the auto controls updateautocontrols(slider.settings.autostart ? 'stop' : 'start'); } /** * appends image captions to the dom */ var appendcaptions = function(){ // cycle through each child slider.children.each(function(index){ // get the image title attribute var title = $(this).find('img:first').attr('title'); // append the caption if (title != undefined && ('' + title).length) { $(this).append('
    ' + title + '
    '); } }); } /** * click next binding * * @param e (event) * - dom event object */ var clicknextbind = function(e){ // if auto show is running, stop it if (slider.settings.auto) el.stopauto(); el.gotonextslide(); e.preventdefault(); } /** * click prev binding * * @param e (event) * - dom event object */ var clickprevbind = function(e){ // if auto show is running, stop it if (slider.settings.auto) el.stopauto(); el.gotoprevslide(); e.preventdefault(); } /** * click start binding * * @param e (event) * - dom event object */ var clickstartbind = function(e){ el.startauto(); e.preventdefault(); } /** * click stop binding * * @param e (event) * - dom event object */ var clickstopbind = function(e){ el.stopauto(); e.preventdefault(); } /** * click pager binding * * @param e (event) * - dom event object */ var clickpagerbind = function(e){ // if auto show is running, stop it if (slider.settings.auto) el.stopauto(); var pagerlink = $(e.currenttarget); if(pagerlink.attr('data-slide-index') !== undefined){ var pagerindex = parseint(pagerlink.attr('data-slide-index')); // if clicked pager link is not active, continue with the gotoslide call if(pagerindex != slider.active.index) el.gotoslide(pagerindex); e.preventdefault(); } } /** * updates the pager links with an active class * * @param slideindex (int) * - index of slide to make active */ var updatepageractive = function(slideindex){ // if "short" pager type var len = slider.children.length; // nb of children if(slider.settings.pagertype == 'short'){ if(slider.settings.maxslides > 1) { len = math.ceil(slider.children.length/slider.settings.maxslides); } slider.pagerel.html( (slideindex + 1) + slider.settings.pagershortseparator + len); return; } // remove all pager active classes slider.pagerel.find('a').removeclass('active'); // apply the active class for all pagers slider.pagerel.each(function(i, el) { $(el).find('a').eq(slideindex).addclass('active'); }); } /** * performs needed actions after a slide transition */ var updateafterslidetransition = function(){ // if infinte loop is true if(slider.settings.infiniteloop){ var position = ''; // first slide if(slider.active.index == 0){ // set the new position position = slider.children.eq(0).position(); // carousel, last slide }else if(slider.active.index == getpagerqty() - 1 && slider.carousel){ position = slider.children.eq((getpagerqty() - 1) * getmoveby()).position(); // last slide }else if(slider.active.index == slider.children.length - 1){ position = slider.children.eq(slider.children.length - 1).position(); } if(position){ if (slider.settings.mode == 'horizontal') { setpositionproperty(-position.left, 'reset', 0); } else if (slider.settings.mode == 'vertical') { setpositionproperty(-position.top, 'reset', 0); } } } // declare that the transition is complete slider.working = false; // onslideafter callback slider.settings.onslideafter(slider.children.eq(slider.active.index), slider.oldindex, slider.active.index); } /** * updates the auto controls state (either active, or combined switch) * * @param state (string) "start", "stop" * - the new state of the auto show */ var updateautocontrols = function(state){ // if autocontrolscombine is true, replace the current control with the new state if(slider.settings.autocontrolscombine){ slider.controls.autoel.html(slider.controls[state]); // if autocontrolscombine is false, apply the "active" class to the appropriate control }else{ slider.controls.autoel.find('a').removeclass('active'); slider.controls.autoel.find('a:not(.bx-' + state + ')').addclass('active'); } } /** * updates the direction controls (checks if either should be hidden) */ var updatedirectioncontrols = function(){ if(getpagerqty() == 1){ slider.controls.prev.addclass('disabled'); slider.controls.next.addclass('disabled'); }else if(!slider.settings.infiniteloop && slider.settings.hidecontrolonend){ // if first slide if (slider.active.index == 0){ slider.controls.prev.addclass('disabled'); slider.controls.next.removeclass('disabled'); // if last slide }else if(slider.active.index == getpagerqty() - 1){ slider.controls.next.addclass('disabled'); slider.controls.prev.removeclass('disabled'); // if any slide in the middle }else{ slider.controls.prev.removeclass('disabled'); slider.controls.next.removeclass('disabled'); } } } /** * initialzes the auto process */ var initauto = function(){ // if autodelay was supplied, launch the auto show using a settimeout() call if(slider.settings.autodelay > 0){ var timeout = settimeout(el.startauto, slider.settings.autodelay); // if autodelay was not supplied, start the auto show normally }else{ el.startauto(); } // if autohover is requested if(slider.settings.autohover){ // on el hover el.hover(function(){ // if the auto show is currently playing (has an active interval) if(slider.interval){ // stop the auto show and pass true agument which will prevent control update el.stopauto(true); // create a new autopaused value which will be used by the relative "mouseout" event slider.autopaused = true; } }, function(){ // if the autopaused value was created be the prior "mouseover" event if(slider.autopaused){ // start the auto show and pass true agument which will prevent control update el.startauto(true); // reset the autopaused value slider.autopaused = null; } }); } } /** * initialzes the ticker process */ var initticker = function(){ var startposition = 0; // if autodirection is "next", append a clone of the entire slider if(slider.settings.autodirection == 'next'){ el.append(slider.children.clone().addclass('bx-clone')); // if autodirection is "prev", prepend a clone of the entire slider, and set the left position }else{ el.prepend(slider.children.clone().addclass('bx-clone')); var position = slider.children.first().position(); startposition = slider.settings.mode == 'horizontal' ? -position.left : -position.top; } setpositionproperty(startposition, 'reset', 0); // do not allow controls in ticker mode slider.settings.pager = false; slider.settings.controls = false; slider.settings.autocontrols = false; // if autohover is requested if(slider.settings.tickerhover && !slider.usingcss){ // on el hover slider.viewport.hover(function(){ el.stop(); }, function(){ // calculate the total width of children (used to calculate the speed ratio) var totaldimens = 0; slider.children.each(function(index){ totaldimens += slider.settings.mode == 'horizontal' ? $(this).outerwidth(true) : $(this).outerheight(true); }); // calculate the speed ratio (used to determine the new speed to finish the paused animation) var ratio = slider.settings.speed / totaldimens; // determine which property to use var property = slider.settings.mode == 'horizontal' ? 'left' : 'top'; // calculate the new speed var newspeed = ratio * (totaldimens - (math.abs(parseint(el.css(property))))); tickerloop(newspeed); }); } // start the ticker loop tickerloop(); } /** * runs a continuous loop, news ticker-style */ var tickerloop = function(resumespeed){ speed = resumespeed ? resumespeed : slider.settings.speed; var position = {left: 0, top: 0}; var reset = {left: 0, top: 0}; // if "next" animate left position to last child, then reset left to 0 if(slider.settings.autodirection == 'next'){ position = el.find('.bx-clone').first().position(); // if "prev" animate left position to 0, then reset left to first non-clone child }else{ reset = slider.children.first().position(); } var animateproperty = slider.settings.mode == 'horizontal' ? -position.left : -position.top; var resetvalue = slider.settings.mode == 'horizontal' ? -reset.left : -reset.top; var params = {resetvalue: resetvalue}; setpositionproperty(animateproperty, 'ticker', speed, params); } /** * initializes touch events */ var inittouch = function(){ // initialize object to contain all touch values slider.touch = { start: {x: 0, y: 0}, end: {x: 0, y: 0} } slider.viewport.bind('touchstart', ontouchstart); } /** * event handler for "touchstart" * * @param e (event) * - dom event object */ var ontouchstart = function(e){ if(slider.working){ e.preventdefault(); }else{ // record the original position when touch starts slider.touch.originalpos = el.position(); var orig = e.originalevent; // record the starting touch x, y coordinates slider.touch.start.x = orig.changedtouches[0].pagex; slider.touch.start.y = orig.changedtouches[0].pagey; // bind a "touchmove" event to the viewport slider.viewport.bind('touchmove', ontouchmove); // bind a "touchend" event to the viewport slider.viewport.bind('touchend', ontouchend); } } /** * event handler for "touchmove" * * @param e (event) * - dom event object */ var ontouchmove = function(e){ var orig = e.originalevent; // if scrolling on y axis, do not prevent default var xmovement = math.abs(orig.changedtouches[0].pagex - slider.touch.start.x); var ymovement = math.abs(orig.changedtouches[0].pagey - slider.touch.start.y); // x axis swipe if((xmovement * 3) > ymovement && slider.settings.preventdefaultswipex){ e.preventdefault(); // y axis swipe }else if((ymovement * 3) > xmovement && slider.settings.preventdefaultswipey){ e.preventdefault(); } if(slider.settings.mode != 'fade' && slider.settings.onetoonetouch){ var value = 0; // if horizontal, drag along x axis if(slider.settings.mode == 'horizontal'){ var change = orig.changedtouches[0].pagex - slider.touch.start.x; value = slider.touch.originalpos.left + change; // if vertical, drag along y axis }else{ var change = orig.changedtouches[0].pagey - slider.touch.start.y; value = slider.touch.originalpos.top + change; } setpositionproperty(value, 'reset', 0); } } /** * event handler for "touchend" * * @param e (event) * - dom event object */ var ontouchend = function(e){ slider.viewport.unbind('touchmove', ontouchmove); var orig = e.originalevent; var value = 0; // record end x, y positions slider.touch.end.x = orig.changedtouches[0].pagex; slider.touch.end.y = orig.changedtouches[0].pagey; // if fade mode, check if absolute x distance clears the threshold if(slider.settings.mode == 'fade'){ var distance = math.abs(slider.touch.start.x - slider.touch.end.x); if(distance >= slider.settings.swipethreshold){ slider.touch.start.x > slider.touch.end.x ? el.gotonextslide() : el.gotoprevslide(); el.stopauto(); } // not fade mode }else{ var distance = 0; // calculate distance and el's animate property if(slider.settings.mode == 'horizontal'){ distance = slider.touch.end.x - slider.touch.start.x; value = slider.touch.originalpos.left; }else{ distance = slider.touch.end.y - slider.touch.start.y; value = slider.touch.originalpos.top; } // if not infinite loop and first / last slide, do not attempt a slide transition if(!slider.settings.infiniteloop && ((slider.active.index == 0 && distance > 0) || (slider.active.last && distance < 0))){ setpositionproperty(value, 'reset', 200); }else{ // check if distance clears threshold if(math.abs(distance) >= slider.settings.swipethreshold){ distance < 0 ? el.gotonextslide() : el.gotoprevslide(); el.stopauto(); }else{ // el.animate(property, 200); setpositionproperty(value, 'reset', 200); } } } slider.viewport.unbind('touchend', ontouchend); } /** * window resize event callback */ var resizewindow = function(e){ // don't do anything if slider isn't initialized. if(!slider.initialized) return; // get the new window dimens (again, thank you ie) var windowwidthnew = $(window).width(); var windowheightnew = $(window).height(); // make sure that it is a true window resize // *we must check this because our dinosaur friend ie fires a window resize event when certain dom elements // are resized. can you just die already?* if(windowwidth != windowwidthnew || windowheight != windowheightnew){ // set the new window dimens windowwidth = windowwidthnew; windowheight = windowheightnew; // update all dynamic elements el.redrawslider(); // call user resize handler slider.settings.onsliderresize.call(el, slider.active.index); } } /** * =================================================================================== * = public functions * =================================================================================== */ /** * performs slide transition to the specified slide * * @param slideindex (int) * - the destination slide's index (zero-based) * * @param direction (string) * - internal use only - the direction of travel ("prev" / "next") */ el.gotoslide = function(slideindex, direction){ // if plugin is currently in motion, ignore request if(slider.working || slider.active.index == slideindex) return; // declare that plugin is in motion slider.working = true; // store the old index slider.oldindex = slider.active.index; // if slideindex is less than zero, set active index to last child (this happens during infinite loop) if(slideindex < 0){ slider.active.index = getpagerqty() - 1; // if slideindex is greater than children length, set active index to 0 (this happens during infinite loop) }else if(slideindex >= getpagerqty()){ slider.active.index = 0; // set active index to requested slide }else{ slider.active.index = slideindex; } // onslidebefore, onslidenext, onslideprev callbacks slider.settings.onslidebefore(slider.children.eq(slider.active.index), slider.oldindex, slider.active.index); if(direction == 'next'){ slider.settings.onslidenext(slider.children.eq(slider.active.index), slider.oldindex, slider.active.index); }else if(direction == 'prev'){ slider.settings.onslideprev(slider.children.eq(slider.active.index), slider.oldindex, slider.active.index); } // check if last slide slider.active.last = slider.active.index >= getpagerqty() - 1; // update the pager with active class if(slider.settings.pager) updatepageractive(slider.active.index); // // check for direction control update if(slider.settings.controls) updatedirectioncontrols(); // if slider is set to mode: "fade" if(slider.settings.mode == 'fade'){ // if adaptiveheight is true and next height is different from current height, animate to the new height if(slider.settings.adaptiveheight && slider.viewport.height() != getviewportheight()){ slider.viewport.animate({height: getviewportheight()}, slider.settings.adaptiveheightspeed); } // fade out the visible child and reset its z-index value slider.children.filter(':visible').fadeout(slider.settings.speed).css({zindex: 0}); // fade in the newly requested slide slider.children.eq(slider.active.index).css('zindex', slider.settings.slidezindex+1).fadein(slider.settings.speed, function(){ $(this).css('zindex', slider.settings.slidezindex); updateafterslidetransition(); }); // slider mode is not "fade" }else{ // if adaptiveheight is true and next height is different from current height, animate to the new height if(slider.settings.adaptiveheight && slider.viewport.height() != getviewportheight()){ slider.viewport.animate({height: getviewportheight()}, slider.settings.adaptiveheightspeed); } var moveby = 0; var position = {left: 0, top: 0}; // if carousel and not infinite loop if(!slider.settings.infiniteloop && slider.carousel && slider.active.last){ if(slider.settings.mode == 'horizontal'){ // get the last child position var lastchild = slider.children.eq(slider.children.length - 1); position = lastchild.position(); // calculate the position of the last slide moveby = slider.viewport.width() - lastchild.outerwidth(); }else{ // get last showing index position var lastshowingindex = slider.children.length - slider.settings.minslides; position = slider.children.eq(lastshowingindex).position(); } // horizontal carousel, going previous while on first slide (infiniteloop mode) }else if(slider.carousel && slider.active.last && direction == 'prev'){ // get the last child position var eq = slider.settings.moveslides == 1 ? slider.settings.maxslides - getmoveby() : ((getpagerqty() - 1) * getmoveby()) - (slider.children.length - slider.settings.maxslides); var lastchild = el.children('.bx-clone').eq(eq); position = lastchild.position(); // if infinite loop and "next" is clicked on the last slide }else if(direction == 'next' && slider.active.index == 0){ // get the last clone position position = el.find('> .bx-clone').eq(slider.settings.maxslides).position(); slider.active.last = false; // normal non-zero requests }else if(slideindex >= 0){ var requestel = slideindex * getmoveby(); position = slider.children.eq(requestel).position(); } /* if the position doesn't exist * (e.g. if you destroy the slider on a next click), * it doesn't throw an error. */ if ("undefined" !== typeof(position)) { var value = slider.settings.mode == 'horizontal' ? -(position.left - moveby) : -position.top; // plugin values to be animated setpositionproperty(value, 'slide', slider.settings.speed); } } } /** * transitions to the next slide in the show */ el.gotonextslide = function(){ // if infiniteloop is false and last page is showing, disregard call if (!slider.settings.infiniteloop && slider.active.last) return; var pagerindex = parseint(slider.active.index) + 1; el.gotoslide(pagerindex, 'next'); } /** * transitions to the prev slide in the show */ el.gotoprevslide = function(){ // if infiniteloop is false and last page is showing, disregard call if (!slider.settings.infiniteloop && slider.active.index == 0) return; var pagerindex = parseint(slider.active.index) - 1; el.gotoslide(pagerindex, 'prev'); } /** * starts the auto show * * @param preventcontrolupdate (boolean) * - if true, auto controls state will not be updated */ el.startauto = function(preventcontrolupdate){ // if an interval already exists, disregard call if(slider.interval) return; // create an interval slider.interval = setinterval(function(){ slider.settings.autodirection == 'next' ? el.gotonextslide() : el.gotoprevslide(); }, slider.settings.pause); // if auto controls are displayed and preventcontrolupdate is not true if (slider.settings.autocontrols && preventcontrolupdate != true) updateautocontrols('stop'); } /** * stops the auto show * * @param preventcontrolupdate (boolean) * - if true, auto controls state will not be updated */ el.stopauto = function(preventcontrolupdate){ // if no interval exists, disregard call if(!slider.interval) return; // clear the interval clearinterval(slider.interval); slider.interval = null; // if auto controls are displayed and preventcontrolupdate is not true if (slider.settings.autocontrols && preventcontrolupdate != true) updateautocontrols('start'); } /** * returns current slide index (zero-based) */ el.getcurrentslide = function(){ return slider.active.index; } /** * returns current slide element */ el.getcurrentslideelement = function(){ return slider.children.eq(slider.active.index); } /** * returns number of slides in show */ el.getslidecount = function(){ return slider.children.length; } /** * update all dynamic slider elements */ el.redrawslider = function(){ // resize all children in ratio to new screen size slider.children.add(el.find('.bx-clone')).width(getslidewidth()); // adjust the height slider.viewport.css('height', getviewportheight()); //console.log( getviewportheight() ); // update the slide position if(!slider.settings.ticker) setslideposition(); // if active.last was true before the screen resize, we want // to keep it last no matter what screen size we end on if (slider.active.last) slider.active.index = getpagerqty() - 1; // if the active index (page) no longer exists due to the resize, simply set the index as last if (slider.active.index >= getpagerqty()) slider.active.last = true; // if a pager is being displayed and a custom pager is not being used, update it if(slider.settings.pager && !slider.settings.pagercustom){ populatepager(); updatepageractive(slider.active.index); } } /** * destroy the current instance of the slider (revert everything back to original state) */ el.destroyslider = function(){ // don't do anything if slider has already been destroyed if(!slider.initialized) return; slider.initialized = false; $('.bx-clone', this).remove(); slider.children.each(function() { $(this).data("origstyle") != undefined ? $(this).attr("style", $(this).data("origstyle")) : $(this).removeattr('style'); }); $(this).data("origstyle") != undefined ? this.attr("style", $(this).data("origstyle")) : $(this).removeattr('style'); $(this).unwrap().unwrap(); if(slider.controls.el) slider.controls.el.remove(); if(slider.controls.next) slider.controls.next.remove(); if(slider.controls.prev) slider.controls.prev.remove(); if(slider.pagerel && slider.settings.controls) slider.pagerel.remove(); $('.bx-caption', this).remove(); if(slider.controls.autoel) slider.controls.autoel.remove(); clearinterval(slider.interval); if(slider.settings.responsive) $(window).unbind('resize', resizewindow); } /** * reload the slider (revert all dom changes, and re-initialize) */ el.reloadslider = function(settings){ if (settings != undefined) options = settings; el.destroyslider(); init(); } init(); // returns the current jquery object return this; } })(jquery); /*bxslider end*/