-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathjquery.bannerRotate-1.4.min.js
1 lines (1 loc) · 2.23 KB
/
jquery.bannerRotate-1.4.min.js
1
(function(a){a.fn.bannerRotate=function(b){var c={speed:500,secSpeed:500,interval:4e3,shouldHoverSwitch:!1,builedNav:function(b){var c=0,d=a("<div class='controlsContainer'>").hide(),e="";for(c=0;c<b;c++)e+="<a href='#'>";return d.html(e),d},stopAnimation:function(a){a.stop(!0,!0)},stopInterval:function(a){if(!a)return;window.clearInterval(a)},stopTimeout:function(a){if(!a)return;window.clearTimeout(a)},addHoverUsability:{active:!0,getMiliseconds:function(){return(new Date).getTime()},timeLapsed:function(a){var b=this.getMiliseconds();return b-a}}},d=a.extend(c,b);return this.each(function(b,c){if(a(this).children().length>1){var e=a(c),f=e.children(),g=f.length,h=function(b){if(p)return;var c=e.children(),d,f=function(b){b.each(function(){var b=a(this);if(b.is("a"))d=b.attr("rel"),d&&b.css("background",d);else{var c=b.find("img"),d=c.attr("rel");d&&c.attr("src",d)}})};if(b){f(c.eq(0));return}f(c.slice(1)),p=!0},i=h(1),j=e.append(d.builedNav(g).fadeIn(d.secSpeed)).find(".controlsContainer a"),k=1,l=0,m,n=function(a){a?(l=m,k=(l+1)%g):(l=k,k=(k+1)%g)},o=0,p=!1,q,r,s,t,u=function(){if(d.addHoverUsability.active)do o=d.addHoverUsability.getMiliseconds();while(0);f.eq(k).fadeIn(d.speed),f.eq(l).fadeOut(d.speed),j.eq(l).removeClass("active"),j.eq(k).addClass("active"),n()},v=function(){q=setInterval(u,d.interval)};f.children().bind("mouseover",function(a){a.preventDefault()}),e.hover(function(){d.stopInterval(q),d.stopAnimation(f)},function(){if(d.addHoverUsability.active){r&&(d.stopTimeout(r),d.stopTimeout(s));var a=d.addHoverUsability.timeLapsed(o);a>=d.interval?(v(),u()):(r=setTimeout(u,d.interval-a),s=setTimeout(v,d.interval-a+d.speed))}else v()}).find(".controlsContainer").delegate("a","click",function(){!p&&h();var b=a(this);return b.hasClass("active")?!1:(b.siblings().removeClass("active"),b.addClass("active"),m=j.index(b),f.eq(l).fadeOut(d.secSpeed),f.eq(m).fadeIn(d.secSpeed,function(){f.eq(m).css("opacity",1)}),d.addHoverUsability.active&&(o=d.addHoverUsability.getMiliseconds()),n(!0),!1)}).delegate("a","mouseover",function(){d.shouldHoverSwitch&&a(this).click()})}j.eq(0).addClass("active"),f.not(":eq(0)").hide(),v(),setTimeout(h,d.interval/2);if(d.addHoverUsability.active)do o=d.addHoverUsability.getMiliseconds();while(0)})}})(jQuery)