1 // © 2006-2010 Joey Hess
2 // Redistribution and use in source and compiled forms, with or without
3 // modification, are permitted under any circumstances. No warranty.
5 // Uses CSS to hide toggleables, to avoid any flashing on page load. The
6 // CSS is only emitted after it tests that it's going to be able
7 // to show the toggleables.
8 if (document.getElementById && document.getElementsByTagName && document.createTextNode) {
9 document.write('<style type="text/css">div.toggleable { display: none; }</style>');
10 hook("onload", inittoggle);
13 function inittoggle() {
14 var as = getElementsByClass('toggle');
15 for (var i = 0; i < as.length; i++) {
16 var id = as[i].href.match(/#(\w.+)/)[1];
17 if (document.getElementById(id).className == "toggleable")
18 document.getElementById(id).style.display="none";
19 as[i].onclick = function() {
27 var id = s.href.match(/#(\w.+)/)[1];
28 style = document.getElementById(id).style;
29 if (style.display == "none")
30 style.display = "block";
32 style.display = "none";