mirror of
https://github.com/silverstripe/silverstripe-docsviewer
synced 2024-10-22 09:05:56 +00:00
ENHANCEMENT: Automatically add anchor links to headings that have IDs using javascript
This commit is contained in:
parent
257c833e86
commit
a069dbd9d9
@ -7,7 +7,6 @@
|
||||
*
|
||||
* Transform a #table-of-contents div to a nested list
|
||||
*/
|
||||
|
||||
if($("#table-of-contents").length > 0) {
|
||||
var toc = '<div class="box"><ul id="toc"><h4>In this document:</h4>';
|
||||
|
||||
@ -21,6 +20,24 @@
|
||||
$('#table-of-contents').prepend(toc);
|
||||
}
|
||||
|
||||
/** ---------------------------------------------
|
||||
* HEADING ANCHOR LINKS
|
||||
*
|
||||
* Automatically adds anchor links to headings that have IDs
|
||||
*/
|
||||
$("h1[id], h2[id], h3[id], h4[id], h5[id], h6[id]").each(function() {
|
||||
var link = '<a class="heading-anchor-link" title="Link to this section" href="#' + $(this).attr('id') + '">¶</a>';
|
||||
$(this).append(' ' + link);
|
||||
});
|
||||
|
||||
$("h1[id], h2[id], h3[id], h4[id], h5[id], h6[id]").mouseenter(function() {
|
||||
$(this).addClass('hover');
|
||||
});
|
||||
|
||||
$("h1[id], h2[id], h3[id], h4[id], h5[id], h6[id]").mouseleave(function() {
|
||||
$(this).removeClass('hover');
|
||||
});
|
||||
|
||||
/** ---------------------------------------------
|
||||
* LANGAUGE SELECTER
|
||||
*
|
||||
|
Loading…
x
Reference in New Issue
Block a user