From 59a4abbd5c78832f9f28cfe0ee8f8cced3486090 Mon Sep 17 00:00:00 2001 From: Jan Schneider Date: Sat, 26 Jun 2010 15:30:00 +0200 Subject: [PATCH] Migrate to prototype. --- wicked/js/toc.js | 33 +++++++-------------------------- 1 file changed, 7 insertions(+), 26 deletions(-) diff --git a/wicked/js/toc.js b/wicked/js/toc.js index 8533b8c78..4419dff92 100644 --- a/wicked/js/toc.js +++ b/wicked/js/toc.js @@ -1,35 +1,16 @@ /** - * Javascript code for making the ToC collapsible. + * Javascript code for making the TOC collapsible. * * See the enclosed file COPYING for license information (GPL). If you * did not receive this file, see http://www.fsf.org/copyleft/gpl.html. */ -addEvent(window, 'load', wicked_toc); -function wicked_toc() -{ - var toc = document.getElementById('toc'); - var ol, h2; - for (var i = 0; i < toc.childNodes.length; ++i) { - var tagName = toc.childNodes[i].tagName.toUpperCase(); - if (tagName == 'OL') { - ol = toc.childNodes[i]; - } else if (tagName == 'H2') { - h2 = toc.childNodes[i]; - } - } - +document.observe('dom:loaded', function() { + var h2 = $('toc').down('h2'), + ol = $('toc').down('ol'); if (!ol) { return; } - - h2.style.cursor = 'pointer'; - - addEvent(h2, 'click', function() { - if (ol.style.display != 'none') { - ol.style.display = 'none'; - } else { - ol.style.display = ''; - } - }); -} + h2.setStyle({ cursor: 'pointer' }); + h2.observe('click', ol.toggle.bind(ol)); +}); -- 2.11.0