forked from litten/hexo-theme-yilia
/
toc.ejs
52 lines (46 loc) · 1.43 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
<div id="toc" class="toc-article">
<strong class="toc-title"><%= __('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="<%= __('toc.hide') %>" title="<%= __('tooltip.tocButton') %>">
<script>
var valueHide = "<%= __('toc.hide') %>";
var valueShow = "<%= __('toc.show') %>";
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) { %>
<script>
$(document).ready(function() {
$(".toc li a").mouseover(function() {
var title = $(this).find('.toc-text').text();
$(this).attr("title", title);
});
})
</script>
<% } %>