Difference between revisions of "Team:Utrecht/js/myFunctions"

 
(30 intermediate revisions by the same user not shown)
Line 11: Line 11:
 
//Definitions of Submenus
 
//Definitions of Submenus
  
var submenuProject = '<a href= "https://2018.igem.org/Team:Utrecht/ProjectOverview" id = "submenuProjectOverview"> <b>Overview</b></a> <a href="https://2018.igem.org/Team:Utrecht/Description" id = "submenuDescription" >Description</a><a href="https://2018.igem.org/Team:Utrecht/Design" id = "submenuDesign">Design</a><a href="https://2018.igem.org/Team:Utrecht/Model" id = "submenuModel">Model</a><a href="https://2018.igem.org/Team:Utrecht/Parts" id = "submenuBiobricks">Biobricks</a><a href="https://2018.igem.org/Team:Utrecht/SafeByDesign" id = "submenuSafeByDesign">Safety&Risks</a>';
+
var submenuProject = '<a href="https://2018.igem.org/Team:Utrecht/Description" id = "submenuDescription" ><b>Description</b></a><a href="https://2018.igem.org/Team:Utrecht/Design" id = "submenuDesign">Design</a><a href="https://2018.igem.org/Team:Utrecht/Model" id = "submenuModel">Model</a><a href="https://2018.igem.org/Team:Utrecht/Parts" id = "submenuBiobricks">Basic Biobricks</a><a href="https://2018.igem.org/Team:Utrecht/Improve" id = "submenuImprove">Improved Biobrick</a><a href="https://2018.igem.org/Team:Utrecht/SafeByDesign" id = "submenuSafeByDesign">Safety&Risks</a>';
  
var submenuLab = '<a href="https://2018.igem.org/Team:Utrecht/Notebook" id = "submenuNotebook">Lab Notebook</a> <a href="https://2018.igem.org/Team:Utrecht/Protocol" id = "submenuProtocol">Protocols</a> <a href="https://2018.igem.org/Team:Utrecht/Safety" id = "submenuSafety">Safety</a> <a href="https://2018.igem.org/Team:Utrecht/Results" id = "submenuResults">Results</a> <a href="https://2018.igem.org/Team:Utrecht/InterLab" id = "submenuInterLab">Interlab</a>';
+
var submenuLab = '<a href="https://2018.igem.org/Team:Utrecht/Notebook" id = "submenuNotebook"><b>Lab Notebook</b></a> <a href="https://2018.igem.org/Team:Utrecht/Protocol" id = "submenuProtocol">Protocols</a> <a href="https://2018.igem.org/Team:Utrecht/Safety" id = "submenuSafety">Safety</a> <a href="https://2018.igem.org/Team:Utrecht/Results" id = "submenuResults">Results</a> <a href="https://2018.igem.org/Team:Utrecht/InterLab" id = "submenuInterLab">Interlab</a>';
  
var submenuHP = '<a href="https://2018.igem.org/Team:Utrecht/Human_Practices" id = "submenuIntegratedHP">Integrated HP</a> <a href="https://2018.igem.org/Team:Utrecht/PublicEngagement" id = "submenuPE">Public Engagement</a> <a href="https://2018.igem.org/Team:Utrecht/Conference" id = "submenuConference">Conference</a> <a href="https://2018.igem.org/Team:Utrecht/MeetUps" id = "submenuMeetUps">Meet-Ups</a>';
+
var submenuHP = '<a href="https://2018.igem.org/Team:Utrecht/Human_Practices" id = "submenuIntegratedHP"><b>Integrated HP</b></a><a href="https://2018.igem.org/Team:Utrecht/Applied_Design" id = "submenuAppliedDesign">Applied Design</a><a href="https://2018.igem.org/Team:Utrecht/Public_Engagement" id = "submenuPE">Public Engagement</a> <a href="https://2018.igem.org/Team:Utrecht/Conference" id = "submenuConference">Conference</a> <a href="https://2018.igem.org/Team:Utrecht/MeetUps" id = "submenuMeetUps">Meet-Ups</a>';
  
var submenuJamboree = '<a href="https://2018.igem.org/Team:Utrecht/Vlogs" id = "submenuVlogs">Vlogs</a> <a href="https://2018.igem.org/Team:Utrecht/AfterJamboree" id = "submenuAJ">After Jamboree</a>';
+
var submenuJamboree = '<a href="https://2018.igem.org/Team:Utrecht/AfterJamboree" id = "submenuAJ"><b>After Jamboree</b></a>';
  
var submenuAboutUs = '<a href="https://2018.igem.org/Team:Utrecht/Team" id = "submenuTeam">Team</a> <a href="https://2018.igem.org/Team:Utrecht/Collaborations" id = "submenuCollaborations">Collabs</a>';
+
var submenuAboutUs = '<a href="https://2018.igem.org/Team:Utrecht/Team" id = "submenuTeam"><b>Team</b></a> <a href="https://2018.igem.org/Team:Utrecht/Collaborations" id = "submenuCollaborations">Collaborations</a>';
  
var submenuCredit = '<a href="https://2018.igem.org/Team:Utrecht/Attributions" id = "submenuAtributions">Attributions</a> <a href="https://2018.igem.org/Team:Utrecht/Sponsors" id = "submenuSponsors">Sponsors</a>';
+
var submenuCredit = '<a href="https://2018.igem.org/Team:Utrecht/Attributions" id = "submenuAtributions"><b>Attributions</b></a> <a href="https://2018.igem.org/Team:Utrecht/Sponsors" id = "submenuSponsors">Sponsors</a>';
  
  
Line 44: Line 44:
 
};
 
};
  
$("#menuAboutUs").hoverIntent(function(){
 
        $("#mySubmenu").stop();
 
        $("#mySubmenu").css("left","25vh");
 
$("#mySubmenu").html(submenuAboutUs);
 
        $(defActive).addClass('active');
 
});
 
 
 
 
$("#menuProject").hoverIntent(function(){
 
$("#menuProject").hoverIntent(function(){
 
         $("#mySubmenu").stop();
 
         $("#mySubmenu").stop();
         $("#mySubmenu").css("left","45vh");
+
         $("#mySubmenu").css("left","25vh");
 
$("#mySubmenu").html(submenuProject);         
 
$("#mySubmenu").html(submenuProject);         
 
         $(defActive).addClass('active');
 
         $(defActive).addClass('active');
Line 60: Line 54:
 
$("#menuLaboratory").hoverIntent(function(){
 
$("#menuLaboratory").hoverIntent(function(){
 
         $("#mySubmenu").stop();
 
         $("#mySubmenu").stop();
         $("#mySubmenu").css("left","65vh");
+
         $("#mySubmenu").css("left","45vh");
 
$("#mySubmenu").html(submenuLab);
 
$("#mySubmenu").html(submenuLab);
 
         $(defActive).addClass('active');
 
         $(defActive).addClass('active');
Line 67: Line 61:
 
$("#menuHumanPractices").hoverIntent(function(){
 
$("#menuHumanPractices").hoverIntent(function(){
 
         $("#mySubmenu").stop();
 
         $("#mySubmenu").stop();
         $("#mySubmenu").css("left","85vh");
+
         $("#mySubmenu").css("left","65vh");
 
$("#mySubmenu").html(submenuHP);
 
$("#mySubmenu").html(submenuHP);
 +
        $(defActive).addClass('active');
 +
});
 +
 +
$("#menuCredit").hoverIntent(function(){
 +
        $("#mySubmenu").stop();
 +
        $("#mySubmenu").css("left","85vh");
 +
$("#mySubmenu").html(submenuCredit);
 
         $(defActive).addClass('active');
 
         $(defActive).addClass('active');
 
});
 
});
Line 79: Line 80:
 
});
 
});
  
$("#menuCredit").hoverIntent(function(){
+
$("#menuAboutUs").hoverIntent(function(){
 
         $("#mySubmenu").stop();
 
         $("#mySubmenu").stop();
         $("#mySubmenu").css("left","125vh");
+
         $("#mySubmenu").css("left","125vh");
$("#mySubmenu").html(submenuCredit);
+
$("#mySubmenu").html(submenuAboutUs);
 
         $(defActive).addClass('active');
 
         $(defActive).addClass('active');
 
});
 
});
Line 95: Line 96:
 
var topMenu = $("#top-menu"),
 
var topMenu = $("#top-menu"),
 
     sideMenu = $("#side-menu"),
 
     sideMenu = $("#side-menu"),
 +
    secretMenu = $("#secret-menu"),
 
     topMenuHeight = topMenu.outerHeight()+ 15,
 
     topMenuHeight = topMenu.outerHeight()+ 15,
 
     menuItems = sideMenu.find("a");
 
     menuItems = sideMenu.find("a");
 +
    secretItems = secretMenu.find("a");
 
 
 
//menuItems.css("color", "green")
 
//menuItems.css("color", "green")
Line 109: Line 112:
 
   e.preventDefault();
 
   e.preventDefault();
 
});
 
});
 +
 +
if(location.hash){
 +
setTimeout(function() { 
 +
window.scrollBy(0, -topMenuHeight);
 +
}, 1000);
 +
};
 +
  
 
window.addEventListener("scroll", event => {
 
window.addEventListener("scroll", event => {
Line 160: Line 170:
 
     document.documentElement.scrollTop = 0; // For Chrome, Firefox, IE and Opera
 
     document.documentElement.scrollTop = 0; // For Chrome, Firefox, IE and Opera
 
}  
 
}  
 +
  
 
//Mobile Menu
 
//Mobile Menu

Latest revision as of 17:31, 5 December 2018

//Content exchange Teampage

function tellStory1(story){ $("#storyStudent").html(story); }

function tellStory2(story){ $("#storySupervisor").html(story); }

//Definitions of Submenus

var submenuProject = '<a href="https://2018.igem.org/Team:Utrecht/Description" id = "submenuDescription" >Description</a><a href="https://2018.igem.org/Team:Utrecht/Design" id = "submenuDesign">Design</a><a href="https://2018.igem.org/Team:Utrecht/Model" id = "submenuModel">Model</a><a href="https://2018.igem.org/Team:Utrecht/Parts" id = "submenuBiobricks">Basic Biobricks</a><a href="https://2018.igem.org/Team:Utrecht/Improve" id = "submenuImprove">Improved Biobrick</a><a href="https://2018.igem.org/Team:Utrecht/SafeByDesign" id = "submenuSafeByDesign">Safety&Risks</a>';

var submenuLab = '<a href="https://2018.igem.org/Team:Utrecht/Notebook" id = "submenuNotebook">Lab Notebook</a> <a href="https://2018.igem.org/Team:Utrecht/Protocol" id = "submenuProtocol">Protocols</a> <a href="https://2018.igem.org/Team:Utrecht/Safety" id = "submenuSafety">Safety</a> <a href="https://2018.igem.org/Team:Utrecht/Results" id = "submenuResults">Results</a> <a href="https://2018.igem.org/Team:Utrecht/InterLab" id = "submenuInterLab">Interlab</a>';

var submenuHP = '<a href="https://2018.igem.org/Team:Utrecht/Human_Practices" id = "submenuIntegratedHP">Integrated HP</a><a href="https://2018.igem.org/Team:Utrecht/Applied_Design" id = "submenuAppliedDesign">Applied Design</a><a href="https://2018.igem.org/Team:Utrecht/Public_Engagement" id = "submenuPE">Public Engagement</a> <a href="https://2018.igem.org/Team:Utrecht/Conference" id = "submenuConference">Conference</a> <a href="https://2018.igem.org/Team:Utrecht/MeetUps" id = "submenuMeetUps">Meet-Ups</a>';

var submenuJamboree = '<a href="https://2018.igem.org/Team:Utrecht/AfterJamboree" id = "submenuAJ">After Jamboree</a>';

var submenuAboutUs = '<a href="https://2018.igem.org/Team:Utrecht/Team" id = "submenuTeam">Team</a> <a href="https://2018.igem.org/Team:Utrecht/Collaborations" id = "submenuCollaborations">Collaborations</a>';

var submenuCredit = '<a href="https://2018.igem.org/Team:Utrecht/Attributions" id = "submenuAtributions">Attributions</a> <a href="https://2018.igem.org/Team:Utrecht/Sponsors" id = "submenuSponsors">Sponsors</a>';


//Changes Submenu


var defSubmenu = ; var defActive = ;

var resetSubmenu = function(){

   $("#mySubmenu").html(defSubmenu);
   $(defActive).addClass('active');

}

$(document).ready(function(){

if(/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) ) {

   $(".menuItem").click(function(e){       
     e.preventDefault();
  });

};


$("#menuProject").hoverIntent(function(){

       $("#mySubmenu").stop();
       $("#mySubmenu").css("left","25vh");	

$("#mySubmenu").html(submenuProject);

       $(defActive).addClass('active');

});

$("#menuLaboratory").hoverIntent(function(){

       $("#mySubmenu").stop();
       $("#mySubmenu").css("left","45vh");	

$("#mySubmenu").html(submenuLab);

       $(defActive).addClass('active');

});

$("#menuHumanPractices").hoverIntent(function(){

       $("#mySubmenu").stop();
       $("#mySubmenu").css("left","65vh");

$("#mySubmenu").html(submenuHP);

       $(defActive).addClass('active');

});

$("#menuCredit").hoverIntent(function(){

       $("#mySubmenu").stop();
       $("#mySubmenu").css("left","85vh");

$("#mySubmenu").html(submenuCredit);

       $(defActive).addClass('active');

});

$("#menuJamboree").hoverIntent(function(){

       $("#mySubmenu").stop();
       $("#mySubmenu").css("left","105vh");

$("#mySubmenu").html(submenuJamboree);

       $(defActive).addClass('active');

});

$("#menuAboutUs").hoverIntent(function(){

       $("#mySubmenu").stop();
       $("#mySubmenu").css("left","125vh");	

$("#mySubmenu").html(submenuAboutUs);

       $(defActive).addClass('active');

});


let mainNavLinks = document.querySelectorAll(".sidenav ul li a");

let lastId; let cur = [];


var topMenu = $("#top-menu"),

   sideMenu = $("#side-menu"),
   secretMenu = $("#secret-menu"),
   topMenuHeight = topMenu.outerHeight()+ 15,
   menuItems = sideMenu.find("a");
   secretItems = secretMenu.find("a");

//menuItems.css("color", "green") // Bind click handler to menu items // so we can get a fancy scroll animation menuItems.click(function(e){

 var href = $(this).attr("href"),
     offsetTop = href === "#" ? 0 : $(href).offset().top-topMenuHeight+1;
 $('html, body').stop().animate({ 
     scrollTop: offsetTop
 }, 300);
 e.preventDefault();

});

if(location.hash){ setTimeout(function() {

window.scrollBy(0, -topMenuHeight);

}, 1000); };


window.addEventListener("scroll", event => {

 let fromTop = window.scrollY;
 mainNavLinks.forEach(link => {
   let section = document.querySelector(link.hash);
   if (((section.offsetTop - topMenuHeight - 10) <= fromTop) ) {
     if ((section.offsetTop + section.offsetHeight  - topMenuHeight - 10)> fromTop){
       link.classList.add("current");
     } else {
       link.classList.remove("current");
     }
   } 
   else {
     link.classList.remove("current");
   }
 });
if (document.body.scrollTop > 20 || document.documentElement.scrollTop > 20) {
       $("#BackToTop").show();
   } else {
       $("#BackToTop").hide();
   }

});

$(".ClickThis").click(function(){ $(this).siblings(".CollapseThis").toggle(400, "linear");

   });
   
   $(".collapseLink").click(function(e){
       var topMenu = $("#top-menu"),
       subMenu = $(".submenuM"),
       topMenuHeight = topMenu.outerHeight()+ subMenu.outerHeight()+ 1,
       href = $(this).attr("href"),
       offsetTop = href === "#" ? 0 : $(href).offset().top-topMenuHeight+1;
       

$(".CollapseThis").hide(2, "linear");

       $(href).children(".CollapseThis").show(2, "linear");
       
       $('html, body').stop().animate({ 
       scrollTop: offsetTop
       }, 500);
       e.preventDefault();
   });

});


// When the user clicks on the button, scroll to the top of the document function topFunction() {

   document.body.scrollTop = 0; // For Safari
   document.documentElement.scrollTop = 0; // For Chrome, Firefox, IE and Opera

}


//Mobile Menu /* Toggle between adding and removing the "responsive" class to topnav when the user clicks on the icon */ function myFunction(y) {

   var x = document.getElementById("myMenu");
   if (x.className === "menuM") {
       x.className += " open";
   } else {
       x.className = "menuM";
   }

y.classList.toggle("change"); }