forked from helga-sida/roundabout
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathjquery.roundabout.min.js
41 lines (41 loc) · 23.3 KB
/
jquery.roundabout.min.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
/**
* jQuery Roundabout - v2.4.2
* http://fredhq.com/projects/roundabout
*
* Moves list-items of enabled ordered and unordered lists long
* a chosen path. Includes the default "lazySusan" path, that
* moves items long a spinning turntable.
*
* Terms of Use // jQuery Roundabout
*
* Open source under the BSD license
*
* Copyright (c) 2011-2012, Fred LeBlanc
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* - Neither the name of the author nor the names of its contributors
* may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
(function(e){"use strict";var t,n,r,i=0,s=1,o=2,u=25,a=100,f=0,l={keyframes:"keyframes",animation:"animation",transform:"transform"},c=false;e.extend({roundaboutShapes:{def:"lazySusan",lazySusan:function(e,t,n){return{x:Math.sin(e+t),y:Math.sin(e+3*Math.PI/2+t)/8*n,z:(Math.cos(e+t)+1)/2,scale:Math.sin(e+Math.PI/2+t)/2+.5}}}});t={bearing:0,tilt:0,minZ:100,maxZ:280,minOpacity:.4,maxOpacity:1,minScale:.4,maxScale:1,duration:600,btnNext:null,btnNextCallback:function(){},btnPrev:null,btnPrevCallback:function(){},btnToggleAutoplay:null,btnStartAutoplay:null,btnStopAutoplay:null,easing:"swing",clickToFocus:true,clickToFocusCallback:function(){},focusBearing:0,shape:"lazySusan",debug:false,childSelector:"li",startingChild:null,reflect:false,floatComparisonThreshold:.001,autoplay:false,autoplayDuration:1e3,autoplayPauseOnHover:false,autoplayCallback:function(){},autoplayInitialDelay:0,enableDrag:false,dropDuration:600,dropEasing:"swing",dropAnimateTo:"nearest",dropCallback:function(){},dragAxis:"x",dragFactor:4,triggerFocusEvents:true,triggerBlurEvents:true,responsive:false,useCssAnimation:false,prefix:"",btnsPager:null};n={autoplayInterval:null,autoplayIsRunning:false,autoplayStartTimeout:null,animating:false,childInFocus:-1,touchMoveStartPosition:null,stopAnimation:false,lastAnimationStep:false,skipNextAnimation:0,childrenMaxCount:0,showPrev:false};r={init:function(i,s,o){var u,a=false,h=(new Date).getTime(),p=(Math.random()*100).toFixed(0);i=typeof i==="object"?i:{};s=e.isFunction(s)?s:function(){};s=e.isFunction(i)?i:s;u=e.extend({},t,i,n);if(u.useCssAnimation===true){a=true}else if(u.useCssAnimation==="auto"){if(!("Modernizr"in window)){console.error('You must include Modernizr library to use \'useCssAnimation: "auto"\' option. Resetting to "false".')}else if(Modernizr.csstransforms&&Modernizr.csstransitions&&Modernizr.cssanimations){a=true}}if(u.prefix===""){u.prefix=f;f++}return this.each(function(){var t=e(this),n=t.children(u.childSelector).length,i=360/n,f=u.startingChild&&u.startingChild>n-1?n-1:u.startingChild,h=u.startingChild===null?u.bearing:360-f*i,p=t.css("position")!=="static"?t.css("position"):"relative",d=this.style,v;if(!c){v=r.getVendorPropName(d,"animation");for(var m in l){l[m]=v+l[m]}c=true}t.css({padding:0,position:p}).addClass("roundabout-holder").data("roundabout",e.extend({},u,{startingChild:f,bearing:h,oppositeOfFocusBearing:r.normalize.apply(null,[u.focusBearing-180]),dragBearing:h,period:i,supportCSSAnimation:a,showPrev:false}));if(o){t.unbind(".roundabout").children(u.childSelector).unbind(".roundabout")}else{if(u.responsive){e(window).bind("resize",function(){r.stopAutoplay.apply(t);r.relayoutChildren.apply(t)})}}if(u.clickToFocus){t.children(u.childSelector).each(function(n){e(this).bind("click.roundabout",function(){r.showListElement.apply(t,[n])})})}if(u.btnNext){e(u.btnNext).bind("click.roundabout",function(){if(!t.data("roundabout").animating){r.animateToNextChild.apply(t,[t.data("roundabout").btnNextCallback])}return false})}if(u.btnPrev){e(u.btnPrev).bind("click.roundabout",function(){r.animateToPreviousChild.apply(t,[t.data("roundabout").btnPrevCallback]);return false})}if(u.btnToggleAutoplay){e(u.btnToggleAutoplay).bind("click.roundabout",function(){r.toggleAutoplay.apply(t);return false})}if(u.btnStartAutoplay){e(u.btnStartAutoplay).bind("click.roundabout",function(){r.startAutoplay.apply(t);return false})}if(u.btnStopAutoplay){e(u.btnStopAutoplay).bind("click.roundabout",function(){r.stopAutoplay.apply(t);return false})}if(u.btnsPager){var g=t.parent().find(u.btnsPager);if(g.size()===0){console.error("Can't find pager elements.")}else{g.bind("click.roundabout",function(){var n=e(this).index();r.showElementByPager.apply(t,[n]);return false})}}if(u.autoplayPauseOnHover){t.bind("mouseenter.roundabout.autoplay",function(){r.stopAutoplay.apply(t,[true])}).bind("mouseleave.roundabout.autoplay",function(){r.startAutoplay.apply(t)})}if(u.enableDrag){if(!e.isFunction(t.drag)){if(u.debug){alert("You do not have the drag plugin loaded.")}}else if(!e.isFunction(t.drop)){if(u.debug){alert("You do not have the drop plugin loaded.")}}else{t.drag(function(e,n){var i=t.data("roundabout"),s=i.dragAxis.toLowerCase()==="x"?"deltaX":"deltaY";r.stopAnimation.apply(t);r.setBearing.apply(t,[i.dragBearing+n[s]/i.dragFactor])}).drop(function(e){var n=t.data("roundabout"),i=r.getAnimateToMethod(n.dropAnimateTo);r.allowAnimation.apply(t);r[i].apply(t,[n.dropDuration,n.dropEasing,n.dropCallback]);n.dragBearing=n.period*r.getNearestChild.apply(t)})}t.each(function(){var t=e(this).get(0),n=e(this).data("roundabout"),i=n.dragAxis.toLowerCase()==="x"?"pageX":"pageY",s=r.getAnimateToMethod(n.dropAnimateTo);if(t.addEventListener){t.addEventListener("touchstart",function(e){n.touchMoveStartPosition=e.touches[0][i]},false);t.addEventListener("touchmove",function(t){var s=(t.touches[0][i]-n.touchMoveStartPosition)/n.dragFactor;t.preventDefault();r.stopAnimation.apply(e(this));r.setBearing.apply(e(this),[n.dragBearing+s])},false);t.addEventListener("touchend",function(t){t.preventDefault();r.allowAnimation.apply(e(this));s=r.getAnimateToMethod(n.dropAnimateTo);r[s].apply(e(this),[n.dropDuration,n.dropEasing,n.dropCallback]);n.dragBearing=n.period*r.getNearestChild.apply(e(this))},false)}})}r.initChildren.apply(t,[s,o])})},initChildren:function(t,n){var i=e(this),s=i.data("roundabout");t=t||function(){};i.children(s.childSelector).each(function(t){var s,o,u,a=r.getPlacement.apply(i,[t]);if(n&&e(this).data("roundabout")){s=e(this).data("roundabout").startWidth;o=e(this).data("roundabout").startHeight;u=e(this).data("roundabout").startFontSize}e(this).addClass("roundabout-moveable-item").css("position","absolute");e(this).data("roundabout",{startWidth:s||e(this).width(),startHeight:o||e(this).height(),startFontSize:u||parseInt(e(this).css("font-size"),10),degrees:a,backDegrees:r.normalize.apply(null,[a-180]),childNumber:t,currentScale:1,parent:i,isFirstReposition:true,isFirstAnimation:true})});r.updateChildren.apply(i);if(s.autoplay){s.autoplayStartTimeout=setTimeout(function(){r.startAutoplay.apply(i)},s.autoplayInitialDelay)}if(s.supportCSSAnimation){r.createStyles.apply(i)}i.trigger("ready");t.apply(i);return i},generateKeyframesInfo:function(){var t=r.getInfo.apply(this),n,i=this.children(),s=i.length,o=i.data("roundabout"),a=0,f=s*(u+1),c=2*Math.PI/f,h=[],p;for(var d=0;d<f;d++){n=t.shape(a,t.focusBearingRadian,t.tilt);n.scale=n.scale>1?1:n.scale;n.adjustedScale=(t.scale.min+t.scale.diff*n.scale).toFixed(4);n.width=(n.adjustedScale*o.startWidth).toFixed(4);n.height=(n.adjustedScale*o.startHeight).toFixed(4);p={left:(n.x*t.midStage.width+t.nudge.width-n.width/2/n.adjustedScale).toFixed(0)+"px",top:(n.y*t.midStage.height+t.nudge.height-n.height/2/n.adjustedScale).toFixed(0)+"px",opacity:(t.opacity.min+t.opacity.diff*n.scale).toFixed(2),"z-index":Math.round(t.zValues.min+t.zValues.diff*n.z),position:"absolute"};p[l.transform]="scale("+n.adjustedScale+","+n.adjustedScale+")";h.push(p);a=a+c}e(this).data("roundabout").childrenMaxCount=s-1;return h},createStyles:function(){var t=r.generateKeyframesInfo.apply(this),n="",i,s=a/(u+1),o=0,f=e(this).children(),c=f.eq(0).outerWidth(false)+"px",h=f.eq(0).outerHeight(false)+"px",p=e(this).data("roundabout"),d=p.duration/1e3,v=1,m=p.childrenMaxCount,g=p.prefix,y=m,b=0,w,E;for(var S=0;S<=m;S++){i=0;e(f[S]).css(t[b]);n=n+"@"+l.keyframes+" roundaboutAnimation"+g+"_"+S+"{";for(o;o<(S+1)*(u+2);o++){n=n+i.toFixed(0)+"%"+r.objToString(t[b]);i=i+s;b++;if(b==t.length){b=0}}b--;n=n+"}";n=n+".position"+g+"_"+v+"{"+l.animation+":roundaboutAnimation"+g+"_"+S+" "+d+"s;"+l.animation+"-timing-function:linear;"+"width:"+c+";"+l.transform+":"+t[b][l.transform]+";height:"+h+";top:"+t[b].top+";left:"+t[b].left+";position: absolute;opacity:"+t[b].opacity+";z-index:"+t[b]["z-index"]+";}";if(v==m){v=0}else{v++}}b=0;o=u+2;var x=m;for(var S=0;S<=m;S++){i=0;if(x>m){x=0}n=n+"@"+l.keyframes+" roundaboutAnimationNext"+g+"_"+x+"{";x++;for(o=u+2;o>0;o--){n=n+i.toFixed(0)+"%"+r.objToString(t[b]);i=i+s;if(b===0){b=t.length-1}else{b--}}n=n+"}";y=m-S-1;if(y<0){y=m}var T=b-u;if(x>m){x=0}w=b-u;n=n+".positionNext"+g+"_"+y+"{"+l.animation+":roundaboutAnimationNext"+g+"_"+x+" "+d+"s;"+l.animation+"-timing-function:linear;width:"+c+";"+l.transform+":"+t[w][l.transform]+";height:"+h+";top:"+t[w].top+";left:"+t[w].left+";position: absolute;opacity:"+t[w].opacity+";z-index:"+t[w]["z-index"]+";}";b++}E=e("<style>",{text:n,id:"animation-styles"+g});if(e("head").size()>0){E=e("head")}else{E=e(this)}E.append(e("<style>",{text:n,id:"animation-styles"+g}))},getInfo:function(){var t=e(this),n=t.data("roundabout"),i=-1,s={bearing:n.bearing,tilt:n.tilt,stage:{width:Math.floor(e(this).width()*.9),height:Math.floor(e(this).height()*.9)},animating:n.animating,inFocus:n.childInFocus,focusBearingRadian:r.degToRad.apply(null,[n.focusBearing]),shape:e.roundaboutShapes[n.shape]||e.roundaboutShapes[e.roundaboutShapes.def]};s.midStage={width:s.stage.width/2,height:s.stage.height/2};s.nudge={width:s.midStage.width+s.stage.width*.05,height:s.midStage.height+s.stage.height*.05};s.zValues={min:n.minZ,max:n.maxZ,diff:n.maxZ-n.minZ};s.opacity={min:n.minOpacity,max:n.maxOpacity,diff:n.maxOpacity-n.minOpacity};s.scale={min:n.minScale,max:n.maxScale,diff:n.maxScale-n.minScale};return s},updateChildren:function(){return this.each(function(){var t=e(this),n=t.data("roundabout"),i=-1,s=r.getInfo.apply(t);t.children(n.childSelector).each(function(o){if(r.updateChild.apply(t,[e(this),s,o,function(){e(this).trigger("ready")}])&&(!s.animating||n.lastAnimationStep)){i=o;e(this).addClass("roundabout-in-focus")}else{e(this).removeClass("roundabout-in-focus")}});if(i!==s.inFocus){if(n.triggerBlurEvents){t.children(n.childSelector).eq(s.inFocus).trigger("blur")}n.childInFocus=i;if(n.triggerFocusEvents&&i!==-1){t.children(n.childSelector).eq(i).trigger("focus")}}t.trigger("childrenUpdated")})},updateChild:function(t,n,i,s){var o,u=this,a=e(t),f=a.data("roundabout"),l=[],c=r.degToRad.apply(null,[360-f.degrees+n.bearing]),h,p,d=this.data("roundabout");if(d.supportCSSAnimation){if(f.isFirstReposition){f.isFirstReposition=false}else{if(!f.isFirstAnimation){a.removeClass(function(){var e="",t=this.className.split(" ");for(var n=0;n<t.length;n++){if(/_(\d+)/g.test(t[n])){e+=t[n]+" ";h=parseInt(t[n].match(/(\d+)([^\w\d]+|$)/g),10)}}return e})}else{a.removeAttr("style");f.isFirstAnimation=false;h=i}if(f.showPrev){p=h+1;if(p>d.childrenMaxCount){p=0}a.addClass("position"+d.prefix+"_"+p);f.showPrev=false}else{p=h-1;if(p==-1){p=d.childrenMaxCount}a.addClass("positionNext"+d.prefix+"_"+p)}}}else{s=s||function(){};c=r.normalizeRad.apply(null,[c]);o=n.shape(c,n.focusBearingRadian,n.tilt);o.scale=o.scale>1?1:o.scale;o.adjustedScale=(n.scale.min+n.scale.diff*o.scale).toFixed(4);o.width=(o.adjustedScale*f.startWidth).toFixed(4);o.height=(o.adjustedScale*f.startHeight).toFixed(4);a.css({left:(o.x*n.midStage.width+n.nudge.width-o.width/2).toFixed(0)+"px",top:(o.y*n.midStage.height+n.nudge.height-o.height/2).toFixed(0)+"px",width:o.width+"px",height:o.height+"px",opacity:(n.opacity.min+n.opacity.diff*o.scale).toFixed(2),zIndex:Math.round(n.zValues.min+n.zValues.diff*o.z),fontSize:(o.adjustedScale*f.startFontSize).toFixed(1)+"px"});f.currentScale=o.adjustedScale}if(u.data("roundabout").debug){l.push('<div style="font-weight: normal; font-size: 10px; padding: 2px; width: '+a.css("width")+'; background-color: #ffc;">');l.push('<strong style="font-size: 12px; white-space: nowrap;">Child '+i+"</strong><br />");if(this.data("roundabout").supportCSSAnimation){l.push("<strong>Use CSS3:</strong> false <br />");l.push("<strong>width:</strong> "+a.css("width")+"<br />");l.push("<strong>height:</strong> "+a.css("height")+"<br />");l.push("<strong>font-size:</strong> "+a.css("font-size")+"<br />")}else{l.push("<strong>Use CSS3:</strong> true <br />")}l.push("<strong>left:</strong> "+a.css("left")+"<br />");l.push("<strong>top:</strong> "+a.css("top")+"<br />");l.push("<strong>opacity:</strong> "+a.css("opacity")+"<br />");l.push("<strong>z-index:</strong> "+a.css("z-index")+"<br />");l.push("<strong>scale:</strong> "+a.data("roundabout").currentScale);l.push("</div>");a.html(l.join(""))}a.trigger("reposition");s.apply(u);return r.isInFocus.apply(u,[f.degrees])},setBearing:function(t,n){n=n||function(){};t=r.normalize.apply(null,[t]);this.each(function(){var n,i,s,o=e(this),u=o.data("roundabout"),a=u.bearing;u.bearing=t;o.trigger("bearingSet");r.updateChildren.apply(o);n=Math.abs(a-t);if(!u.animating||n>180){return}n=Math.abs(a-t);o.children(u.childSelector).each(function(n){var i;if(r.isChildBackDegreesBetween.apply(e(this),[t,a])){i=a>t?"Clockwise":"Counterclockwise";e(this).trigger("move"+i+"ThroughBack")}})});n.apply(this);return this},adjustBearing:function(t,n){n=n||function(){};if(t===0){return this}this.each(function(){r.setBearing.apply(e(this),[e(this).data("roundabout").bearing+t])});n.apply(this);return this},setTilt:function(t,n){n=n||function(){};this.each(function(){e(this).data("roundabout").tilt=t;r.updateChildren.apply(e(this))});n.apply(this);return this},adjustTilt:function(t,n){n=n||function(){};this.each(function(){r.setTilt.apply(e(this),[e(this).data("roundabout").tilt+t])});n.apply(this);return this},animateToBearing:function(t,n,u,a,f){var l=(new Date).getTime();f=f||function(){};if(e.isFunction(a)){f=a;a=null}else if(e.isFunction(u)){f=u;u=null}else if(e.isFunction(n)){f=n;n=null}this.each(function(){var c,h,p,d=e(this),v=d.data("roundabout"),m=!n?v.duration:n,g=u?u:v.easing||"swing";if(!a){a={timerStart:l,start:v.bearing,totalTime:m}}c=l-a.timerStart;if(v.skipNextAnimation==o&&v.supportCSSAnimation){v.skipNextAnimation=i;return}else if(v.skipNextAnimation==s&&v.supportCSSAnimation){v.skipNextAnimation=v.skipNextAnimation+1}if(v.stopAnimation){r.allowAnimation.apply(d);v.animating=false;return}if(c<m&&!v.supportCSSAnimation){if(!v.animating){d.trigger("animationStart")}v.animating=true;if(typeof e.easing.def==="string"){h=e.easing[g]||e.easing[e.easing.def];p=h(null,c,a.start,t-a.start,a.totalTime)}else{p=e.easing[g](c/a.totalTime,c,a.start,t-a.start,a.totalTime)}if(r.compareVersions.apply(null,[e().jquery,"1.7.2"])>=0&&!e.easing["easeOutBack"]){p=a.start+(t-a.start)*p}p=r.normalize.apply(null,[p]);v.dragBearing=p;r.setBearing.apply(d,[p,function(){setTimeout(function(){r.animateToBearing.apply(d,[t,m,g,a,f])},0)}])}else{v.lastAnimationStep=true;t=r.normalize.apply(null,[t]);r.setBearing.apply(d,[t,function(){d.trigger("animationEnd")}]);v.animating=false;v.lastAnimationStep=false;v.dragBearing=t;f.apply(d)}});return this},animateToNearbyChild:function(t,n){var i=t[0],s=t[1],o=t[2]||function(){};if(e.isFunction(s)){o=s;s=null}else if(e.isFunction(i)){o=i;i=null}return this.each(function(){var t,u,a=e(this),f=a.data("roundabout"),l=!f.reflect?f.bearing%360:f.bearing,c=a.children(f.childSelector).length;if(!f.animating){if(f.reflect&&n==="previous"||!f.reflect&&n==="next"){l=Math.abs(l)<f.floatComparisonThreshold?360:l;for(t=0;t<c;t+=1){u={lower:f.period*t,upper:f.period*(t+1)};u.upper=t===c-1?360:u.upper;if(l<=Math.ceil(u.upper)&&l>=Math.floor(u.lower)){if(c===2&&l===360){r.animateToDelta.apply(a,[-180,i,s,o])}else{r.animateBearingToFocus.apply(a,[u.lower,i,s,o])}break}}}else{l=Math.abs(l)<f.floatComparisonThreshold||360-Math.abs(l)<f.floatComparisonThreshold?0:l;for(t=c-1;t>=0;t-=1){u={lower:f.period*t,upper:f.period*(t+1)};u.upper=t===c-1?360:u.upper;if(l>=Math.floor(u.lower)&&l<Math.ceil(u.upper)){if(c===2&&l===360){r.animateToDelta.apply(a,[180,i,s,o])}else{r.animateBearingToFocus.apply(a,[u.upper,i,s,o])}break}}}}})},animateToNearestChild:function(t,n,i){i=i||function(){};if(e.isFunction(n)){i=n;n=null}else if(e.isFunction(t)){i=t;t=null}return this.each(function(){var s=r.getNearestChild.apply(e(this));r.animateToChild.apply(e(this),[s,t,n,i])})},animateToChild:function(t,n,i,s){s=s||function(){};if(e.isFunction(i)){s=i;i=null}else if(e.isFunction(n)){s=n;n=null}return this.each(function(){var o,u=e(this),a=u.data("roundabout");if(a.childInFocus!==t&&!a.animating){o=u.children(a.childSelector).eq(t);r.animateBearingToFocus.apply(u,[o.data("roundabout").degrees,n,i,s])}})},animateToNextChild:function(e,t,n){return r.animateToNearbyChild.apply(this,[arguments,"next"])},animateToPreviousChild:function(e,t,n){return r.animateToNearbyChild.apply(this,[arguments,"previous"])},animateToDelta:function(t,n,i,s){s=s||function(){};if(e.isFunction(i)){s=i;i=null}else if(e.isFunction(n)){s=n;n=null}return this.each(function(){var o=e(this).data("roundabout").bearing+t;r.animateToBearing.apply(e(this),[o,n,i,s])})},animateBearingToFocus:function(t,n,i,s){s=s||function(){};if(e.isFunction(i)){s=i;i=null}else if(e.isFunction(n)){s=n;n=null}return this.each(function(){var o=e(this).data("roundabout").bearing-t;o=Math.abs(360-o)<Math.abs(o)?360-o:-o;o=o>180?-(360-o):o;if(o!==0){r.animateToDelta.apply(e(this),[o,n,i,s])}})},showElementByPager:function(t){var n=e(this);if(e(this).data("roundabout").useCssAnimation){var i=t,s=n.find(".roundabout-in-focus").index(),o=n.children(e(this).data("roundabout").childSelector),u=i-s,a=e(this).data("roundabout").childrenMaxCount-1,f,l,c=e(this).data("roundabout").duration;if(u>1&&u<=a){f=function(){if(s>i){clearInterval(l)}else{r.showListElement.apply(n,[s]);s++}};f();l=setInterval(f,c)}else if(u<-1&&u>=-a){f=function(){if(s<i){clearInterval(l)}else{r.showListElement.apply(n,[s]);s--}};f();l=setInterval(f,c)}else{r.showListElement.apply(n,[i])}}else{r.showListElement.apply(n,[t])}},showListElement:function(t){var n=this,i=r.getPlacement.apply(n,[t]),s=n.children(n.data("roundabout")).eq(t),o=n.find(".roundabout-in-focus").index(),u=o-t,a=n.data("roundabout").supportCSSAnimation,f=n.data("roundabout").childrenMaxCount;if((u>0||u===-f)&&a&&u!==f){n.children(n.data("roundabout")).each(function(){e(this).data("roundabout").showPrev=true})}if(!r.isInFocus.apply(n,[i])){r.stopAnimation.apply(s);if(!n.data("roundabout").animating){r.animateBearingToFocus.apply(n,[i,n.data("roundabout").clickToFocusCallback])}return false}},stopAnimation:function(){return this.each(function(){var t=e(this),n=t.parent().data("roundabout");if(n.supportCSSAnimation){n.skipNextAnimation=s}t.data("roundabout").stopAnimation=true})},allowAnimation:function(){return this.each(function(){e(this).data("roundabout").stopAnimation=false})},startAutoplay:function(t){return this.each(function(){var n=e(this),i=n.data("roundabout");t=t||i.autoplayCallback||function(){};clearInterval(i.autoplayInterval);i.autoplayInterval=setInterval(function(){r.animateToNextChild.apply(n,[t])},i.autoplayDuration);i.autoplayIsRunning=true;n.trigger("autoplayStart")})},stopAutoplay:function(t){return this.each(function(){clearInterval(e(this).data("roundabout").autoplayInterval);e(this).data("roundabout").autoplayInterval=null;e(this).data("roundabout").autoplayIsRunning=false;if(!t){e(this).unbind(".autoplay")}e(this).trigger("autoplayStop")})},toggleAutoplay:function(t){return this.each(function(){var n=e(this),i=n.data("roundabout");t=t||i.autoplayCallback||function(){};if(!r.isAutoplaying.apply(e(this))){r.startAutoplay.apply(e(this),[t])}else{r.stopAutoplay.apply(e(this),[t])}})},isAutoplaying:function(){return this.data("roundabout").autoplayIsRunning},changeAutoplayDuration:function(t){return this.each(function(){var n=e(this),i=n.data("roundabout");i.autoplayDuration=t;if(r.isAutoplaying.apply(n)){r.stopAutoplay.apply(n);setTimeout(function(){r.startAutoplay.apply(n)},10)}})},normalize:function(e){var t=e%360;return t<0?360+t:t},normalizeRad:function(e){while(e<0){e+=Math.PI*2}while(e>Math.PI*2){e-=Math.PI*2}return e},isChildBackDegreesBetween:function(t,n){var r=e(this).data("roundabout").backDegrees;if(t>n){return r>=n&&r<t}else{return r<n&&r>=t}},getAnimateToMethod:function(e){e=e.toLowerCase();if(e==="next"){return"animateToNextChild"}else if(e==="previous"){return"animateToPreviousChild"}return"animateToNearestChild"},relayoutChildren:function(){e(document).find("#animation-styles"+e(this).data("roundabout").prefix).remove();return this.each(function(){var t=e(this),n=e.extend({},t.data("roundabout"));n.startingChild=t.data("roundabout").childInFocus;r.init.apply(t,[n,null,true])})},getNearestChild:function(){var t=e(this),n=t.data("roundabout"),r=t.children(n.childSelector).length;if(!n.reflect){return(r-Math.round(n.bearing/n.period)%r)%r}else{return Math.round(n.bearing/n.period)%r}},degToRad:function(e){return r.normalize.apply(null,[e])*Math.PI/180},objToString:function(e){var t="{";for(var n in e){if(e.hasOwnProperty(n)){t=t+n+":"+e[n]+";"}}t=t+"}";return t},getPlacement:function(e){var t=this.data("roundabout");return!t.reflect?360-t.period*e:t.period*e},isInFocus:function(e){var t,n=this,i=n.data("roundabout"),s=r.normalize.apply(null,[i.bearing]);e=r.normalize.apply(null,[e]);t=Math.abs(s-e);return t<=i.floatComparisonThreshold||t>=360-i.floatComparisonThreshold},getChildInFocus:function(){var t=e(this).data("roundabout");return t.childInFocus>-1?t.childInFocus:false},compareVersions:function(e,t){var n,r=e.split(/\./i),i=t.split(/\./i),s=r.length>i.length?r.length:i.length;for(n=0;n<=s;n++){if(r[n]&&!i[n]&&parseInt(r[n],10)!==0){return 1}else if(i[n]&&!r[n]&&parseInt(i[n],10)!==0){return-1}else if(r[n]===i[n]){continue}if(r[n]&&i[n]){if(parseInt(r[n],10)>parseInt(i[n],10)){return 1}else{return-1}}}return 0},getVendorPropName:function(e,t){var n=["Webkit","O","Moz","ms"],r=["-webkit-","-o-","-moz-","-ms-"],i=t.charAt(0).toUpperCase()+t.slice(1),s=t,o=r.length;if(t in e){return""}while(o--){t=n[o]+i;if(t in e){return r[o]}}return""}};e.fn.roundabout=function(t){if(r[t]){return r[t].apply(this,Array.prototype.slice.call(arguments,1))}else if(typeof t==="object"||e.isFunction(t)||!t){return r.init.apply(this,arguments)}else{e.error("Method "+t+" does not exist for jQuery.roundabout.")}}})(jQuery)