diff --git a/doc/godocs.js b/doc/godocs.js index 37573136abc..8fd32fef0f4 100644 --- a/doc/godocs.js +++ b/doc/godocs.js @@ -164,21 +164,26 @@ function getElementsByClassName(base, clazz) { return foundElements; } -function godocs_bindExampleToggle(eg) { - var heading = getElementsByClassName(eg, "exampleHeading"); +function godocs_bindToggle(el) { + var button = getElementsByClassName(el, "toggleButton"); var callback = function() { - if (eg.className == "example") { - eg.className = "exampleVisible"; + if (el.className == "toggle") { + el.className = "toggleVisible"; } else { - eg.className = "example"; + el.className = "toggle"; } }; - for (var i = 0; i < heading.length; i++) { - bindEvent(heading[i], "click", callback); + for (var i = 0; i < button.length; i++) { + bindEvent(button[i], "click", callback); } } -function godocs_bindExampleLink(l) { - var prefix = "example_"; +function godocs_bindToggles(className) { + var els = getElementsByClassName(document, className); + for (var i = 0; i < els.length; i++) { + godocs_bindToggle(els[i]); + } +} +function godocs_bindToggleLink(l, prefix) { bindEvent(l, "click", function() { var i = l.href.indexOf("#"+prefix); if (i < 0) { @@ -186,24 +191,23 @@ function godocs_bindExampleLink(l) { } var id = prefix + l.href.slice(i+1+prefix.length); var eg = document.getElementById(id); - eg.className = "exampleVisible"; + eg.className = "toggleVisible"; }); } -function godocs_bindExamples() { - var examples = getElementsByClassName(document, "example"); - for (var i = 0; i < examples.length; i++) { - godocs_bindExampleToggle(examples[i]); - } - var links = getElementsByClassName(document, "exampleLink"); +function godocs_bindToggleLinks(className, prefix) { + var links = getElementsByClassName(document, className); for (i = 0; i < links.length; i++) { - godocs_bindExampleLink(links[i]); + godocs_bindToggleLink(links[i], prefix); } } function godocs_onload() { godocs_bindSearchEvents(); godocs_generateTOC(); - godocs_bindExamples(); + godocs_bindToggles("toggle"); + godocs_bindToggles("toggleVisible"); + godocs_bindToggleLinks("exampleLink", "example_"); + godocs_bindToggleLinks("overviewLink", ""); } bindEvent(window, 'load', godocs_onload); diff --git a/doc/style.css b/doc/style.css index 53f5e18cd18..ea66f988a67 100644 --- a/doc/style.css +++ b/doc/style.css @@ -364,11 +364,11 @@ div#blog .read { text-align: right; } -.exampleHeading { cursor: pointer; } -.example .collapsed { display: block; } -.example .expanded { display: none; } -.exampleVisible .collapsed { display: none; } -.exampleVisible .expanded { display: block; } +.toggleButton { cursor: pointer; } +.toggle .collapsed { display: block; } +.toggle .expanded { display: none; } +.toggleVisible .collapsed { display: none; } +.toggleVisible .expanded { display: block; } table.codetable { margin-left: auto; margin-right: auto; border-style: none; } hr { border-style: none; border-top: 1px solid black; } diff --git a/lib/godoc/example.html b/lib/godoc/example.html index 43ee4bddc19..ede31d61f9b 100644 --- a/lib/godoc/example.html +++ b/lib/godoc/example.html @@ -1,9 +1,9 @@ -
▹ Example{{example_suffix .Name}}
+▹ Example{{example_suffix .Name}}