forked from litten/hexo-theme-yilia
/
toc.ejs
60 lines (53 loc) · 1.6 KB
/
toc.ejs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<div id="toc" class="toc-article">
<strong class="toc-title">文章目录</strong>
<%- toc(post.content) %>
</div>
<style>
.left-col .switch-btn {
display: none;
}
.left-col .switch-area {
display: none;
}
</style>
<input type="button" id="tocButton" value="隐藏目录" title="点击按钮隐藏或者显示文章目录">
<%- js('http://7.url.cn/edu/jslib/comb/require-2.1.6,jquery-1.9.1.min') %>
<script>
var valueHide = "隐藏目录";
var valueShow = "显示目录";
if ($(".left-col").is(":hidden")) {
$("#tocButton").attr("value", valueShow);
}
$("#tocButton").click(function() {
if ($("#toc").is(":hidden")) {
$("#tocButton").attr("value", valueHide);
$("#toc").slideDown(320);
$(".switch-btn, .switch-area").fadeOut(300);
}
else {
$("#tocButton").attr("value", valueShow);
$("#toc").slideUp(350);
$(".switch-btn, .switch-area").fadeIn(500);
}
})
if ($(".toc").length < 1) {
$("#toc, #tocButton").hide();
$(".switch-btn, .switch-area").show();
}
</script>
<% if (theme.toc_nowrap) { %>
<style>
.toc {
white-space: nowrap;
overflow-x: hidden;
}
</style>
<script>
$(document).ready(function() {
$(".toc li a").mouseover(function() {
var title = $(this).find('.toc-text').text();
$(this).attr("title", title);
});
})
</script>
<% } %>