Template:CSU Template 1 top
From 2012.igem.org
(Difference between revisions)
Line 323: | Line 323: | ||
var newOpac = (Math.round(roundNum * (parseFloat(curElem.style.opacity) - (1/numFadeLoops)))) / roundNum; | var newOpac = (Math.round(roundNum * (parseFloat(curElem.style.opacity) - (1/numFadeLoops)))) / roundNum; | ||
curElem.style.opacity = newOpac; | curElem.style.opacity = newOpac; | ||
- | setTimeout(function() {fade(curElemID)}, (fadeTime/numFadeLoops)); | + | setTimeout(function(){fade(curElemID)}, (fadeTime/numFadeLoops)); |
//Current slide has faded completely | //Current slide has faded completely | ||
Line 338: | Line 338: | ||
//Starts next fade. isFading = false is a required parameter | //Starts next fade. isFading = false is a required parameter | ||
- | setTimeout(function() {fade(nextElemID, false)}, slideStayTime); | + | setTimeout(function(){fade(nextElemID, false)}, slideStayTime); |
//Menu bar functions | //Menu bar functions | ||
Line 380: | Line 380: | ||
//******************************************************************* | //******************************************************************* | ||
- | var | + | var ddspeed = 10; |
- | var | + | var ddtimer = 15; |
//Main function to handle the mouse events | //Main function to handle the mouse events | ||
- | function | + | function ddMain(id, direction) { |
- | + | ||
- | + | var headerElem = document.getElementById('ddHeader' + id); | |
- | + | var contentElem = document.getElementById('ddContent' + id); | |
- | + | clearInterval(contentElem.timer); | |
- | + | ||
- | + | if (direction == 1) { | |
- | + | clearTimeout(headerElem.timer); | |
- | + | if (contentElem.maxh <= contentElem.offsetHeight) { | |
- | + | if (contentElem.maxh) { | |
- | + | return; | |
- | + | } //end if | |
- | + | } else if (!contentElem.maxh) { | |
- | + | contentElem.style.display = 'block'; | |
- | + | contentElem.style.height = 'auto'; | |
- | + | contentElem.maxh = contentElem.offsetHeight; | |
- | + | contentElem.style.height = '0px'; | |
- | + | } //end if | |
- | + | contentElem.timer = setInterval(function(){ddSlide(contentElem,1)},ddtimer); | |
- | + | } else { | |
- | + | headerElem.timer = setTimeout(function(){ddCollapse(contentElem)},50); | |
- | } | + | } //end if |
+ | |||
+ | } //end function ddMain | ||
//Collapse menu | //Collapse menu | ||
- | function ddCollapse( | + | function ddCollapse(contentElem) { |
- | + | ||
- | } | + | contentElem.timer = setInterval(function(){ddSlide(contentElem, -1)},ddtimer); |
+ | |||
+ | } //end function ddCollapse | ||
//Cancel the collapse if a user rolls over the dropdown | //Cancel the collapse if a user rolls over the dropdown | ||
- | function | + | function cancelCollapse(id) { |
- | + | ||
- | + | var headerElem = document.getElementById('ddHeader' + id); | |
- | + | var contentElem = document.getElementById('ddContent' + id); | |
- | + | clearTimeout(headerElem.timer); | |
- | + | clearInterval(contentElem.timer); | |
- | + | ||
- | + | if (contentElem.offsetHeight < contentElem.maxh) { | |
+ | contentElem.timer = setInterval(function(){ddSlide(contentElem,1)}, ddtimer); | ||
+ | } //end if | ||
+ | |||
} | } | ||
//Incrementally expand/contract the dropdown and change the opacity | //Incrementally expand/contract the dropdown and change the opacity | ||
- | function ddSlide( | + | function ddSlide(contentElem,direction) { |
- | + | ||
- | + | var curHeight = contentElem.offsetHeight; | |
- | + | ||
- | + | if (direction == 1) { | |
- | + | distance = Math.round((contentElem.maxh - curHeight) / ddspeed); | |
- | + | } else { | |
- | + | distance = Math.round(curHeight / ddspeed); | |
- | + | } //end if | |
- | + | ||
- | + | if (distance <= 1) { | |
- | + | if (direction == 1) { | |
- | + | distance = 1; | |
- | + | } //end if | |
- | + | } //end if | |
- | + | ||
- | + | contentElem.style.height = curHeight + (distance * direction) + 'px'; | |
- | + | contentElem.style.opacity = curHeight / contentElem.maxh; | |
- | + | contentElem.style.filter = 'alpha(opacity=' + (curHeight * 100 / contentElem.maxh) + ')'; | |
- | + | ||
- | + | if (curHeight < 2) { | |
- | + | if (direction != 1) { | |
- | + | clearInterval(contentElem.timer); | |
- | + | } //end if | |
- | + | } else if (curHeight > (contentElem.maxh - 2)) { | |
- | } | + | if (direction == 1) { |
+ | clearInterval(contentElem.timer); | ||
+ | } //end if | ||
+ | } //end if | ||
+ | } //end function ddSlide | ||
//******************************************************************* | //******************************************************************* | ||
Line 488: | Line 499: | ||
<td> | <td> | ||
<dl> | <dl> | ||
- | <dt id=" | + | <dt id="ddHeader1" onClick="linkTo('https://2012.igem.org/Team:Colorado_State')">Home</dt> |
- | <dd id=" | + | <dd id="ddContent1"> |
<ul> | <ul> | ||
<li><a href="https://2012.igem.org/Team:Colorado_State/Project">Home</a></li> | <li><a href="https://2012.igem.org/Team:Colorado_State/Project">Home</a></li> | ||
Line 498: | Line 509: | ||
<td> | <td> | ||
<dl> | <dl> | ||
- | <dt id=" | + | <dt id="ddHeader2" onMouseOver="ddMain(2,1)" onMouseOut="ddMain(2)">The Brew</dt> |
- | <dd id=" | + | <dd id="ddContent2" onMouseOver="cancelCollapse(2)" onMouseOut="ddMain(2)"> |
<ul> | <ul> | ||
- | + | <li><a href="https://2012.igem.org/Team:Colorado_State/Project">Project Summary</a></li> | |
<li><a href="https://2012.igem.org/Team:Colorado_State/Parts">Parts Submitted to the Registry</a></li> | <li><a href="https://2012.igem.org/Team:Colorado_State/Parts">Parts Submitted to the Registry</a></li> | ||
<li><a href="https://2012.igem.org/Team:Colorado_State/Results">Results</a></li> | <li><a href="https://2012.igem.org/Team:Colorado_State/Results">Results</a></li> | ||
Line 514: | Line 525: | ||
<td> | <td> | ||
<dl> | <dl> | ||
- | <dt id=" | + | <dt id="ddHeader3" onMouseOver="ddMenu(3,1)" onMouseOut="ddMenu(3)">The Brewers</dt> |
- | <dd id=" | + | <dd id="ddContent3" onMouseOver="cancelHide(3)" onMouseOut="ddMenu(3)"> |
<ul> | <ul> | ||
<li><a href="https://2012.igem.org/Team:Colorado_State/Team">Meet the Students</a></li> | <li><a href="https://2012.igem.org/Team:Colorado_State/Team">Meet the Students</a></li> |
Revision as of 17:27, 31 July 2012