From be1d923f577e80991d4a9953d31aa2b3091a51bb Mon Sep 17 00:00:00 2001 From: Abdulhamid Alattar Date: Mon, 22 Dec 2014 17:29:38 +0400 Subject: [PATCH 1/2] Update jquery.roundabout.js responsive and enlargement issue fixes , child not defined issue when loading big images --- jquery.roundabout.js | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/jquery.roundabout.js b/jquery.roundabout.js index df83da2..3aceafe 100644 --- a/jquery.roundabout.js +++ b/jquery.roundabout.js @@ -1,3 +1,7 @@ +/** + * jQuery Roundabout - v2.4.3 + * Resolved changing size bug and crashing if loading images was too big + **/ /** * jQuery Roundabout - v2.4.2 * http://fredhq.com/projects/roundabout @@ -169,7 +173,7 @@ } else { // bind responsive action if (settings.responsive) { - $(window).bind("resize", function() { + $(window).bind("resize.roundabout", function() { methods.stopAutoplay.apply(self); methods.relayoutChildren.apply(self); }); @@ -328,6 +332,13 @@ callback = callback || function() {}; + if(relayout){ + data.relayoutProportion = self.width() / data.startWidth + }else{ + data.relayoutProportion = 1; + data.startWidth = self.width(); + } + self.children(data.childSelector).each(function(i) { var startWidth, startHeight, startFontSize, degrees = methods.getPlacement.apply(self, [i]); @@ -470,6 +481,7 @@ var factors, self = this, child = $(childElement), + selfData = self.data("roundabout"), data = child.data("roundabout"), out = [], rad = methods.degToRad.apply(null, [(360.0 - data.degrees) + info.bearing]); @@ -484,7 +496,7 @@ // correct factors.scale = (factors.scale > 1) ? 1 : factors.scale; - factors.adjustedScale = (info.scale.min + (info.scale.diff * factors.scale)).toFixed(4); + factors.adjustedScale = ((info.scale.min + (info.scale.diff * factors.scale)).toFixed(4)) * selfData.relayoutProportion; factors.width = (factors.adjustedScale * data.startWidth).toFixed(4); factors.height = (factors.adjustedScale * data.startHeight).toFixed(4); @@ -1141,8 +1153,12 @@ // returns the current child in focus, or false if none are in focus getChildInFocus: function() { var data = $(this).data("roundabout"); - - return (data.childInFocus > -1) ? data.childInFocus : false; + if(typeof data !== 'undefined'){ + + return (data.childInFocus > -1) ? data.childInFocus : false; + }else{ + return false; + } }, @@ -1193,4 +1209,4 @@ $.error("Method " + method + " does not exist for jQuery.roundabout."); } }; -})(jQuery); \ No newline at end of file +})(jQuery); From 5b65251196d23455ac69857b12aaf321055095e5 Mon Sep 17 00:00:00 2001 From: Abdulhamid Alattar Date: Mon, 22 Dec 2014 17:33:03 +0400 Subject: [PATCH 2/2] Update jquery.roundabout.min.js --- jquery.roundabout.min.js | 48 ++++++++++++++++++++-------------------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/jquery.roundabout.min.js b/jquery.roundabout.min.js index b6f4935..fe44cf9 100644 --- a/jquery.roundabout.min.js +++ b/jquery.roundabout.min.js @@ -1,31 +1,31 @@ /** - * 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. - * + * jQuery Roundabout - v2.4.3 + * Resolved changing size bug and crashing if loading images was too big + * Abdulhamid AlAttar + **/ +/** + * 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. - * + * + * 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. - * + * - 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 @@ -38,4 +38,4 @@ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ -(function(a){"use strict";var b,c,d;a.extend({roundaboutShapes:{def:"lazySusan",lazySusan:function(a,b,c){return{x:Math.sin(a+b),y:Math.sin(a+3*Math.PI/2+b)/8*c,z:(Math.cos(a+b)+1)/2,scale:Math.sin(a+Math.PI/2+b)/2+.5}}}});b={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};c={autoplayInterval:null,autoplayIsRunning:false,autoplayStartTimeout:null,animating:false,childInFocus:-1,touchMoveStartPosition:null,stopAnimation:false,lastAnimationStep:false};d={init:function(e,f,g){var h,i=(new Date).getTime();e=typeof e==="object"?e:{};f=a.isFunction(f)?f:function(){};f=a.isFunction(e)?e:f;h=a.extend({},b,e,c);return this.each(function(){var b=a(this),c=b.children(h.childSelector).length,e=360/c,i=h.startingChild&&h.startingChild>c-1?c-1:h.startingChild,j=h.startingChild===null?h.bearing:360-i*e,k=b.css("position")!=="static"?b.css("position"):"relative";b.css({padding:0,position:k}).addClass("roundabout-holder").data("roundabout",a.extend({},h,{startingChild:i,bearing:j,oppositeOfFocusBearing:d.normalize.apply(null,[h.focusBearing-180]),dragBearing:j,period:e}));if(g){b.unbind(".roundabout").children(h.childSelector).unbind(".roundabout")}else{if(h.responsive){a(window).bind("resize",function(){d.stopAutoplay.apply(b);d.relayoutChildren.apply(b)})}}if(h.clickToFocus){b.children(h.childSelector).each(function(c){a(this).bind("click.roundabout",function(){var e=d.getPlacement.apply(b,[c]);if(!d.isInFocus.apply(b,[e])){d.stopAnimation.apply(a(this));if(!b.data("roundabout").animating){d.animateBearingToFocus.apply(b,[e,b.data("roundabout").clickToFocusCallback])}return false}})})}if(h.btnNext){a(h.btnNext).bind("click.roundabout",function(){if(!b.data("roundabout").animating){d.animateToNextChild.apply(b,[b.data("roundabout").btnNextCallback])}return false})}if(h.btnPrev){a(h.btnPrev).bind("click.roundabout",function(){d.animateToPreviousChild.apply(b,[b.data("roundabout").btnPrevCallback]);return false})}if(h.btnToggleAutoplay){a(h.btnToggleAutoplay).bind("click.roundabout",function(){d.toggleAutoplay.apply(b);return false})}if(h.btnStartAutoplay){a(h.btnStartAutoplay).bind("click.roundabout",function(){d.startAutoplay.apply(b);return false})}if(h.btnStopAutoplay){a(h.btnStopAutoplay).bind("click.roundabout",function(){d.stopAutoplay.apply(b);return false})}if(h.autoplayPauseOnHover){b.bind("mouseenter.roundabout.autoplay",function(){d.stopAutoplay.apply(b,[true])}).bind("mouseleave.roundabout.autoplay",function(){d.startAutoplay.apply(b)})}if(h.enableDrag){if(!a.isFunction(b.drag)){if(h.debug){alert("You do not have the drag plugin loaded.")}}else if(!a.isFunction(b.drop)){if(h.debug){alert("You do not have the drop plugin loaded.")}}else{b.drag(function(a,c){var e=b.data("roundabout"),f=e.dragAxis.toLowerCase()==="x"?"deltaX":"deltaY";d.stopAnimation.apply(b);d.setBearing.apply(b,[e.dragBearing+c[f]/e.dragFactor])}).drop(function(a){var c=b.data("roundabout"),e=d.getAnimateToMethod(c.dropAnimateTo);d.allowAnimation.apply(b);d[e].apply(b,[c.dropDuration,c.dropEasing,c.dropCallback]);c.dragBearing=c.period*d.getNearestChild.apply(b)})}b.each(function(){var b=a(this).get(0),c=a(this).data("roundabout"),e=c.dragAxis.toLowerCase()==="x"?"pageX":"pageY",f=d.getAnimateToMethod(c.dropAnimateTo);if(b.addEventListener){b.addEventListener("touchstart",function(a){c.touchMoveStartPosition=a.touches[0][e]},false);b.addEventListener("touchmove",function(b){var f=(b.touches[0][e]-c.touchMoveStartPosition)/c.dragFactor;b.preventDefault();d.stopAnimation.apply(a(this));d.setBearing.apply(a(this),[c.dragBearing+f])},false);b.addEventListener("touchend",function(b){b.preventDefault();d.allowAnimation.apply(a(this));f=d.getAnimateToMethod(c.dropAnimateTo);d[f].apply(a(this),[c.dropDuration,c.dropEasing,c.dropCallback]);c.dragBearing=c.period*d.getNearestChild.apply(a(this))},false)}})}d.initChildren.apply(b,[f,g])})},initChildren:function(b,c){var e=a(this),f=e.data("roundabout");b=b||function(){};e.children(f.childSelector).each(function(b){var f,g,h,i=d.getPlacement.apply(e,[b]);if(c&&a(this).data("roundabout")){f=a(this).data("roundabout").startWidth;g=a(this).data("roundabout").startHeight;h=a(this).data("roundabout").startFontSize}a(this).addClass("roundabout-moveable-item").css("position","absolute");a(this).data("roundabout",{startWidth:f||a(this).width(),startHeight:g||a(this).height(),startFontSize:h||parseInt(a(this).css("font-size"),10),degrees:i,backDegrees:d.normalize.apply(null,[i-180]),childNumber:b,currentScale:1,parent:e})});d.updateChildren.apply(e);if(f.autoplay){f.autoplayStartTimeout=setTimeout(function(){d.startAutoplay.apply(e)},f.autoplayInitialDelay)}e.trigger("ready");b.apply(e);return e},updateChildren:function(){return this.each(function(){var b=a(this),c=b.data("roundabout"),e=-1,f={bearing:c.bearing,tilt:c.tilt,stage:{width:Math.floor(a(this).width()*.9),height:Math.floor(a(this).height()*.9)},animating:c.animating,inFocus:c.childInFocus,focusBearingRadian:d.degToRad.apply(null,[c.focusBearing]),shape:a.roundaboutShapes[c.shape]||a.roundaboutShapes[a.roundaboutShapes.def]};f.midStage={width:f.stage.width/2,height:f.stage.height/2};f.nudge={width:f.midStage.width+f.stage.width*.05,height:f.midStage.height+f.stage.height*.05};f.zValues={min:c.minZ,max:c.maxZ,diff:c.maxZ-c.minZ};f.opacity={min:c.minOpacity,max:c.maxOpacity,diff:c.maxOpacity-c.minOpacity};f.scale={min:c.minScale,max:c.maxScale,diff:c.maxScale-c.minScale};b.children(c.childSelector).each(function(g){if(d.updateChild.apply(b,[a(this),f,g,function(){a(this).trigger("ready")}])&&(!f.animating||c.lastAnimationStep)){e=g;a(this).addClass("roundabout-in-focus")}else{a(this).removeClass("roundabout-in-focus")}});if(e!==f.inFocus){if(c.triggerBlurEvents){b.children(c.childSelector).eq(f.inFocus).trigger("blur")}c.childInFocus=e;if(c.triggerFocusEvents&&e!==-1){b.children(c.childSelector).eq(e).trigger("focus")}}b.trigger("childrenUpdated")})},updateChild:function(b,c,e,f){var g,h=this,i=a(b),j=i.data("roundabout"),k=[],l=d.degToRad.apply(null,[360-j.degrees+c.bearing]);f=f||function(){};l=d.normalizeRad.apply(null,[l]);g=c.shape(l,c.focusBearingRadian,c.tilt);g.scale=g.scale>1?1:g.scale;g.adjustedScale=(c.scale.min+c.scale.diff*g.scale).toFixed(4);g.width=(g.adjustedScale*j.startWidth).toFixed(4);g.height=(g.adjustedScale*j.startHeight).toFixed(4);i.css({left:(g.x*c.midStage.width+c.nudge.width-g.width/2).toFixed(0)+"px",top:(g.y*c.midStage.height+c.nudge.height-g.height/2).toFixed(0)+"px",width:g.width+"px",height:g.height+"px",opacity:(c.opacity.min+c.opacity.diff*g.scale).toFixed(2),zIndex:Math.round(c.zValues.min+c.zValues.diff*g.z),fontSize:(g.adjustedScale*j.startFontSize).toFixed(1)+"px"});j.currentScale=g.adjustedScale;if(h.data("roundabout").debug){k.push('
');k.push('Child '+e+"
");k.push("left: "+i.css("left")+"
");k.push("top: "+i.css("top")+"
");k.push("width: "+i.css("width")+"
");k.push("opacity: "+i.css("opacity")+"
");k.push("height: "+i.css("height")+"
");k.push("z-index: "+i.css("z-index")+"
");k.push("font-size: "+i.css("font-size")+"
");k.push("scale: "+i.data("roundabout").currentScale);k.push("
");i.html(k.join(""))}i.trigger("reposition");f.apply(h);return d.isInFocus.apply(h,[j.degrees])},setBearing:function(b,c){c=c||function(){};b=d.normalize.apply(null,[b]);this.each(function(){var c,e,f,g=a(this),h=g.data("roundabout"),i=h.bearing;h.bearing=b;g.trigger("bearingSet");d.updateChildren.apply(g);c=Math.abs(i-b);if(!h.animating||c>180){return}c=Math.abs(i-b);g.children(h.childSelector).each(function(c){var e;if(d.isChildBackDegreesBetween.apply(a(this),[b,i])){e=i>b?"Clockwise":"Counterclockwise";a(this).trigger("move"+e+"ThroughBack")}})});c.apply(this);return this},adjustBearing:function(b,c){c=c||function(){};if(b===0){return this}this.each(function(){d.setBearing.apply(a(this),[a(this).data("roundabout").bearing+b])});c.apply(this);return this},setTilt:function(b,c){c=c||function(){};this.each(function(){a(this).data("roundabout").tilt=b;d.updateChildren.apply(a(this))});c.apply(this);return this},adjustTilt:function(b,c){c=c||function(){};this.each(function(){d.setTilt.apply(a(this),[a(this).data("roundabout").tilt+b])});c.apply(this);return this},animateToBearing:function(b,c,e,f,g){var h=(new Date).getTime();g=g||function(){};if(a.isFunction(f)){g=f;f=null}else if(a.isFunction(e)){g=e;e=null}else if(a.isFunction(c)){g=c;c=null}this.each(function(){var i,j,k,l=a(this),m=l.data("roundabout"),n=!c?m.duration:c,o=e?e:m.easing||"swing";if(!f){f={timerStart:h,start:m.bearing,totalTime:n}}i=h-f.timerStart;if(m.stopAnimation){d.allowAnimation.apply(l);m.animating=false;return}if(i=0&&!a.easing["easeOutBack"]){k=f.start+(b-f.start)*k}k=d.normalize.apply(null,[k]);m.dragBearing=k;d.setBearing.apply(l,[k,function(){setTimeout(function(){d.animateToBearing.apply(l,[b,n,o,f,g])},0)}])}else{m.lastAnimationStep=true;b=d.normalize.apply(null,[b]);d.setBearing.apply(l,[b,function(){l.trigger("animationEnd")}]);m.animating=false;m.lastAnimationStep=false;m.dragBearing=b;g.apply(l)}});return this},animateToNearbyChild:function(b,c){var e=b[0],f=b[1],g=b[2]||function(){};if(a.isFunction(f)){g=f;f=null}else if(a.isFunction(e)){g=e;e=null}return this.each(function(){var b,h,i=a(this),j=i.data("roundabout"),k=!j.reflect?j.bearing%360:j.bearing,l=i.children(j.childSelector).length;if(!j.animating){if(j.reflect&&c==="previous"||!j.reflect&&c==="next"){k=Math.abs(k)=Math.floor(h.lower)){if(l===2&&k===360){d.animateToDelta.apply(i,[-180,e,f,g])}else{d.animateBearingToFocus.apply(i,[h.lower,e,f,g])}break}}}else{k=Math.abs(k)=0;b-=1){h={lower:j.period*b,upper:j.period*(b+1)};h.upper=b===l-1?360:h.upper;if(k>=Math.floor(h.lower)&&k180?-(360-g):g;if(g!==0){d.animateToDelta.apply(a(this),[g,c,e,f])}})},stopAnimation:function(){return this.each(function(){a(this).data("roundabout").stopAnimation=true})},allowAnimation:function(){return this.each(function(){a(this).data("roundabout").stopAnimation=false})},startAutoplay:function(b){return this.each(function(){var c=a(this),e=c.data("roundabout");b=b||e.autoplayCallback||function(){};clearInterval(e.autoplayInterval);e.autoplayInterval=setInterval(function(){d.animateToNextChild.apply(c,[b])},e.autoplayDuration);e.autoplayIsRunning=true;c.trigger("autoplayStart")})},stopAutoplay:function(b){return this.each(function(){clearInterval(a(this).data("roundabout").autoplayInterval);a(this).data("roundabout").autoplayInterval=null;a(this).data("roundabout").autoplayIsRunning=false;if(!b){a(this).unbind(".autoplay")}a(this).trigger("autoplayStop")})},toggleAutoplay:function(b){return this.each(function(){var c=a(this),e=c.data("roundabout");b=b||e.autoplayCallback||function(){};if(!d.isAutoplaying.apply(a(this))){d.startAutoplay.apply(a(this),[b])}else{d.stopAutoplay.apply(a(this),[b])}})},isAutoplaying:function(){return this.data("roundabout").autoplayIsRunning},changeAutoplayDuration:function(b){return this.each(function(){var c=a(this),e=c.data("roundabout");e.autoplayDuration=b;if(d.isAutoplaying.apply(c)){d.stopAutoplay.apply(c);setTimeout(function(){d.startAutoplay.apply(c)},10)}})},normalize:function(a){var b=a%360;return b<0?360+b:b},normalizeRad:function(a){while(a<0){a+=Math.PI*2}while(a>Math.PI*2){a-=Math.PI*2}return a},isChildBackDegreesBetween:function(b,c){var d=a(this).data("roundabout").backDegrees;if(b>c){return d>=c&&d=b}},getAnimateToMethod:function(a){a=a.toLowerCase();if(a==="next"){return"animateToNextChild"}else if(a==="previous"){return"animateToPreviousChild"}return"animateToNearestChild"},relayoutChildren:function(){return this.each(function(){var b=a(this),c=a.extend({},b.data("roundabout"));c.startingChild=b.data("roundabout").childInFocus;d.init.apply(b,[c,null,true])})},getNearestChild:function(){var b=a(this),c=b.data("roundabout"),d=b.children(c.childSelector).length;if(!c.reflect){return(d-Math.round(c.bearing/c.period)%d)%d}else{return Math.round(c.bearing/c.period)%d}},degToRad:function(a){return d.normalize.apply(null,[a])*Math.PI/180},getPlacement:function(a){var b=this.data("roundabout");return!b.reflect?360-b.period*a:b.period*a},isInFocus:function(a){var b,c=this,e=c.data("roundabout"),f=d.normalize.apply(null,[e.bearing]);a=d.normalize.apply(null,[a]);b=Math.abs(f-a);return b<=e.floatComparisonThreshold||b>=360-e.floatComparisonThreshold},getChildInFocus:function(){var b=a(this).data("roundabout");return b.childInFocus>-1?b.childInFocus:false},compareVersions:function(a,b){var c,d=a.split(/\./i),e=b.split(/\./i),f=d.length>e.length?d.length:e.length;for(c=0;c<=f;c++){if(d[c]&&!e[c]&&parseInt(d[c],10)!==0){return 1}else if(e[c]&&!d[c]&&parseInt(e[c],10)!==0){return-1}else if(d[c]===e[c]){continue}if(d[c]&&e[c]){if(parseInt(d[c],10)>parseInt(e[c],10)){return 1}else{return-1}}}return 0}};a.fn.roundabout=function(b){if(d[b]){return d[b].apply(this,Array.prototype.slice.call(arguments,1))}else if(typeof b==="object"||a.isFunction(b)||!b){return d.init.apply(this,arguments)}else{a.error("Method "+b+" does not exist for jQuery.roundabout.")}}})(jQuery) \ No newline at end of file +(function(c){var t,u,g;c.extend({roundaboutShapes:{def:"lazySusan",lazySusan:function(a,b,c){return{x:Math.sin(a+b),y:Math.sin(a+3*Math.PI/2+b)/8*c,z:(Math.cos(a+b)+1)/2,scale:Math.sin(a+Math.PI/2+b)/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:!0,clickToFocusCallback:function(){},focusBearing:0,shape:"lazySusan",debug:!1,childSelector:"li",startingChild:null,reflect:!1,floatComparisonThreshold:.001,autoplay:!1,autoplayDuration:1E3,autoplayPauseOnHover:!1,autoplayCallback:function(){},autoplayInitialDelay:0,enableDrag:!1,dropDuration:600,dropEasing:"swing",dropAnimateTo:"nearest",dropCallback:function(){},dragAxis:"x",dragFactor:4,triggerFocusEvents:!0,triggerBlurEvents:!0,responsive:!1};u={autoplayInterval:null,autoplayIsRunning:!1,autoplayStartTimeout:null,animating:!1,childInFocus:-1,touchMoveStartPosition:null,stopAnimation:!1,lastAnimationStep:!1};g={init:function(a,b,h){var d;(new Date).getTime();a="object"===typeof a?a:{};b=c.isFunction(b)?b:function(){};b=c.isFunction(a)?a:b;d=c.extend({},t,a,u);return this.each(function(){var a=c(this),m=a.children(d.childSelector).length,k=360/m,m=d.startingChild&&d.startingChild>m-1?m-1:d.startingChild,n=null===d.startingChild?d.bearing:360-m*k,p="static"!==a.css("position")?a.css("position"):"relative";a.css({padding:0,position:p}).addClass("roundabout-holder").data("roundabout",c.extend({},d,{startingChild:m,bearing:n,oppositeOfFocusBearing:g.normalize.apply(null,[d.focusBearing-180]),dragBearing:n,period:k}));h?a.unbind(".roundabout").children(d.childSelector).unbind(".roundabout"):d.responsive&&c(window).bind("resize.roundabout",function(){g.stopAutoplay.apply(a);g.relayoutChildren.apply(a)});d.clickToFocus&&a.children(d.childSelector).each(function(b){c(this).bind("click.roundabout",function(){var d=g.getPlacement.apply(a,[b]);if(!g.isInFocus.apply(a,[d]))return g.stopAnimation.apply(c(this)),a.data("roundabout").animating||g.animateBearingToFocus.apply(a,[d,a.data("roundabout").clickToFocusCallback]),!1})});d.btnNext&&c(d.btnNext).bind("click.roundabout",function(){a.data("roundabout").animating||g.animateToNextChild.apply(a,[a.data("roundabout").btnNextCallback]);return!1});d.btnPrev&&c(d.btnPrev).bind("click.roundabout",function(){g.animateToPreviousChild.apply(a,[a.data("roundabout").btnPrevCallback]);return!1});d.btnToggleAutoplay&&c(d.btnToggleAutoplay).bind("click.roundabout",function(){g.toggleAutoplay.apply(a);return!1});d.btnStartAutoplay&&c(d.btnStartAutoplay).bind("click.roundabout",function(){g.startAutoplay.apply(a);return!1});d.btnStopAutoplay&&c(d.btnStopAutoplay).bind("click.roundabout",function(){g.stopAutoplay.apply(a);return!1});d.autoplayPauseOnHover&&a.bind("mouseenter.roundabout.autoplay",function(){g.stopAutoplay.apply(a,[!0])}).bind("mouseleave.roundabout.autoplay",function(){g.startAutoplay.apply(a)});d.enableDrag&&(c.isFunction(a.drag)?c.isFunction(a.drop)?a.drag(function(b,d){var c=a.data("roundabout"),h="x"===c.dragAxis.toLowerCase()?"deltaX":"deltaY";g.stopAnimation.apply(a);g.setBearing.apply(a,[c.dragBearing+d[h]/c.dragFactor])}).drop(function(b){b=a.data("roundabout");var d=g.getAnimateToMethod(b.dropAnimateTo);g.allowAnimation.apply(a);g[d].apply(a,[b.dropDuration,b.dropEasing,b.dropCallback]);b.dragBearing=b.period*g.getNearestChild.apply(a)}):d.debug&&alert("You do not have the drop plugin loaded."):d.debug&&alert("You do not have the drag plugin loaded."),a.each(function(){var a=c(this).get(0),b=c(this).data("roundabout"),d="x"===b.dragAxis.toLowerCase()?"pageX":"pageY",h=g.getAnimateToMethod(b.dropAnimateTo);a.addEventListener&&(a.addEventListener("touchstart",function(a){b.touchMoveStartPosition=a.touches[0][d]},!1),a.addEventListener("touchmove",function(a){var h=(a.touches[0][d]-b.touchMoveStartPosition)/b.dragFactor;a.preventDefault();g.stopAnimation.apply(c(this));g.setBearing.apply(c(this),[b.dragBearing+h])},!1),a.addEventListener("touchend",function(a){a.preventDefault();g.allowAnimation.apply(c(this));h=g.getAnimateToMethod(b.dropAnimateTo);g[h].apply(c(this),[b.dropDuration,b.dropEasing,b.dropCallback]);b.dragBearing=b.period*g.getNearestChild.apply(c(this))},!1))}));g.initChildren.apply(a,[b,h])})},initChildren:function(a,b){var h=c(this),d=h.data("roundabout");a=a||function(){};b?d.relayoutProportion=h.width()/d.startWidth:(d.relayoutProportion=1,d.startWidth=h.width());h.children(d.childSelector).each(function(a){var d,k,n,p=g.getPlacement.apply(h,[a]);b&&c(this).data("roundabout")&&(d=c(this).data("roundabout").startWidth,k=c(this).data("roundabout").startHeight,n=c(this).data("roundabout").startFontSize);c(this).addClass("roundabout-moveable-item").css("position","absolute");c(this).data("roundabout",{startWidth:d||c(this).width(),startHeight:k||c(this).height(),startFontSize:n||parseInt(c(this).css("font-size"),10),degrees:p,backDegrees:g.normalize.apply(null,[p-180]),childNumber:a,currentScale:1,parent:h})});g.updateChildren.apply(h);d.autoplay&&(d.autoplayStartTimeout=setTimeout(function(){g.startAutoplay.apply(h)},d.autoplayInitialDelay));h.trigger("ready");a.apply(h);return h},updateChildren:function(){return this.each(function(){var a=c(this),b=a.data("roundabout"),h=-1,d={bearing:b.bearing,tilt:b.tilt,stage:{width:Math.floor(.9*c(this).width()),height:Math.floor(.9*c(this).height())},animating:b.animating,inFocus:b.childInFocus,focusBearingRadian:g.degToRad.apply(null,[b.focusBearing]),shape:c.roundaboutShapes[b.shape]||c.roundaboutShapes[c.roundaboutShapes.def]};d.midStage={width:d.stage.width/2,height:d.stage.height/2};d.nudge={width:d.midStage.width+.05*d.stage.width,height:d.midStage.height+.05*d.stage.height};d.zValues={min:b.minZ,max:b.maxZ,diff:b.maxZ-b.minZ};d.opacity={min:b.minOpacity,max:b.maxOpacity,diff:b.maxOpacity-b.minOpacity};d.scale={min:b.minScale,max:b.maxScale,diff:b.maxScale-b.minScale};a.children(b.childSelector).each(function(f){!g.updateChild.apply(a,[c(this),d,f,function(){c(this).trigger("ready")}])||d.animating&&!b.lastAnimationStep?c(this).removeClass("roundabout-in-focus"):(h=f,c(this).addClass("roundabout-in-focus"))});h!==d.inFocus&&(b.triggerBlurEvents&&a.children(b.childSelector).eq(d.inFocus).trigger("blur"),b.childInFocus=h,b.triggerFocusEvents&&-1!==h&&a.children(b.childSelector).eq(h).trigger("focus"));a.trigger("childrenUpdated")})},updateChild:function(a,b,h,d){var f;a=c(a);h=this.data("roundabout");var m=a.data("roundabout"),k=[];f=g.degToRad.apply(null,[360-m.degrees+b.bearing]);d=d||function(){};f=g.normalizeRad.apply(null,[f]);f=b.shape(f,b.focusBearingRadian,b.tilt);f.scale=1'),k.push('Child '+e+"
"),k.push("left: "+a.css("left")+"
"),k.push("top: "+a.css("top")+"
"),k.push("width: "+a.css("width")+"
"),k.push("opacity: "+a.css("opacity")+"
"),k.push("height: "+a.css("height")+"
"),k.push("z-index: "+a.css("z-index")+"
"),k.push("font-size: "+a.css("font-size")+"
"),k.push("scale: "+a.data("roundabout").currentScale),k.push(""),a.html(k.join("")));a.trigger("reposition");d.apply(this);return g.isInFocus.apply(this,[m.degrees])},setBearing:function(a,b){b=b||function(){};a=g.normalize.apply(null,[a]);this.each(function(){var b,d=c(this),f=d.data("roundabout"),m=f.bearing;f.bearing=a;d.trigger("bearingSet");g.updateChildren.apply(d);b=Math.abs(m-a);!f.animating||180a?"Clockwise":"Counterclockwise",c(this).trigger("move"+b+"ThroughBack"))}))});b.apply(this);return this},adjustBearing:function(a,b){b=b||function(){};if(0===a)return this;this.each(function(){g.setBearing.apply(c(this),[c(this).data("roundabout").bearing+a])});b.apply(this);return this},setTilt:function(a,b){b=b||function(){};this.each(function(){c(this).data("roundabout").tilt=a;g.updateChildren.apply(c(this))});b.apply(this);return this},adjustTilt:function(a,b){b=b||function(){};this.each(function(){g.setTilt.apply(c(this),[c(this).data("roundabout").tilt+a])});b.apply(this);return this},animateToBearing:function(a,b,h,d,f){var m=(new Date).getTime();f=f||function(){};c.isFunction(d)?(f=d,d=null):c.isFunction(h)?(f=h,h=null):c.isFunction(b)&&(f=b,b=null);this.each(function(){var k,n,p=c(this),l=p.data("roundabout"),q=b?b:l.duration,r=h?h:l.easing||"swing";d||(d={timerStart:m,start:l.bearing,totalTime:q});k=m-d.timerStart;l.stopAnimation?(g.allowAnimation.apply(p),l.animating=!1):k=Math.floor(a)){2===r&&360===q?g.animateToDelta.apply(p,[-180,h,d,f]):g.animateBearingToFocus.apply(p,[a,h,d,f]);break}}else for(q=Math.abs(q)=Math.floor(a)&&qa?360+a:a},normalizeRad:function(a){for(;0>a;)a+=2*Math.PI;for(;a>2*Math.PI;)a-=2*Math.PI;return a},isChildBackDegreesBetween:function(a,b){var h=c(this).data("roundabout").backDegrees;return a>b?h>=b&&h=a},getAnimateToMethod:function(a){a=a.toLowerCase();return"next"===a?"animateToNextChild":"previous"===a?"animateToPreviousChild":"animateToNearestChild"},relayoutChildren:function(){return this.each(function(){var a=c(this),b=c.extend({},a.data("roundabout"));b.startingChild=a.data("roundabout").childInFocus;g.init.apply(a,[b,null,!0])})},getNearestChild:function(){var a=c(this),b=a.data("roundabout"),a=a.children(b.childSelector).length;return b.reflect?Math.round(b.bearing/b.period)%a:(a-Math.round(b.bearing/b.period)%a)%a},degToRad:function(a){return g.normalize.apply(null,[a])*Math.PI/180},getPlacement:function(a){var b=this.data("roundabout");return b.reflect?b.period*a:360-b.period*a},isInFocus:function(a){var b=this.data("roundabout"),c=g.normalize.apply(null,[b.bearing]);a=g.normalize.apply(null,[a]);a=Math.abs(c-a);return a<=b.floatComparisonThreshold||a>=360-b.floatComparisonThreshold},getChildInFocus:function(){var a=c(this).data("roundabout");return"undefined"!==typeof a?-1f.length?d.length:f.length;for(c=0;c<=g;c++){if(d[c]&&!f[c]&&0!==parseInt(d[c],10))return 1;if(f[c]&&!d[c]&&0!==parseInt(f[c],10))return-1;if(d[c]!==f[c]&&d[c]&&f[c])return parseInt(d[c],10)>parseInt(f[c],10)?1:-1}return 0}};c.fn.roundabout=function(a){if(g[a])return g[a].apply(this,Array.prototype.slice.call(arguments,1));if("object"===typeof a||c.isFunction(a)||!a)return g.init.apply(this,arguments);c.error("Method "+a+" does not exist for jQuery.roundabout.")}})(jQuery);