diff options
author | Joey Hess <joey@kitenet.net> | 2010-04-24 00:55:09 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2010-04-24 00:55:09 -0400 |
commit | 998f47ed137959d0a0951368d8d0f891673c3ce5 (patch) | |
tree | 10b26da9fe1513c3b8b4990e6caa7446352218a5 /underlays/javascript/ikiwiki/toggle.js | |
parent | 39d4bfde6b9c49f0a8b13699be701bda11eb851a (diff) | |
parent | e90d67d3c9a93862657563e17e24054087f205d1 (diff) |
Merge branch 'master' into templatemove
Diffstat (limited to 'underlays/javascript/ikiwiki/toggle.js')
-rw-r--r-- | underlays/javascript/ikiwiki/toggle.js | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/underlays/javascript/ikiwiki/toggle.js b/underlays/javascript/ikiwiki/toggle.js new file mode 100644 index 000000000..d190b737a --- /dev/null +++ b/underlays/javascript/ikiwiki/toggle.js @@ -0,0 +1,29 @@ +// Uses CSS to hide toggleables, to avoid any flashing on page load. The +// CSS is only emitted after it tests that it's going to be able +// to show the toggleables. +if (document.getElementById && document.getElementsByTagName && document.createTextNode) { + document.write('<style type="text/css">div.toggleable { display: none; }</style>'); + hook("onload", inittoggle); +} + +function inittoggle() { + var as = getElementsByClass('toggle'); + for (var i = 0; i < as.length; i++) { + var id = as[i].href.match(/#(\w.+)/)[1]; + if (document.getElementById(id).className == "toggleable") + document.getElementById(id).style.display="none"; + as[i].onclick = function() { + toggle(this); + return false; + } + } +} + +function toggle(s) { + var id = s.href.match(/#(\w.+)/)[1]; + style = document.getElementById(id).style; + if (style.display == "none") + style.display = "block"; + else + style.display = "none"; +} |