Team:SYSU-China/Project.js

From 2013.igem.org

(Difference between revisions)
Line 1: Line 1:
 +
/*Navigater start*/
 +
$(document).ready(function(){
$(document).ready(function(){
 +
$("div.navigater").html('<UL> <LI class="column" id="HOME"><A href="https://2013.igem.org/Team:SYSU-China">Home</A> <LI class="column" id="PROJECT"><A href="https://2013.igem.org/Team:SYSU-China/Project">PROJECT</A> <UL>        <LI><A style="color:#777;" href="">Overview</A></LI> <LI><A href="https://2013.igem.org/Team:SYSU-China/Project?#h2_0">Background</A></LI> <LI><A href="https://2013.igem.org/Team:SYSU-China/Project/Design">Design</A></LI>                        <LI><A href="https://2013.igem.org/Team:SYSU-China/Project/Results">Results</A></LI>        <LI><A href="https://2013.igem.org/Team:SYSU-China/Project/Future_work">Future work</A></LI>        <LI><A style="color:#777;" href="">Modeling</A></LI></UL></LI>    <LI class="column" id="JUDGING" ><A href="">JUDGING</A>      <UL>        <LI><A style="color:#777;" href="">Biobrick</A></LI>        <LI><A style="color:#777;" href="">Achievements</A></LI></UL></LI>    <LI class="column" id="SAFETY"><A href="">Safety</A>      <UL>        <LI><A style="color:#777;" href="">Safety</A></LI>        <LI><A style="color:#777;" href="">Ethics</A></LI>        <LI><A href="https://2013.igem.org/Team:SYSU-China/Safety/Human practice">Human practice</A></LI></UL></LI>  <LI class="column" id="NOTEBOOK"><A href="">NOTEBOOK</A>      <UL>        <LI><A style="color:#777;" href="">Methods</A></LI>        <LI><A style="color:#777;" href="">Labnotes</A></LI></UL></LI>    <LI class="column" id="TEAM"><A href="">TEAM</A>                <UL>                        <LI><A href="https://2013.igem.org/Team:SYSU-China/Team/Member">Member</A></LI>                        <LI><A style="color:#777;" href="">Attributions</A></LI>                        <LI><A style="color:#777;" href="">Gallery</A></LI>                        <LI><A style="color:#777;" href="">Contact us</A></LI>                        <LI><A style="color:#777;" href="">Acknowledgments</A></LI></UL></LI></UL>  ')
-
/* TOPBUTTON_POSITION */
+
/*Navigater End*/
-
scr_position = 0;
+
/* Reference Anchor Start */
-
$("#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(https://static.igem.org/mediawiki/2013/f/f3/TOP_BACKING.png)"});
+
-
});
+
-
$("#top_button span").mouseout(function(){
+
-
$("#top_button span").css({"background":"url(https://static.igem.org/mediawiki/2013/4/46/WIKI-MASCOT-STAND-SHADOW.png)"});
+
-
});
+
-
$(window).scroll(function(){
+
-
if ( scr_position < $(window).scrollTop() ) {
+
-
$("#top_button span").css({"background":"url(https://static.igem.org/mediawiki/2013/4/41/TOP_FALLING.png)"});
+
-
} else {
+
-
$("#top_button span").css({"background":"url(https://static.igem.org/mediawiki/2013/f/f3/TOP_BACKING.png)"});
+
-
};
+
-
scr_position = $(window).scrollTop();
+
-
$("#top_button span").animate({padding: "+=0px"},600,function(){
+
-
$("#top_button span").css({"background":"url(https://static.igem.org/mediawiki/2013/4/46/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") {
+
anchor_quote = $(".quote");
-
$("#top_button span").css({"position":"relative","top":$("#cont_column").height()-100,"left":$("#top_button").width()});
+
name = 0;
-
} else if ($(window).scrollTop() + $(window).height() - $("#cont_column").height() -$("div.navigater").height() - $("#animat").height() <=20 &&$("#top_button span").css("position")=="relative"){
+
anchor_quote.each(function() {
-
$("#top_button span").css({"position":"fixed","top":$(window).height()-177,"left":$("div.content_body").offset().left+$("div.content_body").width()});
+
var refer_num = $(this).text();
-
};
+
name = name + 1;
-
 
+
$(this).attr("href",'#"+name+"');
-
});
+
$(".references:contains("+refer_num+")").each(function(){
-
+
if ($(this).attr("name") == "undefined") {
-
 
+
$(this).attr("name",'#"+name+"');
-
$("#top_button span").click(function(){
+
return false;
-
$('body,html').animate({scrollTop:0},500);
+
} else {
-
 
+
return true;
-
});
+
}
-
+
-
 
+
-
/* SIDE_TAG */
+
-
title = $(".chapter h1,.chapter h2");
+
-
number = 0;
+
-
tag = "";
+
-
h2num = 0;
+
-
title.each(function() {
+
-
var anchor_num = $(this).offset().top;
+
-
$(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 + "<div class='anchor-h2' id= 'h2num_"+h2num+"'><p class='" + anchor_num + "' >" + text + "</p></div>";
+
-
}
+
-
else {
+
-
tag = tag +"<div class='anchor-h3 h2num_"+h2num+"' id= 'id_"+number+"'><p class='" + anchor_num + "' >"+ text +"</p></div>";
+
-
}
+
-
number = number + 1;
+
-
});
+
-
num_max = number-1;
+
-
$("#side_bar").html( tag );
+
-
/*SIDE_BAR LINK*/
+
-
$("#side_bar p").click(function(){
+
-
var anchor_num = $(this).attr("class");
+
-
$('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;});
+
-
};
+
});
});
 +
alert(name);
});
});
-
+
});
-
/*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);
+
-
};
+
/* Reference Anchor End */
-
 
+
-
});
+
-
+
-
+
-
});
+

Revision as of 07:36, 26 September 2013

/*Navigater start*/

$(document).ready(function(){

$("div.navigater").html(' ')

/*Navigater End*/

/* Reference Anchor Start */

anchor_quote = $(".quote"); name = 0; anchor_quote.each(function() { var refer_num = $(this).text(); name = name + 1; $(this).attr("href",'#"+name+"'); $(".references:contains("+refer_num+")").each(function(){ if ($(this).attr("name") == "undefined") { $(this).attr("name",'#"+name+"'); return false; } else { return true; } }); alert(name); }); });

/* Reference Anchor End */