diff options
author | Mark Lentczner <markl@glyphic.com> | 2010-07-25 18:47:49 +0000 |
---|---|---|
committer | Mark Lentczner <markl@glyphic.com> | 2010-07-25 18:47:49 +0000 |
commit | a3639ab3529cf25511f944f52b35380527073433 (patch) | |
tree | a256dc065c5a03077e6df739296620e94e8f4c57 /html/haddock-util.js | |
parent | 9393846ff6b439bd8f360f1239e79fe684f734ee (diff) |
change how collapsing sections are done
make whole .caption be the target
improve javascript for class toggling
have plus/minus images come from .css, not img tags
Diffstat (limited to 'html/haddock-util.js')
-rw-r--r-- | html/haddock-util.js | 36 |
1 files changed, 22 insertions, 14 deletions
diff --git a/html/haddock-util.js b/html/haddock-util.js index 372fd0e8..155ee08f 100644 --- a/html/haddock-util.js +++ b/html/haddock-util.js @@ -1,17 +1,26 @@ // Haddock JavaScript utilities -function toggle(button,id) + +function makeClassToggle(cOn, cOff) +{ + var rOn = new RegExp('\\b'+cOn+'\\b'); + var rOff = new RegExp('\\b'+cOff+'\\b'); + + return function(e, a) { + var c = e.className; + if (a == null) { a = rOff.test(c); } + if (a) { c = c.replace(rOff, cOn); } + else { c = c.replace(rOn, cOff); } + e.className = c; + } +} + +toggleClassShow = makeClassToggle("show", "hide"); +toggleClassCollapser = makeClassToggle("collapser", "expander"); + +function toggleSection(toggler,id) { - var n = document.getElementById(id).style; - if (n.display == "none") - { - button.src = "minus.gif"; - n.display = "block"; - } - else - { - button.src = "plus.gif"; - n.display = "none"; - } + toggleClassShow(document.getElementById(id)) + toggleClassCollapser(toggler); } @@ -172,7 +181,6 @@ function resetStyle() { function styleMenu(show) { var m = document.getElementById('style-menu'); - if (show == null) { show = m.className == "hide"; } - m.className = show ? "show" : "hide"; + toggleClassShow(m, show); } |