diff options
author | Arquivo Publico de Memoria Coletiva <arquivo@sarava.org> | 2015-07-31 23:38:38 -0300 |
---|---|---|
committer | Arquivo Publico de Memoria Coletiva <arquivo@sarava.org> | 2015-07-31 23:38:38 -0300 |
commit | df4566af59ba8e453d12f27784bbcd4082cfc666 (patch) | |
tree | 6fffdd129c497f550b2d32831b274dc7cebe6792 /ikiwiki/toggle.js | |
parent | 1fac146001ef2ed20f20fb5adf802e81452879ce (diff) | |
download | arquivo-df4566af59ba8e453d12f27784bbcd4082cfc666.tar.gz arquivo-df4566af59ba8e453d12f27784bbcd4082cfc666.tar.bz2 |
Initial static site generation
Diffstat (limited to 'ikiwiki/toggle.js')
-rw-r--r-- | ikiwiki/toggle.js | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/ikiwiki/toggle.js b/ikiwiki/toggle.js new file mode 100644 index 00000000000..d190b737ae1 --- /dev/null +++ b/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"; +} |