Difference between revisions of "Template:SJTU-BioX-Shanghai/Content"

 
(35 intermediate revisions by 3 users not shown)
Line 3: Line 3:
 
function toc_loop() {
 
function toc_loop() {
 
   var TOP = window.pageYOffset + 20;
 
   var TOP = window.pageYOffset + 20;
   var headings = $('#toc ~ h2 > span:last-child, #toc ~ h3 > span:last-child');
+
   var headings = $('#toc ~ h2 > span:first-child, #toc ~ h3 > span:first-child');
 
   if (headings.length == 0) return
 
   if (headings.length == 0) return
  
Line 16: Line 16:
 
   var prev_a = $('#toc a.reading');
 
   var prev_a = $('#toc a.reading');
 
   var a = $('a[href="#'+ id +'"]');
 
   var a = $('a[href="#'+ id +'"]');
 +
  //console.log(prev_a, a);
 
   prev_a.removeClass('reading');
 
   prev_a.removeClass('reading');
 
   a.addClass('reading');
 
   a.addClass('reading');
Line 27: Line 28:
 
       var id = a.attributes["href"].value;
 
       var id = a.attributes["href"].value;
 
       var ele = document.getElementById(id.slice(1, id.length));
 
       var ele = document.getElementById(id.slice(1, id.length));
       var top = ele.offsetTop, docEle =  document.documentElement
+
       var top = ele.offsetTop, docEle =  document.documentElement;
       var pageHeight = docEle.offsetHeight
+
       var pageHeight = docEle.scrollHeight;
       var windowHeight =  docEle.clientHeight
+
       var windowHeight =  docEle.clientHeight;
  
 
       if ((pageHeight - top) > windowHeight) setTimeout ("scrollBy(0, -20)", 10);
 
       if ((pageHeight - top) > windowHeight) setTimeout ("scrollBy(0, -20)", 10);
 
     }
 
     }
 
   )
 
   )
 +
 +
  $('#toc ul ul').css({ "margin-left": "0px" });
  
 
   setInterval("toc_loop()", 10);
 
   setInterval("toc_loop()", 10);
Line 40: Line 43:
  
 
<style>
 
<style>
 +
 +
#globalWrapper {
 +
padding:0;
 +
margin:0;
 +
font-size:100%;
 +
}
 +
body{   
 +
font: initial;
 +
}
 +
 
#toc ul a{
 
#toc ul a{
 
   font-family: Trebuchet MS,"Helvetica Neue",Helvetica,Arial;
 
   font-family: Trebuchet MS,"Helvetica Neue",Helvetica,Arial;
   border-left-color: #109E52;
+
   color: #1B927B;
 
}
 
}
 
#toc ul a.reading {
 
#toc ul a.reading {
   border-left-color: #109E52;
+
   border-left-color: rgb(136, 198, 119);
  color:#109E52;
+
 
}
 
}
 
#toc {
 
#toc {
 
   position: fixed;
 
   position: fixed;
 
   right: 1em;
 
   right: 1em;
   top: 18em;
+
   top: 18px;
  
 +
  box-sizing: border-box;
 
   padding: 0em;
 
   padding: 0em;
 +
  padding-left: 1em;
 
   width: 16em;
 
   width: 16em;
   font-size: 0.6em;
+
   font-size: 0.75em;
 
   border: 0px;
 
   border: 0px;
  
Line 69: Line 83:
 
   margin-top: 0px;
 
   margin-top: 0px;
 
   margin-bottom: 0px;
 
   margin-bottom: 0px;
}
 
#toc ul ul {
 
  margin-left: 0px;
 
 
}
 
}
 
#toc ul a {
 
#toc ul a {
Line 82: Line 93:
 
   font-weight:500;
 
   font-weight:500;
 
}
 
}
 +
 +
#toc ul ul ul {
 +
  display: none;
 +
}
 +
 
</style>
 
</style>
 
</html>
 
</html>

Latest revision as of 01:21, 19 September 2015