Template:Team:UC Davis/Head
From 2011.igem.org
(Difference between revisions)
Line 7: | Line 7: | ||
<script> | <script> | ||
- | jQuery.noConflict() | + | jQuery.noConflict(); |
jQuery.extend(jQuery.easing,{easeOutBack:function(x,t,b,c,d,s){ | jQuery.extend(jQuery.easing,{easeOutBack:function(x,t,b,c,d,s){ | ||
if(s==undefined)s=1.70158; | if(s==undefined)s=1.70158; | ||
Line 32: | Line 32: | ||
function snapback(dur){ | function snapback(dur){ | ||
} | } | ||
- | var setting=jQuery.extend({fx:'easeOutBack',fxtime:500,snapdelay:300},usersetting) | + | var setting=jQuery.extend({fx:'easeOutBack',fxtime:500,snapdelay:300},usersetting); |
- | var $menu=$('#'+setting.id).find('li:eq(0)').parents('ul:eq(0)') | + | var $menu=$('#'+setting.id).find('li:eq(0)').parents('ul:eq(0)'); |
- | $menulinks=$menu.find('li a') | + | $menulinks=$menu.find('li a'); |
$menulinks.eq(thispagenumber).css('color',colorsarray[thispagenumber]); | $menulinks.eq(thispagenumber).css('color',colorsarray[thispagenumber]); | ||
var $contentbox=$('#contentbox').css({top:$menulinks.eq(0).position().bottom,zIndex:1}); | var $contentbox=$('#contentbox').css({top:$menulinks.eq(0).position().bottom,zIndex:1}); | ||
- | var $effectref=$(gooeymenu.effectmarkup).css({top:$menulinks.eq(0).position().top,width:$menulinks.eq(thispagenumber).parent().outerWidth(),height:$menulinks.eq(0).outerHeight(),zIndex:0,opacity:0.5}).appendTo($menu) | + | var $effectref=$(gooeymenu.effectmarkup).css({top:$menulinks.eq(0).position().top,width:$menulinks.eq(thispagenumber).parent().outerWidth(),height:$menulinks.eq(0).outerHeight(),zIndex:0,opacity:0.5}).appendTo($menu); |
barheight=$menulinks.eq(0).outerHeight(); | barheight=$menulinks.eq(0).outerHeight(); | ||
- | $effectref.css({left:$menulinks.eq(thispagenumber).position().left}) | + | $effectref.css({left:$menulinks.eq(thispagenumber).position().left}); |
if(typeof setting.selectitem!="undefined"){ | if(typeof setting.selectitem!="undefined"){ | ||
- | var $selectedlink=$menulinks.removeClass('selected').eq(setting.selectitem).addClass('selected') | + | var $selectedlink=$menulinks.removeClass('selected').eq(setting.selectitem).addClass('selected'); |
} | } | ||
else{ | else{ | ||
- | var $selectedlink=$menulinks.filter('.selected:eq(0)') | + | var $selectedlink=$menulinks.filter('.selected:eq(0)'); |
var $selectedlink=$menulinks.eq(1); | var $selectedlink=$menulinks.eq(1); | ||
} | } | ||
- | setting.defaultselectedBool=$selectedlink.length | + | setting.defaultselectedBool=$selectedlink.length; |
$menulinks.mouseover(function(){ | $menulinks.mouseover(function(){ | ||
- | var $target=$(this) | + | var $target=$(this); |
if(currenttarget!=$target) | if(currenttarget!=$target) | ||
{ | { | ||
- | clearTimeout(setting.snapbacktimer) | + | clearTimeout(setting.snapbacktimer); |
currenttarget=$target; | currenttarget=$target; | ||
$contentbox.dequeue().css({left:$target.parent().position().left,opacity:0}); | $contentbox.dequeue().css({left:$target.parent().position().left,opacity:0}); | ||
$contentbox.html(contentarray[$target.parent().index()]); | $contentbox.html(contentarray[$target.parent().index()]); | ||
- | var $contentlinks=$contentbox.find('a') | + | var $contentlinks=$contentbox.find('a'); |
$contentlinks.hover(function(){ | $contentlinks.hover(function(){ | ||
$(this).css({color:colorsarray[$target.parent().index()]}); | $(this).css({color:colorsarray[$target.parent().index()]}); | ||
Line 63: | Line 63: | ||
}) | }) | ||
$contentbox.dequeue().animate({opacity:1},setting.fxtime*4,setting.fx); | $contentbox.dequeue().animate({opacity:1},setting.fxtime*4,setting.fx); | ||
- | $effectref.dequeue().animate({left:$target.parent().position().left-$target.parent().outerWidth()*(1-1)/2+25,width:$target.parent().outerWidth()*1,height:150,opacity:0.5},setting.fxtime,setting.fx) | + | $effectref.dequeue().animate({left:$target.parent().position().left-$target.parent().outerWidth()*(1-1)/2+25,width:$target.parent().outerWidth()*1,height:150,opacity:0.5},setting.fxtime,setting.fx); |
- | $target.dequeue().animate({color:colorsarray[$target.parent().index()]},setting.fxtime,setting.fx) | + | $target.dequeue().animate({color:colorsarray[$target.parent().index()]},setting.fxtime,setting.fx); |
if(setting.defaultselectedBool==0) | if(setting.defaultselectedBool==0) | ||
- | $selectedlink=$target | + | $selectedlink=$target; |
} | } | ||
}) | }) | ||
$menulinks.mouseleave(function(){ | $menulinks.mouseleave(function(){ | ||
- | var $target=$(this) | + | var $target=$(this); |
if($menulinks.index(this)!=thispagenumber) | if($menulinks.index(this)!=thispagenumber) | ||
- | $target.dequeue().animate({color:'#aaa'},setting.fxtime,setting.fx) | + | $target.dequeue().animate({color:'#aaa'},setting.fxtime,setting.fx); |
}) | }) | ||
if($selectedlink.length>0){ | if($selectedlink.length>0){ | ||
- | snapback(0) | + | snapback(0); |
$('#navcon').mouseleave(function(){ | $('#navcon').mouseleave(function(){ | ||
currenttarget=$menulinks.eq(thispagenumber); | currenttarget=$menulinks.eq(thispagenumber); | ||
Line 85: | Line 85: | ||
} | } | ||
$(window).bind('resize',function(){ | $(window).bind('resize',function(){ | ||
- | snapback(setting.fxtime) | + | snapback(setting.fxtime); |
}) | }) | ||
}) | }) |
Revision as of 21:11, 20 July 2011