Team:YORK UK/static/script.js
From 2013.igem.org
function selection(){ // Checks whether a specific link or just a section link selected var queries = {}; queryString = document.location.search; if(queryString == ""){ // queryString = $("#navlocal > ul:nth-child(1) > li:nth-child(2) > div").text().toLowerCase(); queryString = $("#navlocal > ul:nth-child(1) > li:nth-child(2) > div").attr('id'); } else{ $.each(document.location.search.substr(1).split('&'),function(c,q){ var i = q.split('='); queries[i[0].toString()] = i[1].toString(); }); queryString = queries['page']; }
currentLocation = (window.location.pathname.substr(window.location.pathname.lastIndexOf('/') + 1)); currentContent = $("#" + queryString); currentContent.css("background","#fad210"); $("[href='"+currentLocation +"?page="+queryString+"']").toggleClass("selected"); currentContent = $("#" + (currentContent.attr('id')+"content")); currentContent.show({duration: "slow", queue: false});
$("#navlocal div").click(function(event){
newContent = $("#"+$(this).attr('id')+"content");
event.preventDefault();
if((newContent.attr("id")) != currentContent.attr('id')){
currentContent.slideUp({duration: "slow", queue: false});
currentContentId = currentContent.attr('id').substring(0, currentContent.attr('id').length - 7);
$("#"+currentContentId).css("background","#ffffff");
$("[href='"+currentLocation +"?page="+currentContentId+"']").toggleClass("selected");
currentContent = newContent;
currentContent.delay(300).show({duration: "slow", queue: false});
$(this).css("background","#fad210");
$("[href='"+currentLocation +"?page="+$(this).attr('id')+"']").toggleClass("selected");
}
})
};
function navigation(currentMenu){
currentMenu = currentMenu || "";
if(currentMenu != ""){
currentMenu = $("#"+currentMenu);
currentMenu.show();
moveDistance = parseInt(currentMenu.css('width'), 10);
moveDistance += parseInt((1080 - moveDistance)/2);
currentMenu.animate(
{
left: "+="+parseInt(moveDistance),
}, {duration: 400, queue: false});
}
moveDistance = 0; $("#nav2").bind('mousewheel', function(event, delta, deltaX, deltaY) { if( currentMenu != ""){ // if((parseInt(currentMenu.css('left'))+parseInt(currentMenu.css('width'))) > 0 && (parseInt(currentMenu.css('left')) - 1080 < 0)){ // } if(delta > 0) if(parseInt(currentMenu.css('left')) - 1080 + 150< 0) currentMenu.animate({ left: "+="+100, },{duration: 100, queue: false}); // currentMenu.css("left","+=50"); else true; else if((parseInt(currentMenu.css('left'))+parseInt(currentMenu.css('width')) - 150) > 0) currentMenu.animate({ left: "-="+100, }, {duration: 100, queue: false}); } return false; });
$("#navigation a").mouseover(function(){ newMenu = $("#"+$(this).text().toLowerCase()); if(currentMenu != ""){
if(currentMenu.attr('id') == newMenu.attr('id')){ return false; } else { fromLeft = parseInt(currentMenu.css("left"), 10) toReturn = parseInt(currentMenu.css("width"), 10); currentMenu.animate({ left: "-="+(fromLeft + toReturn), }, {duration: 400, queue: false}); currentMenu.hide(); }
newMenu.show(); moveDistance = parseInt(newMenu.css('width'), 10); moveDistance += parseInt((1080 - moveDistance)/2); console.log(moveDistance); newMenu.animate({ left: "+="+moveDistance, }, {duration: 400, queue: false});
currentMenu = newMenu;
} else {
newMenu.show(); moveDistance = parseInt(newMenu.css('width'), 10); moveDistance += parseInt((1080 - moveDistance)/2); newMenu.animate({ left: "+="+(moveDistance), }, {duration: 400, queue: false});
currentMenu = newMenu; }
// $("#"+$(this).text().toLowerCase()+ "#nav2").mouseleave(function(){ // $(this).animate({ // left: "-="+moveDistance, // }, {duration: 400, queue: false}); }); };
$(document).ready(function(){
$("img").mousemove(function(e){
var pageCoords = "( " + e.pageX + ", " + e.pageY + " )";
var clientCoords = "( " + e.clientX + ", " + e.clientY + " )";
$("span:first").text("( e.pageX, e.pageY ) : " + pageCoords);
$("span:last").text("( e.clientX, e.clientY ) : " + clientCoords);
});
});