Add anchors around all headers in the content.

- Just uses the header's text as its anchor name. Spaces work. Scrolling to the anchor works even when the anchor is added after the dom loads.
- Adjust theme css to only style links, not <a> tags used as anchors.
This commit is contained in:
asolove 2015-12-27 15:17:59 -07:00
parent 50504282fb
commit 0ab8a73ba2
2 changed files with 13 additions and 4 deletions

View File

@ -315,7 +315,7 @@ h3 {
.light .mobile-nav-chapters { .light .mobile-nav-chapters {
background-color: #fafafa; background-color: #fafafa;
} }
.light .content a { .light .content a:link {
color: #4183c4; color: #4183c4;
} }
.light .theme-popup { .light .theme-popup {
@ -371,7 +371,7 @@ h3 {
.coal .mobile-nav-chapters { .coal .mobile-nav-chapters {
background-color: #292c2f; background-color: #292c2f;
} }
.coal .content a { .coal .content a:link {
color: #2b79a2; color: #2b79a2;
} }
.coal .theme-popup { .coal .theme-popup {
@ -427,7 +427,7 @@ h3 {
.navy .mobile-nav-chapters { .navy .mobile-nav-chapters {
background-color: #282d3f; background-color: #282d3f;
} }
.navy .content a { .navy .content a:link {
color: #2b79a2; color: #2b79a2;
} }
.navy .theme-popup { .navy .theme-popup {
@ -483,7 +483,7 @@ h3 {
.rust .mobile-nav-chapters { .rust .mobile-nav-chapters {
background-color: #3b2e2a; background-color: #3b2e2a;
} }
.rust .content a { .rust .content a:link {
color: #2b79a2; color: #2b79a2;
} }
.rust .theme-popup { .rust .theme-popup {

View File

@ -28,6 +28,15 @@ $( document ).ready(function() {
var html = $("html"); var html = $("html");
var sidebar = $("#sidebar"); var sidebar = $("#sidebar");
var page_wrapper = $("#page-wrapper"); var page_wrapper = $("#page-wrapper");
var content = $("#content");
// Add anchors for all content headers
content.find("h1, h2, h3, h4, h5").wrap(function(){
var wrapper = $("<a>");
wrapper.attr("name", $(this).text());
return wrapper;
});
// Toggle sidebar // Toggle sidebar