+doc #17669 better section header and TOC navigation

This commit is contained in:
Konrad Malawski 2015-07-07 19:14:35 +02:00
parent 403369a29e
commit 221605c7b3
2 changed files with 15 additions and 1 deletions

View file

@ -351,7 +351,17 @@
</style>
{%- endif %}
<script type="text/javascript">
$('#toc').toc();
var $toc = $('#toc');
$toc.toc();
// change hash when TOC link clicked:
$toc.find("a").click(function() { window.location.hash = $(this).attr('href'); });
// show clickable section sign when section header hovered:
$('.section h2,.section h3,.section h4,.section h5').each(function(i, el) {
var $el = $(el);
$el.prepend($("<a class='section-marker' href='#" + $el.attr("id") + "'>&sect;</a>"))
});
</script>
{% block footer %}{% endblock %}
{%- endblock %}

View file

@ -174,3 +174,7 @@ strong {color: #0B5567; }
.footer h5 { text-transform: none; }
.footnote .label { background-color: transparent }
.section-marker { position: absolute; width: 1em; margin-left: -1em; display: block; text-decoration: none; visibility: hidden; text-align: center; font-weight: normal; }
.section-marker:hover { text-decoration: none; }
.section h2:hover > a,.section h3:hover > a,.section h4:hover > a,.section h5:hover > a { visibility: visible; }