export javascript, and support default-open toggles

master
Joey Hess 2008-07-02 15:33:52 -04:00
parent ed25c2abf2
commit e998235240
1 changed files with 3 additions and 2 deletions

View File

@ -9,7 +9,7 @@ use IkiWiki 2.00;
# of css to hide toggleables, to avoid any flashing on page load. The css # of css to hide toggleables, to avoid any flashing on page load. The css
# is only emitted after the javascript tests that it's going to be able to # is only emitted after the javascript tests that it's going to be able to
# show the toggleables. # show the toggleables.
my $javascript=<<'EOF'; our $javascript=<<'EOF';
<script type="text/javascript"> <script type="text/javascript">
<!-- <!--
if (document.getElementById && document.getElementsByTagName && document.createTextNode) { if (document.getElementById && document.getElementsByTagName && document.createTextNode) {
@ -21,7 +21,8 @@ function inittoggle() {
var as = getElementsByClass('toggle'); var as = getElementsByClass('toggle');
for (var i = 0; i < as.length; i++) { for (var i = 0; i < as.length; i++) {
var id = as[i].href.match(/#(\w.+)/)[1]; var id = as[i].href.match(/#(\w.+)/)[1];
document.getElementById(id).style.display="none"; if (document.getElementById(id).className == "toggleable")
document.getElementById(id).style.display="none";
as[i].onclick = function() { as[i].onclick = function() {
toggle(this); toggle(this);
return false; return false;