Difference between revisions of "Template:Team:TU Eindhoven/Menu Script"
(201 intermediate revisions by 5 users not shown) | |||
Line 17: | Line 17: | ||
setTimeout(function(){element.css("pointer-events","auto")},400); | setTimeout(function(){element.css("pointer-events","auto")},400); | ||
}); | }); | ||
+ | |||
+ | //Wikitour | ||
+ | $(document).ready(function(){ | ||
+ | var landingPageHeight = $('#landingPage').height(); | ||
+ | var windowHeight = $(window).height(); | ||
+ | var scrollNow = landingPageHeight - windowHeight; | ||
+ | |||
+ | $('#wikiTour').hover( function(){$('#wikiTour').fadeTo(0,1);}, function(){ | ||
+ | if ($(window).scrollTop() > 0) { | ||
+ | $('#wikiTour').fadeTo(0, 1); | ||
+ | } else { | ||
+ | $('#wikiTour').fadeTo(0, 0.4); | ||
+ | } }); | ||
+ | |||
+ | //Check to see if the window is top if not then display button | ||
+ | $(window).scroll(function(){ | ||
+ | |||
+ | if ($(window).scrollTop() > 0) { | ||
+ | $('#wikiTour').fadeTo(0, 1); | ||
+ | } else { | ||
+ | $('#wikiTour').fadeTo(0, 0.4); | ||
+ | } | ||
+ | |||
+ | }); | ||
+ | |||
+ | }); | ||
//scroll zooi van hans | //scroll zooi van hans | ||
− | + | $("a[href*=#]").click(function(e) { | |
− | + | if($(this).hasClass("extern")){ | |
− | }); | + | return; |
+ | } | ||
+ | e.preventDefault(); | ||
+ | var id= $(this).attr('href'); | ||
+ | id = id.substring(id.lastIndexOf("#")); | ||
+ | var el = $(id); | ||
+ | //If there is no element with this id, check for name attribute | ||
+ | if (el.length <= 0){ | ||
+ | el = $('[name=' + id.substring(1)+ ']'); | ||
+ | } | ||
+ | $('html, body').animate({ scrollTop: el.offset().top - 40}, 1000); | ||
+ | |||
+ | }); | ||
+ | |||
+ | $(window).scroll(function(){ | ||
+ | if( $(window).scrollTop() == 0){ | ||
+ | $("#scrollUp").css("display","none"); | ||
+ | } | ||
+ | else{ | ||
+ | $("#scrollUp").css("display","initial"); | ||
+ | } | ||
+ | |||
+ | $("#scrollUp").css("opacity", $(window).scrollTop() / 400); | ||
+ | }); | ||
+ | |||
+ | $("#scrollUp").click(function() { | ||
+ | $('html, body').animate({ scrollTop: 0}, 1000); | ||
+ | setTimeout(function(){$("#scrollUp").css("bottom","calc(0)");},1000); | ||
+ | }); | ||
// Get current Page | // Get current Page | ||
Line 27: | Line 81: | ||
switch (locus) { | switch (locus) { | ||
case '/Team:TU_Eindhoven': | case '/Team:TU_Eindhoven': | ||
− | submenu = | + | submenu = 1; |
break; | break; | ||
case '/Team:TU_Eindhoven/Team': | case '/Team:TU_Eindhoven/Team': | ||
Line 48: | Line 102: | ||
break; | break; | ||
case '/Team:TU_Eindhoven/Project/Experimental_Approach': | case '/Team:TU_Eindhoven/Project/Experimental_Approach': | ||
+ | submenu = 3; | ||
+ | break; | ||
+ | case '/Team:TU_Eindhoven/Project/Protocols': | ||
+ | submenu = 3; | ||
+ | break; | ||
+ | case '/Team:TU_Eindhoven/Project': | ||
submenu = 3; | submenu = 3; | ||
break; | break; | ||
Line 53: | Line 113: | ||
submenu = 3; | submenu = 3; | ||
break; | break; | ||
− | case '/Team:TU_Eindhoven/Project/ | + | case '/Team:TU_Eindhoven/Project/Expression_System': |
submenu = 3; | submenu = 3; | ||
break; | break; | ||
− | case '/Team:TU_Eindhoven/ | + | case '/Team:TU_Eindhoven/Measurement': |
submenu = 4; | submenu = 4; | ||
break; | break; | ||
− | case '/Team:TU_Eindhoven/ | + | case '/Team:TU_Eindhoven/ResultsHome': |
submenu = 4; | submenu = 4; | ||
break; | break; | ||
− | case '/Team:TU_Eindhoven/ | + | case '/Team:TU_Eindhoven/Results': |
submenu = 4; | submenu = 4; | ||
break; | break; | ||
− | case '/Team:TU_Eindhoven/ | + | case '/Team:TU_Eindhoven/Achievements': |
submenu = 4; | submenu = 4; | ||
break; | break; | ||
− | case '/Team:TU_Eindhoven/ | + | case '/Team:TU_Eindhoven/Parts': |
+ | submenu = 4; | ||
+ | break; | ||
+ | case '/Team:TU_Eindhoven/Modeling': | ||
submenu = 5; | submenu = 5; | ||
break; | break; | ||
− | case '/Team:TU_Eindhoven/ | + | case '/Team:TU_Eindhoven/Modeling/Approach': |
submenu = 5; | submenu = 5; | ||
break; | break; | ||
− | case '/Team:TU_Eindhoven/ | + | case '/Team:TU_Eindhoven/Modeling/Script': |
submenu = 5; | submenu = 5; | ||
+ | break; | ||
+ | case '/Team:TU_Eindhoven/Modeling/Results': | ||
+ | submenu = 5; | ||
+ | break; | ||
+ | case '/Team:TU_Eindhoven/Practices': | ||
+ | submenu = 6; | ||
+ | break; | ||
+ | case '/Team:TU_Eindhoven/Policy_Practices/Regulations': | ||
+ | submenu = 6; | ||
+ | break; | ||
+ | case '/Team:TU_Eindhoven/Policy_Practices/Stakeholders': | ||
+ | submenu = 6; | ||
+ | break; | ||
+ | case '/Team:TU_Eindhoven/Policy_Practices/Human_Outreach': | ||
+ | submenu = 6; | ||
+ | break; | ||
+ | case '/Team:TU_Eindhoven/Policy_Practices/Application_scenarios': | ||
+ | submenu = 6; | ||
+ | break; | ||
+ | case '/Team:TU_Eindhoven/Collaborations': | ||
+ | submenu = 7; | ||
+ | break; | ||
+ | case '/Team:TU_Eindhoven/Collaborations/CloningGuide': | ||
+ | submenu = 7; | ||
+ | break; | ||
+ | case '/Team:TU_Eindhoven/Collaborations/AmoyNewsletter': | ||
+ | submenu = 7; | ||
+ | break; | ||
+ | case '/Team:TU_Eindhoven/Collaborations/Collaboration_Attributions': | ||
+ | submenu = 7; | ||
+ | break; | ||
+ | case '/Team:TU_Eindhoven/Collaborations/CloningGuide/FullScreen': | ||
+ | submenu = 7; | ||
break; | break; | ||
case '/Team:TU_Eindhoven/Team/Sponsors': | case '/Team:TU_Eindhoven/Team/Sponsors': | ||
− | submenu = | + | submenu = 8; |
+ | break; | ||
+ | case '/Team:TU_Eindhoven/Safety/Lab': | ||
+ | submenu = 9; | ||
+ | break; | ||
+ | case '/Team:TU_Eindhoven/Safety': | ||
+ | submenu = 9; | ||
+ | break; | ||
+ | case '/Team:TU_Eindhoven/Safety/Project': | ||
+ | submenu = 9; | ||
+ | break; | ||
+ | case '/Team:TU_Eindhoven/Safety/LabEquipment': | ||
+ | submenu = 9; | ||
break; | break; | ||
}; // "submenu" contains the number of the submenu to be shown by default (or 0 for none). | }; // "submenu" contains the number of the submenu to be shown by default (or 0 for none). | ||
Line 94: | Line 202: | ||
var a = 0; | var a = 0; | ||
+ | var fb_twit = 0; | ||
$("#twitter_logo,#twitter").hover( | $("#twitter_logo,#twitter").hover( | ||
function() { | function() { | ||
− | $("#twitter").css("z-index", " | + | $("#twitter").css("z-index","11"); |
+ | $("#twitter").css("display","initial"); | ||
+ | $("#menu1,#menu2,#menu3,#menu4,#menu5,#menu6,#menu7,#menu8,#menu9").css("color", "#004415"); | ||
+ | $("#submenu").css("height","0px"); | ||
+ | fb_twit = 1; | ||
}, | }, | ||
function() { | function() { | ||
− | $("#twitter").css("z-index", "-1"); | + | $("#twitter").css("z-index","-1"); |
+ | $("#twitter").css("display","none"); | ||
+ | fb_twit = 0; | ||
+ | defaultMenu(); | ||
}); | }); | ||
$("#facebook_logo,#facebook").hover( | $("#facebook_logo,#facebook").hover( | ||
function() { | function() { | ||
− | $("#facebook").css("z-index", " | + | $("#facebook").css("z-index","11"); |
+ | $("#facebook").css("display","initial"); | ||
+ | $("#menu1,#menu2,#menu3,#menu4,#menu5,#menu6,#menu7,#menu8,#menu9").css("color", "#004415"); | ||
+ | $("#submenu").css("height","0px"); | ||
+ | fb_twit = 1; | ||
}, | }, | ||
function() { | function() { | ||
− | $("#facebook").css("z-index", "-1"); | + | $("#facebook").css("z-index","-1"); |
+ | $("#facebook").css("display","none"); | ||
+ | fb_twit = 0; | ||
+ | defaultMenu(); | ||
}); | }); | ||
Line 133: | Line 256: | ||
function() { | function() { | ||
a = 6; | a = 6; | ||
+ | }); | ||
+ | $("#menu7").hover( | ||
+ | function() { | ||
+ | a = 7; | ||
+ | }); | ||
+ | $("#menu8").hover( | ||
+ | function() { | ||
+ | a = 8; | ||
+ | }); | ||
+ | $("#menu9").hover( | ||
+ | function() { | ||
+ | a = 9; | ||
}); | }); | ||
Line 158: | Line 293: | ||
case 5: | case 5: | ||
$("#menu5").css("color", "#9DC671"); | $("#menu5").css("color", "#9DC671"); | ||
+ | $("#submenu").css("height", "60px"); | ||
+ | break; | ||
+ | case 6: | ||
+ | $("#menu6").css("color", "#9DC671"); | ||
+ | $("#submenu").css("height", "60px"); | ||
+ | break; | ||
+ | case 7: | ||
+ | $("#menu7").css("color", "#9DC671"); | ||
+ | $("#submenu").css("height", "60px"); | ||
+ | break; | ||
+ | case 9: | ||
+ | $("#menu9").css("color", "#9DC671"); | ||
$("#submenu").css("height", "60px"); | $("#submenu").css("height", "60px"); | ||
break; | break; | ||
Line 163: | Line 310: | ||
}, | }, | ||
function() { | function() { | ||
− | + | subhover = 0; | |
− | + | defaultMenu(); | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
}); | }); | ||
− | $("#menu1,#menu2,#menu3,#menu4,#menu5,#menu6").hover( | + | $("#menu1,#menu2,#menu3,#menu4,#menu5,#menu6,#menu7,#menu8,#menu9").hover( |
function() { | function() { | ||
menuhover = 1; | menuhover = 1; | ||
//reset alles en display dan alleen de juiste | //reset alles en display dan alleen de juiste | ||
− | $("#menu1,#menu2,#menu3,#menu4,#menu5,#menu6").css("color", "#004415"); | + | $("#menu1,#menu2,#menu3,#menu4,#menu5,#menu6,#menu7,#menu8,#menu9").css("color", "#004415"); |
− | $("#sub2,#sub3,#sub4,#sub5").css("display", "none"); | + | $("#sub2,#sub3,#sub4,#sub5,#sub6,#sub7,#sub9").css("display","none"); |
switch (a) { | switch (a) { | ||
case 1: | case 1: | ||
$("#menu1").css("color", "#9DC671"); | $("#menu1").css("color", "#9DC671"); | ||
+ | $("#submenu").css("height","0px"); | ||
break; | break; | ||
case 2: | case 2: | ||
$("#menu2").css("color", "#9DC671"); | $("#menu2").css("color", "#9DC671"); | ||
− | $("#sub2").css("display", "block"); | + | $("#sub2").css("display","block"); |
$("#submenu").css("height", "60px"); | $("#submenu").css("height", "60px"); | ||
break; | break; | ||
case 3: | case 3: | ||
$("#menu3").css("color", "#9DC671"); | $("#menu3").css("color", "#9DC671"); | ||
− | $("#sub3").css("display", "block"); | + | $("#sub3").css("display","block"); |
$("#submenu").css("height", "60px"); | $("#submenu").css("height", "60px"); | ||
break; | break; | ||
case 4: | case 4: | ||
$("#menu4").css("color", "#9DC671"); | $("#menu4").css("color", "#9DC671"); | ||
− | $("#sub4").css("display", "block"); | + | $("#sub4").css("display","block"); |
$("#submenu").css("height", "60px"); | $("#submenu").css("height", "60px"); | ||
break; | break; | ||
case 5: | case 5: | ||
$("#menu5").css("color", "#9DC671"); | $("#menu5").css("color", "#9DC671"); | ||
− | $("#sub5").css("display", "block"); | + | $("#sub5").css("display","block"); |
$("#submenu").css("height", "60px"); | $("#submenu").css("height", "60px"); | ||
break; | break; | ||
case 6: | case 6: | ||
$("#menu6").css("color", "#9DC671"); | $("#menu6").css("color", "#9DC671"); | ||
+ | $("#sub6").css("display","block"); | ||
+ | $("#submenu").css("height", "60px"); | ||
+ | break; | ||
+ | case 7: | ||
+ | $("#menu7").css("color", "#9DC671"); | ||
+ | $("#sub7").css("display","block"); | ||
+ | $("#submenu").css("height", "60px"); | ||
+ | break; | ||
+ | case 8: | ||
+ | $("#menu8").css("color", "#9DC671"); | ||
+ | $("#submenu").css("height", "0px"); | ||
+ | break; | ||
+ | case 9: | ||
+ | $("#menu9").css("color", "#9DC671"); | ||
+ | $("#sub9").css("display","block"); | ||
+ | $("#submenu").css("height", "60px"); | ||
break; | break; | ||
} | } | ||
}, | }, | ||
function() { | function() { | ||
− | + | menuhover = 0; | |
− | + | defaultMenu(); | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
}); | }); | ||
+ | |||
+ | defaultMenu(); | ||
// Show default menu | // Show default menu | ||
function defaultMenu() { | function defaultMenu() { | ||
− | + | setTimeout(function(){ | |
+ | if (subhover == 1 || menuhover == 1 || fb_twit == 1){ | ||
+ | } | ||
+ | else{ | ||
+ | a = submenu; | ||
+ | if (submenu == 1 || submenu == 8 ){ | ||
+ | $("#submenu").css("height", "0"); | ||
+ | $("#menu1,#menu2,#menu3,#menu4,#menu5,#menu6,#menu7,#menu8,#menu9").css("color", "#004415"); | ||
+ | $("#sub2,#sub3,#sub4,#sub5,#sub6,#sub7,#sub9").css("display","none"); | ||
+ | $("#menu"+submenu.toString()).css("color", "#9DC671"); | ||
+ | } | ||
+ | else{ | ||
+ | $("#sub2,#sub3,#sub4,#sub5,#sub6,#sub7,#sub9").css("display","none"); | ||
+ | $("#submenu").css("height", "60px"); | ||
+ | $("#menu1,#menu2,#menu3,#menu4,#menu5,#menu6,#menu7,#menu8,#menu9").css("color", "#004415"); | ||
+ | $("#sub"+submenu.toString()).css("display","block"); | ||
+ | $("#menu"+submenu.toString()).css("color", "#9DC671"); | ||
+ | } | ||
+ | } | ||
+ | },5); | ||
} | } | ||
Line 253: | Line 418: | ||
//Content Menu | //Content Menu | ||
− | $("#contentToggle").css("height",$("#infoTab"). | + | $("#contentToggle").css("height",$("#infoTab").outerHeight()); |
− | $("#infoTabContent").css("height",$("#infoTabContent"). | + | $("#infoTabContent").css("height",$("#infoTabContent").outerHeight()); |
+ | $("#infoTab").css("top","calc(50% - " + $("#infoTab").outerHeight()/2 + "px"); | ||
− | if( | + | if(localStorage.getItem('contentMenu') == null){ |
− | + | localStorage.contentMenu = "true"; | |
} | } | ||
else{ | else{ | ||
Line 264: | Line 430: | ||
$("#contentToggle").click(function(){ | $("#contentToggle").click(function(){ | ||
− | if( | + | if(localStorage.contentMenu == "true"){ |
$("#infoTab").css("transition","transform 1s"); | $("#infoTab").css("transition","transform 1s"); | ||
− | $("#infoTab").css("transform","translate(-80%,0)"); | + | var scale = 200/$("#infoTab").outerHeight(); |
+ | $("#infoTab").css("transform","translate(-80%,0) scale(1"+","+scale.toString()); | ||
$("#contentToggleImg").css("transform","rotate(180deg)"); | $("#contentToggleImg").css("transform","rotate(180deg)"); | ||
− | + | localStorage.contentMenu = "false"; | |
} | } | ||
else{ | else{ | ||
$("#infoTab").css("transition","transform 1s"); | $("#infoTab").css("transition","transform 1s"); | ||
− | $("#infoTab").css("transform","translate(0,0)"); | + | $("#infoTab").css("transform","translate(0,0) scale(1,1)"); |
$("#contentToggleImg").css("transform","rotate(0deg)"); | $("#contentToggleImg").css("transform","rotate(0deg)"); | ||
− | + | localStorage.contentMenu = "true"; | |
} | } | ||
}); | }); | ||
Line 295: | Line 462: | ||
}); | }); | ||
− | |||
function contentMenuCheck() { | function contentMenuCheck() { | ||
− | if( | + | if(localStorage.contentMenu == "false"){ |
$("#infoTab").css("transition","none"); | $("#infoTab").css("transition","none"); | ||
− | $("#infoTab").css("transform","translate(-80%,0)"); | + | var scale = 200/$("#infoTab").outerHeight(); |
+ | $("#infoTab").css("transform","translate(-80%,0) scale(1"+","+scale.toString()); | ||
$("#contentToggleImg").css("transform","rotate(180deg)"); | $("#contentToggleImg").css("transform","rotate(180deg)"); | ||
} | } | ||
} | } | ||
</html> | </html> |
Latest revision as of 01:06, 21 November 2015
$(document).ready(function() { //uitklap zooi van hans JW is een BITCH HANS is CRACKIE $('.spoilerbutton').click(function() { var id = "spoiler" + $(this).attr("id").match(/\d+/); if ($(this).attr("src").indexOf("Uitgeklapt") != -1) { $(this).attr("src","https://static.igem.org/mediawiki/2015/8/87/TU_Eindhoven_Ingeklapt.png"); $('#' + id).slideToggle(); } else { $(this).attr("src","https://static.igem.org/mediawiki/2015/6/65/TU_Eindhoven_Uitgeklapt.png"); $('#' + id).slideToggle(); }; var element = $(this); element.css("pointer-events","none"); setTimeout(function(){element.css("pointer-events","auto")},400); }); //Wikitour $(document).ready(function(){ var landingPageHeight = $('#landingPage').height(); var windowHeight = $(window).height(); var scrollNow = landingPageHeight - windowHeight; $('#wikiTour').hover( function(){$('#wikiTour').fadeTo(0,1);}, function(){ if ($(window).scrollTop() > 0) { $('#wikiTour').fadeTo(0, 1); } else { $('#wikiTour').fadeTo(0, 0.4); } }); //Check to see if the window is top if not then display button $(window).scroll(function(){ if ($(window).scrollTop() > 0) { $('#wikiTour').fadeTo(0, 1); } else { $('#wikiTour').fadeTo(0, 0.4); } }); }); //scroll zooi van hans $("a[href*=#]").click(function(e) { if($(this).hasClass("extern")){ return; } e.preventDefault(); var id= $(this).attr('href'); id = id.substring(id.lastIndexOf("#")); var el = $(id); //If there is no element with this id, check for name attribute if (el.length <= 0){ el = $('[name=' + id.substring(1)+ ']'); } $('html, body').animate({ scrollTop: el.offset().top - 40}, 1000); }); $(window).scroll(function(){ if( $(window).scrollTop() == 0){ $("#scrollUp").css("display","none"); } else{ $("#scrollUp").css("display","initial"); } $("#scrollUp").css("opacity", $(window).scrollTop() / 400); }); $("#scrollUp").click(function() { $('html, body').animate({ scrollTop: 0}, 1000); setTimeout(function(){$("#scrollUp").css("bottom","calc(0)");},1000); }); // Get current Page locus=$(location).attr('pathname'); submenu = 0; switch (locus) { case '/Team:TU_Eindhoven': submenu = 1; break; case '/Team:TU_Eindhoven/Team': submenu = 2; break; case '/Team:TU_Eindhoven/Team/Members': submenu = 2; break; case '/Team:TU_Eindhoven/Team/Supervisors': submenu = 2; break; case '/Team:TU_Eindhoven/Attributions': submenu = 2; break; case '/Team:TU_Eindhoven/Description': submenu = 3; break; case '/Team:TU_Eindhoven/Project/Design': submenu = 3; break; case '/Team:TU_Eindhoven/Project/Experimental_Approach': submenu = 3; break; case '/Team:TU_Eindhoven/Project/Protocols': submenu = 3; break; case '/Team:TU_Eindhoven/Project': submenu = 3; break; case '/Team:TU_Eindhoven/Notebook': submenu = 3; break; case '/Team:TU_Eindhoven/Project/Expression_System': submenu = 3; break; case '/Team:TU_Eindhoven/Measurement': submenu = 4; break; case '/Team:TU_Eindhoven/ResultsHome': submenu = 4; break; case '/Team:TU_Eindhoven/Results': submenu = 4; break; case '/Team:TU_Eindhoven/Achievements': submenu = 4; break; case '/Team:TU_Eindhoven/Parts': submenu = 4; break; case '/Team:TU_Eindhoven/Modeling': submenu = 5; break; case '/Team:TU_Eindhoven/Modeling/Approach': submenu = 5; break; case '/Team:TU_Eindhoven/Modeling/Script': submenu = 5; break; case '/Team:TU_Eindhoven/Modeling/Results': submenu = 5; break; case '/Team:TU_Eindhoven/Practices': submenu = 6; break; case '/Team:TU_Eindhoven/Policy_Practices/Regulations': submenu = 6; break; case '/Team:TU_Eindhoven/Policy_Practices/Stakeholders': submenu = 6; break; case '/Team:TU_Eindhoven/Policy_Practices/Human_Outreach': submenu = 6; break; case '/Team:TU_Eindhoven/Policy_Practices/Application_scenarios': submenu = 6; break; case '/Team:TU_Eindhoven/Collaborations': submenu = 7; break; case '/Team:TU_Eindhoven/Collaborations/CloningGuide': submenu = 7; break; case '/Team:TU_Eindhoven/Collaborations/AmoyNewsletter': submenu = 7; break; case '/Team:TU_Eindhoven/Collaborations/Collaboration_Attributions': submenu = 7; break; case '/Team:TU_Eindhoven/Collaborations/CloningGuide/FullScreen': submenu = 7; break; case '/Team:TU_Eindhoven/Team/Sponsors': submenu = 8; break; case '/Team:TU_Eindhoven/Safety/Lab': submenu = 9; break; case '/Team:TU_Eindhoven/Safety': submenu = 9; break; case '/Team:TU_Eindhoven/Safety/Project': submenu = 9; break; case '/Team:TU_Eindhoven/Safety/LabEquipment': submenu = 9; break; }; // "submenu" contains the number of the submenu to be shown by default (or 0 for none). // icon var link = document.createElement('link'); link.type = 'image/x-icon'; link.rel = 'shortcut icon'; link.href = 'https://static.igem.org/mediawiki/2015/4/4a/Logo_Eindhoven_small.png'; document.getElementsByTagName('head')[0].appendChild(link); //background $("