Team:YORK UK/static/script.js
From 2013.igem.org
(6 intermediate revisions not shown) | |||
Line 29: | Line 29: | ||
currentContentId = currentContent.attr('id').substring(0, currentContent.attr('id').length - 7); | currentContentId = currentContent.attr('id').substring(0, currentContent.attr('id').length - 7); | ||
$("#"+currentContentId).css("background","#ffffff"); | $("#"+currentContentId).css("background","#ffffff"); | ||
+ | $("#"+currentContentId).css("border-top-color","#ffffff"); | ||
$("[href='"+currentLocation +"?page="+currentContentId+"']").toggleClass("selected"); | $("[href='"+currentLocation +"?page="+currentContentId+"']").toggleClass("selected"); | ||
currentContent = newContent; | currentContent = newContent; | ||
currentContent.delay(300).show({duration: "slow", queue: false}); | currentContent.delay(300).show({duration: "slow", queue: false}); | ||
$(this).css("background","#fad210"); | $(this).css("background","#fad210"); | ||
+ | $(this).css("border-top-color","#fad210"); | ||
$("[href='"+currentLocation +"?page="+$(this).attr('id')+"']").toggleClass("selected"); | $("[href='"+currentLocation +"?page="+$(this).attr('id')+"']").toggleClass("selected"); | ||
} | } | ||
Line 122: | Line 124: | ||
baseAdress = "https://2013.igem.org/Team:York_UK"; | baseAdress = "https://2013.igem.org/Team:York_UK"; | ||
currentLocation = window.location.pathname.substr(window.location.pathname.lastIndexOf('/') + 1); | currentLocation = window.location.pathname.substr(window.location.pathname.lastIndexOf('/') + 1); | ||
- | + | if(currentLocation.indexOf(".html") == -1){ | |
- | + | $("[href='"+ baseAdress +"']").addClass("selected"); | |
- | + | console.log(" Homepage [href='"+ baseAdress +"']"); | |
- | + | } | |
- | + | else{ | |
- | + | $("[href='"+ baseAdress +"/"+ currentLocation + "']").addClass("selected"); | |
- | + | console.log($("[href='"+ baseAdress +"/"+ currentLocation + "']")); | |
- | + | } | |
- | + | ||
- | } | + | |
- | + | ||
- | + | ||
} | } | ||
Latest revision as of 19:03, 25 September 2013
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.origin + window.location.pathname; 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");
$("#"+currentContentId).css("border-top-color","#ffffff");
$("[href='"+currentLocation +"?page="+currentContentId+"']").toggleClass("selected");
currentContent = newContent;
currentContent.delay(300).show({duration: "slow", queue: false});
$(this).css("background","#fad210");
$(this).css("border-top-color","#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((975 - 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')) - 975 + 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((975 - 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((975 - 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}); }); };
function selectedMenu(){ console.log("selected Menu" + window.location.pathname.substr(window.location.pathname.lastIndexOf('/') + 1)); baseAdress = "https://2013.igem.org/Team:York_UK"; currentLocation = window.location.pathname.substr(window.location.pathname.lastIndexOf('/') + 1); if(currentLocation.indexOf(".html") == -1){ $("[href='"+ baseAdress +"']").addClass("selected"); console.log(" Homepage [href='"+ baseAdress +"']"); } else{ $("[href='"+ baseAdress +"/"+ currentLocation + "']").addClass("selected"); console.log($("[href='"+ baseAdress +"/"+ currentLocation + "']")); } }
$(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);
});
});