godoc: add on-hover permalink anchors across the site
We already have anchors for godoc types and functions. Add them for every heading (and "dl") on every other page on the site. Change-Id: Ibad77f04442e48dd5a41de759010625f89b48604 Reviewed-on: https://go-review.googlesource.com/33641 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
This commit is contained in:
parent
6c803ab014
commit
c97d1a2623
|
@ -305,9 +305,36 @@ function updateVersionTags() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function addPermalinks() {
|
||||||
|
function addPermalink(source, parent) {
|
||||||
|
var id = source.attr("id");
|
||||||
|
if (id == "" || id.indexOf("tmp_") === 0) {
|
||||||
|
// Auto-generated permalink.
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (parent.find("> .permalink").length) {
|
||||||
|
// Already attached.
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
parent.append(" ").append($("<a class='permalink'>¶</a>").attr("href", "#" + id));
|
||||||
|
}
|
||||||
|
|
||||||
|
$("#page .container").find("h2[id], h3[id]").each(function() {
|
||||||
|
var el = $(this);
|
||||||
|
addPermalink(el, el);
|
||||||
|
});
|
||||||
|
|
||||||
|
$("#page .container").find("dl[id]").each(function() {
|
||||||
|
var el = $(this);
|
||||||
|
// Add the anchor to the "dt" element.
|
||||||
|
addPermalink(el, el.find("> dt").first());
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
bindSearchEvents();
|
bindSearchEvents();
|
||||||
generateTOC();
|
generateTOC();
|
||||||
|
addPermalinks();
|
||||||
bindToggles(".toggle");
|
bindToggles(".toggle");
|
||||||
bindToggles(".toggleVisible");
|
bindToggles(".toggleVisible");
|
||||||
bindToggleLinks(".exampleLink", "example_");
|
bindToggleLinks(".exampleLink", "example_");
|
||||||
|
|
|
@ -875,9 +875,36 @@ function updateVersionTags() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function addPermalinks() {
|
||||||
|
function addPermalink(source, parent) {
|
||||||
|
var id = source.attr("id");
|
||||||
|
if (id.indexOf("tmp_") === 0) {
|
||||||
|
// Auto-generated permalink.
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (parent.find("> .permalink").length) {
|
||||||
|
// Already attached.
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
parent.append(" ").append($(" <a class='permalink'>¶</a>").attr("href", "#" + id));
|
||||||
|
}
|
||||||
|
|
||||||
|
$("#page .container").find("h2[id], h3[id]").each(function() {
|
||||||
|
var el = $(this);
|
||||||
|
addPermalink(el, el);
|
||||||
|
});
|
||||||
|
|
||||||
|
$("#page .container").find("dl[id]").each(function() {
|
||||||
|
var el = $(this);
|
||||||
|
// Add the anchor to the "dt" element.
|
||||||
|
addPermalink(el, el.find("> dt").first());
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
bindSearchEvents();
|
bindSearchEvents();
|
||||||
generateTOC();
|
generateTOC();
|
||||||
|
addPermalinks();
|
||||||
bindToggles(".toggle");
|
bindToggles(".toggle");
|
||||||
bindToggles(".toggleVisible");
|
bindToggles(".toggleVisible");
|
||||||
bindToggleLinks(".exampleLink", "example_");
|
bindToggleLinks(".exampleLink", "example_");
|
||||||
|
@ -1599,8 +1626,8 @@ function cgAddChild(tree, ul, cgn) {
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
{{if $.IsMain}}
|
{{if $.IsMain}}
|
||||||
{{comment_html .Doc}}
|
|
||||||
{{/* command documentation */}}
|
{{/* command documentation */}}
|
||||||
|
{{comment_html .Doc}}
|
||||||
{{else}}
|
{{else}}
|
||||||
{{/* package documentation */}}
|
{{/* package documentation */}}
|
||||||
<div id="short-nav">
|
<div id="short-nav">
|
||||||
|
@ -2849,7 +2876,7 @@ a:hover,
|
||||||
.permalink {
|
.permalink {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
h2:hover .permalink, h3:hover .permalink {
|
:hover > .permalink {
|
||||||
display: inline;
|
display: inline;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -46,7 +46,7 @@ a:hover,
|
||||||
.permalink {
|
.permalink {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
h2:hover .permalink, h3:hover .permalink {
|
:hover > .permalink {
|
||||||
display: inline;
|
display: inline;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue