X-Git-Url: http://git.vanrenterghem.biz/git.ikiwiki.info.git/blobdiff_plain/99b59f2d62a8e431d84a469ab31a8da101333b26..219afc3f9c646f323c9a51744b6fba43f04786db:/IkiWiki/Plugin/toggle.pm diff --git a/IkiWiki/Plugin/toggle.pm b/IkiWiki/Plugin/toggle.pm index ef30fe6b6..e203defb0 100644 --- a/IkiWiki/Plugin/toggle.pm +++ b/IkiWiki/Plugin/toggle.pm @@ -39,18 +39,22 @@ function toggle(s) { style.display = "none"; } -function getElementsByClass(c) { +function getElementsByClass(cls, node, tag) { + if (document.getElementsByClass) + return document.getElementsByClass(cls, node, tag); + if (! node) node = document; + if (! tag) tag = '*'; var ret = new Array(); - var pattern = new RegExp("(^|\\s)"+c+"(\\s|$)"); - var els = document.getElementsByTagName('*'); - for (i = 0, j = 0; i < els.length; i++) { + var pattern = new RegExp("(^|\\s)"+cls+"(\\s|$)"); + var els = node.getElementsByTagName(tag); + for (i = 0; i < els.length; i++) { if ( pattern.test(els[i].className) ) { - ret[j] = els[i]; - j++; + ret.push(els[i]); } } return ret; } + //--> EOF @@ -106,7 +110,7 @@ sub preprocess_toggleable (@) { #{{{ sub format (@) { #{{{ my %params=@_; - if ($params{content}=~s!(