Permalink
Browse files

Add TOC Button 添加目录按钮

Add a button to show or hide TOC.
添加一个按钮用于显示或者隐藏文章目录。
  • Loading branch information...
MOxFIVE MOxFIVE
MOxFIVE authored and MOxFIVE committed Aug 21, 2015
1 parent c3eba7a commit be8fb25df35ba2155fb081b8dbc6550d654a8720
Showing with 27 additions and 1 deletion.
  1. +15 −0 themes/Yilia/layout/_partial/article.ejs
  2. +12 −1 themes/Yilia/source/css/_partial/article.styl
@@ -33,6 +33,21 @@
<%- toc(post.content) %>
</div>
<% } %>
<input type="button" value="显示/隐藏文章目录" id="tocButton">
<script type="text/javascript">
var toc_button= document.getElementById("tocButton");
var toc_div= document.getElementById("toc");
/* Show or hide toc when click on tocButton.
通过点击设置的按钮显示或者隐藏文章目录.*/
toc_button.onclick=function(){
if(toc_div.style.display=="none"){
toc_div.style.display="block";
}
else{
toc_div.style.display="none";
}
}
</script>
<%- post.content %>
<% } %>
</div>
@@ -359,6 +359,16 @@
}
/*toc*/
#tocButton {
background: lightblue;
padding: 0.3em;
font-size: 0.8em;
opacity: 0.5;
padding: 0.3em 0.5em;
border-radius: 6px;
border-style : outset;
}
.toc-article {
background: #eee;
border-radius: 2.8%;
@@ -372,8 +382,9 @@
#toc {
line-height: 1.5em;
font-size: .9em;
float right
float: right;
}
#toc .toc {
padding: 0
}

0 comments on commit be8fb25

Please sign in to comment.