var oCarouselOptions; $(document).ready(function() { // link demos $(".coverflow div.wrapper").click(function() { var demo = $('img',this).attr('_code'); if (demo) { inst.options.clickfunc(demo); return false; if($.browser.safari) location.href = demo; else $("#toplist").load(demo+'&SNAP=1 .toplist_content'); return false; }else { //alert('Under construction!'); } }); if ($("div.coverflow").size()) { var inst = new $.ui.carousel($("div.coverflow")[0], $.extend({ height: 120, width: 180 },oCarouselOptions)); $("div.coverflow-button-left, div.coverflow-button-right").bind("mouseover", function() { var right = this.className.indexOf("right") == -1; if(inst.autoRotator) { window.clearInterval(inst.autoRotator); inst.autoRotator = 0; $('.wrapper',inst.element).stop(); } if(!inst.timer) inst.timer = window.setInterval(function() { inst.rotate(right ? "right" : null,0,0.019); }, 13); }) .bind("mouseout", function() { window.clearInterval(inst.timer); inst.timer=0; }); $('.coverflow div.shadow').hover(function() { this._lastopacity = $(this).css('opacity'); $(this).stop().animate({opacity: 0 }, 300); }, function() { $(this).stop().animate({opacity: this._lastopacity }, 300); }); var iRot=0.78; iRot=2*Math.PI/$("> *", inst.element).length; window.setTimeout(function() { inst.element.animate({ opacity: 1 },2000); inst.rotate(0,2000,iRot); window.setTimeout(function() { inst.autoRotator = window.setInterval(function() { inst.rotate(0,2000,iRot); },5000); },3000); },0); } $('a').click(function(){ this.blur(); }); // smooth hover effects by DragonInteractive var hover = hoverEffects(); hover.init(); }); $.ui.carousel = function(element, options) { this.element = $(element); this.options = $.extend({ radiusX:110, radiusY:-10, addpaddingY:0, clickfunc:function(url){ if($.browser.safari) location.href = url; else $("#toplist").load(url+'&SNAP=1 .toplist_content'); } }, options); var self = this; $.extend(this, { start: Math.PI/2, step: 2*Math.PI/$("> *", this.element).length, radiusX: this.options.radiusX, radiusY: this.options.radiusY, paddingX: this.element.outerWidth() / 2, paddingY: this.element.outerHeight() / 2 + this.options.addpaddingY }); $("> *", this.element).css({ position: "absolute", top: 0, left: 0, zIndex: 1 }); this.rotate(); this.rotate("right"); this.element.parent().bind("mousewheel", function(e,delta) { if(self.autoRotator) window.clearInterval(self.autoRotator); self.rotate(delta < 0 ? "right" : "left"); return false; }); }; $.ui.carousel.prototype.rotate = function(d,ani,speed) { this.start = this.start + (d == "right" ? -(speed || 0.03) : (speed || 0.03)); var o = this.options; var itself = this; setTimeout(function(){ $("> *", itself.element).each(function(i) { var minheight = 30; var angle = itself.start + i * itself.step; var x = itself.radiusX * Math.cos(angle); var y = itself.radiusY * Math.sin(angle); var _self = this; var width = o.width * ((itself.radiusY+y) / (2 * itself.radiusY)); // width = (width * width * width) / (o.width * o.width); //This makes the pieces smaller // width = width * width / o.width; var height = parseInt(width * o.height / o.width); //This is highly custom - it will hide the elements at the back $(_self).css({ visibility: height < minheight ? "hidden" : "visible" }); if(height < minheight && !ani) return; //This imrpoves the speed, but cannot be used with animation if(ani) { $(_self).animate({ top: Math.round(itself.paddingY + y - height/2) + "px", left: Math.round(itself.paddingX + x - width/2) + "px", width: Math.round(width) + "px", height: Math.round(height) + "px" },{ duration: ani, easing: "easeOutQuad" }); $(_self).css({ zIndex: Math.round(parseInt(100 * (itself.radiusY+y) / (2 * itself.radiusY))) }); } else { $(_self).css({ top: itself.paddingY + y - height/2 + "px", left: itself.paddingX + x - width/2 + "px", width: width + "px", height: height + "px", zIndex: parseInt(100 * (itself.radiusY+y) / (2 * itself.radiusY)) }); } $("div.shadow",_self).css({ opacity: 1 - (width / o.width) }); }); }, 0); } /** * All credit here goes to DragonInteractive and Yuri Vishnevsky */ var hoverEffects = function() { var me = this; var args = arguments; var self = { c: { navItems: 'div.coverflow-button-left, div.coverflow-button-right', navSpeed: ($.browser.safari ? 600: 350), snOpeningSpeed: ($.browser.safari ? 400: 250), snOpeningTimeout: 150, snClosingSpeed: function() { if (self.subnavHovered()) return 123450; return 150 }, snClosingTimeout: 700 }, init: function() { $('.bg', this.c.navItems).css({ 'opacity': 0 }); this.initHoverFades() }, subnavHovered: function() { var hovered = false; $(self.c.navItems).each(function() { if (this.hovered) hovered = true }); return hovered }, initHoverFades: function() { //$('#navigation .bg').css('opacity', 0); $(self.c.navItems).hover(function() { self.fadeNavIn.apply(this) }, function() { var el = this; setTimeout(function() { if (!el.open) self.fadeNavOut.apply(el) }, 10) }) }, fadeNavIn: function() { $('.bg', this).stop().animate({ 'opacity': 1 }, self.c.navSpeed) }, fadeNavOut: function() { $('.bg', this).stop().animate({ 'opacity': 0 }, self.c.navSpeed) }, initSubmenus: function() { $(this.c.navItems).hover(function() { $(self.c.navItems).not(this).each(function() { self.fadeNavOut.apply(this); }); this.hovered = true; var el = this; self.fadeNavIn.apply(el); }, function() { this.hovered = false; var el = this; if (!el.open) self.fadeNavOut.apply(el); }) } }; return self; };