aboutsummaryrefslogtreecommitdiff
path: root/html/haddock-util.js
diff options
context:
space:
mode:
Diffstat (limited to 'html/haddock-util.js')
-rw-r--r--html/haddock-util.js36
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);
}