Team:WHU-China/assets/main.js
From 2014.igem.org
// Transition var fadeSectionTo = function ( target ) {
current = $( "main>section.current" ); current.fadeOut(100, function () { target.fadeIn(200) }); current.removeClass( "current" ); target.addClass( "current" );
};
var switchSectionTo = function ( object, ref, state, subnav ) {
fadeSectionTo( object );
$( "nav>ul>li" ).each(function () { $( this ).removeClass( "current" ); }); $( ref ).addClass( "current" );
$( "nav>ul>ul" ).slideUp(200); $( subnav ).slideDown(200);
window.history.pushState(state, "Home | iGEM: WHU-China", state);
};
$( "nav>ul>li:nth-of-type(1)" ).click(function () {
var target = $( "#home" ); switchSectionTo( target, this, "home" ); return false;
}); $( "nav>ul>li:nth-of-type(2)" ).click(function () {
var target = $( "#project" ); switchSectionTo( target, this, "project", $( "nav>ul>ul:nth-of-type(1)" ) ); return false;
}); $( "nav>ul>li:nth-of-type(3)" ).click(function () {
var target = $( "#achieve" ); switchSectionTo( target, this, "achieve", $( "nav>ul>ul:nth-of-type(2)" ) ); return false;
}); $( "nav>ul>li:nth-of-type(4)" ).click(function () {
var target = $( "#safety" ); switchSectionTo( target, this, "safety", $( "nav>ul>ul:nth-of-type(3)" ) ); return false;
}); $( "nav>ul>li:nth-of-type(5)" ).click(function () {
var target = $( "#practice" ); switchSectionTo( target, this, "practice", $( "nav>ul>ul:nth-of-type(4)" ) ); return false;
}); $( "nav>ul>li:nth-of-type(6)" ).click(function () {
var target = $( "#notebook" ); switchSectionTo( target, this, "notebook", $( "nav>ul>ul:nth-of-type(5)" ) ); return false;
}); $( "nav>ul>li:nth-of-type(7)" ).click(function () {
var target = $( "#team" ); switchSectionTo( target, this, "team", $( "nav>ul>ul:nth-of-type(6)" ) ); return false;
});