Team:Queens-Canada/full/animat0r.js
From 2010.igem.org
Line 145: | Line 145: | ||
var t2 = document.getElementById("tier2"); | var t2 = document.getElementById("tier2"); | ||
width = 100/5; | width = 100/5; | ||
- | t2.innerHTML = mt('pseudocoelom') + mt('digestive') + mt('nervous', ' | + | t2.innerHTML = mt('pseudocoelom') + mt('digestive') + mt('nervous', 'nervous') + mt('skin', 'exterior') + mt('reproductive'); |
showT2(); | showT2(); | ||
} | } |
Revision as of 15:33, 24 October 2010
var transitioning = 0; var width = 0; var fading = 0;
function resizeIframe() { var height = document.getElementById('tier0p').clientHeight; var ifr = document.getElementById('the_frame'); ifr.style.height = height + "px"; }
function prep() { var ifr = document.getElementById("the_frame");
ifr.style.opacity = 0; /*@cc_on ifr.style.filter = "alpha(opacity=0)"; @*/
if (ifr.addEventListener) { ifr.addEventListener("load", showPage, false) } else if(ifr.attachEvent) { ifr.detachEvent("onload", showPage) // Bug fix line ifr.attachEvent("onload", showPage) }
showPage(); resizeIframe(); window.onresize = resizeIframe; }
function strpos(haystack, needle, offset) {
var i = (haystack+).indexOf(needle, (offset || 0)); return i === -1 ? false : i;
}
function showPage() { var ifr = document.getElementById("the_frame");
animateFade(1, 0); if(strpos(ifr.contentDocument.URL, 'project') != false) showProject(); if(strpos(ifr.contentDocument.URL, 'guide') != false) showGuide();
document.body.style.cursor = 'default'; }
function toPage(url) { animateFade(0, 1, url); }
function animateFade(to, at, url) { if((to == 1) && fading == 0) fading = 1; if((to == 0) && fading == 1) return; var ifr = document.getElementById("the_frame"); opa = at; ifr.style.opacity = opa; /*@cc_on ifr.style.filter = "alpha(opacity=" + opa * 100 + ")"; @*/
if(to == 1) opa = opa + 0.1; if(to == 0) opa = opa - 0.1; if((opa < to) && to == 0) { document.body.style.cursor = 'wait'; ifr.src = url;
ifr.style.opacity = 0; /*@cc_on ifr.style.filter = "alpha(opacity=0)"; @*/
// ifr.onload = 'animateFade(1, 0)'; // setTimeout('animateFade(1, 0)', 20); return; } if((opa > to) && to == 1) { fading = 0; ifr.style.opacity = 1; /*@cc_on ifr.style.filter = "alpha(opacity=100)"; @*/
return; }
setTimeout('animateFade(' + to + ',' + opa + ',"' + url + '")', 1); }
function animateShowT2(percentDone) { var t2 = document.getElementById("tier2"); t2.style.top = (100 + percentDone * 35) + "px"; if(percentDone == 0.01) transitioning = 1;
percentDone = 1 - ((1 - percentDone) / 1.6); if(percentDone > 0.995) { transitioning = 0; t2.style.top = '135px'; return; }
setTimeout('animateShowT2(' + percentDone + ')', 40); }
function showT2() { setTimeout('animateShowT2(0.01)', 20); }
function mt(name, title) { if(title == null) title = name; width2 = width; /*@cc_on width2 -= 1; @*/
return '}
function progress() { var t2 = document.getElementById("tier2"); width = 100/3; t2.innerHTML = mt('idea', 'the idea') + mt('notebook', 'notebook') + mt('safety', 'safety'); showT2(); }
function biobricks() { var t2 = document.getElementById("tier2"); width = 100/2; t2.innerHTML = mt('parts', 'the parts') + mt('contributing', 'contributing'); showT2(); }
function sponsors() { toPage("sponsors"); }
function people() { var t2 = document.getElementById("tier2"); width = 100/2; t2.innerHTML = mt('team') + mt('contributors'); showT2(); }
function practical() { var t2 = document.getElementById("tier2"); width = 100/3; t2.innerHTML = mt('lifecycle') + mt('transformation') + mt('care'); showT2(); }
function anatomy() { var t2 = document.getElementById("tier2"); width = 100/5; t2.innerHTML = mt('pseudocoelom') + mt('digestive') + mt('nervous', 'nervous') + mt('skin', 'exterior') + mt('reproductive'); showT2(); }
function genetics() { var t2 = document.getElementById("tier2"); width = 100/4; t2.innerHTML = mt('promoter', "the promoter and 5' utr") + mt('rnai', "rna interference and 3' utr") + mt('termination', 'introns and termination') + mt('strains', 'strains and mutants'); showT2(); }
function context() { var t2 = document.getElementById("tier2"); width = 100/3; t2.innerHTML = mt('intro', 'introduction') + mt('history', 'history in science') + mt('resources', 'online resources'); showT2(); }
function hideT2(callback) { var t2 = document.getElementById("tier2"); if(t2.style.top == '100px') { if(callback != null) callback(); } else { if(transitioning == 1) return; transitioning = 1; animateHideT2(0.01, callback); } }
function animateHideT2(percentDone, callback) { var t2 = document.getElementById("tier2"); t2.style.top = (135 - percentDone * 35) + "px";
percentDone = 1 - ((1 - percentDone) / 1.6); if(percentDone > 0.995) { t2.style.top = '100px'; if(callback != null) { callback(); } transitioning = 0; } else { setTimeout('animateHideT2(' + percentDone + ',' + callback + ')', 40); } }
function showGuide() { var tp = document.getElementById("t_project"); var tg = document.getElementById("t_guide");
if(tp.style.left == "auto") return; if(transitioning == 1) return; var ig = document.getElementById("i_guide");
ig.src = "";
var flexSpace = document.getElementById("tier0tm2").clientWidth - 307 - 73 - 83; if(flexSpace < 5) return;
hideT2();
transitioning = 1;
tg.style.width = '73px'; tg.style.right = 'auto'; tp.style.width = (83 + flexSpace - 5) + 'px'; tp.style.left = 'auto';
animateGuide(0.01); }
function animateGuide(percentDone) { var tp = document.getElementById("t_project"); var tg = document.getElementById("t_guide");
var flexSpace = document.getElementById("tier0tm2").clientWidth - 307 - 73 - 83; var fS = flexSpace * percentDone;
tg.style.width = (73 + fS - 5) + "px"; tp.style.width = (83 + flexSpace - fS) + "px"; percentDone = 1 - ((1 - percentDone) / 1.6); if(percentDone > 0.995) { finishGuide(); return; }
setTimeout('animateGuide(' + percentDone + ')', 40); }
function finishGuide() { var tp = document.getElementById("t_project"); var tg = document.getElementById("t_guide"); var ip = document.getElementById("i_project");
ip.src = "";
tg.style.left = '0px'; tg.style.right = '395px'; tg.style.width = 'auto'; tp.style.left = 'auto'; tp.style.right = '307px'; tp.style.width = '83px'; transitioning = 0; }
// reverse function showProject() { var tp = document.getElementById("t_project"); var tg = document.getElementById("t_guide");
if(tg.style.right == "auto") return; if(transitioning == 1) return; var ip = document.getElementById("i_project");
ip.src = "";
var flexSpace = document.getElementById("tier0tm2").clientWidth - 307 - 73 - 83; if(flexSpace < 5) return;
hideT2();
transitioning = 1;
tg.style.width = (73 + flexSpace - 5) + 'px'; tg.style.right = 'auto'; tp.style.width = '83px'; tp.style.left = 'auto';
animateProject(0.01); }
function animateProject(percentDone) { var tp = document.getElementById("t_project"); var tg = document.getElementById("t_guide");
var flexSpace = document.getElementById("tier0tm2").clientWidth - 307 - 73 - 83; var fS = flexSpace * percentDone;
tg.style.width = (73 + flexSpace - fS) + "px"; tp.style.width = (83 + fS - 5) + "px"; percentDone = 1 - ((1 - percentDone) / 1.6); if(percentDone > 0.995) { finishProject(); return; }
setTimeout('animateProject(' + percentDone + ')', 40); }
function finishProject() { var tp = document.getElementById("t_project"); var tg = document.getElementById("t_guide"); var ig = document.getElementById("i_guide");
ig.src = "";
tg.style.left = '0px'; tg.style.right = 'auto'; tg.style.width = '73px'; tp.style.left = '78px'; tp.style.right = '307px'; tp.style.width = 'auto'; transitioning = 0; }