Team:SYSU-China/Project.js

From 2013.igem.org

(Difference between revisions)
Line 72: Line 72:
var id=$(this).attr("class");
var id=$(this).attr("class");
var anchor_num = $('#"+id+"').offset().top;
var anchor_num = $('#"+id+"').offset().top;
-
alert(id + "////"+ anchor_num);
+
alert(""+ id + "////"+ anchor_num+"");
$('body,html').animate({scrollTop:anchor_num},500);
$('body,html').animate({scrollTop:anchor_num},500);
});
});

Revision as of 02:51, 29 October 2013

$(document).ready(function(){

/* TOPBUTTON_POSITION */

scr_position = 0; $("#top_button span").css({"left":$("div.content_body").offset().left+$("div.content_body").width(),"top":$(window).height()-177});

$("#top_button span").mouseenter(function(){ $("#top_button span").stop(); $("#top_button span").css({"background":"url(TOP_BACKING.png)"}); }); $("#top_button span").mouseout(function(){ $("#top_button span").css({"background":"url(WIKI-MASCOT-STAND-SHADOW.png)"}); }); $(window).scroll(function(){ if ( scr_position < $(window).scrollTop() ) { $("#top_button span").css({"background":"url(TOP_FALLING.png)"}); } else { $("#top_button span").css({"background":"url(TOP_BACKING.png)"}); }; scr_position = $(window).scrollTop(); $("#top_button span").animate({padding: "+=0px"},600,function(){ $("#top_button span").css({"background":"url(WIKI-MASCOT-STAND-SHADOW.png)"}); });

/*TOP BUTTON HANGING*/

if ($(window).scrollTop() + $(window).height() - $("#cont_column").height() -$("div.navigater").height() - $("#animat").height() > 20 &&$("#top_button span").css("position")=="fixed") { $("#top_button span").css({"position":"relative","top":$("#cont_column").height()-100,"left":$("#top_button").width()}); } else if ($(window).scrollTop() + $(window).height() - $("#cont_column").height() -$("div.navigater").height() - $("#animat").height() <=20 &&$("#top_button span").css("position")=="relative"){ $("#top_button span").css({"position":"fixed","top":$(window).height()-177,"left":$("div.content_body").offset().left+$("div.content_body").width()}); };

});


$("#top_button span").click(function(){ $('body,html').animate({scrollTop:0},500);

});


/* SIDE_TAG */ title = $(".chapter h1,.chapter h2"); number = 0; tag = ""; h2num = 0; title.each(function() { var anchor_num = "h2_"+ number; $(this).attr("id","h2_"+number); var id=$('#h2_'+ number); text = $(this).text(); if(new RegExp(":").test(text)) { title=text.split(":"); text = title[0]; }; if ($(this).attr('tagName') == "H1") //不可用"h1" { h2num = h2num + 1;

tag = tag + "

" + text + "

";

} else {

tag = tag +"

"+ text +"

";

} number = number + 1; }); num_max = number-1; $("#side_bar").html( tag );

/*SIDE_BAR LINK*/ $("#side_bar p").click(function(){ var id=$(this).attr("class"); var anchor_num = $('#"+id+"').offset().top; alert(""+ id + "////"+ anchor_num+""); $('body,html').animate({scrollTop:anchor_num},500); });

/* FOLLOWING */ win_height = $(window).height(); number = 0; toptop = 145;

$(".anchor-h2 .anchor-h3").css("position","relative"); $(".anchor-h3").hide(); /*SLIDE DOWN*/ $(function(){ var feedback=0; $(".anchor-h2").mouseenter(function(event) { var h2num = $(this).attr("id"); event.preventDefault(); if (feedback==h2num) { $("."+h2num).slideToggle("fast",function(){feedback = h2num}); } else if (feedback!=h2num){ /*$(".anchor-h3").slideUp("fast");*/ $("."+h2num).slideDown("fast",function(){feedback = h2num;}); }; }); });

/*SIDE_BAR HANGING*/ scr_position_2 = 0; if ($(window).scrollTop() >= 185) { $("#side_bar").css({"position":"fixed","top":0}); left = $("div.chapter").offset().left - $("#side_bar").width(); $("#side_bar").css("left",left+1); } else if ($(window).scrollTop() < 185){ $("#side_bar").css({"position":"absolute","top":50}); left = $("div.chapter").offset().left - $("div.content_body").offset().left - $("#side_bar").width(); $("#side_bar").css("left",left+1); }; $(window).scroll(function(){ scr_position_2 = $(window).scrollTop(); if ($(window).scrollTop() >= 178 &&$("#side_bar").css("position")=="absolute") { $("#side_bar").css({"position":"fixed","top":0}); left = $("div.chapter").offset().left - $("#side_bar").width(); $("#side_bar").css("left",left+1); } else if ($(window).scrollTop() < 178 &&$("#side_bar").css("position")=="fixed"){ $("#side_bar").css({"position":"absolute","top":50}); left = $("div.chapter").offset().left - $("div.content_body").offset().left - $("#side_bar").width(); $("#side_bar").css("left",left+1);

};

});


});