[release-branch.go1.7] godoc: allow nested toggles and toggles with <a name>
Toggles can now be nested within one another. They can also be referenced using an <a> element with the name attribute, rather than an element with the "id" attribute. Updates golang/go#17574. Change-Id: I43c17499a6879e983a79a74e14c99128296288e1 Reviewed-on: https://go-review.googlesource.com/34825 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Reviewed-on: https://go-review.googlesource.com/35094 Reviewed-by: Chris Broadfoot <cbro@golang.org>
This commit is contained in:
parent
05ca1f09ae
commit
9d32829149
|
@ -113,6 +113,11 @@ function generateTOC() {
|
||||||
|
|
||||||
function bindToggle(el) {
|
function bindToggle(el) {
|
||||||
$('.toggleButton', el).click(function() {
|
$('.toggleButton', el).click(function() {
|
||||||
|
if ($(this).closest(".toggle, .toggleVisible")[0] != el) {
|
||||||
|
// Only trigger the closest toggle header.
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if ($(el).is('.toggle')) {
|
if ($(el).is('.toggle')) {
|
||||||
$(el).addClass('toggleVisible').removeClass('toggle');
|
$(el).addClass('toggleVisible').removeClass('toggle');
|
||||||
} else {
|
} else {
|
||||||
|
@ -120,6 +125,7 @@ function bindToggle(el) {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function bindToggles(selector) {
|
function bindToggles(selector) {
|
||||||
$(selector).each(function(i, el) {
|
$(selector).each(function(i, el) {
|
||||||
bindToggle(el);
|
bindToggle(el);
|
||||||
|
@ -239,9 +245,16 @@ function fixFocus() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function toggleHash() {
|
function toggleHash() {
|
||||||
var hash = $(window.location.hash);
|
// Open all of the toggles for a particular hash.
|
||||||
if (hash.is('.toggle')) {
|
var els = $(window.location.hash + ", a[name='" + window.location.hash.substring(1) + "']");
|
||||||
hash.find('.toggleButton').first().click();
|
while (els.length) {
|
||||||
|
for (var i = 0; i < els.length; i++) {
|
||||||
|
var el = $(els[i]);
|
||||||
|
if (el.is('.toggle')) {
|
||||||
|
el.find('.toggleButton').first().click();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
els = el.parent();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -683,6 +683,11 @@ function generateTOC() {
|
||||||
|
|
||||||
function bindToggle(el) {
|
function bindToggle(el) {
|
||||||
$('.toggleButton', el).click(function() {
|
$('.toggleButton', el).click(function() {
|
||||||
|
if ($(this).closest(".toggle, .toggleVisible")[0] != el) {
|
||||||
|
// Only trigger the closest toggle header.
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if ($(el).is('.toggle')) {
|
if ($(el).is('.toggle')) {
|
||||||
$(el).addClass('toggleVisible').removeClass('toggle');
|
$(el).addClass('toggleVisible').removeClass('toggle');
|
||||||
} else {
|
} else {
|
||||||
|
@ -690,6 +695,7 @@ function bindToggle(el) {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function bindToggles(selector) {
|
function bindToggles(selector) {
|
||||||
$(selector).each(function(i, el) {
|
$(selector).each(function(i, el) {
|
||||||
bindToggle(el);
|
bindToggle(el);
|
||||||
|
@ -809,9 +815,16 @@ function fixFocus() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function toggleHash() {
|
function toggleHash() {
|
||||||
var hash = $(window.location.hash);
|
// Open all of the toggles for a particular hash.
|
||||||
if (hash.is('.toggle')) {
|
var els = $(window.location.hash + ", a[name='" + window.location.hash.substring(1) + "']");
|
||||||
hash.find('.toggleButton').first().click();
|
while (els.length) {
|
||||||
|
for (var i = 0; i < els.length; i++) {
|
||||||
|
var el = $(els[i]);
|
||||||
|
if (el.is('.toggle')) {
|
||||||
|
el.find('.toggleButton').first().click();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
els = el.parent();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3248,10 +3261,10 @@ div#blog .read {
|
||||||
}
|
}
|
||||||
|
|
||||||
.toggleButton { cursor: pointer; }
|
.toggleButton { cursor: pointer; }
|
||||||
.toggle .collapsed { display: block; }
|
.toggle > .collapsed { display: block; }
|
||||||
.toggle .expanded { display: none; }
|
.toggle > .expanded { display: none; }
|
||||||
.toggleVisible .collapsed { display: none; }
|
.toggleVisible > .collapsed { display: none; }
|
||||||
.toggleVisible .expanded { display: block; }
|
.toggleVisible > .expanded { display: block; }
|
||||||
|
|
||||||
table.codetable { margin-left: auto; margin-right: auto; border-style: none; }
|
table.codetable { margin-left: auto; margin-right: auto; border-style: none; }
|
||||||
table.codetable td { padding-right: 10px; }
|
table.codetable td { padding-right: 10px; }
|
||||||
|
|
|
@ -445,10 +445,10 @@ div#blog .read {
|
||||||
}
|
}
|
||||||
|
|
||||||
.toggleButton { cursor: pointer; }
|
.toggleButton { cursor: pointer; }
|
||||||
.toggle .collapsed { display: block; }
|
.toggle > .collapsed { display: block; }
|
||||||
.toggle .expanded { display: none; }
|
.toggle > .expanded { display: none; }
|
||||||
.toggleVisible .collapsed { display: none; }
|
.toggleVisible > .collapsed { display: none; }
|
||||||
.toggleVisible .expanded { display: block; }
|
.toggleVisible > .expanded { display: block; }
|
||||||
|
|
||||||
table.codetable { margin-left: auto; margin-right: auto; border-style: none; }
|
table.codetable { margin-left: auto; margin-right: auto; border-style: none; }
|
||||||
table.codetable td { padding-right: 10px; }
|
table.codetable td { padding-right: 10px; }
|
||||||
|
|
Loading…
Reference in New Issue