Team:Queens-Canada/full/animat0r.js
From 2010.igem.org
(2 intermediate revisions not shown) | |||
Line 220: | Line 220: | ||
var tg = document.getElementById("t_guide"); | var tg = document.getElementById("t_guide"); | ||
- | if( | + | if(tg.style.width == "auto") { |
if(force == 2) toPage("guide"); | if(force == 2) toPage("guide"); | ||
return; | return; | ||
Line 280: | Line 280: | ||
var tg = document.getElementById("t_guide"); | var tg = document.getElementById("t_guide"); | ||
- | if( | + | if(tp.style.width == "auto") { |
if(force == 2) toPage("project"); | if(force == 2) toPage("project"); | ||
return; | return; |
Latest revision as of 03:14, 27 October 2010
var transitioning = 0; var width = 0; var fading = 0; var T2 = null;
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) { hideT2(); showProject(); } if(strpos(ifr.contentDocument.URL, 'idea') != false) { showProject(1); hideT2(progress, 1); } if(strpos(ifr.contentDocument.URL, 'notebook') != false) { showProject(1); hideT2(progress, 1); } if(strpos(ifr.contentDocument.URL, 'safety') != false) { showProject(1); hideT2(progress, 1); } if(strpos(ifr.contentDocument.URL, 'team') != false) { hideT2(); showProject(); } if(strpos(ifr.contentDocument.URL, 'contributors') != false) { showProject(1); hideT2(people, 1); } if(strpos(ifr.contentDocument.URL, 'parts') != false) { showProject(1); hideT2(parts, 1); } if(strpos(ifr.contentDocument.URL, 'contributing') != false) { showProject(1); hideT2(biobricks, 1); } if(strpos(ifr.contentDocument.URL, 'sponsors') != false) { showProject(); }
if(strpos(ifr.contentDocument.URL, 'guide') != false) { hideT2(); showGuide(); } if(strpos(ifr.contentDocument.URL, 'intro') != false) { showGuide(1); hideT2(context, 1); } if(strpos(ifr.contentDocument.URL, 'history') != false) { showGuide(1); hideT2(context, 1); } if(strpos(ifr.contentDocument.URL, 'resources') != false) { showGuide(1); hideT2(context, 1); } if(strpos(ifr.contentDocument.URL, 'exterior') != false) { showGuide(1); hideT2(anatomy, 1); } if(strpos(ifr.contentDocument.URL, 'pseudocoelom') != false) { showGuide(1); hideT2(anatomy, 1); } if(strpos(ifr.contentDocument.URL, 'digestive') != false) { showGuide(1); hideT2(anatomy, 1); } if(strpos(ifr.contentDocument.URL, 'nervous') != false) { showGuide(1); hideT2(anatomy, 1); } if(strpos(ifr.contentDocument.URL, 'reproductive') != false) { showGuide(1); hideT2(anatomy, 1); } if(strpos(ifr.contentDocument.URL, 'promoter') != false) { showGuide(1); hideT2(genetics, 1); } if(strpos(ifr.contentDocument.URL, 'transcripts') != false) { showGuide(1); hideT2(genetics, 1); } if(strpos(ifr.contentDocument.URL, 'rnai') != false) { showGuide(1); hideT2(genetics, 1); } if(strpos(ifr.contentDocument.URL, 'strains') != false) { showGuide(1); hideT2(genetics, 1); } if(strpos(ifr.contentDocument.URL, 'transformation') != false) { showGuide(1); hideT2(practical, 1); } if(strpos(ifr.contentDocument.URL, 'care') != false) { showGuide(1); hideT2(practical, 1); } if(strpos(ifr.contentDocument.URL, 'protocols') != false) { showGuide(1); hideT2(practical, 1); }
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', 'overview') + 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() { toPage("team"); // var t2 = document.getElementById("tier2"); // width = 100/2; // t2.innerHTML = mt('team', 'the team') + mt('contributors'); // showT2(); }
function practical() { var t2 = document.getElementById("tier2"); width = 100/3; t2.innerHTML = mt('transformation') + mt('care') + mt('protocols', 'miscellaneous'); showT2(); }
function anatomy() { var t2 = document.getElementById("tier2"); width = 100/5; t2.innerHTML = mt('pseudocoelom') + mt('digestive') + mt('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('transcripts', 'introns and transcripts') + mt('rnai', "rna interference and 3' utr") + 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, force) { if(callback == T2) return; T2 = callback; var t2 = document.getElementById("tier2"); if(t2.style.top == '100px') { if(callback != null) callback(); } else { if(transitioning == 1 && force == 0) 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(force) { var tp = document.getElementById("t_project"); var tg = document.getElementById("t_guide");
if(tg.style.width == "auto") { if(force == 2) toPage("guide"); 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;
if(force != 1) 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(force) { var tp = document.getElementById("t_project"); var tg = document.getElementById("t_guide");
if(tp.style.width == "auto") { if(force == 2) toPage("project"); 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();
if(force != 1) hideT2();
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; }