Team:YORK UK/static/script.js
From 2013.igem.org
Line 46: | Line 46: | ||
currentMenu.show(); | currentMenu.show(); | ||
moveDistance = parseInt(currentMenu.css('width'), 10); | moveDistance = parseInt(currentMenu.css('width'), 10); | ||
- | moveDistance += parseInt(( | + | moveDistance += parseInt((975 - moveDistance)/2); |
currentMenu.animate( | currentMenu.animate( | ||
{ | { | ||
Line 59: | Line 59: | ||
// } | // } | ||
if(delta > 0) | if(delta > 0) | ||
- | if(parseInt(currentMenu.css('left')) - | + | if(parseInt(currentMenu.css('left')) - 975 + 150< 0) |
currentMenu.animate({ | currentMenu.animate({ | ||
left: "+="+100, | left: "+="+100, | ||
Line 92: | Line 92: | ||
newMenu.show(); | newMenu.show(); | ||
moveDistance = parseInt(newMenu.css('width'), 10); | moveDistance = parseInt(newMenu.css('width'), 10); | ||
- | moveDistance += parseInt(( | + | moveDistance += parseInt((975 - moveDistance)/2); |
console.log(moveDistance); | console.log(moveDistance); | ||
newMenu.animate({ | newMenu.animate({ | ||
Line 104: | Line 104: | ||
newMenu.show(); | newMenu.show(); | ||
moveDistance = parseInt(newMenu.css('width'), 10); | moveDistance = parseInt(newMenu.css('width'), 10); | ||
- | moveDistance += parseInt(( | + | moveDistance += parseInt((975 - moveDistance)/2); |
newMenu.animate({ | newMenu.animate({ | ||
left: "+="+(moveDistance), | left: "+="+(moveDistance), |
Revision as of 19:01, 24 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.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");
console.log("[href='"+currentLocation +"?page="+currentContentId+"']");
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((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}); }); };
$(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);
});
});